예제 #1
0
 public void SetInitialExtent()
 {
     // Set the initial extent.
     Esri.ArcGISRuntime.Geometry.SpatialReference sr       = Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84;
     Esri.ArcGISRuntime.Geometry.Envelope         envelope = new Esri.ArcGISRuntime.Geometry.Envelope(10, 40, 14, 43, sr);
     this.mapView.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(envelope);
 }
예제 #2
0
 /// <summary>
 /// Erzeugt eine neue Instanz und verwendet den angegebenen Endpunkt.
 /// </summary>
 /// <param name="url">der Endpunkt eines Dienstes</param>
 /// <param name="mapSpatialReference">der Raumbezug der Karte</param>
 public TrafficLayer(string url, Esri.ArcGISRuntime.Geometry.SpatialReference mapSpatialReference)
 {
     // TODO: Dispose des Dienstes implementieren
     _service             = new TrafficService();
     _url                 = url;
     _mapSpatialReference = mapSpatialReference;
     Overlay              = CreateOverlay();
     AreaOfInterest       = new EnvelopeBuilder(mapSpatialReference).ToGeometry();
 }
예제 #3
0
        private static MapPoint CreatePoint(double[] coordinates, Esri.ArcGISRuntime.Geometry.SpatialReference spatialReference)
        {
            if (coordinates.Length < 1)
            {
                return(new MapPoint(double.NaN, double.NaN));
            }

            return(new MapPoint(coordinates[0], coordinates[1], spatialReference));
        }
        public async void GetAddressTest()
        {
            try
            {
                var mapPoint = await MyMapView.Editor.RequestPointAsync();

                var geoSpatialRef = new Esri.ArcGISRuntime.Geometry.SpatialReference(4326);
                var spatialRef    = new Esri.ArcGISRuntime.Geometry.SpatialReference(102100);
                //spatialRef.Wkt = "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]";
                //var mapPoint = new Esri.ArcGISRuntime.Geometry.MapPoint(this.mapPoint.X, this.mapPoint.Y, spatialRef);
                var mapPointGeo = Esri.ArcGISRuntime.Geometry.GeometryEngine.Project(mapPoint, geoSpatialRef) as Esri.ArcGISRuntime.Geometry.MapPoint;
                var uri         = new Uri("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");
                var token       = String.Empty;
                var locator     = new Esri.ArcGISRuntime.Tasks.Geocoding.OnlineLocatorTask(uri, token);
                var addressInfo = await locator.ReverseGeocodeAsync(mapPointGeo, 100, new System.Threading.CancellationToken());
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: " + e.Message, "Error");
            }
        }
        public Graphic MakeMapPointGraphic2(double X, double Y, int SR, int anAttributeValue1, string anAttributeValue2)
        {
            // This function constructs a new Graphic using:
            // (1) coordinate pairs (X, Y)
            // (2) a SpatialReference.WKID (SR)
            // (3) some Attribute values (anAttributeValue, anAttributeValue2)

            // Create a SpatialReference for the Graphic.

            Esri.ArcGISRuntime.Geometry.SpatialReference aSpatialReference = new Esri.ArcGISRuntime.Geometry.SpatialReference(SR);

            // Create a MapPoint object and set its SpatialReference and coordinate (X,Y) information.
            Esri.ArcGISRuntime.Geometry.MapPoint aMapPoint = new Esri.ArcGISRuntime.Geometry.MapPoint(X, Y, aSpatialReference);

            // Create a new instance of one Graphic and assign its Geometry.

            Graphic aGraphic = new Graphic();

            aGraphic.Geometry = (Esri.ArcGISRuntime.Geometry.Geometry)aMapPoint;

            // Create a new instance of a SimpleMarkerSymbol and set its Color, Style, and Size Properties.
            SimpleMarkerSymbol aSimpleMarkerySymbol = new SimpleMarkerSymbol();

            aSimpleMarkerySymbol.Color = Colors.Red;
            aSimpleMarkerySymbol.Style = SimpleMarkerStyle.Circle;
            aSimpleMarkerySymbol.Size  = 20;
            aGraphic.Symbol            = (Symbol)aSimpleMarkerySymbol;

            // Add some Attributes to the Graphic.
            aGraphic.Attributes.Add("Temperature", anAttributeValue1);
            aGraphic.Attributes.Add("Location", anAttributeValue2);

            // Dynamically wire-up the MouseRightButtonDown Event handler.



            // Return the created Graphic.
            return(aGraphic);
        }
예제 #6
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);
        }
예제 #7
0
        /// <summary>
        /// Will convert a given set of projected coordinates into geographic ones.
        /// </summary>
        public async void DisplayGeoCoordinatesAsync()
        {
            //XY
            int x_value = 0;
            int y_value = 0;

            if (_locationEasting != string.Empty)
            {
                x_value = int.Parse(_locationEasting);
            }
            if (_locationNorthing != string.Empty)
            {
                y_value = int.Parse(_locationNorthing);
            }

            //Transform
            if (x_value != 0.0 && y_value != 0.0)
            {
                //Bad system
                bool isSystemValid = false;

                if (_selectedLocationDatums != null)
                {
                    //Detect a projected system
                    int selectedEPGS = 0;
                    int.TryParse(_selectedLocationDatums, out selectedEPGS);

                    if (selectedEPGS > 10000)
                    {
                        //Detect Datum difference
                        SpatialReference inSR  = new Esri.ArcGISRuntime.Geometry.SpatialReference(selectedEPGS);
                        SpatialReference outSR = SpatialReferences.Wgs84; //Default
                        if ((selectedEPGS > 26900 && selectedEPGS < 27000) || selectedEPGS == 4617)
                        {
                            outSR = new Esri.ArcGISRuntime.Geometry.SpatialReference(4617);
                        }

                        //Get geographic point
                        MapPoint geoPoint = CalculateGeographicCoordinate(x_value, y_value, inSR, outSR);

                        double y = geoPoint.Y;
                        double x = geoPoint.X;
                        _locationLatitude  = y.ToString();
                        _locationLongitude = x.ToString();

                        isSystemValid = true;
                    }
                }

                if (!isSystemValid && _selectedLocationDatums != null && _selectedLocationDatums != string.Empty)
                {
                    //Show warning to select something
                    await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
                    {
                        ContentDialog defaultEventLocationDialog = new ContentDialog()
                        {
                            Title           = local.GetString("LocationDialogDatumTitle"),
                            Content         = local.GetString("LocationDialogDatumContent"),
                            CloseButtonText = local.GetString("GenericDialog_ButtonOK")
                        };
                        defaultEventLocationDialog.Style = (Style)Application.Current.Resources["WarningDialog"];
                        await Services.ContentDialogMaker.CreateContentDialogAsync(defaultEventLocationDialog, true);
                    }).AsTask();
                }
            }
            else
            {
                _locationLongitude = x_value.ToString();
                _locationLatitude  = y_value.ToString();
            }

            RaisePropertyChanged("LocationLatitude");
            RaisePropertyChanged("LocationLongitude");
        }
예제 #8
0
        /// <summary>
        /// On save event
        /// </summary>
        public async void SaveDialogInfoAsync()
        {
            //Parse coordinate pairs
            double _long     = 0.0;
            double _lat      = 0.0;
            int    _easting  = 0;
            int    _northing = 0;

            double.TryParse(_locationLongitude, out _long);
            double.TryParse(_locationLatitude, out _lat);
            int.TryParse(_locationEasting, out _easting);
            int.TryParse(_locationNorthing, out _northing);

            //Detect a projected system
            int selectedEPGS = 0;

            int.TryParse(SelectedLocationDatums.ToString(), out selectedEPGS);

            //Make sure that everything has been filled
            if ((_long == 0 || _lat == 0) && (_easting != 0 || _northing != 0))
            {
                //Detect Datum difference
                SpatialReference inSR  = new Esri.ArcGISRuntime.Geometry.SpatialReference(selectedEPGS);
                SpatialReference outSR = SpatialReferences.Wgs84; //Default
                if ((selectedEPGS > 26900 && selectedEPGS < 27000) || selectedEPGS == 4617)
                {
                    outSR = new Esri.ArcGISRuntime.Geometry.SpatialReference(4617);
                }

                MapPoint geoSave = CalculateGeographicCoordinate(_easting, _northing, inSR, outSR);
                if (geoSave != null)
                {
                    LocationLongitude = geoSave.X.ToString();
                    LocationLatitude  = geoSave.Y.ToString();
                    RaisePropertyChanged("LocationLongitude");
                    RaisePropertyChanged("LocationLatitude");
                }
            }

            //Get current class information and add to model
            locationModel.LocationID    = LocationID; //Prime key
            locationModel.LocationAlias = LocationAlias;
            locationModel.LocationLat   = _lat;
            locationModel.LocationLong  = _long;
            locationModel.LocationElev  = Double.Parse(LocationElevation);
            locationModel.MetaID        = localSetting.GetSettingValue(Dictionaries.DatabaseLiterals.FieldUserInfoID).ToString(); //Foreign key
            locationModel.LocationNotes = LocationNotes;

            locationModel.LocationEasting  = _easting;
            locationModel.LocationNorthing = _northing;


            if (SelectedLocationDatums != null)
            {
                locationModel.LocationDatum = SelectedLocationDatums;
            }

            if (entryType != null)
            {
                locationModel.LocationEntryType = entryType;
            }


            //Save model class
            accessData.SaveFromSQLTableObject(locationModel, doLocationUpdate);

            //Launch an event call for everyone that an earthmat has been edited.
            if (newLocationEdit != null)
            {
                newLocationEdit(this);
            }
        }
예제 #9
0
        private static Graphic CreateRoadGraphic(GeoJsonFeature <GeoJsonPolygon> roadFeature, Esri.ArcGISRuntime.Geometry.SpatialReference originalSpatialReference, Esri.ArcGISRuntime.Geometry.SpatialReference targetSpatialReference)
        {
            var roadPolyline = CreatePolyline(roadFeature.Geometry.Coordinates, originalSpatialReference);

            if (!originalSpatialReference.IsEqual(targetSpatialReference))
            {
                // In den Raumbezug der Karte projezieren
                roadPolyline = (Esri.ArcGISRuntime.Geometry.Polyline)GeometryEngine.Project(roadPolyline, targetSpatialReference);
            }

            var roadGraphic = new Graphic(roadPolyline, roadFeature.Properties);

            return(roadGraphic);
        }
예제 #10
0
        private static Esri.ArcGISRuntime.Geometry.Polyline CreatePolyline(PointCollectionList parts, Esri.ArcGISRuntime.Geometry.SpatialReference spatialReference)
        {
            var builder = new PolylineBuilder(spatialReference);

            foreach (var part in parts)
            {
                var roadPart = new Part(spatialReference);
                foreach (var vertex in part)
                {
                    var point = CreatePoint(vertex, spatialReference);
                    if (!point.IsEmpty)
                    {
                        roadPart.AddPoint(point);
                    }
                }
                builder.AddPart(roadPart);
            }
            return(builder.ToGeometry());
        }