ArcObjects Library Reference  (Geometry)    

ISpatialReference2 Interface

Provides access to additional members that control a SpatialReference.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Extends the ISpatialReference interface by adding functions to compare precision (resolution) of two spatial references, and round off coordinate data to the current resolution.

Members

Description
Read-only property Abbreviation The abbreviated name of this spatial reference component.
Read-only property Alias The alias of this spatial reference component.
Method ApplyPrecision Applies the measure and z value precisions.
Method ApplyXYPrecision Applies the XY precision.
Method Changed Notify this object that some of its parts have changed (parameter values, z unit, etc.).
Read-only property FactoryCode The factory code of the spatial reference.
Method GetDomain The XY domain extent.
Method GetFalseOriginAndUnits Get the false origin and units.
Method GetMDomain The measure domain extent.
Method GetMFalseOriginAndUnits Get the measure false origin and units.
Method GetZDomain The Z domain extent.
Method GetZFalseOriginAndUnits Get the Z false origin and units.
Method HasMPrecision Returns true when m-value precision information has been defined.
Method HasXYPrecision Returns true when (x,y) precision information has been defined.
Method HasZPrecision Returns true when z-value precision information has been defined.
Method IsMPrecisionEqual Returns true if the measure precisions of the two spatial references are the same.
Method IsPrecisionEqual Returns TRUE when the precision information for the two spatial references is the same.
Method IsXYPrecisionEqual Returns true if the XY precisions of the two spatial references are the same.
Method IsZPrecisionEqual Returns true if the Z precisions of the two spatial references are the same.
Read-only property Name The name of this spatial reference component.
Read-only property Remarks The comment string of this spatial reference component.
Method SetDomain The XY domain extent.
Method SetFalseOriginAndUnits Set the false origin and units.
Method SetMDomain The measure domain extent.
Method SetMFalseOriginAndUnits Set the measure false origin and units.
Method SetZDomain The Z domain extent.
Method SetZFalseOriginAndUnits Set the Z false origin and units.
Read/write property ZCoordinateUnit The unit for the Z coordinate.

Inherited Interfaces

Interfaces Description
ISpatialReference Provides access to members that control a SpatialReference.
ISpatialReferenceInfo Provides access to members that control the properties common to all components of a spatial reference system.

CoClasses that implement ISpatialReference2

CoClasses and Classes Description
GeographicCoordinateSystem Creates a geographic coordinate system.
ProjectedCoordinateSystem Creates a projected coordinate system.
UnknownCoordinateSystem Creates an unknown coordinate system.
[C#]
        public static bool CompareSpatialRefs2(ISpatialReference2 sourceSR, ISpatialReference2 targetSR)
        {
            IClone sClone = sourceSR as IClone;
            IClone tClone = targetSR as IClone;
            // first level test compares the coordinate system component  
            if (!sClone.IsEqual(tClone))
                return false;
            // Can also check just Horizontal Coordinate System equality 
            bool SREqual = true;
            ICompareCoordinateSystems compare = sourceSR as ICompareCoordinateSystems;
            compare.IsEqualNoVCS(targetSR, ref SREqual);
            if (!SREqual)
                return false;
            return true;
        }
[Visual Basic 6.0]

The following code example demonstrates how to compare two spatial references. It uses the ISpatialReference2 interface to compare the XY precision in addition to the coordinate system. This is the same type of comparison that is performed by the Copy/Paste functionality in ArcCatalog.

Public Function CompareSpatialReferences(ByVal pSourceSR As ISpatialReference, ByVal pTargetSR As ISpatialReference) As Boolean
 
  Dim pSourceClone As IClone
  Dim pTargetClone As IClone
  Dim bSREqual As Boolean
 
  Set pSourceClone = pSourceSR
  Set pTargetClone = pTargetSR
 
  'Compare the coordinate system component of the spatial reference
  bSREqual = pSourceClone.IsEqual(pTargetClone)
 
  'If the comparison failed, return false and exit
  If Not bSREqual Then
    CompareSpatialReferences = False
    Exit Function
  End If
 
  'We can also compare the XY precision to ensure the spatial references are equal
  Dim pSourceSR2 As ISpatialReference2
  Dim bXYIsEqual As Boolean
 
  Set pSourceSR2 = pSourceSR
  bXYIsEqual = pSourceSR2.IsXYPrecisionEqual(pTargetSR)
 
  'If the comparison failed, return false and exit
  If Not bXYIsEqual Then
    CompareSpatialReferences = False
    Exit Function
  End If
 
  CompareSpatialReferences = True
 
End Function

 


Feedback Send feedback on this page