开发者

The best way to connect users in closed proximity ? (latitude, longitude)

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开发者_JAVA百科 advices? Is GeoJSON useful for me? How can I do that in Python?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜