I have a MultilineShape typed shape file, and then a list of anchor points that we know for sure are located on the MultilineShape, between every two anchor points, we want to add more points, those new added points will also be on the line, with the same length along the line. The problems are:
those two anchor points could be located on two different lines, lets say if we know those two lines are connected, then for all the anchor points in the list, how to decide which point is the first anchor point, and which point is the next anchor point? obviously we cannot use the distance to decide as the nearest point in distance would have longer length along the line.
can someone help with this problem? thanks in advance.
Interpolation along a MultilineShape?
Hi David,
would you please try the below pseudo-code to see if it works for you?
MultilineShape multilineshapes =
new
MultilineShape();
foreach
(LineShape line
in
multilineshapes.Lines)
{
Collection<Vertex> newVertexes =
new
Collection<Vertex>();
Collection<Vertex> oldvertexes = line.Vertices;
int
currentIndex = 0;
newVertexes.Add(line.Vertices[0]);
while
(currentIndex < line.Vertices.Count)
{
Vertex currentVertext = line.Vertices[currentIndex];
Vertex nextVertext = line.Vertices[currentIndex + 1];
Collection<Vertex> addedVertexes = GenerateNewVertex(currentVertext,nextVertext,distance);
newVertexes.AddRange(addedVertexes);
}
newVertexes.Add(line.Vertices[line.Vertices.Count - 1]);
line.Vertices.Clear();
line.Vertices.addRange(newVertexes);
}
You still need do more modifications on above, but the key is the vertexes in each single line are ordered.
I may misunderstand your needs, but if yes, please feel free to correct me.
Thanks,
Troy