public void LoadBinary(string filename) { if (!File.Exists(filename)) { throw new ArgumentNullException(filename); } Points.Clear(); using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open))) { int pointsCount = reader.ReadInt32(); for (int i = 0; i < pointsCount; i += 1) { var point = new SurfacePoint { EquipmentId = reader.ReadInt32(), GridX = (float)reader.ReadDouble(), GridY = (float)reader.ReadDouble(), Height = (float)reader.ReadDouble(), Id = reader.ReadInt32(), PrimeElevation = (float)reader.ReadDouble(), SurveyId = reader.ReadInt32(), TerrainTime = new DateTime(reader.ReadInt64()) }; Points.Add(point); } } }
public void LoadCSV(string filename) { if (!File.Exists(filename + CSV)) { throw new ArgumentNullException(filename + CSV); } Points.Clear(); float minH = float.MaxValue; float maxH = float.MinValue; var pointsIgnored = 0; using (var file = new StreamReader(filename + CSV)) { string line; while ((line = file.ReadLine()) != null) { var tokens = line.Split(','); if (tokens.Length == 3) { float x, y, z; if (float.TryParse(tokens[0], out x) && float.TryParse(tokens[1], out y) && float.TryParse(tokens[2], out z) /*&& (height >= 2400f && height <= 3100f)*/) { if (z < minH) { minH = z; } if (z > maxH) { maxH = z; } var point = new SurfacePoint { GridX = x, GridY = y, Height = z }; Points.Add(point); } } else { Console.WriteLine(line); pointsIgnored += 1; } } } if (pointsIgnored > 0) { Console.WriteLine("Ignored:{0}", pointsIgnored); } Console.WriteLine("minH:{0} maxH:{1}", minH, maxH); Points.Sort(); }