/// <summary>
 /// Transform the given enumeration of geo coordinates into a shape definition.
 /// </summary>
 /// <param name="GeoCoordinates">An enumeration of geo coordinates.</param>
 /// <param name="OnScreenUpperLeft">The upper-left screen offset.</param>
 /// <param name="ZoomLevel">The current zoom level of the Aegir map.</param>
 /// <param name="CloseShape">Whether to close the shape (polygon), or not (line).</param>
 public static GeoCoordinates2ShapeDefinitionPipe ToShapeDefinition(this IEnumerable <IEnumerable <GeoCoordinate> > GeoCoordinates,
                                                                    ScreenXY OnScreenUpperLeft,
                                                                    UInt32 ZoomLevel,
                                                                    Boolean CloseShape)
 {
     return(new GeoCoordinates2ShapeDefinitionPipe(OnScreenUpperLeft, ZoomLevel, CloseShape, GeoCoordinates));
 }
 /// <summary>
 /// Transform the given enumeration of geo coordinates into a shape definition.
 /// </summary>
 /// <param name="ArrowSender">The sender of the messages/objects.</param>
 /// <param name="OnScreenUpperLeft">The upper-left screen offset.</param>
 /// <param name="ZoomLevel">The current zoom level of the Aegir map.</param>
 /// <param name="CloseShape">Whether to close the shape (polygon), or not (line).</param>
 /// <param name="OnError">A delegate to transform an incoming error into an outgoing error.</param>
 public static GeoCoordinates2ShapeDefinitionArrow ToShapeDefinition(this IArrowSender <IEnumerable <GeoCoordinate> > ArrowSender,
                                                                     ScreenXY OnScreenUpperLeft,
                                                                     UInt32 ZoomLevel,
                                                                     Boolean CloseShape,
                                                                     Func <Exception, Exception> OnError = null)
 {
     return(new GeoCoordinates2ShapeDefinitionArrow(OnScreenUpperLeft, ZoomLevel, CloseShape, OnError, ArrowSender));
 }
        /// <summary>
        /// Create a new pipe to transform an enumeration of
        /// geo coordinates into shape definitions.
        /// </summary>
        /// <param name="OnScreenUpperLeft">The upper-left screen offset.</param>
        /// <param name="ZoomLevel">The current zoom level of the Aegir map.</param>
        /// <param name="CloseShape">Whether to close the shape (polygon), or not (line).</param>
        /// <param name="IEnumerable">An optional IEnumerable&lt;S&gt; as element source.</param>
        /// <param name="IEnumerator">An optional IEnumerator&lt;S&gt; as element source.</param>
        public GeoCoordinates2ShapeDefinitionPipe(ScreenXY OnScreenUpperLeft,
                                                  UInt32 ZoomLevel,
                                                  Boolean CloseShape,
                                                  IEnumerable <IEnumerable <GeoCoordinate> > IEnumerable = null,
                                                  IEnumerator <IEnumerable <GeoCoordinate> > IEnumerator = null)

            : base(IEnumerable,
                   Item => Item.GeoCoordinates2ShapeDefinition(OnScreenUpperLeft, ZoomLevel, CloseShape))

        {
        }
        /// <summary>
        /// Create a new arrow to transform an enumeration of
        /// geo coordinates into shape definitions.
        /// </summary>
        /// <param name="OnScreenUpperLeft">The upper-left screen offset.</param>
        /// <param name="ZoomLevel">The current zoom level of the Aegir map.</param>
        /// <param name="CloseShape">Whether to close the shape (polygon), or not (line).</param>
        /// <param name="OnError">A delegate to transform an incoming error into an outgoing error.</param>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        public GeoCoordinates2ShapeDefinitionArrow(ScreenXY OnScreenUpperLeft,
                                                   UInt32 ZoomLevel,
                                                   Boolean CloseShape,
                                                   Func <Exception, Exception> OnError = null,
                                                   IArrowSender <IEnumerable <GeoCoordinate> > ArrowSender = null)

            : base(Item => Item.GeoCoordinates2ShapeDefinition(OnScreenUpperLeft, ZoomLevel, CloseShape),
                   OnError,
                   ArrowSender)

        {
        }
Exemple #5
0
        private void DrawLine(ScreenXY P1, ScreenXY P2, Brush Stroke, Double StrokeThickness)
        {
            var Line = new Line()
            {
                X1              = P1.X + this.MapControl.ScreenOffset.X,
                Y1              = P1.Y + this.MapControl.ScreenOffset.Y,
                X2              = P2.X + this.MapControl.ScreenOffset.X,
                Y2              = P2.Y + this.MapControl.ScreenOffset.Y,
                Stroke          = Stroke,
                StrokeThickness = StrokeThickness
            };

            this.Children.Add(Line);
        }
Exemple #6
0
        private void DrawCircle(ScreenXY P, Double Radius, Brush Stroke, Double StrokeThickness)
        {
            var Ellipse = new Ellipse()
            {
                Width           = 2 * Radius,
                Height          = 2 * Radius,
                Stroke          = Stroke,
                StrokeThickness = StrokeThickness
            };

            this.Children.Add(Ellipse);

            Canvas.SetLeft(Ellipse, P.X - Radius + this.MapControl.ScreenOffset.X);
            Canvas.SetTop(Ellipse, P.Y - Radius + this.MapControl.ScreenOffset.Y);
        }
        /// <summary>
        /// Transform the given enumeration of geo coordinates into a shape definition.
        /// </summary>
        /// <param name="GeoCoordinates">An enumeration of geo coordinates.</param>
        /// <param name="OnScreenUpperLeft">The upper-left screen offset.</param>
        /// <param name="ZoomLevel">The current zoom level of the Aegir map.</param>
        /// <param name="CloseShape">Whether to close the shape (polygon), or not (line).</param>
        public static SDL GeoCoordinates2ShapeDefinition(this IEnumerable <GeoCoordinate> GeoCoordinates,
                                                         ScreenXY OnScreenUpperLeft,
                                                         UInt32 ZoomLevel,
                                                         Boolean CloseShape)

        {
            if (GeoCoordinates == null)
            {
                throw new ArgumentNullException("GeoCoordinates");
            }

            var StringBuilder = new StringBuilder("M ");

            Action <ScreenXY> ApplyScreenOffset = ScreenXY => {
                StringBuilder.Append(((Int64)ScreenXY.X) - OnScreenUpperLeft.X);
                StringBuilder.Append(" ");
                StringBuilder.Append(((Int64)ScreenXY.Y) - OnScreenUpperLeft.Y);
                StringBuilder.Append(" ");
            };

            var GeoCoordinates2 = GeoCoordinates.ToArray();
            var BoundingBox     = GeoCoordinates2.GeoCoordinate2BoundingBox();


            GeoCoordinates2.

            // Project the geo coordinate onto the current screen (without offset!)
            Select(GeoCoordinate => GeoCalculations.GeoCoordinate2ScreenXY(GeoCoordinate, ZoomLevel)).

            ForEach(
                // For the first...
                OnScreenXY => {
                ApplyScreenOffset(OnScreenXY);
                StringBuilder.Append("L ");
            },

                // For the rest..
                OnScreenXY => ApplyScreenOffset(OnScreenXY));


            if (CloseShape)
            {
                StringBuilder.Append("Z ");
            }

            return(new SDL(StringBuilder.ToString()));
        }
Exemple #8
0
        private void DrawLine(ScreenXY P1, ScreenXY P2, Brush Stroke, Double StrokeThickness)
        {
            var Line = new Line() {
                X1               = P1.X + this.MapControl.ScreenOffset.X,
                Y1               = P1.Y + this.MapControl.ScreenOffset.Y,
                X2               = P2.X + this.MapControl.ScreenOffset.X,
                Y2               = P2.Y + this.MapControl.ScreenOffset.Y,
                Stroke           = Stroke,
                StrokeThickness  = StrokeThickness
            };

            this.Children.Add(Line);
        }
Exemple #9
0
        private void DrawCircle(ScreenXY P, Double Radius, Brush Stroke, Double StrokeThickness)
        {
            var Ellipse = new Ellipse()
            {
                Width  = 2*Radius,
                Height = 2*Radius,
                Stroke = Stroke,
                StrokeThickness = StrokeThickness
            };

            this.Children.Add(Ellipse);

            Canvas.SetLeft(Ellipse, P.X - Radius + this.MapControl.ScreenOffset.X);
            Canvas.SetTop (Ellipse, P.Y - Radius + this.MapControl.ScreenOffset.Y);
        }