private async void UpdateManualFeedback() { if (LineFromType == LineFromTypes.BearingAndDistance && Azimuth.HasValue && HasPoint1 && Point1 != null) { GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); // update feedback var segment = QueuedTask.Run(() => { var mpList = new List <MapPoint>() { Point1 }; // get point 2 // SDK Bug, GeometryEngine.GeodesicMove seems to not honor the LinearUnit passed in, always does Meters var tempDistance = ConvertFromTo(LineDistanceType, DistanceTypes.Meters, Distance); var results = GeometryEngine.Instance.GeodeticMove(mpList, MapView.Active.Map.SpatialReference, tempDistance, LinearUnit.Meters /*GetLinearUnit(LineDistanceType)*/, GetAzimuthAsRadians().Value, GetCurveType()); foreach (var mp in results) { // WORKAROUND: For some odd reason GeodeticMove is removing the Z attribute of the point // so need to put it back so all points will have a consistent Z. // This is important when storing to feature class with Z if (mp == null) { continue; } if (Double.IsNaN(mp.Z)) { MapPointBuilder mb = new MapPointBuilder(mp.X, mp.Y, 0.0, mp.SpatialReference); Point2 = mb.ToGeometry(); } else { Point2 = mp; } } if (Point2 != null) { var point2Proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference); return(LineBuilder.CreateLineSegment(Point1, (MapPoint)point2Proj)); } else { return(null); } }).Result; if (segment != null) { await UpdateFeedbackWithGeoLine(segment, curveType, lu); } } else { ClearTempGraphics(); // if not, or no longer, valid clear } }
private Geometry CreatePolyline() { if (Point1 == null || Point2 == null) { return(null); } var nameConverter = new EnumToFriendlyNameConverter(); GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); try { // create line var polyline = QueuedTask.Run(() => { var point2Proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference); var segment = LineBuilder.CreateLineSegment(Point1, (MapPoint)point2Proj); return(PolylineBuilder.CreatePolyline(segment)); }).Result; Geometry newline = GeometryEngine.Instance.GeodeticDensifyByLength(polyline, 0, lu, curveType); var displayValue = nameConverter.Convert(LineDistanceType, typeof(string), new object(), CultureInfo.CurrentCulture); // Hold onto the attributes in case user saves graphics to file later LineAttributes lineAttributes = new LineAttributes() { mapPoint1 = Point1, mapPoint2 = Point2, distance = distance, angle = (double)azimuth, angleunit = LineAzimuthType.ToString(), distanceunit = displayValue.ToString(), originx = Point1.X, originy = Point1.Y, destinationx = Point2.X, destinationy = Point2.Y }; CreateLineFeature(newline, lineAttributes); ResetPoints(); return((Geometry)newline); } catch (Exception ex) { // do nothing System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }
internal override async void OnMouseMoveEvent(object obj) { GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); if (!IsActiveTab) { return; } var point = obj as MapPoint; if (point == null) { return; } if (LineFromType == LineFromTypes.BearingAndDistance) { return; } if (HasPoint1 && !HasPoint2) { // update azimuth from segment var segment = QueuedTask.Run(() => { try { var pointProj = GeometryEngine.Instance.Project(point, Point1.SpatialReference); return(LineBuilder.CreateLineSegment(Point1, (MapPoint)pointProj)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }).Result; if (segment == null) { return; } UpdateAzimuth(segment.Angle); await UpdateFeedbackWithGeoLine(segment, curveType, lu); } base.OnMouseMoveEvent(obj); }
internal async Task UpdateFeedbackWithGeoLine(LineSegment segment, GeodeticCurveType type, LinearUnit lu) { if (Point1 == null || segment == null) { return; } var polyline = await QueuedTask.Run(() => { return(PolylineBuilder.CreatePolyline(segment)); }); ClearTempGraphics(); Geometry newline = GeometryEngine.Instance.GeodeticDensifyByLength(polyline, 0, lu, type); await AddGraphicToMap(Point1, ColorFactory.Instance.GreenRGB, null, true, 5.0); await AddGraphicToMap(newline, ColorFactory.Instance.GreyRGB, null, true); }
public GeodeticCurveType DeriveCurveType(LineTypes type) { GeodeticCurveType curveType = GeodeticCurveType.Geodesic; if (type == LineTypes.Geodesic) { curveType = GeodeticCurveType.Geodesic; } else if (type == LineTypes.GreatElliptic) { curveType = GeodeticCurveType.GreatElliptic; } else if (type == LineTypes.Loxodrome) { curveType = GeodeticCurveType.Loxodrome; } return(curveType); }
private async void UpdateManualFeedback() { if (LineFromType == LineFromTypes.BearingAndDistance && Azimuth.HasValue && HasPoint1 && Point1 != null) { GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); // update feedback var segment = QueuedTask.Run(() => { var mpList = new List <MapPoint>() { Point1 }; // get point 2 // SDK Bug, GeometryEngine.GeodesicMove seems to not honor the LinearUnit passed in, always does Meters var tempDistance = ConvertFromTo(LineDistanceType, DistanceTypes.Meters, Distance); var results = GeometryEngine.Instance.GeodeticMove(mpList, MapView.Active.Map.SpatialReference, tempDistance, LinearUnit.Meters /*GetLinearUnit(LineDistanceType)*/, GetAzimuthAsRadians().Value, GetCurveType()); foreach (var mp in results) { Point2 = mp; } if (Point2 != null) { var point2Proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference); return(LineBuilder.CreateLineSegment(Point1, (MapPoint)point2Proj)); } else { return(null); } }).Result; if (segment != null) { await UpdateFeedbackWithGeoLine(segment, curveType, lu); } } else { ClearTempGraphics(); // if not, or no longer, valid clear } }
internal override async void UpdateFeedback() { GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); if (LineFromType == LineFromTypes.Points) { if (Point1 == null || Point2 == null) { return; } var segment = QueuedTask.Run(() => { try { var point2proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference); return(LineBuilder.CreateLineSegment(Point1, (MapPoint)point2proj)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }).Result; if (segment == null) { return; } UpdateAzimuth(segment.Angle); await UpdateFeedbackWithGeoLine(segment, curveType, lu); } else { UpdateManualFeedback(); } }
private Geometry CreatePolyline() { if (Point1 == null || Point2 == null) { return(null); } GeodeticCurveType curveType = DeriveCurveType(LineType); LinearUnit lu = DeriveUnit(LineDistanceType); try { // create line var polyline = QueuedTask.Run(() => { var point2Proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference); var segment = LineBuilder.CreateLineSegment(Point1, (MapPoint)point2Proj); return(PolylineBuilder.CreatePolyline(segment)); }).Result; Geometry newline = GeometryEngine.Instance.GeodeticDensifyByLength(polyline, 0, lu, curveType); // Hold onto the attributes in case user saves graphics to file later LineAttributes lineAttributes = new LineAttributes() { mapPoint1 = Point1, mapPoint2 = Point2, _distance = distance, angle = (double)azimuth, angleunit = LineAzimuthType.ToString(), distanceunit = LineDistanceType.ToString(), originx = Point1.X, originy = Point1.Y, destinationx = Point2.X, destinationy = Point2.Y }; AddGraphicToMap(newline, (ProGraphicAttributes)lineAttributes); ResetPoints(); return(newline as Geometry); } catch (Exception ex) { // do nothing return(null); } }