Repository navigation
refactor(map): selection and view-distance boxes converted from the dataset's own coordinates - #2462
Conversation
…ataset's own coordinates Part of opengeos#2032 (C1b). Dataset::extent_from_lonlat converts a query box to a dataset's own coordinates; rectangle selection, workspace summaries and snapshots, the geoprocessing extent filter, the view clipping distance and radius selection convert explicitly instead of reading geometry as longitude/latitude. Every dataset is still in longitude/latitude, so nothing changes.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| pub fn extent_from_lonlat(&self, e: &Extent) -> Extent { | ||
| match raster::Crs::LonLat.to(self.coord_crs()) { | ||
| Ok(to) => to.extent(e), | ||
| Err(_) => Extent::EMPTY, |
There was a problem hiding this comment.
AGENTS.md (Never silent), confidence medium. This Err arm returns an empty box with no notice, and the same silent empty result shows up in within_report (network.rs, returns WithinReport::default()), in text_graphic_at/text_shown (mapview.rs, ? skips the layer), and in the view-distance and upright-marker paths (render). A failed conversion of a query box therefore selects fewer features (or none) without a notice. This can't be reached while coord_crs is always longitude/latitude, and the PR body already defers it, but the rule says existing silent losses are bugs and new paths shouldn't add one. Suggest either a Session::notify-style count for the case, or a test or doc that pins it as unreachable until C2.
Code reviewVerdict: The change is sound today. Every dataset is held in longitude/latitude, so each new conversion is the identity and no existing behaviour changes. The findings below concern the non-identity branches that C2 will be the first to run. Bugs
Security
Performance
Quality
AGENTS.md
Prior reviews
Change sizeCompared: the whole PR against main (merge base 82526c3 to PR head ae7dce2).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. |
Part of #2032 (C1b): selection and view-distance checks convert between a layer's own coordinates and longitude/latitude, not read its geometry as longitude/latitude. Storage stays longitude/latitude (
Dataset::coord_crs()returns it for every dataset), so nothing a user sees changes; this follows C1a (#2454) as groundwork for layers that keep their own coordinates (C2).What it changes
Dataset::extent_from_lonlat(&Extent)(new): a longitude/latitude box in the dataset's own coordinates, throughCrs::to. It is the reverse ofextent_to_lonlat(refactor(map): layer extents converted from the dataset's own coordinates #2454). A query box is converted once per layer, not once per feature. Between longitude/latitude it is the box itself. A box partly outside what the layer's system holds gives the part that converts. A streamed source'sextent_from_lonlatrefuses such a box instead; which suits layers that keep their own coordinates is for C2.select.byRect);text_shown), converted from the layer's own coordinates.within_view_distance, upright markers, and the hit-test of graphics text in the map view. Each converts with one conversion per layer.network::within_report, andwithinandwithin_countedwith it). It uses the geometry as it is while the conversion is the identity, so no copy is made today.Already in map units, unchanged
Map::hit,hits_atandhits_in(identify, select at a point, by rectangle), selection by polygon and snapping test the projected geometry. Since #2448 that geometry is drawn from the layer's own system.Left for later
snap_vertex::consider) projects the source geometry with the map's projection, as longitude/latitude: C1c, with editing.vertexedit.rs,design.rsandsketch.rsread vertices as longitude/latitude, as does the phone app's editing (ui-touchedit.rs). Moving a text graphic writes longitude/latitude: C1c.stac_area.rs) sends the selected geometries as a longitude/latitude area, and the globe draws stored geometry as longitude/latitude: both still to convert (C1e and drawing).coord_crssays.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 conversions give the same boxes and places.
Tests
every_dataset_is_held_in_lonlat(data) also checks that a longitude/latitude box asked of a dataset is the same box, and an empty one stays empty.a_box_partly_outside_its_target_keeps_the_part_that_converts(data): whatextent_from_lonlatwill do for a layer in its own system. A box with a corner UTM 32N can't bring back gives the box of the rest; a box wholly outside gives an empty one. The other non-identity branches (within_report's conversion, the view-distance and text-graphic conversions) can't run while every dataset is in longitude/latitude; C2 brings their tests.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).Summary by CodeRabbit