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 void PointValid() { LASPoint pointB = new LASPoint(); pointB.X = 23.0; Assert.IsTrue(point.IsValid()); Assert.IsTrue(pointB.IsValid()); }
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 ScanFlags() { byte zeros = 0; LASPoint pointS = new LASPoint(); Assert.AreEqual(pointS.ScanFlags, zeros); pointS.ReturnNumber = 3; pointS.NumberOfReturns = 7; pointS.ScanDirection = 0; pointS.FlightLineEdge = 1; string expected = "10111011"; byte bits = pointS.ScanFlags; Assert.AreEqual(Convert.ToString(pointS.ScanFlags, 2), (expected)); LASPoint pointN; pointN = pointS.Copy(); Assert.AreEqual(pointN.ScanFlags, pointS.ScanFlags); }
public void SetPointCoordinates() { LASPoint pointB = new LASPoint(); pointB.X = 23.0; Assert.AreEqual(pointB.X, 23.0); Assert.IsFalse(point.Equals(pointB)); pointB.X = 0.0; point.X = 0.0; Assert.IsTrue(point.Equals(point)); pointB.X = 1.123; pointB.Y = 2.456; pointB.Z = 3.789; LASPoint pointC = new LASPoint(); pointC.X = 1.123; pointC.Y = 2.456; pointC.Z = 3.789; Assert.IsTrue(pointC.Equals(pointB)); }
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; }