Exemple #1
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;
        }
Exemple #2
0
        public void WriteEVLRs(Stream stream, LASEVLR[] vlrs)
        {
            stream.Seek((long)m_startOfFirstExtendedVariableLengthRecord, SeekOrigin.Begin);

            using (var writer = new FlexibleBinaryWriter(stream))
            {
                foreach (var vlr in vlrs)
                {
                    writer.Write(vlr);
                }
            }
        }
Exemple #3
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;
        }
Exemple #4
0
 public void UpdateEVLR(LASRecordIdentifier record, ISerializeBinary obj)
 {
     for (var i = 0; i < m_evlrs.Length; i++)
     {
         if (m_evlrs[i].RecordIdentifier.Equals(record))
         {
             m_evlrs[i] = new LASEVLR(record, obj);
             break;
         }
     }
 }