Ejemplo n.º 1
0
        void processField()
        {
            PointExtension.LocalLatitude = selectedField.Locations.Min(p => p.Latitude);
            LineDefinition lineDef_AB = LineDefinition.GetLineDefinition(flagA.Location.ToGeoPoint().ToCart(), flagB.Location.ToGeoPoint().ToCart());

            GuidanceLines.Clear();
            Swathes.Clear();
            AnalysisResult res = AnalyzeFieldAndShowSwaths(selectedField, lineDef_AB);

            AppliedArea = res.AppliedArea / 10000;
            FieldArea   = res.FieldArea / 10000;
            //Savings = (res.AppliedArea - res.FieldArea) / 10000 * CostHa;
            SectionSaving = (res.AppliedArea - res.FieldArea) / 10000 * CostHa * (1 - 1.0 / NumberOfSections);
            SectionLoss   = (res.AppliedArea - res.FieldArea) / 10000 * CostHa - SectionSaving;

            double totalNozzleSaving = (res.AppliedArea - res.FieldArea) / 10000 * CostHa * (1 - 1.0 / NumberOfNozzles);

            NozzleSaving = totalNozzleSaving - SectionSaving;
            NozzleLoss   = (res.AppliedArea - res.FieldArea) / 10000 * CostHa - totalNozzleSaving;

            SectionPaybackHa = SectionControlPrice / (SectionSaving / AppliedArea);
            NozzlePaybackHa  = (NozzleControlPrice - SectionControlPrice) / (NozzleSaving / AppliedArea);
        }
Ejemplo n.º 2
0
        public void TestChooseHeadlandInterstion()
        {
            List <MyPoint3D> headland = new List <MyPoint3D>();

            //headland.Add(new MyPoint3D());
            headland.Add(new MyPoint3D()
            {
                X = 10
            });
            headland.Add(new MyPoint3D()
            {
                Y = 10
            });
            headland.Add(new MyPoint3D()
            {
                X = -10
            });
            headland.Add(new MyPoint3D()
            {
                Y = -10
            });
            headland.Add(new MyPoint3D()
            {
                X = 10
            });
            //headland.Add(new MyPoint3D());

            LineDefinition line = new LineDefinition()
            {
                k = 1
            };
            LineDefinition headlandLine = new LineDefinition()
            {
                k = -1, b = 10
            };
            var intersection = Utility.ChooseHeadlandIntersection(headland, line, 2, headlandLine, new MyPoint3D()
            {
                X = 5, Y = 5
            });

            Assert.AreEqual(5 - Math.Sqrt(2) / 2, intersection.X);
            Assert.AreEqual(5 - Math.Sqrt(2) / 2, intersection.Y);

            line = new LineDefinition()
            {
                k = -1
            };
            headlandLine = new LineDefinition()
            {
                k = 1, b = -10
            };
            intersection = Utility.ChooseHeadlandIntersection(headland, line, 2, headlandLine, new MyPoint3D()
            {
                X = 5, Y = -5
            });
            Assert.AreEqual(true, Math.Abs(5 - Math.Sqrt(2) / 2 - intersection.X) < 0.00000001);
            Assert.AreEqual(true, Math.Abs(-5 + Math.Sqrt(2) / 2 - intersection.Y) < 0.00000001);

            line = new LineDefinition()
            {
                k = -1
            };
            headlandLine = new LineDefinition()
            {
                k = 1, b = 10
            };
            intersection = Utility.ChooseHeadlandIntersection(headland, line, 2, headlandLine, new MyPoint3D()
            {
                X = -5, Y = 5
            });
            Assert.AreEqual(true, Math.Abs(-5 + Math.Sqrt(2) / 2 - intersection.X) < 0.00000001);
            Assert.AreEqual(true, Math.Abs(5 - Math.Sqrt(2) / 2 - intersection.Y) < 0.00000001);

            line = new LineDefinition()
            {
                k = 1
            };
            headlandLine = new LineDefinition()
            {
                k = -1, b = -10
            };
            intersection = Utility.ChooseHeadlandIntersection(headland, line, 2, headlandLine, new MyPoint3D()
            {
                X = -5, Y = -5
            });
            Assert.AreEqual(true, Math.Abs(-5 + Math.Sqrt(2) / 2 - intersection.X) < 0.00000001);
            Assert.AreEqual(true, Math.Abs(-5 + Math.Sqrt(2) / 2 - intersection.Y) < 0.00000001);



            headland = new List <MyPoint3D>();
            headland.Add(new MyPoint3D()
            {
                X = 25.0 / 3
            });
            headland.Add(new MyPoint3D()
            {
                Y = 25.0 / 4
            });
            headland.Add(new MyPoint3D()
            {
                X = -25.0 / 3
            });
            headland.Add(new MyPoint3D()
            {
                Y = -25.0 / 4
            });
            headland.Add(new MyPoint3D()
            {
                X = 25.0 / 3
            });

            line = new LineDefinition()
            {
                k = 4.0 / 3
            };
            headlandLine = new LineDefinition()
            {
                k = -3.0 / 4, b = 25.0 / 4
            };
            intersection = Utility.ChooseHeadlandIntersection(headland, line, 2, headlandLine, new MyPoint3D()
            {
                X = 3, Y = 4
            });
            Assert.AreEqual(true, Math.Abs(3 - 3.0 / 5 - intersection.X) < 0.00000001);
            Assert.AreEqual(true, Math.Abs(4 - 4.0 / 5 - intersection.Y) < 0.00000001);

            line = new LineDefinition()
            {
                k = 4.0 / 3
            };
            headlandLine = new LineDefinition()
            {
                k = -3.0 / 4, b = -25.0 / 4
            };
            intersection = Utility.ChooseHeadlandIntersection(headland, line, 2, headlandLine, new MyPoint3D()
            {
                X = -3, Y = -4
            });
            Assert.AreEqual(true, Math.Abs(-3 + 3.0 / 5 - intersection.X) < 0.00000001);
            Assert.AreEqual(true, Math.Abs(-4 + 4.0 / 5 - intersection.Y) < 0.00000001);



            headland = new List <MyPoint3D>();
            headland.Add(new MyPoint3D()
            {
                X = 90, Y = 10
            });
            headland.Add(new MyPoint3D()
            {
                X = -30, Y = 90
            });
            headland.Add(new MyPoint3D()
            {
                X = 70, Y = 125
            });
            headland.Add(new MyPoint3D()
            {
                X = 90, Y = 10
            });

            line = LineDefinition.GetLineDefinition(new MyPoint3D(), new MyPoint3D()
            {
                X = 15, Y = 60
            });
            headlandLine = LineDefinition.GetLineDefinition(new MyPoint3D()
            {
                X = 90, Y = 10
            }, new MyPoint3D()
            {
                X = -30, Y = 90
            });
            intersection = Utility.ChooseHeadlandIntersection(headland, line, 10, headlandLine, new MyPoint3D()
            {
                X = 15, Y = 60
            });
        }