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;
|
VLRStart = Header.HeaderSize;
|
||||||
VLRHeader initial = new VLRHeader();
|
VLRHeader initial = new VLRHeader();
|
||||||
initial.ReadRecords(VLRStream);
|
initial.ReadRecords(VLRStream);
|
||||||
vlrCollection = new RecordCollection(VLRStream, VLRStart, Header.NumberVLRs, initial);
|
vlrCollection = new RecordCollection(ref VLRStream, VLRStart, Header.NumberVLRs, initial);
|
||||||
|
|
||||||
// Grab a starting PDR
|
// Grab a starting PDR
|
||||||
PDRStart = Header.DataOffset;
|
PDRStart = Header.DataOffset;
|
||||||
@ -103,7 +103,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(EVLRStream, EVLRStart, Header.NumberOfExtendedVLRs, evlrInitial);
|
evlrCollection = new RecordCollection(ref 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,6 +146,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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: ");
|
||||||
foreach (uint legacyReturn in LegacyNumberOfPointByReturn)
|
for (int i = 0; i < LegacyNumberOfPointByReturn.Length; i++)
|
||||||
{
|
{
|
||||||
sb.Append(legacyReturn);
|
uint legacyReturn = LegacyNumberOfPointByReturn[i];
|
||||||
sb.Append(" ");
|
sb.Append($"{i+1}: {legacyReturn} ");
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
@ -6,7 +6,7 @@ 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 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)
|
/// PDR 6-10 share a slightly different substructure (more flags)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPointDataRecord
|
public interface IPointDataRecord
|
||||||
@ -48,7 +48,10 @@ namespace LASRead.LASFormat
|
|||||||
class PDR0 : IPointDataRecord
|
class PDR0 : IPointDataRecord
|
||||||
{
|
{
|
||||||
const int headerSize = 20;
|
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 X { get; set; }
|
||||||
public int Y { get; set; }
|
public int Y { get; set; }
|
||||||
public int Z { get; set; }
|
public int Z { get; set; }
|
||||||
|
@ -39,6 +39,7 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +141,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 base.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ namespace LASRead.LASFormat
|
|||||||
public class RecordCollection : IEnumerable<Record>
|
public class RecordCollection : IEnumerable<Record>
|
||||||
{
|
{
|
||||||
RecordEnumerator enumerator;
|
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()
|
public IEnumerator<Record> GetEnumerator()
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace LASRead.LASFormat
|
|||||||
uint currentCount;
|
uint currentCount;
|
||||||
uint maxCount;
|
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;
|
dataSource = source;
|
||||||
streamStart = startPosition;
|
streamStart = startPosition;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user