ArcObjects Library Reference (Geometry)  

IESRISpatialReferenceGEN.ExportToESRISpatialReference Method

Exports this spatial reference component to a buffer.

[Visual Basic .NET]
Public Sub ExportToESRISpatialReference ( _
    ByRef str As String, _
    ByRef cBytesWrote As Integer _
)
[C#]
public void ExportToESRISpatialReference (
    ref string str,
    ref int cBytesWrote
);
[C++]
HRESULT ExportToESRISpatialReference(
  BSTR* str,
  long* cBytesWrote
);
[C++]

Parameters

str [out]   str is a parameter of type BSTR cBytesWrote [out]   cBytesWrote is a parameter of type long

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.
[C#]

private void CreateESRISpatialReferenceInfo()
{
    IESRISpatialReferenceGEN esriSpatialReference = new GeographicCoordinateSystemClass();
    ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
    //Predefined GeogCoordSys - esriSRGeoCS_Airy1830
    IGeographicCoordinateSystem geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Airy1830);
    ISpatialReference3 spatialReference = geographicCoordinateSystem as ISpatialReference3;
    IVerticalCoordinateSystem verticalCoordinateSystem = spatialReferenceFactory.CreateVerticalCoordinateSystem((int)esriSRVerticalCSType.esriSRVertCS_Alicante);
    spatialReference.VerticalCoordinateSystem = verticalCoordinateSystem;
    esriSpatialReference = spatialReference as IESRISpatialReferenceGEN;
    String buffer = "";
    int bytesWrote;
    esriSpatialReference.ExportToESRISpatialReference(out buffer, out bytesWrote);

    ISpatialReferenceInfo spatialReferenceInfo;
    spatialReferenceFactory.CreateESRISpatialReferenceInfo(buffer, out spatialReferenceInfo, out bytesWrote);
    System.Windows.Forms.MessageBox.Show(spatialReferenceInfo.Name);
}

[Visual Basic .NET]

    Sub CreateESRISpatialReferenceInfo()
        Dim pSpatialReferenceFactory3 As ISpatialReferenceFactory3
        pSpatialReferenceFactory3 = New SpatialReferenceEnvironment
        Dim pESRISpatialReference As IESRISpatialReferenceGEN
        Dim pSRI As ISpatialReferenceInfo
        Dim pGeographicCoordinateSystem As IGeographicCoordinateSystem
        Dim pVCS As IVerticalCoordinateSystem
        Dim pSR3 As ISpatialReference3
        Dim pBytes As Long
        Dim pBuffer As String
        pBuffer = ""
        pESRISpatialReference = New GeographicCoordinateSystem
        pSpatialReferenceFactory3 = New SpatialReferenceEnvironment
        'Predefined GeogCoordSys - esriSRGeoCS_Airy1830
        pGeographicCoordinateSystem = pSpatialReferenceFactory3.CreateGeographicCoordinateSystem(esriSRGeoCSType.esriSRGeoCS_Airy1830)
        pSR3 = pGeographicCoordinateSystem
        pVCS = pSpatialReferenceFactory3.CreateVerticalCoordinateSystem(esriSRVerticalCSType.esriSRVertCS_Alicante)
        pSR3.VerticalCoordinateSystem = pVCS

        pESRISpatialReference = pSR3
        pESRISpatialReference.ExportToESRISpatialReference(pBuffer, pBytes)

        pSpatialReferenceFactory3.CreateESRISpatialReferenceInfo(pBuffer, pSRI, pBytes)
        Debug.Print(pSRI.Name + ", " + pSRI.Abbreviation)
    End Sub

See Also

IESRISpatialReferenceGEN Interface