开发者

Get all cities in latitude/longitude range

I have a list of cities, each of them obviously has a longitude and latitude.

Now selecting one of these cities, i want to obtain all the other cities that have a longitude / latitude开发者_开发技巧 in a range of 50 km from the selected city. What formula should I use?

I am only interested in the mathematical formula to convert km to latidutine and longitude from a know city position

Then i will calculate the maximum and minimum latitude and longitude, for considering an acceptable range. (like a Square)

tks


I don't want to calculate the distance between two points!+ I want to calculate min e max latitude and longitude and then filter my cities by this coordinates.

I've found a sample in Php that worked for me. (i've ported it to C#)

http://blog.fedecarg.com/2009/02/08/geo-proximity-search-the-haversine-equation/


You'd probably want to use the Haversine formula.

You may want to check out the following articles for further reading and for a few implementations in various languages:

  • Calculate distance, bearing and more between Latitude/Longitude points by Chris Veness.
  • Calculate Distance Between Two Points on a Globe in 11 languages.


You are looking for the Great Circle calculation. It returns the shortest distance across the surface of the planet given two points and their respective latitude and longitude. There is a great Wikipedia article here: http://en.wikipedia.org/wiki/Great-circle_distance

There is a pretty decent implementation - source code in javascript here: http://trac.osgeo.org/openlayers/wiki/GreatCircleAlgorithms

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜