根据纬度、经度获取邮政编码
我已从 http://www.ordnancesurvey.co 下载了英国邮政编码列表。 uk/oswebsite/opendata/index.html 并将其安装在 MSSQL 2005 数据库中。该表由邮政编码、纬度和经度组成。我需要一种有效的方法来获取距给定纬度/经度最近的邮政编码。计算两点之间的距离并选择最小的距离意味着循环遍历每个查询的所有数据。大约有 170 万个条目。谢谢。
I have downloaded the UK postcode list from http://www.ordnancesurvey.co.uk/oswebsite/opendata/index.html and installed it in a MSSQL 2005 database. The table consists of postcode, latitude and longitude. I need an efficient method to get the nearest postcode to a given lat/long. Calculating the distance between two points and choosing the smallest would mean cycling through all the data for each query. There are approx 1.7 million entries. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过首先使用“圆近似”过滤查询来加快计算速度 - 即。返回确定半径
delta
内的所有邮政编码。基本查询应该是这样的:现在剩下的数据量应该更容易管理。
另外,如果您正在开发一些“关键任务”,请务必查看 PostGIS。他们可能已经解决了您可能遇到的一些问题......;)
You could fasten up your calculations by first filter your query using a "circle approximation" - ie. return all postcodes inside a determined radius
delta
. The basic query should be something like this:And now amount of data left should be a bit more manageable.
Also, if you are developing something "mission critical", be sure to take a look at PostGIS. It might be that they have already solved some problems you might run into... ;)