AnsweredAssumed Answered

splitting zAware polylines

Question asked by basth on Mar 12, 2013
Latest reply on Mar 13, 2013 by basth
Hi All,

I'm trying to split a polyline by the boundaries of a polygon using IPolyCurve2.SplitAtPoints using C#.
The polyline I'm trying to split is zAware and holds elevation values at a regular interval.
After splitting the polyline I would obviously like to get the different parts and save them as new features in my feature class, then deleting the original one.
The problem is that when I try to set feature.shape to the geometry in my geometry collection made up of all the polyline parts, I get the error message that the geometry has no Z values.

Does anybody know how to solve this issue? I've looked around in the forum but all I found was code that doesn't deal with polylines that hold Z values.

Thank you very much!

Here is the code I'm using, passing in the original polyline, the point collection that holds all the intersection points with the polygon and the original feature class I create new features in.

public void SplitPolylineFeature(IFeature pPolylineFeature, IPointCollection pSplitPointCollection, IFeatureClass pFeatureClass)         {             //split the feature, each split makes a new part             IEnumVertex pEnumVertex = pSplitPointCollection.EnumVertices;             IPolycurve2 pPolyCurve = pPolylineFeature.Shape as IPolycurve2;             IEnumSplitPoint pEnumSplitPoint = pPolyCurve.SplitAtPoints(pEnumVertex, true, true, -1);             object Missing = Type.Missing;              if(pEnumSplitPoint.SplitHappened)             {                 //new geocoll for polycurve                 IGeometryCollection pGeometryCollection = pPolyCurve as IGeometryCollection;                  //loop through the parts of the split polyline                 for(int intPartCount = 0; intPartCount < pGeometryCollection.GeometryCount; intPartCount++)                 {                     IGeometryCollection pLineGeoColl = new PolylineClass();                     IGeometry pGeometry = pGeometryCollection.get_Geometry(intPartCount);                     //IZAware zAware1 = (IZAware)pGeometry;                     //zAware1.ZAware = true;                      pLineGeoColl.AddGeometry(pGeometry, ref Missing, ref Missing);                      IFeature pFeature = pFeatureClass.CreateFeature();                     try                     {                         pFeature.Shape = pLineGeoColl as IGeometry;  //code crashes here: Geometry has no Z values                         pFeature.Store();                     }                     catch (Exception ex)                     {                         MessageBox.Show("Error in WillisPolylines.SplitPolylineFeature: " + ex.Message);                     }                                     }             }             pPolylineFeature.Delete();         }