Compare commits

..

No commits in common. "5af930b4ea27c7ec4f237441fb12b407f545db47" and "c966dfe4e9fee22baf4a97601462fafd1b5e6283" have entirely different histories.

7 changed files with 142 additions and 100 deletions

View File

@ -62,7 +62,6 @@ namespace LASFormat
Header = new FileHeader(); Header = new FileHeader();
Header.ReadHeader(source); // Reads intrinsics from the stream, such as Header.ReadHeader(source); // Reads intrinsics from the stream, such as
// Reflective PDR type
PDRType = Type.GetType("LASRead.LASFormat.PDR" + Header.PointDataRecordFormat.ToString()); PDRType = Type.GetType("LASRead.LASFormat.PDR" + Header.PointDataRecordFormat.ToString());
@ -75,7 +74,7 @@ namespace LASFormat
VLRStart = Header.HeaderSize; VLRStart = Header.HeaderSize;
VLRHeader initial = new VLRHeader(); VLRHeader initial = new VLRHeader();
initial.ReadRecords(VLRStream); initial.ReadRecords(VLRStream);
vlrCollection = new RecordCollection(ref VLRStream, VLRStart, Header.NumberVLRs, initial); vlrCollection = new RecordCollection(VLRStream, VLRStart, Header.NumberVLRs, initial);
// Grab a starting PDR // Grab a starting PDR
PDRStart = Header.DataOffset; PDRStart = Header.DataOffset;
@ -84,16 +83,12 @@ namespace LASFormat
PDRStream = GetOffsetStream(source, PDRSize); PDRStream = GetOffsetStream(source, PDRSize);
byte[] pdrInitial = new byte[Header.PointDataRecordLength]; byte[] pdrInitial = new byte[Header.PointDataRecordLength];
PDRStream.Read(pdrInitial, 0, Header.PointDataRecordLength); PDRStream.Read(pdrInitial, 0, Header.PointDataRecordLength);
// Convert the PDRF to our PDR types. Uses System.Reflections to find the value and avoid the use of switch-case. // Convert the PDRF to our PDR types. Uses System.Reflections to find the value and avoid the use of switch-case.
// Use generics to identify the PDR type. // Use generics to identify the PDR type.
// i.e., Reflections looks for the class 'LASRead.LASFormat.PDR<value>' and uses that as the type of the following methods
// at runtime.
// We use Activator.CreateInstance to instance this unknown type (which we assert must be an instance of IPointDataRecord)
Type t = Type.GetType("LASRead.LASFormat.PDR" + Header.PointDataRecordFormat.ToString()); Type t = Type.GetType("LASRead.LASFormat.PDR" + Header.PointDataRecordFormat.ToString());
IPointDataRecord initialPoint = (IPointDataRecord)Activator.CreateInstance(t); IPointDataRecord initialPoint = (IPointDataRecord)Activator.CreateInstance(t);
initialPoint.ReadPoint(pdrInitial); initialPoint.ReadPoint(pdrInitial);
// Using generics to dynamically create a PDRCollection<PDR[type]> storage // Using generics to dynamically create a PDRCollection<PDR*> storage
points = Activator.CreateInstance(typeof(PDRCollection<>).MakeGenericType(PDRType), new object[] { Header, PDRStream, initialPoint}); points = Activator.CreateInstance(typeof(PDRCollection<>).MakeGenericType(PDRType), new object[] { Header, PDRStream, initialPoint});
PointsType = Type.GetTypeArray(new object[] { points })[0]; PointsType = Type.GetTypeArray(new object[] { points })[0];
// Grab a starting EVLR // Grab a starting EVLR
@ -103,7 +98,7 @@ namespace LASFormat
EVLRStream = GetOffsetStream(source, EVLRSize); EVLRStream = GetOffsetStream(source, EVLRSize);
EVLRHeader evlrInitial = new EVLRHeader(); EVLRHeader evlrInitial = new EVLRHeader();
evlrInitial.ReadRecords(EVLRStream); evlrInitial.ReadRecords(EVLRStream);
evlrCollection = new RecordCollection(ref EVLRStream, EVLRStart, Header.NumberOfExtendedVLRs, evlrInitial); evlrCollection = new RecordCollection(EVLRStream, EVLRStart, Header.NumberOfExtendedVLRs, evlrInitial);
// Finally, set the stream back to the starting position // Finally, set the stream back to the starting position
source.Position = 0; source.Position = 0;
// TODO: Grab a starting Waveform // TODO: Grab a starting Waveform
@ -146,7 +141,6 @@ namespace LASFormat
source.Read(buffer, 0, remaining); source.Read(buffer, 0, remaining);
newStream.Write(buffer, 0, remaining); newStream.Write(buffer, 0, remaining);
} }
newStream.Position = 0;
return newStream; return newStream;
} }

View File

@ -335,10 +335,10 @@ namespace LASRead.LASFormat
sb.Append("PointDataLength: " + PointDataRecordLength.ToString() + Environment.NewLine); sb.Append("PointDataLength: " + PointDataRecordLength.ToString() + Environment.NewLine);
sb.Append("Legacy #PDRs: " + LegacyNumberOfPointRecords.ToString() + Environment.NewLine); sb.Append("Legacy #PDRs: " + LegacyNumberOfPointRecords.ToString() + Environment.NewLine);
sb.Append("Legacy #PDR returns: "); sb.Append("Legacy #PDR returns: ");
for (int i = 0; i < LegacyNumberOfPointByReturn.Length; i++) foreach (uint legacyReturn in LegacyNumberOfPointByReturn)
{ {
uint legacyReturn = LegacyNumberOfPointByReturn[i]; sb.Append(legacyReturn);
sb.Append($"{i+1}: {legacyReturn} "); sb.Append(" ");
} }
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);
sb.Append("X Scale Factor: " + X_scaleFactor.ToString() + Environment.NewLine); sb.Append("X Scale Factor: " + X_scaleFactor.ToString() + Environment.NewLine);

View File

@ -6,26 +6,26 @@ namespace LASRead.LASFormat
{ {
/// <summary> /// <summary>
/// LAS Data Payloads are in the Point Data Record (PDR) format <br /> /// LAS Data Payloads are in the Point Data Record (PDR) format <br />
/// PDR formats 0-5 share the same basic substructure (which is ultimately inherited from this interface) <br /> /// PDR 0-5 share the same basic substructure (which is inherited from this interface, <br />
/// PDR 6-10 share a slightly different substructure (more flags) /// PDR 6-10 share a slightly different substructure (more flags)
/// </summary> /// </summary>
public interface IPointDataRecord public interface IPointDataRecord
{ {
public int X { get; set; } int X { get; set; }
public int Y { get; set; } int Y { get; set; }
public int Z { get; set; } int Z { get; set; }
public ushort? Intensity { get; set; } Nullable<ushort> Intensity { get; set; }
public byte ReturnNumberFlag_value { get; set; } byte ReturnNumberFlag_value { get; set; }
public byte NumberOfReturnsFlag_value { get; set; } byte NumberOfReturnsFlag_value { get; set; }
public byte ScanDirectionFlag_value { get; set; } byte ScanDirectionFlag_value { get; set; }
public byte EdgeOfFlightLineFlag_value { get; set; } byte EdgeOfFlightLineFlag_value { get; set; }
public byte Classification { get; set; } byte Classification { get; set; }
public sbyte ScanAngleRank { get; set; } sbyte ScanAngleRank { get; set; }
public byte? UserData { get; set; } Nullable<byte> UserData { get; set; }
public ushort PointSourceID { get; set; } ushort PointSourceID { get; set; }
public bool ReadPoint(byte[] data); bool ReadPoint(byte[] data);
/// <summary> /// <summary>
/// Reads the flags from the supplied byte /// Reads the flags from the supplied byte
@ -47,23 +47,33 @@ namespace LASRead.LASFormat
class PDR0 : IPointDataRecord class PDR0 : IPointDataRecord
{ {
const int headerSize = 20; int x;
/// <summary> int y;
/// PDRs for the X,Y,Z are 4-byte integers. They are multiplied by the scale defined in the int z;
/// header to determine the true (potentially non-integral) coordinate of the point ushort? intensity;
/// </summary> byte returnNumberFlag_value;
public int X { get; set; } byte numberOfReturnsFlag_value;
public int Y { get; set; } byte scanDirectionFlag_value;
public int Z { get; set; } byte edgeOfFlightLineFlag_value;
public ushort? Intensity { get; set; } byte classification;
public byte ReturnNumberFlag_value { get; set; } sbyte scanAngleRank;
public byte NumberOfReturnsFlag_value { get; set; } byte? userData;
public byte ScanDirectionFlag_value { get; set; } ushort pointSourceID;
public byte EdgeOfFlightLineFlag_value { get; set; }
public byte Classification { get; set; } public static readonly int headerSize = 20;
public sbyte ScanAngleRank { get; set; }
public byte? UserData { get; set; } public int X { get => x; set => x = value; }
public ushort PointSourceID { get; set; } public int Y { get => y; set => y = value; }
public int Z { get => z; set => z = value; }
public ushort? Intensity { get => intensity; set => intensity = value; }
public byte ReturnNumberFlag_value { get => returnNumberFlag_value; set => returnNumberFlag_value = value; }
public byte NumberOfReturnsFlag_value { get => numberOfReturnsFlag_value; set => numberOfReturnsFlag_value = value; }
public byte ScanDirectionFlag_value { get => scanDirectionFlag_value; set => scanDirectionFlag_value = value; }
public byte EdgeOfFlightLineFlag_value { get => edgeOfFlightLineFlag_value; set => edgeOfFlightLineFlag_value = value; }
public byte Classification { get => classification; set => classification = value; }
public sbyte ScanAngleRank { get => scanAngleRank; set => scanAngleRank = value; }
public byte? UserData { get => userData; set => userData = value; }
public ushort PointSourceID { get => pointSourceID; set => pointSourceID = value; }
public virtual bool ReadFlag(Tuple<byte, byte> source) public virtual bool ReadFlag(Tuple<byte, byte> source)
{ {
@ -90,15 +100,15 @@ namespace LASRead.LASFormat
{ {
if (DataHelpers.VerifySize(data, headerSize)) if (DataHelpers.VerifySize(data, headerSize))
{ {
X = BitConverter.ToInt32(data, 0); x = BitConverter.ToInt32(data, 0);
Y = BitConverter.ToInt32(data, 4); y = BitConverter.ToInt32(data, 4);
Z = BitConverter.ToInt32(data, 8); z = BitConverter.ToInt32(data, 8);
Intensity = BitConverter.ToUInt16(data, 12); intensity = BitConverter.ToUInt16(data, 12);
ReadFlag(Tuple.Create(data[14], (byte)0)); ReadFlag(Tuple.Create(data[14], (byte)0));
Classification = data[15]; classification = data[15];
ScanAngleRank = (sbyte)data[16]; scanAngleRank = (sbyte)data[16];
UserData = data[17]; userData = data[17];
PointSourceID = BitConverter.ToUInt16(data, 18); pointSourceID = BitConverter.ToUInt16(data, 18);
return true; return true;
} }
else return false; else return false;
@ -128,11 +138,11 @@ namespace LASRead.LASFormat
sb.Append("Intensity: " + Intensity.ToString() + Environment.NewLine); sb.Append("Intensity: " + Intensity.ToString() + Environment.NewLine);
sb.Append("Return Number: " + ReturnNumberFlag_value.ToString() + Environment.NewLine); sb.Append("Return Number: " + ReturnNumberFlag_value.ToString() + Environment.NewLine);
sb.Append("Number of Returns: " + NumberOfReturnsFlag_value.ToString() + Environment.NewLine); sb.Append("Number of Returns: " + NumberOfReturnsFlag_value.ToString() + Environment.NewLine);
sb.Append("Scan Direction: " + (ReturnNumberFlag_value == 0 ? "+" : "-") + Environment.NewLine); sb.Append("Scan Direction: " + (returnNumberFlag_value == 0 ? "+" : "-") + Environment.NewLine);
sb.Append("Edge of Flight Line: " + (ReturnNumberFlag_value == 0 ? "no" : "yes") + Environment.NewLine); sb.Append("Edge of Flight Line: " + (returnNumberFlag_value == 0 ? "no" : "yes") + Environment.NewLine);
sb.Append("Classification: " + ((Classifications)Classification) + Environment.NewLine); sb.Append("Classification: " + ((Classifications)Classification) + Environment.NewLine);
sb.Append("Scan Angle Rank: " + ScanAngleRank.ToString() + Environment.NewLine); sb.Append("Scan Angle Rank: " + ScanAngleRank.ToString() + Environment.NewLine);
sb.Append("User Data: " + (UserData == 0 ? "no" : "yes") + Environment.NewLine); sb.Append("User Data: " + (userData == 0 ? "no" : "yes") + Environment.NewLine);
sb.Append("Point Data Source: " + PointSourceID.ToString() + Environment.NewLine); sb.Append("Point Data Source: " + PointSourceID.ToString() + Environment.NewLine);
return sb.ToString(); return sb.ToString();
@ -157,8 +167,8 @@ namespace LASRead.LASFormat
BitConverter.GetBytes(Intensity ?? 0).CopyTo(result, 12); BitConverter.GetBytes(Intensity ?? 0).CopyTo(result, 12);
MergeFlags().CopyTo(result, 14); MergeFlags().CopyTo(result, 14);
result[15] = Classification; result[15] = Classification;
result[16] = (byte)ScanAngleRank; result[16] = (byte)scanAngleRank;
result[17] = UserData ?? 0; result[17] = userData ?? 0;
BitConverter.GetBytes(PointSourceID).CopyTo(result, 18); BitConverter.GetBytes(PointSourceID).CopyTo(result, 18);
return result; return result;
} }
@ -166,7 +176,7 @@ namespace LASRead.LASFormat
class PDR1 : PDR0 class PDR1 : PDR0
{ {
double GPSTime; double GPSTime;
const int headerSize = 28; new public static readonly int headerSize = 28;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
if (DataHelpers.VerifySize(data, headerSize)) if (DataHelpers.VerifySize(data, headerSize))
@ -206,7 +216,7 @@ namespace LASRead.LASFormat
ushort red; ushort red;
ushort green; ushort green;
ushort blue; ushort blue;
const int headerSize = 26; new public static readonly int headerSize = 26;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
if (DataHelpers.VerifySize(data, headerSize)) if (DataHelpers.VerifySize(data, headerSize))
@ -249,7 +259,7 @@ namespace LASRead.LASFormat
ushort red; ushort red;
ushort green; ushort green;
ushort blue; ushort blue;
const int headerSize = 34; new public static readonly int headerSize = 34;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
if (DataHelpers.VerifySize(data, headerSize)) if (DataHelpers.VerifySize(data, headerSize))
@ -298,7 +308,7 @@ namespace LASRead.LASFormat
float dy; float dy;
float dz; float dz;
const int headerSize = 57; new public static readonly int headerSize = 57;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
@ -360,7 +370,7 @@ namespace LASRead.LASFormat
float dy; float dy;
float dz; float dz;
const int headerSize = 63; new public static readonly int headerSize = 63;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
@ -413,24 +423,40 @@ namespace LASRead.LASFormat
class PDR6 : IPointDataRecord class PDR6 : IPointDataRecord
{ {
const int headerSize = 30; int x;
int y;
int z;
ushort? intensity;
byte returnNumberFlag_value; // NB: 4 bits here
byte numberOfReturnsFlag_value; // 4
byte classificationFlag_value; // 4
byte scannerChannelFlag_value; // 2
byte scanDirectionFlag_value; // 1
byte edgeOfFlightLineFlag_value; // 1
byte classification;
short scanAngleRank;
byte? userData;
ushort pointSourceID;
double GPSTime;
public static readonly int headerSize = 30;
// Inherited members // Inherited members
public int X { get; set; } public int X { get => x; set => x = value; }
public int Y { get; set; } public int Y { get => y; set => y = value; }
public int Z { get; set; } public int Z { get => z; set => z = value; }
public ushort? Intensity { get; set; } public ushort? Intensity { get => intensity; set => intensity = value; }
public byte ReturnNumberFlag_value { get; set; } public byte ReturnNumberFlag_value { get => returnNumberFlag_value; set => returnNumberFlag_value = value; }
public byte NumberOfReturnsFlag_value { get; set; } public byte NumberOfReturnsFlag_value { get => numberOfReturnsFlag_value; set => numberOfReturnsFlag_value = value; }
public byte ScanDirectionFlag_value { get; set; } public byte ScanDirectionFlag_value { get => scanDirectionFlag_value; set => scanDirectionFlag_value = value; }
public byte EdgeOfFlightLineFlag_value { get; set; } public byte EdgeOfFlightLineFlag_value { get => edgeOfFlightLineFlag_value; set => edgeOfFlightLineFlag_value = value; }
public byte Classification { get; set; } public byte Classification { get => classification; set => classification = value; }
public short ScanAngleRank { get; set; } public short ScanAngleRank { get => scanAngleRank; set => scanAngleRank = value; }
public byte? UserData { get; set; } public byte? UserData { get => userData; set => userData = value; }
public ushort PointSourceID { get; set; } public ushort PointSourceID { get => pointSourceID; set => pointSourceID = value; }
// Local members // Local members
public byte ClassificationFlag_value { get; set; } public byte ClassificationFlag_value { get => classificationFlag_value; set => classificationFlag_value = value; }
public byte ScannerChannelFlag_value { get; set; } public byte ScannerChannelFlag_value { get => scannerChannelFlag_value; set => scannerChannelFlag_value = value; }
public double GPSTime1 { get; set; } public double GPSTime1 { get => GPSTime; set => GPSTime = value; }
sbyte IPointDataRecord.ScanAngleRank { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } sbyte IPointDataRecord.ScanAngleRank { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
@ -451,15 +477,15 @@ namespace LASRead.LASFormat
{ {
if (DataHelpers.VerifySize(data, headerSize)) if (DataHelpers.VerifySize(data, headerSize))
{ {
X = BitConverter.ToInt32(data, 0); x = BitConverter.ToInt32(data, 0);
Y = BitConverter.ToInt32(data, 4); y = BitConverter.ToInt32(data, 4);
Z = BitConverter.ToInt32(data, 8); z = BitConverter.ToInt32(data, 8);
Intensity = BitConverter.ToUInt16(data, 12); intensity = BitConverter.ToUInt16(data, 12);
ReadFlag(Tuple.Create(data[14], data[15])); ReadFlag(Tuple.Create(data[14], data[15]));
Classification = data[16]; classification = data[16];
UserData = data[17]; userData = data[17];
ScanAngleRank = BitConverter.ToInt16(data, 18); scanAngleRank = BitConverter.ToInt16(data, 18);
PointSourceID = BitConverter.ToUInt16(data, 20); pointSourceID = BitConverter.ToUInt16(data, 20);
return true; return true;
} }
else return false; else return false;
@ -480,11 +506,11 @@ namespace LASRead.LASFormat
sb.Append("Number of Returns: " + NumberOfReturnsFlag_value.ToString() + Environment.NewLine); sb.Append("Number of Returns: " + NumberOfReturnsFlag_value.ToString() + Environment.NewLine);
sb.Append("Classification Value: " + ClassificationFlag_value + Environment.NewLine); sb.Append("Classification Value: " + ClassificationFlag_value + Environment.NewLine);
sb.Append("Scanner Channel Value: " + ScannerChannelFlag_value + Environment.NewLine); sb.Append("Scanner Channel Value: " + ScannerChannelFlag_value + Environment.NewLine);
sb.Append("Scan Direction: " + (ReturnNumberFlag_value == 0 ? "+" : "-") + Environment.NewLine); sb.Append("Scan Direction: " + (returnNumberFlag_value == 0 ? "+" : "-") + Environment.NewLine);
sb.Append("Edge of Flight Line: " + (ReturnNumberFlag_value == 0 ? "no" : "yes") + Environment.NewLine); sb.Append("Edge of Flight Line: " + (returnNumberFlag_value == 0 ? "no" : "yes") + Environment.NewLine);
sb.Append("Classification: " + ((Classifications)Classification) + Environment.NewLine); sb.Append("Classification: " + ((Classifications)Classification) + Environment.NewLine);
sb.Append("Scan Angle Rank: " + ScanAngleRank.ToString() + Environment.NewLine); sb.Append("Scan Angle Rank: " + ScanAngleRank.ToString() + Environment.NewLine);
sb.Append("User Data: " + (UserData == 0 ? "no" : "yes") + Environment.NewLine); sb.Append("User Data: " + (userData == 0 ? "no" : "yes") + Environment.NewLine);
sb.Append("Point Data Source: " + PointSourceID.ToString() + Environment.NewLine); sb.Append("Point Data Source: " + PointSourceID.ToString() + Environment.NewLine);
sb.Append("GPS Time: " + GPSTime1.ToString() + Environment.NewLine); sb.Append("GPS Time: " + GPSTime1.ToString() + Environment.NewLine);
return sb.ToString(); return sb.ToString();
@ -510,8 +536,8 @@ namespace LASRead.LASFormat
BitConverter.GetBytes(Intensity ?? 0).CopyTo(result, 12); BitConverter.GetBytes(Intensity ?? 0).CopyTo(result, 12);
MergeFlags().CopyTo(result, 14); MergeFlags().CopyTo(result, 14);
result[15] = Classification; result[15] = Classification;
result[16] = (byte)ScanAngleRank; result[16] = (byte)scanAngleRank;
result[17] = UserData ?? 0; result[17] = userData ?? 0;
BitConverter.GetBytes(PointSourceID).CopyTo(result, 18); BitConverter.GetBytes(PointSourceID).CopyTo(result, 18);
return result; return result;
} }
@ -523,7 +549,7 @@ namespace LASRead.LASFormat
ushort green; ushort green;
ushort blue; ushort blue;
const int headerSize = 36; new public static readonly int headerSize = 36;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
@ -558,7 +584,7 @@ namespace LASRead.LASFormat
{ {
ushort nIR; ushort nIR;
const int headerSize = 38; new public static readonly int headerSize = 38;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
@ -598,7 +624,7 @@ namespace LASRead.LASFormat
float dy; float dy;
float dz; float dz;
const int headerSize = 59; new public static readonly int headerSize = 59;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {
@ -647,7 +673,7 @@ namespace LASRead.LASFormat
float dy; float dy;
float dz; float dz;
const int headerSize = 67; new public static readonly int headerSize = 67;
public override bool ReadPoint(byte[] data) public override bool ReadPoint(byte[] data)
{ {

View File

@ -39,7 +39,6 @@ namespace LASRead.LASFormat
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append(header.ToString() + Environment.NewLine); sb.Append(header.ToString() + Environment.NewLine);
sb.Append(string.Format("Binary Data @{0}, of length {1}{2}", position + header.HeaderLength, header.HeaderLength, Environment.NewLine)); sb.Append(string.Format("Binary Data @{0}, of length {1}{2}", position + header.HeaderLength, header.HeaderLength, Environment.NewLine));
sb.Append(header.ToString());
return sb.ToString(); return sb.ToString();
} }
} }
@ -141,7 +140,7 @@ namespace LASRead.LASFormat
sb.Append("Record ID: " + RecordID.ToString() + Environment.NewLine); sb.Append("Record ID: " + RecordID.ToString() + Environment.NewLine);
sb.Append("Record Length After Header: " + RecordID.ToString() + Environment.NewLine); sb.Append("Record Length After Header: " + RecordID.ToString() + Environment.NewLine);
sb.Append("Description: " + new string(DataHelpers.ToCharArray(Description)) + Environment.NewLine); sb.Append("Description: " + new string(DataHelpers.ToCharArray(Description)) + Environment.NewLine);
return sb.ToString(); return base.ToString();
} }

View File

@ -9,9 +9,9 @@ namespace LASRead.LASFormat
public class RecordCollection : IEnumerable<Record> public class RecordCollection : IEnumerable<Record>
{ {
RecordEnumerator enumerator; RecordEnumerator enumerator;
public RecordCollection(ref Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader) public RecordCollection(Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
{ {
enumerator = new RecordEnumerator(ref source, startPosition, maxItems, firstHeader); enumerator = new RecordEnumerator(source, startPosition, maxItems, firstHeader);
} }
public IEnumerator<Record> GetEnumerator() public IEnumerator<Record> GetEnumerator()
{ {
@ -32,7 +32,7 @@ namespace LASRead.LASFormat
uint currentCount; uint currentCount;
uint maxCount; uint maxCount;
public RecordEnumerator(ref Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader) public RecordEnumerator(Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
{ {
dataSource = source; dataSource = source;
streamStart = startPosition; streamStart = startPosition;

23
LASRead/UnitTest1.cs Normal file
View File

@ -0,0 +1,23 @@
using NUnit.Framework;
using LASFormat;
using System.IO;
namespace Tests
{
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test1()
{
FileStream fs = File.OpenRead("C:\\points.las");
LASFile lasFile = new LASFile(fs);
Assert.Pass();
}
}
}

View File

@ -49,7 +49,7 @@ namespace LasInteractor
private static void ReadFile(string source, bool printAll) private static void ReadFile(string source, bool printAll)
{ {
Console.WriteLine("Reading {0}", source); Console.WriteLine("Reading {0}", source);
FileStream fs = File.OpenRead(source.Trim('\"')); FileStream fs = File.OpenRead(source);
Console.WriteLine("File is {0} bytes", fs.Length); Console.WriteLine("File is {0} bytes", fs.Length);
LASFile lasFile = new LASFile(fs); LASFile lasFile = new LASFile(fs);
/*FileStream os = File.OpenWrite("tdata.dat"); /*FileStream os = File.OpenWrite("tdata.dat");