private static void CheckAGB() { string problem = CBiomassController.IsValidEquation(CParameterSetter.GetStringSettings(ESettings.agb)); if (problem.Length > 0) { problems.Add($"DBH equation problem: {problem}"); } }
/// <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); }
public static EProcessResult Start() { CSequenceController.SetValues(); DateTime startTime = DateTime.Now; CProjectData.Init(); CTreeManager.Init(); CAnalytics.Init(); CDartTxt.Init(); CLasExporter.Init(); CBiomassController.Init( CParameterSetter.GetStringSettings(ESettings.dbh), CParameterSetter.GetStringSettings(ESettings.agb)); CTreeRadiusCalculator.Init(); CShpController.Init(); CReftreeManager.Init(); Thread.CurrentThread.CurrentCulture = new CultureInfo("en"); //GENERAL CProjectData.useMaterial = true; CObjExporter.simplePointsObj = false; CMaterialManager.Init(); string[] workerResult = new string[2]; workerResult[0] = "this string"; workerResult[1] = "some other string"; CProjectData.backgroundWorker.ReportProgress(10, workerResult); try { List <string> tiledFiles = CProgramLoader.GetTiledPreprocessedFilePaths(); tilesCount = tiledFiles.Count; int startTile = CParameterSetter.GetIntSettings(ESettings.startIndex); if (startTile < 0 || startTile >= tiledFiles.Count) { throw new Exception($"Parameter startTile = {startTile}, tiledFiles.Count = {tiledFiles.Count}"); } for (int i = startTile; i < tiledFiles.Count; i++) { string tiledFilePath = tiledFiles[i]; EProcessResult tileProcess = ProcessTile(tiledFilePath, i); if (CProjectData.backgroundWorker.CancellationPending) { break; } } } catch (Exception e) { CDebug.Error( $"{Environment.NewLine}exception: {e.Message} {Environment.NewLine}{Environment.NewLine}" + $"StackTrace: {e.StackTrace}{Environment.NewLine}"); OnException(); return(EProcessResult.Exception); } if (CProjectData.backgroundWorker.CancellationPending) { CDebug.Step(EProgramStep.Cancelled); return(EProcessResult.Cancelled); } CDebug.Step(EProgramStep.ExportMainFiles); //TODO: implement this in super class for all controllers //dont create the main file if not needed if (tilesCount > 1) { CDartTxt.ExportMain(); CLasExporter.ExportMain(); CShpController.ExportMain(); } CBitmapExporter.ExportMain(); CDebug.Step(EProgramStep.Done); if (CSequenceController.IsLastSequence()) { CSequenceController.OnLastSequenceEnd(); return(EProcessResult.Done); } CSequenceController.currentConfigIndex++; return(Start()); }