Create polyline z feature

2580
4
11-14-2011 11:45 AM
DaveZhang
New Contributor II
Hi, everyone

    I am trying to create the polyline z features in geodatabase, when I crete for 2 dimensional lines, I can always use code:

  IFeatureBuffer fb = featureCls.CreateFeatureBuffer();
  ...
  fb.shape = m_polyline;
  featureCursor.Insert(fb);
...

however, when deal with "polyline Z" the the above code throw exception "Item could not be found in this collection", can anyone help? thank you very much.

the codes I did looking the following:

            IPointCollection zpointColl = (IPointCollection)centerline;
            zawre = (IZAware)centerline;
            zawre.ZAware = true;
            centerline.FromPoint = startPoint;
            centerline.ToPoint = EndPoint;
            centerline.SpatialReference = spaRef;
            az = (IZ)zawre;
            az.MultiplyZs(1);
            az.InterpolateZsBetween(0, 0, 0, (zpointColl.PointCount - 1)); //Polyline always one part
            az.CalculateNonSimpleZs();
            try
            {
                IFeatureBuffer fb = CenterlineClass.CreateFeatureBuffer();
                fb.set_Value(fb.Fields.FindField("LineID"), pipeID);
                fb.set_Value(fb.Fields.FindField("Length"), length);
                //fb.Shape = centerline; //  (IGeometry)az
                int i = fb.Fields.FindField("shape");
                fb.Shape = centerline;  //This line always throw exception Item could not be found in this collection
                centerLineCur.InsertFeature(fb);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
0 Kudos
4 Replies
NeilClemmons
Regular Contributor III
Is your feature class z-aware?  If not, you can't store z values in it.  You can check this by looking at the feature class properties in ArcCatalog - Has Z will be true if the feature class is z-aware.
0 Kudos
DaveZhang
New Contributor II
Thank you for your reply.
Yes, the featureClass does contain Z values.
0 Kudos
NeilClemmons
Regular Contributor III
Make sure your geometry has z values.  NaN is not a valid z value, the z value must be a number.
0 Kudos
DaveZhang
New Contributor II
Thank you very much, this solved my problem, according to application logic, for some specific area, there can be NaN for Z.
0 Kudos