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);
        }
        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);
        }
        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 myDrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            _geometryService.CancelAsync();
            _queryTask.CancelAsync();

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = e.Geometry;
            // 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);
        }
Example #6
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);
              }
        }
        private async void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            try
            {
                if (_cts != null)
                    _cts.Cancel();

                _cts = new CancellationTokenSource();

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

                _pointAndBufferGraphicsLayer.Graphics.Clear();
                _resultsGraphicsLayer.Graphics.Clear();

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

                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);

                BufferResult bufferResult = await _geometryService.BufferTaskAsync(bufferParams, _cts.Token);

                Graphic bufferGraphic = new Graphic();
                bufferGraphic.Geometry = bufferResult.Results[0].Geometry;
                bufferGraphic.Symbol = LayoutRoot.Resources["BufferSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                bufferGraphic.SetZIndex(1);

                _pointAndBufferGraphicsLayer.Graphics.Add(bufferGraphic);

                ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
                query.ReturnGeometry = true;
                query.OutSpatialReference = MyMap.SpatialReference;
                query.Geometry = bufferGraphic.Geometry;
                query.OutFields.Add("OWNERNME1");

                QueryResult queryResult = await _queryTask.ExecuteTaskAsync(query, _cts.Token);

                if (queryResult.FeatureSet.Features.Count < 1)
                {
                    MessageBox.Show("No features found");
                    return;
                }

                foreach (Graphic selectedGraphic in queryResult.FeatureSet.Features)
                {
                    selectedGraphic.Symbol = LayoutRoot.Resources["ParcelSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                    _resultsGraphicsLayer.Graphics.Add(selectedGraphic);
                }
            }
            catch (Exception ex)
            {
                if (ex is ServiceException)
                {
                    MessageBox.Show(String.Format("{0}: {1}", (ex as ServiceException).Code.ToString(), (ex as ServiceException).Details[0]), "Error", MessageBoxButton.OK);
                    return;
                }
            }
        }
Example #8
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 async void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            try
            {
                if (_cts != null)
                {
                    _cts.Cancel();
                }

                _cts = new CancellationTokenSource();

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

                _pointAndBufferGraphicsLayer.Graphics.Clear();
                _resultsGraphicsLayer.Graphics.Clear();

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

                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);

                BufferResult bufferResult = await _geometryService.BufferTaskAsync(bufferParams, _cts.Token);

                Graphic bufferGraphic = new Graphic();
                bufferGraphic.Geometry = bufferResult.Results[0].Geometry;
                bufferGraphic.Symbol   = LayoutRoot.Resources["BufferSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                bufferGraphic.SetZIndex(1);

                _pointAndBufferGraphicsLayer.Graphics.Add(bufferGraphic);

                ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
                query.ReturnGeometry      = true;
                query.OutSpatialReference = MyMap.SpatialReference;
                query.Geometry            = bufferGraphic.Geometry;
                query.OutFields.Add("OWNERNME1");

                QueryResult queryResult = await _queryTask.ExecuteTaskAsync(query, _cts.Token);

                if (queryResult.FeatureSet.Features.Count < 1)
                {
                    MessageBox.Show("No features found");
                    return;
                }

                foreach (Graphic selectedGraphic in queryResult.FeatureSet.Features)
                {
                    selectedGraphic.Symbol = LayoutRoot.Resources["ParcelSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
                    _resultsGraphicsLayer.Graphics.Add(selectedGraphic);
                }
            }
            catch (Exception ex)
            {
                if (ex is ServiceException)
                {
                    MessageBox.Show(String.Format("{0}: {1}", (ex as ServiceException).Code.ToString(), (ex as ServiceException).Details[0]), "Error", MessageBoxButton.OK);
                    return;
                }
            }
        }
        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);
        }