MongoDB中,记录地里位置信息的数据,如何聚合后查询得到结果
某草草
某草草 2017-06-14 10:54:45
0
2
820

车辆监控项目,记录车辆GPS定位数据,我们在检测浙江省高速道路的时候,GPS热力图显示,结果变成这样了,如图:

MongoDB里,存储数据的格式是这样滴
{

"_id" : ObjectId("593e58b8d1eece32080d6632"), "x" : 121.494230074275, "y" : 29.6998736880818

}

通过查询后,返回json格式是这样的:

{"lng":"121.98826732480999624","lat":"29.88628748150999925","count":1},{"lng":"122.00810540175000085","lat":"29.82699952501900142","count":1},{"lng":"122.00148151521000273","lat":"29.82556419141700133","count":1},{"lng":"122.09566082377000384","lat":"29.86581727309599898","count":1},{"lng":"121.99538599286999840","lat":"29.82299558164600128","count":1},{"lng":"121.98481996031999586","lat":"29.81670171825599880","count":1},{"lng":"121.97925141116000702","lat":"29.81335324424399857","count":1},{"lng":"121.96654822066000179","lat":"29.80203305154499915","count":1},{"lng":"121.96121962927000482","lat":"29.79876428024099866","count":1},{"lng":"121.94649301222000304","lat":"29.79243430893799882","count":1},{"lng":"121.94300499519999903","lat":"29.79132642105500040","count":1},{"lng":"121.93624256578000598","lat":"29.79261412193099900","count":1},{"lng":"121.92976345401000060","lat":"29.79086531288499984","count":1},{"lng":"121.91419359308000026","lat":"29.78270234553000151","count":1}

请问,有什么查询的方法,能够聚合一个点位的数据后,得到查询结果,就是后面的count值是聚合后的值,想到的类似mysql中的group by,但这又不是简单的group by,不知道有什么解决方案

某草草
某草草

全部回复 (2)
Ty80

个人理解是,一种思路是,在地图里面划分很多区域,对落在每个区域里面的位置($geowithin)的个数进行统计。

供参考。

Love MongoDB! Have fun!

    淡淡烟草味

    每日过来提交一下

      最新下载
      更多>
      网站特效
      网站源码
      网站素材
      前端模板
      关于我们 免责声明 Sitemap
      PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!