Exemple #1
0
        // 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 <DatumTransformation> 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);

            // Reset list.
            SuitableTransformationsList.Clear();

            // 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)
                };
                SuitableTransformationsList.Add(item);
            }
        }
Exemple #2
0
        // 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 <DatumTransformation> 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;
        }
Exemple #3
0
        // 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 <DatumTransformation> 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 <DatumTransformation> transformsList = new List <DatumTransformation>();

            foreach (DatumTransformation transformation in transformations)
            {
                transformsList.Add(transformation);
            }

            // Create an adapter for showing the spinner list.
            TransformationsAdapter transformationsAdapter = new TransformationsAdapter(this, transformsList)
            {
                DefaultTransformation = defaultTransform
            };

            // Apply the adapter to the spinner.
            _transformationsPicker.Adapter = transformationsAdapter;
        }
Exemple #4
0
        /// <summary>
        /// Will calculate a
        /// </summary>
        /// <param name="inX"></param>
        /// <param name="inY"></param>
        /// <returns></returns>
        public MapPoint CalculateGeographicCoordinate(int easting, int northing, SpatialReference inSR, SpatialReference outSR)
        {
            //Variables
            MapPoint geoPoint = new MapPoint(0, 0, outSR);

            //Transform
            if (easting != 0.0 && northing != 0.0)
            {
                if (outSR != null)
                {
                    DatumTransformation datumTransfo = null;
                    if ((outSR.Wkid > 26900 && outSR.Wkid < 27000))
                    {
                        outSR = new Esri.ArcGISRuntime.Geometry.SpatialReference(4617);
                    }
                    else
                    {
                        datumTransfo = TransformationCatalog.GetTransformation(inSR, outSR);
                    }

                    MapPoint proPoint = new MapPoint(easting, northing, inSR);

                    //Validate if transformation is needed.
                    if (datumTransfo != null)
                    {
                        geoPoint = (MapPoint)Esri.ArcGISRuntime.Geometry.GeometryEngine.Project(proPoint, outSR, datumTransfo);
                    }
                    else
                    {
                        geoPoint = (MapPoint)Esri.ArcGISRuntime.Geometry.GeometryEngine.Project(proPoint, outSR);
                    }
                }
            }

            return(geoPoint);
        }