Find nearest edge in graph

前端 未结 5 1110
慢半拍i
慢半拍i 2021-02-04 02:43

I want to find the nearest edge in a graph. Consider the following example: \"yellow:

5条回答
  •  既然无缘
    2021-02-04 03:16

    There are spatial query structures which are appropriate for other types of data than points. The most general is the "R-tree" structure (and its many, many variants), which will allow you to store the bounding rectangles of your line segments. You can then search outward from your query points, examining the segments in the bounding rectangles and stopping when the nearest remaining rectangle is further than the closest line encountered so far. This could have poor performance when there are many long line segments overlapping, but for a PSLG such as you seem to have here, that shouldn't happen.

    Another option is to use the segments to define a BSP tree, and scan outwards from your point to find all the "visible" lines. This in turn will be problematic if your point can see many edges.

提交回复
热议问题