2

我有一个表(DB2 数据库),其中包含城市信息和相应的纬度和经度以及与城市相关的许多其他信息。我的要求是:

我的应用程序的输入将是纬度和经度,它们可能或许多不是存储在数据库中的精确纬度和经度。我需要在输入纬度和经度的帮助下从表中找到最近的城市信息。非常感谢任何帮助。

java中是否有可用的最近邻实现或SQL来处理这个

4

1 回答 1

2

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.

于 2010-12-02T03:01:45.243 回答