private void UpdateManualFeedback() { if (LineFromType == LineFromTypes.BearingAndDistance && Azimuth.HasValue && HasPoint1 && Point1 != null) { // update feedback var segment = QueuedTask.Run(() => { var mpList = new List <MapPoint>() { Point1 }; // get point 2 var results = GeometryEngine.GeodesicMove(mpList, MapView.Active.Map.SpatialReference, Distance, GetLinearUnit(LineDistanceType), GetAzimuthAsRadians().Value); foreach (var mp in results) { Point2 = mp; } if (Point2 != null) { return(LineBuilder.CreateLineSegment(Point1, Point2)); } else { return(null); } }).Result; if (segment != null) { UpdateFeedbackWithGeoLine(segment); } } }
// Move the polygon the specified distance and angle private void GeodesicMoveButton_Click(object sender, RoutedEventArgs e) { try { if (_originalGraphics.Graphics.Count == 0) { throw new Exception("Digitize a polygon to move."); } var coords = _originalGraphics.Graphics[0].Geometry as IEnumerable <CoordinateCollection>; if (coords == null) { throw new Exception("Digitize a polygon to move."); } var points = coords.First().Select(c => new MapPoint(c, mapView.SpatialReference)); var distance = (double)comboDistance.SelectedItem; var azimuth = (double)sliderAngle.Value; var movedPoints = GeometryEngine.GeodesicMove(points, distance, LinearUnits.Miles, azimuth); Polygon movedPoly = new Polygon(movedPoints.Select(p => p.Coordinate), mapView.SpatialReference); _movedGraphics.Graphics.Clear(); _movedGraphics.Graphics.Add(new Graphic(movedPoly)); } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } }
// Move the polygon the specified distance and angle private void GeodesicMoveButton_Click(object sender, RoutedEventArgs e) { try { if (_originalOverlay.Graphics.Count == 0) { throw new Exception("Digitize a polygon to move."); } var coords = _originalOverlay.Graphics[0].Geometry as Multipart; if (coords == null) { throw new Exception("Digitize a polygon to move."); } var points = coords.Parts.First().GetPoints(); var distance = (double)comboDistance.SelectedItem; var azimuth = (double)sliderAngle.Value; var movedPoints = GeometryEngine.GeodesicMove(points, distance, LinearUnits.Miles, azimuth); Polygon movedPoly = new PolygonBuilder(movedPoints, MyMapView.SpatialReference).ToGeometry(); _movedOverlay.Graphics.Clear(); _movedOverlay.Graphics.Add(new Graphic(movedPoly)); } catch (Exception ex) { var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } }
/// <summary> /// Method to draw the radials inside the range rings /// Must have at least 1 radial /// All radials are drawn from the center point to the farthest ring /// </summary> private void DrawRadials() { // must have at least 1 if (NumberOfRadials < 1) { return; } double azimuth = 0.0; double interval = 360.0 / NumberOfRadials; double radialLength = 0.0; if (IsInteractive) { radialLength = maxDistance; } else { radialLength = Distance * NumberOfRings; } try { // for each radial, draw from center point for (int x = 0; x < NumberOfRadials; x++) { var polyline = QueuedTask.Run(() => { MapPoint movedMP = null; var mpList = new List <MapPoint>() { Point1 }; // get point 2 var results = GeometryEngine.GeodesicMove(mpList, MapView.Active.Map.SpatialReference, radialLength, GetLinearUnit(LineDistanceType), GetAzimuthAsRadians(azimuth)); // update feedback //UpdateFeedback(); foreach (var mp in results) { movedMP = mp; } if (movedMP != null) { var segment = LineBuilder.CreateLineSegment(Point1, movedMP); return(PolylineBuilder.CreatePolyline(segment)); } else { return(null); } }).Result; if (polyline != null) { AddGraphicToMap(polyline); } azimuth += interval; } } catch (Exception ex) { Console.WriteLine(ex); } }