Пример #1
0
 public LAZStreamReader(string path, LASHeader header, LASVLR lazEncodedVLR)
 {
     m_path = path;
     m_header = header;
     m_lazEncodedVLR = lazEncodedVLR;
     m_laz = new LAZInterop(m_path, m_header.OffsetToPointData, m_lazEncodedVLR.Data);
 }
Пример #2
0
		public LAZFile(string path)
			: base(path)
		{
			m_lazEncodedVLR = m_vlrs.FirstOrDefault(vlr => vlr.RecordIdentifier.Equals(c_record));

			if (m_lazEncodedVLR == null)
				throw new Exception("no laz record");
		}
Пример #3
0
        public LASFile(string path, LASHeader header, LASVLR[] vlrs, LASEVLR[] evlrs)
            : base(path)
        {
            m_header = header;
            m_vlrs = vlrs;
            m_evlrs = evlrs;

            using (var stream = File.Create(FilePath))
            {
                using (var writer = new FlexibleBinaryWriter(stream))
                {
                    header.Serialize(writer);
                }

                //header.WriteVLRs(stream, vlrs);
            }

            m_extent = m_header.Extent;
        }
Пример #4
0
        public void WriteVLRs(Stream stream, LASVLR[] vlrs)
        {
            //m_numberOfVariableLengthRecords = vlrs.Length;

            // my stream doesn't seek for now
            stream.Seek(m_headerSize, SeekOrigin.Begin);

            using (var writer = new FlexibleBinaryWriter(stream))
            {
                foreach (var vlr in vlrs)
                {
                    writer.Write(vlr);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// This will only work if point format, point length, offset, and scale are identical.
        /// </summary>
        public LASHeader(LASHeader[] headers, LASVLR[] vlrs, LASEVLR[] evlrs)
        {
            var header = headers[0];
            var extent = headers.Select(h => h.m_extent).Union3D();

            var points = (ulong)headers.Sum(h => (long)h.m_numberOfPointRecords);
            var pointsByReturn = new ulong[15];
            for (var i = 0; i < pointsByReturn.Length; i++)
            {
                pointsByReturn[i] = (ulong)headers.Sum(h => (long)h.m_numberOfPointsByReturn[i]);
            }

            uint legacyPoints = 0;
            uint[] legacyPointsByReturn;

            if (points > uint.MaxValue)
            {
                legacyPoints = 0;
                legacyPointsByReturn = new uint[5];
            }
            else
            {
                legacyPoints = (uint)points;
                legacyPointsByReturn = pointsByReturn.Take(5).Select(c => (uint)c).ToArray();
            }

            m_fileSourceID = header.m_fileSourceID;

            m_globalEncoding = header.m_globalEncoding;
            m_projectID = header.m_projectID;
            m_version = LASVersionInfo.Create(LASVersion.LAS_1_4);

            m_systemIdentifier = header.m_systemIdentifier;
            m_generatingSoftware = header.m_generatingSoftware;
            m_fileCreationDayOfYear = header.m_fileCreationDayOfYear;
            m_fileCreationYear = header.m_fileCreationYear;

            m_headerSize = c_minHeaderSize[LASVersion.LAS_1_4];
            m_offsetToPointData = m_headerSize + (uint)vlrs.Sum(vlr => vlr.Length);

            m_numberOfVariableLengthRecords = (uint)vlrs.Length;
            m_pointDataRecordFormat = header.m_pointDataRecordFormat;
            m_pointDataRecordLength = header.m_pointDataRecordLength;

            if (points > uint.MaxValue)
            {
                m_legacyNumberOfPointRecords = 0;
                m_legacyNumberOfPointsByReturn = new uint[5];
            }
            else
            {
                m_legacyNumberOfPointRecords = legacyPoints;
                m_legacyNumberOfPointsByReturn = legacyPointsByReturn;
            }

            m_quantization = header.m_quantization;
            m_extent = extent;

            m_startOfWaveformDataPacketRecord = 0;

            m_startOfFirstExtendedVariableLengthRecord = m_offsetToPointData + (points * m_pointDataRecordLength);
            m_numberOfExtendedVariableLengthRecords = (uint)evlrs.Length;
            m_numberOfPointRecords = points;

            m_numberOfPointsByReturn = pointsByReturn;
        }