How to work with the geometry environment

Working with the geometry environment

GeometryEnvironment provides a way of creating geometries from different inputs and setting or getting global variables for controlling the behavior of geometry methods. It also provides Java and .NET friendly versions of methods originally defined on other geometry objects (see the IGeometryBridge and IGeometryBridge2 interfaces).
The GeometryEnvironment object is a singleton object, so calling new several times does not create a new object each time. Instead, it returns a reference to the existing GeometryEnvironment object.
Using the geometry and spatial reference environments
The following code example uses the IGeometryBridge2 interface on the GeometryEnvironment singleton object to define a polyline from an array of WKSPoint structures. It also uses the SpatialReferenceEnvironment singleton object to create a predefined projected coordinate system. Some of the concepts discussed in the previous introduction are used here.
static IPolyline testGeometryEnvironment()throws Exception{
    ISpatialReferenceFactory spatialReferenceFactory = new

    //Create a projected coordinate system and define its domain, resolution, and x,y tolerance.
    ISpatialReferenceResolution spatialReferenceResolution = 
    ISpatialReferenceTolerance spatialReferenceTolerance = 
    ISpatialReference spatialReference = (ISpatialReference)

    //Create an array of WKSPoint structures starting in the middle of the x,y domain of the 
    //projected coordinate system.

    double[] xMin = new double[1];
    double[] xMax = new double[1];
    double[] yMin = new double[1];
    double[] yMax = new double[1];
    spatialReference.getDomain(xMin, xMax, yMin, yMax);

    double xFactor = (xMin[0] + xMax[0]) * 0.5;
    double yFactor = (yMin[0] + yMax[0]) * 0.5;

    _WKSPoint[] wksPoints = new _WKSPoint[10];
    for (int i = 0; i < wksPoints.length; i++){
        wksPoints[i].x = (xFactor + i);
        wksPoints[i].y = (yFactor + i);

    IPointCollection4 pointCollection = new Polyline();

    IGeometryBridge2 geometryBridge = new GeometryEnvironment();
    geometryBridge.addWKSPoints(pointCollection, wksPoints);

    IPolyline polyline = (IPolyline)pointCollection;

    return polyline;

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