Exemplo n.º 1
0
 //When location changes, push this location to the route datasource
 private void LocationDisplay_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Location")
     {
         if (LocationDisplay.Location != null && LocationDisplay.Location.Position != null && !LocationDisplay.Location.Position.IsEmpty)
         {
             if (Route != null)
             {
                 Route.SetCurrentLocation(LocationDisplay.Location.Position);
             }
             if (firstLocation)
             {
                 var accuracy = double.IsNaN(LocationDisplay.Location.HorizontalAccuracy) ? 0 :
                                LocationDisplay.Location.HorizontalAccuracy;
                 ViewpointRequested = new Viewpoint(
                     GeometryEngine.BufferGeodetic(LocationDisplay.Location.Position, accuracy + 500, LinearUnits.Meters)
                     );
                 firstLocation = false;
                 if (Route == null && m_routeTaskCancellationToken == null && !string.IsNullOrWhiteSpace(RouteToAddress))                         //calculate route now
                 //Calculate a route from the address
                 {
                     GenerateRoute(RouteToAddress);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        private async void LostPet_ClickAsync(object sender, EventArgs e)
        {
            if (_selectedLocation == null)
            {
                return;
            }

            _lostLocation = _selectedLocation;

            _lostOverlay.Graphics.Clear();
            _bufferOverlay.Graphics.Clear();


            Geometry bufferGeometryGeodesic = GeometryEngine.BufferGeodetic(_lostLocation, _radius, LinearUnits.Miles, double.NaN, GeodeticCurveType.Geodesic);
            Color    customColor            = Color.FromArgb(60, Color.Orange);
            Graphic  geodesicBufferGraphic  = new Graphic(bufferGeometryGeodesic, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, customColor, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 2.0)));

            Console.WriteLine(bufferGeometryGeodesic.ToJson());
            Console.WriteLine(bufferGeometryGeodesic.ToString());
            Console.WriteLine(bufferGeometryGeodesic.GeometryType.ToString());

            Geometry bufferGeometryGeodesic2 = GeometryEngine.BufferGeodetic(_lostLocation, _radius * 0.66, LinearUnits.Miles, double.NaN, GeodeticCurveType.Geodesic);
            Geometry bufferGeometryGeodesic3 = GeometryEngine.BufferGeodetic(_lostLocation, _radius * 0.33, LinearUnits.Miles, double.NaN, GeodeticCurveType.Geodesic);
            Graphic  geodesicBufferGraphic2  = new Graphic(bufferGeometryGeodesic2, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, customColor, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 2.0)));

            Graphic geodesicBufferGraphic3 = new Graphic(bufferGeometryGeodesic3, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, customColor, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 2.0)));

            _bufferOverlay.Graphics.Add(geodesicBufferGraphic);
            _bufferOverlay.Graphics.Add(geodesicBufferGraphic2);
            _bufferOverlay.Graphics.Add(geodesicBufferGraphic3);

            await _mapView.SetViewpointAsync(new Viewpoint(geodesicBufferGraphic.Geometry.Extent));

            CreateErrorDialog("Lost dog submitted to GeoEvent");
        }
        private void ConfigureTileLayerOverrides(GenerateOfflineMapParameterOverrides overrides)
        {
            // Create a parameter key for the first basemap layer.
            OfflineMapParametersKey basemapKey = new OfflineMapParametersKey(MyMapView.Map.Basemap.BaseLayers.First());

            // Get the export tile cache parameters for the layer key.
            ExportTileCacheParameters basemapParams = overrides.ExportTileCacheParameters[basemapKey];

            // Clear the existing level IDs.
            basemapParams.LevelIds.Clear();

            // Get the min and max scale from the UI.
            int minScale = (int)MinScaleEntry.Value;
            int maxScale = (int)MaxScaleEntry.Value;

            // Re-add selected scales.
            for (int i = minScale; i < maxScale; i++)
            {
                basemapParams.LevelIds.Add(i);
            }

            // Expand the area of interest based on the specified buffer distance.
            int bufferDistance = (int)ExtentBufferEntry.Value;

            basemapParams.AreaOfInterest = GeometryEngine.BufferGeodetic(_areaOfInterest, bufferDistance, LinearUnits.Meters);
        }
Exemplo n.º 4
0
        protected Polygon CreatePolygon(Esri.ArcGISRuntime.Geometry.PointCollection mappoints)
        {
            var poly = new Polygon(mappoints); // new List<Esri.ArcGISRuntime.Geometry.PointCollection> { points }, sref);

            GeometryEngine.BufferGeodetic(poly, 0, LinearUnits.Kilometers);
            //GeometryEngine.DensifyGeodetic(poly, 10, LinearUnits.Kilometers);
            return(poly);
        }
Exemplo n.º 5
0
        public virtual List <T> ListByPosition(MapPoint point, double toleranceMeters = 0)
        {
            Geometry buf = (toleranceMeters > 0 ? GeometryEngine.BufferGeodetic(point, toleranceMeters, LinearUnits.Meters) : point);

            IEnumerable <T> elements = Elements.Where(r => GeometryEngine.Intersects(r.Graphic.Geometry, buf));

            return(elements.ToList());
        }
Exemplo n.º 6
0
        public virtual T ByPosition(MapPoint point, double toleranceMeters = 0)
        {
            Geometry buf = (toleranceMeters > 0 ? GeometryEngine.BufferGeodetic(point, toleranceMeters, LinearUnits.Meters) : point);

            IEnumerable <T> elements = Elements.Where(r => GeometryEngine.Intersects(r.Graphic.Geometry, buf));

            //Console.WriteLine("ByPosition({0}) found {1} elements", typeof(T).Name, elements.Count());
            return(elements.FirstOrDefault());
        }
        public FakeLocationDataSource()
        {
            // Generate the points that will be used.

            // The location will walk around a circle around the point.
            Polygon outerCircle = (Polygon)GeometryEngine.BufferGeodetic(_circleRouteCenter, 1000, LinearUnits.Feet);

            // Get a list of points on the circle from the buffered point.
            _artificialMapPoints = outerCircle.Parts[0].Points.ToList();
        }
Exemplo n.º 8
0
        private void OnAddPolygonsCommand()
        {
            var points = GetPoints();

            foreach (var point in points)
            {
                var polygon = GeometryEngine.BufferGeodetic(point, 3, LinearUnits.Kilometers);
                GraphicsProvider.Publish(new MapObject(polygon)
                {
                    LayerId = LayerKeys.Polygon.ToString()
                });
            }
        }
        public FakeLocationDataSource()
        {
            // Generate the points that will be used.

            // The location will walk around a circle around the point.
            Polygon outerCircle = (Polygon)GeometryEngine.BufferGeodetic(_circleRouteCenter, 1000, LinearUnits.Feet);

            // Get a list of points on the circle from the buffered point.
            _artificialMapPoints = outerCircle.Parts[0].Points.ToList();

            // Create the timer and configure it to repeat every second.
            _timer           = new Timer(1000);
            _timer.AutoReset = true;

            // Listen for timer elapsed events.
            _timer.Elapsed += TimerOnElapsed;
        }
        private void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Hide keyboard if present.
            _bufferDistanceMilesTextField.ResignFirstResponder();

            try
            {
                // Get the location tapped by the user (a map point in the WebMercator projected coordinate system).
                MapPoint userTapPoint = e.Location;

                // Get the buffer distance (miles) entered in the text box.
                double bufferInMiles = Convert.ToDouble(_bufferDistanceMilesTextField.Text);

                // Call a helper method to convert the input distance to meters.
                double bufferInMeters = LinearUnits.Miles.ToMeters(bufferInMiles);

                // Create a planar buffer graphic around the input location at the specified distance.
                Geometry bufferGeometryPlanar = GeometryEngine.Buffer(userTapPoint, bufferInMeters);
                Graphic  planarBufferGraphic  = new Graphic(bufferGeometryPlanar);

                // Create a geodesic buffer graphic using the same location and distance.
                Geometry bufferGeometryGeodesic = GeometryEngine.BufferGeodetic(userTapPoint, bufferInMeters, LinearUnits.Meters, double.NaN, GeodeticCurveType.Geodesic);
                Graphic  geodesicBufferGraphic  = new Graphic(bufferGeometryGeodesic);

                // Create a graphic for the user tap location.
                Graphic locationGraphic = new Graphic(userTapPoint);

                // Get the graphics overlays.
                GraphicsOverlay planarBufferGraphicsOverlay   = _myMapView.GraphicsOverlays["PlanarPolys"];
                GraphicsOverlay geodesicBufferGraphicsOverlay = _myMapView.GraphicsOverlays["GeodesicPolys"];
                GraphicsOverlay tapPointGraphicsOverlay       = _myMapView.GraphicsOverlays["TapPoints"];

                // Add the buffer polygons and tap location graphics to the appropriate graphic overlays.
                planarBufferGraphicsOverlay.Graphics.Add(planarBufferGraphic);
                geodesicBufferGraphicsOverlay.Graphics.Add(geodesicBufferGraphic);
                tapPointGraphicsOverlay.Graphics.Add(locationGraphic);
            }
            catch (Exception ex)
            {
                // Display an error message if there is a problem generating the buffers.
                UIAlertController alertController = UIAlertController.Create("Error creating buffers", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
            }
        }
Exemplo n.º 11
0
        private void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            try
            {
                // Get the location tapped by the user (a map point in the WebMercator projected coordinate system).
                MapPoint userTapPoint = e.Location;

                // Get the buffer distance (miles) entered in the text box.
                double bufferInMiles = System.Convert.ToDouble(_bufferDistanceMilesEditText.Text);

                // Call a helper method to convert the input distance to meters.
                double bufferInMeters = LinearUnits.Miles.ToMeters(bufferInMiles);

                // Create a planar buffer graphic around the input location at the specified distance.
                Geometry bufferGeometryPlanar = GeometryEngine.Buffer(userTapPoint, bufferInMeters);
                Graphic  planarBufferGraphic  = new Graphic(bufferGeometryPlanar);

                // Create a geodesic buffer graphic using the same location and distance.
                Geometry bufferGeometryGeodesic = GeometryEngine.BufferGeodetic(userTapPoint, bufferInMeters, LinearUnits.Meters, double.NaN, GeodeticCurveType.Geodesic);
                Graphic  geodesicBufferGraphic  = new Graphic(bufferGeometryGeodesic);

                // Create a graphic for the user tap location.
                Graphic locationGraphic = new Graphic(userTapPoint);

                // Get the graphics overlays.
                GraphicsOverlay planarBufferGraphicsOverlay   = _myMapView.GraphicsOverlays["PlanarPolys"];
                GraphicsOverlay geodesicBufferGraphicsOverlay = _myMapView.GraphicsOverlays["GeodesicPolys"];
                GraphicsOverlay tapPointGraphicsOverlay       = _myMapView.GraphicsOverlays["TapPoints"];

                // Add the buffer polygons and tap location graphics to the appropriate graphic overlays.
                planarBufferGraphicsOverlay.Graphics.Add(planarBufferGraphic);
                geodesicBufferGraphicsOverlay.Graphics.Add(geodesicBufferGraphic);
                tapPointGraphicsOverlay.Graphics.Add(locationGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating the buffer polygon.
                AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
                alertBuilder.SetTitle("There was a problem generating buffers.");
                alertBuilder.SetMessage(ex.ToString());
                alertBuilder.Show();
            }
        }
Exemplo n.º 12
0
        protected override void GenerateGraphicFor(Sensor element)
        {
            MapPoint position = element.Position.ToEsriPoint();

            element.Graphic = new Graphic(position, GeneralRenderers.SensorPicSymbol);

            Polygon range = GeometryEngine.BufferGeodetic(position, Sensor.Range, LinearUnits.Meters) as Polygon;

            element.RangeGraphic           = new Graphic(range, GeneralRenderers.SensorRangeFillSymbol);
            element.RangeGraphic.IsVisible = true;

            Polygon alarm = GeometryEngine.BufferGeodetic(position, 1.0, LinearUnits.Meters) as Polygon;

            element.AlarmGraphic           = new Graphic(range, GeneralRenderers.SensorAlarmFillSymbol);
            element.AlarmGraphic.IsVisible = false;

            BaseOverlay.Graphics.Add(element.RangeGraphic);
            BaseOverlay.Graphics.Add(element.AlarmGraphic);
            BaseOverlay.Graphics.Add(element.Graphic);
        }
        private void ConfigureTileLayerOverrides()
        {
            // Create a parameter key for the first basemap layer.
            OfflineMapParametersKey basemapKey = new OfflineMapParametersKey(_map.Basemap.BaseLayers.First());

            // Get the export tile cache parameters for the layer key.
            ExportTileCacheParameters basemapParams = _overrides.ExportTileCacheParameters[basemapKey];

            // Clear the existing level IDs.
            basemapParams.LevelIds.Clear();

            // Re-add selected scales.
            for (int i = _minScale; i < _maxScale; i++)
            {
                basemapParams.LevelIds.Add(i);
            }

            // Expand the area of interest based on the specified buffer distance.
            basemapParams.AreaOfInterest = GeometryEngine.BufferGeodetic(_areaOfInterest, _bufferExtent, LinearUnits.Meters);
        }
Exemplo n.º 14
0
        private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            try
            {
                // Get the location tapped by the user (a map point in the WebMercator projected coordinate system).
                MapPoint userTapPoint = e.Location;

                // Get the buffer distance (miles) entered in the text box.
                double bufferInMiles = System.Convert.ToDouble(BufferDistanceMilesEntry.Text);

                // Call a helper method to convert the input distance to meters.
                double bufferInMeters = LinearUnits.Miles.ToMeters(bufferInMiles);

                // Create a planar buffer graphic around the input location at the specified distance.
                Geometry bufferGeometryPlanar = GeometryEngine.Buffer(userTapPoint, bufferInMeters);
                Graphic  planarBufferGraphic  = new Graphic(bufferGeometryPlanar);

                // Create a geodesic buffer graphic using the same location and distance.
                Geometry bufferGeometryGeodesic = GeometryEngine.BufferGeodetic(userTapPoint, bufferInMeters, LinearUnits.Meters, double.NaN, GeodeticCurveType.Geodesic);
                Graphic  geodesicBufferGraphic  = new Graphic(bufferGeometryGeodesic);

                // Create a graphic for the user tap location.
                Graphic locationGraphic = new Graphic(userTapPoint);

                // Get the graphics overlays.
                GraphicsOverlay planarBufferGraphicsOverlay   = MyMapView.GraphicsOverlays["PlanarPolys"];
                GraphicsOverlay geodesicBufferGraphicsOverlay = MyMapView.GraphicsOverlays["GeodesicPolys"];
                GraphicsOverlay tapPointGraphicsOverlay       = MyMapView.GraphicsOverlays["TapPoints"];

                // Add the buffer polygons and tap location graphics to the appropriate graphic overlays.
                planarBufferGraphicsOverlay.Graphics.Add(planarBufferGraphic);
                geodesicBufferGraphicsOverlay.Graphics.Add(geodesicBufferGraphic);
                tapPointGraphicsOverlay.Graphics.Add(locationGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating the buffers.
                Page currentPage = (App.Current.MainPage as NavigationPage).CurrentPage;
                currentPage.DisplayAlert(ex.Message, "Error creating buffers", "OK");
            }
        }
        private async void HandleMapTap(MapPoint mapLocation)
        {
            // Normalize geometry - important for geometries that will be sent to a server for processing.
            mapLocation = (MapPoint)GeometryEngine.NormalizeCentralMeridian(mapLocation);

            switch (_currentSampleState)
            {
            case SampleState.AddingBarriers:
                // Buffer the tapped point to create a larger barrier.
                Geometry bufferedGeometry = GeometryEngine.BufferGeodetic(mapLocation, 500, LinearUnits.Meters);

                // Create the graphic to show the barrier.
                Graphic barrierGraphic = new Graphic(bufferedGeometry, _barrierSymbol);

                // Add the graphic to the overlay - this will cause it to appear on the map.
                _barriersOverlay.Graphics.Add(barrierGraphic);
                break;

            case SampleState.AddingStops:
                // Get the name of this stop.
                string stopName = $"{_stopsOverlay.Graphics.Count + 1}";

                // Create the marker to show underneath the stop number.
                PictureMarkerSymbol pushpinMarker = await GetPictureMarker();

                // Create the text symbol for showing the stop.
                TextSymbol stopSymbol = new TextSymbol(stopName, System.Drawing.Color.White, 15,
                                                       HorizontalAlignment.Center, VerticalAlignment.Middle);
                stopSymbol.OffsetY = 15;

                CompositeSymbol combinedSymbol = new CompositeSymbol(new MarkerSymbol[] { pushpinMarker, stopSymbol });

                // Create the graphic to show the stop.
                Graphic stopGraphic = new Graphic(mapLocation, combinedSymbol);

                // Add the graphic to the overlay - this will cause it to appear on the map.
                _stopsOverlay.Graphics.Add(stopGraphic);
                break;
            }
        }
Exemplo n.º 16
0
        public static Geometry GetBuffer(Geometry geometry, double meters)
        {
            Geometry buf = GeometryEngine.BufferGeodetic(geometry, meters, LinearUnits.Meters);

            return(buf);
        }