How to create a multipoint object from the vertices of a polyline


Creating a multipoint object from the vertices of a polyline

The following code example creates a multipoint with point elements being copies of the vertices of an existing polyline. It then offsets those elements five units to the right using one transformation method, then offsets them up another five units.
[Java]
static void transformPoint(IPolyline polyline)throws Exception{
    IPointCollection polylinePoints = (IPointCollection)polyline;
    IGeometry multipoint = new Multipoint();
    multipoint.setSpatialReferenceByRef(polyline.getSpatialReference());

    IPointCollection multipointPoints = (IPointCollection)multipoint;

    //Add copies of the polyline vertices to the multipoint.
    multipointPoints.addPointCollection(polylinePoints);

    IAffineTransformation2D affineTransformation = new AffineTransformation2D();
    affineTransformation.move(5, 0);

    ITransform2D transformee = (ITransform2D)multipoint;
    transformee.transform(esriTransformDirection.esriTransformForward,
        affineTransformation);

    //Shift up by 5. 
    transformee.move(0, 5);
    transformee.transform(esriTransformDirection.esriTransformForward,
        affineTransformation);
}






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