Пример #1
0
        //TODO: Add more test case for other soil types
        public void ConfirmRingRadius(string Tree, double expected, int ring)
        {
            RingTestData rtd = new RingTestData()
            {
                Tree           = Tree,
                ExpectedRadius = expected,
                ExpectedIndex  = ring
            };

            double calculated = RunTest <double>(nameof(ConfirmRingRadiusResident), rtd);

            Assert.AreEqual(rtd.ExpectedRadius, calculated, 0);
        }
Пример #2
0
        public double ConfirmRingRadiusResident(RingTestData rtd)
        {
            Document acDoc   = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acDoc.TransactionManager.StartTransaction())
            {
                Tree newTree = new Tree();
                newTree.Phase    = Phase.Existing;
                newTree.Species  = rtd.Tree;
                newTree.Location = new Autodesk.AutoCAD.Geometry.Point3d(0, 0, 0);

                bool   found      = false;
                double startDepth = 0;

                if (Tree.DeciduousHigh.ContainsKey(rtd.Tree))
                {
                    newTree.ActualHeight = Tree.DeciduousHigh[rtd.Tree];
                    newTree.TreeType     = TreeType.Deciduous;
                    newTree.WaterDemand  = WaterDemand.High;
                    found      = true;
                    startDepth = 1;
                }

                if (Tree.DeciduousMedium.ContainsKey(rtd.Tree))
                {
                    newTree.ActualHeight = Tree.DeciduousHigh[rtd.Tree];
                    newTree.TreeType     = TreeType.Deciduous;
                    newTree.WaterDemand  = WaterDemand.Medium;
                    found      = true;
                    startDepth = 0.9;
                }

                if (Tree.DeciduousLow.ContainsKey(rtd.Tree))
                {
                    newTree.ActualHeight = Tree.DeciduousHigh[rtd.Tree];
                    newTree.TreeType     = TreeType.Deciduous;
                    newTree.WaterDemand  = WaterDemand.Low;
                    found      = true;
                    startDepth = 0.75;
                }

                if (Tree.ConiferousHigh.ContainsKey(rtd.Tree))
                {
                    newTree.ActualHeight = Tree.DeciduousHigh[rtd.Tree];
                    newTree.TreeType     = TreeType.Coniferous;
                    newTree.WaterDemand  = WaterDemand.High;
                    found      = true;
                    startDepth = 1;
                }

                if (Tree.ConiferousMedium.ContainsKey(rtd.Tree))
                {
                    newTree.ActualHeight = Tree.DeciduousHigh[rtd.Tree];
                    newTree.TreeType     = TreeType.Coniferous;
                    newTree.WaterDemand  = WaterDemand.Medium;
                    found      = true;
                    startDepth = 0.9;
                }

                if (!found)
                {
                    return(-1);
                }

                var    rings = newTree.DrawRings(Shrinkage.High, startDepth, 0.3);
                Circle c     = rings[rtd.ExpectedIndex] as Circle;

                return(c.Radius);
            }
        }