Skip to content

Commit

Permalink
ZMap: support reading variant of format where there is no newline cha…
Browse files Browse the repository at this point in the history
…racter at end of column
  • Loading branch information
rouault committed Mar 14, 2024
1 parent 543cd3f commit fad01f6
Show file tree
Hide file tree
Showing 2 changed files with 258 additions and 193 deletions.
23 changes: 23 additions & 0 deletions autotest/gdrivers/zmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,26 @@ def test_zmap_nodata():
)
ds = None
gdal.GetDriverByName("ZMap").Delete(filename)


###############################################################################
# Test variant of the format where there is no flush at end of column


def test_zmap_no_flush_end_of_column(tmp_path):

src_ds = gdal.GetDriverByName("MEM").Create("", 2, 5)
src_ds.WriteRaster(0, 0, 2, 5, b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09")
filename = str(tmp_path / "out.zmap")
with gdaltest.config_option("ZMAP_EMIT_EOL_AT_END_OF_COLUMN", "NO"):
gdal.GetDriverByName("ZMap").CreateCopy(filename, src_ds)
f = gdal.VSIFOpenL(filename, "rb")
assert f
data = gdal.VSIFReadL(1, 1000, f)
gdal.VSIFCloseL(f)
assert (
data
== b"!\n! Created by GDAL.\n!\n@GRID FILE, GRID, 4\n 20, 1E+30, , 7, 1\n 5, 2, 0.0000000, 2.0000000, -5.0000000, 0.0000000\n0.0, 0.0, 0.0\n@\n 0.0000000 2.0000000 4.0000000 6.0000000\n 8.0000000 1.0000000 3.0000000 5.0000000\n 7.0000000 9.0000000\n"
)
ds = gdal.Open(filename)
assert ds.ReadRaster(buf_type=gdal.GDT_Byte) == src_ds.ReadRaster()
Loading

0 comments on commit fad01f6

Please sign in to comment.