List transformations by suitability

This sample demonstrates how to use the TransformationCatalog to get a list of available DatumTransformations that can be used to project a Geometry between two different SpatialReferences, and how to use one of the transformations to perform the GeometryEngine.Project operation. The TransformationCatalog is also used to set the location of files upon which grid-based transformations depend, and to find the default transformation used for the two SpatialReferences.

List datum transformations by suitability

Instructions

Tap on a listed transformation to re-project the point geometry (shown with a blue square) using the selected transformation. The reprojected geometry will be shown in red. If there are grid-based transformations for which projection engine files are not available locally, these will be shown in gray in the list. The default transformation is shown in bold. To download the additional transformation data, log on to your developers account (https://developers.arcgis.com), click the Download APIs button on the dashboard page, and download the Coordinate System Data archive from the Supplemental ArcGIS Runtime Data tab. Unzip the archive to the SampleData sub-folder of the ApplicationData directory, which can be found for each platform at run time with System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData).

Code

<UserControl x:Class="ArcGISRuntime.WPF.Samples.ListTransformations.ListTransformations"
             x:Name="_this"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
             xmlns:local="clr-namespace:ArcGISRuntime.WPF.Samples.ListTransformations">
    <Grid DataContext="{Binding ElementName=_this}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition Height="30"/>
                <RowDefinition Height="30"/>
                <RowDefinition Height="240"/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <TextBlock x:Name="InSpatialRefTextBox"
                       Grid.Row="0"
                       VerticalAlignment="Bottom"
                       Margin="10,0"/>
            <TextBlock x:Name="OutSpatialRefTextBox"
                       Grid.Row="1"
                       VerticalAlignment="Top"
                       Margin="10,0"/>
            <CheckBox x:Name="UseExtentCheckBox"
                      Grid.Row="2"
                      Content="Consider current extent"
                      IsChecked="False"
                      Checked="UseExtentCheckBox_CheckChanged"
                      Unchecked="UseExtentCheckBox_CheckChanged"/>
            <ListBox x:Name="TransformationsListBox"
                     Grid.Row="3"
                     Width="280" Height="240"
                     HorizontalAlignment="Center"
                     ItemsSource="{Binding Path=SuitableTransformationsList}"
                     SelectionChanged="TransformationsListBox_Selected">
                <ListBox.Resources>
                    <!-- Define triggers that will style the item differently if PE files are missing. -->
                    <Style TargetType="ListBoxItem">
                        <Style.Triggers>
                            <!-- Gray text if files are missing. -->
                            <DataTrigger Binding="{Binding Path=TransformationObject.IsMissingProjectionEngineFiles}" Value="True">
                                <Setter Property="Foreground" Value="Gray" />
                            </DataTrigger>
                            <!-- Blue text otherwise -->
                            <DataTrigger Binding="{Binding Path=TransformationObject.IsMissingProjectionEngineFiles}" Value="False">
                                <Setter Property="Foreground" Value="Blue" />
                            </DataTrigger>
                            <!-- Bold text for the default -->
                            <DataTrigger Binding="{Binding Path=IsDefault}" Value="True">
                                <Setter Property="FontWeight" Value="ExtraBold" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                    <!-- Bind to the Name property of each datum transformation. -->
                    <DataTemplate DataType="{x:Type local:DatumTransformationListBoxItem}">
                        <TextBlock Text="{Binding Path=TransformationObject.Name}"/>
                    </DataTemplate>
                </ListBox.Resources>
            </ListBox>
            <TextBlock x:Name="MessagesTextBox"
                       Grid.Row="4"
                       Width="280" Height="200"
                       TextWrapping="Wrap"/>
        </Grid>
        <esri:MapView x:Name="MyMapView"
                      Grid.Column="1" />
    </Grid>
</UserControl>


In this topic
  1. Instructions
  2. Code