ArcObjects Library Reference

Convert Spatial Reference From Low To High Precision Snippet

Converts an existing low precision spatial reference and returns a new high precision spatial reference.

[C#]

///<summary>Converts an existing low precision spatial reference and returns a new high precision spatial reference.</summary>
///  
///<param name="lowSpatialReference">An ISpatialReference interface that is the low spatial reference to be converted.</param>
///<param name="xyDoubler">A System.Int32 that is the amount of doubling (2^x) based on the input resolution; -1 produces a value close to the default resolution. Example: -1</param>
///<param name="mDoubler">A System.Int32 that determines doubling of m-resolution based on input m-resolution; the default is 0. Example: 0</param>
///<param name="zDoubler">A System.Int32 that determines doubling of z-resolution based on input z-resolution; default is 0. Example: 0</param>
///   
///<returns>An ISpatialReference interface that is the new high precision spatial reference.</returns>
///   
///<remarks></remarks>
public ESRI.ArcGIS.Geometry.ISpatialReference ConvertSpatialReferenceFromLowToHighPrecision(ESRI.ArcGIS.Geometry.ISpatialReference lowSpatialReference, System.Int32 xyDoubler, System.Int32 mDoubler, System.Int32 zDoubler)
{
  ESRI.ArcGIS.Geometry.IControlPrecision2 controlPrecision2 = lowSpatialReference as ESRI.ArcGIS.Geometry.IControlPrecision2;  // Dynamic Cast
  if (!controlPrecision2.IsHighPrecision)
  {
    ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3 spatialReferenceFactory3 = new ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass();
    ESRI.ArcGIS.Geometry.ISpatialReference highSpatialReference = spatialReferenceFactory3.ConstructHighPrecisionSpatialReference(lowSpatialReference, xyDoubler, zDoubler, mDoubler);

    return highSpatialReference;
  }
  return null;
}
[Visual Basic .NET]

'''<summary>Converts an existing low precision spatial reference and returns a new high precision spatial reference.</summary>
'''  
'''<param name="lowSpatialReference">An ISpatialReference interface that is the low spatial reference to be converted.</param>
'''<param name="xyDoubler">A System.Int32 that is the amount of doubling (2^x) based on the input resolution; -1 produces a value close to the default resolution. Example: -1</param>
'''<param name="mDoubler">A System.Int32 that determines doubling of m-resolution based on input m-resolution; the default is 0. Example: 0</param>
'''<param name="zDoubler">A System.Int32 that determines doubling of z-resolution based on input z-resolution; default is 0. Example: 0</param>
'''   
'''<returns>An ISpatialReference interface that is the new high precision spatial reference.</returns>
'''   
'''<remarks></remarks>
Public Function ConvertSpatialReferenceFromLowToHighPrecision(ByVal lowSpatialReference As ESRI.ArcGIS.Geometry.ISpatialReference, ByVal xyDoubler As System.Int32, ByVal mDoubler As System.Int32, ByVal zDoubler As System.Int32) As ESRI.ArcGIS.Geometry.ISpatialReference

  Dim controlPrecision2 As ESRI.ArcGIS.Geometry.IControlPrecision2 = CType(lowSpatialReference, ESRI.ArcGIS.Geometry.IControlPrecision2) ' Explicit Cast

  If Not controlPrecision2.IsHighPrecision Then

    Dim spatialReferenceFactory3 As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory3 = New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironmentClass
    Dim highSpatialReference As ESRI.ArcGIS.Geometry.ISpatialReference = spatialReferenceFactory3.ConstructHighPrecisionSpatialReference(lowSpatialReference, xyDoubler, zDoubler, mDoubler)

    Return highSpatialReference

  End If

  Return Nothing

End Function


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Geometry
  • ESRI.ArcGIS.System