How to construct a high- or low-precision spatial reference


Constructing a high- or low-precision spatial reference

The following code example determines whether you are constructing a high- or low-precision spatial reference and sets the default resolution and default tolerance:
[Java]
static void constructCoordinateSystem(boolean highPrecision)throws Exception{
    ISpatialReferenceFactory3 spatialReferenceFactory = new
        SpatialReferenceEnvironment();
    ISpatialReference3 spatialReference = (ISpatialReference3)
        spatialReferenceFactory.createESRISpatialReferenceFromPRJFile(
        "C:\\Program Files\\ArcGIS\\Coordinate Systems\\Geographic Coordinate Systems\\World\\WGS 1984.prj");

    IControlPrecision2 controlPrecision = (IControlPrecision2)spatialReference;

    //Determines whether you are constructing a high or low.
    controlPrecision.setIsHighPrecision(highPrecision);
    ISpatialReferenceResolution spatialReferenceResolution = 
        (ISpatialReferenceResolution)spatialReference;

    //These three methods are the keys, construct horizon, then set the default x,y resolution and tolerance.
    spatialReferenceResolution.constructFromHorizon();

    //Set the default x,y resolution value.
    spatialReferenceResolution.setDefaultXYResolution();

    //Set the default x,y tolerance value.
    ISpatialReferenceTolerance spatialReferenceTolerance = 
        (ISpatialReferenceTolerance)spatialReference;
    spatialReferenceTolerance.setDefaultXYTolerance();

    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);

    System.out.println("Domain : " + xMin[0] + ", " + xMax[0] + ", " + yMin[0] + 
        ", " + yMax[0]);
}


See Also:

How to import or export a spatial reference




Additional Requirements
  • This article assumes your project includes references to the ESRI Geometry assembly.

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