We are currently working on a project where we have to merge sections (polylines) to a route, but the big question is how to do this. We have currently tried adding those two as segmentcollections but it gives some rather wicked results.
2 Answers
Try using the ITopologicalOperator.Union method called on one of those polylines, passing the second one as its parameter. As long as the two polylines' endpoints meet, this approach should solve your problem.
EDIT: when performing union on multiple geometries (more than two), ITopologicalOperator.ConstructUnion is more efficient. You would call this method on an empty (freshly created) Polyline, passing an enumeration of all the polylines. This enumeration can be a GeometryBag instance as it implements IEnumGeometry.
-
I just switched back from
ITopologicalOperator.ConstructUnion
toITopologicalOperator.Union
because the merged geometry wasn't correct --vertices were moved (looked almost like the line was generalized except the vertex count didn't change). Jun 22, 2011 at 16:51
It is also possible to use MergeGeometries from IConstructMerge interface.
I guess even that can solve the above issue!