Ejemplo n.º 1
0
        private GeoMultiLine CreateMultiLine()
        {
            GeoLine line1 = new GeoLine();
            GeoLine line2 = new GeoLine();

            double startX                  = Map1.CurrentBound.MinX + Map1.CurrentBound.Width * .15;
            double endX                    = Map1.CurrentBound.MinX + Map1.CurrentBound.Width * .85;
            double height                  = Map1.CurrentBound.Height * .25;
            double centerY1                = Map1.CurrentCenter.Y + height;
            double centerY2                = Map1.CurrentCenter.Y - height;
            int    segmentCount            = 30;
            double segmentHorizontalLength = (endX - startX) / segmentCount;

            for (int i = 0; i < segmentCount; i++)
            {
                double x1 = startX + segmentHorizontalLength * i;
                double y1 = Math.Sin(Math.PI * 2 * i / segmentCount) * height + centerY1;
                line1.Coordinates.Add(new GeoCoordinate(x1, y1));

                double x2 = startX + segmentHorizontalLength * i;
                double y2 = Math.Cos(Math.PI * 2 * i / segmentCount) * height + centerY2;
                line2.Coordinates.Add(new GeoCoordinate(x2, y2));
            }

            GeoMultiLine multiLine = new GeoMultiLine();

            multiLine.Lines.Add(line1);
            multiLine.Lines.Add(line2);
            return(multiLine);
        }
Ejemplo n.º 2
0
        private GeoLine CreateGreatCircle()
        {
            GeoPoint     point1             = new GeoPoint(-73.935242, 40.730610);
            GeoPoint     point2             = new GeoPoint(2.294694, 48.858093);
            GeoMultiLine greatCircleInWgs84 = point1.GetGreatCircle(point2, 30);

            Projection   projection          = new Proj4Projection(SpatialReferences.GetWgs84(), SpatialReferences.GetSphericalMercator());
            GeoMultiLine greatCircleIn900913 = (GeoMultiLine)projection.ConvertToTarget(greatCircleInWgs84);

            return(greatCircleIn900913.Lines[0]);
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            MemoryLayer resultLayer = Map1.FindLayer <MemoryLayer>("ResultLayer");

            if (resultLayer.Features.Count == 0)
            {
                GeoMultiLine shortestResult = await Task.Run(() => feature1.Geometry.GetShortestLineTo(feature2.Geometry));

                GeoLine shortestLine = shortestResult.Lines.First();

                resultLayer.Features.Add(new Feature(shortestLine));
                resultLayer.Features.Add(new Feature(new GeoPoint(shortestLine.Coordinates.First())));
                resultLayer.Features.Add(new Feature(new GeoPoint(shortestLine.Coordinates.Last())));
                Map1.Refresh("ResultOverlay");
            }
        }