在许多段中找到距离某个点最近的段的算法(反向地理编码)
我有一组由两个点定义的线段。给定一个点,我如何找到距离该点最近的线段?
我已经编写了一个计算点和线段之间距离的算法。 无论如何,计算每个路段的距离,然后选择距离最小的路段并不是很有效:(
由于这些路段代表街道,这实际上是一个反向地理编码问题,所以我希望这个问题有众所周知的解决方案...
谢谢很多!
I have a set of segments defined by two points. Given a point how can I discover the closest segment to such point?
I have already written an algorithm that computes the distance between a point and a segment.
Anyway calculating such distance for each segment and then choose the segment with the lowest distance is not really efficient :(
Since the segments represent streets this is actually a Reverse GeoCoding problem so I hope there are well-known solutions to this problem...
THANKS A LOT!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用网格、kd 树、四叉树或类似的二元空间划分方法。然后,从您的点所在的树单元开始,开始探索线段,直到该点到包含该线段的单元格的距离大于迄今为止找到的最小距离。
http://en.wikipedia.org/wiki/Binary_space_partitioning
(当然,这是假设路段/街道很少发生变化,但您有很多点需要定位)。
Use a grid, kd-tree, quadtree or similar binary space partitioning method. Then, starting from the tree cell that your point lies in, start exploring segments until the distance from the point to the cell containing the segment is greater than the smallest distance found so far.
http://en.wikipedia.org/wiki/Binary_space_partitioning
(This is, of course, assuming that the segments/streets change only very rarely, but you have a lot of points to locate).