diff --git a/src/Android/Xamarin.Android/ArcGISRuntime.Xamarin.Samples.Android.csproj b/src/Android/Xamarin.Android/ArcGISRuntime.Xamarin.Samples.Android.csproj
index 881d9bdc6d..7f6d9489b0 100644
--- a/src/Android/Xamarin.Android/ArcGISRuntime.Xamarin.Samples.Android.csproj
+++ b/src/Android/Xamarin.Android/ArcGISRuntime.Xamarin.Samples.Android.csproj
@@ -115,6 +115,7 @@
Designer
+
@@ -173,6 +174,7 @@
+
@@ -477,6 +479,9 @@
+
+
+
diff --git a/src/Android/Xamarin.Android/Samples/Data/GeodatabaseTransactions/GeodatabaseTransactions.cs b/src/Android/Xamarin.Android/Samples/Data/GeodatabaseTransactions/GeodatabaseTransactions.cs
index 905744da50..5c8ba80567 100644
--- a/src/Android/Xamarin.Android/Samples/Data/GeodatabaseTransactions/GeodatabaseTransactions.cs
+++ b/src/Android/Xamarin.Android/Samples/Data/GeodatabaseTransactions/GeodatabaseTransactions.cs
@@ -80,67 +80,88 @@ protected override void OnCreate(Bundle bundle)
private void CreateLayout()
{
// Button to start an edit transaction
- _startEditingButton = new Button(this);
- _startEditingButton.Text = "Start";
- var g = new GridLayout(this);
+ _startEditingButton = new Button(this)
+ {
+ Text = "Start"
+ };
_startEditingButton.Click += BeginTransaction;
// Button to stop a transaction
- _stopEditingButton = new Button(this);
- _stopEditingButton.Text = "Stop";
- _stopEditingButton.Enabled = false;
+ _stopEditingButton = new Button(this)
+ {
+ Text = "Stop",
+ Enabled = false
+ };
_stopEditingButton.Click += StopEditTransaction;
// Button to synchronize local edits with the service
- _syncEditsButton = new Button(this);
- _syncEditsButton.Text ="Sync";
- _syncEditsButton.Enabled = false;
+ _syncEditsButton = new Button(this)
+ {
+ Text = "Sync",
+ Enabled = false
+ };
_syncEditsButton.Click += SynchronizeEdits;
// Button to add bird features
- _addBirdButton = new Button(this);
- _addBirdButton.Text="Add Bird";
- _addBirdButton.Enabled = false;
+ _addBirdButton = new Button(this)
+ {
+ Text = "Add Bird",
+ Enabled = false
+ };
_addBirdButton.Click += AddNewFeature;
// Button to add marine features
- _addMarineButton = new Button(this);
- _addMarineButton.Text = "Add Marine";
- _addMarineButton.Enabled = false;
+ _addMarineButton = new Button(this)
+ {
+ Text = "Add Marine",
+ Enabled = false
+ };
_addMarineButton.Click += AddNewFeature;
// Layout to hold the first row of buttons (start, stop, sync)
- LinearLayout editButtonsRow1 = new LinearLayout(this);
- editButtonsRow1.Orientation = Orientation.Horizontal;
+ LinearLayout editButtonsRow1 = new LinearLayout(this)
+ {
+ Orientation = Orientation.Horizontal
+ };
editButtonsRow1.AddView(_startEditingButton);
editButtonsRow1.AddView(_stopEditingButton);
editButtonsRow1.AddView(_syncEditsButton);
// Layout to hold the second row of buttons (add bird, add marine)
- LinearLayout editButtonsRow2 = new LinearLayout(this);
- editButtonsRow2.Orientation = Orientation.Horizontal;
+ LinearLayout editButtonsRow2 = new LinearLayout(this)
+ {
+ Orientation = Orientation.Horizontal
+ };
editButtonsRow2.AddView(_addBirdButton);
editButtonsRow2.AddView(_addMarineButton);
// Layout for the 'require transaction' switch
- LinearLayout editSwitchRow = new LinearLayout(this);
- editSwitchRow.Orientation = Orientation.Horizontal;
- _requireTransactionSwitch = new Switch(this);
- _requireTransactionSwitch.Checked = true;
- _requireTransactionSwitch.Text = "Require transaction";
+ LinearLayout editSwitchRow = new LinearLayout(this)
+ {
+ Orientation = Orientation.Horizontal
+ };
+ _requireTransactionSwitch = new Switch(this)
+ {
+ Checked = true,
+ Text = "Require transaction"
+ };
_requireTransactionSwitch.CheckedChange += RequireTransactionChanged;
editSwitchRow.AddView(_requireTransactionSwitch);
// Progress bar
- _progressBar = new ProgressBar(this);
- _progressBar.Visibility = Android.Views.ViewStates.Gone;
+ _progressBar = new ProgressBar(this)
+ {
+ Visibility = Android.Views.ViewStates.Gone
+ };
// Use the rest of the view to show status messages
_messageTextBlock = new TextView(this);
// Create the main layout
- LinearLayout layout = new LinearLayout(this);
- layout.Orientation = Orientation.Vertical;
+ LinearLayout layout = new LinearLayout(this)
+ {
+ Orientation = Orientation.Vertical
+ };
// Add the first row of buttons
layout.AddView(editButtonsRow1);
diff --git a/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/ListTransformations.cs b/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/ListTransformations.cs
new file mode 100644
index 0000000000..1f1038d454
--- /dev/null
+++ b/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/ListTransformations.cs
@@ -0,0 +1,371 @@
+// Copyright 2018 Esri.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
+// language governing permissions and limitations under the License.
+
+using Android.App;
+using Android.OS;
+using Android.Views;
+using Android.Widget;
+using ArcGISRuntimeXamarin.Managers;
+using Esri.ArcGISRuntime;
+using Esri.ArcGISRuntime.Geometry;
+using Esri.ArcGISRuntime.Mapping;
+using Esri.ArcGISRuntime.Symbology;
+using Esri.ArcGISRuntime.UI;
+using Esri.ArcGISRuntime.UI.Controls;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+
+namespace ArcGISRuntimeXamarin.Samples.ListTransformations
+{
+ [Activity]
+ public class ListTransformations : Activity
+ {
+ // Map view control to display a map in the app.
+ private MapView _myMapView = new MapView();
+
+ // Point whose coordinates will be projected using a selected transform.
+ private MapPoint _originalPoint;
+
+ // Graphic representing the projected point.
+ private Graphic _projectedPointGraphic;
+
+ // GraphicsOverlay to hold the point graphics.
+ private GraphicsOverlay _pointsOverlay;
+
+ // Text view to display messages to the user (exceptions, etc.).
+ private TextView _messagesTextView;
+
+ // Labels to display the input/output spatial references (WKID).
+ private TextView _inWkidLabel;
+ private TextView _outWkidLabel;
+
+ // Spinner to display the datum transformations suitable for the input/output spatial references.
+ private Spinner _transformationsPicker;
+
+ // Switch to toggle suitable transformations for the current extent.
+ private Switch _useExtentSwitch;
+
+ protected override void OnCreate(Bundle bundle)
+ {
+ base.OnCreate(bundle);
+
+ Title = "List transformations by suitability";
+
+ // Create the UI.
+ CreateLayout();
+
+ // Create a new map, add a point graphic, and fill the datum transformations list.
+ Initialize();
+ }
+
+ private async void Initialize()
+ {
+ // Create the map and add it to the map view control.
+ Map myMap = new Map(Basemap.CreateImageryWithLabels());
+
+ // Create a point in the Greenwich observatory courtyard in London, UK, the location of the prime meridian.
+ _originalPoint = new MapPoint(538985.355, 177329.516, SpatialReference.Create(27700));
+
+ // Set the initial extent to an extent centered on the point.
+ Viewpoint initialViewpoint = new Viewpoint(_originalPoint, 5000);
+ myMap.InitialViewpoint = initialViewpoint;
+
+ // Handle the map loading to fill the UI controls.
+ myMap.Loaded += MyMap_Loaded;
+
+ // Load the map and add the map to the map view.
+ await myMap.LoadAsync();
+ _myMapView.Map = myMap;
+
+ // Create a graphics overlay to hold the original and projected points.
+ _pointsOverlay = new GraphicsOverlay();
+ _myMapView.GraphicsOverlays.Add(_pointsOverlay);
+
+ // Add the point as a graphic with a blue square.
+ SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Square, Color.Blue, 15);
+ Graphic originalGraphic = new Graphic(_originalPoint, markerSymbol);
+ _pointsOverlay.Graphics.Add(originalGraphic);
+
+ // Get the path to the projection engine data (if it exists).
+ string peFolderPath = GetProjectionDataPath();
+ if (!string.IsNullOrEmpty(peFolderPath))
+ {
+ TransformationCatalog.ProjectionEngineDirectory = peFolderPath;
+ _messagesTextView.Text = "Using projection data found at '" + peFolderPath + "'";
+ }
+ else
+ {
+ _messagesTextView.Text = "Projection engine data not found.";
+ }
+ }
+
+ private void MyMap_Loaded(object sender, EventArgs e)
+ {
+ // Get the map's spatial reference.
+ SpatialReference mapSpatialReference = (sender as Map).SpatialReference;
+
+ // Run on the UI thread.
+ RunOnUiThread(() =>
+ {
+ // Show the input and output spatial reference (WKID) in the labels.
+ _inWkidLabel.Text = "In WKID = " + _originalPoint.SpatialReference.Wkid;
+ _outWkidLabel.Text = "Out WKID = " + mapSpatialReference.Wkid;
+
+ // Call a function to create a list of transformations to fill the picker.
+ GetSuitableTransformations(_originalPoint.SpatialReference, mapSpatialReference, _useExtentSwitch.Checked);
+ });
+ }
+
+ private void CreateLayout()
+ {
+ // View for the input/output wkid labels.
+ LinearLayout wkidLabelsStackView = new LinearLayout(this) { Orientation = Orientation.Horizontal };
+ wkidLabelsStackView.SetPadding(10, 10, 0, 10);
+
+ // Create a label for the input spatial reference.
+ _inWkidLabel = new TextView(this)
+ {
+ Text = "In WKID = ",
+ TextAlignment = TextAlignment.ViewStart
+ };
+
+ // Create a label for the output spatial reference.
+ _outWkidLabel = new TextView(this)
+ {
+ Text = "Out WKID = ",
+ TextAlignment = TextAlignment.ViewStart
+ };
+
+ // Create some horizontal space between the labels.
+ Space space = new Space(this);
+ space.SetMinimumWidth(30);
+
+ // Add the Wkid labels to the stack view.
+ wkidLabelsStackView.AddView(_inWkidLabel);
+ wkidLabelsStackView.AddView(space);
+ wkidLabelsStackView.AddView(_outWkidLabel);
+
+ // Create the 'use extent' switch.
+ _useExtentSwitch = new Switch(this)
+ {
+ Checked = false,
+ Text = "Use extent"
+ };
+
+ // Handle the checked change event for the switch.
+ _useExtentSwitch.CheckedChange += UseExtentSwitch_CheckedChange;
+
+ // Create a picker (Spinner) for datum transformations.
+ _transformationsPicker = new Spinner(this);
+ _transformationsPicker.SetPadding(5, 10, 0, 10);
+
+ // Handle the selection event to work with the selected transformation.
+ _transformationsPicker.ItemSelected += TransformationsPicker_ItemSelected;
+
+ // Create a text view to show messages.
+ _messagesTextView = new TextView(this);
+
+ // Create a new vertical layout for the app UI.
+ LinearLayout mainLayout = new LinearLayout(this) { Orientation = Orientation.Vertical };
+
+ // Create a layout for the app tools.
+ LinearLayout toolsLayout = new LinearLayout(this) { Orientation = Orientation.Vertical };
+ toolsLayout.SetPadding(10, 0, 0, 0);
+ toolsLayout.SetMinimumHeight(320);
+
+ // Add the transformation UI controls to the tools layout.
+ toolsLayout.AddView(wkidLabelsStackView);
+ toolsLayout.AddView(_useExtentSwitch);
+ toolsLayout.AddView(_transformationsPicker);
+ toolsLayout.AddView(_messagesTextView);
+
+ // Add the tools layout and map view to the main layout.
+ mainLayout.AddView(toolsLayout);
+ mainLayout.AddView(_myMapView);
+
+ // Show the layout in the app.
+ SetContentView(mainLayout);
+ }
+
+ // Function to get suitable datum transformations for the specified input and output spatial references.
+ private void GetSuitableTransformations(SpatialReference inSpatialRef, SpatialReference outSpatialRef, bool considerExtent)
+ {
+ // Get suitable transformations. Use the current extent to evaluate suitability, if requested.
+ IReadOnlyList transformations;
+ if (considerExtent)
+ {
+ Envelope currentExtent = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope;
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef, currentExtent);
+ }
+ else
+ {
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef);
+ }
+
+ // Get the default transformation for the specified input and output spatial reference.
+ DatumTransformation defaultTransform = TransformationCatalog.GetTransformation(inSpatialRef, outSpatialRef);
+
+ // Create a list of transformations.
+ List transformsList = new List();
+ foreach(DatumTransformation transformation in transformations)
+ {
+ transformsList.Add(transformation);
+ }
+
+ // Create an adapter for showing the spinner list.
+ TransformationsAdapter transformationsAdapter = new TransformationsAdapter(this, transformsList);
+ transformationsAdapter.DefaultTransformation = defaultTransform;
+
+ // Apply the adapter to the spinner.
+ _transformationsPicker.Adapter = transformationsAdapter;
+ }
+
+ private void TransformationsPicker_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
+ {
+ // Get the selected transform from the spinner. Return if none is selected.
+ TransformationsAdapter adapter = _transformationsPicker.Adapter as TransformationsAdapter;
+ DatumTransformation selectedTransform = adapter[e.Position];
+ if (selectedTransform == null) { return; }
+
+ try
+ {
+ // Project the original point using the selected transform.
+ MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(_originalPoint, _myMapView.SpatialReference, selectedTransform);
+
+ // Update the projected graphic (if it already exists), create it otherwise.
+ if (_projectedPointGraphic != null)
+ {
+ _projectedPointGraphic.Geometry = projectedPoint;
+ }
+ else
+ {
+ // Create a symbol to represent the projected point (a cross to ensure both markers are visible).
+ SimpleMarkerSymbol projectedPointMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.Red, 15);
+
+ // Create the point graphic and add it to the overlay.
+ _projectedPointGraphic = new Graphic(projectedPoint, projectedPointMarker);
+ _pointsOverlay.Graphics.Add(_projectedPointGraphic);
+ }
+
+ _messagesTextView.Text = "Projected point using transform: " + selectedTransform.Name;
+ }
+ catch (ArcGISRuntimeException ex)
+ {
+ // Exception if a transformation is missing grid files.
+ _messagesTextView.Text = "Error using selected transformation: " + ex.Message;
+
+ // Remove the projected point graphic (if it exists).
+ if (_projectedPointGraphic != null && _pointsOverlay.Graphics.Contains(_projectedPointGraphic))
+ {
+ _pointsOverlay.Graphics.Remove(_projectedPointGraphic);
+ _projectedPointGraphic = null;
+ }
+ }
+ }
+
+ private void UseExtentSwitch_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e)
+ {
+ // Call a function to create a list of transformations to fill the picker.
+ GetSuitableTransformations(_originalPoint.SpatialReference, _myMapView.Map.SpatialReference, _useExtentSwitch.Checked);
+ }
+
+ private string GetProjectionDataPath()
+ {
+ #region offlinedata
+
+ // The data manager provides a method to get the folder path.
+ string folder = DataManager.GetDataFolder();
+
+ // Get the full path to the projection engine data folder.
+ string folderPath = Path.Combine(folder, "SampleData", "PEDataRuntime");
+
+ // Check if the directory exists.
+ if (!Directory.Exists(folderPath))
+ {
+ folderPath = "";
+ }
+
+ return folderPath;
+
+ #endregion offlinedata
+ }
+ }
+
+ // An Adapter class to provide a list of datum transformations for display in a Spinner control.
+ public class TransformationsAdapter : BaseAdapter
+ {
+ // Property to expose the default datum transformation (will be displayed with different text color).
+ public DatumTransformation DefaultTransformation { get; set; }
+
+ // Fields to store the list of transformations and the current context.
+ private List _transformations;
+ private Activity _context;
+
+ // Constructor for the adapter. Store the context and the list of transformations to display.
+ public TransformationsAdapter(Activity context, List items) : base()
+ {
+ _transformations = items;
+ _context = context;
+ }
+
+ // Provide an ID for an item at a given position (just return the position).
+ public override long GetItemId(int position)
+ {
+ return position;
+ }
+
+ // Provide the datum transformation at this position in the list.
+ public override DatumTransformation this[int position]
+ {
+ get { return _transformations[position]; }
+ }
+
+ // Provide the number of items (datum transformations) in the list.
+ public override int Count
+ {
+ get
+ {
+ return _transformations.Count;
+ }
+ }
+
+ // Override the GetView method to provide a custom (formatted) text view for each transformation in the list.
+ public override View GetView(int position, View convertView, ViewGroup parent)
+ {
+ // Create a new text view to display the transformation name with the proper formatting.
+ TextView transformTextView = new TextView(_context);
+
+ // Get the datum transformation being displayed.
+ DatumTransformation thisTransform = _transformations[position];
+
+ // Set the text with the transformation name.
+ transformTextView.SetText(thisTransform.Name, TextView.BufferType.Normal);
+
+ // Use white as the default text color (available transforms).
+ transformTextView.SetTextColor(Android.Graphics.Color.White);
+
+ // See if the transform is missing required projection engine files. If so, display the text in gray.
+ if (thisTransform.IsMissingProjectionEngineFiles)
+ {
+ transformTextView.SetTextColor(Android.Graphics.Color.Gray);
+ }
+
+ // If this is the default transformation, show it in blue.
+ if(thisTransform.Name == DefaultTransformation.Name)
+ {
+ transformTextView.SetTextColor(Android.Graphics.Color.Blue);
+ }
+
+ // Pass back the text view.
+ return transformTextView;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg b/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg
new file mode 100644
index 0000000000..ae370680c3
Binary files /dev/null and b/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg differ
diff --git a/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/metadata.json b/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/metadata.json
new file mode 100644
index 0000000000..0071a5ccda
--- /dev/null
+++ b/src/Android/Xamarin.Android/Samples/GeometryEngine/ListTransformations/metadata.json
@@ -0,0 +1,21 @@
+{
+ "Name": "List transformations by suitability",
+ "SampleName": "ListTransformations",
+ "Description": "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.",
+ "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 (http://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).",
+ "Type": 0,
+ "RequiresOnlineConnection": true,
+ "RequiresOfflineData": false,
+ "RequiresLocalServer": false,
+ "Image": "ListTransformations.jpg",
+ "Link": "",
+ "TypeLink": [
+ "T:Esri.ArcGISRuntime.Geometry.TransformationCatalog",
+ "P:Esri.ArcGISRuntime.Geometry.TransformationCatalog.ProjectionEngineDirectory",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference)",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.Envelope)",
+ "T:Esri.ArcGISRuntime.Geometry.DatumTransformation",
+ "T:Esri.ArcGISRuntime.Geometry.SpatialReference"
+ ],
+ "SampleFolder": "ListTransformations"
+}
\ No newline at end of file
diff --git a/src/Android/Xamarin.Android/groups.json b/src/Android/Xamarin.Android/groups.json
index 55cfacb952..7071a9c8fe 100644
--- a/src/Android/Xamarin.Android/groups.json
+++ b/src/Android/Xamarin.Android/groups.json
@@ -542,6 +542,10 @@
{
"SampleName": "ProjectWithSpecificTransformation",
"Path": "Samples/GeometryEngine/ProjectWithSpecificTransformation"
+ },
+ {
+ "SampleName": "ListTransformations",
+ "Path": "Samples/GeometryEngine/ListTransformations"
}
]
}
diff --git a/src/Forms/Shared/Forms.projitems b/src/Forms/Shared/Forms.projitems
index 23ef40492c..6bb3e920b7 100644
--- a/src/Forms/Shared/Forms.projitems
+++ b/src/Forms/Shared/Forms.projitems
@@ -17,6 +17,10 @@
MSBuild:UpdateDesignTimeXaml
+
+ MSBuild:UpdateDesignTimeXaml
+
+ MSBuild:UpdateDesignTimeXaml
@@ -67,6 +71,10 @@
CodeReadGeoPackage.xaml
+
+ Code
+ ListTransformations.xaml
+ CodeRasterRgbRenderer.xaml
@@ -100,7 +108,7 @@
-
+
@@ -186,7 +194,8 @@
-
+
+
@@ -197,7 +206,7 @@
-
+
diff --git a/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg
new file mode 100644
index 0000000000..b35fa31005
Binary files /dev/null and b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg differ
diff --git a/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml
new file mode 100644
index 0000000000..670bcd7c9e
--- /dev/null
+++ b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs
new file mode 100644
index 0000000000..83418bdfe5
--- /dev/null
+++ b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs
@@ -0,0 +1,322 @@
+// Copyright 2018 Esri.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
+// language governing permissions and limitations under the License.
+
+using System.Collections.Generic;
+using System.IO;
+using ArcGISRuntimeXamarin.Managers;
+using Esri.ArcGISRuntime;
+using Esri.ArcGISRuntime.Geometry;
+using Esri.ArcGISRuntime.Mapping;
+using Esri.ArcGISRuntime.Symbology;
+using Esri.ArcGISRuntime.UI;
+using Xamarin.Forms;
+
+#if WINDOWS_UWP
+using Colors = Windows.UI.Colors;
+#else
+
+using Colors = System.Drawing.Color;
+
+#endif
+
+namespace ArcGISRuntimeXamarin.Samples.ListTransformations
+{
+ public partial class ListTransformations : ContentPage
+ {
+ // Point whose coordinates will be projected using a selected transform.
+ private MapPoint _originalPoint;
+
+ // Graphic representing the projected point.
+ private Graphic _projectedPointGraphic;
+
+ // GraphicsOverlay to hold the point graphics.
+ private GraphicsOverlay _pointsOverlay;
+
+ // Property to expose the list of datum transformations for binding to the list box.
+ private IReadOnlyList _datumTransformations;
+ public IReadOnlyList SuitableTransformationsList
+ {
+ get
+ {
+ return _datumTransformations;
+ }
+ set
+ {
+ _datumTransformations = value;
+ OnPropertyChanged("SuitableTransformationsList");
+ }
+ }
+
+ public ListTransformations()
+ {
+ InitializeComponent();
+
+ Title = "List transformations";
+
+ // Bind the view to this page.
+ this.BindingContext = this;
+
+ // Create a new map, add a point graphic, and fill the datum transformations list.
+ Initialize();
+ }
+
+ private async void Initialize()
+ {
+ // Create the map.
+ Map myMap = new Map(Basemap.CreateImageryWithLabels());
+
+ // Create a point in the Greenwich observatory courtyard in London, UK, the location of the prime meridian.
+ _originalPoint = new MapPoint(538985.355, 177329.516, SpatialReference.Create(27700));
+
+ // Set the initial extent to an extent centered on the point.
+ Viewpoint initialViewpoint = new Viewpoint(_originalPoint, 5000);
+ myMap.InitialViewpoint = initialViewpoint;
+
+ // Load the map and add the map to the map view.
+ await myMap.LoadAsync();
+ MyMapView.Map = myMap;
+
+ // Create a graphics overlay to hold the original and projected points.
+ _pointsOverlay = new GraphicsOverlay();
+ MyMapView.GraphicsOverlays.Add(_pointsOverlay);
+
+ // Add the point as a graphic with a blue square.
+ SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Square, Colors.Blue, 15);
+ Graphic originalGraphic = new Graphic(_originalPoint, markerSymbol);
+ _pointsOverlay.Graphics.Add(originalGraphic);
+
+ // Get the path to the projection engine data (if it exists).
+ string peFolderPath = GetProjectionDataPath();
+ if (!string.IsNullOrEmpty(peFolderPath))
+ {
+ TransformationCatalog.ProjectionEngineDirectory = peFolderPath;
+ MessagesTextBox.Text = "Using projection data found at '" + peFolderPath + "'";
+ }
+ else
+ {
+ MessagesTextBox.Text = "Projection engine data not found.";
+ }
+
+ // Show the input and output spatial reference.
+ InSpatialRefTextBox.Text = "In WKID = " + _originalPoint.SpatialReference.Wkid;
+ OutSpatialRefTextBox.Text = "Out WKID = " + myMap.SpatialReference.Wkid;
+
+ // Create a list of transformations to fill the UI list box.
+ GetSuitableTransformations(_originalPoint.SpatialReference, myMap.SpatialReference, UseExtentSwitch.IsToggled);
+ }
+
+ // Function to get suitable datum transformations for the specified input and output spatial references.
+ private void GetSuitableTransformations(SpatialReference inSpatialRef, SpatialReference outSpatialRef, bool considerExtent)
+ {
+ // Get suitable transformations. Use the current extent to evaluate suitability, if requested.
+ IReadOnlyList transformations;
+ if (considerExtent)
+ {
+ Envelope currentExtent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope;
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef, currentExtent);
+ }
+ else
+ {
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef);
+ }
+
+ // Get the default transformation for the specified input and output spatial reference.
+ DatumTransformation defaultTransform = TransformationCatalog.GetTransformation(inSpatialRef, outSpatialRef);
+
+ List transformationItems = new List();
+ // Wrap the transformations in a class that includes a boolean to indicate if it's the default transformation.
+ foreach (DatumTransformation transform in transformations)
+ {
+ DatumTransformationListBoxItem item = new DatumTransformationListBoxItem(transform)
+ {
+ IsDefault = (transform.Name == defaultTransform.Name)
+ };
+ transformationItems.Add(item);
+ }
+
+ // Set the transformation list property that the list box binds to.
+ SuitableTransformationsList = transformationItems;
+ }
+
+ private void TransformationsListBox_ItemSelected(object sender, SelectedItemChangedEventArgs e)
+ {
+ // Get the selected transform from the list box. Return if there isn't a selected item.
+ DatumTransformationListBoxItem selectedListBoxItem = TransformationsListBox.SelectedItem as DatumTransformationListBoxItem;
+ if (selectedListBoxItem == null) { return; }
+
+ // Get the datum transformation object from the list box item.
+ DatumTransformation selectedTransform = selectedListBoxItem.TransformationObject;
+
+ try
+ {
+ // Project the original point using the selected transform.
+ MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(_originalPoint, MyMapView.SpatialReference, selectedTransform);
+
+ // Update the projected graphic (if it already exists), create it otherwise.
+ if (_projectedPointGraphic != null)
+ {
+ _projectedPointGraphic.Geometry = projectedPoint;
+ }
+ else
+ {
+ // Create a symbol to represent the projected point (a cross to ensure both markers are visible).
+ SimpleMarkerSymbol projectedPointMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Colors.Red, 15);
+
+ // Create the point graphic and add it to the overlay.
+ _projectedPointGraphic = new Graphic(projectedPoint, projectedPointMarker);
+ _pointsOverlay.Graphics.Add(_projectedPointGraphic);
+ }
+
+ MessagesTextBox.Text = "Projected point using transform: " + selectedTransform.Name;
+ }
+ catch (ArcGISRuntimeException ex)
+ {
+ // Exception if a transformation is missing grid files.
+ MessagesTextBox.Text = "Error using selected transformation: " + ex.Message;
+
+ // Remove the projected point graphic (if it exists).
+ if (_projectedPointGraphic != null && _pointsOverlay.Graphics.Contains(_projectedPointGraphic))
+ {
+ _pointsOverlay.Graphics.Remove(_projectedPointGraphic);
+ _projectedPointGraphic = null;
+ }
+ }
+ }
+
+ private void UseExtentSwitch_Toggled(object sender, ToggledEventArgs e)
+ {
+ // Recreate the contents of the datum transformations list box.
+ GetSuitableTransformations(_originalPoint.SpatialReference, MyMapView.Map.SpatialReference, UseExtentSwitch.IsToggled);
+ }
+
+ private string GetProjectionDataPath()
+ {
+ #region offlinedata
+
+ // The data manager provides a method to get the folder path.
+ string folder = DataManager.GetDataFolder();
+
+ // Get the full path to the projection engine data folder.
+ string folderPath = Path.Combine(folder, "SampleData", "PEDataRuntime");
+
+ // Check if the directory exists.
+ if (!Directory.Exists(folderPath))
+ {
+ folderPath = "";
+ }
+
+ return folderPath;
+
+ #endregion offlinedata
+ }
+ }
+
+ // A class that wraps a DatumTransformation object and adds a property that indicates if it's the default transformation.
+ public class DatumTransformationListBoxItem
+ {
+ // Datum transformation object.
+ public DatumTransformation TransformationObject { get; set; }
+
+ // Whether or not this transformation is the default (for the specified in/out spatial reference).
+ public bool IsDefault { get; set; }
+
+ // Constructor that takes the DatumTransformation object to wrap.
+ public DatumTransformationListBoxItem(DatumTransformation transformation)
+ {
+ TransformationObject = transformation;
+ }
+ }
+
+ // Class to select the appropriate data template for datum transformation list items.
+ public class TransformRowTemplateSelector : DataTemplateSelector
+ {
+ // Data templates for three types of datum transformations.
+ // - Those without supporting projection engine data (making the transformation unavailable).
+ private readonly DataTemplate _unavailableTransformTemplate;
+ // - Available transformations (data required is either available by default, or has been stored on the device).
+ private readonly DataTemplate _availableTransformTemplate;
+ // - The default datum transformation for the context (input/output spatial reference, and possibly the extent).
+ private readonly DataTemplate _defaultTransformTemplate;
+
+ public TransformRowTemplateSelector()
+ {
+ // Create the data template for unavailable transformations.
+ this._unavailableTransformTemplate = new DataTemplate(() =>
+ {
+ Label transformNameLabel = new Label
+ {
+ // Show these with gray text.
+ TextColor = Color.Gray,
+ BackgroundColor = Color.White
+ };
+ transformNameLabel.SetBinding(Label.TextProperty, "TransformationObject.Name");
+
+ return new ViewCell { View = transformNameLabel };
+ });
+
+ // Create the data template for available (but non-default) transformations.
+ this._availableTransformTemplate = new DataTemplate(() =>
+ {
+ Label transformNameLabel = new Label
+ {
+ // Show these with black text.
+ TextColor = Color.Black,
+ BackgroundColor = Color.White
+ };
+ transformNameLabel.SetBinding(Label.TextProperty, "TransformationObject.Name");
+
+ return new ViewCell { View = transformNameLabel };
+ });
+
+ // Create the data template for the default transformation.
+ this._defaultTransformTemplate = new DataTemplate(() =>
+ {
+ Label transformNameLabel = new Label
+ {
+ // Show these with bold blue text.
+ FontAttributes = FontAttributes.Bold,
+ TextColor = Color.Blue,
+ BackgroundColor = Color.White
+ };
+ transformNameLabel.SetBinding(Label.TextProperty, "TransformationObject.Name");
+
+ return new ViewCell { View = transformNameLabel };
+ });
+ }
+
+ // Logic that is called when a template is needed for a list view item.
+ protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
+ {
+ DataTemplate selectedTemplate = null;
+
+ // Get the current list item being created. Return if the item is null.
+ DatumTransformationListBoxItem transformationItem = item as DatumTransformationListBoxItem;
+ if(item == null) { return null; }
+
+ // Read the IsMissingProjectionEngineFiles property to select the available or unavailable data template.
+ if (transformationItem.TransformationObject.IsMissingProjectionEngineFiles)
+ {
+ selectedTemplate = _unavailableTransformTemplate;
+ }
+ else if (!transformationItem.TransformationObject.IsMissingProjectionEngineFiles)
+ {
+ selectedTemplate = _availableTransformTemplate;
+ }
+
+ // See if this is the default transformation.
+ if (transformationItem.IsDefault)
+ {
+ selectedTemplate = _defaultTransformTemplate;
+ }
+
+ // Return the selected template.
+ return selectedTemplate;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/metadata.json b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/metadata.json
new file mode 100644
index 0000000000..0071a5ccda
--- /dev/null
+++ b/src/Forms/Shared/Samples/GeometryEngine/ListTransformations/metadata.json
@@ -0,0 +1,21 @@
+{
+ "Name": "List transformations by suitability",
+ "SampleName": "ListTransformations",
+ "Description": "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.",
+ "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 (http://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).",
+ "Type": 0,
+ "RequiresOnlineConnection": true,
+ "RequiresOfflineData": false,
+ "RequiresLocalServer": false,
+ "Image": "ListTransformations.jpg",
+ "Link": "",
+ "TypeLink": [
+ "T:Esri.ArcGISRuntime.Geometry.TransformationCatalog",
+ "P:Esri.ArcGISRuntime.Geometry.TransformationCatalog.ProjectionEngineDirectory",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference)",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.Envelope)",
+ "T:Esri.ArcGISRuntime.Geometry.DatumTransformation",
+ "T:Esri.ArcGISRuntime.Geometry.SpatialReference"
+ ],
+ "SampleFolder": "ListTransformations"
+}
\ No newline at end of file
diff --git a/src/Forms/Shared/groups.json b/src/Forms/Shared/groups.json
index a35d936f68..1a3c278a78 100644
--- a/src/Forms/Shared/groups.json
+++ b/src/Forms/Shared/groups.json
@@ -546,6 +546,10 @@
{
"SampleName": "ProjectWithSpecificTransformation",
"Path": "Samples/GeometryEngine/ProjectWithSpecificTransformation"
+ },
+ {
+ "SampleName": "ListTransformations",
+ "Path": "Samples/GeometryEngine/ListTransformations"
}
]
}
diff --git a/src/Forms/iOS/ArcGISRuntime.Xamarin.Forms.iOS.csproj b/src/Forms/iOS/ArcGISRuntime.Xamarin.Forms.iOS.csproj
index d0ba59372e..68c67b5c1f 100644
--- a/src/Forms/iOS/ArcGISRuntime.Xamarin.Forms.iOS.csproj
+++ b/src/Forms/iOS/ArcGISRuntime.Xamarin.Forms.iOS.csproj
@@ -151,9 +151,6 @@
..\..\..\packages\Esri.ArcGISRuntime.Hydrography.100.2.0\lib\Xamarin.iOS10\Esri.ArcGISRuntime.Hydrography.dll
-
- ..\..\..\packages\Esri.ArcGISRuntime.Xamarin.iOS.100.2.0\lib\Xamarin.iOS10\Esri.ArcGISRuntime.Preview.dll
- ..\..\..\packages\Esri.ArcGISRuntime.Xamarin.Forms.100.2.0\lib\Xamarin.iOS10\Esri.ArcGISRuntime.Xamarin.Forms.dll
diff --git a/src/UWP/ArcGISRuntime.UWP.Samples/ArcGISRuntime.UWP.Samples.CSharp.csproj b/src/UWP/ArcGISRuntime.UWP.Samples/ArcGISRuntime.UWP.Samples.CSharp.csproj
index 6fcda97cb4..722796b61d 100644
--- a/src/UWP/ArcGISRuntime.UWP.Samples/ArcGISRuntime.UWP.Samples.CSharp.csproj
+++ b/src/UWP/ArcGISRuntime.UWP.Samples/ArcGISRuntime.UWP.Samples.CSharp.csproj
@@ -102,8 +102,17 @@
+
+
+
+
+
+
+
+
+
@@ -315,6 +324,9 @@
ViewshedGeoElement.xaml
+
+ ListTransformations.xaml
+ Animate3DGraphic.xaml
@@ -607,6 +619,10 @@
MSBuild:CompileDesigner
+
+ MSBuild:Compile
+ Designer
+ MSBuild:CompileDesigner
diff --git a/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg
new file mode 100644
index 0000000000..34afe908a3
Binary files /dev/null and b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg differ
diff --git a/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml
new file mode 100644
index 0000000000..76747f3b68
--- /dev/null
+++ b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs
new file mode 100644
index 0000000000..06e8c77bcc
--- /dev/null
+++ b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs
@@ -0,0 +1,232 @@
+// Copyright 2018 Esri.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
+// language governing permissions and limitations under the License.
+
+using ArcGISRuntime.Samples.Managers;
+using Esri.ArcGISRuntime;
+using Esri.ArcGISRuntime.Geometry;
+using Esri.ArcGISRuntime.Mapping;
+using Esri.ArcGISRuntime.Symbology;
+using Esri.ArcGISRuntime.UI;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using Windows.UI;
+using Windows.UI.Xaml;
+
+namespace ArcGISRuntime.UWP.Samples.ListTransformations
+{
+ public partial class ListTransformations : INotifyPropertyChanged
+ {
+ // Point whose coordinates will be projected using a selected transform.
+ private MapPoint _originalPoint;
+
+ // Graphic representing the projected point.
+ private Graphic _projectedPointGraphic;
+
+ // GraphicsOverlay to hold the point graphics.
+ private GraphicsOverlay _pointsOverlay;
+
+ // Property to expose the list of datum transformations for binding to the list box.
+ private IReadOnlyList _datumTransformations;
+ public IReadOnlyList SuitableTransformationsList
+ {
+ get
+ {
+ return _datumTransformations;
+ }
+ set
+ {
+ _datumTransformations = value;
+ OnPropertyChanged("SuitableTransformationsList");
+ }
+ }
+
+ // Implement INotifyPropertyChanged to indicate when the list of transformations has been updated.
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void OnPropertyChanged(string propertyName)
+ {
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+ public ListTransformations()
+ {
+ InitializeComponent();
+
+ Initialize();
+ }
+
+ private async void Initialize()
+ {
+ // Create the map.
+ Map myMap = new Map(Basemap.CreateImageryWithLabels());
+
+ // Create a point in the Greenwich observatory courtyard in London, UK, the location of the prime meridian.
+ _originalPoint = new MapPoint(538985.355, 177329.516, SpatialReference.Create(27700));
+
+ // Set the initial extent to an extent centered on the point.
+ Viewpoint initialViewpoint = new Viewpoint(_originalPoint, 5000);
+ myMap.InitialViewpoint = initialViewpoint;
+
+ // Load the map and add the map to the map view.
+ await myMap.LoadAsync();
+ MyMapView.Map = myMap;
+
+ // Create a graphics overlay to hold the original and projected points.
+ _pointsOverlay = new GraphicsOverlay();
+ MyMapView.GraphicsOverlays.Add(_pointsOverlay);
+
+ // Add the point as a graphic with a blue square.
+ SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Square, Colors.Blue, 15);
+ Graphic originalGraphic = new Graphic(_originalPoint, markerSymbol);
+ _pointsOverlay.Graphics.Add(originalGraphic);
+
+ // Get the path to the projection engine data (if it exists).
+ string peFolderPath = GetProjectionDataPath();
+ if (!string.IsNullOrEmpty(peFolderPath))
+ {
+ TransformationCatalog.ProjectionEngineDirectory = peFolderPath;
+ MessagesTextBox.Text = "Using projection data found at '" + peFolderPath + "'";
+ }
+ else
+ {
+ MessagesTextBox.Text = "Projection engine data not found.";
+ }
+
+ // Show the input and output spatial reference.
+ InSpatialRefTextBox.Text = "In WKID = " + _originalPoint.SpatialReference.Wkid;
+ OutSpatialRefTextBox.Text = "Out WKID = " + myMap.SpatialReference.Wkid;
+
+ // Create a list of transformations to fill the UI list box.
+ GetSuitableTransformations(_originalPoint.SpatialReference, myMap.SpatialReference, UseExtentCheckBox.IsChecked == true);
+ }
+
+ // Function to get suitable datum transformations for the specified input and output spatial references.
+ private void GetSuitableTransformations(SpatialReference inSpatialRef, SpatialReference outSpatialRef, bool considerExtent)
+ {
+ // Get suitable transformations. Use the current extent to evaluate suitability, if requested.
+ IReadOnlyList transformations;
+ if (considerExtent)
+ {
+ Envelope currentExtent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope;
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef, currentExtent);
+ }
+ else
+ {
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef);
+ }
+
+ // Get the default transformation for the specified input and output spatial reference.
+ DatumTransformation defaultTransform = TransformationCatalog.GetTransformation(inSpatialRef, outSpatialRef);
+
+ List transformationItems = new List();
+ // Wrap the transformations in a class that includes a boolean to indicate if it's the default transformation.
+ foreach (DatumTransformation transform in transformations)
+ {
+ DatumTransformationListBoxItem item = new DatumTransformationListBoxItem(transform)
+ {
+ IsDefault = (transform.Name == defaultTransform.Name)
+ };
+ transformationItems.Add(item);
+ }
+
+ // Set the transformation list property that the list box binds to.
+ SuitableTransformationsList = transformationItems;
+ }
+
+ private void TransformationsListBox_Selected(object sender, RoutedEventArgs e)
+ {
+ // Get the selected transform from the list box. Return if there isn't a selected item.
+ DatumTransformationListBoxItem selectedListBoxItem = TransformationsListBox.SelectedItem as DatumTransformationListBoxItem;
+ if (selectedListBoxItem == null) { return; }
+
+ DatumTransformation selectedTransform = selectedListBoxItem.TransformationObject;
+
+ try
+ {
+ // Project the original point using the selected transform.
+ MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(_originalPoint, MyMapView.SpatialReference, selectedTransform);
+
+ // Update the projected graphic (if it already exists), create it otherwise.
+ if (_projectedPointGraphic != null)
+ {
+ _projectedPointGraphic.Geometry = projectedPoint;
+ }
+ else
+ {
+ // Create a symbol to represent the projected point (a cross to ensure both markers are visible).
+ SimpleMarkerSymbol projectedPointMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Colors.Red, 15);
+
+ // Create the point graphic and add it to the overlay.
+ _projectedPointGraphic = new Graphic(projectedPoint, projectedPointMarker);
+ _pointsOverlay.Graphics.Add(_projectedPointGraphic);
+ }
+
+ MessagesTextBox.Text = "Projected point using transform: " + selectedTransform.Name;
+ }
+ catch (ArcGISRuntimeException ex)
+ {
+ // Exception if a transformation is missing grid files.
+ MessagesTextBox.Text = "Error using selected transformation: " + ex.Message;
+
+ // Remove the projected point graphic (if it exists).
+ if (_projectedPointGraphic != null && _pointsOverlay.Graphics.Contains(_projectedPointGraphic))
+ {
+ _pointsOverlay.Graphics.Remove(_projectedPointGraphic);
+ _projectedPointGraphic = null;
+ }
+ }
+ }
+
+ private void UseExtentCheckBox_CheckChanged(object sender, RoutedEventArgs e)
+ {
+ // Recreate the contents of the datum transformations list box.
+ GetSuitableTransformations(_originalPoint.SpatialReference, MyMapView.Map.SpatialReference, UseExtentCheckBox.IsChecked == true);
+ }
+
+ private string GetProjectionDataPath()
+ {
+ #region offlinedata
+
+ // The data manager provides a method to get the folder path.
+ string folder = DataManager.GetDataFolder();
+
+ // Get the full path to the projection engine data folder.
+ string folderPath = Path.Combine(folder, "SampleData", "PEDataRuntime");
+
+ // Check if the directory exists.
+ if (!Directory.Exists(folderPath))
+ {
+ folderPath = "";
+ }
+
+ return folderPath;
+
+ #endregion offlinedata
+ }
+ }
+
+ // A class that wraps a DatumTransformation object and adds a property that indicates if it's the default transformation.
+ public class DatumTransformationListBoxItem
+ {
+ // Datum transformation object.
+ public DatumTransformation TransformationObject { get; set; }
+
+ // Whether or not this transformation is the default (for the specified in/out spatial reference).
+ public bool IsDefault { get; set; }
+
+ // Constructor that takes the DatumTransformation object to wrap.
+ public DatumTransformationListBoxItem(DatumTransformation transformation)
+ {
+ TransformationObject = transformation;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/metadata.json b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/metadata.json
new file mode 100644
index 0000000000..0071a5ccda
--- /dev/null
+++ b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/GeometryEngine/ListTransformations/metadata.json
@@ -0,0 +1,21 @@
+{
+ "Name": "List transformations by suitability",
+ "SampleName": "ListTransformations",
+ "Description": "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.",
+ "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 (http://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).",
+ "Type": 0,
+ "RequiresOnlineConnection": true,
+ "RequiresOfflineData": false,
+ "RequiresLocalServer": false,
+ "Image": "ListTransformations.jpg",
+ "Link": "",
+ "TypeLink": [
+ "T:Esri.ArcGISRuntime.Geometry.TransformationCatalog",
+ "P:Esri.ArcGISRuntime.Geometry.TransformationCatalog.ProjectionEngineDirectory",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference)",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.Envelope)",
+ "T:Esri.ArcGISRuntime.Geometry.DatumTransformation",
+ "T:Esri.ArcGISRuntime.Geometry.SpatialReference"
+ ],
+ "SampleFolder": "ListTransformations"
+}
\ No newline at end of file
diff --git a/src/UWP/ArcGISRuntime.UWP.Samples/groups.json b/src/UWP/ArcGISRuntime.UWP.Samples/groups.json
index e32f9f7ad3..8ee367ba4a 100644
--- a/src/UWP/ArcGISRuntime.UWP.Samples/groups.json
+++ b/src/UWP/ArcGISRuntime.UWP.Samples/groups.json
@@ -546,6 +546,10 @@
{
"SampleName": "ProjectWithSpecificTransformation",
"Path": "Samples/GeometryEngine/ProjectWithSpecificTransformation"
+ },
+ {
+ "SampleName": "ListTransformations",
+ "Path": "Samples/GeometryEngine/ListTransformations"
}
]
}
diff --git a/src/WPF/ArcGISRuntime.WPF.Samples/ArcGISRuntime.WPF.Samples.CSharp.csproj b/src/WPF/ArcGISRuntime.WPF.Samples/ArcGISRuntime.WPF.Samples.CSharp.csproj
index 0f6399d6f5..ed5e3d06cd 100644
--- a/src/WPF/ArcGISRuntime.WPF.Samples/ArcGISRuntime.WPF.Samples.CSharp.csproj
+++ b/src/WPF/ArcGISRuntime.WPF.Samples/ArcGISRuntime.WPF.Samples.CSharp.csproj
@@ -82,6 +82,9 @@
PreserveNewest
+
+ PreserveNewest
+ PreserveNewest
@@ -676,6 +679,9 @@
ViewshedGeoElement.xaml
+
+ ListTransformations.xaml
+ Animate3DGraphic.xaml
@@ -986,6 +992,10 @@
MSBuild:CompileDesigner
+
+ MSBuild:Compile
+ Designer
+ MSBuild:CompileDesigner
@@ -1421,6 +1431,9 @@
PreserveNewest
+
+ PreserveNewest
+
diff --git a/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg
new file mode 100644
index 0000000000..5820e57575
Binary files /dev/null and b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg differ
diff --git a/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml
new file mode 100644
index 0000000000..c8dbd118e8
--- /dev/null
+++ b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs
new file mode 100644
index 0000000000..da938b1b66
--- /dev/null
+++ b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/ListTransformations.xaml.cs
@@ -0,0 +1,233 @@
+// Copyright 2018 Esri.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
+// language governing permissions and limitations under the License.
+
+using ArcGISRuntime.Samples.Managers;
+using Esri.ArcGISRuntime;
+using Esri.ArcGISRuntime.Geometry;
+using Esri.ArcGISRuntime.Mapping;
+using Esri.ArcGISRuntime.Symbology;
+using Esri.ArcGISRuntime.UI;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Windows;
+using System.Windows.Media;
+
+namespace ArcGISRuntime.WPF.Samples.ListTransformations
+{
+ public partial class ListTransformations : INotifyPropertyChanged
+ {
+ // Point whose coordinates will be projected using a selected transform.
+ private MapPoint _originalPoint;
+
+ // Graphic representing the projected point.
+ private Graphic _projectedPointGraphic;
+
+ // GraphicsOverlay to hold the point graphics.
+ GraphicsOverlay _pointsOverlay;
+
+ // Property to expose the list of datum transformations for binding to the list box.
+ private IReadOnlyList _datumTransformations;
+ public IReadOnlyList SuitableTransformationsList
+ {
+ get
+ {
+ return _datumTransformations;
+ }
+ set
+ {
+ _datumTransformations = value;
+ OnPropertyChanged("SuitableTransformationsList");
+ }
+ }
+
+ // Implement INotifyPropertyChanged to indicate when the list of transformations has been updated.
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void OnPropertyChanged(string propertyName)
+ {
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+ public ListTransformations()
+ {
+ InitializeComponent();
+
+ // Create the map, set the initial extent, and add the original point graphic.
+ Initialize();
+ }
+
+ private async void Initialize()
+ {
+ // Create the map.
+ Map myMap = new Map(Basemap.CreateImageryWithLabels());
+
+ // Create a point in the Greenwich observatory courtyard in London, UK, the location of the prime meridian.
+ _originalPoint = new MapPoint(538985.355, 177329.516, SpatialReference.Create(27700));
+
+ // Set the initial extent to an extent centered on the point.
+ Viewpoint initialViewpoint = new Viewpoint(_originalPoint, 5000);
+ myMap.InitialViewpoint = initialViewpoint;
+
+ // Load the map and add the map to the map view.
+ await myMap.LoadAsync();
+ MyMapView.Map = myMap;
+
+ // Create a graphics overlay to hold the original and projected points.
+ _pointsOverlay = new GraphicsOverlay();
+ MyMapView.GraphicsOverlays.Add(_pointsOverlay);
+
+ // Add the point as a graphic with a blue square.
+ SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Square, Colors.Blue, 15);
+ Graphic originalGraphic = new Graphic(_originalPoint, markerSymbol);
+ _pointsOverlay.Graphics.Add(originalGraphic);
+
+ // Get the path to the projection engine data (if it exists).
+ string peFolderPath = GetProjectionDataPath();
+ if (!string.IsNullOrEmpty(peFolderPath))
+ {
+ TransformationCatalog.ProjectionEngineDirectory = peFolderPath;
+ MessagesTextBox.Text = "Using projection data found at '" + peFolderPath + "'";
+ }
+ else
+ {
+ MessagesTextBox.Text = "Projection engine data not found.";
+ }
+
+ // Show the input and output spatial reference.
+ InSpatialRefTextBox.Text = "In WKID = " + _originalPoint.SpatialReference.Wkid;
+ OutSpatialRefTextBox.Text = "Out WKID = " + myMap.SpatialReference.Wkid;
+
+ // Create a list of transformations to fill the UI list box.
+ GetSuitableTransformations(_originalPoint.SpatialReference, myMap.SpatialReference, UseExtentCheckBox.IsChecked == true);
+ }
+
+ // Function to get suitable datum transformations for the specified input and output spatial references.
+ private void GetSuitableTransformations(SpatialReference inSpatialRef, SpatialReference outSpatialRef, bool considerExtent)
+ {
+ // Get suitable transformations. Use the current extent to evaluate suitability, if requested.
+ IReadOnlyList transformations;
+ if (considerExtent)
+ {
+ Envelope currentExtent = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope;
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef, currentExtent);
+ }
+ else
+ {
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef);
+ }
+
+ // Get the default transformation for the specified input and output spatial reference.
+ DatumTransformation defaultTransform = TransformationCatalog.GetTransformation(inSpatialRef, outSpatialRef);
+
+ List transformationItems = new List();
+ // Wrap the transformations in a class that includes a boolean to indicate if it's the default transformation.
+ foreach(DatumTransformation transform in transformations)
+ {
+ DatumTransformationListBoxItem item = new DatumTransformationListBoxItem(transform)
+ {
+ IsDefault = (transform.Name == defaultTransform.Name)
+ };
+ transformationItems.Add(item);
+ }
+
+ // Set the transformation list property that the list box binds to.
+ SuitableTransformationsList = transformationItems;
+ }
+
+ private void TransformationsListBox_Selected(object sender, RoutedEventArgs e)
+ {
+ // Get the selected transform from the list box. Return if there isn't a selected item.
+ DatumTransformationListBoxItem selectedListBoxItem = TransformationsListBox.SelectedItem as DatumTransformationListBoxItem;
+ if(selectedListBoxItem == null) { return; }
+
+ DatumTransformation selectedTransform = selectedListBoxItem.TransformationObject;
+
+ try
+ {
+ // Project the original point using the selected transform.
+ MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(_originalPoint, MyMapView.SpatialReference, selectedTransform);
+
+ // Update the projected graphic (if it already exists), create it otherwise.
+ if (_projectedPointGraphic != null)
+ {
+ _projectedPointGraphic.Geometry = projectedPoint;
+ }
+ else
+ {
+ // Create a symbol to represent the projected point (a cross to ensure both markers are visible).
+ SimpleMarkerSymbol projectedPointMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Colors.Red, 15);
+
+ // Create the point graphic and add it to the overlay.
+ _projectedPointGraphic = new Graphic(projectedPoint, projectedPointMarker);
+ _pointsOverlay.Graphics.Add(_projectedPointGraphic);
+ }
+
+ MessagesTextBox.Text = "Projected point using transform: " + selectedTransform.Name;
+ }
+ catch(ArcGISRuntimeException ex)
+ {
+ // Exception if a transformation is missing grid files.
+ MessagesTextBox.Text = "Error using selected transformation: " + ex.Message;
+
+ // Remove the projected point graphic (if it exists).
+ if (_projectedPointGraphic != null && _pointsOverlay.Graphics.Contains(_projectedPointGraphic))
+ {
+ _pointsOverlay.Graphics.Remove(_projectedPointGraphic);
+ _projectedPointGraphic = null;
+ }
+ }
+ }
+
+ private void UseExtentCheckBox_CheckChanged(object sender, RoutedEventArgs e)
+ {
+ // Recreate the contents of the datum transformations list box.
+ GetSuitableTransformations(_originalPoint.SpatialReference, MyMapView.Map.SpatialReference, UseExtentCheckBox.IsChecked == true);
+ }
+
+ private string GetProjectionDataPath()
+ {
+ #region offlinedata
+
+ // The data manager provides a method to get the folder path.
+ string folder = DataManager.GetDataFolder();
+
+ // Get the full path to the projection engine data folder.
+ string folderPath = Path.Combine(folder, "SampleData", "PEDataRuntime");
+
+ // Check if the directory exists.
+ if (!Directory.Exists(folderPath))
+ {
+ folderPath = "";
+ }
+
+ return folderPath;
+
+ #endregion offlinedata
+ }
+ }
+
+ // A class that wraps a DatumTransformation object and adds a property that indicates if it's the default transformation.
+ public class DatumTransformationListBoxItem
+ {
+ // Datum transformation object.
+ public DatumTransformation TransformationObject { get; set; }
+
+ // Whether or not this transformation is the default (for the specified in/out spatial reference).
+ public bool IsDefault { get; set; }
+
+ // Constructor that takes the DatumTransformation object to wrap.
+ public DatumTransformationListBoxItem(DatumTransformation transformation)
+ {
+ TransformationObject = transformation;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/metadata.json b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/metadata.json
new file mode 100644
index 0000000000..0071a5ccda
--- /dev/null
+++ b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/GeometryEngine/ListTransformations/metadata.json
@@ -0,0 +1,21 @@
+{
+ "Name": "List transformations by suitability",
+ "SampleName": "ListTransformations",
+ "Description": "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.",
+ "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 (http://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).",
+ "Type": 0,
+ "RequiresOnlineConnection": true,
+ "RequiresOfflineData": false,
+ "RequiresLocalServer": false,
+ "Image": "ListTransformations.jpg",
+ "Link": "",
+ "TypeLink": [
+ "T:Esri.ArcGISRuntime.Geometry.TransformationCatalog",
+ "P:Esri.ArcGISRuntime.Geometry.TransformationCatalog.ProjectionEngineDirectory",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference)",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.Envelope)",
+ "T:Esri.ArcGISRuntime.Geometry.DatumTransformation",
+ "T:Esri.ArcGISRuntime.Geometry.SpatialReference"
+ ],
+ "SampleFolder": "ListTransformations"
+}
\ No newline at end of file
diff --git a/src/WPF/ArcGISRuntime.WPF.Samples/groups.json b/src/WPF/ArcGISRuntime.WPF.Samples/groups.json
index 94be6ee258..60988613d6 100644
--- a/src/WPF/ArcGISRuntime.WPF.Samples/groups.json
+++ b/src/WPF/ArcGISRuntime.WPF.Samples/groups.json
@@ -604,6 +604,10 @@
{
"SampleName": "ProjectWithSpecificTransformation",
"Path": "Samples/GeometryEngine/ProjectWithSpecificTransformation"
+ },
+ {
+ "SampleName": "ListTransformations",
+ "Path": "Samples/GeometryEngine/ListTransformations"
}
]
}
diff --git a/src/iOS/Xamarin.iOS/ArcGISRuntime.Xamarin.Samples.iOS.csproj b/src/iOS/Xamarin.iOS/ArcGISRuntime.Xamarin.Samples.iOS.csproj
index 77be6d6858..5d3ce1a245 100644
--- a/src/iOS/Xamarin.iOS/ArcGISRuntime.Xamarin.Samples.iOS.csproj
+++ b/src/iOS/Xamarin.iOS/ArcGISRuntime.Xamarin.Samples.iOS.csproj
@@ -178,6 +178,7 @@
+
@@ -244,6 +245,7 @@
+
@@ -547,6 +549,9 @@
+
+
+
diff --git a/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/ListTransformations.cs b/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/ListTransformations.cs
new file mode 100644
index 0000000000..fc82aaf4a1
--- /dev/null
+++ b/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/ListTransformations.cs
@@ -0,0 +1,443 @@
+// Copyright 2018 Esri.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
+// language governing permissions and limitations under the License.
+
+using ArcGISRuntimeXamarin.Managers;
+using CoreGraphics;
+using Esri.ArcGISRuntime;
+using Esri.ArcGISRuntime.Geometry;
+using Esri.ArcGISRuntime.Mapping;
+using Esri.ArcGISRuntime.Symbology;
+using Esri.ArcGISRuntime.UI;
+using Esri.ArcGISRuntime.UI.Controls;
+using Foundation;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using UIKit;
+
+namespace ArcGISRuntimeXamarin.Samples.ListTransformations
+{
+ [Register("ListTransformations")]
+ public class ListTransformations : UIViewController
+ {
+ // Map view control to display a map in the app.
+ private MapView _myMapView = new MapView();
+
+ // Stack view to contain the datum transformation UI.
+ private UIStackView _transformToolsView = new UIStackView();
+
+ // Store the height of each set of controls (may vary on different devices).
+ private nfloat _mapViewHeight;
+ private nfloat _transformToolsHeight;
+
+ // Point whose coordinates will be projected using a selected transform.
+ private MapPoint _originalPoint;
+
+ // Graphic representing the projected point.
+ private Graphic _projectedPointGraphic;
+
+ // GraphicsOverlay to hold the point graphics.
+ private GraphicsOverlay _pointsOverlay;
+
+ // Text view to display messages to the user (exceptions, etc.).
+ private UITextView _messagesTextView;
+
+ // Labels to display the input/output spatial references (WKID).
+ private UILabel _inWkidLabel;
+ private UILabel _outWkidLabel;
+
+ // Picker to display the datum transformations suitable for the input/output spatial references.
+ private UIPickerView _transformationsPicker;
+
+ // Switch to toggle suitable transformations for the current extent.
+ private UISwitch _useExtentSwitch;
+
+ public ListTransformations()
+ {
+ Title = "List datum transformations";
+ }
+
+ public override void ViewDidLoad()
+ {
+ base.ViewDidLoad();
+
+ // Get the height of the map view and the UI tools view (one half each).
+ _mapViewHeight = (nfloat)(View.Bounds.Height / 2.0);
+ _transformToolsHeight = (nfloat)(View.Bounds.Height / 2.0);
+
+ // Create the UI.
+ CreateLayout();
+
+ // Create a new map, add a point graphic, and fill the datum transformations list.
+ Initialize();
+ }
+
+ public override void ViewDidLayoutSubviews()
+ {
+ base.ViewDidLayoutSubviews();
+
+ // Place the MapView (top 2/3 of the view)
+ _myMapView.Frame = new CGRect(0, 0, View.Bounds.Width, _mapViewHeight);
+
+ // Place the edit tools (bottom 1/3 of the view)
+ _transformToolsView.Frame = new CGRect(0, _mapViewHeight, View.Bounds.Width, _transformToolsHeight);
+ }
+
+ private async void Initialize()
+ {
+ // Create the map and add it to the map view control.
+ Map myMap = new Map(Basemap.CreateImageryWithLabels());
+
+ // Create a point in the Greenwich observatory courtyard in London, UK, the location of the prime meridian.
+ _originalPoint = new MapPoint(538985.355, 177329.516, SpatialReference.Create(27700));
+
+ // Set the initial extent to an extent centered on the point.
+ Viewpoint initialViewpoint = new Viewpoint(_originalPoint, 5000);
+ myMap.InitialViewpoint = initialViewpoint;
+
+ // Handle the map loading to fill the UI controls.
+ myMap.Loaded += MyMap_Loaded;
+
+ // Load the map and add the map to the map view.
+ await myMap.LoadAsync();
+ _myMapView.Map = myMap;
+
+ // Create a graphics overlay to hold the original and projected points.
+ _pointsOverlay = new GraphicsOverlay();
+ _myMapView.GraphicsOverlays.Add(_pointsOverlay);
+
+ // Add the point as a graphic with a blue square.
+ SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Square, Color.Blue, 15);
+ Graphic originalGraphic = new Graphic(_originalPoint, markerSymbol);
+ _pointsOverlay.Graphics.Add(originalGraphic);
+
+ // Get the path to the projection engine data (if it exists).
+ string peFolderPath = GetProjectionDataPath();
+ if (!string.IsNullOrEmpty(peFolderPath))
+ {
+ TransformationCatalog.ProjectionEngineDirectory = peFolderPath;
+ _messagesTextView.Text = "Using projection data found at '" + peFolderPath + "'";
+ }
+ else
+ {
+ _messagesTextView.Text = "Projection engine data not found.";
+ }
+ }
+
+ private void MyMap_Loaded(object sender, EventArgs e)
+ {
+ // Get the map's spatial reference.
+ SpatialReference mapSpatialReference = (sender as Map).SpatialReference;
+
+ // Run on the UI thread.
+ InvokeOnMainThread(() =>
+ {
+ // Show the input and output spatial reference (WKID) in the labels.
+ _inWkidLabel.Text = "In WKID = " + _originalPoint.SpatialReference.Wkid;
+ _outWkidLabel.Text = "Out WKID = " + mapSpatialReference.Wkid;
+
+ // Call a function to create a list of transformations to fill the picker.
+ GetSuitableTransformations(_originalPoint.SpatialReference, mapSpatialReference, _useExtentSwitch.On);
+ });
+ }
+
+ private void CreateLayout()
+ {
+ // Place the map view in the upper half of the display.
+ _myMapView.Frame = new CGRect(0, 0, View.Bounds.Width, _mapViewHeight);
+
+ // Place the transformations UI in the bottom half.
+ _transformToolsView.Axis = UILayoutConstraintAxis.Vertical;
+ _transformToolsView.Frame = new CGRect(0, _mapViewHeight, View.Bounds.Width, _transformToolsHeight);
+
+ // View for the input/output wkid labels.
+ UIStackView wkidLabelsStackView = new UIStackView(new CGRect(10, 5, View.Bounds.Width-10, 35))
+ {
+ Axis = UILayoutConstraintAxis.Horizontal
+ };
+
+ // Create a label for the input spatial reference.
+ _inWkidLabel = new UILabel(new CGRect(5, 0, (View.Bounds.Width / 2) - 15, 30))
+ {
+ Text = "In WKID = ",
+ TextAlignment = UITextAlignment.Left,
+ TextColor = UIColor.Blue
+ };
+
+ // Create a label for the output spatial reference.
+ _outWkidLabel = new UILabel(new CGRect((View.Bounds.Width / 2) + 5, 0, (View.Bounds.Width / 2) - 15, 30))
+ {
+ Text = "Out WKID = ",
+ TextAlignment = UITextAlignment.Left,
+ TextColor = UIColor.Blue
+ };
+
+ // Add the Wkid labels to the stack view.
+ wkidLabelsStackView.Add(_inWkidLabel);
+ wkidLabelsStackView.Add(_outWkidLabel);
+
+ // Create a horizontal stack view for the 'use extent' switch and label.
+ UIStackView extentSwitchRow = new UIStackView(new CGRect(20, 35, View.Bounds.Width - 20, 35))
+ {
+ Axis = UILayoutConstraintAxis.Horizontal
+ };
+ _useExtentSwitch = new UISwitch
+ {
+ On = false
+ };
+ _useExtentSwitch.ValueChanged += UseExtentSwitch_ValueChanged;
+
+ // Create a label for the use extent switch.
+ UILabel useExtentLabel = new UILabel(new CGRect(70, 0, View.Bounds.Width - 70, 30))
+ {
+ Text = "Use extent",
+ TextAlignment = UITextAlignment.Left,
+ TextColor = UIColor.Blue
+ };
+
+ // Add the switch and the label to the horizontal stack view.
+ extentSwitchRow.Add(_useExtentSwitch);
+ extentSwitchRow.Add(useExtentLabel);
+
+ // Create a picker for datum transformations.
+ _transformationsPicker = new UIPickerView(new CGRect(20, 70, View.Bounds.Width-20, 120));
+
+ // Create a text view to show messages.
+ _messagesTextView = new UITextView(new CGRect(20, 200, View.Bounds.Width-20, 60));
+
+ // Add the controls to the transform UI (stack view).
+ _transformToolsView.AddSubviews(wkidLabelsStackView, extentSwitchRow, _transformationsPicker, _messagesTextView);
+
+ // Add the map view and tools subviews to the view.
+ View.AddSubviews(_myMapView, _transformToolsView);
+
+ // Set the view background color.
+ View.BackgroundColor = UIColor.White;
+ }
+
+ private void UseExtentSwitch_ValueChanged(object sender, EventArgs e)
+ {
+ // Recreate the contents of the datum transformations list box.
+ GetSuitableTransformations(_originalPoint.SpatialReference, _myMapView.Map.SpatialReference, _useExtentSwitch.On);
+ }
+
+ // Function to get suitable datum transformations for the specified input and output spatial references.
+ private void GetSuitableTransformations(SpatialReference inSpatialRef, SpatialReference outSpatialRef, bool considerExtent)
+ {
+ // Get suitable transformations. Use the current extent to evaluate suitability, if requested.
+ IReadOnlyList transformations;
+ if (considerExtent)
+ {
+ Envelope currentExtent = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry as Envelope;
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef, currentExtent);
+ }
+ else
+ {
+ transformations = TransformationCatalog.GetTransformationsBySuitability(inSpatialRef, outSpatialRef);
+ }
+
+ // Get the default transformation for the specified input and output spatial reference.
+ DatumTransformation defaultTransform = TransformationCatalog.GetTransformation(inSpatialRef, outSpatialRef);
+
+ // Create a picker model to display the updated transformations.
+ TransformationsPickerModel pickerModel = new TransformationsPickerModel(transformations, defaultTransform);
+
+ // Handle the selection event to work with the selected transformation.
+ pickerModel.TransformationSelected += TransformationsPicker_TransformationSelected;
+
+ // Apply the model to the picker.
+ _transformationsPicker.Model = pickerModel;
+ }
+
+ // Handle selection events in the transformation picker.
+ private void TransformationsPicker_TransformationSelected(object sender, TransformationSelectionEventArgs e)
+ {
+ // Get the selected transform from the event arguments. Return if none is selected.
+ DatumTransformation selectedTransform = e.Transformation;
+ if(selectedTransform == null) { return; }
+
+ try
+ {
+ // Project the original point using the selected transform.
+ MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(_originalPoint, _myMapView.SpatialReference, selectedTransform);
+
+ // Update the projected graphic (if it already exists), create it otherwise.
+ if (_projectedPointGraphic != null)
+ {
+ _projectedPointGraphic.Geometry = projectedPoint;
+ }
+ else
+ {
+ // Create a symbol to represent the projected point (a cross to ensure both markers are visible).
+ SimpleMarkerSymbol projectedPointMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.Red, 15);
+
+ // Create the point graphic and add it to the overlay.
+ _projectedPointGraphic = new Graphic(projectedPoint, projectedPointMarker);
+ _pointsOverlay.Graphics.Add(_projectedPointGraphic);
+ }
+
+ _messagesTextView.Text = "Projected point using transform: " + selectedTransform.Name;
+ }
+ catch (ArcGISRuntimeException ex)
+ {
+ // Exception if a transformation is missing grid files.
+ _messagesTextView.Text = "Error using selected transformation: " + ex.Message;
+
+ // Remove the projected point graphic (if it exists).
+ if (_projectedPointGraphic != null && _pointsOverlay.Graphics.Contains(_projectedPointGraphic))
+ {
+ _pointsOverlay.Graphics.Remove(_projectedPointGraphic);
+ _projectedPointGraphic = null;
+ }
+ }
+ }
+
+ private string GetProjectionDataPath()
+ {
+ #region offlinedata
+
+ // The data manager provides a method to get the folder path.
+ string folder = DataManager.GetDataFolder();
+
+ // Get the full path to the projection engine data folder.
+ string folderPath = Path.Combine(folder, "SampleData", "PEDataRuntime");
+
+ // Check if the directory exists.
+ if (!Directory.Exists(folderPath))
+ {
+ folderPath = "";
+ }
+
+ return folderPath;
+
+ #endregion offlinedata
+ }
+ }
+
+ // Class that defines a view model for showing available datum transformations in a picker control.
+ public class TransformationsPickerModel : UIPickerViewModel
+ {
+ // Event raised when the selected transformation changes.
+ public event EventHandler TransformationSelected;
+
+ // List of datum transformation values.
+ private IReadOnlyList _datumTransformations;
+
+ // Store the default transformation.
+ private DatumTransformation _defaultTransformation;
+
+ // Store the selected transformation.
+ private DatumTransformation _selectedTransformation;
+
+ // Constructor that takes the datum transformations list to display.
+ public TransformationsPickerModel(IReadOnlyList transformationList, DatumTransformation defaultTransform)
+ {
+ _datumTransformations = transformationList;
+ _defaultTransformation = defaultTransform;
+ }
+
+ // Property to expose the currently selected transformation value in the picker.
+ public DatumTransformation SelectedDatumTransformation
+ {
+ get { return _selectedTransformation; }
+ }
+
+ // Return the number of picker components (just one).
+ public override nint GetComponentCount(UIPickerView pickerView)
+ {
+ return 1;
+ }
+
+ // Return the number of rows in the section (the size of the transformations list).
+ public override nint GetRowsInComponent(UIPickerView pickerView, nint component)
+ {
+ return _datumTransformations.Count;
+ }
+
+ // Get the title to display in the picker component.
+ public override string GetTitle(UIPickerView pickerView, nint row, nint component)
+ {
+ return _datumTransformations[(int)row].Name;
+ }
+
+ // Handle the selection event for the picker.
+ public override void Selected(UIPickerView pickerView, nint row, nint component)
+ {
+ // Get the selected datum transformation factor.
+ _selectedTransformation = _datumTransformations[(int)pickerView.SelectedRowInComponent(0)];
+
+ // Raise the selection event (with the new transformation) so listeners can handle it.
+ EventHandler selectionEventHandler = TransformationSelected;
+ if(selectionEventHandler != null)
+ {
+ TransformationSelectionEventArgs args = new TransformationSelectionEventArgs(_selectedTransformation);
+ selectionEventHandler(this, args);
+ }
+ }
+
+ // Return the desired width for each component in the picker.
+ public override nfloat GetComponentWidth(UIPickerView picker, nint component)
+ {
+ return 280f;
+ }
+
+ // Return the desired height for rows in the picker.
+ public override nfloat GetRowHeight(UIPickerView picker, nint component)
+ {
+ return 30f;
+ }
+
+ // Override GetView to create different label colors for each type of transformation.
+ public override UIView GetView(UIPickerView pickerView, nint row, nint component, UIView view)
+ {
+ // Get the transformation being displayed.
+ DatumTransformation thisTransform = _datumTransformations[(int)row];
+
+ // See if this is the default transformation and if it's available (has required PE files).
+ bool isDefault = thisTransform.Name == _defaultTransformation.Name;
+ bool isNotAvailable = thisTransform.IsMissingProjectionEngineFiles;
+
+ // Create the correct color for the transform type (available=black, default=blue, or unavailable=gray).
+ UIColor labelColor = UIColor.Black;
+ if (isNotAvailable)
+ {
+ labelColor = UIColor.Gray;
+ }
+
+ if (isDefault)
+ {
+ labelColor = UIColor.Blue;
+ }
+
+ // Create a label to display the transform.
+ UILabel transformLabel = new UILabel(new RectangleF(0, 0, 260f, 30f))
+ {
+ TextColor = labelColor,
+ Font = UIFont.SystemFontOfSize(16f),
+ TextAlignment = UITextAlignment.Center,
+ Text = thisTransform.Name
+ };
+
+ return transformLabel;
+ }
+ }
+
+ // Event arguments to return when a new datum transformation is selected in the picker.
+ public class TransformationSelectionEventArgs : EventArgs
+ {
+ // Selected datum transformation.
+ public DatumTransformation Transformation { get; set; }
+
+ public TransformationSelectionEventArgs(DatumTransformation transformation)
+ {
+ Transformation = transformation;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg b/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg
new file mode 100644
index 0000000000..70a648d00f
Binary files /dev/null and b/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/ListTransformations.jpg differ
diff --git a/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/metadata.json b/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/metadata.json
new file mode 100644
index 0000000000..0071a5ccda
--- /dev/null
+++ b/src/iOS/Xamarin.iOS/Samples/GeometryEngine/ListTransformations/metadata.json
@@ -0,0 +1,21 @@
+{
+ "Name": "List transformations by suitability",
+ "SampleName": "ListTransformations",
+ "Description": "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.",
+ "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 (http://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).",
+ "Type": 0,
+ "RequiresOnlineConnection": true,
+ "RequiresOfflineData": false,
+ "RequiresLocalServer": false,
+ "Image": "ListTransformations.jpg",
+ "Link": "",
+ "TypeLink": [
+ "T:Esri.ArcGISRuntime.Geometry.TransformationCatalog",
+ "P:Esri.ArcGISRuntime.Geometry.TransformationCatalog.ProjectionEngineDirectory",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference)",
+ "M:Esri.ArcGISRuntime.Geometry.TransformationCatalog.GetTransformationsBySuitability(Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.SpatialReference,Esri.ArcGISRuntime.Geometry.Envelope)",
+ "T:Esri.ArcGISRuntime.Geometry.DatumTransformation",
+ "T:Esri.ArcGISRuntime.Geometry.SpatialReference"
+ ],
+ "SampleFolder": "ListTransformations"
+}
\ No newline at end of file
diff --git a/src/iOS/Xamarin.iOS/groups.json b/src/iOS/Xamarin.iOS/groups.json
index b7d709185a..95cb607829 100644
--- a/src/iOS/Xamarin.iOS/groups.json
+++ b/src/iOS/Xamarin.iOS/groups.json
@@ -547,6 +547,10 @@
{
"SampleName": "ProjectWithSpecificTransformation",
"Path": "Samples/GeometryEngine/ProjectWithSpecificTransformation"
+ },
+ {
+ "SampleName": "ListTransformations",
+ "Path": "Samples/GeometryEngine/ListTransformations"
}
]
}