Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private void SetRangeY()
        {
            CParameterSetter.SetParameter(ESettings.rangeYmin, form.trackBarRangeYmin.Value);
            CParameterSetter.SetParameter(ESettings.rangeYmax, form.trackBarRangeYmax.Value);

            SSplitRange range = CParameterSetter.GetSplitRange();

            form.textRangeYmin.Text = range.ToStringYmin();
            form.textRangeYmax.Text = range.ToStringYmax();

            form.labelRangeYval.Text = range.RangeY.ToString("0.0") + " m";
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Calculates estimated file size
        /// </summary>
        private static float GetResultFileSize()
        {
            CHeaderInfo header = CProjectData.sourceFileHeader;

            if (header == null)
            {
                return(0);
            }

            arrayHeight = header.Height;
            arrayWidth  = header.Width;
            if ((ESplitMode)CParameterSetter.GetIntSettings(ESettings.currentSplitMode) == ESplitMode.Manual)
            {
                SSplitRange range = CParameterSetter.GetSplitRange();
                arrayWidth  = range.RangeX;
                arrayHeight = range.RangeY;
            }

            float area = arrayWidth * arrayHeight;

            const float treeStructure = .05f;
            const float reftreeSize   = 1;
            const float treeBoxSize   = .01f;

            const float treeDensity = .1f;    //1 tree per 10 squared meters
            float       groundSize  = 5;      //its just small, no reason to count it in

            float totalSize = groundSize;


            if (CParameterSetter.GetBoolSettings(ESettings.exportTreeStructures))
            {
                totalSize += area * treeDensity * treeStructure;
            }
            if (CParameterSetter.GetBoolSettings(ESettings.exportTreeBoxes))
            {
                totalSize += area * treeDensity * treeBoxSize;
            }
            if (CParameterSetter.GetBoolSettings(ESettings.exportRefTrees))
            {
                totalSize += area * treeDensity * reftreeSize;
            }
            return(totalSize);
        }
Ejemplo n.º 4
0
        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;
            }
        }