Fixed a number of small bugs, refactored
This commit is contained in:
parent
269373faa2
commit
5af930b4ea
@ -75,7 +75,7 @@ namespace LASFormat
|
||||
VLRStart = Header.HeaderSize;
|
||||
VLRHeader initial = new VLRHeader();
|
||||
initial.ReadRecords(VLRStream);
|
||||
vlrCollection = new RecordCollection(VLRStream, VLRStart, Header.NumberVLRs, initial);
|
||||
vlrCollection = new RecordCollection(ref VLRStream, VLRStart, Header.NumberVLRs, initial);
|
||||
|
||||
// Grab a starting PDR
|
||||
PDRStart = Header.DataOffset;
|
||||
@ -103,7 +103,7 @@ namespace LASFormat
|
||||
EVLRStream = GetOffsetStream(source, EVLRSize);
|
||||
EVLRHeader evlrInitial = new EVLRHeader();
|
||||
evlrInitial.ReadRecords(EVLRStream);
|
||||
evlrCollection = new RecordCollection(EVLRStream, EVLRStart, Header.NumberOfExtendedVLRs, evlrInitial);
|
||||
evlrCollection = new RecordCollection(ref EVLRStream, EVLRStart, Header.NumberOfExtendedVLRs, evlrInitial);
|
||||
// Finally, set the stream back to the starting position
|
||||
source.Position = 0;
|
||||
// TODO: Grab a starting Waveform
|
||||
@ -146,6 +146,7 @@ namespace LASFormat
|
||||
source.Read(buffer, 0, remaining);
|
||||
newStream.Write(buffer, 0, remaining);
|
||||
}
|
||||
newStream.Position = 0;
|
||||
return newStream;
|
||||
}
|
||||
|
||||
|
@ -335,10 +335,10 @@ namespace LASRead.LASFormat
|
||||
sb.Append("PointDataLength: " + PointDataRecordLength.ToString() + Environment.NewLine);
|
||||
sb.Append("Legacy #PDRs: " + LegacyNumberOfPointRecords.ToString() + Environment.NewLine);
|
||||
sb.Append("Legacy #PDR returns: ");
|
||||
foreach (uint legacyReturn in LegacyNumberOfPointByReturn)
|
||||
for (int i = 0; i < LegacyNumberOfPointByReturn.Length; i++)
|
||||
{
|
||||
sb.Append(legacyReturn);
|
||||
sb.Append(" ");
|
||||
uint legacyReturn = LegacyNumberOfPointByReturn[i];
|
||||
sb.Append($"{i+1}: {legacyReturn} ");
|
||||
}
|
||||
sb.Append(Environment.NewLine);
|
||||
sb.Append("X Scale Factor: " + X_scaleFactor.ToString() + Environment.NewLine);
|
||||
|
@ -6,7 +6,7 @@ namespace LASRead.LASFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// LAS Data Payloads are in the Point Data Record (PDR) format <br />
|
||||
/// PDR 0-5 share the same basic substructure (which is inherited from this interface, <br />
|
||||
/// PDR formats 0-5 share the same basic substructure (which is ultimately inherited from this interface) <br />
|
||||
/// PDR 6-10 share a slightly different substructure (more flags)
|
||||
/// </summary>
|
||||
public interface IPointDataRecord
|
||||
@ -48,7 +48,10 @@ namespace LASRead.LASFormat
|
||||
class PDR0 : IPointDataRecord
|
||||
{
|
||||
const int headerSize = 20;
|
||||
|
||||
/// <summary>
|
||||
/// PDRs for the X,Y,Z are 4-byte integers. They are multiplied by the scale defined in the
|
||||
/// header to determine the true (potentially non-integral) coordinate of the point
|
||||
/// </summary>
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Z { get; set; }
|
||||
|
@ -39,6 +39,7 @@ namespace LASRead.LASFormat
|
||||
StringBuilder sb = new StringBuilder();
|
||||
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(header.ToString());
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
@ -140,7 +141,7 @@ namespace LASRead.LASFormat
|
||||
sb.Append("Record ID: " + RecordID.ToString() + Environment.NewLine);
|
||||
sb.Append("Record Length After Header: " + RecordID.ToString() + Environment.NewLine);
|
||||
sb.Append("Description: " + new string(DataHelpers.ToCharArray(Description)) + Environment.NewLine);
|
||||
return base.ToString();
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,9 +9,9 @@ namespace LASRead.LASFormat
|
||||
public class RecordCollection : IEnumerable<Record>
|
||||
{
|
||||
RecordEnumerator enumerator;
|
||||
public RecordCollection(Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
|
||||
public RecordCollection(ref Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
|
||||
{
|
||||
enumerator = new RecordEnumerator(source, startPosition, maxItems, firstHeader);
|
||||
enumerator = new RecordEnumerator(ref source, startPosition, maxItems, firstHeader);
|
||||
}
|
||||
public IEnumerator<Record> GetEnumerator()
|
||||
{
|
||||
@ -32,7 +32,7 @@ namespace LASRead.LASFormat
|
||||
uint currentCount;
|
||||
uint maxCount;
|
||||
|
||||
public RecordEnumerator(Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
|
||||
public RecordEnumerator(ref Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
|
||||
{
|
||||
dataSource = source;
|
||||
streamStart = startPosition;
|
||||
|
Loading…
x
Reference in New Issue
Block a user