public static Graphic NewDonut(double x, double y, double innerRadius, double outerRadius) { double[] px = new double[NUM]; double[] py = new double[NUM]; GeometryAlgorithms.CircleToPoints(x, y, outerRadius, NUM, px, py, AngleDirection.CounterClockwise); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); for (int i = 0; i < NUM; i++) { MapPoint p = new MapPoint(px[i], py[i]); pc.Add(p); } pc.Add(pc[0]); PolygonBuilder polygon = new PolygonBuilder(pc); GeometryAlgorithms.CircleToPoints(x, y, innerRadius, NUM, px, py, AngleDirection.Clockwise); pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); for (int i = 0; i < NUM; i++) { MapPoint p = new MapPoint(px[i], py[i]); pc.Add(p); } pc.Add(pc[0]); polygon.AddPart(pc); Graphic g = new Graphic(); g.Geometry = polygon.ToGeometry(); return g; }
public static Graphic NewDonut(double x, double y, double innerRadius, double outerRadius) { double[] px = new double[NUM]; double[] py = new double[NUM]; GeometryAlgorithms.CircleToPoints(x, y, outerRadius, NUM, px, py, AngleDirection.CounterClockwise); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); for (int i = 0; i < NUM; i++) { MapPoint p = new MapPoint(px[i], py[i]); pc.Add(p); } pc.Add(pc[0]); PolygonBuilder polygon = new PolygonBuilder(pc); GeometryAlgorithms.CircleToPoints(x, y, innerRadius, NUM, px, py, AngleDirection.Clockwise); pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); for (int i = 0; i < NUM; i++) { MapPoint p = new MapPoint(px[i], py[i]); pc.Add(p); } pc.Add(pc[0]); polygon.AddPart(pc); Graphic g = new Graphic(); g.Geometry = polygon.ToGeometry(); return(g); }
public static Graphic NewLine(MapPoint p1, MapPoint p2) { Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); return(NewPolyline(pc)); }
public static Graphic NewTriangle(MapPoint p1, MapPoint p2, MapPoint p3) { Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); //pc.Add(p1); return(NewPolygon(pc)); }
private void CreatePoints() { _coordinates = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); _coordinates.Add(new MapPoint(-106.981, 39.028, 6000, SpatialReferences.Wgs84)); _coordinates.Add(new MapPoint(-106.956, 39.081, 6000, SpatialReferences.Wgs84)); _coordinates.Add(new MapPoint(-106.869, 39.081, 6000, SpatialReferences.Wgs84)); _coordinates.Add(new MapPoint(-106.879, 39.014, 6000, SpatialReferences.Wgs84)); }
private void CreatePoints() { _coordinates = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); _coordinates.Add(new MapPoint(-106.981, 39.028, 6000, SpatialReferences.Wgs84)); _coordinates.Add(new MapPoint(-106.956, 39.081, 6000, SpatialReferences.Wgs84)); _coordinates.Add(new MapPoint(-106.869, 39.081, 6000, SpatialReferences.Wgs84)); _coordinates.Add(new MapPoint(-106.879, 39.014, 6000, SpatialReferences.Wgs84)); }
public static Graphic NewQuadrilateral(MapPoint p1, MapPoint p2, MapPoint p3, MapPoint p4) { Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); //pc.Add(p1); return(NewPolygon(pc)); }
public void OnPolygonWinOK(object parameter) { readytodrawPolygon = false; _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; var tempgraphic = drawPolygonGraphic; _graphicsOverlay.Graphics.Remove(drawPolygonGraphic); SphereMarkerSymbol tagsymbol = App.Current.Resources["drawtoolPolygon"] as SphereMarkerSymbol; PolygonColor = parameter as SolidColorBrush; var Polygonsym = new SimpleFillSymbol(); Polygonsym.Color = PolygonColor.Color; var sPointcollect = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (MapPoint tPoint in Polygonpointcollec) { MapPoint sPoint = new MapPoint(tPoint.X, tPoint.Y, drawPolygonZ); sPointcollect.Add(sPoint); } drawPolygonGraphic = new Graphic(new Polygon(sPointcollect), Polygonsym); drawPolygonGraphic.Attributes["Label"] = Polygongraphictext; _graphicsOverlay.Graphics.Add(drawPolygonGraphic); drawPolygonZ = 0; Polygonpointcollec.Clear(); Polygonwinshowing = false; PolygonWin.Close(); return; }
public void OnLineWinOK(object parameter) { readytodrawLine = false; _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; var tempgraphic = drawLineGraphic; _graphicsOverlay.Graphics.Remove(drawLineGraphic); SphereMarkerSymbol tagsymbol = App.Current.Resources["drawtoolLine"] as SphereMarkerSymbol; LineColor = parameter as SolidColorBrush; var linesym = new SimpleLineSymbol(); linesym.Color = LineColor.Color; linesym.Width = linewidth; var sPointcollect = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (MapPoint tPoint in Linepointcollec) { MapPoint sPoint = new MapPoint(tPoint.X, tPoint.Y, drawLineZ); sPointcollect.Add(sPoint); } drawLineGraphic = new Graphic(new Polyline(sPointcollect), linesym); drawLineGraphic.Attributes["Label"] = Linegraphictext; _graphicsOverlay.Graphics.Add(drawLineGraphic); drawLineZ = 0; Linepointcollec.Clear(); linewinshowing = false; LineWin.Close(); return; }
public static Graphic NewCircle(double x, double y, double r) { double[] px = new double[NUM]; double[] py = new double[NUM]; GeometryAlgorithms.CircleToPoints(x, y, r, NUM, px, py, AngleDirection.CounterClockwise); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); for (int i = 0; i < NUM; i++) { MapPoint p = new MapPoint(px[i], py[i]); pc.Add(p); } pc.Add(pc[0]); return(NewPolygon(pc)); }
public static Graphic NewCircle(double x, double y, double r) { double[] px = new double[NUM]; double[] py = new double[NUM]; GeometryAlgorithms.CircleToPoints(x, y, r, NUM, px, py, AngleDirection.CounterClockwise); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); for (int i = 0; i < NUM; i++) { MapPoint p = new MapPoint(px[i], py[i]); pc.Add(p); } pc.Add(pc[0]); return NewPolygon(pc); }
private Graphic GraphicFromAttributes(List <XElement> graphicAttributes) { // Get the geometry and the spatial reference from the message elements. XElement geometryAttribute = graphicAttributes.First(attr => attr.Name == "_control_points"); XElement spatialReferenceAttr = graphicAttributes.First(attr => attr.Name == "_wkid"); // Split the geometry field into a list of points. Array pointStrings = geometryAttribute.Value.Split(';'); // Create a point collection in the correct spatial reference. int wkid = Convert.ToInt32(spatialReferenceAttr.Value); SpatialReference pointSR = SpatialReference.Create(wkid); PointCollection graphicPoints = new PointCollection(pointSR); // Add a point for each point in the list. foreach (string pointString in pointStrings) { var coords = pointString.Split(','); graphicPoints.Add(Convert.ToDouble(coords[0]), Convert.ToDouble(coords[1])); } // Create a multipoint from the point collection. Multipoint graphicMultipoint = new Multipoint(graphicPoints); // Create the graphic from the multipoint. Graphic messageGraphic = new Graphic(graphicMultipoint); // Add all of the message's attributes to the graphic (some of these are used for rendering). foreach (XElement attr in graphicAttributes) { messageGraphic.Attributes[attr.Name.ToString()] = attr.Value; } return(messageGraphic); }
// Draw horizontal distributed load // Note: x1<x2, (x1,y1)-(x2,y1) is a horizontal line, (x1,y2)-(x2,y3) is a oblique line // public static GraphicCollection DistributedLoad_Horizontal(double x1, double x2, double y1, double y2, double y3, Symbol backgroundFillSymbol, Symbol arrowFillSymbol, Symbol lineSymbol) { GraphicCollection gc = new GraphicCollection(); MapPoint p1 = new MapPoint(x1, y1); MapPoint p2 = new MapPoint(x1, y2); MapPoint p3 = new MapPoint(x2, y3); MapPoint p4 = new MapPoint(x2, y1); Graphic g = ArcGISMappingUtility.NewQuadrilateral(p1, p2, p3, p4); g.Symbol = backgroundFillSymbol; gc.Add(g); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); pc.Add(p1); g = ArcGISMappingUtility.NewPolyline(pc); g.Symbol = lineSymbol; gc.Add(g); double x00, y00, y01; for (int i = 0; i <= 10; ++i) { x00 = x1 + i * (x2 - x1) / 10.0; y00 = y1; y01 = y2 + i * (y3 - y2) / 10.0; MapPoint p00 = new MapPoint(x00, y00); MapPoint p01 = new MapPoint(x00, y01); g = ArcGISMappingUtility.NewLine(p00, p01); g.Symbol = lineSymbol; gc.Add(g); pc = ArcGISMappingUtility.VectorArrowPoints(x00, y2, p00); g = ArcGISMappingUtility.NewPolygon(pc); g.Symbol = arrowFillSymbol; gc.Add(g); } return(gc); }
private void Draw(bool points, bool area) { System.Drawing.Color redColor = System.Drawing.Color.FromName("Red"); System.Drawing.Color blueColor = System.Drawing.Color.FromName("Blue"); if (points) { foreach (Incident incident in personOfInterest.Incidents) { //Create a point geometry var point = new MapPoint(incident.XCoord, incident.YCoord, SpatialReferences.Wgs84); //Create point symbol with outline var pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, redColor, 10); pointSymbol.Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, blueColor, 2); //Create point graphic with geometry & symbol var pointGraphic = new Graphic(point, pointSymbol); //Add point graphic to graphic overlay MapGraphics.Graphics.Add(pointGraphic); } } if (area) { //Create polygon geometry var polygonPoints = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); foreach (Incident incident in personOfInterest.Incidents) { polygonPoints.Add(new MapPoint(incident.XCoord, incident.YCoord)); } var polygon = new Polygon(polygonPoints); System.Drawing.Color blueColorTrans = System.Drawing.Color.FromArgb(128, 0, 0, 255); //Create symbol for polygon with outline var polygonSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blueColorTrans, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, redColor, 2)); //Create polygon graphic with geometry and symbol Graphic polygonGraphic = new Graphic(polygon, polygonSymbol); //Add polygon graphic to graphics overlay MapGraphics.Graphics.Add(polygonGraphic); } }
public static IEnumerable <MapPoint> ChangeSpatialReference( IEnumerable <MapPoint> part, SpatialReference sr) { Esri.ArcGISRuntime.Geometry.PointCollection points = new Esri.ArcGISRuntime.Geometry.PointCollection(sr); foreach (MapPoint p in part) { points.Add(ChangeSpatialReference(p, sr)); } return(points); }
private void Load3DLineLayer(object parameter) { var pointcollec = new Esri.ArcGISRuntime.Geometry.PointCollection(); pointcollec.Add(new MapPoint(116.587, 39.852, 3000)); pointcollec.Add(new MapPoint(116.587, 39.952, 3000)); pointcollec.Add(new MapPoint(116.687, 39.952, 3000)); pointcollec.Add(new MapPoint(116.687, 40.052, 3000)); var line = new Esri.ArcGISRuntime.Geometry.Polyline(pointcollec, SpatialReferences.Wgs84); var graphicLayer = new GraphicsLayer(); graphicLayer.DisplayName = "3D线图层"; graphicLayer.ShowLegend = false; graphicLayer.Graphics.Add(new Graphic(line)); graphicLayer.Renderer = App.Current.Resources["LineSimpleRenderer"] as SimpleRenderer; graphicLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; graphicLayer.ID = "3DLineLayer"; scene.Layers.Add(graphicLayer); }
// Creates a square polygon with a hole centered at the given point private Polygon CreatePolygonBox(MapPoint center, double length) { var halfLen = length / 2.0; Geometry.PointCollection coords = new Geometry.PointCollection(); coords.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); coords.Add(new MapPoint(center.X + halfLen, center.Y + halfLen)); coords.Add(new MapPoint(center.X + halfLen, center.Y - halfLen)); coords.Add(new MapPoint(center.X - halfLen, center.Y - halfLen)); coords.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); halfLen /= 3; Geometry.PointCollection coordsHole = new Geometry.PointCollection(); coordsHole.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); coordsHole.Add(new MapPoint(center.X - halfLen, center.Y - halfLen)); coordsHole.Add(new MapPoint(center.X + halfLen, center.Y - halfLen)); coordsHole.Add(new MapPoint(center.X + halfLen, center.Y + halfLen)); coordsHole.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); return(new Polygon(new List <Geometry.PointCollection> { coords, coordsHole }, MyMapView.SpatialReference)); }
VectorArrowPoints(double beginPntX, double beginPntY, MapPoint endPnt) { double x = beginPntX - endPnt.X; double y = beginPntY - endPnt.Y; double angle = Math.Atan2(y, x); double alpha = Math.PI / 6; // arrow is 30 degree by each side of original line double length = Math.Sqrt(x * x + y * y) * 0.25; // arrow is a quarter of original length MapPointBuilder p1 = new MapPointBuilder(endPnt); MapPointBuilder p2 = new MapPointBuilder(endPnt); p1.X += length * Math.Cos(angle + alpha); p1.Y += length * Math.Sin(angle + alpha); p2.X += length * Math.Cos(angle - alpha); p2.Y += length * Math.Sin(angle - alpha); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1.ToGeometry()); pc.Add(endPnt); pc.Add(p2.ToGeometry()); return(pc); }
public static void Reverse(Esri.ArcGISRuntime.Geometry.PointCollection pts) { IEnumerable <MapPoint> reversedPts = pts.Reverse(); Esri.ArcGISRuntime.Geometry.PointCollection newPts = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (MapPoint pt in reversedPts) { newPts.Add(pt); } pts.Clear(); foreach (MapPoint pt in newPts) { pts.Add(pt); } }
public Polygon CreateCirclePolygon(double lat, double lon, double radiuskm) { var mappoints = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); double lat_rad1; //outer ring double lon_rad1; for (var i = 0; i < 35; i++) { var theta = (float)(2 * Math.PI * i) / 35; //outer ring RadialToLatitudeLongitude(radiuskm, theta, lat * Math.PI / 180, lon * Math.PI / 180, out lat_rad1, out lon_rad1); mappoints.Add(lon_rad1 * 180.0 / Math.PI, lat_rad1 * 180.0 / Math.PI, 10); } return(new Polygon(mappoints)); }
public void OnLineWinOK(object parameter) { readytodrawLine = false; _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; var tempgraphic = drawLineGraphic; _graphicsOverlay.Graphics.Remove(drawLineGraphic); SphereMarkerSymbol tagsymbol = App.Current.Resources["drawtoolLine"] as SphereMarkerSymbol; LineColor = parameter as SolidColorBrush; var linesym = new SimpleLineSymbol(); linesym.Color = LineColor.Color; linesym.Width = linewidth; var sPointcollect = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach(MapPoint tPoint in Linepointcollec) { MapPoint sPoint = new MapPoint(tPoint.X, tPoint.Y, drawLineZ); sPointcollect.Add(sPoint); } drawLineGraphic = new Graphic(new Polyline(sPointcollect), linesym); drawLineGraphic.Attributes["Label"] = Linegraphictext; _graphicsOverlay.Graphics.Add(drawLineGraphic); drawLineZ = 0; Linepointcollec.Clear(); linewinshowing = false; LineWin.Close(); return; }
public static IEnumerable<MapPoint> ChangeSpatialReference( IEnumerable<MapPoint> part, SpatialReference sr) { Esri.ArcGISRuntime.Geometry.PointCollection points = new Esri.ArcGISRuntime.Geometry.PointCollection(sr); foreach (MapPoint p in part) points.Add(ChangeSpatialReference(p, sr)); return points; }
// Draw horizontal distributed load // Note: x1<x2, (x1,y1)-(x2,y1) is a horizontal line, (x1,y2)-(x2,y3) is a oblique line // public static GraphicCollection DistributedLoad_Horizontal(double x1, double x2, double y1, double y2, double y3, Symbol backgroundFillSymbol, Symbol arrowFillSymbol, Symbol lineSymbol) { GraphicCollection gc = new GraphicCollection(); MapPoint p1 = new MapPoint(x1, y1); MapPoint p2 = new MapPoint(x1, y2); MapPoint p3 = new MapPoint(x2, y3); MapPoint p4 = new MapPoint(x2, y1); Graphic g = ArcGISMappingUtility.NewQuadrilateral(p1, p2, p3, p4); g.Symbol = backgroundFillSymbol; gc.Add(g); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); pc.Add(p1); g = ArcGISMappingUtility.NewPolyline(pc); g.Symbol = lineSymbol; gc.Add(g); double x00, y00, y01; for (int i = 0; i <= 10; ++i) { x00 = x1 + i * (x2 - x1) / 10.0; y00 = y1; y01 = y2 + i * (y3 - y2) / 10.0; MapPoint p00 = new MapPoint(x00, y00); MapPoint p01 = new MapPoint(x00, y01); g = ArcGISMappingUtility.NewLine(p00, p01); g.Symbol = lineSymbol; gc.Add(g); pc = ArcGISMappingUtility.VectorArrowPoints(x00, y2, p00); g = ArcGISMappingUtility.NewPolygon(pc); g.Symbol = arrowFillSymbol; gc.Add(g); } return gc; }
VectorArrowPoints(double beginPntX, double beginPntY, MapPoint endPnt) { double x = beginPntX - endPnt.X; double y = beginPntY - endPnt.Y; double angle = Math.Atan2(y, x); double alpha = Math.PI / 6; // arrow is 30 degree by each side of original line double length = Math.Sqrt(x * x + y * y) * 0.25; // arrow is a quarter of original length MapPointBuilder p1 = new MapPointBuilder(endPnt); MapPointBuilder p2 = new MapPointBuilder(endPnt); p1.X += length * Math.Cos(angle + alpha); p1.Y += length * Math.Sin(angle + alpha); p2.X += length * Math.Cos(angle - alpha); p2.Y += length * Math.Sin(angle - alpha); Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1.ToGeometry()); pc.Add(endPnt); pc.Add(p2.ToGeometry()); return pc; }
public static void Reverse(Esri.ArcGISRuntime.Geometry.PointCollection pts) { IEnumerable<MapPoint> reversedPts = pts.Reverse(); Esri.ArcGISRuntime.Geometry.PointCollection newPts = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (MapPoint pt in reversedPts) newPts.Add(pt); pts.Clear(); foreach (MapPoint pt in newPts) pts.Add(pt); }
private void Load3DLineLayer(object parameter) { var pointcollec = new Esri.ArcGISRuntime.Geometry.PointCollection(); pointcollec.Add(new MapPoint(116.587, 39.852, 3000)); pointcollec.Add(new MapPoint(116.587, 39.952, 3000)); pointcollec.Add(new MapPoint(116.687, 39.952, 3000)); pointcollec.Add(new MapPoint(116.687, 40.052, 3000)); var line = new Esri.ArcGISRuntime.Geometry.Polyline(pointcollec, SpatialReferences.Wgs84); var graphicLayer = new GraphicsLayer(); graphicLayer.DisplayName = "3D线图层"; graphicLayer.ShowLegend = false; graphicLayer.Graphics.Add(new Graphic(line)); graphicLayer.Renderer = App.Current.Resources["LineSimpleRenderer"] as SimpleRenderer; graphicLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; graphicLayer.ID = "3DLineLayer"; scene.Layers.Add(graphicLayer); }
//=================探空仪位置更新==================== private void AnimatePlane(object sender, ElapsedEventArgs elapsedEventArgs) { //LoadData(); Dispatcher.BeginInvoke(new Action(() => { if (Global.namelist.Count > 0) { var ait = Global.namelist.GetEnumerator(); var bit = Global.lonlist.GetEnumerator(); var cit = Global.latlist.GetEnumerator(); var dit = Global.radiuslist.GetEnumerator(); while (ait.MoveNext() && bit.MoveNext() && cit.MoveNext() && dit.MoveNext()) { double lo = double.Parse(bit.Current.ToString()); double la = double.Parse(cit.Current.ToString()); double ra = double.Parse(dit.Current.ToString()); Createarea(lo, la, ra); } } })); //if (_randomizer.Next(0, 10) > 8) //{ // Don't send an update about 20% of the time. // return; // } // _locationIndex++; int cnt = 0; MapPoint p = observerCamera.Location; double dis = 999999999; if (Dector2D.Count > 0 && MapPointslist.Count > 0) { int count = Dector2D.Count; for (int i = 0; i < count; i++) { int index = Global.DectorIndexIdlist[i]; List <MapPoint> _artificialMapPoints = new List <MapPoint>(); if (MapPointslist[i].Count > 0) { _artificialMapPoints = MapPointslist[i]; if (index > _artificialMapPoints.Count) { Global.DectorNamelist.Remove(Global.DectorNamelist[i]); Global.StationIdlist.Remove(Global.StationIdlist[i]); Global.DectorIndexIdlist.Remove(Global.DectorIndexIdlist[i]); } else { MapPoint selectedMapPoint = _artificialMapPoints[index % _artificialMapPoints.Count]; double dis1 = Distance(p.X, p.Y, p.Z, selectedMapPoint.X, selectedMapPoint.Y, selectedMapPoint.Z); if (dis1 < dis) { cnt = i; dis = dis1; } Graphic name2D = Dector2D[i]; name2D.Geometry = new MapPoint(selectedMapPoint.X, selectedMapPoint.Y, spatialReference: SpatialReference.Create(wkid: 4326)); Graphic name3D = Dector3D[i]; name3D.Geometry = new MapPoint(selectedMapPoint.X, selectedMapPoint.Y, selectedMapPoint.Z); //=====预测轨迹显示==== // Create a purple simple line symbol SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.FromArgb(0xFF, 0x80, 0x00, 0x80), 3); SimpleLineSymbol lineSymbol1 = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Red, 3); Esri.ArcGISRuntime.Geometry.PointCollection points = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); Esri.ArcGISRuntime.Geometry.PointCollection points1 = new Esri.ArcGISRuntime.Geometry.PointCollection(); if (index + 120 < _artificialMapPoints.Count) { for (int j = index; j < index + 120; j++) { // Get the next point . MapPoint selectedMapPoint1 = _artificialMapPoints[j % _artificialMapPoints.Count]; points.Add(new MapPoint(selectedMapPoint1.X, selectedMapPoint1.Y, spatialReference: SpatialReference.Create(wkid: 4326))); points1.Add(new MapPoint(selectedMapPoint1.X, selectedMapPoint1.Y, selectedMapPoint1.Z)); } ; } // Create the polyline from the point collection Esri.ArcGISRuntime.Geometry.Polyline polyline = new Esri.ArcGISRuntime.Geometry.Polyline(points); Esri.ArcGISRuntime.Geometry.Polyline polyline1 = new Esri.ArcGISRuntime.Geometry.Polyline(points1); GraphicsOverlay _overlay = Dector2Doverlay[i]; GraphicsOverlay _overlay1 = Dector3Doverlay[i]; _overlay.Graphics.Clear(); _overlay1.Graphics.Clear(); // Create the graphic with polyline and symbol Graphic graphic = new Graphic(polyline, lineSymbol); Graphic graphic1 = new Graphic(polyline1, lineSymbol1); // Add graphic to the graphics overlay _overlay.Graphics.Add(graphic); _overlay1.Graphics.Add(graphic1); } } } } if (MapPointslist.Count > 0) { List <MapPoint> _artificialMapPoints2 = new List <MapPoint>(); _artificialMapPoints2 = MapPointslist[cnt]; // Get the next point . MapPoint selectedMapPoint2 = _artificialMapPoints2[Global.DectorIndexIdlist[cnt] % _artificialMapPoints2.Count]; string n = Global.DectorNamelist[cnt]; Dispatcher.BeginInvoke(new Action(() => { NameLabel.Text = n; AboveSeaLevelLabel.Text = " " + selectedMapPoint2.Z + "m"; LonLabel.Text = " " + selectedMapPoint2.X; LatLabel.Text = " " + selectedMapPoint2.Y; })); } if (Global.DectorIndexIdlist.Count > 0) { for (int k = 0; k < Global.DectorIndexIdlist.Count; k++) { Global.DectorIndexIdlist[k] = Global.DectorIndexIdlist[k] + 120; } } }
public void OnPolygonWinOK(object parameter) { readytodrawPolygon = false; _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; var tempgraphic = drawPolygonGraphic; _graphicsOverlay.Graphics.Remove(drawPolygonGraphic); SphereMarkerSymbol tagsymbol = App.Current.Resources["drawtoolPolygon"] as SphereMarkerSymbol; PolygonColor = parameter as SolidColorBrush; var Polygonsym = new SimpleFillSymbol(); Polygonsym.Color = PolygonColor.Color; var sPointcollect = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (MapPoint tPoint in Polygonpointcollec) { MapPoint sPoint = new MapPoint(tPoint.X, tPoint.Y, drawPolygonZ); sPointcollect.Add(sPoint); } drawPolygonGraphic = new Graphic(new Polygon(sPointcollect), Polygonsym); drawPolygonGraphic.Attributes["Label"] = Polygongraphictext; _graphicsOverlay.Graphics.Add(drawPolygonGraphic); drawPolygonZ = 0; Polygonpointcollec.Clear(); Polygonwinshowing = false; PolygonWin.Close(); return; }
//private async void MouseMove(object parameter) //{ // Point curPoint = Mouse.GetPosition(tagView as FrameworkElement); // _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; // if (b_onpointmoving && b_onpoint) // { // var tempgraphic = drawPointGraphic; // _graphicsOverlay.Graphics.Remove(drawPointGraphic); // MapPoint point = tagView.ScreenToLocation(curPoint); // drawPointGraphic = new Graphic(new MapPoint(point.X, point.Y, (tempgraphic.Geometry as MapPoint).Z), tempgraphic.Attributes, tempgraphic.Symbol); // _graphicsOverlay.Graphics.Add(drawPointGraphic); // return; // } // var ga = await _graphicsOverlay.HitTestAsync(tagView, curPoint); // if (ga != null) // { // b_onpoint = true; // Mouse.SetCursor(Cursors.Hand); // } // else // { // b_onpoint = false; // Mouse.SetCursor(Cursors.Arrow); // } //} private void MouseLeftButtonDown(object parameter) { if (readytodrawPoint) { Point curPoint = Mouse.GetPosition(tagView as FrameworkElement); MapPoint tagPoint = tagView.ScreenToLocation(curPoint); drawpointX = tagPoint.X; drawpointY = tagPoint.Y; drawPointGraphic = new Graphic(tagPoint, App.Current.Resources["drawtoolpoint"] as Symbol); Pointgraphictext = "InputLabel"; drawPointGraphic.Attributes["Label"] = pointgraphictext; pointColor = new SolidColorBrush((drawPointGraphic.Symbol as SphereMarkerSymbol).Color); _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; _graphicsOverlay.Graphics.Add(drawPointGraphic); if (!pointwinshowing) { pointWin = new PointToolWin(); //pointWin.Owner = tagView.Parent as Window; pointwinshowing = true; pointWin.Show(); readytodrawPoint = false; } } else if (readytodrawLine) { Point curPoint = Mouse.GetPosition(tagView as FrameworkElement); MapPoint tagPoint = tagView.ScreenToLocation(curPoint); _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; if (linewinshowing) { _graphicsOverlay.Graphics.Remove(drawLineGraphic); } linegraphictext = "Inputlabel"; Linepointcollec.Add(new MapPoint(tagPoint.X, tagPoint.Y, drawLineZ)); var linesym = new SimpleLineSymbol(); lineColor = new SolidColorBrush((App.Current.Resources["drawtoolpoint"] as SphereMarkerSymbol).Color); linesym.Color = LineColor.Color; linesym.Width = linewidth; drawLineGraphic = new Graphic(new Polyline(Linepointcollec), linesym); _graphicsOverlay.Graphics.Add(drawLineGraphic); if (!linewinshowing) { LineWin = new LineToolWin(); LineWin.Show(); linewinshowing = true; } } else if (readytodrawPolygon) { Point curPoint = Mouse.GetPosition(tagView as FrameworkElement); MapPoint tagPoint = tagView.ScreenToLocation(curPoint); _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; if (Polygonwinshowing) { _graphicsOverlay.Graphics.Remove(drawPolygonGraphic); } polygongraphictext = "Inputlabel"; Polygonpointcollec.Add(new MapPoint(tagPoint.X, tagPoint.Y, drawPolygonZ)); var Polygonsym = new SimpleFillSymbol(); PolygonColor = new SolidColorBrush((App.Current.Resources["drawtoolpoint"] as SphereMarkerSymbol).Color); Polygonsym.Color = PolygonColor.Color; drawPolygonGraphic = new Graphic(new Polygon(Polygonpointcollec), Polygonsym); _graphicsOverlay.Graphics.Add(drawPolygonGraphic); if (!Polygonwinshowing) { PolygonWin = new PolygonToolWin(); PolygonWin.Show(); Polygonwinshowing = true; } } }
private async void MouseRightButtonUp(object parameter) { Point curPoint = Mouse.GetPosition(tagView as FrameworkElement); MapPoint tagPoint = tagView.ScreenToLocation(curPoint); _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; var ga = await _graphicsOverlay.HitTestAsync(tagView, curPoint); if (ga != null) { if (ga.Geometry.GeometryType == GeometryType.Point) { drawPointGraphic = ga; drawpointX = (drawPointGraphic.Geometry as MapPoint).X; drawpointY = (drawPointGraphic.Geometry as MapPoint).Y; drawpointZ = (drawPointGraphic.Geometry as MapPoint).Z; if (pointwinshowing == false) { pointWin = new PointToolWin(); pointwinshowing = true; pointWin.ShowDialog(); } } if (ga.Geometry.GeometryType == GeometryType.Polyline) { drawLineGraphic = ga; linegraphictext = drawLineGraphic.Attributes["Label"] as string; linewidth = (drawLineGraphic.Symbol as SimpleLineSymbol).Width; Esri.ArcGISRuntime.Geometry.PointCollection tagcol = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (var part in (drawLineGraphic.Geometry as Polyline).Parts) { for (int i = 0; i < part.Count; i++) { var linepart = part.ElementAt(i); tagcol.Add(linepart.StartPoint); if (i == (part.Count - 1)) { tagcol.Add(linepart.EndPoint); } drawLineZ = linepart.StartPoint.Z; } } Linepointcollec = tagcol; if (linewinshowing == false) { LineWin = new LineToolWin(); linewinshowing = true; LineWin.ShowDialog(); } } if (ga.Geometry.GeometryType == GeometryType.Polygon) { drawPolygonGraphic = ga; polygongraphictext = drawPolygonGraphic.Attributes["Label"] as string; Esri.ArcGISRuntime.Geometry.PointCollection tagcol = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (var part in (drawPolygonGraphic.Geometry as Polygon).Parts) { for (int i = 0; i < part.Count; i++) { var Polygonpart = part.ElementAt(i); tagcol.Add(Polygonpart.StartPoint); if (i == (part.Count - 1)) { tagcol.Add(Polygonpart.EndPoint); } drawPolygonZ = Polygonpart.StartPoint.Z; } } Polygonpointcollec = tagcol; if (Polygonwinshowing == false) { PolygonWin = new PolygonToolWin(); Polygonwinshowing = true; PolygonWin.ShowDialog(); } } } }
public void CreateOpacity() { Color colorRed = Colors.Red; colorRed.A = 180; { var mapOL = new GraphicsOverlay(); mapOL.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; var listpc = new List <Esri.ArcGISRuntime.Geometry.PointCollection>(); var pc1 = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); pc1.Add(-5, -5, 10); pc1.Add(5, -5, 10); pc1.Add(5, 5, 10); pc1.Add(-5, 5, 10); listpc.Add(pc1); var pc2 = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); pc2.Add(-2, -2, 10); pc2.Add(2, -2, 10); pc2.Add(2, 2, 10); pc2.Add(-2, 2, 10); listpc.Add(pc2); var poly1 = new Polygon(listpc); var g1 = new Graphic(poly1, new SimpleFillSymbol() { Color = Colors.Red, Outline = new SimpleLineSymbol() { Color = Colors.Black, Width = 2, Style = SimpleLineSymbolStyle.Solid }, Style = SimpleFillSymbolStyle.Null }) { ZIndex = 2 }; mapOL.Graphics.Add(g1); var poly2 = new Polygon(listpc); var g2 = new Graphic(poly1, new SimpleFillSymbol() { Color = colorRed, Outline = new SimpleLineSymbol() { Color = Colors.Transparent, Width = 0, Style = SimpleLineSymbolStyle.Null }, Style = SimpleFillSymbolStyle.Solid }) { ZIndex = 1 }; mapOL.Graphics.Add(g2); _mapgraphicsOverlays.Clear(); _mapgraphicsOverlays.Add(mapOL); } { var sceneOL = new GraphicsOverlay(); sceneOL.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; sceneOL.RenderingMode = GraphicsRenderingMode.Static; var listpc = new List <Esri.ArcGISRuntime.Geometry.PointCollection>(); var pc1 = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); pc1.Add(-5, -5, 10); pc1.Add(5, -5, 10); pc1.Add(5, 5, 10); pc1.Add(-5, 5, 10); listpc.Add(pc1); var pc2 = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); pc2.Add(-2, -2, 10); pc2.Add(-2, 2, 10); pc2.Add(2, 2, 10); pc2.Add(2, -2, 10); listpc.Add(pc2); var poly1 = new Polygon(listpc); var g1 = new Graphic(poly1, new SimpleFillSymbol() { Color = Colors.Red, Outline = new SimpleLineSymbol() { Color = Colors.Black, Width = 2, Style = SimpleLineSymbolStyle.Solid }, Style = SimpleFillSymbolStyle.Null }) { ZIndex = 2 }; sceneOL.Graphics.Add(g1); var poly2 = new Polygon(listpc); var g2 = new Graphic(poly1, new SimpleFillSymbol() { Color = colorRed, Outline = new SimpleLineSymbol() { Color = Colors.Transparent, Width = 0, Style = SimpleLineSymbolStyle.Null }, Style = SimpleFillSymbolStyle.Solid }) { ZIndex = 1 }; sceneOL.Graphics.Add(g2); _scenegraphicsOverlays.Clear(); _scenegraphicsOverlays.Add(sceneOL); } OnPropertyChanged("MapGraphicsOverlays"); OnPropertyChanged("SceneGraphicsOverlays"); }
public void check() { XDocument doc = XDocument.Load(@"D:\EwLinear\Input\AVCS_Cateloge_wk45_new_modif.xml"); int ScalarVariableCount = doc.Root.Descendants("Products") .Elements("ENC").Count(); Console.WriteLine("count{0}", ScalarVariableCount); var polygonPoints1 = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); // var polygonPoints_list = new List<string, string>(); var labelPointBass = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); // IDictionary<string, Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84) > dict = new Dictionary<string, string>(); var query = from Polygon in doc.Root.Descendants("ENC") group Polygon by Polygon.Element("ShortName").Value into gr select gr; var shortname = doc.Root.Descendants("shortname"); var srt = shortname.ToString(); var reasons = doc.Descendants("Polygon").ToList(); //for (int i = 0; i < elemList.Count; i++) //{ // Console.WriteLine(elemList[i].InnerXml); //} // var textname = new List<string>(); var latitude = new List <string>(); var longitude = new List <string>(); var scale = new List <string>(); var usage = new List <string>(); var DatasetTitle = new List <string>(); Func <XElement, string, string, string> getAttributeValue = (xElement, name, text) => xElement.Element(name).Value; // Task<IEnumerable<IGrouping<string, XElement>>> query; // query = ConfigurationManager.AppSettings.Get(); // query = objMgr.GetAVCS(); foreach (var value in query) { List <XElement> str = new List <XElement>(); // textname.Add(value.Key); // textname.Add(value.Key); var q2 = value.Descendants("Polygon").SelectMany(array => array.Value.ToList()); value.Descendants("Polygon").ToList().ForEach(item => { str.Add(item); }); if (str.Count > 1) { foreach (var set1 in str) { set1.Descendants("Position").ToList().ForEach(item => { latitude.Add(item.Attribute("latitude").Value); longitude.Add(item.Attribute("longitude").Value); polygonPoints1.Add(new MapPoint(Convert.ToDouble(item.Attribute("longitude").Value), Convert.ToDouble(item.Attribute("latitude").Value))); }); var q5 = value.Descendants("Metadata").Select(s => new { ONE = s.Element("Scale").Value, TWO = s.Element("Usage").Value, THREE = s.Element("DatasetTitle").Value }).ToList(); string four = q5[0].THREE; string two = q5[0].TWO; usage.Add(four); CreateGraphic_Label(polygonPoints1, value.Key, two); polygonPoints1.Clear(); } } else { value.Descendants("Position").ToList().ForEach(item => { latitude.Add(item.Attribute("latitude").Value); longitude.Add(item.Attribute("longitude").Value); polygonPoints1.Add(new MapPoint(Convert.ToDouble(item.Attribute("longitude").Value), Convert.ToDouble(item.Attribute("latitude").Value))); }); var q1 = value.Descendants("Metadata").Select(s => new { ONE = s.Element("Scale").Value, TWO = s.Element("Usage").Value, THREE = s.Element("DatasetTitle").Value }).ToList(); string three = q1[0].THREE; string two = q1[0].TWO; string one = q1[0].ONE; usage.Add(three); CreateGraphic_Label(polygonPoints1, value.Key, two); } polygonPoints1.Clear(); //} } }
private async void MouseRightButtonUp(object parameter) { Point curPoint = Mouse.GetPosition(tagView as FrameworkElement); MapPoint tagPoint = tagView.ScreenToLocation(curPoint); _graphicsOverlay = tagView.GraphicsOverlays["drawGraphicsOverlay"]; var ga = await _graphicsOverlay.HitTestAsync(tagView, curPoint); if (ga != null) { if(ga.Geometry.GeometryType==GeometryType.Point) { drawPointGraphic = ga; drawpointX = (drawPointGraphic.Geometry as MapPoint).X; drawpointY = (drawPointGraphic.Geometry as MapPoint).Y; drawpointZ = (drawPointGraphic.Geometry as MapPoint).Z; if(pointwinshowing==false) { pointWin = new PointToolWin(); pointwinshowing = true; pointWin.ShowDialog(); } } if (ga.Geometry.GeometryType == GeometryType.Polyline) { drawLineGraphic = ga; linegraphictext = drawLineGraphic.Attributes["Label"] as string; linewidth = (drawLineGraphic.Symbol as SimpleLineSymbol).Width; Esri.ArcGISRuntime.Geometry.PointCollection tagcol = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (var part in (drawLineGraphic.Geometry as Polyline).Parts) { for(int i=0;i<part.Count;i++) { var linepart = part.ElementAt(i); tagcol.Add(linepart.StartPoint); if(i==(part.Count-1)) tagcol.Add(linepart.EndPoint); drawLineZ = linepart.StartPoint.Z; } } Linepointcollec = tagcol; if(linewinshowing==false) { LineWin = new LineToolWin(); linewinshowing = true; LineWin.ShowDialog(); } } if (ga.Geometry.GeometryType == GeometryType.Polygon) { drawPolygonGraphic = ga; polygongraphictext = drawPolygonGraphic.Attributes["Label"] as string; Esri.ArcGISRuntime.Geometry.PointCollection tagcol = new Esri.ArcGISRuntime.Geometry.PointCollection(); foreach (var part in (drawPolygonGraphic.Geometry as Polygon).Parts) { for (int i = 0; i < part.Count; i++) { var Polygonpart = part.ElementAt(i); tagcol.Add(Polygonpart.StartPoint); if (i == (part.Count - 1)) tagcol.Add(Polygonpart.EndPoint); drawPolygonZ = Polygonpart.StartPoint.Z; } } Polygonpointcollec = tagcol; if(Polygonwinshowing==false) { PolygonWin = new PolygonToolWin(); Polygonwinshowing = true; PolygonWin.ShowDialog(); } } } }
//=======敏感区===== public void Createarea(double lon, double lat, double radius) { // Create the graphics overlay. GraphicsOverlay overlay1 = new GraphicsOverlay(); GraphicsOverlay overlay2 = new GraphicsOverlay(); // Create a green simple line symbol SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.FromArgb(0xFF, 0x00, 0x50, 0x00), 1); // Create a green mesh simple fill symbol SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Cross, System.Drawing.Color.Yellow, outlineSymbol); Esri.ArcGISRuntime.Geometry.PointCollection boatPositions = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84); for (int i = 0; i < 36; i++) { double angle = (2 * Math.PI / 36) * i; // new MapPoint([lon + Math.sin(angle) * radius[0], lat[0] + Math.cos(angle) * radius[0]]); boatPositions.Add(new MapPoint(lon + Math.Sin(angle) * radius, lat + Math.Cos(angle) * radius)); } ; // Create the polyline from the point collection Esri.ArcGISRuntime.Geometry.Polygon polygon = new Esri.ArcGISRuntime.Geometry.Polygon(boatPositions); // Create the graphic with polyline and symbol Graphic graphic = new Graphic(polygon, fillSymbol); Graphic graphic1 = new Graphic(polygon, fillSymbol); // Add graphic to the graphics overlay overlay1.Graphics.Add(graphic); overlay2.Graphics.Add(graphic1); //MessageBox.Show(lon + " "+ lat + "添加成功"); // Show the graphics overlay in the scene. MyMapView.GraphicsOverlays.Add(overlay1); MySceneView.GraphicsOverlays.Add(overlay2); int de = -1; int mi = -1; if (Dector2D.Count > 0) { int count = Dector2D.Count; for (int i = 0; i < count; i++) { List <MapPoint> _artificialMapPoints = new List <MapPoint>(); _artificialMapPoints = MapPointslist[i]; int index = Global.DectorIndexIdlist[i]; for (int j = index; j < index + 120; j++) { MapPoint selectedMapPoint = _artificialMapPoints[j % _artificialMapPoints.Count]; double di = Distance(selectedMapPoint.X, selectedMapPoint.Y, selectedMapPoint.Z, lon, lat, 0); if (di < radius * 100000) { de = i; mi = j - index; break; } } // } if (mi != -1) { break; } } //double d = Distance(lon, lat, 0, lon1, lat1, radius1); StackPanel s = new StackPanel(); Label l1 = new Label(); Label l2 = new Label(); Label l3 = new Label(); s.Children.Add(l1); s.Children.Add(l2); s.Children.Add(l3); l1.Content = "longitude :" + lon; l2.Content = "latitude : " + lat; if (de != -1) { l3.Content = "探空仪 " + Global.DectorNamelist[de] + " 将在" + mi + "分钟后到达敏感区"; } else { /* * * string[] strArr = new string[3]; * string sArguments = @"station.py"; //调用的python的文件名字 * strArr[0] = lon.ToString(); * strArr[1] = lat.ToString(); * strArr[2] = (radius*111).ToString(); * RunPythonScript(sArguments, "-u", strArr); */ //int counter = 0; //string line; string result = "Please wait"; string[] lines = System.IO.File.ReadAllLines(@"E:\\VSProjects\\test\\data.txt", Encoding.GetEncoding("gb2312")); //System.Console.WriteLine("Contents of WriteLines2.txt = "); foreach (string line in lines) { result = line; } // System.IO.StreamReader file = new System.IO.StreamReader(@"E:\\VSProjects\\test\\data.txt"); // while ((line = file.ReadLine()) != null) //{ //System.Console.WriteLine(line); // counter++; // } /// MessageBox.Show( result); // file.Close(); l3.Content = result; } MyMapView.ShowCalloutAt(new MapPoint(lon, lat, SpatialReferences.Wgs84), s); } else { //double d = Distance(lon, lat, 0, lon1, lat1, radius1); StackPanel s = new StackPanel(); Label l1 = new Label(); Label l2 = new Label(); Label l3 = new Label(); s.Children.Add(l1); s.Children.Add(l2); s.Children.Add(l3); l1.Content = "longitude :" + lon; l2.Content = "latitude : " + lat; // l3.Content = ""; /* * string[] strArr = new string[3]; * string sArguments = @"station.py"; //调用的python的文件名字 * strArr[0] = lon.ToString(); * strArr[1] = lat.ToString(); * strArr[2] = (radius * 111).ToString(); * RunPythonScript(sArguments, "-u", strArr); */ string result = "Please wait"; string[] lines = System.IO.File.ReadAllLines(@"E:\\VSProjects\\test\\data.txt", Encoding.GetEncoding("gb2312")); //System.Console.WriteLine("Contents of WriteLines2.txt = "); foreach (string line in lines) { result = line; } // System.IO.StreamReader file = new System.IO.StreamReader(@"E:\\VSProjects\\test\\data.txt"); // while ((line = file.ReadLine()) != null) //{ //System.Console.WriteLine(line); // counter++; // } // MessageBox.Show("c" + result); // file.Close(); l3.Content = "可选放球站:" + result; // string text = System.IO.File.ReadAllText(@"E:\\VSProjects\\test\\data.txt"); MyMapView.ShowCalloutAt(new MapPoint(lon, lat, SpatialReferences.Wgs84), s); } // MyMapView.ShowCalloutAt(new MapPoint(lon, lat, SpatialReferences.Wgs84), s); }
public static Graphic NewLine(MapPoint p1, MapPoint p2) { Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); return NewPolyline(pc); }
public static Graphic NewPentagon(MapPoint p1, MapPoint p2, MapPoint p3, MapPoint p4, MapPoint p5) { Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection(); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); pc.Add(p5); //pc.Add(p1); return NewPolygon(pc); }
// myMapView 事件 private async void MyMapView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { IInputElement ie = (IInputElement)(sender); MapPoint loc = myMapView.ScreenToLocation(e.GetPosition(ie)); switch (operation) { case OperateType.DrawPoint: //画点 Graphic pt = new Graphic(loc, pointSymbol); graphicsLayer.Graphics.Add(pt); break; case OperateType.DrawPolyline: //画线 pointCollection.Add(loc); if (pointCollection.Count >= 2) { if (pointCollection.Count > 2) { Graphic g = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1]; PolylineBuilder lb = new PolylineBuilder(pointCollection); g.Geometry = lb.ToGeometry(); } else { Esri.ArcGISRuntime.Geometry.Polyline l = new Esri.ArcGISRuntime.Geometry.Polyline(pointCollection); Graphic lg = new Graphic(l, lineSymbol); graphicsLayer.Graphics.Add(lg); } } break; case OperateType.DrawPolygon: //画多边形 pointCollection.Add(loc); if (pointCollection.Count >= 3) { if (pointCollection.Count > 3) { Graphic g = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1]; PolygonBuilder pb = new PolygonBuilder(pointCollection); g.Geometry = pb.ToGeometry(); } else { Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection); Graphic pg = new Graphic(p, fillSymbol); graphicsLayer.Graphics.Add(pg); } } break; case OperateType.None: //缺省状态 graphicsLayer.ClearSelection(); IdentifyGraphicsOverlayResult result = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); //选择图形元素 if (result.Graphics.Count < 1) { curSelGraphic = null; EditVertexMenuItem.IsEnabled = false; UneditVertexMenuItem.IsEnabled = false; return; } curSelGraphic = result.Graphics.First(); curSelGraphic.IsSelected = true; EditVertexMenuItem.IsEnabled = true; break; } }
// Creates a square polygon with a hole centered at the given point private Polygon CreatePolygonBox(MapPoint center, double length) { var halfLen = length / 2.0; Geometry.PointCollection coords = new Geometry.PointCollection(); coords.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); coords.Add(new MapPoint(center.X + halfLen, center.Y + halfLen)); coords.Add(new MapPoint(center.X + halfLen, center.Y - halfLen)); coords.Add(new MapPoint(center.X - halfLen, center.Y - halfLen)); coords.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); halfLen /= 3; Geometry.PointCollection coordsHole = new Geometry.PointCollection(); coordsHole.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); coordsHole.Add(new MapPoint(center.X - halfLen, center.Y - halfLen)); coordsHole.Add(new MapPoint(center.X + halfLen, center.Y - halfLen)); coordsHole.Add(new MapPoint(center.X + halfLen, center.Y + halfLen)); coordsHole.Add(new MapPoint(center.X - halfLen, center.Y + halfLen)); return new Polygon(new List<Geometry.PointCollection> { coords, coordsHole }, MyMapView.SpatialReference); }
// myMapView 事件 private async void MyMapView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { IInputElement ie = (IInputElement)(sender); MapPoint loc = myMapView.ScreenToLocation(e.GetPosition(ie)); switch (operation) { case OperateType.DrawPoint: //画点 Graphic pt = new Graphic(loc, pointSymbol); graphicsLayer.Graphics.Add(pt); break; case OperateType.DrawPolyline: //画线 pointCollection.Add(loc); if (pointCollection.Count >= 2) { if (pointCollection.Count > 2) { Graphic g = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1]; PolylineBuilder lb = new PolylineBuilder(pointCollection); g.Geometry = lb.ToGeometry(); } else { Esri.ArcGISRuntime.Geometry.Polyline l = new Esri.ArcGISRuntime.Geometry.Polyline(pointCollection); Graphic lg = new Graphic(l, lineSymbol); graphicsLayer.Graphics.Add(lg); } } break; case OperateType.DrawPolygon: //画多边形 pointCollection.Add(loc); if (pointCollection.Count >= 3) { if (pointCollection.Count > 3) { Graphic g = graphicsLayer.Graphics[graphicsLayer.Graphics.Count - 1]; PolygonBuilder pb = new PolygonBuilder(pointCollection); g.Geometry = pb.ToGeometry(); } else { Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection); Graphic pg = new Graphic(p, fillSymbol); graphicsLayer.Graphics.Add(pg); } } break; case OperateType.None: //缺省状态 graphicsLayer.ClearSelection(); IdentifyGraphicsOverlayResult result = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); //选择图形元素 if (result.Graphics.Count < 1) { curSelGraphic = null; EditVertexMenuItem.IsEnabled = false; UneditVertexMenuItem.IsEnabled = false; return; } curSelGraphic = result.Graphics.First(); curSelGraphic.IsSelected = true; EditVertexMenuItem.IsEnabled = true; break; case OperateType.Cal_Clip: //选择图形 IdentifyGraphicsOverlayResult gResult = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); if (gResult.Graphics.Count < 1) { return; } Graphic selGraphic = gResult.Graphics.First(); selGraphic.IsSelected = true; listOfClipGraphics.Add(selGraphic); //记录所选图形 if (listOfClipGraphics.Count == 2) //图形数目为2时,进行剪切计算 { Graphic g1 = listOfClipGraphics[0]; Graphic g2 = listOfClipGraphics[1]; if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon) //如果所选图形不是多边形,则退出 { MessageBox.Show("请选择两个多边形图形!"); listOfClipGraphics.Clear(); graphicsLayer.ClearSelection(); return; } Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Clip(g1.Geometry, g2.Geometry.Extent); //执行剪切操作 if (resultGeometry != null) //处理结果 { graphicsLayer.Graphics.Remove(g1); //从图形层中移除原图形 graphicsLayer.Graphics.Remove(g2); Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol); //利 用剪切结果构建新的图形 graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None; } listOfClipGraphics.Clear(); //清空图形选择集合 graphicsLayer.ClearSelection(); //清空图形层所选 } break; case OperateType.Cal_Union: // 联合 IdentifyGraphicsOverlayResult gResultUnion = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); if (gResultUnion.Graphics.Count < 1) { return; } Graphic selGraphicUnion = gResultUnion.Graphics.First(); selGraphicUnion.IsSelected = true; listOfClipGraphics.Add(selGraphicUnion); //记录所选图形 if (listOfClipGraphics.Count == 2) //图形数目为2时,进行剪切计算 { Graphic g1 = listOfClipGraphics[0]; Graphic g2 = listOfClipGraphics[1]; if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polygon) //如果所选图形不是多边形,则退出 { MessageBox.Show("请选择两个多边形图形!"); listOfClipGraphics.Clear(); graphicsLayer.ClearSelection(); return; } Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Union(g1.Geometry, g2.Geometry.Extent); //执行剪切操作 if (resultGeometry != null) //处理结果 { graphicsLayer.Graphics.Remove(g1); //从图形层中移除原图形 graphicsLayer.Graphics.Remove(g2); Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol); //利 用剪切结果构建新的图形 graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None; } listOfClipGraphics.Clear(); //清空图形选择集合 graphicsLayer.ClearSelection(); //清空图形层所选 } break; case OperateType.Cal_Cut: // 剪切 IdentifyGraphicsOverlayResult gResult_Cut = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); if (gResult_Cut.Graphics.Count < 1) { return; } Graphic selGraphic_Cut = gResult_Cut.Graphics.First(); selGraphic_Cut.IsSelected = true; listOfClipGraphics.Add(selGraphic_Cut); //记录所选图形 if (listOfClipGraphics.Count == 2) //图形数目为1时,进行剪切计算 { Graphic g1 = listOfClipGraphics[0]; Graphic g2 = listOfClipGraphics[1]; if (g1.Geometry.GeometryType != GeometryType.Polygon || g2.Geometry.GeometryType != GeometryType.Polyline) //如果所选图形不是多边形,则退出 { MessageBox.Show("请先选择一个面要素后再选择一个线要素."); listOfClipGraphics.Clear(); graphicsLayer.ClearSelection(); return; } Esri.ArcGISRuntime.Geometry.Polyline polyLine = (Esri.ArcGISRuntime.Geometry.Polyline)g2.Geometry; Esri.ArcGISRuntime.Geometry.Geometry[] resultGeometry = GeometryEngine.Cut(g1.Geometry, polyLine); //执行剪切操作 if (resultGeometry != null) //处理结果 { graphicsLayer.Graphics.Remove(g1); for (int z = 0; z < resultGeometry.Length; z++) { Graphic clipedGraphic = new Graphic(resultGeometry[z], fillSymbol); //利 用剪切结果构建新的图形 graphicsLayer.Graphics.Add(clipedGraphic); } operation = OperateType.None; } listOfClipGraphics.Clear(); //清空图形选择集合 graphicsLayer.ClearSelection(); //清空图形层所选 } break; case OperateType.Cal_Simplify: // 拓扑纠正 IdentifyGraphicsOverlayResult gResult_Simplify = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); if (gResult_Simplify.Graphics.Count < 1) { return; } Graphic selGraphic_Simplify = gResult_Simplify.Graphics.First(); selGraphic_Simplify.IsSelected = true; listOfClipGraphics.Add(selGraphic_Simplify); //记录所选图形 if (listOfClipGraphics.Count == 1) //图形数目为1时,进行剪切计算 { Graphic g1 = listOfClipGraphics[0]; if (g1.Geometry.GeometryType == GeometryType.Point) //如果所选图形不是多边形,则退出 { MessageBox.Show("请先选择一个面要素或线要素."); listOfClipGraphics.Clear(); graphicsLayer.ClearSelection(); return; } Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Simplify(g1.Geometry); //执行剪切操作 if (resultGeometry != null) //处理结果 { graphicsLayer.Graphics.Remove(g1); //从图形层中移除原图形 Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol); //利 用剪切结果构建新的图形 graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None; } listOfClipGraphics.Clear(); //清空图形选择集合 graphicsLayer.ClearSelection(); //清空图形层所选 } break; case OperateType.Cal_Gene: // 简化 IdentifyGraphicsOverlayResult gResult_Gene = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); if (gResult_Gene.Graphics.Count < 1) { return; } Graphic selGraphic_Gene = gResult_Gene.Graphics.First(); selGraphic_Gene.IsSelected = true; listOfClipGraphics.Add(selGraphic_Gene); //记录所选图形 if (listOfClipGraphics.Count == 1) //图形数目为1时 { Graphic g1 = listOfClipGraphics[0]; if (g1.Geometry.GeometryType == GeometryType.Point) //如果所选图形是点,则退出 { MessageBox.Show("请先选择一个面要素或线要素."); listOfClipGraphics.Clear(); graphicsLayer.ClearSelection(); return; } Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Generalize(g1.Geometry, 1000000.0, true); //执行剪切操作 if (resultGeometry != null) //处理结果 { MessageBox.Show(resultGeometry.ToJson() + "\n" + resultGeometry.GeometryType); graphicsLayer.Graphics.Remove(g1); //从图形层中移除原图形 Graphic clipedGraphic = new Graphic(resultGeometry, fillSymbol); //利 用剪切结果构建新的图形 graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None; } listOfClipGraphics.Clear(); //清空图形选择集合 graphicsLayer.ClearSelection(); //清空图形层所选 } break; case OperateType.Cal_Buff: // 缓冲 IdentifyGraphicsOverlayResult gResult_Buff = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); if (gResult_Buff.Graphics.Count < 1) { return; } Graphic selGraphic_Buff = gResult_Buff.Graphics.First(); selGraphic_Buff.IsSelected = true; listOfClipGraphics.Add(selGraphic_Buff); //记录所选图形 if (listOfClipGraphics.Count == 1) //图形数目为1时,进行剪切计算 { Graphic g1 = listOfClipGraphics[0]; Esri.ArcGISRuntime.Geometry.Geometry resultGeometry = GeometryEngine.Buffer(g1.Geometry, 1000000.0); //执行剪切操作 if (resultGeometry != null) //处理结果 { graphicsLayer.Graphics.Remove(g1); //从图形层中移除原图形 Graphic clipedGraphic = new Graphic(resultGeometry, new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.FromArgb(125, 255, 250, 0), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(0, 0, 0), 4.0))); //利 用剪切结果构建新的图形 graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None; } listOfClipGraphics.Clear(); //清空图形选择集合 graphicsLayer.ClearSelection(); //清空图形层所选 } break; case OperateType.Cal_Jiaodian: // 交点 IdentifyGraphicsOverlayResult gResult_Jiaodian = await myMapView.IdentifyGraphicsOverlayAsync(graphicsLayer, e.GetPosition(ie), 5, false); if (gResult_Jiaodian.Graphics.Count < 1) { return; } Graphic selGraphic_Jiaodian = gResult_Jiaodian.Graphics.First(); selGraphic_Jiaodian.IsSelected = true; listOfClipGraphics.Add(selGraphic_Jiaodian); //记录所选图形 if (listOfClipGraphics.Count == 2) //图形数目为1时,进行剪切计算 { Graphic g1 = listOfClipGraphics[0]; Graphic g2 = listOfClipGraphics[1]; IReadOnlyList <Geometry> resultGeometry = GeometryEngine.Intersections(g1.Geometry, g2.Geometry); //执行剪切操作 if (resultGeometry != null) //处理结果 { Graphic clipedGraphic = new Graphic(resultGeometry[0], pointSymbol); //利 用剪切结果构建新的图形 graphicsLayer.Graphics.Add(clipedGraphic); operation = OperateType.None; } listOfClipGraphics.Clear(); //清空图形选择集合 graphicsLayer.ClearSelection(); //清空图形层所选 } break; } }