How to add point IDs to a polyline


Adding point IDs to a polyline

The following code example makes an existing polyline point ID aware and defines ID values for each of its vertices:
[Java]
static void AddPointIDs(IFeatureClass featureClass)throws Exception{
    IFeatureCursor featureCursor = featureClass.search(null, true);
    IFeature currentFeature = featureCursor.nextFeature();

    while (currentFeature != null){
        IPointIDAware pointIDAware = (IPointIDAware)currentFeature.getShape();
        pointIDAware.setPointIDAware(true);

        //The polyline is now point ID aware. It will persist its point IDs the next 
        //time it is saved.
        ISegmentCollection segmentCollection = (ISegmentCollection)pointIDAware;
        IEnumSegment segmentEnumeration = segmentCollection.getEnumSegments();

        ISegment currentSegment[] = new ISegment[1];
        int partIndex[] = new int[1];
        int segmentIndex[] = new int[1];
        segmentEnumeration.next(currentSegment, partIndex, segmentIndex);

        while (currentSegment != null){
            ISegmentID segmentID = (ISegmentID)currentSegment[0];
            segmentID.setIDs(segmentIndex[0], segmentIndex[0] + 1);
            segmentEnumeration.next(currentSegment, partIndex, segmentIndex);
        }

        currentFeature.setShapeByRef((IGeometry)pointIDAware);
        currentFeature.store();

        currentFeature = featureCursor.nextFeature();
    }
}






Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine