public void OpenFileAndGetHeaderTest()
        {
            using (LasFileReader reader = new LasFileReader("file://" + _fixture.CurrentLasFilePath))
            {
                LasPublicHeader header = reader.Header;

                Assert.AreEqual(AEGIS.IO.GeometryStreamFormats.Lasfile, reader.Format);
                Assert.AreEqual((UInt16)39, header.FileSourceId);
                Assert.AreEqual(GPSTimeType.Standard, header.GPSTimeType);
                Assert.False(header.IsWavePacketStorageInternal);
                Assert.False(header.IsWavePacketStorageExternal);
                Assert.True(header.IsReturnNumberOriginSynthetical);
                Assert.AreEqual(CRSType.WKT, header.CRSType);
                Assert.AreEqual((UInt32)81, header.ProjectId1);
                Assert.AreEqual((UInt16)50, header.ProjectId2);
                Assert.AreEqual((UInt16)12, header.ProjectId3);
                Assert.AreEqual((UInt64)974, header.ProjectId4);
                Assert.AreEqual((Byte)1, header.VersionMajor);
                Assert.AreEqual((Byte)4, header.VersionMinor);
                Assert.AreEqual("OTHER", header.SystemIdentifier);
                Assert.AreEqual("LasFileReaderUnitTests", header.GeneratingSoftware);
                Assert.AreEqual((UInt16)286, header.FileCreationDay);
                Assert.AreEqual((UInt16)2020, header.FileCreationYear);
                Assert.AreEqual((UInt16)375, header.PublicHeaderSize);
                Assert.AreEqual((UInt32)375, header.PointDataOffset);
                Assert.AreEqual((UInt32)0, header.VariableLengthRecordCount);
                Assert.AreEqual((Byte)7, header.PointDataFormat);
                Assert.AreEqual((UInt16)36, header.PointDataLength);
                Assert.AreEqual((UInt32)0, header.LegacyPointCount);

                for (var i = 0; i < 5; i++)
                {
                    Assert.AreEqual((UInt32)0, header.LegacyPointCountPerReturn[i]);
                }

                Assert.AreEqual((Double)0.01, header.ScaleFactorX);
                Assert.AreEqual((Double)0.05, header.ScaleFactorY);
                Assert.AreEqual((Double)0.10, header.ScaleFactorZ);
                Assert.AreEqual((Double)(-0.50), header.OffsetX);
                Assert.AreEqual((Double)0.00, header.OffsetY);
                Assert.AreEqual((Double)0.50, header.OffsetZ);
                Assert.AreEqual((Double)100, header.MaxX);
                Assert.AreEqual((Double)0, header.MinX);
                Assert.AreEqual((Double)101, header.MaxY);
                Assert.AreEqual((Double)1, header.MinY);
                Assert.AreEqual((Double)102, header.MaxZ);
                Assert.AreEqual((Double)2, header.MinZ);
                Assert.AreEqual((UInt64)0, header.WavePacketRecordOffset);
                Assert.AreEqual((UInt64)0, header.ExtendedVariableLengthRecordOffset);
                Assert.AreEqual((UInt32)0, header.ExtendedVariableLengthRecordCount);
                Assert.AreEqual((UInt64)5, header.PointCount);
                Assert.AreEqual((UInt64)3, header.PointCountPerReturn[0]);
                Assert.AreEqual((UInt64)2, header.PointCountPerReturn[1]);

                for (var i = 2; i < 15; i++)
                {
                    Assert.AreEqual((UInt64)0, header.PointCountPerReturn[i]);
                }
            }
        }
        public void OpenFileLegacyFormatAndGetHeader()
        {
            using (LasFileReader reader = new LasFileReader("file://" + _fixture.LegacyLasFilePath))
            {
                LasPublicHeader header = reader.Header;

                Assert.AreEqual((UInt32)81, header.ProjectId1);
                Assert.AreEqual((UInt16)50, header.ProjectId2);
                Assert.AreEqual((UInt16)12, header.ProjectId3);
                Assert.AreEqual((UInt64)974, header.ProjectId4);
                Assert.AreEqual((Byte)1, header.VersionMajor);
                Assert.AreEqual((Byte)0, header.VersionMinor);
                Assert.AreEqual("OTHER", header.SystemIdentifier);
                Assert.AreEqual("LasFileReaderUnitTests", header.GeneratingSoftware);
                Assert.AreEqual((UInt16)286, header.FileCreationDay);
                Assert.AreEqual((UInt16)2020, header.FileCreationYear);
                Assert.AreEqual((UInt16)227, header.PublicHeaderSize);
                Assert.AreEqual((UInt32)227, header.PointDataOffset);
                Assert.AreEqual((UInt32)0, header.VariableLengthRecordCount);
                Assert.AreEqual((Byte)0, header.PointDataFormat);
                Assert.AreEqual((UInt16)20, header.PointDataLength);
                Assert.AreEqual((UInt32)5, header.LegacyPointCount);
                Assert.AreEqual((UInt32)3, header.LegacyPointCountPerReturn[0]);
                Assert.AreEqual((UInt32)2, header.LegacyPointCountPerReturn[1]);

                for (var i = 2; i < 5; i++)
                {
                    Assert.AreEqual((UInt32)0, header.LegacyPointCountPerReturn[i]);
                }

                Assert.AreEqual((Double)0.01, header.ScaleFactorX);
                Assert.AreEqual((Double)0.05, header.ScaleFactorY);
                Assert.AreEqual((Double)0.10, header.ScaleFactorZ);
                Assert.AreEqual((Double)(-0.50), header.OffsetX);
                Assert.AreEqual((Double)0.00, header.OffsetY);
                Assert.AreEqual((Double)0.50, header.OffsetZ);
                Assert.AreEqual((Double)100, header.MaxX);
                Assert.AreEqual((Double)0, header.MinX);
                Assert.AreEqual((Double)101, header.MaxY);
                Assert.AreEqual((Double)1, header.MinY);
                Assert.AreEqual((Double)102, header.MaxZ);
                Assert.AreEqual((Double)2, header.MinZ);
                Assert.AreEqual((UInt64)0, header.WavePacketRecordOffset);
                Assert.AreEqual((UInt64)0, header.ExtendedVariableLengthRecordOffset);
                Assert.AreEqual((UInt32)0, header.ExtendedVariableLengthRecordCount);
                Assert.AreEqual((UInt64)5, header.PointCount);
                Assert.AreEqual((UInt64)3, header.PointCountPerReturn[0]);
                Assert.AreEqual((UInt64)2, header.PointCountPerReturn[1]);

                for (var i = 2; i < 15; i++)
                {
                    Assert.AreEqual((UInt64)0, header.PointCountPerReturn[i]);
                }
            }
        }
Example #3
0
 public void SetUp()
 {
     // Initialize the header with default values.
     _header = new LasPublicHeader();
 }
        public void OpenFileNotSupportedPointVersionAndReadTest()
        {
            using (LasFileReader reader = new LasFileReader("file://" + _fixture.FutureLasFilePath))
            {
                LasPublicHeader header = reader.Header;

                Assert.AreEqual((UInt16)39, header.FileSourceId);
                Assert.AreEqual(GPSTimeType.Week, header.GPSTimeType);
                Assert.False(header.IsWavePacketStorageInternal);
                Assert.True(header.IsWavePacketStorageExternal);
                Assert.True(header.IsReturnNumberOriginSynthetical);
                Assert.AreEqual(CRSType.GeoTIFF, header.CRSType);
                Assert.AreEqual((UInt32)81, header.ProjectId1);
                Assert.AreEqual((UInt16)50, header.ProjectId2);
                Assert.AreEqual((UInt16)12, header.ProjectId3);
                Assert.AreEqual((UInt64)974, header.ProjectId4);
                Assert.AreEqual((Byte)1, header.VersionMajor);
                Assert.AreEqual((Byte)5, header.VersionMinor);
                Assert.AreEqual("OTHER", header.SystemIdentifier);
                Assert.AreEqual("LasFileReaderUnitTests", header.GeneratingSoftware);
                Assert.AreEqual((UInt16)286, header.FileCreationDay);
                Assert.AreEqual((UInt16)2020, header.FileCreationYear);
                Assert.AreEqual((UInt16)376, header.PublicHeaderSize);
                Assert.AreEqual((UInt32)376, header.PointDataOffset);
                Assert.AreEqual((UInt32)0, header.VariableLengthRecordCount);
                Assert.AreEqual((Byte)11, header.PointDataFormat);
                Assert.AreEqual((UInt16)37, header.PointDataLength);
                Assert.AreEqual((UInt32)0, header.LegacyPointCount);

                for (var i = 0; i < 5; i++)
                {
                    Assert.AreEqual((UInt32)0, header.LegacyPointCountPerReturn[i]);
                }

                Assert.AreEqual((Double)0.01, header.ScaleFactorX);
                Assert.AreEqual((Double)0.05, header.ScaleFactorY);
                Assert.AreEqual((Double)0.10, header.ScaleFactorZ);
                Assert.AreEqual((Double)(-0.50), header.OffsetX);
                Assert.AreEqual((Double)0.00, header.OffsetY);
                Assert.AreEqual((Double)0.50, header.OffsetZ);
                Assert.AreEqual((Double)100, header.MaxX);
                Assert.AreEqual((Double)0, header.MinX);
                Assert.AreEqual((Double)101, header.MaxY);
                Assert.AreEqual((Double)1, header.MinY);
                Assert.AreEqual((Double)102, header.MaxZ);
                Assert.AreEqual((Double)2, header.MinZ);
                Assert.AreEqual((UInt64)0, header.WavePacketRecordOffset);
                Assert.AreEqual((UInt64)0, header.ExtendedVariableLengthRecordOffset);
                Assert.AreEqual((UInt32)0, header.ExtendedVariableLengthRecordCount);
                Assert.AreEqual((UInt64)5, header.PointCount);
                Assert.AreEqual((UInt64)3, header.PointCountPerReturn[0]);
                Assert.AreEqual((UInt64)2, header.PointCountPerReturn[1]);

                for (var i = 2; i < 15; i++)
                {
                    Assert.AreEqual((UInt64)0, header.PointCountPerReturn[i]);
                }

                Boolean result = false;

                try
                {
                    reader.Read();
                }
                catch (InvalidDataException)
                {
                    result = true;
                }

                Assert.True(result);
            }
        }