コード例 #1
0
        internal static void Transform(WriteableBitmap context, Geometry original, sb.Point location, int border, int fill)
        {
            var geometry = original.GetFlattenedPathGeometry();

            foreach (var figure in geometry.Figures)
            {
                Point firstLocalPoint = ((PolyLineSegment)figure.Segments[0]).Points[0];

                var firstPoint = new Point(firstLocalPoint.X + location.X, firstLocalPoint.Y + location.Y);

                foreach (var segment in figure.Segments)
                {
                    if (segment is PolyLineSegment)
                    {
                        var points = ((PolyLineSegment)segment).Points.Select(i => new Point(i.X + location.X, i.Y + location.Y)).ToList();

                        points.Insert(0, firstPoint);

                        AddLineString(context, points, border, fill);
                    }
                    else if (segment is LineSegment)
                    {
                        var x2 = ((LineSegment)segment).Point.X + location.X;

                        var y2 = ((LineSegment)segment).Point.Y + location.Y;

                        context.DrawLine((int)(firstPoint.X), (int)(firstPoint.Y), (int)(x2), (int)(y2), border);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }
        }
コード例 #2
0
        internal static void Transform(drawing.Graphics graphics, Geometry original, sb.Point location, drawing.Pen pen, drawing.Brush brush)
        {
            var geometry = original.GetFlattenedPathGeometry();

            foreach (var figure in geometry.Figures)
            {
                Point firstLocalPoint = ((PolyLineSegment)figure.Segments[0]).Points[0];

                var firstPoint = new System.Drawing.PointF((float)(firstLocalPoint.X + location.X), (float)(firstLocalPoint.Y + location.Y));

                foreach (var segment in figure.Segments)
                {
                    if (segment is PolyLineSegment)
                    {
                        var points = ((PolyLineSegment)segment).Points.Select(i => new System.Drawing.PointF((float)(i.X + location.X), (float)(i.Y + location.Y))).ToList();

                        points.Add(firstPoint);

                        graphics.DrawLines(pen, points.ToArray());
                    }
                    else if (segment is LineSegment)
                    {
                        var x2 = (float)(((LineSegment)segment).Point.X + location.X);

                        var y2 = (float)(((LineSegment)segment).Point.Y + location.Y);

                        graphics.DrawLine(pen, firstPoint.X, firstPoint.Y, x2, y2);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }
        }
コード例 #3
0
ファイル: Locateable.cs プロジェクト: MohammadUT/IRI.Japey
        public Locateable(sb.Point wgs84GeodeticPosition, AncherFunctionHandler ancherFunction = null) : this(ancherFunction)
        {
            var webMercator = IRI.Ham.CoordinateSystem.MapProjection.MapProjects.GeodeticWgs84ToWebMercator(wgs84GeodeticPosition);

            this.X = webMercator.X;

            this.Y = webMercator.Y;

            this._location = webMercator.AsWpfPoint();
        }
コード例 #4
0
ファイル: MTF.xaml.cs プロジェクト: MohammadUT/IRI.Japey
        private spatial.Point GetStartPoint(sfc.Move[] moves)
        {
            spatial.Point point = new spatial.Point(0, 0);

            double deltaX = 0, deltaY = 0;

            for (int i = 0; i < moves.Length - 1; i++)
            {
                point = moves[i](point, 1);

                deltaX = Math.Min(point.X, deltaX);

                deltaY = Math.Min(point.Y, deltaY);
            }

            return(new spatial.Point(-deltaX, -deltaY));
        }
コード例 #5
0
ファイル: MTF.xaml.cs プロジェクト: MohammadUT/IRI.Japey
        private List <spatial.Point> GetPoints()
        {
            sfc.Move[] movements = GetMoves(this.moves);

            spatial.Point startPoint = GetStartPoint(movements);

            List <spatial.Point> result = new List <spatial.Point>();

            result.Add(startPoint);

            for (int i = 0; i < movements.Length; i++)
            {
                startPoint = movements[i](startPoint, 1);

                result.Add(startPoint);
            }

            return(result);
        }
コード例 #6
0
        public Ham.SpatialBase.IPoint GetWgs84Point()
        {
            var point = new IRI.Ham.SpatialBase.Point(X, Y);

            switch (this.SelectedItem?.MenuType)
            {
            case SpatialReferenceType.Geodetic:
                return(point);   //.Project( ,new IRI.Ham.CoordinateSystem.MapProjection.NoProjection());

            case SpatialReferenceType.UTM:
                return(point.Project(UTM.CreateForZone(UtmZone), new NoProjection()));

            case SpatialReferenceType.Mercator:
            case SpatialReferenceType.TransverseMercator:
            case SpatialReferenceType.CylindricalEqualArea:
            case SpatialReferenceType.LambertConformalConic:
            case SpatialReferenceType.WebMercator:
            case SpatialReferenceType.AlbersEqualAreaConic:
            default:
                throw new NotImplementedException();
            }
        }
コード例 #7
0
ファイル: BezierItem.cs プロジェクト: MohammadUT/IRI.Japey
        public BezierItem(sb.Point startPoint, sb.Point endPoint, Transform toScreen)
        {
            this._toScreen = toScreen;

            var start = toScreen.Transform(startPoint.AsWpfPoint());

            var end = toScreen.Transform(endPoint.AsWpfPoint());

            var startControlPoint = toScreen.Transform(startPoint.AsWpfPoint());

            var endControlPoint = toScreen.Transform(endPoint.AsWpfPoint());


            var bezierSegment = new BezierSegment(startControlPoint, endControlPoint, end, true);

            _bezierFigure = new PathFigure()
            {
                StartPoint = start
            };

            _bezierFigure.Segments.Add(bezierSegment);

            PathGeometry bezierPathGeometry = new PathGeometry(new List <PathFigure>()
            {
                _bezierFigure
            });

            //pathGeometry.Transform = this.panTransformForPoints;


            _startControlLineFigure = new PathFigure()
            {
                StartPoint = start
            };

            _startControlLineFigure.Segments.Add(new LineSegment(startControlPoint, true));


            _endControlLineFigure = new PathFigure()
            {
                StartPoint = end
            };

            _endControlLineFigure.Segments.Add(new LineSegment(endControlPoint, true));

            StartLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(startPoint))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            StartLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                _bezierFigure.StartPoint = newPoint;

                _startControlLineFigure.StartPoint = newPoint;

                //update();
            };


            EndLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(endPoint))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            EndLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                bezierSegment.Point3 = newPoint;

                _endControlLineFigure.StartPoint = newPoint;

                //update();
            };


            StartControlLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(startControlPoint.AsPoint()))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            StartControlLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                bezierSegment.Point1 = newPoint;

                (_startControlLineFigure.Segments.First() as LineSegment).Point = newPoint;

                //update();
            };


            EndControlLocateable = new Locateable(MapProjects.WebMercatorToGeodeticWgs84(endControlPoint.AsPoint()))
            {
                Element = new Common.View.MapMarkers.Circle(1, new SolidColorBrush(Colors.Green))
            };

            EndControlLocateable.OnPositionChanged += (sender, e) =>
            {
                var locateable = (Locateable)sender;

                var newPoint = toScreen.Transform(new System.Windows.Point(locateable.X, locateable.Y));

                bezierSegment.Point2 = newPoint;

                (_endControlLineFigure.Segments.First() as LineSegment).Point = newPoint;

                //update();
            };



            Path temp = new Path();

            temp.Data            = bezierPathGeometry;
            temp.Stroke          = new SolidColorBrush(Colors.Black);
            temp.StrokeThickness = 2;
            //temp.RenderTransform = this.panTransformForPoints;
            //temp.Tag = new LayerTag(0) { IsTiled = false, LayerType = LayerType.Drawing };

            //this.mapView.Children.Add(temp);

            //Path axLine2 = new Path() { Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1, RenderTransform = panTransformForPoints };
            Path axLine2 = new Path()
            {
                Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1
            };

            axLine2.Data = new PathGeometry(new List <PathFigure>()
            {
                _startControlLineFigure
            });
            //axLine2.Tag = new LayerTag(-1) { IsTiled = false, LayerType = LayerType.Drawing };
            //this.mapView.Children.Add(axLine2);

            //Path axLine3 = new Path() { Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1, RenderTransform = panTransformForPoints };
            Path axLine3 = new Path()
            {
                Stroke = new SolidColorBrush(Colors.Gray), StrokeThickness = 1
            };

            axLine3.Data = new PathGeometry(new List <PathFigure>()
            {
                _endControlLineFigure
            });
            //axLine3.Tag = new LayerTag(-1) { IsTiled = false, LayerType = LayerType.Drawing };
            //this.mapView.Children.Add(axLine3);
        }
コード例 #8
0
        private static void AddLineString(WriteableBitmap context, sb.Primitives.Geometry original, sb.Point location, int border, int fill)
        {
            if (original.NumberOfPoints < 1)
            {
                return;
            }

            for (int i = 1; i < original.NumberOfPoints; i++)
            {
                context.DrawLine(
                    (int)(original.Points[i - 1].X + location.X),
                    (int)(original.Points[i - 1].Y + location.Y),
                    (int)(original.Points[i].X + location.X),
                    (int)(original.Points[i].Y + location.Y),
                    border);
            }
        }
コード例 #9
0
        internal static void Transform(WriteableBitmap context, sb.Primitives.Geometry original, sb.Point location, int border, int fill)
        {
            if (original.Geometries != null)
            {
                foreach (var geometry in original.Geometries)
                {
                    Transform(context, geometry, location, border, fill);
                }
            }
            else
            {
                if (original.NumberOfPoints < 1)
                {
                    return;
                }

                var firstPoint = original.Points[0];

                if (original.Type == sb.Primitives.GeometryType.Point)
                {
                    context.DrawEllipseCentered(border, (int)(firstPoint.X + location.X), (int)(firstPoint.Y + location.Y), pointSize, pointSize);
                }
                else if (original.Type == Ham.SpatialBase.Primitives.GeometryType.LineString)
                {
                    AddLineString(context, original, location, border, fill);
                }
            }
        }
コード例 #10
0
        private static void AddLineString(drawing.Graphics graphics, sb.Primitives.Geometry original, sb.Point location, drawing.Pen pen, drawing.Brush brush)
        {
            if (original.NumberOfPoints < 1)
            {
                return;
            }

            for (int i = 1; i < original.NumberOfPoints; i++)
            {
                graphics.DrawLine(pen,
                                  (float)(original.Points[i - 1].X + location.X),
                                  (float)(original.Points[i - 1].Y + location.Y),
                                  (float)(original.Points[i].X + location.X),
                                  (float)(original.Points[i].Y + location.Y));
            }
        }
コード例 #11
0
        internal static void Transform(drawing.Graphics graphics, sb.Primitives.Geometry original, sb.Point location, drawing.Pen pen, drawing.Brush brush)
        {
            if (original.Geometries != null)
            {
                foreach (var geometry in original.Geometries)
                {
                    Transform(graphics, geometry, location, pen, brush);
                }
            }
            else
            {
                if (original.NumberOfPoints < 1)
                {
                    return;
                }

                var firstPoint = original.Points[0];

                if (original.Type == sb.Primitives.GeometryType.Point)
                {
                    graphics.DrawEllipse(pen, (float)(firstPoint.X + location.X), (float)(firstPoint.Y + location.Y), pointSize, pointSize);
                }
                else if (original.Type == Ham.SpatialBase.Primitives.GeometryType.LineString)
                {
                    AddLineString(graphics, original, location, pen, brush);
                }
            }
        }
コード例 #12
0
ファイル: DrawingLayer.cs プロジェクト: MohammadUT/IRI.Japey
        public DrawingLayer(DrawMode mode, Transform toScreen, Func <double, double> screenToMap, sb.Point startMercatorPoint, EditableFeatureLayerOptions options)
        {
            this._mode = mode;

            sb.Primitives.GeometryType type;

            switch (mode)
            {
            case DrawMode.Point:
                type = sb.Primitives.GeometryType.Point;
                break;

            case DrawMode.Polyline:
                type = sb.Primitives.GeometryType.LineString;
                break;

            case DrawMode.Polygon:
                type = sb.Primitives.GeometryType.Polygon;
                break;

            case DrawMode.Rectange:
            case DrawMode.Freehand:
            default:
                throw new NotImplementedException();
            }

            //var options = new EditableFeatureLayerOptions() { IsVerticesLabelVisible = isEdgeLengthVisible };

            this._editableFeatureLayer = new EditableFeatureLayer("edit", new List <sb.Point>()
            {
                startMercatorPoint
            }, toScreen, screenToMap, type, options);

            this._editableFeatureLayer.OnRequestFinishDrawing += (sender, e) => { this.OnRequestFinishDrawing.SafeInvoke(this); };

            this._editableFeatureLayer.RequestFinishEditing = g =>
            {
                this.RequestFinishEditing?.Invoke(g);
            };

            this._editableFeatureLayer.RequestCancelDrawing = () => { this.RequestCancelDrawing?.Invoke(); };

            this.VisibleRange = ScaleInterval.All;

            this.VisualParameters = new VisualParameters(mode == DrawMode.Polygon ? new SolidColorBrush(Colors.YellowGreen) : null, new SolidColorBrush(Colors.Blue), 3, 1);
        }
コード例 #13
0
ファイル: DrawingLayer.cs プロジェクト: MohammadUT/IRI.Japey
 public void StartNewPart(sb.Point webMercatorPoint)
 {
     this._editableFeatureLayer.StartNewPart(webMercatorPoint);
 }
コード例 #14
0
ファイル: DrawingLayer.cs プロジェクト: MohammadUT/IRI.Japey
 public void AddSemiVertex(sb.Point webMercatorPoint)
 {
     this._editableFeatureLayer.AddSemiVertex(webMercatorPoint);
 }
コード例 #15
0
ファイル: DrawingLayer.cs プロジェクト: MohammadUT/IRI.Japey
 public void UpdateLastVertexLocation(sb.Point point)
 {
     this._editableFeatureLayer.UpdateLastSemiVertexLocation(point);
 }