Friday, 25 December 2015

Algorithm: move a source polyline to a reference polyline (completely or maybe partially)


In our system, there're the requirements that we want to move some source lines (with low precision) to reference lines (with high precision). Following pictures gives the normal use cases. The red one is a source line and the blue one is a reference line.


The red one is source line and the blue one is reference line


For this case, the source line would be moved partially, and the result would be as the green line shows:


Move result 1


There're situations that the source line need to be moved completely.


Example 2


Result:


Move result 2



Currently our solution is to project head/end point of the source line to the reference line and vice versa, then find projected points on the source and reference line. With these projected points, we can extract the needed part of the source and reference line and then combine them into a new one.


This works for most cases, but there are cases that this method does not work. Specifically, when either of the line has "C" like shape or the head point is very close to the end point. The next two pictures gives the scenario.


C like shape line


Applying my algorithm, we get the result:


Results


In a way it's understandable because the current algorithm just finds projected points and extracts lines.


What we expected is something like this:


Expected Results


So what I need more robust algorithm to do this so that it can also handle special cases like the preceding one. I have tried to project every points from a line to another and to find the two projected points that closest to the head/end point of the projected line, but there was no luck. Still I can find cases that give unexpected results.


Has anyone come across similar problems before? It would be also great if there is a software or library can do similar job. Any answer will be appreciated.





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...