public static string LasClip(string classifyFilePath) { string shapefilePath = CParameterSetter.GetStringSettings(ESettings.shapeFilePath); string shapefileName = CUtils.GetFileName(shapefilePath); if (!File.Exists(shapefilePath)) { throw new Exception($"shapefile does not exist. {shapefilePath}"); } string clipFileName = $"{forestFileName}_clip[{shapefileName}]"; string clipFilePath = currentTmpFolder + clipFileName + LAZ; if (File.Exists(clipFilePath)) { return(clipFilePath); //already created } string clip = "lasclip -i " + classifyFilePath + " -poly " + shapefilePath + " -o " + clipFilePath; CCmdController.RunLasToolsCmd(clip, clipFilePath); return(clipFilePath); }
/// <summary> /// Split preprocessed file into tiles and converto to txt /// </summary> internal static List <string> GetTxtFilesPaths(string pPreprocessedFilePath) { List <string> result = new List <string>(); int tileSize = CParameterSetter.GetIntSettings(ESettings.tileSize); string outputFolderPath = GetTiledFilesFolder( CUtils.GetFileName(pPreprocessedFilePath), tileSize); FileInfo[] tiles; //lastile splits file into tiles even if tileSize is bigger //todo: WHY? //=> dont split to tiles if (CProjectData.mainHeader.Width <= tileSize && CProjectData.mainHeader.Height <= tileSize) { tiles = new FileInfo[] { new FileInfo(pPreprocessedFilePath) }; } else { tiles = GetTiledFiles(pPreprocessedFilePath, outputFolderPath, tileSize, CProjectData.bufferSize); } for (int i = 0; i < tiles.Length; i++) { string txtFile = Las2Txt(tiles[i].FullName, outputFolderPath); result.Add(txtFile); } return(result); }
/// <summary> /// Returns path to folder containing tiles of given size. /// If doesnt exist => create it /// </summary> private static string GetTiledFilesFolder(string pSourceFileName, int pTileSize) { string forestFileName = CUtils.GetFileName(CParameterSetter.GetStringSettings(ESettings.forestFileName)); string path = currentTmpFolder + $"_tiles[{pTileSize}]_{pSourceFileName}\\"; Directory.CreateDirectory(path); return(path); }
private static string LasHeight(string pGroundFilePath) { string heightFileName = CUtils.GetFileName(pGroundFilePath) + "_h" + LAZ; string heightFilePath = currentTmpFolder + heightFileName; string height = "lasheight -i " + pGroundFilePath + " -o " + heightFilePath; CCmdController.RunLasToolsCmd(height, heightFilePath); return(heightFilePath); }
private static string LasGround(string pNoiseFilePath) { string groundFileName = CUtils.GetFileName(pNoiseFilePath) + "_g" + LAZ; string groundFilePath = currentTmpFolder + groundFileName; string ground = "lasground_new -i " + pNoiseFilePath + " -o " + groundFilePath; CCmdController.RunLasToolsCmd(ground, groundFilePath); return(groundFilePath); }
private static string LasNoise(string pForestFilePath) { string noiseFileName = CUtils.GetFileName(pForestFilePath) + "_n" + LAZ; string noiseFilePath = currentTmpFolder + noiseFileName; string ground = "lasnoise -i " + pForestFilePath + " -o " + noiseFilePath; CCmdController.RunLasToolsCmd(ground, noiseFilePath); return(noiseFilePath); }
public static void Init() { saveFileName = CUtils.GetFileName( CParameterSetter.GetStringSettings(ESettings.forestFileFullName)); string outputFolderSettings = CParameterSetter.GetStringSettings(ESettings.outputFolderPath); //include the method alias into the main folder name EDetectionMethod method = CTreeManager.GetDetectMethod(); string suffix = CUtils.GetMethodSuffix(method); saveFileName += suffix; outputFolder = CObjExporter.CreateFolderIn(saveFileName, outputFolderSettings); Points = new CPointsHolder(); }
/*private static void LasMerge(List<string> pClassifyFilePaths) * { * //string pathsString = ""; * //foreach(string path in pClassifyFilePaths) * //{ * // pathsString += path + " "; * //} * * string merge = * "lasmerge -i " + * currentTmpFolder + "*_c" + LAZ + * " -o " + preprocessedFilePath; * CCmdController.RunLasToolsCmd(merge, preprocessedFilePath); * }*/ private static string LasClassify(string pHeightFilePath) { //string classifyFileName = forestFileName + "_c" + LAZ; //string classifyFilePath = tmpFolder + classifyFileName; string classifyFileName = CUtils.GetFileName(pHeightFilePath) + "_c" + LAZ; string classifyFilePath = currentTmpFolder + classifyFileName; string classify = "lasclassify -i " + pHeightFilePath + " -o " + classifyFilePath; CCmdController.RunLasToolsCmd(classify, classifyFilePath); return(classifyFilePath); }
internal static string Las2Txt(string splitFilePath, string pOutputFolder) { string splitFileName = CUtils.GetFileName(splitFilePath); //use split file name to get unique file name string txtFileName = splitFileName + ".txt"; string txtFilePath = pOutputFolder + txtFileName; string toTxt = "las2txt -i " + splitFilePath + " -o " + txtFilePath + " -parse xyzc -sep tab -header percent"; CCmdController.RunLasToolsCmd(toTxt, txtFilePath); return(txtFilePath); }
/// <summary> /// Get info from preprocessed file using lasinfo and set it to main header /// </summary> private static void SetMainHeader(string pPreprocessedFilePath) { //FileInfo fi = new FileInfo(pPreprocessedFilePath); string infoFilePath = CPreprocessController.currentTmpFolder + "\\" + CUtils.GetFileName(pPreprocessedFilePath) + "_i.txt"; string[] headerLines = CPreprocessController.GetHeaderLines(pPreprocessedFilePath, infoFilePath); if (headerLines == null) { CDebug.Error("header lines are null"); //todo: is it ok to leave it as null?? //CProjectData.mainHeader = new CHeaderInfo(); } else { CProjectData.mainHeader = new CHeaderInfo(headerLines); } //can be inited only after main header is set CBitmapExporter.Init(); }