示例#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);
        }