Provides access to members that generate well known string (WKS) representations of spatial reference objects.
Description
This interface can be used by developers who are familiar with the Projection Engine format for persisting string representations of these components. The ESRISpatialReferenceSize property returns the number of bytes required to hold the projection engine string representation of object implementing this interface. This number is guaranteed to be large enough but may be larger than needed. The number returned from ExportToESRISpatialReference is the exact number of bytes used in the buffer to hold the string. The example code, which demonstrates how to use this method, expects that a valid SpatialReference object has already been created.
The ImportFromESRISpatialReference method defines a spatial reference from its Projection Engine string representation. If you open up a PRJ file in Notepad that contains the string description of a ProjectedCoordinateSystem, you will see something like (but as a single line):
PROJCS["Test",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",
SPHEROID["WGS_1984",6378137,298.257223]],PRIMEM["Greenwich",0],
UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator"],
PARAMETER["false_easting",1000000],UNIT["Foot",0.3048]]
Members
Name | Description | |
---|---|---|
ESRISpatialReferenceSize | The number of bytes required to hold the persistant representation of this spatial reference component. | |
ExportToESRISpatialReference | Exports this spatial reference component to a buffer. | |
ImportFromESRISpatialReference | Defines this spatial reference component from the specified ESRISpatialReference buffer. |
IESRISpatialReferenceGEN.ESRISpatialReferenceSize Property
The number of bytes required to hold the persistant representation of this spatial reference component.
Public ReadOnly Property ESRISpatialReferenceSize As Integer
public int ESRISpatialReferenceSize {get;}
IESRISpatialReferenceGEN.ExportToESRISpatialReference Method
Exports this spatial reference component to a buffer.
Public Sub ExportToESRISpatialReference ( _
ByRef str As String, _
ByRef cBytesWrote As Integer _
)
public void ExportToESRISpatialReference (
ref string str,
ref int cBytesWrote
);
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);
}
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
IESRISpatialReferenceGEN.ImportFromESRISpatialReference Method
Defines this spatial reference component from the specified ESRISpatialReference buffer.
Public Sub ImportFromESRISpatialReference ( _
ByVal str As String, _
ByRef cBytesRead As Integer _
)
public void ImportFromESRISpatialReference (
string str,
ref int cBytesRead
);
Classes that implement IESRISpatialReferenceGEN
Classes | Description |
---|---|
AngularUnit | Creates a angular unit of measure. |
Datum | Creates a datum. |
GeographicCoordinateSystem | Creates a geographic coordinate system. |
LinearUnit | Creates a linear unit of measure. |
Parameter | Creates a parameter. |
PrimeMeridian | Creates a prime meridian. |
ProjectedCoordinateSystem | Creates a projected coordinate system. |
Projection | Creates a map projection. |
Spheroid | Creates a spheroid. |
UnknownCoordinateSystem | Creates an unknown coordinate system. |
VerticalCoordinateSystem | Creates a vertical coordinate system. |
VerticalDatum | Creates a vertical datum. |
Remarks
If working with a .NET language or Java, use this interface rather than IESRISpatialReference.
public void ExportToESRISpatialReference(ISpatialReference spatialReference)
{
long bytes = 0;
string buffer = null;
ISpatialReference projectedCoordinateSystem = spatialReference;
IESRISpatialReferenceGEN2 parameterExport = projectedCoordinateSystem;
parameterExport.ExportToESRISpatialReference2(buffer, bytes);
}
Public Sub ExportToESRISpatialReference(ByVal spatialReference As ISpatialReference)
Dim bytes As Long = Nothing
Dim buffer As String = Nothing
Dim projectedCoordinateSystem As ISpatialReference = spatialReference
Dim parameterExport As IESRISpatialReferenceGEN2 = projectedCoordinateSystem
parameterExport.ExportToESRISpatialReference2(buffer, bytes)
End Sub