maps

Clojure: summing values in a collection of maps

自闭症网瘾萝莉.ら 提交于 2019-12-01 19:07:00
I am trying to sum up values of a collection of maps by their common keys. I have this snippet: (def data [{:a 1 :b 2 :c 3} {:a 1 :b 2 :c 3}] (for [xs data] (map xs [:a :b])) ((1 2) (1 2)) Final result should be ==> (2 4) Basically, I have a list of maps. Then I perform a list of comprehension to take only the keys I need. My question now is how can I now sum up those values? I tried to use "reduce" but it works only over sequences, not over collections. Thanks. ===EDIT==== Using the suggestion from Joost I came out with this: (apply merge-with + (for [x data] (select-keys x [:col0 :col1 :col2

SELECT From MySQL View With HAVING Clause Returns Empty Result Set

喜你入骨 提交于 2019-12-01 18:56:40
My business partner and I are having issues selecting from a MySQL view that has a HAVING clause. The query simply selects a few fields from the view, determines a distance dynamically with a few calculations, and aliases it as 'distance' - then limits the results to those rows with a distance less than a supplied variable. The distance is calculated using the Haversine formula, referenced by Google Maps: https://developers.google.com/maps/articles/phpsqlsearch Here is what I know: 1) When the HAVING clause is removed from the query, it returns all the results in the view successfully,

setting breaks and labels in ggplot

倾然丶 夕夏残阳落幕 提交于 2019-12-01 18:00:44
I have put together the Shiny app (below), showing a choropleth, which looks good except for the scientific notation on the legend. I would like the values to read: '$5,000,000', and '$4,000,000', etc, etc. The code boils down to g <-choroplethr(DF, lod="state", num_buckets = 1) g <- g + scale_fill_gradient(high = "springgreen4", low= "grey90", name="Sum") I attempted this: g <- q + scale_fill_gradient(high = "springgreen4", low= "grey90", name="Sum", labels = c("5,000,000", "4,000,000", "3,000,000", "2,000,000", "1,000,000")) But I got the error, Breaks and labels are different lengths I'm

Using std::unique_ptr inside a map as a key

北慕城南 提交于 2019-12-01 17:57:20
I am using Visual Studio 2012. I have a map that looks like this: std::map<std::string,std::map<std::unique_ptr<sf::Sound>,std::unique_ptr<sf::SoundBuffer>>> listSoundContainer; I'm trying to insert data like this: std::unique_ptr<sf::SoundBuffer> soundBuffer(new sf::SoundBuffer()); if (soundBuffer->loadFromFile("assets/sound/" + _fileName) != false) { std::unique_ptr<sf::Sound> sound(new sf::Sound(*soundBuffer)); typedef std::map<std::unique_ptr<sf::Sound>, std::unique_ptr<sf::SoundBuffer>> innerMap; listSoundContainer[_fileName].insert(innerMap::value_type(std::move(sound), std::move

Put pin on Google Map

最后都变了- 提交于 2019-12-01 17:54:54
I need to redirect user to Google Maps page and put some pin on defined location. The problem is that you could easily center map on some point with simple request: http://maps.google.com/maps?hl=en&ll=49.901711,32.508545&spn=5.959342,16.907959&z=7 But how to set a pin with such request ? You can do this with My Maps. Create or open a map. Click Edit to enter editing mode. Click the blue marker. Your cursor changes into a placemark icon with an "X" crosshairs. The crosshairs indicate where the placemark will fall. Move the cursor to the appropriate location. If you want to dismiss this

Put pin on Google Map

让人想犯罪 __ 提交于 2019-12-01 17:43:25
问题 I need to redirect user to Google Maps page and put some pin on defined location. The problem is that you could easily center map on some point with simple request: http://maps.google.com/maps?hl=en&ll=49.901711,32.508545&spn=5.959342,16.907959&z=7 But how to set a pin with such request ? 回答1: You can do this with My Maps. Create or open a map. Click Edit to enter editing mode. Click the blue marker. Your cursor changes into a placemark icon with an "X" crosshairs. The crosshairs indicate

Google Maps Android API v2 简介

瘦欲@ 提交于 2019-12-01 16:49:45
通过Google Maps Android API ,你可以给你的应用程序添加基于Google Maps数据的地图。那些API自动处理对于Google Maps服务器的访问,数据下载,地图显示,及对地图手势的相应。你也可以使用API调用来给一个基本的地图添加 markers,polygons,和overlays ,及改变一个特定的地图区域的用户视图。这些对象为地图位置提供了额外的信息,并允许用户与地图进行交互。这些API使你可以给一幅地图添加这样的一些图形: 固定在 地图上特定位置的图标(Markers)。 线段的集合 (Polylines). 闭合的线段 (Polygons)。 固定在地图上特定位置的Bitmap图形 (Ground Overlays)。 显示在基本地图片上面的一系列图像 (Tile Overlays)。 读者 这份文档适用于熟悉 Android开发 及面向对象编程概念的读者。你也应该熟悉用户眼中的 Google Maps 。 这份概念性的文档主要用于使你能够快速的开始浏览及使用 Google Maps Android API 开发应用程序。你也许也想要参考一些参考文档来了解类和方法特定的详细信息。 商用Google Maps Mobile SDK 商用 Google Maps Mobile SDK 许可,同时为iOS版 Google Maps SDK及

google play Service导入

时光总嘲笑我的痴心妄想 提交于 2019-12-01 16:47:50
Google Maps API v2 android版本开发 国内手机不支持google play Service相关问题解决--图文教程 google 地图在国内的使用让人很头痛,麻烦得要死,真搞不明白google为什么不能搞成跟百度地图那样让人使用。 后注:最近刷机后重新安装(默认root的)可以直接在市场上下载几个apk安装后使用google服务了。 google maps依赖于google play Service,而国内手机大部分都没预装google play Service,单独安装也安装不了,要root后经过几步安装系统app才能使用。 v2版本的申请api key方式让调试也变得复杂,开发的jar包不是用普通的导入方式就可以的,还需要导入工程,相对其他功能来说复杂了很多,网上搜索了很多资料,自己测试出了很多问题后总算在手机上看到地图了,这里记录一下,时间是2013-03-25.(以后可能现在可以的方法又不行了)。 把自己手机上最新的apk导出来传到博客上共享了 google服务相关apk-20130325.zip http://files.cnblogs.com/zdz8207/google%E6%9C%8D%E5%8A%A1%E7%9B%B8%E5%85%B3apk-20130325.zip 官方介绍地址 Google Maps Android API

@Value注入map、List,yaml格式

一笑奈何 提交于 2019-12-01 16:24:35
使用@Value注入map、List 实体类 @Value("#{'${list}'.split(',')}") private List<String> list; @Value("#{${maps}}") private Map<String,String> maps; 配置文件 list: topic1,topic2,topic3 maps: "{key1: 'value1', key2: 'value2'}" ps: 注意上面的map解析中,一定要用""把map所对应的value包起来,要不然解析会失败,导致不能转成 Map<String,String> 。 来源: CSDN 作者: 天天洗头的老哥儿 链接: https://blog.csdn.net/inquesiting/article/details/82984017

leaflet overlapping shapes opacity

家住魔仙堡 提交于 2019-12-01 16:22:32
问题 Below is a screenshot of a leaflet (http://leafletjs.com/) map with circles in them. The opacity of the circle is 0.5 and you can clearly see where they overlap. Is it possible to add a style rule such that the overlap doesn't have a higher opacity? It doesn't seem like leaflet has support for this but I wonder if such a thing is possible with css maybe? I like to be able to show what the red circle is over (ie, show what is beneath it) and have a homogenous colour. Assigning the opacity to