Repository navigation
refactor(map): layer extents converted from the dataset's own coordinates - #2454
Conversation
…ates Part of opengeos#2032 (C1a). Dataset::extent_to_lonlat/lonlat_extent/to_lonlat and Layer::rows_extent convert from Dataset::coord_crs() to longitude/latitude; layer, map and selection extents, zoom to a feature, export notices, the OGC collection extent, raster grids from a layer, GeoLibre's working system, the Assistant's feature places and a shared map's locator use them. Every dataset is still in longitude/latitude, so nothing changes.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| // In longitude/latitude, the entries' system. The identity keeps the place as it is, as | ||
| // before; a place another system can't convert is left out (unreachable while every | ||
| // dataset is in longitude/latitude), as a NaN entry would make the locator unreadable. | ||
| let Some(c) = (if lonlat.is_identity() { Some(c) } else { lonlat.point(c) }) else { continue }; |
There was a problem hiding this comment.
Bug (medium-high confidence): the identity shortcut keeps NaN places, which can make the saved locator unreadable.
Reprojection::point already returns None for a non-finite place, even on the identity path (out.is_finite().then_some(out)). The shortcut skips that check. A geometry with NaN coordinates has a non-empty extent with a NaN centre, so the entry becomes (text, NaN, NaN). serde_json::to_vec writes NaN as null, and find reads the locator back into Vec<(String, f64, f64)>, which fails on null. The whole locator then reads as "not a RustGIS locator". The comment's own rationale (a NaN entry breaks the locator) applies here too.
For every finite place, point returns the same value as the shortcut, so removing the shortcut changes nothing except dropping the NaN entries. Suggested replacement:
| // In longitude/latitude, the entries' system. The identity keeps the place as it is, as | |
| // before; a place another system can't convert is left out (unreachable while every | |
| // dataset is in longitude/latitude), as a NaN entry would make the locator unreadable. | |
| let Some(c) = (if lonlat.is_identity() { Some(c) } else { lonlat.point(c) }) else { continue }; | |
| // In longitude/latitude, the entries' system: the identity gives each finite place as it | |
| // is. A place that is not finite, or that another system can't convert, is left out, as a | |
| // NaN entry would make the locator unreadable (it is saved as null and read back as numbers). | |
| let Some(c) = lonlat.point(c) else { continue }; |
Also, a feature left out here is silent. That is unreachable while every dataset is longitude/latitude, so it can wait for C2, but the notice should be added then (AGENTS.md "Never silent").
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Already raised: 0 (no prior review threads on this PR). Change sizeCompared with the base branch: the whole PR against main (merge base 89385f6 to PR head bf81237).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. |
Part of #2032 (C1a): a layer's extents are converted from its dataset's own coordinates to longitude/latitude, not read as longitude/latitude. Storage stays longitude/latitude (
Dataset::coord_crs()returns it for every dataset), so nothing a user sees changes; this is groundwork for layers that keep their own coordinates (C2).What it changes
Dataset::extent()is documented as the box in the dataset's own coordinates (what a file written in them holds). New:Dataset::extent_to_lonlat(&Extent): a box in its own coordinates in longitude/latitude, throughCrs::to(feat(data,map): convert between any two coordinate systems; draw layers from their own (#2032 B1+B2) #2448). Between longitude/latitude it is the box itself.Dataset::lonlat_extent():extent()through it.Dataset::lonlat_conversion(): the conversion itself (aReprojection), for places taken from its geometry one by one.Layer::rows_extent(rows)(new): the longitude/latitude box around some of a layer's features.Layer::extent,shown_extentandselection_extentuse it orlonlat_extent, and soMap::full_extent,shown_extentandselection_extentwith them.raster.projectandraster.rasterizewhen itsextentnames a layer;export_notestakes a longitude/latitude extent): layer export, conversion, table export, the app's download of a layer;lonlat_conversion(): the_lon/_latthe Assistant/MCP feature query gives for going to a feature, and the entries of a shared web map's locator (search box). A place another system couldn't convert would be left out (a NaN entry would make the locator unreadable); with every dataset in longitude/latitude the conversion is the identity, which keeps each place as it is.Left as they are, deliberately
Session::zoom_toandMap::fit_lonlat(they take a longitude/latitude box),SourceInfo.extent(streamed sources are read in longitude/latitude by theirReprojectuntil C2), raster extents, bookmarks and the extent history (stored as cameras in map units).looks_projected): they judge coordinates before they are stored; C2 changes them.gpkg_contentsbox: written from the features as written, in the file's system.Surfaces
No user-visible change on any surface (desktop, web, phone, CLI, Python, Assistant/MCP, ribbon, undo): no command, parameter, setting or saved field is added, and every dataset is in longitude/latitude, whose conversion gives the same box.
Tests
a_layers_extents_are_identity_converted_to_lonlat(map): a layer whose dataset records LV95 as its system gives its geometry's box as its extent, the same aslonlat_extent;rows_extentleaves out rows past the last; the selection's box, the layer's and the map's. It covers the identity, the only conversion a dataset has today.every_dataset_is_held_in_lonlat(data) now also checks that the longitude/latitude box is the geometry's, and an empty box stays empty.cargo xtask ci-equivalent run: fmt, clippy, tests, layers, schema, notices and the wasm build pass; the only test failures are three that fail on this machine onmaintoo (damaged_shapefiles_are_errors_or_skips_not_panics,reads_what_gdal_writes_when_gdal_is_installed,a_streamed_shapefile_is_framed_by_its_records). After the review fixes: clippy, and the assistant, map, engine and GeoLibre tests again (2729 passed).Summary by CodeRabbit