/// <summary> /// Add a polyline to the map layer. /// </summary> /// <param name="lc"> /// The collection of map locations making up the polyline. /// </param> /// <param name="br"> /// The brush with which to render the polyline. /// </param> public void AddPolyline(ILocationCollection lc, Brush br) { if (this.map == null) { return; } var bg = new List <BasicGeoposition>(); foreach (var loc in lc) { this.UpdateLocationRectangle(loc.Longitude, loc.Latitude); bg.Add(LocationToGeoposition(loc)); } if (br is SolidColorBrush scb) { var mp = new MapPolyline { Path = new Geopath(bg), StrokeColor = scb.Color, StrokeThickness = 1.0, StrokeDashed = false }; this.mel.MapElements.Add(mp); } }
/// <summary> /// Adds a polyline to this map layer. /// </summary> /// <param name="lc"> /// The collection of map locations. /// </param> /// <param name="br"> /// The brush to use when rendering the polyline. /// </param> public void AddPolyline(ILocationCollection lc, Brush br) { if (this.bingMap == null) { return; } var bg = new List <BasicGeoposition>(); foreach (var loc in lc) { bg.Add(BingMilSymLayer.LocationToGeoposition(loc)); } if (br is SolidColorBrush scb) { var mp = new MapPolyline { Path = new Geopath(bg), StrokeColor = scb.Color, StrokeThickness = 1.0, StrokeDashed = false }; this.mel.MapElements.Add(mp); } }
/// <summary> /// Plots a 3+ point tactical graphic /// </summary> /// <param name="sc"> /// The symbol code to plot. /// </param> /// <param name="loc"> /// The location collection that defines the spatial extent of the symbol. /// </param> public void PlotSymbol(string sc, ILocationCollection loc) { this.pg = new MilGraphic(sc, loc); ToolTipService.SetToolTip(this.pg, sc); this.milsymLayer.AddSymbol(this.pg); // Draw the base and transformed base vectors this.polyLayer.AddPolyline(loc, new SolidColorBrush(Colors.Blue)); }
/// <summary> /// Add a polyline to the map layer. /// </summary> /// <param name="lc"> /// The collection of map locations making up the polyline. /// </param> /// <param name="br"> /// The brush with which to render the polyline. /// </param> public void AddPolyline(ILocationCollection lc, Brush br) { foreach (var loc in lc) { this.UpdateLocationRectangle(loc.Longitude, loc.Latitude); } base.Children.Add(new MapPolyline { Locations = lc as LocationCollection, Stroke = br }); }
/// <summary> /// Convert a list of Points into a collection of Locations using the factory. /// </summary> /// <param name="pts"> /// The list of Points. /// </param> /// <returns> /// The collection of Locations. /// </returns> private ILocationCollection[] PointsToCollection(IEnumerable <Point> pts) { var locs = new ILocationCollection[4]; locs[0] = this.milsymFactory.LocationCollection(); foreach (var p in pts) { locs[0].Add(this.milsymFactory.Location(Order.LatLon, p.X, p.Y)); } return(locs); }
/// <summary> /// Adds a polyline to this map layer. /// </summary> /// <param name="lc"> /// The location collection that defines the polyline. /// </param> /// <param name="br"> /// The brush used to render the polyline. /// </param> public void AddPolyline(ILocationCollection lc, Brush br) { var pc = new PointCollection(); foreach (var p in lc) { pc.Add(Transform.GeographicToWebMercator(p as MapPoint)); } var polyline = new Polyline(); polyline.Paths.Add(pc); var graphic = new Graphic { Symbol = new SimpleLineSymbol { Color = br }, Geometry = polyline }; Graphics.Add(graphic); }
/// <summary> /// Adds a polyline to this map layer. /// </summary> /// <param name="lc"> /// The collection of map locations. /// </param> /// <param name="br"> /// The brush to use when rendering the polyline. /// </param> public void AddPolyline(ILocationCollection lc, Brush br) { base.Children.Add(new MapPolyline { Locations = lc as LocationCollection, Stroke = br }); }
/// <summary> /// Get Closed Bezier Spline Control Points. /// </summary> /// <param name="knots">Input Knot Bezier spline points.</param> /// <param name="firstControlPoints">Output First Control points array of the same /// length as the <paramref name="knots"/> array.</param> /// <param name="secondControlPoints">Output Second Control points array of of the same /// length as the <paramref name="knots"/> array.</param> public static void GetCurveControlPoints( IList <ILocation> knots, out ILocationCollection firstControlPoints, out ILocationCollection secondControlPoints) { firstControlPoints = MilSymFactory.LocationCollection(); secondControlPoints = MilSymFactory.LocationCollection(); int n = knots.Count; if (n <= 2) { return; } // Calculate first Bezier control points // The matrix. var a = new double[n]; var b = new double[n]; var c = new double[n]; for (int i = 0; i < n; ++i) { a[i] = 1; b[i] = 4; c[i] = 1; } // Right hand side vector for points X coordinates. var rhs = new double[n]; for (int i = 0; i < n; ++i) { int j = (i == n - 1) ? 0 : i + 1; rhs[i] = (4 * knots[i].Longitude) + (2 * knots[j].Longitude); } // Solve the system for X. double[] x = Cyclic.Solve(a, b, c, 1, 1, rhs); // Right hand side vector for points Y coordinates. for (int i = 0; i < n; ++i) { int j = (i == n - 1) ? 0 : i + 1; rhs[i] = (4 * knots[i].Latitude) + (2 * knots[j].Latitude); } // Solve the system for Y. double[] y = Cyclic.Solve(a, b, c, 1, 1, rhs); // Fill output arrays. for (int i = 0; i < n; ++i) { // First control point. firstControlPoints.Add(MilSymFactory.Location(Order.LatLon, y[i], x[i])); // Second control point. secondControlPoints.Add( MilSymFactory.Location(Order.LatLon, (2 * knots[i].Latitude) - y[i], (2 * knots[i].Longitude) - x[i])); } }
/// <summary> /// Get open-ended Bezier Spline Control Points. /// </summary> /// <param name="knots">Input Knot Bezier spline points.</param> /// <param name="firstControlPoints">Output First Control points array of knots.Length - 1 length.</param> /// <param name="secondControlPoints">Output Second Control points array of knots.Length - 1 length.</param> /// <exception cref="ArgumentNullException"><paramref name="knots"/> parameter must be not null.</exception> /// <exception cref="ArgumentException"><paramref name="knots"/> array must containg at least two points.</exception> public static void GetCurveControlPoints( ILocationCollection knots, out ILocationCollection firstControlPoints, out ILocationCollection secondControlPoints) { firstControlPoints = MilSymFactory.LocationCollection(); secondControlPoints = MilSymFactory.LocationCollection(); if (knots == null) { throw new ArgumentNullException("knots"); } int n = knots.Count - 1; if (n < 1) { throw new ArgumentException(@"At least two knot points required", "knots"); } if (n == 1) { // Special case: Bezier curve should be a straight line. // 3P1 = 2P0 + P3 firstControlPoints.Add( MilSymFactory.Location( Order.LatLon, ((2 * knots[0].Latitude) + knots[1].Latitude) / 3, ((2 * knots[0].Longitude) + knots[1].Longitude) / 3)); // P2 = 2P1 – P0 secondControlPoints.Add( MilSymFactory.Location( Order.LatLon, (2 * firstControlPoints[0].Latitude) - knots[0].Latitude, (2 * firstControlPoints[0].Longitude) - knots[0].Longitude)); return; } // Calculate first Bezier control points // Right hand side vector var rhs = new double[n]; // Set right hand side X values for (int i = 1; i < n - 1; ++i) { rhs[i] = (4 * knots[i].Longitude) + (2 * knots[i + 1].Longitude); } rhs[0] = knots[0].Longitude + (2 * knots[1].Longitude); rhs[n - 1] = ((8 * knots[n - 1].Longitude) + knots[n].Longitude) / 2.0; // Get first control points X-values double[] x = GetFirstControlPoints(rhs); // Set right hand side Y values for (int i = 1; i < n - 1; ++i) { rhs[i] = (4 * knots[i].Latitude) + (2 * knots[i + 1].Latitude); } rhs[0] = knots[0].Latitude + (2 * knots[1].Latitude); rhs[n - 1] = ((8 * knots[n - 1].Latitude) + knots[n].Latitude) / 2.0; // Get first control points Y-values double[] y = GetFirstControlPoints(rhs); // Fill output arrays for (int i = 0; i < n; ++i) { // First control point firstControlPoints.Add(MilSymFactory.Location(Order.LatLon, y[i], x[i])); // Second control point if (i < n - 1) { secondControlPoints.Add( MilSymFactory.Location( Order.LatLon, (2 * knots[i + 1].Latitude) - y[i + 1], (2 * knots[i + 1].Longitude) - x[i + 1])); } else { secondControlPoints.Add( MilSymFactory.Location( Order.LatLon, (knots[n].Latitude + y[n - 1]) / 2, (knots[n].Longitude + x[n - 1]) / 2)); } } }