Esempio n. 1
0
        /// <summary>
        /// Generates point feature representing position of the tree.
        /// Attributes:
        /// id, X, Y, height, DBH, AGB, type
        /// </summary>
        private static Feature GetTreePosition(CTree pTree, ref StringBuilder pString)
        {
            CVector3D globalTreepos = CUtils.GetGlobalPosition(pTree.peak.Center);
            IPoint    myPoint       = factory.CreatePoint(new Coordinate(globalTreepos.X, globalTreepos.Y));

            AttributesTable attributesTable = new AttributesTable();

            attributesTable.Add(ATTR_ID, pTree.treeIndex);
            pString.Append(pTree.treeIndex + SEP);
            shpInfoMain.Append(pTree.treeIndex + SEP);

            attributesTable.Add(ATTR_X, globalTreepos.X.ToString(NUM_FORMAT));
            attributesTable.Add(ATTR_Y, globalTreepos.Y.ToString(NUM_FORMAT));
            pString.Append(globalTreepos.X.ToString(NUM_FORMAT) + SEP);
            shpInfoMain.Append(globalTreepos.X.ToString(NUM_FORMAT) + SEP);
            pString.Append(globalTreepos.Y.ToString(NUM_FORMAT) + SEP);
            shpInfoMain.Append(globalTreepos.Y.ToString(NUM_FORMAT) + SEP);

            float treeHeight = pTree.GetTreeHeight();

            attributesTable.Add(ATTR_HEIGHT, treeHeight.ToString(NUM_FORMAT));
            pString.Append(treeHeight.ToString(NUM_FORMAT) + SEP);
            shpInfoMain.Append(treeHeight.ToString(NUM_FORMAT) + SEP);

            if (CParameterSetter.GetBoolSettings(ESettings.calculateDBH))
            {
                double stemDiameter = CBiomassController.GetTreeStemDiameter(treeHeight);
                attributesTable.Add(ATTR_DBG, stemDiameter.ToString(NUM_FORMAT));
                pString.Append(stemDiameter.ToString(NUM_FORMAT) + SEP);
                shpInfoMain.Append(stemDiameter.ToString(NUM_FORMAT) + SEP);

                if (CParameterSetter.GetBoolSettings(ESettings.calculateAGB))
                {
                    double biomass = CBiomassController.GetTreeBiomass(stemDiameter, treeHeight);
                    attributesTable.Add(ATTR_AGB, biomass.ToString(NUM_FORMAT));
                    pString.Append(biomass.ToString(NUM_FORMAT) + SEP);
                    shpInfoMain.Append(biomass.ToString(NUM_FORMAT) + SEP);
                }
            }

            //251 - Finalizace produktu
            //attributesTable.Add(ATTR_TYPE, pTree.assignedRefTree.RefTreeTypeName);
            //pString.Append(pTree.assignedRefTree.RefTreeTypeName + SEP);

            Feature feature = new Feature(myPoint, attributesTable);

            pString.AppendLine();
            shpInfoMain.AppendLine();

            return(feature);
        }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        private static string GetTreeLines(CTree pTree)
        {
            string output = "";

            foreach (Vector3 p in pTree.Points)
            {
                string color = pTree.isValid ?
                               pTree.assignedMaterial.ToString255() :
                               CMaterialManager.GetInvalidMaterial().ToString255();

                //int treeIndex = pTree.isValid ? pTree.assignedRefTree.treeIndex : 0;
                int treeIndex = pTree.treeIndex;

                CVector3D globalP = CUtils.GetGlobalPosition(p);
                output += GetPointLine(globalP, 5, (byte)treeIndex, color) + newLine;
            }
            return(output);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        private static Feature GetTreeBorder(CTree pTree)
        {
            List <Vector3>    furthestPoints = pTree.GetFurthestPoints();
            List <Coordinate> pointsCoords   = new List <Coordinate>();

            foreach (Vector3 p in furthestPoints)
            {
                CVector3D globalP = CUtils.GetGlobalPosition(p);
                pointsCoords.Add(new Coordinate(globalP.X, globalP.Y));
            }
            pointsCoords.Add(pointsCoords[0]);             //to close polygon

            IPolygon polygon = factory.CreatePolygon(pointsCoords.ToArray());

            //id
            AttributesTable attributesTable = new AttributesTable();

            attributesTable.Add(ATTR_ID, pTree.treeIndex);

            //position
            CVector3D globalTreepos = CUtils.GetGlobalPosition(pTree.peak.Center);

            attributesTable.Add(ATTR_X, globalTreepos.X.ToString(NUM_FORMAT));
            attributesTable.Add(ATTR_Y, globalTreepos.Y.ToString(NUM_FORMAT));

            //area
            attributesTable.Add(ATTR_AREA, pTree.GetArea());

            //tree height
            float treeHeight = pTree.GetTreeHeight();

            attributesTable.Add(ATTR_HEIGHT, treeHeight.ToString(NUM_FORMAT));

            //reftree type
            //attributesTable.Add(ATTR_TYPE, pTree.assignedRefTree.RefTreeTypeName);

            Feature feature = new Feature(polygon, attributesTable);

            return(feature);
        }
Esempio n. 4
0
        /// <summary>
        /// Add points from given class to the output and main output
        /// </summary>
        private static void AddPointsTo(ref StringBuilder pOutput, EClass pClass, ref DateTime start)
        {
            List <Vector3> points = CProjectData.Points.GetPoints(pClass);
            string         res;
            DateTime       lastDebug = DateTime.Now;

            for (int i = 0; i < points.Count; i++)
            {
                if (CProjectData.backgroundWorker.CancellationPending)
                {
                    return;
                }

                CDebug.Progress(i, points.Count, DEBUG_FREQUENCY, ref lastDebug, start, "Export las (ground points)");

                Vector3   p       = points[i];
                CVector3D globalP = CUtils.GetGlobalPosition(p);
                res = GetPointLine(globalP, 1, 0, GetClassColor(pClass)) + newLine;
                pOutput.Append(res);
            }
            //mainOutput.Append(pOutput);
        }