连接近距离用户的最佳方式? (纬度、经度)
我创建了一个 Android 应用程序,可以将跑步者紧密地连接起来。我使用了 Tornado ServerWeb (Python) 和 No-SQL 数据库。
我的解决方案:
将用户的所有 {lon,lat} (定期更新)存储在 DataLocation 中。
当用户想要查看他周围的用户时,它会调用我的服务器的特定函数,该函数从他当前的位置创建一个边界框。下一步是返回位于其边界框中的 DataLocation 用户。
这是个好办法吗?有什么建议吗? GeoJSON 对我有用吗?我怎样才能在Python中做到这一点?
I create an android app which connect runners in closed proximity. I used a Tornado ServerWeb (Python) and a No-SQL database.
My solution:
Store all the {lon,lat} (regularly updated) of users in a DataLocation.
When a user want to see users around him, it calls specific function to my server which make a bounding box from his current position. The next step is to return the users of my DataLocation who are in his bounding box.
Is that a good way? Any advices? Is GeoJSON useful for me? How can I do that in Python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有图书馆并想自己计算距离,可以使用大圆来计算距离距离。公式并不太复杂。要查找特定半径内的一组点,您需要在数据库中查询距离(按大圆距离计算)小于半径的点。
此外,如果您想获得更好的速度,您将需要缓存中间计算,例如另一列中的正弦和余弦,因为这会加快速度,特别是如果您想在数据库级别执行查询。
If you don't have a library and want to do it yourself, you can calculate distance using the Great Circle Distance. The formula is not too complex. To find a group of points that are within a certain radius, you will need to query the database for points whose distance(as calculated by great circle distance) is less than your radius.
In addition, if you are wanting to get better speed, you will want to cache intermediate calculations, such as sines and cosines in another column, as that will speed things up, especially if you want to do the query at the database level.