查找最近邻居/纬度和经度
我有一个表(DB2 数据库),其中包含城市信息以及相应的纬度和经度以及与城市相关的许多其他信息。我的要求是:
我的应用程序的输入将是纬度和经度,这可能是也可能不是存储在数据库中的精确纬度和经度。我需要借助输入的纬度和经度从表中找到最近的城市信息。非常感谢任何帮助。
java中是否有可用的最近邻居实现 或者 SQL 来处理这个问题
I have a table (DB2 database) with city information and corresponding latitude and longitude and many other info related to the city. My requirement is:
Input to my application will be latitude and longitude which may or many not be exact lat and long stored in DB. I need to find the nearest City info from the table with the help of input latitude and longitude. Any help is highly appreciated.
Is there a nearest neighbor implementation in java available for this
or
SQL to handle this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 KD-Tree:
KDTree Implements in Java
在 SQL 中,您可以 Pythagoras 找到,然后按距给定点的距离排序,但这可能不会很有效。
You could use a KD-Tree:
KDTree Implementation in Java
Within SQL, you could Pythagoras to find, and then order by, the distance from a given point, but this likely wouldn't be very efficient.