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