How to construct a high or low precision spatial reference
Development licensing
Deployment licensing
ArcView
ArcView
ArcEditor
ArcEditor
ArcInfo
ArcInfo
Engine Developer Kit
Engine Runtime
Constructing a high or low precision spatial reference
The following code example determines whether you are constructing a high or low precision spatial reference, sets the default resolution, and the default tolerance:
[C#]
privatevoid ConstructCoordinateSystem(bool highPrecision)
{
ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
ISpatialReference3 spatialReference = spatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile("C:\\Program Files\\ArcGIS\\Coordinate Systems\\Geographic Coordinate Systems\\World\\WGS 1984.prj") as ISpatialReference3;
IControlPrecision2 controlPrecision = spatialReference as IControlPrecision2;
//Determines whether you are constructing a high or low.
controlPrecision.IsHighPrecision = highPrecision;
ISpatialReferenceResolution spatialReferenceResolution = spatialReference as ISpatialReferenceResolution;
//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 = spatialReference as ISpatialReferenceTolerance;
spatialReferenceTolerance.SetDefaultXYTolerance();
double xMin;
double xMax;
double yMin;
double yMax;
spatialReference.GetDomain(out xMin, out xMax, out yMin, out yMax);
System.Windows.Forms.MessageBox.Show("Domain : "+ xMin +", "+ xMax + ", "+ yMin +", "+ yMax);
}
[VB.NET]
PrivateSub ConstructCoordinateSystem(ByVal highPrecision AsBoolean)
Dim spatialReferenceFactory As ISpatialReferenceFactory3 = New SpatialReferenceEnvironmentClass()
Dim spatialReference As ISpatialReference3 = CType(spatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile _
("C:\\Program Files\\ArcGIS\\Coordinate Systems\\Geographic Coordinate Systems\\World\\WGS 1984.prj"), ISpatialReference3)
Dim controlPrecision As IControlPrecision2 = CType(spatialReference, IControlPrecision2)
'Determines whether you are constructing a high or low.
controlPrecision.IsHighPrecision = highPrecision
Dim spatialReferenceResolution As ISpatialReferenceResolution = CType(spatialReference, ISpatialReferenceResolution)
'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.Dim spatialReferenceTolerance As ISpatialReferenceTolerance = CType(spatialReference, ISpatialReferenceTolerance)
spatialReferenceTolerance.SetDefaultXYTolerance()
Dim xMin AsDoubleDim xMax AsDoubleDim yMin AsDoubleDim yMax AsDouble
spatialReference.GetDomain(xMin, xMax, yMin, yMax)
System.Windows.Forms.MessageBox.Show("Domain : " & xMin & ", " & xMax & ", " & yMin & ", " & yMax)
EndSub