Skip to content

Commit 744d8d8

Browse files
authored
Merge pull request OSGeo#9457 from rouault/zmap_no_flush_end_of_column
ZMap: support reading variant of format where there is no newline character at end of column
2 parents 634ecf0 + 59505b2 commit 744d8d8

File tree

2 files changed

+258
-193
lines changed

2 files changed

+258
-193
lines changed

autotest/gdrivers/zmap.py

+23
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,26 @@ def test_zmap_nodata():
6565
)
6666
ds = None
6767
gdal.GetDriverByName("ZMap").Delete(filename)
68+
69+
70+
###############################################################################
71+
# Test variant of the format where there is no flush at end of column
72+
73+
74+
def test_zmap_no_flush_end_of_column(tmp_path):
75+
76+
src_ds = gdal.GetDriverByName("MEM").Create("", 2, 5)
77+
src_ds.WriteRaster(0, 0, 2, 5, b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09")
78+
filename = str(tmp_path / "out.zmap")
79+
with gdaltest.config_option("ZMAP_EMIT_EOL_AT_END_OF_COLUMN", "NO"):
80+
gdal.GetDriverByName("ZMap").CreateCopy(filename, src_ds)
81+
f = gdal.VSIFOpenL(filename, "rb")
82+
assert f
83+
data = gdal.VSIFReadL(1, 1000, f)
84+
gdal.VSIFCloseL(f)
85+
assert (
86+
data
87+
== 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"
88+
)
89+
ds = gdal.Open(filename)
90+
assert ds.ReadRaster(buf_type=gdal.GDT_Byte) == src_ds.ReadRaster()

0 commit comments

Comments
 (0)