Sorting Geographical non-contiguous line segments along an implied curve

南笙酒味 提交于 2020-01-02 08:02:23

问题


Given:

A Set (for the sake of discussion we will call it S), which is an unordered collection of line segments. Each line segment is defined as two Longitude-Latitude end-points. While all of the line segments follow an implied curve, there are "gaps" between each of the segments, of various sizes. We refer to this curve as "implied" because it is not explicitly defined anywhere. The only information that we have available are the line segments contained within S.

Desired Result:

A sequence (for the sake of discussion we will call it R), which is an ordered collection of line segments. Each line segment is defined just as before, following the same implied curve as before but are now sorted by their position along the implied curve.

Context (i.e. "Why in the heck do I need this?"):

Basically I have incomplete geographical data that needs to be normalized and "completed" by doing some very simple interpolation to form a complete curve with no gaps. You might ask "why not just fit a curve to all the line segment end-points and be done with it?" -- well, that's not quite what I am after. The line segments are precisely where they should be located, and there is no need for the final curve to be "smooth". In fact, I intend to connect each of the segments with a straight-line (the crudest form of interpolation imaginable). But, connecting the segments is easy; the hard part is sorting them.

So In Summary: What would be a performant algorithm for going from S to R?


回答1:


You can use a k-d tree or a cover tree to find nearby points quickly.

If you need one continuous curve, I would suggest that a short traveling salesman path that incorporates the given edges would be a reasonable reconstruction. You could use 2-opt together with a k-d tree the way Bentley described (paywalled, sorry; I think there's also a description in this chapter on TSP local search by Johnson and McGeoch). The one modification needed would be to ensure that the initial path includes the given edges and that 2-opt moves do not remove those edges.




回答2:


I guess the implied curve has two properties. One is it is continious which means there is no segments. Second, its first derivative is continious which means there is no corners.

From second property we can say that if the angle between two line is closer to each other, they are more related. But i guess it is not enough. You can define a cost function which depends on the angle between lines and distance of lines.

C = A*angle + B*distance (where A,B should be tested and tuned)

Form this function you can find how much each line is related to another one. Than you can just simply connect the line with the strongest relations. Though i guess greedy algorithm does not mean you will always get the optimal solution.



来源:https://stackoverflow.com/questions/15823517/sorting-geographical-non-contiguous-line-segments-along-an-implied-curve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!