public void hhhhh() { // LASReader lasreader = new LASReader(@"c:\las\sample_our2.las"); LASReader lasreader = new LASReader(@"C:\las\data\TO_core_last_clip.las"); LASPoint laspoint; //laspoint = lasreader.GetPointAt(0); //Console.WriteLine(laspoint.X + "," + laspoint.Y + "," + laspoint.Z + " " + laspoint.Intensity ); LASHeader lasheader = lasreader.GetHeader(); LASWriter laswriter = new LASWriter(@"c:\las\sample_our.las", lasheader, LASReadWriteMode.LASModeWrite); //LASReader lasreader = new LASReader(@"C:\las\data\TO_core_last_clip.las"); //LASPoint laspoint = new LASPoint(); laspoint = lasreader.GetPointAt(0); //laspoint.X = 23.0; //Assert.AreEqual(laspoint.X, 23.0); //byte gg = laspoint.Classification; //bool d = lasreader.GetNextPoint(); ////d = lasreader.GetNextPoint(); //LASPoint point = lasreader.GetPointAt(1); //Assert.LessOrEqual(Math.Abs(point.X - 630262.30), 0.0001); //Assert.LessOrEqual(Math.Abs(point.Y - 4834500.0), 0.0001); //Assert.LessOrEqual(Math.Abs(point.Z - 51.53), 0.0001); Assert.AreEqual(laspoint.Intensity, 670); // Assert.AreEqual(laspoint.Classification,(byte) 1); //Assert.AreEqual(point.ScanAngleRank, 0); //Assert.AreEqual(point.UserData, 3); //Assert.AreEqual(point.ScanFlags, 9); //Assert.LessOrEqual(Math.Abs(point.Time - 413665.23360000004), 0.0001); }
static void Main(string[] args) { try { string filename = @".\test.las"; LASHeader hdr = new LASHeader(); hdr.VersionMajor = 1; hdr.VersionMinor = 1; hdr.DataFormatId = (byte)LASHeader.PointFormat.ePointFormat1; hdr.PointRecordsCount = 1000; // should be corrected automatically by writer LASWriter laswriter = new LASWriter(filename, hdr, LASReadWriteMode.LASModeWrite); LASPoint p = new LASPoint(); p.X = 10; p.Y = 20; p.Z = 30; laswriter.WritePoint(p); //File.Delete(filename); } catch (LASException e) { Console.WriteLine("\nLASException! Msg: {0}", e.Message); } catch (SystemException e) { Console.WriteLine("\nException! Msg: {0}", e.Message); } catch { Console.WriteLine("Unknown exception caught"); } Console.WriteLine("End of file"); Console.Read(); }
public QTree(LasDataManager dMgr, LASFile lasfile) { TreeID = Guid.NewGuid(); las_header = lasfile.header; int num_Leafs = (int)las_header.NumberOfPointRecords / POINTS_PER_LEAF; double d = Math.Sqrt((double)las_header.NumberOfPointRecords / POINTS_PER_LEAF); NumberOfTreeLevels = (int)Math.Ceiling(Math.Log(d, 2)) + 1; double nodesOneSide = Math.Pow(2, NumberOfTreeLevels - 1); double currLeafs = nodesOneSide * nodesOneSide; double dWidth = las_header.MaxX - las_header.MinX; double dHeight = las_header.MaxY - las_header.MinY; QTreeNode.MAX_WIDTH = (float)(dWidth / nodesOneSide); QTreeNode.MAX_HEIGHT = (float)(dHeight / nodesOneSide); Console.WriteLine("Creating QTree"); Console.WriteLine("Map width={0} height={1}", dWidth, dHeight); Console.WriteLine("Calculated points per leaf: {0} , actual: {1}, leafs: {2}", POINTS_PER_LEAF, (double)las_header.NumberOfPointRecords / (double)currLeafs, currLeafs); Console.WriteLine("Node width={0} height={1}", QTreeNode.MAX_WIDTH, QTreeNode.MAX_HEIGHT); //init qleaf direct access array numberOfLeafs = (int)currLeafs; root = new QTreeNode(new BoundingBox(0, 0, (float)dWidth, (float)dHeight), this, null, 0); Console.WriteLine("Created nodes={0}", QTreeNode.NUM_NODES); }
public static void Create(LASHeader header, LASPointExtraBytes[] extra) { GetAttributes(header.PointDataRecordFormat); if (extra != null) { // convert the extra byte definitions } }
public void FileSignature() { LASHeader header = new LASHeader(); // string sig = "LASF and garbage"; Assert.AreEqual(header.FileSignature.Length, 4); Assert.AreEqual(header.FileSignature, "LASF"); // I can not set FileSignature from c# API because i am a bad guy. //header.FileSignature = "LASF"; }
public void ProjectId() { LASHeader h = new LASHeader(); //string strid="030B4A82-1B7C-11CF-9D53-00AA003C9CB6"; // Assert.AreEqual(h.Reserved, 0); // liblas::guid id(strid.c_str()); // h.ProjectId=; // std::string strid("030B4A82-1B7C-11CF-9D53-00AA003C9CB6"); //liblas::guid id(strid.c_str()); //liblas::LASHeader h; //h.SetProjectId(id); //ensure_not(h.GetProjectId().is_null()); //ensure_equals(h.GetProjectId(), id); }
public void FileSourceId() { LASHeader h1 = new LASHeader(); UInt16 id1 = 1; UInt16 id2 = 65535; UInt16 overflowed = 0; h1.FileSourceId = id1; Assert.AreEqual(h1.FileSourceId, id1); h1.FileSourceId = id2; Assert.AreEqual(h1.FileSourceId, id2); // Unsigned overflow // Likely compiler warning: truncation from int to liblas::uint16_t h1.FileSourceId = (ushort)(id2 + 1); Assert.AreEqual(h1.FileSourceId, overflowed); }
static void Main(string[] args) { try { LASReader lasreader = new LASReader(@"c:\las\sample_our2.las"); LASPoint laspoint; LASHeader lasheader = lasreader.GetHeader(); Console.WriteLine(lasheader.SoftwareId);// lasheader.VersionMinor = 0; LASWriter laswriter = new LASWriter(@"c:\las\sample_our.las", lasheader, LASReadWriteMode.LASModeWrite); Console.WriteLine("Number of points in file= {0}", lasheader.PointRecordsCount); while (lasreader.GetNextPoint()) { laspoint = lasreader.GetPoint(); laspoint.X = laspoint.X + 3; //Console.WriteLine(laspoint.X + "," + laspoint.Y + "," + laspoint.Z); laswriter.WritePoint(laspoint); } } catch (LASException e) { Console.WriteLine("\nLASException! Msg: {0}", e.Message); } catch (SystemException e) { Console.WriteLine("\nException! Msg: {0}", e.Message); } catch { Console.WriteLine("Unknown exception caught"); } finally { Console.WriteLine("Do i need something to do?"); } Console.WriteLine("End of file"); Console.Read(); }
public void SoftwareId() { LASHeader h = new LASHeader(); string softid1 = "Short Soft Id"; // 13 bytes int len1 = softid1.Length; string softid2 = "Long Software Identifier - XX YY"; // 32 bytes int len2 = softid2.Length; h.SoftwareId = softid1; Assert.AreEqual(h.SoftwareId, softid1); Assert.AreEqual(h.SoftwareId.Length, len1); // Assert.AreEqual(h.GetSoftwareId(true).size(), 32); h.SoftwareId = softid2; Assert.AreEqual(h.SoftwareId, softid2); Assert.AreEqual(h.SoftwareId.Length, len2); // Assert.AreEqual(h.GetSoftwareId(true).size(), 32); }
public void CopyConstructor() { LASHeader header = new LASHeader(); // string sig = "LASF and garbage"; // header.FileSignature = sig; // Assert.AreEqual(header.FileSignature.Length,4); // LASHeader h1; Assert.AreEqual(1, 1); //h1.SetFileSignature(sig); //ensure_not(h1.GetFileSignature() == sig); //ensure_equals(h1.GetFileSignature().size(), 4); //ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature); //LASHeader h2(h1); //ensure_not(h2.GetFileSignature() == sig); //ensure_equals(h2.GetFileSignature().size(), 4); //ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature); }
static void Main(string[] args) { try { string filename = @"..\..\..\..\..\test\data\TO_core_last_zoom.las"; LASReader lasreader = new LASReader(filename); LASHeader h = lasreader.GetHeader(); Console.WriteLine("Version : " + lasreader.GetVersion()); Console.WriteLine("Signature: : " + h.FileSignature); Console.WriteLine("Format : " + h.DataFormatId); Console.WriteLine("Project : " + h.ProjectId); Console.WriteLine("Points count: " + h.PointRecordsCount); Console.WriteLine("VLRecords count: " + h.VariableLengthRecordsCount); int counter = 0; while (lasreader.GetNextPoint()) { LASPoint laspoint = lasreader.GetPoint(); counter += 1; } if (lasreader.GetHeader().PointRecordsCount != counter) { throw new LASException("read incorrect number of point records"); } } catch (LASException e) { Console.WriteLine("\nLASException! Msg: {0}", e.Message); } catch (SystemException e) { Console.WriteLine("\nException! Msg: {0}", e.Message); } catch { Console.WriteLine("Unknown exception caught"); } Console.WriteLine("End of file"); Console.Read(); }
public void PointRecordsByReturnCount() { LASHeader h = new LASHeader(); // Assert.AreEqual(h.GetPointRecordsByReturnCount(5),5); h.SetPointRecordsByReturnCount(0, 100); //ensure_equals(h.GetPointRecordsByReturnCount().size(), 5); Assert.AreEqual(h.GetPointRecordsByReturnCount(0), 100); h.SetPointRecordsByReturnCount(1, 101); //ensure_equals(h.GetPointRecordsByReturnCount().size(), 5); Assert.AreEqual(h.GetPointRecordsByReturnCount(1), 101); h.SetPointRecordsByReturnCount(2, 102); //ensure_equals(h.GetPointRecordsByReturnCount().size(), 5); Assert.AreEqual(h.GetPointRecordsByReturnCount(2), 102); h.SetPointRecordsByReturnCount(3, 103); //ensure_equals(h.GetPointRecordsByReturnCount().size(), 5); Assert.AreEqual(h.GetPointRecordsByReturnCount(3), 103); h.SetPointRecordsByReturnCount(4, 104); //ensure_equals(h.GetPointRecordsByReturnCount().size(), 5); Assert.AreEqual(h.GetPointRecordsByReturnCount(4), 104); try { // 5 is out of range h.SetPointRecordsByReturnCount(5, 500); //don´t get the next line... Assert.AreEqual(2, 5); } catch (LASException e) { Assert.AreEqual(e.Message, "Exception in Set Header SetPointRecordsByReturnCount."); } }
public void MinorMajorVersion() { LASHeader h = new LASHeader(); h.VersionMinor = 0; h.VersionMajor = 1; Assert.AreEqual(h.VersionMinor, 0); Assert.AreEqual(h.VersionMajor, 1); h.VersionMinor = 1; h.VersionMajor = 1; Assert.AreEqual(h.VersionMinor, 1); Assert.AreEqual(h.VersionMajor, 1); try { h.VersionMajor = 2; //don´t get the next line... Assert.AreEqual(2, 5); } catch (LASException e) { Assert.AreEqual(e.Message, "Exception in Set Header VersionMajor."); } try { h.VersionMinor = 2; //don´t get the next line... Assert.AreEqual(2, 5); } catch (LASException e) { Assert.AreEqual(e.Message, "Exception in Set Header VersionMinor."); } }
public void Reserved() { LASHeader h = new LASHeader(); Assert.AreEqual(h.Reserved, 0); }
public LASFile(string filename, int pointsToStore) { IsLoaded = false; using (LASReader reader = new LASReader(filename)) using (LASHeader header = reader.GetHeader()) { ProjectID = header.ProjectId; Signature = header.FileSignature; NumPoints = header.PointRecordsCount; XOffset = header.GetMinX(); YOffset = header.GetMinY(); ZOffset = header.GetMinZ(); XExtent = header.MaxX() - XOffset; YExtent = header.GetMaxY() - YOffset; ZExtent = header.GetMaxZ() - ZOffset; chunks = new List <LASChunk>((int)(NumPoints / LASChunk.ChunkSize + 1)); LASChunk curChunk = new LASChunk(0); long curOffset = 0, stored = 0; long pointSkip = NumPoints / pointsToStore; if (pointSkip <= 0) { pointSkip = 1; } while (reader.GetNextPoint()) { curOffset++; if (curOffset % pointSkip == 0) { LASPoint point = reader.GetPoint(); if (point.ReturnNumber > 1) { curOffset--; continue; } curChunk.Points.Add( new LPoint() { X = (float)(point.X - XOffset), Y = (float)(point.Y - YOffset), Z = (float)(point.Z - ZOffset), Intensity = (float)point.Intensity } ); stored++; if (curChunk.Points.Count >= LASChunk.ChunkSize) { chunks.Add(curChunk); curChunk = new LASChunk(curOffset); } } } if (curChunk.Points.Count > 0) { chunks.Add(curChunk); } StoredPoints = stored; } Filename = filename; IsLoaded = true; }