Repository navigation
Commit d4595d1
authored
* feat(raster): read SRTM .hgt and DTED elevation natively (#2076)
SRTM tiles (.hgt) and DTED levels 0-2 (.dt0, .dt1, .dt2) now open in
pure Rust, on the desktop and in the web app, added by path or uploaded,
instead of only through GDAL.
An .hgt is placed by its name (N37W122) and checked by its size before
it is read; a wrong size or name is refused, saying why. DTED follows
MIL-PRF-89020B: signed-magnitude heights, the spacing zones, and the
checksum of each column. A column with a damaged header or a wrong
checksum, or one a cut-short file doesn't hold, is read as no data and
counted in a notice. Voids are no data, with a count. Each layer says
once that its heights are above the EGM96 geoid (mean sea level), not
the WGS 84 ellipsoid. Large files are read at a step within the memory
budget.
* fix(dted): read columns with wrong checksums, two's complement heights, the DSI's level
A column whose checksum doesn't match is read as stored and counted in a
notice, since some producers write wrong checksums. Only a damaged record
header makes a column no data. Heights that decode below -16000 m are read
as two's complement and counted. The DSI's series designator gives the
level, and a notice says when the extension disagrees.
* fix(hgt): read 0.5 arc-second tiles, center stepped cells on their posts
A 7201 x 7201 tile is read too, at a step where the memory budget calls
for one. Read at a step, each kept post is now the center of its cell for
SRTM and DTED alike. A name with a multi-byte character right after the
tile code is refused, and the "may be cut short" hint shows for any size
short of the largest tile.
* fix(raster): say when a crs or layer given for SRTM or DTED is ignored
These files are WGS 84 with one band. A "crs" or "layer" given with
layer.addData or layer.addDataBytes, or kept by a project saved when they
went through GDAL, is now said to be ignored rather than dropped
silently. The read still goes ahead.
* fix(python): embed only the elevation files that fit under the limit
An .hgt tile (2.9 MB at its smallest) and a DTED level 2 cell (4.3 MB at
its smallest) are always over EMBED_LIMIT (2 MiB), so they're added by
path. Level 0 (about 34 KB) stays, and so does level 1, which is under
the limit from 50 degrees of latitude, where its cells have fewer columns.
* refactor(raster): pictures take their read step from step_within
read_scan_limited worked out the same power-of-two step as step_within,
with the channels sharing the budget. It now calls step_within with the
budget divided by the channel count, which gives the same step and the
same error past a step of 2^20.
* chore: remove the review notes
* refactor(raster): move the shared elevation helpers into raster/mod.rs
* refactor(raster): one list of the elevation file extensions
* refactor(raster): check an SRTM tile's name and size once
* fix(dted): read records by place when their counts are numbered differently
* fix(raster): an elevation file read at a step keeps its scale exact
* fix(hgt): give the nearest tile sizes for a file of the wrong size
* fix(raster): say what an ignored crs or layer means for SRTM and DTED
* perf(raster): count skipped elevation posts without decoding them
* chore: remove the review notes
* fix(raster): an elevation file read at a step says its own size; the warp takes the step
* test(raster): pin the warp at a step, a fixture for elevation layers
A picture read at every second pixel of a 61-pixel-wide file is warped
by exactly two file pixels a cell; the old overview ratio was a cell off
toward the far edge. A project fixture keeps an .hgt layer with the crs
it saved when these went through GDAL, and a .dt1 layer. The SRTM and
DTED readers say they're one step that doesn't look at Cancel.
* fix(raster): cap elevation reads; refuse DTED tape-layout partial cells
The SRTM and DTED readers read no more than the size they checked, so a
file that grows in between is refused, not read whole. A DTED partial
cell in the magnetic-tape layout counts only the lines with heights and
leaves missing posts out of its records (MIL-PRF-89020B 3.11.3.2.2), so
fixed-length records would misplace them: it is refused. Partial cells
on the full CD-ROM grid read as before, their missing posts as voids.
* fix(dted): find a tape-layout partial cell by its DSI counts
The UHL counts a full cell on both media (MIL-PRF-89020B 3.12 c); on
tape only the DSI counts shrink to the lines with heights. The check
compared the UHL's, so it missed real tape files. It now refuses a
partial cell whose DSI counts are smaller than the UHL's.
A world-file test now also turns a picture read at a step, pinning the
turned grid's size at the file's resolution and its exact step.
* fix(raster): a turned picture read at a step says its true size
Placed by a turned world file, a picture read at every k-th pixel now
gives the whole file's size turned at its own resolution, sized as the
north-up grid is, not the reduced grid times k (4 × 102 for a 101 × 3
picture that turns to 3 × 101). It keeps its step, as a north-up one now
does too, so a later warp scales by exactly k; a turned grid made coarser
to fit goes by the sizes' ratio.
* docs(raster): say why the SRTM and DTED decode stays on one thread
The largest SRTM tile decodes in about 0.12 s in a release build, less
than reading its 104 MB from disk; a DTED cell is at most a quarter of
that.
* fix(data): the capped read sizes its buffer once, when the file's size is known
* fix(dted): refuse a partial cell whose file is shorter than its full grid
On tape a partial cell with a height on every line counts the whole cell
in its DSI too, but its records leave missing posts out
(MIL-PRF-89020B 3.11.3.2.2), so the check by counts missed it and its
columns were read out of place. The CD-ROM layout always holds every
record whole (3.11.3.2.1), so a partial cell whose file is shorter than
its full grid is now refused, said as cut short or tape layout, since the
two can't be told apart. A complete cell cut short is still read as far
as it goes.
* fix(dted): refuse record counts that place heights in another column; say voids in two's complement aren't found
* fix(dted): refuse a record whose latitude count isn't 0; the notice speaks of longitude counts only
* fix(raster): refuse DTED records whose counts would place heights in the wrong column (#2076)
Longitude counts are now read by place only when the whole cell counts
from 1 (every record its place + 1). Any other count that isn't the
record's place is refused, naming the first such record's place and
count. Before, a count naming no column (such as every count offset past
the cell's last line) or a column with its own record was read by place.
The notice now says the counts number the columns from 1, not that they
"don't match".
A record whose latitude count isn't 0 was already refused; it gets its
own test, with a negative count too. The data formats guide no longer
says latitude counts are read by place.
* fix(analysis): warp a stepped SRTM or DTED grid with each cell on its post
Read at a step, these readers center each kept cell on its post, so the
warp put every height (step-1)/2 file pixels off. The layer now says where
its corner lies in the file's pixels, and the warp uses it both ways.
* fix(raster): stream SRTM and DTED tiles from the file instead of holding them whole
On the desktop the readers now decode a row (SRTM) or record (DTED) at a
time, with the same checks, notices and errors, so a 7201 x 7201 tile
peaks at about 2x the file instead of 3x. The browser still reads bytes.
* fix(raster): an SRTM or DTED layer drops the crs it ignores, so reopening says it once
* docs(raster): the read-step comment in the picture reader says what it is
* docs(raster): state what the SRTM and DTED readers hold as a multiple of the file
* fix(raster): a DTED file read by path counts bytes added after its size check
---------
Co-authored-by: Cory Douglas Martin <4108748+flight1973@users.noreply.github.com>
1 parent 533e875 commit d4595d1
18 files changed
Lines changed: 2118 additions & 43 deletions
File tree
- apps
- rustgis-python/python/rustgis
- rustgis-web/src
- crates
- analysis/src
- data/src/raster
- engine/src
- cmd
- tests
- map/src
- ui-egui/src
- docs/user-guide
- schema/fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
1373 | 1374 | | |
1374 | 1375 | | |
1375 | 1376 | | |
1376 | | - | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
1377 | 1381 | | |
1378 | 1382 | | |
1379 | 1383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
226 | | - | |
227 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| |||
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
278 | | - | |
| 280 | + | |
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
| |||
1206 | 1208 | | |
1207 | 1209 | | |
1208 | 1210 | | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
1209 | 1267 | | |
1210 | 1268 | | |
1211 | 1269 | | |
| |||
0 commit comments