4

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.

9

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 to ITopologicalOperator.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). – Jay Cummins Jun 22 '11 at 16:51
1

It is also possible to use MergeGeometries from IConstructMerge interface.

I guess even that can solve the above issue!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.