Compare commits
5
Commits
c966dfe4e9
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38ef1859c2 | ||
|
|
a7d04f54da | ||
|
|
9335d37f7c | ||
|
|
5af930b4ea | ||
|
|
269373faa2 |
+30
-14
@@ -17,10 +17,11 @@ namespace LASFormat
|
|||||||
//
|
//
|
||||||
// Todos:
|
// Todos:
|
||||||
// - Split a LAS file into subsections, probably about 100m^2
|
// - Split a LAS file into subsections, probably about 100m^2
|
||||||
// - generate heightmaps from sections, 0-255 per point
|
// - generate heightmaps from sections, 0-255 per point (or more, especially if using the same scale worldwide)
|
||||||
// - Output heightmaps in a Unity- and Unreal- ready format
|
// - Output heightmaps in a Unity- and Unreal- ready format
|
||||||
// - Ouput vertex colours for each point, if available
|
// - Ouput vertex colours for each point, if available
|
||||||
// - Allow exporting different layers of a file
|
// - Allow exporting different layers of a file
|
||||||
|
// - Link to a raster map provider and dynamically load into the aforementioned engine
|
||||||
private const int V = 16384;
|
private const int V = 16384;
|
||||||
private const int V1 = V * (ushort.MaxValue +1);
|
private const int V1 = V * (ushort.MaxValue +1);
|
||||||
|
|
||||||
@@ -62,20 +63,30 @@ 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());
|
||||||
|
|
||||||
|
|
||||||
// As the header has now been read, we can now create some underlying streams, to act as our object sources.
|
// As the header has now been read, we can now create some underlying streams, to act as our object sources.
|
||||||
// Set our current source position to the end of the header.
|
// Set our current source position to the end of the header.
|
||||||
source.Position = Header.HeaderSize;
|
source.Position = Header.HeaderSize;
|
||||||
long VLRSize = Header.DataOffset - Header.HeaderSize;
|
//long VLRSize = Header.DataOffset - Header.HeaderSize;
|
||||||
VLRStream = GetOffsetStream(source, VLRSize);
|
//VLRStream = GetOffsetStream(source, VLRSize);
|
||||||
// Grab a starting VLR
|
// Grab a starting VLR
|
||||||
VLRStart = Header.HeaderSize;
|
//VLRStart = Header.HeaderSize;
|
||||||
VLRHeader initial = new VLRHeader();
|
VLRHeader initial = new VLRHeader();
|
||||||
initial.ReadRecords(VLRStream);
|
initial.ReadRecords(source);
|
||||||
vlrCollection = new RecordCollection(VLRStream, VLRStart, Header.NumberVLRs, initial);
|
vlrCollection = new RecordCollection(ref source, Header.HeaderSize, Header.NumberVLRs, initial);
|
||||||
|
// !---------------------------------------------------------------
|
||||||
|
// NB: at this point, the actual coordinate system is unknown - there is no obvious
|
||||||
|
// conversions for this data
|
||||||
|
// - An example are New Zealand coordinates, which are presented as Transverse Mercator easting and northing distances in meters,
|
||||||
|
// rather than Geodetic Datum latitude and longitude points in degrees
|
||||||
|
// To resolve coordinates on a world-wide scale, we'll need to identify the coordinate data type and convert to a
|
||||||
|
// standard coordinate system
|
||||||
|
// !---------------------------------------------------------------
|
||||||
|
// A VLR with a user ID of LASF_Projection\0 contains the required coordinate system:
|
||||||
|
// E.g.: 2016 scan information from LINZ contains the following transform string: 'NZGD2000 / New Zealand Transverse Mercator 2000 + NZVD2016 height|NZGD2000|NZVD2016 height|'
|
||||||
// Grab a starting PDR
|
// Grab a starting PDR
|
||||||
PDRStart = Header.DataOffset;
|
PDRStart = Header.DataOffset;
|
||||||
source.Position = (long)PDRStart;
|
source.Position = (long)PDRStart;
|
||||||
@@ -83,22 +94,26 @@ 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*> storage
|
// Using generics to dynamically create a PDRCollection<PDR[type]> 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
|
||||||
EVLRStart = Header.StartOfFirstExtendedVLR;
|
//EVLRStart = Header.StartOfFirstExtendedVLR;
|
||||||
source.Position = (long)EVLRStart;
|
source.Position = Header.StartOfFirstExtendedVLR;
|
||||||
long EVLRSize = (Header.StartOfWaveformDPR == 0 ? source.Length : (long)Header.StartOfWaveformDPR) - (long)Header.StartOfFirstExtendedVLR;
|
//long EVLRSize = (Header.StartOfWaveformDPR == 0 ? source.Length : (long)Header.StartOfWaveformDPR) - (long)Header.StartOfFirstExtendedVLR;
|
||||||
EVLRStream = GetOffsetStream(source, EVLRSize);
|
//EVLRStream = GetOffsetStream(source, EVLRSize);
|
||||||
EVLRHeader evlrInitial = new EVLRHeader();
|
EVLRHeader evlrInitial = new EVLRHeader();
|
||||||
evlrInitial.ReadRecords(EVLRStream);
|
evlrInitial.ReadRecords(source);
|
||||||
evlrCollection = new RecordCollection(EVLRStream, EVLRStart, Header.NumberOfExtendedVLRs, evlrInitial);
|
evlrCollection = new RecordCollection(ref EVLRStream, Header.StartOfFirstExtendedVLR, 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
|
||||||
@@ -141,6 +156,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace LASRead.LASFormat
|
|||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
characters[i] = (char)values[start + i];
|
characters[i] = (char)values[start + i];
|
||||||
|
if (characters[i] == 0) characters[i] = '-';
|
||||||
}
|
}
|
||||||
return characters;
|
return characters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ namespace LASRead.LASFormat
|
|||||||
/// <b>New in 1.4</b><br />
|
/// <b>New in 1.4</b><br />
|
||||||
/// Start of the first Extended Variable Length Record (EVLR)
|
/// Start of the first Extended Variable Length Record (EVLR)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong StartOfFirstExtendedVLR { get; set; }
|
public long StartOfFirstExtendedVLR { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <b>New in 1.4</b><br />
|
/// <b>New in 1.4</b><br />
|
||||||
/// Number of Extended Variable Length Records
|
/// Number of Extended Variable Length Records
|
||||||
@@ -296,7 +296,7 @@ namespace LASRead.LASFormat
|
|||||||
if (VersionMinor >= 4)
|
if (VersionMinor >= 4)
|
||||||
{
|
{
|
||||||
StartOfWaveformDPR = BitConverter.ToUInt64(inputHeader, 227);
|
StartOfWaveformDPR = BitConverter.ToUInt64(inputHeader, 227);
|
||||||
StartOfFirstExtendedVLR = BitConverter.ToUInt64(inputHeader, 235);
|
StartOfFirstExtendedVLR = (long)BitConverter.ToUInt64(inputHeader, 235);
|
||||||
NumberOfExtendedVLRs = BitConverter.ToUInt32(inputHeader, 243);
|
NumberOfExtendedVLRs = BitConverter.ToUInt32(inputHeader, 243);
|
||||||
NumberPointRecords = BitConverter.ToUInt64(inputHeader, 247);
|
NumberPointRecords = BitConverter.ToUInt64(inputHeader, 247);
|
||||||
NumberPointsByReturn = DataHelpers.ToULongArray(inputHeader, 255, 120);
|
NumberPointsByReturn = DataHelpers.ToULongArray(inputHeader, 255, 120);
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace LASRead.LASFormat
|
||||||
|
{
|
||||||
|
|
||||||
|
class GeoKeyTag // Tag = 34735
|
||||||
|
{
|
||||||
|
// Header, first 8 bytes
|
||||||
|
short KeyDirectoryVersion;
|
||||||
|
short KeyRevision;
|
||||||
|
short MinorRevision;
|
||||||
|
short NumberOfKeys;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GeoTIFF Tags that are included to contain the format (especially coordinate) data of the file
|
||||||
|
/// Due to the structure of a TIFF file, data are stored in Keys - these keys often further link to data in another tag
|
||||||
|
/// LiDAR capture data from a section of New Zealand contianed the following keys:
|
||||||
|
/// 1 1 0 11 -- ?
|
||||||
|
/// 1024 0 1 1 -- Type of coordinates (1 == Projected System)
|
||||||
|
/// 1025 0 1 1 -- Raster system used (1 == Pixel is area)
|
||||||
|
/// 1026 34737 66 0 -- ASCII Text about the file (Specifically, 'NZGD2000 / New Zealand Transverse Mercator 2000 + NZVD2016 height' - between 0-66 bytes of tag 34737)
|
||||||
|
/// 2049 34737 9 66 -- ASCII Geographic Citation Parameters, between 66-66+9 bytes ('NZGD2000')
|
||||||
|
/// 2054 0 1 9102 -- Angular Units (9102 = Degrees)
|
||||||
|
/// 3072 0 1 2193 -- Projected Coordinate System Type (2193 is not an expected value
|
||||||
|
/// 3076 0 1 9001 -- Projection Units (9001 = meters)
|
||||||
|
/// 4096 0 1 7839 -- Vertical Coordinate System (7839 = NZVD2016)
|
||||||
|
/// 4097 34737 16 75 -- ASCII Vertical System Name ('NZVD2016 height')
|
||||||
|
/// 4098 0 1 1169 -- Vertical Datum
|
||||||
|
/// 4099 0 1 9001 -- Vertical Units (meters)
|
||||||
|
/// </summary>
|
||||||
|
struct Key
|
||||||
|
{
|
||||||
|
public short KeyID;
|
||||||
|
public short TIFFTagLocation;
|
||||||
|
public short Count;
|
||||||
|
public short Value_Offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Linear unit specifications - used in key ID 3076
|
||||||
|
/// </summary>
|
||||||
|
enum Units
|
||||||
|
{
|
||||||
|
Undefined = 0,
|
||||||
|
Linear_Meter = 9001,
|
||||||
|
Linear_Foot = 9002,
|
||||||
|
Linear_Foot_US_Survey = 9003,
|
||||||
|
Linear_Foot_Modified_American = 9004,
|
||||||
|
Linear_Foot_Clarke = 9005,
|
||||||
|
Linear_Foot_Indian = 9006,
|
||||||
|
Linear_Link = 9007,
|
||||||
|
Linear_Link_Benoit = 9008,
|
||||||
|
Linear_Link_Sears = 9009,
|
||||||
|
Linear_Chain_Benoit = 9010,
|
||||||
|
Linear_Chain_Sears = 9011,
|
||||||
|
Linear_Yard_Sears = 9012,
|
||||||
|
Linear_Yard_Indian = 9013,
|
||||||
|
Linear_Fathom = 9014,
|
||||||
|
Linear_Mile_International_Nautical = 9015,
|
||||||
|
|
||||||
|
Angular_Radian = 9101,
|
||||||
|
Angular_Degree = 9102,
|
||||||
|
Angular_Arc_Minute = 9103,
|
||||||
|
Angular_Arc_Second = 9104,
|
||||||
|
Angular_Grad = 9105,
|
||||||
|
Angular_Gon = 9106,
|
||||||
|
Angular_DMS = 9107,
|
||||||
|
Angular_DMS_Hemisphere = 9108,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vertical system codes - (key 4096)
|
||||||
|
/// </summary>
|
||||||
|
enum VerticalTypeCodes
|
||||||
|
{
|
||||||
|
VertCS_Airy_1830_ellipsoid = 5001,
|
||||||
|
VertCS_Airy_Modified_1849_ellipsoid = 5002,
|
||||||
|
VertCS_ANS_ellipsoid = 5003,
|
||||||
|
VertCS_Bessel_1841_ellipsoid = 5004,
|
||||||
|
VertCS_Bessel_Modified_ellipsoid = 5005,
|
||||||
|
VertCS_Bessel_Namibia_ellipsoid = 5006,
|
||||||
|
VertCS_Clarke_1858_ellipsoid = 5007,
|
||||||
|
VertCS_Clarke_1866_ellipsoid = 5008,
|
||||||
|
VertCS_Clarke_1880_Benoit_ellipsoid = 5010,
|
||||||
|
VertCS_Clarke_1880_IGN_ellipsoid = 5011,
|
||||||
|
VertCS_Clarke_1880_RGS_ellipsoid = 5012,
|
||||||
|
VertCS_Clarke_1880_Arc_ellipsoid = 5013,
|
||||||
|
VertCS_Clarke_1880_SGA_1922_ellipsoid = 5014,
|
||||||
|
VertCS_Everest_1830_1937_Adjustment_ellipsoid = 5015,
|
||||||
|
VertCS_Everest_1830_1967_Definition_ellipsoid = 5016,
|
||||||
|
VertCS_Everest_1830_1975_Definition_ellipsoid = 5017,
|
||||||
|
VertCS_Everest_1830_Modified_ellipsoid = 5018,
|
||||||
|
VertCS_GRS_1980_ellipsoid = 5019,
|
||||||
|
VertCS_Helmert_1906_ellipsoid = 5020,
|
||||||
|
VertCS_INS_ellipsoid = 5021,
|
||||||
|
VertCS_International_1924_ellipsoid = 5022,
|
||||||
|
VertCS_International_1967_ellipsoid = 5023,
|
||||||
|
VertCS_Krassowsky_1940_ellipsoid = 5024,
|
||||||
|
VertCS_NWL_9D_ellipsoid = 5025,
|
||||||
|
VertCS_NWL_10D_ellipsoid = 5026,
|
||||||
|
VertCS_Plessis_1817_ellipsoid = 5027,
|
||||||
|
VertCS_Struve_1860_ellipsoid = 5028,
|
||||||
|
VertCS_War_Office_ellipsoid = 5029,
|
||||||
|
VertCS_WGS_84_ellipsoid = 5030,
|
||||||
|
VertCS_GEM_10C_ellipsoid = 5031,
|
||||||
|
VertCS_OSU86F_ellipsoid = 5032,
|
||||||
|
VertCS_OSU91A_ellipsoid = 5033,
|
||||||
|
VertCS_Newlyn = 5101,
|
||||||
|
VertCS_North_American_Vertical_Datum_1929 = 5102,
|
||||||
|
VertCS_North_American_Vertical_Datum_1988 = 5103,
|
||||||
|
VertCS_Yellow_Sea_1956 = 5104,
|
||||||
|
VertCS_Baltic_Sea = 5105,
|
||||||
|
VertCS_Caspian_Sea = 5106,
|
||||||
|
|
||||||
|
NZ_Vertical = 7839
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 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
|
||||||
{
|
{
|
||||||
int X { get; set; }
|
public int X { get; set; }
|
||||||
int Y { get; set; }
|
public int Y { get; set; }
|
||||||
int Z { get; set; }
|
public int Z { get; set; }
|
||||||
|
|
||||||
Nullable<ushort> Intensity { get; set; }
|
public ushort? Intensity { get; set; }
|
||||||
byte ReturnNumberFlag_value { get; set; }
|
public byte ReturnNumberFlag_value { get; set; }
|
||||||
byte NumberOfReturnsFlag_value { get; set; }
|
public byte NumberOfReturnsFlag_value { get; set; }
|
||||||
byte ScanDirectionFlag_value { get; set; }
|
public byte ScanDirectionFlag_value { get; set; }
|
||||||
byte EdgeOfFlightLineFlag_value { get; set; }
|
public byte EdgeOfFlightLineFlag_value { get; set; }
|
||||||
byte Classification { get; set; }
|
public byte Classification { get; set; }
|
||||||
sbyte ScanAngleRank { get; set; }
|
public sbyte ScanAngleRank { get; set; }
|
||||||
|
|
||||||
Nullable<byte> UserData { get; set; }
|
public byte? UserData { get; set; }
|
||||||
ushort PointSourceID { get; set; }
|
public ushort PointSourceID { get; set; }
|
||||||
bool ReadPoint(byte[] data);
|
public bool ReadPoint(byte[] data);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads the flags from the supplied byte
|
/// Reads the flags from the supplied byte
|
||||||
@@ -47,33 +47,23 @@ namespace LASRead.LASFormat
|
|||||||
|
|
||||||
class PDR0 : IPointDataRecord
|
class PDR0 : IPointDataRecord
|
||||||
{
|
{
|
||||||
int x;
|
const int headerSize = 20;
|
||||||
int y;
|
/// <summary>
|
||||||
int z;
|
/// PDRs for the X,Y,Z are 4-byte integers. They are multiplied by the scale defined in the
|
||||||
ushort? intensity;
|
/// header to determine the true (potentially non-integral) coordinate of the point
|
||||||
byte returnNumberFlag_value;
|
/// </summary>
|
||||||
byte numberOfReturnsFlag_value;
|
public int X { get; set; }
|
||||||
byte scanDirectionFlag_value;
|
public int Y { get; set; }
|
||||||
byte edgeOfFlightLineFlag_value;
|
public int Z { get; set; }
|
||||||
byte classification;
|
public ushort? Intensity { get; set; }
|
||||||
sbyte scanAngleRank;
|
public byte ReturnNumberFlag_value { get; set; }
|
||||||
byte? userData;
|
public byte NumberOfReturnsFlag_value { get; set; }
|
||||||
ushort pointSourceID;
|
public byte ScanDirectionFlag_value { get; set; }
|
||||||
|
public byte EdgeOfFlightLineFlag_value { get; set; }
|
||||||
public static readonly int headerSize = 20;
|
public byte Classification { get; set; }
|
||||||
|
public sbyte ScanAngleRank { get; set; }
|
||||||
public int X { get => x; set => x = value; }
|
public byte? UserData { get; set; }
|
||||||
public int Y { get => y; set => y = value; }
|
public ushort PointSourceID { get; set; }
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -100,15 +90,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;
|
||||||
@@ -138,11 +128,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();
|
||||||
@@ -167,8 +157,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;
|
||||||
}
|
}
|
||||||
@@ -176,7 +166,7 @@ namespace LASRead.LASFormat
|
|||||||
class PDR1 : PDR0
|
class PDR1 : PDR0
|
||||||
{
|
{
|
||||||
double GPSTime;
|
double GPSTime;
|
||||||
new public static readonly int headerSize = 28;
|
const 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))
|
||||||
@@ -216,7 +206,7 @@ namespace LASRead.LASFormat
|
|||||||
ushort red;
|
ushort red;
|
||||||
ushort green;
|
ushort green;
|
||||||
ushort blue;
|
ushort blue;
|
||||||
new public static readonly int headerSize = 26;
|
const 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))
|
||||||
@@ -259,7 +249,7 @@ namespace LASRead.LASFormat
|
|||||||
ushort red;
|
ushort red;
|
||||||
ushort green;
|
ushort green;
|
||||||
ushort blue;
|
ushort blue;
|
||||||
new public static readonly int headerSize = 34;
|
const 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))
|
||||||
@@ -308,7 +298,7 @@ namespace LASRead.LASFormat
|
|||||||
float dy;
|
float dy;
|
||||||
float dz;
|
float dz;
|
||||||
|
|
||||||
new public static readonly int headerSize = 57;
|
const int headerSize = 57;
|
||||||
|
|
||||||
public override bool ReadPoint(byte[] data)
|
public override bool ReadPoint(byte[] data)
|
||||||
{
|
{
|
||||||
@@ -370,7 +360,7 @@ namespace LASRead.LASFormat
|
|||||||
float dy;
|
float dy;
|
||||||
float dz;
|
float dz;
|
||||||
|
|
||||||
new public static readonly int headerSize = 63;
|
const int headerSize = 63;
|
||||||
|
|
||||||
public override bool ReadPoint(byte[] data)
|
public override bool ReadPoint(byte[] data)
|
||||||
{
|
{
|
||||||
@@ -423,40 +413,24 @@ namespace LASRead.LASFormat
|
|||||||
|
|
||||||
class PDR6 : IPointDataRecord
|
class PDR6 : IPointDataRecord
|
||||||
{
|
{
|
||||||
int x;
|
const int headerSize = 30;
|
||||||
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 => x; set => x = value; }
|
public int X { get; set; }
|
||||||
public int Y { get => y; set => y = value; }
|
public int Y { get; set; }
|
||||||
public int Z { get => z; set => z = value; }
|
public int Z { get; set; }
|
||||||
public ushort? Intensity { get => intensity; set => intensity = value; }
|
public ushort? Intensity { get; set; }
|
||||||
public byte ReturnNumberFlag_value { get => returnNumberFlag_value; set => returnNumberFlag_value = value; }
|
public byte ReturnNumberFlag_value { get; set; }
|
||||||
public byte NumberOfReturnsFlag_value { get => numberOfReturnsFlag_value; set => numberOfReturnsFlag_value = value; }
|
public byte NumberOfReturnsFlag_value { get; set; }
|
||||||
public byte ScanDirectionFlag_value { get => scanDirectionFlag_value; set => scanDirectionFlag_value = value; }
|
public byte ScanDirectionFlag_value { get; set; }
|
||||||
public byte EdgeOfFlightLineFlag_value { get => edgeOfFlightLineFlag_value; set => edgeOfFlightLineFlag_value = value; }
|
public byte EdgeOfFlightLineFlag_value { get; set; }
|
||||||
public byte Classification { get => classification; set => classification = value; }
|
public byte Classification { get; set; }
|
||||||
public short ScanAngleRank { get => scanAngleRank; set => scanAngleRank = value; }
|
public short ScanAngleRank { get; set; }
|
||||||
public byte? UserData { get => userData; set => userData = value; }
|
public byte? UserData { get; set; }
|
||||||
public ushort PointSourceID { get => pointSourceID; set => pointSourceID = value; }
|
public ushort PointSourceID { get; set; }
|
||||||
// Local members
|
// Local members
|
||||||
public byte ClassificationFlag_value { get => classificationFlag_value; set => classificationFlag_value = value; }
|
public byte ClassificationFlag_value { get; set; }
|
||||||
public byte ScannerChannelFlag_value { get => scannerChannelFlag_value; set => scannerChannelFlag_value = value; }
|
public byte ScannerChannelFlag_value { get; set; }
|
||||||
public double GPSTime1 { get => GPSTime; set => GPSTime = value; }
|
public double GPSTime1 { get; set; }
|
||||||
|
|
||||||
sbyte IPointDataRecord.ScanAngleRank { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
sbyte IPointDataRecord.ScanAngleRank { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
@@ -477,15 +451,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;
|
||||||
@@ -506,11 +480,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();
|
||||||
@@ -536,8 +510,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;
|
||||||
}
|
}
|
||||||
@@ -549,7 +523,7 @@ namespace LASRead.LASFormat
|
|||||||
ushort green;
|
ushort green;
|
||||||
ushort blue;
|
ushort blue;
|
||||||
|
|
||||||
new public static readonly int headerSize = 36;
|
const int headerSize = 36;
|
||||||
|
|
||||||
public override bool ReadPoint(byte[] data)
|
public override bool ReadPoint(byte[] data)
|
||||||
{
|
{
|
||||||
@@ -584,7 +558,7 @@ namespace LASRead.LASFormat
|
|||||||
{
|
{
|
||||||
ushort nIR;
|
ushort nIR;
|
||||||
|
|
||||||
new public static readonly int headerSize = 38;
|
const int headerSize = 38;
|
||||||
|
|
||||||
public override bool ReadPoint(byte[] data)
|
public override bool ReadPoint(byte[] data)
|
||||||
{
|
{
|
||||||
@@ -624,7 +598,7 @@ namespace LASRead.LASFormat
|
|||||||
float dy;
|
float dy;
|
||||||
float dz;
|
float dz;
|
||||||
|
|
||||||
new public static readonly int headerSize = 59;
|
const int headerSize = 59;
|
||||||
|
|
||||||
public override bool ReadPoint(byte[] data)
|
public override bool ReadPoint(byte[] data)
|
||||||
{
|
{
|
||||||
@@ -673,7 +647,7 @@ namespace LASRead.LASFormat
|
|||||||
float dy;
|
float dy;
|
||||||
float dz;
|
float dz;
|
||||||
|
|
||||||
new public static readonly int headerSize = 67;
|
const int headerSize = 67;
|
||||||
|
|
||||||
public override bool ReadPoint(byte[] data)
|
public override bool ReadPoint(byte[] data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ 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));
|
||||||
|
for (int i = 0; i < data.Length; i += 2)
|
||||||
|
{
|
||||||
|
if (i % 8 == 0) sb.Append("\n");
|
||||||
|
sb.Append($"{BitConverter.ToUInt16(data[i..])} ");
|
||||||
|
|
||||||
|
}
|
||||||
|
//sb.Append(Environment.NewLine + new string(DataHelpers.ToCharArray(data)));
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,9 +145,9 @@ namespace LASRead.LASFormat
|
|||||||
sb.Append("Reserved: " + Reserved.ToString() + Environment.NewLine);
|
sb.Append("Reserved: " + Reserved.ToString() + Environment.NewLine);
|
||||||
sb.Append("User ID: " + new string(DataHelpers.ToCharArray(Id)) + Environment.NewLine);
|
sb.Append("User ID: " + new string(DataHelpers.ToCharArray(Id)) + Environment.NewLine);
|
||||||
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: " + RecordLengthAfterHeader.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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -150,10 +157,10 @@ namespace LASRead.LASFormat
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class EVLRHeader : VLRHeader
|
class EVLRHeader : VLRHeader
|
||||||
{
|
{
|
||||||
public new const int headerLength = 60;
|
public const int headerLength = 60;
|
||||||
|
|
||||||
new public ulong RecordLengthAfterHeader { get; set; }
|
new public ulong RecordLengthAfterHeader { get; set; }
|
||||||
new public int HeaderLength { get => 60; }
|
new public int HeaderLength { get => headerLength; }
|
||||||
|
|
||||||
public override bool ReadRecords(byte[] source)
|
public override bool ReadRecords(byte[] source)
|
||||||
{
|
{
|
||||||
@@ -197,9 +204,9 @@ namespace LASRead.LASFormat
|
|||||||
sb.Append("Reserved: " + Reserved.ToString() + Environment.NewLine);
|
sb.Append("Reserved: " + Reserved.ToString() + Environment.NewLine);
|
||||||
sb.Append("User ID: " + new string(DataHelpers.ToCharArray(Id)) + Environment.NewLine);
|
sb.Append("User ID: " + new string(DataHelpers.ToCharArray(Id)) + Environment.NewLine);
|
||||||
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: " + RecordLengthAfterHeader.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, long 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()
|
||||||
{
|
{
|
||||||
@@ -27,19 +27,22 @@ namespace LASRead.LASFormat
|
|||||||
public class RecordEnumerator : IEnumerator<Record>
|
public class RecordEnumerator : IEnumerator<Record>
|
||||||
{
|
{
|
||||||
Stream dataSource;
|
Stream dataSource;
|
||||||
ulong streamStart;
|
long streamStart;
|
||||||
ulong currentPosition;
|
long currentPosition;
|
||||||
uint currentCount;
|
uint currentCount;
|
||||||
uint maxCount;
|
uint maxCount;
|
||||||
|
IRecordPayloadHeader evalHeader;
|
||||||
|
|
||||||
public RecordEnumerator(Stream source, ulong startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
|
public RecordEnumerator(ref Stream source, long startPosition, uint maxItems, IRecordPayloadHeader firstHeader)
|
||||||
{
|
{
|
||||||
dataSource = source;
|
// Recieves the stream reference, the start position of the first record header, the number of record headers
|
||||||
streamStart = startPosition;
|
dataSource = source; // Stream
|
||||||
currentPosition = startPosition;
|
streamStart = startPosition; // start of the first header
|
||||||
currentCount = 0;
|
currentPosition = startPosition; // The current position of the enumerator
|
||||||
maxCount = maxItems;
|
currentCount = 0; // Total number of items enumerated
|
||||||
Current = new Record(firstHeader, (long)startPosition);
|
maxCount = maxItems; // Maximum number of items to enumerate
|
||||||
|
evalHeader = firstHeader;
|
||||||
|
//Current = new Record(firstHeader, startPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
object IEnumerator.Current => Current;
|
object IEnumerator.Current => Current;
|
||||||
@@ -64,9 +67,16 @@ namespace LASRead.LASFormat
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
long oldPos = dataSource.Position;
|
long oldPos = dataSource.Position;
|
||||||
currentPosition = (ulong)Current.header.HeaderLength + currentPosition;
|
// Advance the position in the stream to the beginning of the next record, after the header and data
|
||||||
dataSource.Position = (long)currentPosition;
|
if (Current != null)
|
||||||
Record nextRecord = new Record(Current.header.ParseRecord(dataSource), (long)currentPosition);
|
{
|
||||||
|
currentPosition += Current.header.HeaderLength + Current.header.RecordLengthAfterHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSource.Position = currentPosition;
|
||||||
|
evalHeader.ReadRecords(dataSource);
|
||||||
|
Record nextRecord = new Record(evalHeader, currentPosition);
|
||||||
|
nextRecord.ReadData(dataSource);
|
||||||
Current = nextRecord;
|
Current = nextRecord;
|
||||||
dataSource.Position = oldPos;
|
dataSource.Position = oldPos;
|
||||||
currentCount++;
|
currentCount++;
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
FileStream fs = File.OpenRead(source.Trim('\"'));
|
||||||
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");
|
||||||
|
|||||||
Reference in New Issue
Block a user