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
1546

被折叠的 条评论
为什么被折叠?



