Ejemplo n.º 1
0
 public ESRI.ArcGIS.Client.Symbols.Symbol GetSymbol(ESRI.ArcGIS.Client.Graphic graphic)
 {
     if (graphic.Geometry is ESRI.ArcGIS.Client.Geometry.Polygon ||
         graphic.Geometry is ESRI.ArcGIS.Client.Geometry.Envelope)
     {
         return new SimpleFillSymbol()
                {
                    Fill            = new SolidColorBrush(Color.FromArgb(0x33, 0xFF, 0, 0)),
                    BorderThickness = 2,
                    BorderBrush     = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0, 0))
                }
     }
     ;
     else if (graphic.Geometry is ESRI.ArcGIS.Client.Geometry.Polyline)
     {
         return new SimpleLineSymbol()
                {
                    Color = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0, 0)),
                    Width = 3
                }
     }
     ;
     else
     {
         return(new SimpleMarkerSymbol());
     }
 }
Ejemplo n.º 2
0
        private void graphicsLayer_MouseEnter(object sender, GraphicMouseEventArgs args)
        {
            mouseIsOver = true;
            Graphic graphic = args.Graphic;

            if (currentFeature != graphic)             //Mouse entered a new feature
            {
                this.expanded  = false;
                currentFeature = graphic;
                Point p = args.GetPosition(Parent as UIElement);
                SetValue(Canvas.LeftProperty, p.X + HorizontalOffset);
                SetValue(Canvas.TopProperty, p.Y + VerticalOffset);
                this.DataContext = this.ItemsSource = graphic.Attributes;
                if (!string.IsNullOrEmpty(TitleMember))
                {
                    object title = null;
                    if (graphic.Attributes.ContainsKey(TitleMember))
                    {
                        title = string.Format("{0}", graphic.Attributes[TitleMember]);
                    }
                    else
                    {
                        string firstKey = null;
                        foreach (string key in graphic.Attributes.Keys)
                        {
                            if (firstKey == null)
                            {
                                firstKey = key;
                            }
                            if (graphic.Attributes[key].GetType() == typeof(string))
                            {
                                title = graphic.Attributes[key] as string;
                                break;
                            }
                        }
                        if (title == null && !string.IsNullOrEmpty(firstKey))
                        {
                            title = string.Format("{0}", graphic.Attributes[firstKey]);
                        }
                    }
                    this.Title = title;
                }
                ChangeVisualState(false);
                Visibility = Visibility.Collapsed;
            }
            if (Visibility == Visibility.Collapsed)
            {
                timer.Start();                 //Delay showing maptip
            }
        }
Ejemplo n.º 3
0
        public void DrawPoint(double latitude, double longitude)
        {
            IsDirty = true;
            ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol marker = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol();
            marker.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle;
            marker.Color = System.Windows.Media.Brushes.OrangeRed;
            // marker.Size =

            ESRI.ArcGIS.Client.Graphic g = new ESRI.ArcGIS.Client.Graphic();
            g.Symbol = marker;

            var pt = MapUtil.ProjectPoint(new System.Windows.Point(longitude, latitude));

            ESRI.ArcGIS.Client.Geometry.MapPoint geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(pt.X, pt.Y);
            g.Geometry = geometry;

            _l1.Graphics.Add(g);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Find graphic in layers, associated to item.
        /// </summary>
        /// <param name="item">Source item.</param>
        /// <param name="objectLayers">Layers collection.</param>
        /// <returns>Graphic.</returns>
        public static ESRI.ArcGIS.Client.Graphic GetGraphicByDataItem(object item, IList <ObjectLayer> objectLayers)
        {
            Debug.Assert(item != null);
            Debug.Assert(objectLayers != null);

            // Find graphic, which represents edited item.
            ESRI.ArcGIS.Client.Graphic graphic = null;

            foreach (ObjectLayer layer in objectLayers)
            {
                graphic = layer.FindGraphicByData(item);

                if (graphic != null)
                {
                    break;
                }
            }

            return(graphic);
        }
Ejemplo n.º 5
0
        public static List<ESRI.ArcGIS.Client.Graphic> GetGraphicList()
        {
            List<ESRI.ArcGIS.Client.Graphic> graphicList = new List<ESRI.ArcGIS.Client.Graphic>();

            List<ExamplePoint> examplePointList = ExamplePoint.RetrieveRecords();

            ESRI.ArcGIS.Client.Geometry.SpatialReference spatialRef = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326);

            foreach (ExamplePoint p in examplePointList)
            {
                ESRI.ArcGIS.Client.Graphic myGraphic = new ESRI.ArcGIS.Client.Graphic();

                myGraphic.Geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(p.pointGeometry.X, p.pointGeometry.Y, spatialRef);

                myGraphic.Attributes.Add("MilePost", p.milePost);

                myGraphic.Attributes.Add("PointName", p.pointName);

                graphicList.Add(myGraphic);

            }

            return graphicList;
        }
Ejemplo n.º 6
0
 private void graphicsLayer_MouseEnter(object sender, GraphicMouseEventArgs args)
 {
     mouseIsOver = true;
     Graphic graphic = args.Graphic;
     if (currentFeature != graphic) //Mouse entered a new feature
     {
         this.expanded = false;
         currentFeature = graphic;
         Point p = args.GetPosition(Parent as UIElement);
         SetValue(Canvas.LeftProperty, p.X + HorizontalOffset);
         SetValue(Canvas.TopProperty, p.Y + VerticalOffset);
         this.DataContext = this.ItemsSource = graphic.Attributes;
         if (!string.IsNullOrEmpty(TitleMember))
         {
             object title = null;
             if (graphic.Attributes.ContainsKey(TitleMember))
                 title = string.Format("{0}", graphic.Attributes[TitleMember]);
             else
             {
                 string firstKey = null;
                 foreach (string key in graphic.Attributes.Keys)
                 {
                     if (firstKey == null) firstKey = key;
                     if (graphic.Attributes[key].GetType() == typeof(string))
                     {
                         title = graphic.Attributes[key] as string;
                         break;
                     }
                 }
                 if (title == null && !string.IsNullOrEmpty(firstKey))
                     title = string.Format("{0}", graphic.Attributes[firstKey]);
             }
             this.Title = title;
         }
         ChangeVisualState(false);
         Visibility = Visibility.Collapsed;
     }
     if (Visibility == Visibility.Collapsed)
     {
         timer.Start(); //Delay showing maptip
     }
 }
        /// <summary>
        /// Create a .pdf document based on location and buffer radius
        /// </summary>
        public async Task <string> GetReportGenerationAsync(ESRI.ArcGIS.Client.Graphic feature, int bufferRadius, int wkid)
        {
            //Create a token so we can gain access to the geoenrich service
            TokenService tokenService = new TokenService();

            Token = await tokenService.GenerateTokenAsync();

            string pdfLocation = Assembly.GetExecutingAssembly().Location;

            pdfLocation = pdfLocation.Replace(".dll", ".pdf");
            if (File.Exists(pdfLocation))
            {
                File.Delete(pdfLocation);
            }

            if (bufferRadius <= 0)
            {
                bufferRadius = 3;
            }

            MapPoint currentLocation = feature.Geometry as MapPoint;

            string token             = string.Format("&token={0}", Token.AccessToken);
            string studyAreas        = "&studyareas=[{\"geometry\":{\"x\":" + currentLocation.X + ",\"y\":" + currentLocation.Y + "}}]";
            string format            = "&format=pdf";
            string studyareasoptions = string.Format("&studyareasoptions=%7B%22areaType%22%3A%22RingBuffer%22%2C%22bufferUnits%22%3A%22esriMiles%22%2C%22bufferRadii%22%3A%5B{0}%5D%7D", bufferRadius);
            string insr = string.Format("&inSR={0}", wkid);
            string f    = "&f=bin";
            string reportGenerationUrl =
                @"http://geoenrich.arcgis.com/arcgis/rest/services/World/MapServer/exts/BAServer/Geoenrichment/CreateReport?" + token + studyAreas + format + studyareasoptions + insr + f;

            #region Issue the request to generate a report
            WebResponse response;
            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(reportGenerationUrl);
                webRequest.Timeout = 0xea60;
                response           = await webRequest.GetResponseAsync();

                if (response == null || response.ContentLength == 0)
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
            #endregion

            #region Read the result into pdfLocation
            try
            {
                using (Stream responseStream = response.GetResponseStream())
                {
                    using (FileStream fileStream = new FileStream(pdfLocation, FileMode.Create))
                    {
                        byte[] buffer    = new byte[4096];
                        int    bytesRead = await responseStream.ReadAsync(buffer, 0, buffer.Length);

                        while (bytesRead > 0)
                        {
                            await fileStream.WriteAsync(buffer, 0, bytesRead);

                            bytesRead = await responseStream.ReadAsync(buffer, 0, buffer.Length);
                        }
                    }
                }
            }
            catch
            {
                return(null);
            }
            #endregion

            return(pdfLocation);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pointGroupId"></param>
        /// <param name="routeEventId"></param>
        /// <param name="groupCreatedDate"></param>
        /// <returns></returns>
        public ESRI.ArcGIS.Client.Graphic toGraphic()
        {
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic();
            graphic.Geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(point_X, point_Y, new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326));

            graphic.Attributes.Add("EventID", this.eventID);
            graphic.Attributes.Add("OriginEventID", this.eventID);
            graphic.Attributes.Add("CreatedDate", createdDate);
            graphic.Attributes.Add("CreatedBy", createdBy);
            graphic.Attributes.Add("POINT_X", point_X);
            graphic.Attributes.Add("POINT_Y", point_Y);
            if (point_Z != null)
            {
                graphic.Attributes.Add("POINT_Z", (double)point_Z);
            }

            graphic.Attributes.Add("Measurement", measurement);
            graphic.Attributes.Add("Description", description);

            if (equipmentid != null)
            {
                graphic.Attributes.Add("EquipmentID", (int)equipmentid);
            }
            if (accuracy != null)
            {
                graphic.Attributes.Add("Accuracy", (double)accuracy);
            }
            if (probe != null)
            {
                graphic.Attributes.Add("Probe", ((bool)probe ? 1 : 0));
            }

            graphic.Attributes.Add("PointGroupID", pointGroupId);
            graphic.Attributes.Add("RouteEventID", routeEventId);
            graphic.Attributes.Add("LastModified", groupCreatedDate);

            graphic.Attributes.Add("SeriesEventID", this.seriesEventId);
            graphic.Attributes.Add("Station", this.station);
            graphic.Attributes.Add("Measure", this.measure);
            graphic.Attributes.Add("ModifiedBy", this.modifiedBy);

            return graphic;
        }