Пример #1
0
        public void ReadNominalBilFile()
        {
            string path = rasterDataPath + "NominalMap.bil";
            var functionStore = new GdalFunctionStore { Path = path };
            functionStore.Open();
            var grid = (IRegularGridCoverage)functionStore.Functions.First(f => f is IRegularGridCoverage);
            Assert.AreEqual(typeof(Int32), grid.Components[0].ValueType);

            var expectedValues = new Int32[]
                                     {
                                         3, 3, 3, 4, -999, -999,
                                         3, 3, 3, 4, 4, -999,
                                         3, 3, 3, 3, 3, 3,
                                         1, 1, 1, 2, 2, 2,
                                         1, 1, 1, 2, 2, 2,
                                         1, 1, 1, 2, 2, 2
                                     };
            Assert.IsTrue(expectedValues.SequenceEqual<Int32>(grid.Components[0].GetValues<Int32>()));
        
          
        }
        public void SerializeArrays()
        {
            // Write data -------------------------------------
            var arrayUInt16 = new UInt16[] { 0, 900, 32000 };
           _serializer.Writer.WriteUInt16Array(arrayUInt16);
            AssertBytesWritten(8);

            var arrayUInt32 = new UInt32[] { 0, 900, 32000 };
           _serializer.Writer.WriteUInt32Array(arrayUInt32);
            AssertBytesWritten(14);

            var arrayInt16 = new Int16[] { -700, 0, 32000 };
           _serializer.Writer.WriteInt16Array(arrayInt16);
            AssertBytesWritten(8);

            var arrayInt32 = new Int32[] { -700, 0, 32000 };
           _serializer.Writer.WriteInt32Array(arrayInt32);
            AssertBytesWritten(14);

            var arrayInt64 = new Int64[] { -700, 0, 32000 };
           _serializer.Writer.WriteInt64Array(arrayInt64);
            AssertBytesWritten(26);

            _serializer.Writer.WriteUInt16Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteUInt32Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteInt16Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteInt32Array(null); AssertBytesWritten(1);
            _serializer.Writer.WriteInt64Array(null); AssertBytesWritten(1);


            // Message end
            _serializer.Writer.Internal.WriteDataUInt(Bms1Tag.MessageEnd, 0);
            AssertBytesWritten(1);

            // Read and verify data ----------------------------------------
            _stream.Position = 0;
            _serializer.Reader.Internal.ReadAttributes();

            Assert.IsTrue(arrayUInt16.SequenceEqual(_serializer.Reader.ReadUInt16Array()));
            Assert.IsTrue(arrayUInt32.SequenceEqual(_serializer.Reader.ReadUInt32Array()));
            Assert.IsTrue(arrayInt16.SequenceEqual(_serializer.Reader.ReadInt16Array()));
            Assert.IsTrue(arrayInt32.SequenceEqual(_serializer.Reader.ReadInt32Array()));
            Assert.IsTrue(arrayInt64.SequenceEqual(_serializer.Reader.ReadInt64Array()));

            Assert.IsNull(_serializer.Reader.ReadUInt16Array());
            Assert.IsNull(_serializer.Reader.ReadUInt32Array());
            Assert.IsNull(_serializer.Reader.ReadInt16Array());
            Assert.IsNull(_serializer.Reader.ReadInt32Array());
            Assert.IsNull(_serializer.Reader.ReadInt64Array());

            // Message end
            Assert.IsTrue(_serializer.Reader.Internal.EndOfBlock);
        }