コード例 #1
0
 /// <summary>
 /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
 {
     try
     {
         client.Geometry.MapPoint clickPoint = e.MapPoint;
         WebMercator mercator        = new ESRI.ArcGIS.Client.Projection.WebMercator();
         client.Geometry.MapPoint pt = null;
         pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
         if (_graphicsLayer == null)
         {
             _graphicsLayer    = new client.GraphicsLayer();
             _graphicsLayer.ID = "ComputedPoints";
             client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
             if (aclyrs.Count() > 0)
             {
                 aclyrs.ChildLayers.Add(_graphicsLayer);
             }
         }
         ResourceDictionary mydictionary = new ResourceDictionary();
         mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
         client.Graphic graphic = new client.Graphic();
         graphic.Geometry = pt;
         graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
         _graphicsLayer.Graphics.Add(graphic);
         RunButton.IsEnabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in map mouseclick: " + ex.Message);
     }
 }
コード例 #2
0
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            client.Geometry.MapPoint clickPoint = e.MapPoint;
            //WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
            ///client.Geometry.MapPoint pt = null;
            //pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint;
            if (_graphicsLayer == null)
            {
                _graphicsLayer = new client.GraphicsLayer();

                _graphicsLayer.ID = "AircraftCommunicationGraphics";
                client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                if (aclyrs.Count() > 0)
                {
                    aclyrs.ChildLayers.Add(_graphicsLayer);
                }
            }
            ResourceDictionary mydictionary = new ResourceDictionary();

            mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
            client.Graphic graphic = new client.Graphic();
            //graphic.Geometry = pt;
            graphic.Geometry = clickPoint;
            graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
            _graphicsLayer.Graphics.Add(graphic);

            if (_graphicsLayer != null && _graphicsLayerPoly != null)
            {
                if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0)
                {
                    RunButton.IsEnabled = true;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                client.Geometry.MapPoint clickPoint = e.MapPoint;
                if (_graphicsLayer == null)
                {
                    _graphicsLayer    = new ESRI.ArcGIS.Client.GraphicsLayer();
                    _graphicsLayer.ID = "FarthestOnCircleGraphics";
                    client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers;
                    if (aclyrs.Count() > 0)
                    {
                        aclyrs.ChildLayers.Add(_graphicsLayer);
                    }
                }
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/FarthestOnCircleAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);
                client.Graphic graphic = new client.Graphic();
                graphic.Geometry = clickPoint;
                graphic.Symbol   = mydictionary["RedPin"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.Graphics.Add(graphic);

                RunButton.IsEnabled = true;
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
コード例 #4
0
        private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry         = clickPoint,
                MapExtent        = MyMap.Extent,
                Width            = (int)MyMap.ActualWidth,
                Height           = (int)MyMap.ActualHeight,
                LayerOption      = LayerOption.visible,
                SpatialReference = MyMap.SpatialReference
            };



            //IdentifyTask identifyTask = new IdentifyTask("http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/");
            IdentifyTask identifyTask = new IdentifyTask(arcgisLayer.Url);


            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed           += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol   = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }
コード例 #5
0
ファイル: MainPage.xaml.cs プロジェクト: ufjl0683/sshmc
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //   System.Random r=new Random();
            //for (int i = 0; i < 3000; i++)
            //{

             //   ESRI.ArcGIS.Client.Geometry.MapPoint mp = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(

              //   new ESRI.ArcGIS.Client.Geometry.MapPoint(121.55437847681263, 24.99750117341647));

            //   new ESRI.ArcGIS.Client.Geometry.MapPoint(121.299405, 25.000298));
               // MapPoint mp = new MapPoint(r.Next(-20037508, 20037508), r.Next(-20037508, 20037508));
            ESRI.ArcGIS.Client.Geometry.MapPoint mp = new ESRI.ArcGIS.Client.Geometry.MapPoint(280221.955, 2765843.943, new SpatialReference(104137));

                ESRI.ArcGIS.Client.Geometry.MapPoint p1, p2;
                p1 = new ESRI.ArcGIS.Client.Geometry.MapPoint(mp.X - 150, mp.Y - 150, new SpatialReference(104137));
                p2 = new ESRI.ArcGIS.Client.Geometry.MapPoint(mp.X + 150, mp.Y + 150, new SpatialReference(104137));
              //  this.map1.ZoomTo(new ESRI.ArcGIS.Client.Geometry.Envelope(p1, p2) );

                if ((this.map1.Layers["elementlyr"] as ESRI.ArcGIS.Client.ElementLayer).Children.Count > 0)
                    return;
                Alarm alarm = new Alarm() { Width = 40, Height = 40 };
                alarm.SetValue(ESRI.ArcGIS.Client.ElementLayer.EnvelopeProperty,
                   new ESRI.ArcGIS.Client.Geometry.Envelope(mp, mp));
                (this.map1.Layers["elementlyr"] as ESRI.ArcGIS.Client.ElementLayer).Children.Add(alarm);
            //}
        }
コード例 #6
0
        /// <summary>
        /// Create straight line geometry.
        /// </summary>
        /// <param name="route">Route.</param>
        /// <returns>Straight line route geometry.</returns>
        private ArcGISGeometry.Polyline _CreateStraightPolyline(Route route)
        {
            ArcGISGeometry.Polyline        routeLine       = new ArcGISGeometry.Polyline();
            ArcGISGeometry.PointCollection pointCollection = new ArcGISGeometry.PointCollection();

            List <Stop> routeStops = CommonHelpers.GetSortedStops(route);

            int startIndex   = _GetStartIndex(routeStops);
            int processCount = _GetProcessStopCount(routeStops);

            // add stop map points
            for (int index = startIndex; index < processCount; ++index)
            {
                Stop stop = routeStops[index];
                if (stop.MapLocation != null)
                {
                    ArcGISGeometry.MapPoint mapPoint = _CreateProjectedMapPoint(stop.MapLocation.Value);
                    pointCollection.Add(mapPoint);
                }
            }

            routeLine.Paths.Add(pointCollection);

            return(routeLine);
        }
コード例 #7
0
        }         // public static GraphicsLayer createRLLayer(Map map, string layerID, string layerName)

        void Map_MouseMove(object sender, MouseEventArgs e)
        {
            // print coordinates
            try {
                //log(string.Format("VRedlineImpl.Map_MouseMove"));
                var c = MapApplication.Current;
                var ScreenCoordsTextBlock = c.FindObjectInLayout("ScreenCoordsTextBlock") as TextBlock;
                var MapCoordsTextBlock    = c.FindObjectInLayout("MapCoordsTextBlock") as TextBlock;

                if (c.Map.Extent != null)
                {
                    System.Windows.Point screenPoint = e.GetPosition(c.Map);
                    ScreenCoordsTextBlock.Text = string.Format("Screen Coords: X = {0}, Y = {1}",
                                                               screenPoint.X, screenPoint.Y);

                    ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = c.Map.ScreenToMap(screenPoint);
                    if (c.Map.WrapAroundIsActive)
                    {
                        mapPoint = ESRI.ArcGIS.Client.Geometry.Geometry.NormalizeCentralMeridian(mapPoint) as ESRI.ArcGIS.Client.Geometry.MapPoint;
                    }
                    MapCoordsTextBlock.Text = string.Format("X = {0}, Y = {1}",
                                                            Math.Round(mapPoint.X, 4), Math.Round(mapPoint.Y, 4));

                    var wm = new ESRI.ArcGIS.Client.Projection.WebMercator();
                    mapPoint = wm.ToGeographic(mapPoint) as ESRI.ArcGIS.Client.Geometry.MapPoint;
                    ScreenCoordsTextBlock.Text = string.Format("Lon = {0}, Lat = {1}",
                                                               Math.Round(mapPoint.X, 7), Math.Round(mapPoint.Y, 7));
                }
            }
            catch (Exception ex) {
                log(string.Format("VRedlineImpl.Map_MouseMove, error: {0}", ex.Message));
            }
        }         // void Map_MouseMove(object sender, MouseEventArgs e) {
コード例 #8
0
ファイル: Shape.cs プロジェクト: valuecreation/RoutePlanner
 /// <summary>
 /// Checks is point has valid\inited values.
 /// </summary>
 /// <param name="point">Point object to check.</param>
 /// <returns>TRUE if all properties of point is valid.</returns>
 private bool _IsPointValid(ESRISDSGeometry.MapPoint point)
 {
     return(!double.IsNaN(point.X) && !double.IsNaN(point.Y) &&
            !double.IsInfinity(point.X) && !double.IsInfinity(point.Y) &&
            (double.MinValue != point.X) && (double.MinValue != point.Y) &&
            (double.MaxValue != point.X) && (double.MaxValue != point.Y));
 }
コード例 #9
0
        private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.Geometry as MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                SpatialReference = MyMap.SpatialReference,
                Geometry         = clickPoint,
                MapExtent        = MyMap.Extent,
                Width            = (int)MyMap.ActualWidth,
                Height           = (int)MyMap.ActualHeight,
                LayerOption      = LayerOption.visible
            };

            IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer");

            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed           += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol   = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }
コード例 #10
0
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
                // 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();
                    }
                }
                location = e.MapPoint;
                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.ClearGraphics();
                Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                graphic.Geometry = location;
                graphic.Attributes.Add("Evac", bombType.Text);
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);

                graphic.Symbol        = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.MapTip = new ContentControl()
                {
                    ContentTemplate = (DataTemplate)Resources["kymaptip"]
                };
                _graphicsLayer.MapTip.SetBinding(ContentControl.ContentProperty, new Binding());
                graphic.SetZIndex(1);
                _graphicsLayer.Graphics.Add(graphic);

                if (location != null)
                {
                    RunButton.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error in mouseclick: " + ex.Message);
            }
        }
コード例 #11
0
        private const double degreeDist  = 111319.49079327357264771338267052;   //earthRadius * toRadians;

        /// <summary>
        /// Calculates horizontal scale at center of extent
        /// for geographic / Plate Carrée projection.
        /// Horizontal scale is 0 at the poles.
        /// </summary>
        private double getResolutionForGeographic(ESRI.ArcGIS.Client.Geometry.MapPoint center, double resolution)
        {
            double y = center.Y;

            if (Math.Abs(y) > 90)
            {
                return(0);
            }
            return(Math.Cos(y * toRadians) * resolution * degreeDist);
        }
コード例 #12
0
 private void MyMap_MouseMove(object sender, MouseEventArgs e)
 {
     //显示坐标
     if (MyMap.Extent != null)
     {
         System.Windows.Point screenPoint = e.GetPosition(MyMap);
         ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = MyMap.ScreenToMap(screenPoint);
         MapCoordsTextBlock.Text = string.Format("X = {0}, Y = {1}",
                                                 Math.Round(mapPoint.X, 4), Math.Round(mapPoint.Y, 4));
     }
 }
コード例 #13
0
        /// <summary>
        /// Create map point and project to webmercator if needed.
        /// </summary>
        /// <param name="point">Source point.</param>
        /// <returns>Map point in correct projection.</returns>
        private ArcGISGeometry.MapPoint _CreateProjectedMapPoint(ArcLogisticsGeometry.Point point)
        {
            ArcLogisticsGeometry.Point projectedPoint = new ArcLogisticsGeometry.Point(point.X, point.Y);

            if (ParentLayer != null && ParentLayer.SpatialReferenceID != null)
            {
                projectedPoint = WebMercatorUtil.ProjectPointToWebMercator(projectedPoint, ParentLayer.SpatialReferenceID.Value);
            }

            ArcGISGeometry.MapPoint mapPoint = new ArcGISGeometry.MapPoint(projectedPoint.X, projectedPoint.Y);
            return(mapPoint);
        }
コード例 #14
0
 /// <summary>
 /// Starts animating the location.
 /// </summary>
 private void UpdateLocation()
 {
     if (Map != null && Map.SpatialReference != null && GeoCoordinate != null && GeoCoordinate != GeoCoordinate.Unknown)
     {
         MapPoint newLocation = new ESRI.ArcGIS.Client.Geometry.MapPoint(GeoCoordinate.Longitude, GeoCoordinate.Latitude)
         {
             SpatialReference = new SpatialReference(4326)
         };
         if (!Map.SpatialReference.Equals(newLocation.SpatialReference))
         {
             if (WebMercatorSR.Equals(Map.SpatialReference))
             {
                 newLocation = merc.FromGeographic(newLocation) as MapPoint;
             }
             else
             {
                 if (ProjectionService != null)
                 {
                     if (!ProjectionService.IsBusy)
                     {
                         var geom = newLocation;
                         EventHandler <Tasks.GraphicsEventArgs> handler = null;
                         handler = (a, b) =>
                         {
                             (a as IProjectionService).ProjectCompleted -= handler;
                             if (b.Results != null && b.Results.Count > 0 && b.Results[0].Geometry is MapPoint)
                             {
                                 BeginAnimateLocation(b.Results[0].Geometry as MapPoint);
                             }
                         };
                         ProjectionService.ProjectCompleted += handler;
                         ProjectionService.ProjectAsync(new Graphic[] { new Graphic()
                                                                        {
                                                                            Geometry = geom
                                                                        } }, Map.SpatialReference);
                     }
                     else
                     {
                         EventHandler <Tasks.GraphicsEventArgs> handler = null;
                         handler = (a, b) =>
                         {
                             ProjectionService.ProjectCompleted -= handler;
                             UpdateLocation();                                             //Try again
                         };
                         ProjectionService.ProjectCompleted += handler;                    //Wait for task to complete
                     }
                 }
                 return;                         //Wait for projection to complete
             }
         }
         BeginAnimateLocation(newLocation);
     }
 }
コード例 #15
0
        public static void AddHeatMapLayer(Layer layer, View view)
        {
            Map    map           = view.Map;
            string originalTitle = string.Empty;

            originalTitle = layer.GetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty) as string;

            FeatureLayer featureLayer = layer as FeatureLayer;

            if (featureLayer != null && !string.IsNullOrEmpty(featureLayer.Url))
            {
                HeatMapFeatureLayer heatMapFeatureLayer = new HeatMapFeatureLayer();
                heatMapFeatureLayer.DisableClientCaching = featureLayer.DisableClientCaching;
                heatMapFeatureLayer.Geometry             = featureLayer.Geometry;
                heatMapFeatureLayer.ProxyUrl             = featureLayer.ProxyUrl;
                heatMapFeatureLayer.Text  = featureLayer.Text;
                heatMapFeatureLayer.Token = featureLayer.Token;
                heatMapFeatureLayer.Url   = featureLayer.Url;
                heatMapFeatureLayer.Where = featureLayer.Where;
                heatMapFeatureLayer.MapSpatialReference = map.SpatialReference;
                heatMapFeatureLayer.ID = "EsriHeatMapLayer__" + Guid.NewGuid().ToString("N");
                foreach (Graphic item in featureLayer.Graphics)
                {
                    ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = item.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
                    if (mapPoint != null)
                    {
                        heatMapFeatureLayer.HeatMapPoints.Add(mapPoint);
                    }
                }
                view.AddLayerToMap(heatMapFeatureLayer, true,
                                   string.IsNullOrEmpty(originalTitle) ? Resources.Strings.HeatMap : string.Format(Resources.Strings.HeatMapTitle, originalTitle));
            }
            else
            {
                GraphicsLayer graphicsLayer = layer as GraphicsLayer;
                if (graphicsLayer != null)
                {
                    ESRI.ArcGIS.Client.Toolkit.DataSources.HeatMapLayer heatMapLayer = new Client.Toolkit.DataSources.HeatMapLayer();
                    foreach (Graphic item in graphicsLayer.Graphics)
                    {
                        ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = item.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
                        if (mapPoint != null)
                        {
                            heatMapLayer.HeatMapPoints.Add(mapPoint);
                        }
                    }
                    view.AddLayerToMap(heatMapLayer, true,
                                       string.IsNullOrEmpty(originalTitle) ? Resources.Strings.HeatMap : string.Format(Resources.Strings.HeatMapTitle, originalTitle));
                }
            }
        }
コード例 #16
0
        public static bool checkEsriIntersect(double lat, double lon, string beatID)
        {
            bool inPoly   = false;
            bool isInside = false;

            ESRI.ArcGIS.Client.Geometry.MapPoint point = new ESRI.ArcGIS.Client.Geometry.MapPoint(lon, lat);
            var spList = from sp in beatPolygons
                         where sp.BeatID == beatID
                         select sp;

            foreach (esriBeat eb in spList)
            {
                ESRI.ArcGIS.Client.Geometry.Polygon p = (ESRI.ArcGIS.Client.Geometry.Polygon)eb.beatData.Geometry;
                if (lat <= eb.maxLat && lat >= eb.minLat && lon <= eb.maxLon && lon >= eb.minLon)
                {
                    /* OLD CODE WORKED MOST OF THE TIME BUT RETURNED OFF BEAT SOMETIMES WHEN A TRUCK WAS ON BEAT */
                    foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in p.Rings)
                    {
                        int i;
                        int j = points.Count - 1;
                        for (i = 0; i < points.Count; i++)
                        {
                            if (points[i].X < point.X && points[j].X >= point.X ||
                                points[j].X < point.X && points[i].X >= point.X)
                            {
                                if (points[i].Y + (point.X - points[i].X) / (points[j].X - points[i].X) * (points[j].Y - points[i].Y) < point.Y)
                                {
                                    inPoly = !inPoly;
                                }
                            }
                            j = i;
                        }
                    }


                    foreach (PointCollection points in p.Rings)
                    {
                        for (int i = 0, j = points.Count - 1; i < points.Count; j = i++)
                        {
                            if (((points[i].Y > point.Y) != (points[j].Y > point.Y)) &&
                                (point.X < (points[j].X - points[i].X) * (point.Y - points[i].Y) / (points[j].Y - points[i].Y) + points[i].X))
                            {
                                isInside = true;
                            }
                        }
                    }
                }
            }
            return(isInside);
        }
コード例 #17
0
        public void AddLocationGraphic(ESRI.ArcGIS.Client.Geometry.MapPoint location)
        {
            if (this.GraphicsLayer == null)
            {
                MessageBox.Show("GraphicsLayer for this widget is not created. Please set property HasGraphics 'true'."); return;
            }

            this.ClearGraphics(-1);
            Graphic graphic = new Graphic();

            graphic.Geometry = location;
            graphic.Symbol   = CreateMarkerSymbol(widgetConfig.GraphicIcon, 0, 24);
            this.GraphicsLayer.Graphics.Add(graphic);
        }
コード例 #18
0
ファイル: Shape.cs プロジェクト: valuecreation/RoutePlanner
        /// <summary>
        /// Method converts ESRI ArcGIS MapPoint object to ESRI ArcLogistics Point object.
        /// </summary>
        /// <param name="mapPoint">MapPoint to convert.</param>
        /// <returns>ESRI ArcLogistics Point object.</returns>
        private ArcLogistics.Geometry.Point _ConvertToArcLogisticsPoint(
            ESRISDSGeometry.MapPoint mapPoint)
        {
            Debug.Assert(mapPoint != null);

            var point = new ArcLogistics.Geometry.Point();

            if (_IsPointValid(mapPoint))
            {
                point = new ArcLogistics.Geometry.Point(
                    mapPoint.X, mapPoint.Y);
            }

            return(point);
        }
コード例 #19
0
        /// <summary>
        /// Convert from mappoint to screen coordinates.
        /// </summary>
        /// <returns>Converted from mappoint to screen coordinates.</returns>
        private System.Windows.Point _ConvertToScreenPos(ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint)
        {
            ESRI.ArcLogistics.Geometry.Point projectedPoint = new ESRI.ArcLogistics.Geometry.Point(
                mapPoint.X, mapPoint.Y);

            if (_mapControl.Map.SpatialReferenceID.HasValue)
            {
                projectedPoint = WebMercatorUtil.ProjectPointToWebMercator(projectedPoint,
                                                                           _mapControl.Map.SpatialReferenceID.Value);
            }

            MapPoint location = new MapPoint(projectedPoint.X, projectedPoint.Y);
            Point    point    = _mapControl.map.MapToScreen(location);

            return(point);
        }
コード例 #20
0
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;
            offsetGraphicsLayer.ClearGraphics();

            ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
            point.SpatialReference = MyMap.SpatialReference;
            System.Windows.Point screenPnt = MyMap.MapToScreen(point);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(null);

            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            IEnumerable <Graphic> selected =
                parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

            List <Graphic> graphicsList = new List <Graphic>();

            foreach (Graphic g in selected)
            {
                graphicsList.Add(g);
            }

            if (graphicsList.Count < 1)
            {
                MyDrawObject.IsEnabled = true;
                return;
            }

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

            geometryService.OffsetCompleted += GeometryService_OffsetCompleted;
            geometryService.Failed          += GeometryService_Failed;

            OffsetParameters offsetParameters = new OffsetParameters()
            {
                BevelRatio     = 1.1,
                OffsetDistance = -30,
                OffsetHow      = GeometryOffset.Bevelled,
                OffsetUnit     = LinearUnit.Meter,
                Simplify       = true
            };

            geometryService.OffsetAsync(graphicsList, offsetParameters);
        }
コード例 #21
0
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            client.Geometry.MapPoint clickPoint = e.MapPoint;

            if (clickPoint != null)
            {
                e.MapPoint.SpatialReference = _mapWidget.Map.SpatialReference;
                client.Graphic graphic = new client.Graphic()
                {
                    Geometry = e.MapPoint,
                    Symbol   = _resourceDictionary["bufferSymbol"] as client.Symbols.PictureMarkerSymbol
                };

                graphic.SetZIndex(1);
                _bufferPointLayer.Graphics.Add(graphic);
            }
        }
コード例 #22
0
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            MyDrawObject.IsEnabled = false;

            if (MyDrawObject.DrawMode == DrawMode.Point)
            {
                ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
                point.SpatialReference = MyMap.SpatialReference;
                System.Windows.Point screenPnt = MyMap.MapToScreen(point);

                // Account for difference between Map and application origin
                GeneralTransform     generalTransform   = MyMap.TransformToVisual(null);
                System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

                IEnumerable <Graphic> selected =
                    parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

                if (selected.ToArray().Length <= 0)
                {
                    MyDrawObject.IsEnabled = true;
                    return;
                }

                selectedGraphic = selected.ToList()[0] as Graphic;

                selectedGraphic.Select();

                MyDrawObject.DrawMode  = DrawMode.Polyline;
                MyDrawObject.IsEnabled = true;

                InfoTextBlock.Text = LayoutRoot.Resources["EndText"] as string;
            }
            else
            {
                ESRI.ArcGIS.Client.Geometry.Polyline polyline = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline;
                polyline.SpatialReference = MyMap.SpatialReference;

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

                geometryService.ReshapeCompleted += GeometryService_ReshapeCompleted;
                geometryService.Failed           += GeometryService_Failed;

                geometryService.ReshapeAsync(selectedGraphic.Geometry, polyline);
            }
        }
コード例 #23
0
        public void AddLocationGraphic(ESRI.ArcGIS.Client.Geometry.MapPoint location, Dictionary <string, object> attributes)
        {
            if (this.GraphicsLayer == null)
            {
                MessageBox.Show("GraphicsLayer for this widget is not created. Please set property HasGraphics 'true'."); return;
            }

            Graphic graphic = new Graphic();

            graphic.Geometry = location;
            graphic.Symbol   = CreateMarkerSymbol(widgetConfig.LocationSymbol.ImageSource, widgetConfig.LocationSymbol.OffsetX, widgetConfig.LocationSymbol.OffsetY);
            foreach (string key in attributes.Keys)
            {
                graphic.Attributes.Add(key, attributes[key]);
            }

            this.GraphicsLayer.Graphics.Add(graphic);
        }
コード例 #24
0
 private void Map_MouseMove(object sender, MouseEventArgs e)
 {
     System.Windows.Point screenPoint = e.GetPosition(Map);
     ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = Map.ScreenToMap(screenPoint);
     if (Map.WrapAroundIsActive)
     {
         mapPoint = ESRI.ArcGIS.Client.Geometry.Geometry.NormalizeCentralMeridian(mapPoint) as ESRI.ArcGIS.Client.Geometry.MapPoint;
     }
     if (mapPoint != null)
     {
         var pt = SpatialReferenceSystem.ToGeographic(mapPoint.X, mapPoint.Y);
         if (pt != null)
         {
             lonLabel.Content = pt[0].ToString("0.0000");
             latLabel.Content = pt[1].ToString("0.0000");
         }
     }
 }
コード例 #25
0
        // This routine does not write out points, but it does write the start location

        private static void WriteConstructionData(ref XmlWriter writer, ref ParcelData parcelData, ref PointDictionary pointDictionary, ref MapPoint projectedStartPoint, ref Configuration configuration, ParcelLineRow record)
        {
            Int32 pointId = record.GetFrom();

            if (!pointDictionary.ContainsKey(pointId))
            {
                return;
            }

            // Rather than using the point from the dictionary, the client should pass in a projected point.
            // ESRI.ArcGIS.Client.Geometry.MapPoint startPoint = pointDictionary[pointId];

            ESRI.ArcGIS.Client.Geometry.MapPoint startPoint = projectedStartPoint;
            if (startPoint == null)
            {
                return;
            }

            writer.WriteStartElement("constructionData");
            writer.WriteStartElement("constructionAdjustment");
            writer.WriteStartElement("startPoint");

            double xM = startPoint.X;
            double yM = startPoint.Y;

            if (configuration.HasSpatialReferenceUnit)
            {
                xM *= configuration.SpatialReferenceUnitsPerMeter;
                yM *= configuration.SpatialReferenceUnitsPerMeter;
            }

            writer.WriteElementString("unjoinedPointNo", pointId.ToString());
            writer.WriteElementString("x", xM.ToString(_doubleFormat));
            writer.WriteElementString("y", yM.ToString(_doubleFormat));

            writer.WriteEndElement(); // startPoint

            if (parcelData.CompassRuleApplied)
            {
                writer.WriteElementString("type", "0"); // compass rule = 0
            }
            writer.WriteEndElement();                   // constructionAdjustment
            writer.WriteEndElement();                   // constructionData
        }
コード例 #26
0
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            outputGraphicsLayer.ClearGraphics();

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

            inputGraphicsLayer.Graphics.Add(graphic);

            if (inputGraphicsLayer.Graphics.Count >= 3)
            {
                ConvexButton.IsEnabled = true;
            }
        }
コード例 #27
0
        /// <summary>
        /// Handles the MouseMove event of the Map control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.MouseEventArgs"/> instance containing the event data.</param>
        private void Map_MouseMove(object sender, MouseEventArgs e)
        {
            if (DraggingVertex == null ||
                DraggingVertex.Geometry == null ||
                !(DraggingVertex.Geometry is MapPoint))
            {
                return;
            }
            //Update the point geometry based on the map coordinate
            Point p = e.GetPosition(MyMap);

            ESRI.ArcGIS.Client.Geometry.MapPoint pnt = MyMap.ScreenToMap(p);
            MapPoint pEdit = DraggingVertex.Geometry as MapPoint;

            pEdit.X = pnt.X;
            pEdit.Y = pnt.Y;
            if (DraggingVertex.Attributes.ContainsKey("lastPnt"))             //Polygon first vertex - also update closing vertex
            {
                pEdit   = DraggingVertex.Attributes["lastPnt"] as MapPoint;
                pEdit.X = pnt.X;
                pEdit.Y = pnt.Y;
            }
            else if (DraggingVertex.Attributes.ContainsKey("corner")) //Envelope
            {
                Graphic  g   = DraggingVertex.Attributes["Feature"] as Graphic;
                Envelope env = g.Geometry as Envelope;
                if ((int)DraggingVertex.Attributes["corner"] == 0)                 //lower left
                {
                    env.XMin = pnt.X;
                    env.YMin = pnt.Y;
                }
                else                 //upper right
                {
                    env.XMax = pnt.X;
                    env.YMax = pnt.Y;
                }
            }
        }
コード例 #28
0
        private void DoneButton_Click(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();
                    }
                }
                location            = null;
                RunButton.IsEnabled = false;
                txtAddress.Text     = "Enter Address";

                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                    _mapWidget.SetToolbar(null);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
コード例 #29
0
        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint point = args.Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
            point.SpatialReference = MyMap.SpatialReference;
            System.Windows.Point screenPnt = MyMap.MapToScreen(point);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(null);

            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            IEnumerable <Graphic> selected =
                parcelGraphicsLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

            foreach (Graphic g in selected)
            {
                if (g.Selected)
                {
                    g.UnSelect(); selectedGraphics.Remove(g);
                }
                else
                {
                    g.Select(); selectedGraphics.Add(g);
                }
            }

            if (selectedGraphics.Count > 1)
            {
                UnionButton.IsEnabled  = true;
                MyDrawObject.IsEnabled = false;
            }
            else
            {
                UnionButton.IsEnabled = false;
            }
        }
コード例 #30
0
        /// <summary>
        /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Map_MouseClick(object sender, client.Map.MouseEventArgs e)
        {
            try
            {
                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
                // 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();

                    }
                }
                location = e.MapPoint;
                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.ClearGraphics();
                Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
                graphic.Geometry = location;
                graphic.Attributes.Add("Evac", bombType.Text);
                ResourceDictionary mydictionary = new ResourceDictionary();
                mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute);

                graphic.Symbol = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol;
                _graphicsLayer.MapTip = new ContentControl()
                {
                    ContentTemplate = (DataTemplate)Resources["kymaptip"]
                };
                _graphicsLayer.MapTip.SetBinding(ContentControl.ContentProperty, new Binding());
                graphic.SetZIndex(1);
                _graphicsLayer.Graphics.Add(graphic);

                if (location != null)
                    RunButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error in mouseclick: " + ex.Message);
            }
        }
コード例 #31
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);
            }
        }
コード例 #32
0
        /// <summary>
        /// Create map point and project to webmercator if needed.
        /// </summary>
        /// <param name="point">Source point.</param>
        /// <returns>Map point in correct projection.</returns>
        private ArcGISGeometry.MapPoint _CreateProjectedMapPoint(ArcLogisticsGeometry.Point point)
        {
            ArcLogisticsGeometry.Point projectedPoint = new ArcLogisticsGeometry.Point(point.X, point.Y);

            if (ParentLayer != null && ParentLayer.SpatialReferenceID != null)
            {
                projectedPoint = WebMercatorUtil.ProjectPointToWebMercator(projectedPoint, ParentLayer.SpatialReferenceID.Value);
            }

            ArcGISGeometry.MapPoint mapPoint = new ArcGISGeometry.MapPoint(projectedPoint.X, projectedPoint.Y);
            return mapPoint;
        }
コード例 #33
0
 /// <summary>
 /// Starts animating the location.
 /// </summary>
 private void UpdateLocation()
 {
     if (Map != null && Map.SpatialReference != null && GeoCoordinate != null && GeoCoordinate != GeoCoordinate.Unknown )
     {
         MapPoint newLocation = new ESRI.ArcGIS.Client.Geometry.MapPoint(GeoCoordinate.Longitude, GeoCoordinate.Latitude) { SpatialReference = new SpatialReference(4326) };
         if (!Map.SpatialReference.Equals(newLocation.SpatialReference))
         {
             if (WebMercatorSR.Equals(Map.SpatialReference))
                 newLocation = merc.FromGeographic(newLocation) as MapPoint;
             else
             {
                 if (ProjectionService != null)
                 {
                     if (!ProjectionService.IsBusy)
                     {
                         var geom = newLocation;
                         EventHandler<Tasks.GraphicsEventArgs> handler = null;
                         handler = (a, b) =>
                             {
                                 (a as IProjectionService).ProjectCompleted -= handler;
                                 if (b.Results != null && b.Results.Count > 0 && b.Results[0].Geometry is MapPoint)
                                     BeginAnimateLocation(b.Results[0].Geometry as MapPoint);
                             };
                         ProjectionService.ProjectCompleted += handler;
                         ProjectionService.ProjectAsync(new Graphic[] { new Graphic() { Geometry = geom } }, Map.SpatialReference);
                     }
                     else
                     {
                         EventHandler<Tasks.GraphicsEventArgs> handler = null;
                         handler = (a, b) =>
                             {
                                 ProjectionService.ProjectCompleted -= handler;
                                 UpdateLocation(); //Try again
                             };
                         ProjectionService.ProjectCompleted += handler; //Wait for task to complete
                     }
                 }
                 return; //Wait for projection to complete
             }
         }
         BeginAnimateLocation(newLocation);
     }
 }
コード例 #34
0
        void LocateTo(int level, double x, double y)
        {

            ESRI.ArcGIS.Client.Geometry.MapPoint mp = new ESRI.ArcGIS.Client.Geometry.MapPoint(x, y, new SpatialReference(102100));
            if (currentx != x || currenty != y)
            {
                currentx = x;
                currenty = y;
              
            }

            this.ZoomToLevel(level, mp);
           

          
        }
コード例 #35
0
        void LocateTo(int level, double x, double y)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint mp = new ESRI.ArcGIS.Client.Geometry.MapPoint(x, y, new SpatialReference(104137));
            if (currentx != x || currenty != y)
            {
                currentx = x;
                currenty = y;
                //load other spactial data here

                //(this.map1.Layers["elementlyr"] as ESRI.ArcGIS.Client.ElementLayer).Children.Clear();

                //Alarm alarm = new Alarm() { Width = 40, Height = 40 };
                //alarm.SetValue(ESRI.ArcGIS.Client.ElementLayer.EnvelopeProperty,
                //   new ESRI.ArcGIS.Client.Geometry.Envelope(mp, mp));
                //(this.map1.Layers["elementlyr"] as ESRI.ArcGIS.Client.ElementLayer).Children.Add(alarm);
            }

            this.ZoomToLevel(level, mp);
            //this.map1.ExtentChanged+=(s,a)=>
            //    {
            //        double width = this.map1.Extent.XMax - this.map1.Extent.XMin;
            //        double height = this.map1.Extent.YMax - this.map1.Extent.YMin;
            //        this.map1.ZoomTo(new ESRI.ArcGIS.Client.Geometry.Envelope()
            //            {
            //                XMin = mp.X - width / 2,
            //                XMax = mp.X + width / 2,
            //                YMin = mp.Y - height / 2,
            //                YMax = mp.Y + height / 2,
            //                SpatialReference = new SpatialReference(104137)
            //            }
            //            );
            //    };

            //double width=this.map1.Extent.XMax-this.map1.Extent.XMin;
            //double height=this.map1.Extent.YMax-this.map1.Extent.YMin;
            //this.map1.ZoomTo(new ESRI.ArcGIS.Client.Geometry.Envelope()
            //    {
            //       XMin=mp.X-width/2,
            //       XMax=mp.X+width/2,
            //       YMin=mp.Y-height/2,
            //       YMax=mp.Y+height/2,
            //       SpatialReference = new SpatialReference(104137)
            //    }
            //    );
        }
コード例 #36
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);
            }
        }
コード例 #37
0
        private void ClearButton_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();

                    }
                }
                location = null;
                RunButton.IsEnabled = false;
                txtAddress.Text = "Enter Address";

                if (_mapWidget != null)
                {
                    _mapWidget.Map.MouseClick -= Map_MouseClick;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
コード例 #38
0
        private void ProcessMessagesButton_Click(object sender, RoutedEventArgs e)
        {
            // This function simulates real time message processing by processing a static set of messages from an XML document.

            /*
             * |== Example Message ==|
             *
             * <geomessage>
             *      <_type>position_report</_type>
             *      <_action>update</_action>
             *      <_id>16986029-8295-48d1-aa6a-478f400a53c0</_id>
             *      <_wkid>3857</_wkid>
             *      <sic>GFGPOLKGS-----X</sic>
             *      <_control_points>-226906.99878,6679149.88998;-228500.51759,6677576.8009;-232194.67644,6675625.78198</_control_points>
             *      <uniquedesignation>DIRECTION OF ATTACK</uniquedesignation>
             * </geomessage>
             */

            // Old code:
            // string messagesXmlFilePath = Path.Combine(ESRI.ArcGIS.Client.ArcGISRuntime.InstallPath, @"SDK\Samples\Data\Symbology\Mil2525CMessages.xml");

            OpenFileDialog openDialog = new OpenFileDialog();

            if (!openDialog.ShowDialog().Value)
            {
                return;
            }

            var xmlFilePath = openDialog.FileName;

            // Load the XML document
            XDocument xmlDocument = XDocument.Load(xmlFilePath, LoadOptions.None);

            // Create a collection of messages - may contain both tags: geomessage -or- message
            IEnumerable <XElement> messagesXml = from n in xmlDocument.Root.Elements() where n.Name == "geomessage" select n;

            if (messagesXml.Count() <= 0)
            {
                messagesXml = from n in xmlDocument.Root.Elements() where n.Name == "message" select n;
            }

            if (messagesXml.Count() <= 0)
            {
                MessageBox.Show("No messages found", "No messages found");
            }

            // Iterate through the messages passing each to the ProcessMessage method on the MessageProcessor.
            // The MessageGroupLayer associated with this MessageProcessor will handle the creation of any
            // GraphicsLayers and Graphic objects necessary to display the message.
            ESRI.ArcGIS.Client.Geometry.MapPoint zoomPoint = null;

            bool success = false;

            foreach (XElement messageXml in messagesXml)
            {
                Message message = new Message(from n in messageXml.Elements() select new KeyValuePair <string, string>(n.Name.ToString(), n.Value));

                success = false;
                try
                {
                    success = _messageLayer.ProcessMessage(message);
                }
                catch (System.Exception ex)
                {
                    if (message.ContainsKey("_type"))
                    {
                        System.Diagnostics.Trace.WriteLine("Exception processing message type: " + message["_type"]);
                    }
                }

                if (success)
                {
                    addedIds.Add(message.Id);
                }

                try
                {
                    // Zoom to a symbol point if SRs match
                    if (zoomPoint == null)
                    {
                        string controlPointsString = message["_control_points"];
                        string wkidString          = message["_wkid"];

                        string firstCoord = controlPointsString.Split(';')[0]; // in case > 1
                        string xString    = firstCoord.Split(',')[0];
                        string yString    = firstCoord.Split(',')[1];

                        double x = double.Parse(xString);
                        double y = double.Parse(yString);

                        int wkid = int.Parse(wkidString);

                        SpatialReference sr = new SpatialReference(wkid);
                        zoomPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint(x, y, sr);

                        // TODO: need to spin up a local service with a GeometryService Task
                        // to do arbitrary conversions from any WKID
                    }
                }
                catch (System.Exception ex)
                {
                    // probably a parse exception
                }
            }

            if (zoomPoint != null)
            {
                // Zoom to the first point found (if we are able)
                if (zoomPoint.SpatialReference.WKID == 3857)
                {
                    Envelope env = new ESRI.ArcGIS.Client.Geometry.Envelope(
                        zoomPoint.X - 10000,
                        zoomPoint.Y - 10000,
                        zoomPoint.X + 10000,
                        zoomPoint.Y + 10000);
                    _map.ZoomTo(env);
                }
            }
        }