private void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs geoViewInputEventArgs) { // Get the tapped point, projected to WGS84. MapPoint destination = (MapPoint)GeometryEngine.Project(geoViewInputEventArgs.Location, SpatialReferences.Wgs84); // Update the destination graphic. _endLocationGraphic.Geometry = destination; // Get the points that define the route polyline. PointCollection polylinePoints = new PointCollection(SpatialReferences.Wgs84) { (MapPoint)_startLocationGraphic.Geometry, destination }; // Create the polyline for the two points. Polyline routeLine = new Polyline(polylinePoints); // Densify the polyline to show the geodesic curve. Geometry pathGeometry = GeometryEngine.DensifyGeodetic(routeLine, 1, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); // Apply the curved line to the path graphic. _pathGraphic.Geometry = pathGeometry; // Calculate and show the distance. double distance = GeometryEngine.LengthGeodetic(pathGeometry, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); _distanceLabel.Text = $"{(int) distance} kilometers"; }
private void MyMapViewOnGeoViewTapped_Line(object sender, GeoViewInputEventArgs geoViewInputEventArgs) { // Get the tapped point, projected to WGS84. MapPoint destination = (MapPoint)GeometryEngine.Project(geoViewInputEventArgs.Location, SpatialReferences.Wgs84); mapPoints.Add(destination); int len = mapPoints.Count(); Esri.ArcGISRuntime.Geometry.PointCollection polylinePoints; Esri.ArcGISRuntime.Geometry.Geometry pathGeometry; Esri.ArcGISRuntime.Geometry.Polyline routeLine; if (len > 1) { polylinePoints = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84) { mapPoints[len - 2], destination }; routeLine = new Esri.ArcGISRuntime.Geometry.Polyline(polylinePoints); pathGeometry = GeometryEngine.DensifyGeodetic(routeLine, 1, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); // 这是测地线的长度 //double distance = GeometryEngine.LengthGeodetic(pathGeometry, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); double distance = GeometryEngine.Length(pathGeometry); //double distance = GeometryEngine.Length(routeLine); lengthList.Add(distance); myMeasureResult.Text += "\n" + distance + " (地图默认长度单位)"; } }
public FakeLocationProvider(Polyline route) { // Densify the route polyline. Polyline densifiedRoute = (Polyline)GeometryEngine.DensifyGeodetic(route, 25.0, LinearUnits.Meters); // Get all of the points from the densified polyline. _gpsPoints = new List <MapPoint>(densifiedRoute.Parts[0].Points); // Create a timer for updating the location. _driveTimer = new Timer(_timerValue) { Enabled = false }; _driveTimer.Elapsed += TimerElapsed; }
public void PlotButton_Click(object sender, RoutedEventArgs e) { azimuthPoint = double.Parse(textAzimuth.Text); distancePoint = double.Parse(textDistance.Text); //distanceList.Add(distancePoint); if (azimuthPoint <= 360) { if (azimuthPoint <= 180) { var result = azimuthPoint; //azimuthList.Add(result); //TraverseData.AzimuthList.Add(result); //azimuthList.Add(result); } if (azimuthPoint > 180) { var result = 180 - (azimuthPoint); //azimuthList.Add(result); //TraverseData.AzimuthList.Add(result); //azimuthList.Add(result); } textAzimuth.Text = ""; textDistance.Text = ""; } double result1; double result2; //GeodeticDistanceResult distance = GeometryEngine.DistanceGeodetic(start, destination, LinearUnits.Meters, AngularUnits.Degrees, GeodeticCurveType.NormalSection); IReadOnlyList <MapPoint> coordinateList = GeometryEngine.MoveGeodetic(mapPoints, distancePoint, LinearUnits.Meters, azimuthPoint, AngularUnits.Degrees, GeodeticCurveType.NormalSection); GeodeticDistanceResult travel = GeometryEngine.DistanceGeodetic(start, coordinateList[0], LinearUnits.Meters, AngularUnits.Degrees, GeodeticCurveType.NormalSection); graphic1.Geometry = coordinateList[0]; if (travel.Azimuth1 >= 0) { result1 = travel.Azimuth1; } else { result1 = travel.Azimuth1 + 360; } if (travel.Azimuth2 >= 0) { result2 = travel.Azimuth2; } else { result2 = travel.Azimuth2 + 360; } textBox.Text = string.Format($"Distance:{travel.Distance} | Azimuth1:{result1} | Azimuth2:{result2} |Initial Point :410175.775805, 552181.881083"); //textBox.Text = string.Format("{0} kilometers", (int)distance); // Get the points that define the route polyline. Esri.ArcGISRuntime.Geometry.PointCollection polylinePoints = new Esri.ArcGISRuntime.Geometry.PointCollection(new SpatialReference(3168)) { (MapPoint)_startLocationGraphic.Geometry, coordinateList[0] }; // Create the polyline for the two points. Polyline routeLine = new Polyline(polylinePoints); // Densify the polyline to show the geodesic curve. Esri.ArcGISRuntime.Geometry.Geometry pathGeometry = GeometryEngine.DensifyGeodetic(routeLine, 1, LinearUnits.Kilometers, GeodeticCurveType.Geodesic); // Apply the curved line to the path graphic. _pathGraphic.Geometry = pathGeometry; }
/// <summary> /// Checks the distance. /// </summary> private void CheckDistance() { SimpleMarkerSceneSymbol sphereSymbol = new SimpleMarkerSceneSymbol { Style = SimpleMarkerSceneSymbolStyle.Sphere, Color = Color.Red, Height = 1000, Width = 100, Depth = 100, AnchorPosition = SceneSymbolAnchorPosition.Center }; MapPoint p1 = new MapPoint(9.386941, 47.666557, SpatialReferences.Wgs84); MapPoint p2 = new MapPoint(9.172648, 47.666100, SpatialReferences.Wgs84); GraphicsOverlay symbolsOverlay = new GraphicsOverlay { Opacity = 0.5 }; symbolsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; symbolsOverlay.Graphics.Add(new Graphic(p1, sphereSymbol)); symbolsOverlay.Graphics.Add(new Graphic(p2, sphereSymbol)); Polyline p = new Polyline(new[] { p1, p2 }); symbolsOverlay.Graphics.Add(new Graphic(p, new SimpleLineSymbol { AntiAlias = true, Style = SimpleLineSymbolStyle.DashDot, Width = 4, Color = Color.Red })); //double dDistance = GeometryEngine.Distance( p1, p2 ); var result = GeometryEngine.DistanceGeodetic(p1, p2, LinearUnits.Meters, AngularUnits.Degrees, GeodeticCurveType.Geodesic); uint iPositionDistanceMeter = 500; Geometry g = GeometryEngine.DensifyGeodetic(p, iPositionDistanceMeter, LinearUnits.Meters); SimpleMarkerSymbol marker = new SimpleMarkerSymbol { Style = SimpleMarkerSymbolStyle.Circle, Color = Color.Yellow, Size = 20 }; foreach (LineSegment x in (g as Polyline).Parts[0]) { symbolsOverlay.Graphics.Add(new Graphic(x.StartPoint, marker)); } this.SceneView.GraphicsOverlays.Add(symbolsOverlay); //----------------------------------------------------------------- //this.SceneView.SetViewpointAsync( new Viewpoint( p1, 100000 ) ); }