code sample for splitting a line feature into two lines at a specified point.

2704
3
05-07-2012 12:20 PM
GeorgeShi
New Contributor
Hi All,

Could you point me to any C# code samples for splitting a polyline (IPolyline) into two at a specified point (with an IPoint reference)?


Thanks in advance!


George S.
0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor
It's a little old (and not in C#), but here's an example of splitting a line with points
0 Kudos
by Anonymous User
Not applicable
For a simple line and point you can just use IFeatureEdit2.SplitWithUpdate to split the line and update the attributes.

IFeatureEdit2 featureEdit = lineFeature as IFeatureEdit2;
featureEdit.SplitWithUpdate(splitPoint);


Alternatively you can keep the returned ISet to do something useful, like keep all the lines selected in this example.
           
IFeatureEdit2 featureEdit = lineFeature as IFeatureEdit2;
//select features after split
featSelection.Add(lineFeature);
ISet newSet = featureEdit.SplitWithUpdate(splitPoint);
newSet.Reset();
IFeature newFeat = newSet.Next() as IFeature;
featSelection.Add(newFeat);
0 Kudos
GeorgeShi
New Contributor
thank you both!
0 Kudos