Skip to content

Commit

Permalink
VICAR: support reading more data types and pixel organization (refs O…
Browse files Browse the repository at this point in the history
…SGeo#1855)

- Support FORMAT=HALF, DOUB and COMP
- Support big-endian order for integer & floating point values
- Support BIP and BIL organizations
- Ignore binary label records (NBL), and properly skip binary prefixes (NBB)
- Add tests
  • Loading branch information
rouault committed Oct 24, 2019
1 parent 9d8e1a9 commit cdc20de
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 204 deletions.
2 changes: 1 addition & 1 deletion autotest/cpp/test_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ namespace tut
ensure_equals( static_cast<int>(sLayout.eInterleaving),
static_cast<int>(GDALDataset::RawBinaryLayout::Interleaving::UNKNOWN) );
ensure_equals( sLayout.eDataType, GDT_Byte );
ensure( !sLayout.bLittleEndianOrder );
ensure( sLayout.bLittleEndianOrder );
ensure_equals( sLayout.nImageOffset, 9680U );
ensure_equals( sLayout.nPixelOffset, 1 );
ensure_equals( sLayout.nLineOffset, 400 );
Expand Down
Binary file added autotest/gdrivers/data/vicar_byte.vic
Binary file not shown.
Binary file added autotest/gdrivers/data/vicar_cfloat32.vic
Binary file not shown.
Binary file added autotest/gdrivers/data/vicar_float32_bil.vic
Binary file not shown.
Binary file added autotest/gdrivers/data/vicar_float32_bip.vic
Binary file not shown.
Binary file added autotest/gdrivers/data/vicar_float32_bsq.vic
Binary file not shown.
Binary file added autotest/gdrivers/data/vicar_float64.vic
Binary file not shown.
Binary file added autotest/gdrivers/data/vicar_int16.vic
Binary file not shown.
Binary file added autotest/gdrivers/data/vicar_int32.vic
Binary file not shown.
22 changes: 21 additions & 1 deletion autotest/gdrivers/vicar.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ def test_vicar_1():
for key in expected_md:
assert md[key] == expected_md[key]



read_datatypes_lists = [
('vicar_byte', gdal.GDT_Byte, 129),
('vicar_int16', gdal.GDT_Int16, 129),
('vicar_int32', gdal.GDT_Int32, 129),
('vicar_float32_bsq', gdal.GDT_Float32, 123),
('vicar_float32_bil', gdal.GDT_Float32, 123),
('vicar_float32_bip', gdal.GDT_Float32, 123),
('vicar_float64', gdal.GDT_Float64, 129),
('vicar_cfloat32', gdal.GDT_CFloat32, 148),
]

@pytest.mark.parametrize(
'filename,dt,checksum',
read_datatypes_lists,
ids=[tup[0] for tup in read_datatypes_lists],
)
def test_vicar_read_datatypes(filename, dt, checksum):

ds = gdal.Open('data/%s.vic' % filename)
b = ds.GetRasterBand(1)
assert b.DataType == dt
assert b.Checksum() == checksum
Loading

0 comments on commit cdc20de

Please sign in to comment.