public static string LasSplit(string classifyFilePath) { SSplitRange range = CParameterSetter.GetSplitRange(); if (!range.IsValid()) { throw new Exception($"range {range} is not valid"); } string splitFileName = $"{forestFileName}_s[{range.MinX},{range.MinY}]-[{range.MaxX},{range.MaxY}]"; string keepXY = $" -keep_xy {range.MinX} {range.MinY} {range.MaxX} {range.MaxY}"; string splitFilePath = currentTmpFolder + splitFileName + LAZ; if (File.Exists(splitFilePath)) { return(splitFilePath); //already created } string split = "lassplit -i " + classifyFilePath + keepXY + " -o " + splitFilePath; //todo: when split file not created there is no error...(ie when invalid range is given) try { //todo: split fails on jen2_merged_preprocessed.laz CCmdController.RunLasToolsCmd(split, splitFilePath); } catch (Exception e) { //split command creates file with other name... CDebug.WriteLine($"exception {e}"); } //for some reason output split file gets appendix: "_0000000" => rename it #region rename //rename split file //todo: move to Utils string sourceFile = splitFileName + "_0000000" + LAZ; FileInfo fi = new FileInfo(currentTmpFolder + sourceFile); if (fi.Exists) { fi.MoveTo(currentTmpFolder + splitFileName + LAZ); Console.WriteLine("Split file Renamed."); } else { //todo: implement my own exception throw new Exception($"Split file not created. Perhaps there are no points at range {range}?"); } #endregion return(splitFilePath); }
private static void CheckRange() { switch ((ESplitMode)CParameterSetter.GetIntSettings(ESettings.currentSplitMode)) { case ESplitMode.Manual: SSplitRange range = CParameterSetter.GetSplitRange(); if (!range.IsValid()) { problems.Add($"range {range} is not valid"); } break; case ESplitMode.Shapefile: string shapefilePath = CParameterSetter.GetStringSettings(ESettings.shapeFilePath); if (!File.Exists(shapefilePath)) { problems.Add($"shapefile not defined. {shapefilePath}"); } break; } }