private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
              graphicsLayer.ClearGraphics();

              e.MapPoint.SpatialReference = MyMap.SpatialReference;
              Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
              {
            Geometry = e.MapPoint,
            Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
              };
              graphic.SetZIndex(1);
              graphicsLayer.Graphics.Add(graphic);

              GeometryService geometryService =
            new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");
              geometryService.BufferCompleted += GeometryService_BufferCompleted;
              geometryService.Failed += GeometryService_Failed;

              // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
              BufferParameters bufferParams = new BufferParameters()
              {
            Unit = chkGeodesic.IsChecked.HasValue && chkGeodesic.IsChecked.Value ? LinearUnit.StatuteMile : (LinearUnit?)null,
            BufferSpatialReference = new SpatialReference(4326),
            OutSpatialReference = MyMap.SpatialReference
              };
              bufferParams.Features.Add(graphic);
              bufferParams.Distances.Add(5);
              bufferParams.Geodesic = chkGeodesic.IsChecked == true ? true : false;

              geometryService.BufferAsync(bufferParams);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.ClearGraphics();

            e.MapPoint.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = e.MapPoint,
                Symbol   = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };

            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

            GeometryService geometryService =
                new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

            geometryService.BufferCompleted += GeometryService_BufferCompleted;
            geometryService.Failed          += GeometryService_Failed;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            BufferParameters bufferParams = new BufferParameters()
            {
                Unit = LinearUnit.StatuteMile,
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference    = MyMap.SpatialReference
            };

            bufferParams.Features.Add(graphic);
            bufferParams.Distances.Add(5);

            geometryService.BufferAsync(bufferParams);
        }
        void myDrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            myDrawObject.IsEnabled = false;
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.ClearGraphics();

            Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = e.Geometry,
                Symbol   = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };

            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

            GeometryService geometryService =
                new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");

            geometryService.BufferCompleted += GeometryService_BufferCompleted;
            geometryService.Failed          += GeometryService_Failed;

            BufferParameters bufferParams = new BufferParameters()
            {
                Unit = LinearUnit.StatuteMile,
                OutSpatialReference = MyMap.SpatialReference,
                Geodesic            = true
            };

            bufferParams.Features.Add(graphic);
            bufferParams.Distances.Add(5);

            geometryService.BufferAsync(bufferParams);
        }
示例#4
0
        public void ProcessBuffer()   // 传入空间对象进行buffer计算,
        {
            try
            {
                _geometryService.CancelAsync();

                Graphic TempGraphic = new Graphic();
                TempGraphic.Geometry = bgeom;
                TempGraphic.Geometry.SpatialReference = new SpatialReference(4326);

                BufferParameters bufferParams = new BufferParameters()
                {
                    BufferSpatialReference = new SpatialReference(102113),
                    OutSpatialReference    = new SpatialReference(4326),
                    Unit = LinearUnit.Meter
                };
                //       double degree = Distance / (106 * 1000);
                //      bufferParams.Distances.AddRange(new double[] { degree  , degree   });
                bufferParams.Distances.Add(Distance);
                bufferParams.Features.Add(TempGraphic);
                _geometryService.BufferAsync(bufferParams);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        private void AddBufferedPoint()
        {
            GraphicsLayer graphicsLayer = myMap.Layers["zoneLayer"] as GraphicsLayer;

            rightClickedPoint.SpatialReference = myMap.SpatialReference;
            Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = rightClickedPoint,
                Symbol   = SimplePointSymbol
            };

            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

            GeometryService geometryService =
                new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

            geometryService.BufferCompleted += GeometryService_BufferCompleted;
            geometryService.Failed          += GeometryService_Failed;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            BufferParameters bufferParams = new BufferParameters()
            {
                Unit = selectedUnit,
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference    = myMap.SpatialReference
            };

            bufferParams.Features.Add(graphic);
            bufferParams.Distances.Add(selectedRadius);

            geometryService.BufferAsync(bufferParams);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            _geometryService.CancelAsync();
            _queryTask.CancelAsync();

            Graphic clickGraphic = new Graphic();

            clickGraphic.Symbol   = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = e.MapPoint;
            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference;

            _pointAndBufferGraphicsLayer.ClearGraphics();
            _resultsGraphicsLayer.ClearGraphics();

            clickGraphic.SetZIndex(2);
            _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic);

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference    = MyMap.SpatialReference,
                Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(100);
            bufferParams.Features.Add(clickGraphic);

            _geometryService.BufferAsync(bufferParams);
        }
示例#7
0
 public int _Action(Graphic _G)
 {
     _BufferParameters.Features.Add(_G);
     MyGS.BufferAsync(_BufferParameters);
     while (!Failed && !Completed)
     {
         foreach (Graphic graphic in results)
         {
             graphic.Symbol = LayoutRoot.Resources["DefaultBufferSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
             graphicsLayer.Graphics.Add(graphic);
         }
     }
     return(0);
 }
示例#8
0
        private void CreateBufferZone(double bufferDistance, Graphic graphic, string units)
        {
            if (geometryService != null)
            {
                int bufferSRWKID           = widgetConfig.ProjectToWKID;
                BufferParameters bufParams = new BufferParameters();
                bufParams.BufferSpatialReference = new SpatialReference((bufferSRWKID == 0) ? 102003 : bufferSRWKID);
                bufParams.OutSpatialReference    = new SpatialReference(this.MapSRWKID);
                bufParams.Distances.Add(bufferDistance);
                bufParams.UnionResults = true;

                // Make the geometry's Spatial Reference consistent with Map's
                // QueryTask returns 3857 instead of 102100 when BING layers are used in the base map
                graphic.Geometry.SpatialReference = new SpatialReference(this.MapSRWKID);

                if (RadioBufferCenter.IsChecked.Value && !(graphic.Geometry is MapPoint))
                {
                    MapPoint center = graphic.Geometry.Extent.GetCenter();
                    center.SpatialReference = new SpatialReference(this.MapSRWKID);
                    Graphic graphic1 = new Graphic();
                    graphic1.Geometry = center;

                    bufParams.Features.Add(graphic1);
                }
                else
                {
                    bufParams.Features.Add(graphic);
                }

                switch (units)
                {
                case "Feet": bufParams.Unit = LinearUnit.Foot; break;

                case "Yards": bufParams.Unit = LinearUnit.SurveyYard; break;

                case "Miles": bufParams.Unit = LinearUnit.StatuteMile; break;

                case "Meters": bufParams.Unit = LinearUnit.Meter; break;

                default: bufParams.Unit = LinearUnit.Foot; break;
                }

                geometryService.BufferAsync(bufParams);
            }
            else
            {
                MessageBox.Show("Geometry Service must be configurated to create a buffer zone.");
            }
        }
        // ***********************************************************************************
        // * ...Set the map mouseclick event so that user can enter the incident
        // ***********************************************************************************
        private void btnSolve_Click(object sender, RoutedEventArgs e)
        {
            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            _bufferParams      = new BufferParameters();
            _bufferParams.Unit = currentLinearUnit();
            _bufferParams.BufferSpatialReference = new SpatialReference(4326);
            _bufferParams.OutSpatialReference    = _mapWidget.Map.SpatialReference;

            _bufferParams.Features.Clear();
            if (_selectedRadioButtonName == "rbDrawPoints" || _selectedRadioButtonName == "rbSelectedFeaturesFromLayer")
            {
                _bufferParams.Features.AddRange(_bufferPointLayer.Graphics);
            }
            else if (_selectedRadioButtonName == "rbSelectedFeaturesOnMap")
            {
                _bufferPointLayer.ClearGraphics();

                IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {
                    client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d);
                    if (featureL.SelectionCount > 0)
                    {
                        _bufferParams.Features.AddRange(featureL.SelectedGraphics);
                    }
                }
            }

            if (_bufferParams.Features.Count == 0)
            {
                MessageBox.Show("Please select features on the map first", "Error");
                return;
            }

            var bufferDistance = Convert.ToDouble(ringInterval.Text);
            var ringDistance   = bufferDistance;

            var numRings = Convert.ToInt32(numberOfRings.Text);

            for (var i = 0; i < numRings; i++)
            {
                _bufferParams.Distances.Add(ringDistance);
                ringDistance = ringDistance + bufferDistance;
            }

            _geometryService.BufferAsync(_bufferParams);
        }
示例#10
0
        private void CacheSnapObjects(ESRI.ArcGIS.Client.Geometry.Geometry geometryObject, double snapDistance)
        {
            // For the given geometry (line or circle), find all the features that fall within the snapDistance.
            // First we need to issue a buffer in this method. GeometryService_LineBufferCompleted will
            // do the feature query.

            _snapObjects.Clear();
            GeometryService geometryServiceScaleRotate = new GeometryService(_xmlConfiguation.GeometryServerUrl);

            if (geometryServiceScaleRotate == null)
            {
                return;
            }

            geometryServiceScaleRotate.BufferCompleted += GeometryService_LineBufferCompleted;
            geometryServiceScaleRotate.Failed          += GeometryService_Failed;
            geometryServiceScaleRotate.CancelAsync();

            Graphic clickGraphic = new Graphic();

            clickGraphic.Symbol   = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = geometryObject;

            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = ParcelMap.SpatialReference,
                OutSpatialReference    = ParcelMap.SpatialReference,
            };
            bufferParams.Distances.Add(snapDistance);
            bufferParams.Features.Add(clickGraphic);

            System.Diagnostics.Debug.WriteLine("Async: Buffering potential candidates for snapping.");
            geometryServiceScaleRotate.BufferAsync(bufferParams, snapDistance);
        }
        private void CalculateDistance(MapPoint mapPoint)
        {
            double dDistance = 0;

            if (Double.TryParse(tbDistanceValue.Text, out dDistance) == false)
            {
                return;
            }
            if (dDistance <= 0)
            {
                return;
            }

            LinearUnit unit = EncodeLinearUnit(comboDistanceUnit.SelectionBoxItem.ToString());

            _geometryService.CancelAsync();

            Graphic clickGraphic = new Graphic();

            //clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = mapPoint;

            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = Map.SpatialReference;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference    = Map.SpatialReference,
                Unit = unit,
            };
            bufferParams.Distances.Add(dDistance);
            bufferParams.Features.Add(clickGraphic);

            _geometryService.BufferAsync(bufferParams);
        }
        void buffer(string agsGeometryServerUrl, BufferParameters bufferParams, FindNearbyEventArgs findNearbyRequest)
        {
            if (string.IsNullOrEmpty(agsGeometryServerUrl))
            {
                return;
            }

            GeometryService geomService = new GeometryService
            {
                Url = agsGeometryServerUrl
            };

            geomService.BufferCompleted += GeometryService_BufferCompleted;
            geomService.Failed          += (o, e) =>
            {
                if (findNearbyToolWindow != null)
                {
                    findNearbyToolWindow.StopBusyIndicator();
                    MapApplication.Current.HideWindow(findNearbyToolWindow);
                }
                MessageBoxDialog.Show(Resources.Strings.MsgErrorExecutingBufferOperation + Environment.NewLine + e.Error.ToString());
            };
            geomService.BufferAsync(bufferParams, findNearbyRequest);
        }
        public void IdentifyPoint(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint)
        {
            if (config.IdentifyURL == "")
            {
                return;
            }

            if (config.IdentifyLayerCount == 0)
            {
                return;
            }

            if (config.UseQueryIdentify)
            {
                _dataItems = new List <DataItem>();

                GeometryService geometryServicePointSnap = new GeometryService(config.GeometryServerUrl);
                if (geometryServicePointSnap == null)
                {
                    return;
                }

                QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);

                geometryServicePointSnap.BufferCompleted += GeometryService_IdentifyPointBufferCompleted;
                geometryServicePointSnap.Failed          += GeometryService_Failed;
                geometryServicePointSnap.CancelAsync();

                SimpleMarkerSymbol defaultSymbolMarker = new SimpleMarkerSymbol()
                {
                    Color = System.Windows.Media.Brushes.Black, Size = 8,
                    Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
                };

                Graphic clickGraphic = new Graphic();
                clickGraphic.Symbol   = defaultSymbolMarker as ESRI.ArcGIS.Client.Symbols.Symbol;
                clickGraphic.Geometry = clickPoint;

                // Input spatial reference for buffer operation defined by first feature of input geometry array
                clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

                // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
                {
                    BufferSpatialReference = ParcelMap.SpatialReference,
                    OutSpatialReference    = ParcelMap.SpatialReference,
                    Unit = LinearUnit.Meter,
                };
                bufferParams.Distances.Add(config.SnapTolerance * config.SpatialReferenceUnitsPerMeter);
                bufferParams.Features.Add(clickGraphic);
                geometryServicePointSnap.BufferAsync(bufferParams, queryItem);
            }
            else
            {
                ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
                {
                    Geometry         = clickPoint,
                    MapExtent        = ParcelMap.Extent,
                    Width            = (int)ParcelMap.ActualWidth,
                    Height           = (int)ParcelMap.ActualHeight,
                    LayerOption      = LayerOption.visible,
                    SpatialReference = ParcelMap.SpatialReference
                };

                // For performance, we allow certain layers to be only identified.
                if (config.IdentifyLayerIDs != null)
                {
                    foreach (int id in config.IdentifyLayerIDs)
                    {
                        identifyParams.LayerIds.Add(id);
                    }
                }

                IdentifyTask identifyTask = new IdentifyTask(config.IdentifyURL);
                identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
                identifyTask.Failed           += IdentifyTask_Failed;

                QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);
                identifyTask.ExecuteAsync(identifyParams, queryItem);
            }
        }
        private void RunButton_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtAddress.Text == "Enter Address")
                {
                    int BuildingEvacDistance = 0;
                    int OutdoorEvacDistance  = 0;

                    if (bombType.Text == "Pipe bomb")
                    {
                        BuildingEvacDistance = 70;
                        OutdoorEvacDistance  = 1200;
                    }
                    else if (bombType.Text == "Suicide vest")
                    {
                        BuildingEvacDistance = 110;
                        OutdoorEvacDistance  = 1750;
                    }
                    else if (bombType.Text == "Briefcase/suitcase bomb")
                    {
                        BuildingEvacDistance = 150;
                        OutdoorEvacDistance  = 1850;
                    }
                    else if (bombType.Text == "Sedan")
                    {
                        BuildingEvacDistance = 320;
                        OutdoorEvacDistance  = 1900;
                    }
                    else if (bombType.Text == "SUV/van")
                    {
                        BuildingEvacDistance = 400;
                        OutdoorEvacDistance  = 2400;
                    }
                    else if (bombType.Text == "Small delivery truck")
                    {
                        BuildingEvacDistance = 640;
                        OutdoorEvacDistance  = 3800;
                    }
                    else if (bombType.Text == "Container/water truck")
                    {
                        BuildingEvacDistance = 860;
                        OutdoorEvacDistance  = 5100;
                    }
                    else if (bombType.Text == "Semi-trailer")
                    {
                        BuildingEvacDistance = 1570;
                        OutdoorEvacDistance  = 9300;
                    }
                    if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0)
                    {
                        return;
                    }



                    //e.MapPoint.SpatialReference = _mapWidget.Map.SpatialReference;
                    //location = e.MapPoint;
                    if (location == null)
                    {
                        return;
                    }
                    Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = location;

                    GeometryService geometryTask = new GeometryService();
                    geometryTask.Url              = "http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer";
                    geometryTask.BufferCompleted += GeometryService_BufferCompleted;
                    geometryTask.Failed          += GeometryService_Failed;

                    // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                    BufferParameters bufferParams = new BufferParameters()
                    {
                        Unit = LinearUnit.SurveyFoot,
                        BufferSpatialReference = new SpatialReference(102004),
                        OutSpatialReference    = _mapWidget.Map.SpatialReference
                    };
                    bufferParams.Features.Add(graphic);
                    double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance };
                    bufferParams.Distances.AddRange(theDistances);
                    geometryTask.BufferAsync(bufferParams);
                }
                else
                {
                    findAddress();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error in run: " + ex.Message);
            }
        }
示例#15
0
        private void CacheSnapObjects(ESRI.ArcGIS.Client.Geometry.Geometry geometryObject, double snapDistance)
        {
            // For the given geometry (line or circle), find all the features that fall within the snapDistance.
              // First we need to issue a buffer in this method. GeometryService_LineBufferCompleted will
              // do the feature query.

              _snapObjects.Clear();
              GeometryService geometryServiceScaleRotate = new GeometryService(_xmlConfiguation.GeometryServerUrl);
              if (geometryServiceScaleRotate == null)
            return;

              geometryServiceScaleRotate.BufferCompleted += GeometryService_LineBufferCompleted;
              geometryServiceScaleRotate.Failed += GeometryService_Failed;
              geometryServiceScaleRotate.CancelAsync();

              Graphic clickGraphic = new Graphic();
              clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
              clickGraphic.Geometry = geometryObject;

              // Input spatial reference for buffer operation defined by first feature of input geometry array
              clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

              // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
              ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
              {
            BufferSpatialReference = ParcelMap.SpatialReference,
            OutSpatialReference = ParcelMap.SpatialReference,
              };
              bufferParams.Distances.Add(snapDistance);
              bufferParams.Features.Add(clickGraphic);

              System.Diagnostics.Debug.WriteLine("Async: Buffering potential candidates for snapping.");
              geometryServiceScaleRotate.BufferAsync(bufferParams, snapDistance);
        }
示例#16
0
        public void IdentifyPoint(Map ParcelMap, ref Configuration config, ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint)
        {
            if (config.IdentifyURL == "")
            return;

              if (config.IdentifyLayerCount == 0)
            return;

              if (config.UseQueryIdentify)
              {
            _dataItems = new List<DataItem>();

            GeometryService geometryServicePointSnap = new GeometryService(config.GeometryServerUrl);
            if (geometryServicePointSnap == null)
              return;

            QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);

            geometryServicePointSnap.BufferCompleted += GeometryService_IdentifyPointBufferCompleted;
            geometryServicePointSnap.Failed += GeometryService_Failed;
            geometryServicePointSnap.CancelAsync();

            SimpleMarkerSymbol defaultSymbolMarker = new SimpleMarkerSymbol()
            {
              Color = System.Windows.Media.Brushes.Black, Size = 8,
              Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle
            };

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = defaultSymbolMarker as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = clickPoint;

            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
              BufferSpatialReference = ParcelMap.SpatialReference,
              OutSpatialReference = ParcelMap.SpatialReference,
              Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(config.SnapTolerance * config.SpatialReferenceUnitsPerMeter);
            bufferParams.Features.Add(clickGraphic);
            geometryServicePointSnap.BufferAsync(bufferParams, queryItem);
              }
              else
              {
            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
              Geometry = clickPoint,
              MapExtent = ParcelMap.Extent,
              Width = (int)ParcelMap.ActualWidth,
              Height = (int)ParcelMap.ActualHeight,
              LayerOption = LayerOption.visible,
              SpatialReference = ParcelMap.SpatialReference
            };

            // For performance, we allow certain layers to be only identified.
            if (config.IdentifyLayerIDs != null)
              foreach (int id in config.IdentifyLayerIDs)
            identifyParams.LayerIds.Add(id);

            IdentifyTask identifyTask = new IdentifyTask(config.IdentifyURL);
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;

            QueryItem queryItem = new QueryItem(ParcelMap, ref config, clickPoint, 0);
            identifyTask.ExecuteAsync(identifyParams, queryItem);
              }
        }
        void locatorTask_AddressToLocationsCompleted(object sender, AddressToLocationsEventArgs e)
        {
            try
            {
                List<AddressCandidate> returnedCandidates = e.Results;
                int BuildingEvacDistance = 0;
                int OutdoorEvacDistance = 0;

                if (bombType.Text == "Pipe bomb")
                {
                    BuildingEvacDistance = 70;
                    OutdoorEvacDistance = 1200;
                }
                else if (bombType.Text == "Suicide vest")
                {
                    BuildingEvacDistance = 110;
                    OutdoorEvacDistance = 1750;
                }
                else if (bombType.Text == "Briefcase/suitcase bomb")
                {
                    BuildingEvacDistance = 150;
                    OutdoorEvacDistance = 1850;
                }
                else if (bombType.Text == "Sedan")
                {
                    BuildingEvacDistance = 320;
                    OutdoorEvacDistance = 1900;
                }
                else if (bombType.Text == "SUV/van")
                {
                    BuildingEvacDistance = 400;
                    OutdoorEvacDistance = 2400;
                }
                else if (bombType.Text == "Small delivery truck")
                {
                    BuildingEvacDistance = 640;
                    OutdoorEvacDistance = 3800;
                }
                else if (bombType.Text == "Container/water truck")
                {
                    BuildingEvacDistance = 860;
                    OutdoorEvacDistance = 5100;
                }
                else if (bombType.Text == "Semi-trailer")
                {
                    BuildingEvacDistance = 1570;
                    OutdoorEvacDistance = 9300;
                }

                if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0)
                    return;

                if (e.Results.Count > 0)
                {
                    AddressCandidate candidate = returnedCandidates[0];

                    ResourceDictionary mydictionary = new ResourceDictionary();
                    mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                    Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = candidate.Location;
                    graphic.Symbol = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;

                    location = candidate.Location;
                    graphic.SetZIndex(1);
                    if (_graphicsLayer == null)
                    {
                        _graphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer();
                        _graphicsLayer.ID = "BombThreatGraphics";
                        client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                        if (aclyrs.Count() > 0)
                        {
                            aclyrs.ChildLayers.Add(_graphicsLayer);
                        }
                    }

                    _graphicsLayer.Graphics.Add(graphic);

                    GeometryService geometryTask = new GeometryService();
                    geometryTask.Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"; geometryTask.BufferCompleted += GeometryService_BufferCompleted;
                    geometryTask.Failed += GeometryService_Failed;

                    // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                    BufferParameters bufferParams = new BufferParameters()
                    {
                        Unit = LinearUnit.SurveyFoot,
                        BufferSpatialReference = new SpatialReference(102004),
                        OutSpatialReference = _mapWidget.Map.SpatialReference
                    };
                    bufferParams.Features.Add(graphic);
                    double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance };
                    bufferParams.Distances.AddRange(theDistances);
                    geometryTask.BufferAsync(bufferParams);

                }
                else
                {
                    MessageBox.Show("No address found.  Example schema: 380 New York Ave., Redlands, CA or click on the map");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Address location complete: " + ex.Message);
            }
        }
 private void BufferPathGeometry(Graphic pathGraphic)
 {
     var l = MyMap.Layers["BufferResultsLayer"] as GraphicsLayer;
     l.Graphics.Clear();
     #region GeometryService - Buffers path geometry
     var geometryService = new GeometryService(GEOMETRY_URL);
     geometryService.BufferCompleted += (s, e) =>
     {
         MyProgressBar.IsIndeterminate = false;
         var g = e.Results.FirstOrDefault();
         l.Graphics.Add(g);
         MyMap.ZoomTo(Expand(l.FullExtent));
         QueryTornadoTracks(g); // Retrieves tornado tracks and finds intersection.
     };
     geometryService.Failed += (s, e) =>
     {
         MyProgressBar.IsIndeterminate = false;
         MessageBox.Show(string.Format("Buffer failed with error '{0}'", e.Error.Message));
     };
     MyProgressBar.IsIndeterminate = true;
     BufferParameters parameters = new BufferParameters()
     {
         Unit = LinearUnit.StatuteMile,
         BufferSpatialReference = new SpatialReference(4326),
         OutSpatialReference = MyMap.SpatialReference,
         Geodesic = true
     };
     parameters.Features.Add(pathGraphic);
     parameters.Distances.Add(100);
     geometryService.BufferAsync(parameters);
     #endregion
 }
示例#19
0
        private void AddBufferedPoint()
        {
            GraphicsLayer graphicsLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer;

            point.SpatialReference = myMap.SpatialReference;
            Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = point,
                Symbol = SimplePointSymbol
            };
            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

            GeometryService geometryService =
              new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
            geometryService.BufferCompleted += GeometryService_BufferCompleted;
            geometryService.Failed += GeometryService_Failed;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            BufferParameters bufferParams = new BufferParameters()
            {
                Unit = StandardUnit,
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference = myMap.SpatialReference
            };
            bufferParams.Features.Add(graphic);
            bufferParams.Distances.Add(radius);

            geometryService.BufferAsync(bufferParams);
        }
示例#20
0
        private void RunButton_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_graphicsLayer != null)
                {
                    _graphicsLayer.Graphics.Clear();
                }
                // Find the map layer in the map widget that contains the data source.
                IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {
                    if (_mapWidget != null && d.IsSelectable == true)
                    {
                        // Get the feature layer in the map for the data source.
                        client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d);

                        //Clear Selection on Feature Layers in map
                        featureL.ClearSelection();
                    }
                }
                if (txtAddress.Text == "Enter Address")
                {
                    int BuildingEvacDistance = 0;
                    int OutdoorEvacDistance  = 0;

                    if (bombType.Text == "Pipe bomb")
                    {
                        BuildingEvacDistance = 70;
                        OutdoorEvacDistance  = 1200;
                    }
                    else if (bombType.Text == "Suicide vest")
                    {
                        BuildingEvacDistance = 110;
                        OutdoorEvacDistance  = 1750;
                    }
                    else if (bombType.Text == "Briefcase/suitcase bomb")
                    {
                        BuildingEvacDistance = 150;
                        OutdoorEvacDistance  = 1850;
                    }
                    else if (bombType.Text == "Sedan")
                    {
                        BuildingEvacDistance = 320;
                        OutdoorEvacDistance  = 1900;
                    }
                    else if (bombType.Text == "SUV/van")
                    {
                        BuildingEvacDistance = 400;
                        OutdoorEvacDistance  = 2400;
                    }
                    else if (bombType.Text == "Small delivery truck")
                    {
                        BuildingEvacDistance = 640;
                        OutdoorEvacDistance  = 3800;
                    }
                    else if (bombType.Text == "Container/water truck")
                    {
                        BuildingEvacDistance = 860;
                        OutdoorEvacDistance  = 5100;
                    }
                    else if (bombType.Text == "Semi-trailer")
                    {
                        BuildingEvacDistance = 1570;
                        OutdoorEvacDistance  = 9300;
                    }
                    if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0)
                    {
                        return;
                    }



                    //e.MapPoint.SpatialReference = _mapWidget.Map.SpatialReference;
                    //location = e.MapPoint;
                    if (location == null)
                    {
                        return;
                    }
                    Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = location;

                    GeometryService geometryTask = new GeometryService();
                    geometryTask.Url              = _serviceURL;
                    geometryTask.BufferCompleted += GeometryService_BufferCompleted;
                    geometryTask.Failed          += GeometryService_Failed;

                    // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                    BufferParameters bufferParams = new BufferParameters()
                    {
                        Unit = LinearUnit.SurveyFoot,
                        BufferSpatialReference = new SpatialReference(102004),
                        OutSpatialReference    = _mapWidget.Map.SpatialReference
                    };
                    bufferParams.Features.Add(graphic);
                    double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance };
                    bufferParams.Distances.AddRange(theDistances);
                    geometryTask.BufferAsync(bufferParams);
                }
                else
                {
                    findAddress();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error in run: " + ex.Message);
            }
        }
        void myDrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            myDrawObject.IsEnabled = false;
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = e.Geometry,
                Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphic.SetZIndex(1);
            graphicsLayer.Graphics.Add(graphic);

            GeometryService geometryService =
              new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");
            geometryService.BufferCompleted += GeometryService_BufferCompleted;
            geometryService.Failed += GeometryService_Failed;

            BufferParameters bufferParams = new BufferParameters()
            {
                Unit = LinearUnit.StatuteMile,
                OutSpatialReference = MyMap.SpatialReference,
                Geodesic = true
            };
            bufferParams.Features.Add(graphic);
            bufferParams.Distances.Add(5);

            geometryService.BufferAsync(bufferParams);
        }
示例#22
0
        void locatorTask_AddressToLocationsCompleted(object sender, AddressToLocationsEventArgs e)
        {
            try
            {
                List <AddressCandidate> returnedCandidates = e.Results;
                int BuildingEvacDistance = 0;
                int OutdoorEvacDistance  = 0;

                if (bombType.Text == "Pipe bomb")
                {
                    BuildingEvacDistance = 70;
                    OutdoorEvacDistance  = 1200;
                }
                else if (bombType.Text == "Suicide vest")
                {
                    BuildingEvacDistance = 110;
                    OutdoorEvacDistance  = 1750;
                }
                else if (bombType.Text == "Briefcase/suitcase bomb")
                {
                    BuildingEvacDistance = 150;
                    OutdoorEvacDistance  = 1850;
                }
                else if (bombType.Text == "Sedan")
                {
                    BuildingEvacDistance = 320;
                    OutdoorEvacDistance  = 1900;
                }
                else if (bombType.Text == "SUV/van")
                {
                    BuildingEvacDistance = 400;
                    OutdoorEvacDistance  = 2400;
                }
                else if (bombType.Text == "Small delivery truck")
                {
                    BuildingEvacDistance = 640;
                    OutdoorEvacDistance  = 3800;
                }
                else if (bombType.Text == "Container/water truck")
                {
                    BuildingEvacDistance = 860;
                    OutdoorEvacDistance  = 5100;
                }
                else if (bombType.Text == "Semi-trailer")
                {
                    BuildingEvacDistance = 1570;
                    OutdoorEvacDistance  = 9300;
                }

                if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0)
                {
                    return;
                }

                if (e.Results.Count > 0)
                {
                    AddressCandidate candidate = returnedCandidates[0];

                    ResourceDictionary mydictionary = new ResourceDictionary();
                    mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                    Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = candidate.Location;
                    graphic.Symbol   = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;

                    location = candidate.Location;
                    graphic.SetZIndex(1);
                    if (_graphicsLayer == null)
                    {
                        _graphicsLayer    = new ESRI.ArcGIS.Client.GraphicsLayer();
                        _graphicsLayer.ID = "BombThreatGraphics";
                        client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                        if (aclyrs.Count() > 0)
                        {
                            aclyrs.ChildLayers.Add(_graphicsLayer);
                        }
                    }

                    _graphicsLayer.Graphics.Add(graphic);

                    GeometryService geometryTask = new GeometryService();
                    geometryTask.Url     = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"; geometryTask.BufferCompleted += GeometryService_BufferCompleted;
                    geometryTask.Failed += GeometryService_Failed;

                    // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                    BufferParameters bufferParams = new BufferParameters()
                    {
                        Unit = LinearUnit.SurveyFoot,
                        BufferSpatialReference = new SpatialReference(102004),
                        OutSpatialReference    = _mapWidget.Map.SpatialReference
                    };
                    bufferParams.Features.Add(graphic);
                    double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance };
                    bufferParams.Distances.AddRange(theDistances);
                    geometryTask.BufferAsync(bufferParams);
                }
                else
                {
                    MessageBox.Show("No address found.  Example schema: 380 New York Ave., Redlands, CA or click on the map");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Address location complete: " + ex.Message);
            }
        }
        private void RunButton_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_graphicsLayer != null)
                    _graphicsLayer.Graphics.Clear();
                // Find the map layer in the map widget that contains the data source.
                IEnumerable<ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {

                    if (_mapWidget != null && d.IsSelectable == true)
                    {
                        // Get the feature layer in the map for the data source.
                        client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d);

                        //Clear Selection on Feature Layers in map
                        featureL.ClearSelection();

                    }
                }
                if (txtAddress.Text == "Enter Address")
                {
                    int BuildingEvacDistance = 0;
                    int OutdoorEvacDistance = 0;

                    if (bombType.Text == "Pipe bomb")
                    {
                        BuildingEvacDistance = 70;
                        OutdoorEvacDistance = 1200;
                    }
                    else if (bombType.Text == "Suicide vest")
                    {
                        BuildingEvacDistance = 110;
                        OutdoorEvacDistance = 1750;
                    }
                    else if (bombType.Text == "Briefcase/suitcase bomb")
                    {
                        BuildingEvacDistance = 150;
                        OutdoorEvacDistance = 1850;
                    }
                    else if (bombType.Text == "Sedan")
                    {
                        BuildingEvacDistance = 320;
                        OutdoorEvacDistance = 1900;
                    }
                    else if (bombType.Text == "SUV/van")
                    {
                        BuildingEvacDistance = 400;
                        OutdoorEvacDistance = 2400;
                    }
                    else if (bombType.Text == "Small delivery truck")
                    {
                        BuildingEvacDistance = 640;
                        OutdoorEvacDistance = 3800;
                    }
                    else if (bombType.Text == "Container/water truck")
                    {
                        BuildingEvacDistance = 860;
                        OutdoorEvacDistance = 5100;
                    }
                    else if (bombType.Text == "Semi-trailer")
                    {
                        BuildingEvacDistance = 1570;
                        OutdoorEvacDistance = 9300;
                    }
                    if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0)
                        return;



                    //e.MapPoint.SpatialReference = _mapWidget.Map.SpatialReference;
                    //location = e.MapPoint;
                    if (location == null)
                        return;
                    Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = location;

                    GeometryService geometryTask = new GeometryService();
                    geometryTask.Url = _serviceURL;
                    geometryTask.BufferCompleted += GeometryService_BufferCompleted;
                    geometryTask.Failed += GeometryService_Failed;

                    // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                    BufferParameters bufferParams = new BufferParameters()
                    {
                        Unit = LinearUnit.SurveyFoot,
                        BufferSpatialReference = new SpatialReference(102004),
                        OutSpatialReference = _mapWidget.Map.SpatialReference
                    };
                    bufferParams.Features.Add(graphic);
                    double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance };
                    bufferParams.Distances.AddRange(theDistances);
                    geometryTask.BufferAsync(bufferParams);
                }
                else
                {
                    findAddress();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error in run: " + ex.Message);
            }
        }
        void buffer(string agsGeometryServerUrl, BufferParameters bufferParams, FindNearbyEventArgs findNearbyRequest)
        {
            if (string.IsNullOrEmpty(agsGeometryServerUrl))
                return;

            GeometryService geomService = new GeometryService
            {
                Url = agsGeometryServerUrl
            };
            geomService.BufferCompleted += GeometryService_BufferCompleted;
            geomService.Failed += (o, e) =>
            {
                if (findNearbyToolWindow != null)
                {
                    findNearbyToolWindow.StopBusyIndicator();
                    MapApplication.Current.HideWindow(findNearbyToolWindow);
                }
                MessageBoxDialog.Show(Resources.Strings.MsgErrorExecutingBufferOperation + Environment.NewLine + e.Error.ToString());                
            };
            geomService.BufferAsync(bufferParams, findNearbyRequest);
        }
 private void ZoomToBufferExtent(MapPoint point)
 {
     if (point == null) return;
     #region GeometryService - Zooms to search extent
     var geometryService = new GeometryService(GEOMETRY_URL);
     geometryService.BufferCompleted += (s, e) =>
     {
         MyProgressBar.IsIndeterminate = false;
         MyMap.ZoomTo(Expand(e.Results.FirstOrDefault().Geometry.Extent));
     };
     geometryService.Failed += (s, e) =>
     {
         MyProgressBar.IsIndeterminate = false;
         MessageBox.Show(string.Format("Get buffer for '{0}' failed with error '{1}'", point, e.Error.Message));
         ShowElement(MyMap);
     };
     MyProgressBar.IsIndeterminate = true;
     BufferParameters parameters = new BufferParameters()
     {
         Unit = LinearUnit.StatuteMile,
         BufferSpatialReference = new SpatialReference(4326),
         OutSpatialReference = MyMap.SpatialReference,
         Geodesic = true
     };
     parameters.Features.Add(new Graphic() { Geometry = point });
     parameters.Distances.Add(DISTANCE);
     geometryService.BufferAsync(parameters);
     #endregion
 }