Exemplo n.º 1
0
 public SQuantizedExtent3D(Extent3D extent)
 {
     _min = new SQuantizedPoint3D((int)extent.MinX, (int)extent.MinY, (int)extent.MinZ);
     _max = new SQuantizedPoint3D((int)extent.MaxX, (int)extent.MaxY, (int)extent.MaxZ);
 }
Exemplo n.º 2
0
        public LasHeader(BinaryReader reader)
        {
            var length = reader.BaseStream.Length;

            if (length < MinHeaderSize[LasVersion.LAS_1_0])
            {
                throw new Exception("Invalid format: header too short");
            }

            if (Encoding.ASCII.GetString(reader.ReadBytes(FileSignature.Length)) != FileSignature)
            {
                throw new Exception("Invalid format: signature does not match");
            }

            _fileSourceId = reader.ReadUInt16();

            _globalEncoding = reader.ReadLasGlobalEncoding();
            _projectId      = reader.ReadLasProjectId();
            _version        = reader.ReadLasVersionInfo();

            _systemIdentifier      = reader.ReadBytes(32).ToAsciiString();
            _generatingSoftware    = reader.ReadBytes(32).ToAsciiString();
            _fileCreationDayOfYear = reader.ReadUInt16();
            _fileCreationYear      = reader.ReadUInt16();

            _headerSize        = reader.ReadUInt16();
            _offsetToPointData = reader.ReadUInt32();

            var minHeaderSize = MinHeaderSize[_version.Version];

            if (length < minHeaderSize)
            {
                throw new Exception("Invalid format: header too short for version");
            }
            if (minHeaderSize > _headerSize)
            {
                throw new Exception("Invalid format: header size incorrect");
            }

            _numberOfVariableLengthRecords = reader.ReadUInt32();
            _pointDataRecordFormat         = reader.ReadByte();
            _pointDataRecordLength         = reader.ReadUInt16();
            _legacyNumberOfPointRecords    = reader.ReadUInt32();
            _legacyNumberOfPointsByReturn  = reader.ReadUInt32Array(5);

            _quantization = reader.ReadSQuantization3D();
            _extent       = reader.ReadExtent3D();

            if (_version.Version >= LasVersion.LAS_1_3)
            {
                _startOfWaveformDataPacketRecord = reader.ReadUInt64();
            }

            if (_version.Version >= LasVersion.LAS_1_4)
            {
                _startOfFirstExtendedVariableLengthRecord = reader.ReadUInt64();
                _numberOfExtendedVariableLengthRecords    = reader.ReadUInt32();
                _numberOfPointRecords   = reader.ReadUInt64();
                _numberOfPointsByReturn = reader.ReadUInt64Array(15);
            }
            else
            {
                _numberOfPointRecords   = _legacyNumberOfPointRecords;
                _numberOfPointsByReturn = new ulong[15];
                for (var i = 0; i < _legacyNumberOfPointsByReturn.Length; i++)
                {
                    _numberOfPointsByReturn[i] = _legacyNumberOfPointsByReturn[i];
                }
            }

            // This doesn't apply to LAZ files
            //ulong pointDataRegionLength = (ulong)length - _offsetToPointData;
            //if (pointDataRegionLength < _pointDataRecordLength * PointCount)
            //    throw new Exception("Invalid format: point data region is not the expected size");
        }