how to calculate all points(longitude,latitude) within a given radius from given point (longitude,latitude)?

自闭症网瘾萝莉.ら 提交于 2019-12-10 11:59:15

问题


I have a given point (longitude,latitude) and I want to get all the points ranges that comes lets say 5 miles radius in given point?


回答1:


I'm just guessing here, but I think you'll need to find a different approach. If you're trying to do something like Foursquare, Google Maps, etc where it finds places within a 5-mile radius of your current location, I think you'll find that these services don't calculate all the points in that radius and then match them up to places at those points.

There would probably be some smarts behind the code that do something like this...

  1. Get the users current location
  2. Find the suburb (or failing that, find the city) that the current location exists in. Also find all the surrounding suburbs adjacent to this one.
  3. Find all the places within those suburbs, and calculate how far they are away from the current user location

This kind of process is one potential method that could be employed by these services. This deals with small subset of place comparisons, which is relatively quick to perform. Also, places on a map usually have a suburb/city associated with them anyway, so database lookups for places would be rather quick, as there would be an index that involves the suburb.

If you're aim is to do something like this, I would try to figure out a different way to compare points rather than simply trying to calculate everything in your radius.

And of course, there would also be plenty of specific algorithms for calculating this better, but that's not my area of expertise, and would be better suited to another forum. I'm not trying to say that this is the best way to do it, but there's plenty of other ways to do it that rely on known location data which would be quicker and smarter than your suggested requirement.



来源:https://stackoverflow.com/questions/10868501/how-to-calculate-all-pointslongitude-latitude-within-a-given-radius-from-given

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!