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 licensing | Deployment licensing |
---|---|
ArcView | ArcView |
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |
Engine Developer Kit | Engine Runtime |