1

I have a database with 10,000+ addresses that I want to sort by distance from a single lat/lon.

The addresses are sometimes full street addresses, and other times just zipcode, and sometimes city/state.

I don't know if the google geolocation api will work do to the large number of addresses, but if this does work, please let me know.

Another possibility would be to fetch the lat/lon for each address before I add it to the database, and can use the SQL Geography data type. This would allow sorting by distance (I think). Are there are free services that allow fetching lat/lon for addresses and allow storing that information in a database? I know googles terms of service disallow this use (storing of information retrieved from its services).

Are there any other ideas to be able to sort this list?

4

1 回答 1

0

这是如何根据纬度和经度计算距离的一个很好的链接: 计算两个纬度和经度地理坐标之间的距离

该链接将以双精度返回距离,然后您可以对其进行排序。我认为地理编码器可能是您正在寻找的: http: //geocoder.us/

编辑:您可以使用上面的链接来查询地理编码器以获取每个地址的纬度和经度,然后使用上面的 stackoverflow 帖子来了解如何计算距离,然后根据双打列表进行排序。例如,如果您已经预先计算了纬度/经度。数据库中的每个地址,然后作为一个新地址,使用服务器获取纬度/经度,然后编写一个存储过程来计算距离并按降序返回行。

于 2013-05-07T00:59:57.757 回答