車輛監控項目,記錄車輛GPS定位數據,我們在偵測浙江省高速道路的時候,GPS熱力圖顯示,結果變成這樣了,如圖:
{
"_id" : ObjectId("593e58b8d1eece32080d6632"),
"x" : 121.494230074275,
"y" : 29.6998736880818
}通過查詢後,返回json格式是這樣的:
{"lng":"121.98826732480999624","lat":"29.88628748150999925","count":1},{"lng":"122.00810540175000 "count":1} ,{"lng":"122.00148151521000273","lat":"29.82556419141700133","count":1},{"lng":"122.09566082377000lat38" count":1},{ "lng":"121.99538599286999840","lat":"29.82299558164600128","count":1},{"lng":"121.984819960319958603199586"lng" 1},{"lng ":"121.97925141116000702","lat":"29.81335324424399857","count":1},{"lng":"121.966548220660001795," {"lng": "121.96121962927000482","lat":"29.79876428024099866","count":1},{"lng":"121.94649301222000304"9." lng":"121.94300499519999903 ","lat":"29.79132642105500040","count":1},{"lng":"121.93624256578000598","lat":"29.792614121930999000," 0060", "lat":"29.79086531288499984","count":1},{"lng":"121.91419359308000026","lat":"29.78270234553000151","lat":"29.78270234553000151","lat":}##"
請問,有什麼查詢的方法,能夠聚合一個點位的資料後,得到查詢結果,就是後面的count值是聚合後的值,想到的類似mysql中的group by,但這又不是簡單的group by,不知道有什麼解決方案
個人理解是,一種想法是,在地圖裡面劃分很多區域,對落在每個區域裡面的位置($geowithin)的個數進行統計。
供參考。
Love MongoDB! Have fun!
每日來投稿一下