A collection of GeographicTransformation objects, used in the GeographicTransformations2D and GeographicTransformations3D properties.

Namespace:  ESRI.ArcGISExplorer.Geometry

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public class GeographicTransformationCollection : IEnumerable
Visual Basic (Declaration)
Public Class GeographicTransformationCollection _
	Implements IEnumerable

Remarks

This class provides a strongly-typed collection of GeographicTransformation objects; the GeographicTransformations2D and GeographicTransformations3D properties use a GeographicTransformationCollection to manage a list of transformations which will be automatically used when displaying MapItems, if required.

You can add, remove, and replace transformations in the collection, and iterate through the existing transformations.

By default, there are no transformations in the 2D collection (GeographicTransformations2D), and one transformation in the 3D collection (GeographicTransformations3D). The 3D collection contains a default transformation from NAD to WGS 1984.

Examples

The code below shows how you can create a list of suitable GeographicTransformations for projecting geometries between two specific coordinate systems; one being the coordinate system of the current display - 2D or 3D, and the other being the coordinate system of a Layer, newLayer. Before attempting to add the new transformation to the CurrentGeographicTransformations collection of the Map, the FindTransform method is used to find out if there is an existing transformation for that coordinate system pair, as only one transformation can be specified for each unique pair of coordinate systems. Assuming the newLayer variable refers to a layer in the map, then this code ensures the transformation will be used when the map is displayed in the current mode (2D or 3D), increasing the accuracy of the reprojection of the data. The code also assumes you have using statements for the Geometry and Mapping namespaces.
CopyC#
// Get the current CoordinateSystem of the display (for 3D this is always WGS 1984).
ESRI.ArcGISExplorer.Mapping.MapDisplay disp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;
CoordinateSystem csDisp = disp.CurrentCoordinateSystem;

// Get the coordinate system of the layer.
CoordinateSystem csLayer = newLayer.CoordinateSystem;

// Find out if a transformation is already available between the CoordinateSystem of the new data and the
// CoordinateSystem of the 2D display.
GeographicTransformationCollection transforms = disp.CurrentGeographicTransformations;
GeographicTransformation existingTransform = transforms.FindCurrentTransform(csDisp, csLayer);
if (existingTransform == null)
{
    // No current transformation specified, so get suitable transformations between the two coordinate systems.
    System.Collections.Generic.IList<GeographicTransformation> suitableTrans = GeographicTransformation.GetTransformations(csDisp, csLayer);
    if (suitableTrans.Count > 0)
    {
        // Choose a transformation to use. The code below is hardcoded to use the first 
        // transformation found, but there may be more than one suitable transformation.
        transforms.Add(suitableTrans[0]);
        MessageBox.Show("Added the transformation " + suitableTrans[0].Name + Environment.NewLine +
            " between " + csLayer.Name + " and " + csDisp.Name,
            "Using New GeographicTransformation", MessageBoxButtons.OK, MessageBoxIcon.Information);

        // Alternatively, inform the user of the suitable transformations and let them choose.
    }
    else
    {
        // If no transformations are returned, there may be no transformation 
        // required between the systems - they may have the same underlying geographic CS.
        MessageBox.Show("No GeographicTransformations found between " + csLayer.Name + " and " + csDisp.Name,
            "No Suitable GeographicTransformations", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}
else
{
    MessageBox.Show("Already using the transformation " + existingTransform.Name + Environment.NewLine +
            " between " + csLayer.Name + " and " + csDisp.Name,
            "Existing GeographicTransformation", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
CopyVB.NET
' Get the current CoordinateSystem of the display (for 3D this is always WGS 1984).
Dim disp As ESRI.ArcGISExplorer.Mapping.MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
Dim csDisp As CoordinateSystem = disp.CurrentCoordinateSystem

' Get the coordinate system of the layer.
Dim csLayer As CoordinateSystem = newLayer.CoordinateSystem

' Find out if a transformation is already available between the CoordinateSystem of the new data and the
'CoordinateSystem of the 2D display.
Dim transforms As GeographicTransformationCollection = disp.CurrentGeographicTransformations
Dim existingTransform As GeographicTransformation = transforms.FindCurrentTransform(csDisp, csLayer)
If existingTransform Is Nothing Then
    ' No current transformation specified, so get suitable transformations between the two coordinate systems.
    Dim suitableTrans As System.Collections.Generic.IList(Of GeographicTransformation) = GeographicTransformation.GetTransformations(csDisp, csLayer)
    If suitableTrans.Count > 0 Then

        ' Choose a transformation to use. The code below is hardcoded to use the first 
        ' transformation found, but there may be more than one suitable transformation.
        transforms.Add(suitableTrans(0))
        MessageBox.Show("Added the transformation " & suitableTrans(0).Name & Environment.NewLine & _
                                        " between " & csLayer.Name & " and " & csDisp.Name, "Using New GeographicTransformation", MessageBoxButtons.OK, MessageBoxIcon.Information)

        ' Alternatively, inform the user of the suitable transformations and let them choose.


    Else

        ' If no transformations are returned, there may be no transformation 
        ' required between the systems - they may have the same underlying geographic CS.
        MessageBox.Show("No GeographicTransformations found between " & csLayer.Name & " and " & csDisp.Name, _
                                        "No Suitable GeographicTransformations", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End If

Else

    MessageBox.Show("Already using the transformation " & existingTransform.Name & Environment.NewLine & _
                " between " & csLayer.Name & " and " & csDisp.Name, _
                "Existing GeographicTransformation", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If

Inheritance Hierarchy

System..::.Object

  ESRI.ArcGISExplorer.Geometry..::.GeographicTransformationCollection

See Also