Get spatialReference Domain, with XY Precision

المشرف العام

Administrator
طاقم الإدارة
I'm trying to get a spatialReference domain from prj file by using the function :

private void ConstructCoordinateSystem(bool highPrecision){ // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class. Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); System.Object obj = Activator.CreateInstance(t); ISpatialReferenceFactory3 spatialReferenceFactory = obj as ISpatialReferenceFactory3; // Create a geographic coordinate system from a .prj file that contains the well-known string. // You might need to update the file location. ISpatialReference3 spatialReference = spatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile( "C:\\Program Files\\ArcGIS\\Desktop10.0\\Coordinate Systems\\Geographic Coordinate Systems\\World\\WGS 1984.prj")as ISpatialReference3; // Determines whether you are constructing a high- or low-precision spatial reference. IControlPrecision2 controlPrecision = spatialReference as IControlPrecision2; controlPrecision.IsHighPrecision = highPrecision; ISpatialReferenceResolution spatialReferenceResolution = spatialReference as ISpatialReferenceResolution; ISpatialReferenceTolerance spatialReferenceTolerance = spatialReference as ISpatialReferenceTolerance; // The following three methods are key: construct horizon, then set the default x,y resolution and tolerance. spatialReferenceResolution.ConstructFromHorizon(); spatialReferenceResolution.SetDefaultXYResolution(); spatialReferenceTolerance.SetDefaultXYTolerance(); // Check the x,y spatial domain. 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);}When I use a prj file other than WGS, It woks perfectly.

But when I use a WGS file, in this case I need to add a test hasXYPrecision before calling spatialReference.GetDomain().

The problem is that the property hasXYPrecision returns always false, in both cases (WGS file and non-WGS file)

Any Ideas !



أكثر...
 
أعلى