如何找到给定半径内最近的城市?
您是否知道一些实用程序或网站,我可以在其中输入美国城市、州和以英里为单位的径向距离作为输入,然后它会返回该半径内的所有城市?
谢谢!
Do you know some utility or a web site where I can give US city,state and radial distance in miles as input and it would return me all the cities within that radius?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我是这样做的。
您可以获得城市、街道、邮政编码及其纬度和经度的列表。
(我记不起我们从哪里得到的)
编辑: http:// /geonames.usgs.gov/domestic/download_data.htm
就像上面提到的人可能会工作。
然后,您可以编写一个方法来根据半径计算最小和最大纬度和经度,并查询最小和最大之间的所有城市。 然后循环并计算距离并删除任何不在半径内的内容
这是我的代码的摘录,希望您能看到发生了什么。 我从一个邮政编码(数据库中的一张表)开始,然后拉回可能的匹配项,最后剔除那些不在半径内的人。
Here is how I do it.
You can obtain a list of city, st, zip codes and their latitudes and longitudes.
(I can't recall off the top of my head where we got ours)
edit: http://geonames.usgs.gov/domestic/download_data.htm
like someone mentioned above would probably work.
Then you can write a method to calculate the min and max latitude and longitudes based on a radius, and query for all cities between those min and max. Then loop through and calculate the distance and remove any that are not in the radius
There's an excerpt of my code, hopefully you can see what's happening. I start out with one ZipCodes( a table in my DB), then I pull back possible matches, and finally I weed out those who are not in the radius.
Oracle、PostGIS、带有GIS扩展的mysql、带有GIS扩展的sqlite都支持这种查询。
如果您没有数据集,请查看:
http://www.geonames.org/
Oracle, PostGIS, mysql with GIS extensions, sqlite with GIS extensions all support this kind of queries.
If you don't have the dataset look at:
http://www.geonames.org/
看一下 xmethods.net 上广告的此 Web 服务。 它需要订阅才能实际使用,但声称可以满足您的需要。
问题描述中所宣传的方法:
http://xmethods.net/ve2/ ViewListing.po?key=uuid:5428B3DD-C7C6-E1A8-87D6-461729AF02C0
Take a look at this web service advertised on xmethods.net. It requires a subscription to actually use, but claims to do what you need.
The advertised method in question's description:
http://xmethods.net/ve2/ViewListing.po?key=uuid:5428B3DD-C7C6-E1A8-87D6-461729AF02C0
您可以从 http://geonames.usgs.gov 获取一个非常好的地理定位城市/地名数据库 - find一个适当的数据库转储,将其导入到您的数据库中,然后执行您需要的查询类型非常简单,特别是如果您的 DBMS 支持某种空间查询(例如 Oracle Spatial, MySQL 空间扩展、PostGIS 或 SQLServer 2008)
另请参阅:如何进行基于位置的搜索
You can obtain a pretty good database of geolocated cities/placenames from http://geonames.usgs.gov - find an appropriate database dump, import it into your DB, and performing the kind of query your need is pretty straightforward, particularly if your DBMS supports some kind of spatial queries (e.g. like Oracle Spatial, MySQL Spatial Extensions, PostGIS or SQLServer 2008)
See also: how to do location based search
我没有网站,但我们已在 Oracle 中将其实现为数据库功能,并在 SAS 中将其实现为统计宏。 它只需要一个包含所有城市及其经纬度的数据库。
I do not have a website, but we have implemented this both in Oracle as a database function and in SAS as a statistics macro. It only requires a database with all cities and their lat and long.
也许这会有所帮助。 该项目的配置单位是公里。 您可以在 CityDAO.java 中修改这些
“LocationFinder\src\main\resources\json\cities.json”文件包含比利时的所有城市。 如果您愿意,也可以删除或创建条目。 只要不更改名称和/或结构,就不需要更改代码。
请务必阅读自述文件 https://github.com/GlennVanSchil/LocationFinder
Maybe this can help. The project is configured in kilometers though. You can modify these in CityDAO.java
The "LocationFinder\src\main\resources\json\cities.json" file contains all cities from Belgium. You can delete or create entries if you want too. As long as you don't change the names and/or structure, no code changes are required.
Make sure to read the README https://github.com/GlennVanSchil/LocationFinder