public void ProcessPrescription(Prescription prescription)
        {
            if (prescription is VectorPrescription) //Only Vector currently supported for the Visualizer map
            {
                VectorPrescription vectorPrescription = prescription as VectorPrescription;

                using (var graphics = _spatialViewer.CreateGraphics())
                {
                    _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);

                    List <Point>         allPoints = new List <Point>();
                    List <List <Point> > projectedPointsPerPolygon = new List <List <Point> >();
                    foreach (Polygon polygon in vectorPrescription.RxShapeLookups.SelectMany(x => x.Shape.Polygons))
                    {
                        List <Point> polygonPoints = new List <Point>();
                        foreach (Point point in polygon.ExteriorRing.Points)
                        {
                            Point projectedPoint = point.ToUtm();
                            allPoints.Add(projectedPoint);
                            polygonPoints.Add(projectedPoint);
                        }
                        projectedPointsPerPolygon.Add(polygonPoints);
                    }
                    _drawingUtil.SetMinMax(allPoints);
                    foreach (List <Point> polygonPoints in projectedPointsPerPolygon)
                    {
                        var screenPolygon = polygonPoints.Select(point => point.ToXy(_drawingUtil.MinX, _drawingUtil.MinY, _drawingUtil.GetDelta())).ToArray();
                        graphics.DrawPolygon(DrawingUtil.B_Black, screenPolygon);
                    }
                }
            }
        }
Esempio n. 2
0
        public static void SetMinMax(this AbLine abLine, DrawingUtil drawingUtil)
        {
            var points = new List <Point> {
                abLine.A.ToUtm(), abLine.B.ToUtm()
            };

            SetMinMax(drawingUtil, points);
        }
Esempio n. 3
0
        public static void SetMinMax(this MultiAbLine multiAbLine, DrawingUtil drawingUtil)
        {
            var points = multiAbLine.AbLines.SelectMany(x => new List <Point> {
                x.A.ToUtm(), x.B.ToUtm()
            }).ToList();

            SetMinMax(drawingUtil, points);
        }
Esempio n. 4
0
        public static void SetMinMax(this APlus aPlus, DrawingUtil drawingUtil)
        {
            var points = new List <Point> {
                aPlus.Point.ToUtm()
            };

            SetMinMax(drawingUtil, points);
        }
Esempio n. 5
0
        public void ProccessGuidancePattern(GuidancePattern guidancePattern)
        {
            using (var graphics = _spatialViewer.CreateGraphics())
            {
                _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);

                SetMinMax(guidancePattern);

                ProcessPattern(guidancePattern);
            }
        }
Esempio n. 6
0
        public void ProccessGuidancePattern(GuidancePattern guidancePattern)
        {
            using (var graphics = _spatialViewer.CreateGraphics())
            {
                _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);

                SetMinMax(guidancePattern);

                ProcessPattern(guidancePattern);
            }
        }
Esempio n. 7
0
        public void ProcessGuidance(GuidanceGroup guidanceGroup, List <GuidancePattern> guidancePatterns)
        {
            using (var graphics = _spatialViewer.CreateGraphics())
            {
                _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);

                SetMinMax(guidancePatterns, guidanceGroup.GuidancePatternIds);

                foreach (var id in guidanceGroup.GuidancePatternIds)
                {
                    ProcessGuidancePattern(guidancePatterns, id);
                }
            }
        }
Esempio n. 8
0
        public void ProcessGuidance(GuidanceGroup guidanceGroup, List<GuidancePattern> guidancePatterns)
        {
            using (var graphics = _spatialViewer.CreateGraphics())
            {
                _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);

                SetMinMax(guidancePatterns, guidanceGroup.GuidancePatternIds);

                foreach (var id in guidanceGroup.GuidancePatternIds)
                {
                    ProcessGuidancePattern(guidancePatterns, id);
                }
            }
        }
Esempio n. 9
0
        public void GivenMinAndMaxesSetAndHeightAndLonAreGreaterWhenGetDeltaThenDeltaIsReturned()
        {
            _drawingUtil = new DrawingUtil(600, 1050, _graphics);

            var points = new List<Point>();
            points.Add(new Point { X = 5600, Y = 9000 });
            points.Add(new Point { X = 3600, Y = 7200 });
            points.Add(new Point { X = 9000, Y = 2000 });
            points.Add(new Point { X = 7600, Y = 2700 });
            points.Add(new Point { X = 1000, Y = 8000 });
            _drawingUtil.SetMinMax(points);

            var delta = _drawingUtil.GetDelta();
            Assert.AreEqual(7, delta);
        }
Esempio n. 10
0
        public void ProcessBoundary(FieldBoundary fieldBoundary)
        {
            using (var graphics = _spatialViewer.CreateGraphics())
            {
                _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);
                foreach (var polygon in fieldBoundary.SpatialData.Polygons)
                {
                    var projectedPoints = polygon.ExteriorRing.Points.Select(point => point.ToUtm()).ToList();
                    _drawingUtil.SetMinMax(projectedPoints);

                    var screenPolygon = projectedPoints.Select(point => point.ToXy(_drawingUtil.MinX, _drawingUtil.MinY, _drawingUtil.GetDelta())).ToArray();

                    graphics.DrawPolygon(DrawingUtil.B_Black, screenPolygon);
                }
            }
        }
Esempio n. 11
0
        public void ProcessBoundary(FieldBoundary fieldBoundary)
        {
            using (var graphics = _spatialViewer.CreateGraphics())
            {
                _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);
                foreach (var polygon in fieldBoundary.SpatialData.Polygons)
                {
                    var projectedPoints = polygon.ExteriorRing.Points.Select(point => point.ToUtm()).ToList();
                    _drawingUtil.SetMinMax(projectedPoints);
                    
                    var screenPolygon = projectedPoints.Select(point => point.ToXy(_drawingUtil.MinX, _drawingUtil.MinY, _drawingUtil.GetDelta())).ToArray();

                    graphics.DrawPolygon(DrawingUtil.Pen, screenPolygon);
                }
            }
        }
Esempio n. 12
0
        public static void SetMinMax(this CenterPivot centerPivot, DrawingUtil drawingUtil)
        {
            var centerUtm = centerPivot.Center.ToUtm();
            var radius    = Math.Abs(centerUtm.X - centerPivot.EndPoint.ToUtm().X);

            var northPoint = new Point
            {
                X = centerUtm.X,
                Y = centerUtm.Y + radius,
            };
            var southPoint = new Point
            {
                X = centerUtm.X,
                Y = centerUtm.Y - radius,
            };
            var westPoint = new Point
            {
                X = centerUtm.X - radius,
                Y = centerUtm.Y,
            };
            var eastPoint = new Point
            {
                X = centerUtm.X + radius,
                Y = centerUtm.Y,
            };

            var points = new List <Point>
            {
                northPoint,
                southPoint,
                westPoint,
                eastPoint
            };

            SetMinMax(drawingUtil, points);
        }
Esempio n. 13
0
        public static void SetMinMax(this CenterPivot centerPivot, DrawingUtil drawingUtil)
        {
            var centerUtm = centerPivot.Center.ToUtm();
            var radius = Math.Abs(centerUtm.X - centerPivot.EndPoint.ToUtm().X);

            var northPoint = new Point
            {
                X = centerUtm.X,
                Y = centerUtm.Y + radius,
            };
            var southPoint = new Point
            {
                X = centerUtm.X,
                Y = centerUtm.Y - radius,
            };
            var westPoint = new Point
            {
                X = centerUtm.X - radius,
                Y = centerUtm.Y,
            };
            var eastPoint = new Point
            {
                X = centerUtm.X + radius,
                Y = centerUtm.Y,
            };

            var points = new List<Point>
            {
                northPoint,
                southPoint,
                westPoint,
                eastPoint
            };

            SetMinMax(drawingUtil, points);
        }
Esempio n. 14
0
        public static void SetMinMax(this Spiral spiral, DrawingUtil drawingUtil)
        {
            var points = spiral.Shape.Points.Select(x => x.ToUtm()).ToList();

            SetMinMax(drawingUtil, points);
        }
Esempio n. 15
0
        public static void SetMinMax(this AbCurve abCurve, DrawingUtil drawingUtil)
        {
            var points = abCurve.Shape.SelectMany(x => x.Points).Select(x => x.ToUtm()).ToList();

            SetMinMax(drawingUtil, points);
        }
Esempio n. 16
0
        public static void SetMinMax(this AbCurve abCurve, DrawingUtil drawingUtil)
        {
            var points = abCurve.Shape.SelectMany(x => x.Points).Select(x => x.ToUtm()).ToList();

            SetMinMax(drawingUtil, points);
        }
Esempio n. 17
0
 private static void SetMinMax(DrawingUtil drawingUtil, List <Point> points)
 {
     drawingUtil.SetMinMax(points);
 }
        /// <summary>
        /// Draws a Red polygon if all values 0, a DarkMagenta polygon if all values the same non-zero value, or else themes Red/DarkOrange/Gold/YellowGreen/LawnGreen/LimeGreen/ForestGreen/DarkGreen.
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="workingDataKey"></param>
        public void ThemeMap(string workingDataKey)
        {
            using (var graphics = _spatialViewer.CreateGraphics())
            {
                graphics.Clear(System.Drawing.Color.White);
                _drawingUtil = new DrawingUtil(_spatialViewer.Width, _spatialViewer.Height, graphics);

                List <Point>  projectedPoints = new List <Point>();
                List <double> doubleValues    = null;
                foreach (SpatialRecord record in _spatialRecords)
                {
                    Point point = record.Geometry as Point;
                    projectedPoints.Add(point.ToUtm());

                    if (_workingDataDictionary.ContainsKey(workingDataKey))
                    {
                        WorkingData         workingData = _workingDataDictionary[workingDataKey];
                        RepresentationValue repValue    = record.GetMeterValue(workingData);
                        if (repValue is NumericRepresentationValue)
                        {
                            NumericRepresentationValue numericValue = repValue as NumericRepresentationValue;
                            if (doubleValues == null)
                            {
                                doubleValues = new List <double>();
                            }
                            doubleValues.Add(numericValue.Value.Value);
                        }
                        else if (repValue is EnumeratedValue)
                        {
                            EnumeratedValue enumValue = repValue as EnumeratedValue;
                            if (enumValue.Representation.Code == "dtRecordingStatus")
                            {
                                if (doubleValues == null)
                                {
                                    doubleValues = new List <double>();
                                }
                                doubleValues.Add(enumValue.Value.Value == "On" ? 1d : -1d);
                            }
                        }
                    }
                }

                if (!projectedPoints.Any())
                {
                    return;
                }

                _drawingUtil.SetMinMax(projectedPoints);
                var screenPolygon = projectedPoints.Select(point => point.ToXy(_drawingUtil.MinX, _drawingUtil.MinY, _drawingUtil.GetDelta())).ToArray();

                if (screenPolygon.All(p => !double.IsNaN(p.X) && !double.IsNaN(p.Y)))
                {
                    if (doubleValues == null)
                    {
                        //WorkingData is not numeric
                        graphics.DrawPolygon(DrawingUtil.B_Black, screenPolygon);
                    }
                    else
                    {
                        if (doubleValues.Max() == doubleValues.Min())
                        {
                            //All values are the same
                            if (doubleValues.Max() <= 0d)
                            {
                                //Zero values
                                graphics.DrawPolygon(DrawingUtil.E_Red, screenPolygon);
                            }
                            else
                            {
                                //Non-zero values
                                graphics.DrawPolygon(DrawingUtil.L_DarkGreen, screenPolygon);
                            }
                        }
                        else
                        {
                            double        max                  = doubleValues.Max();
                            double        min                  = doubleValues.Min();
                            double        average              = doubleValues.Average();
                            List <double> removedZeroValues    = doubleValues.Where(dv => dv != 0).ToList();
                            double        avarageWithoutZeroes = removedZeroValues.Average();
                            if (average != avarageWithoutZeroes)
                            {
                                min = removedZeroValues.Min();
                            }


                            int    i     = 0;
                            double range = (max - min) / 7.0;
                            double e7th  = min;
                            double f7th  = e7th + range;
                            double g7th  = f7th + range;
                            double h7th  = g7th + range;
                            double i7th  = h7th + range;
                            double j7th  = i7th + range;
                            double k7th  = j7th + range;
                            double l7th  = max;

                            foreach (System.Drawing.PointF f in screenPolygon)
                            {
                                double             dbl = i < doubleValues.Count ? doubleValues[i] : 0d; //Values will be in same order as points
                                System.Drawing.Pen pen = DrawingUtil.B_Black;

                                if (dbl <= e7th)
                                {
                                    pen = DrawingUtil.E_Red;
                                }
                                else if (dbl <= f7th)
                                {
                                    pen = DrawingUtil.F_DarkOrange;
                                }
                                else if (dbl <= g7th)
                                {
                                    pen = DrawingUtil.G_Gold;
                                }
                                else if (dbl <= h7th)
                                {
                                    pen = DrawingUtil.H_YellowGreen;
                                }
                                else if (dbl <= i7th)
                                {
                                    pen = DrawingUtil.I_LawnGreen;
                                }
                                else if (dbl <= j7th)
                                {
                                    pen = DrawingUtil.J_LimeGreen;
                                }
                                else if (dbl <= k7th)
                                {
                                    pen = DrawingUtil.K_ForestGreen;
                                }
                                else if (dbl <= l7th)
                                {
                                    pen = DrawingUtil.L_DarkGreen;
                                }

                                graphics.DrawEllipse(pen, new System.Drawing.RectangleF(f.X, f.Y, 2, 2));
                                i++;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 19
0
 private static void SetMinMax(DrawingUtil drawingUtil, List<Point> points)
 {
     drawingUtil.SetMinMax(points);
 }
Esempio n. 20
0
        public static void SetMinMax(this Spiral spiral, DrawingUtil drawingUtil)
        {
            var points = spiral.Shape.Points.Select(x => x.ToUtm()).ToList();

            SetMinMax(drawingUtil, points);
        }
Esempio n. 21
0
        public static void SetMinMax(this MultiAbLine multiAbLine, DrawingUtil drawingUtil)
        {
            var points = multiAbLine.AbLines.SelectMany(x => new List<Point> {x.A.ToUtm(), x.B.ToUtm()}).ToList();

            SetMinMax(drawingUtil, points);
        }
Esempio n. 22
0
        public static void SetMinMax(this APlus aPlus, DrawingUtil drawingUtil)
        {
            var points = new List<Point> {aPlus.Point.ToUtm()};

            SetMinMax(drawingUtil, points);
        }
Esempio n. 23
0
 public void Setup()
 {
     _tabPage = new TabPage();
     _graphics = _tabPage.CreateGraphics();
     _drawingUtil = new DrawingUtil(1050, 1050, _graphics);
 }
Esempio n. 24
0
        public static void SetMinMax(this AbLine abLine, DrawingUtil drawingUtil)
        {
            var points = new List<Point> {abLine.A.ToUtm(), abLine.B.ToUtm()};

            SetMinMax(drawingUtil, points);
        }