1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""Generate the committable SRTM `.hgt` test fixture `tests/fixtures/terrain/mini.hgt`.
This is the SRTM analogue of the committed `tools/egm2008_to70.gfc`: a tiny,
reproducible elevation tile (16-bit signed big-endian, row-major, **north row
first**, void sentinel -32768) that lets the `.hgt` parser be exercised in CI by
`include_bytes!` without a 25 MB download. Re-running this script reproduces the
committed file bit-for-bit.
The layout follows the GDAL SRTMHGT driver spec
(https://gdal.org/en/stable/drivers/raster/srtmhgt.html): an `N`x`N` tile spans a
1-degree cell whose lower-left corner is given by the filename; row 0 is the
northernmost latitude (`ll_lat + 1`), each value is `samples_per_side` apart at
`1/(N-1)` degree spacing, and -32768 marks a void.
We use `N = 11` (so the fixture is `2*11*11 = 242` bytes, < 1 KB) and a smooth,
deterministic synthetic relief plus two deliberately-placed void cells so the
NaN-propagation path is also covered. The elevation at row `i` (north→south),
column `j` (west→east) is:
elev(i, j) = round(800 + 600*sin(pi*i/(N-1)) * cos(pi*j/(N-1))) [metres]
with the two corners of the second interior row set to the void sentinel.
Usage:
python3 tools/gen_terrain_fixture.py tests/fixtures/terrain/mini.hgt
"""
= 11
= -32768
=
# Cells deliberately voided (row, col), north-row-first indexing, to exercise the
# void-rejection path in the parser/sampler.
=
return
= 800.0 + 600.0 * *
return
=
# row 0 = northernmost
# col 0 = westernmost
# 16-bit signed big-endian, row-major.
= b
assert == 2 * * ,
# Echo a few hand-checkable values so the Rust test can assert against them.
= // 2