//public static Vector3 ParseHeaderVector3(string pXstring, string pYstring, string pZstring) //{ // float x = float.Parse(pXstring); // float y = float.Parse(pYstring); // float z = float.Parse(pZstring); // return new Vector3(x, y, z); //} public static Tuple <EClass, Vector3> ParseLine(string pLine, bool pUseHeader) { string[] split = pLine.Split(null); if (split.Length < 4 || (split.Length > 0 && split[0].Contains("#"))) { CDebug.WriteLine(pLine + " not valid"); return(null); } double x = double.Parse(split[0]); double y = double.Parse(split[1]); double z = double.Parse(split[2]); int _class = int.Parse(split[3]); //we don't use prescribed coordinate parsing as it produces badly visualisable terrain (with offset etc) //it should not have any effect on data processing Vector3 headerOffset = pUseHeader ? CProjectData.GetOffset() : Vector3.Zero; float xFloat = (float)(x - headerOffset.X); float yFloat = (float)(y - headerOffset.Y); float zFloat = (float)(z - headerOffset.Z); //swap canceled ////swap Y-Z. Y = height in this project //float tmp = yFloat; //yFloat = zFloat; //zFloat = tmp; EClass eClass = (EClass)_class; //Array acceptedClasses = Enum.GetValues(typeof(EClass)); //if(IsAcceptedClass(eClass)) //{ // _class = (int)EClass.Other; //} //if (_class != (int)EClass.Undefined && _class != (int)EClass.Ground && _class != (int)EClass.Vege) //{ // _class = (int)EClass.Other; //} return(new Tuple <EClass, Vector3>(eClass, new Vector3(xFloat, yFloat, zFloat))); }
//class, position, note public static Tuple <int, Vector3, string> ParseLine(string pLine, bool pUseHeader) { string[] split = pLine.Split(null); //line example: //ID X Y Z POZN TYP CISLO_ //556 756123.256 5489291.262 923.47 *STROM403 11 403 //1 756168.829 5489339.169 936.49 rozhrani_plotu 52 if (!double.TryParse(split[1], out double x)) { return(null); } if (!double.TryParse(split[2], out double y)) { return(null); } if (!double.TryParse(split[3], out double z)) { return(null); } string _note = split[4]; if (string.IsNullOrEmpty(_note)) { return(null); } if (!int.TryParse(split[5], out int _class)) { return(null); } if (x > maxInputX) { maxInputX = x; } if (y > maxInputX) { maxInputY = y; } if (x < minInputX) { minInputX = x; } if (y < minInputY) { minInputY = y; } //we don't use prescribed coordinate parsing as it produces badly visualisable terrain (with offset etc) //it should not have any effect on data processing Vector3 headerOffset = pUseHeader ? CProjectData.GetOffset() : Vector3.Zero; float xFloat = (float)(x - headerOffset.X); float yFloat = (float)(y - headerOffset.Y); float zFloat = (float)(z - headerOffset.Z); //swap Y-Z. Y = height in this project float tmp = yFloat; yFloat = zFloat; zFloat = tmp; return(new Tuple <int, Vector3, string>(_class, new Vector3(xFloat, yFloat, zFloat), _note)); }