Skip to content

refactor(map): layer extents converted from the dataset's own coordinates - #2454

Merged
pick2510 merged 1 commit into
opengeos:mainfrom
pick2510:feat/crs-extents
Nov 19, 2026
Merged

pick2510 merged 1 commit into
opengeos:mainfrom
pick2510:feat/crs-extents

Conversation

@pick2510

@pick2510 pick2510 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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:
  • Layer::rows_extent(rows) (new): the longitude/latitude box around some of a layer's features. Layer::extent, shown_extent and selection_extent use it or lonlat_extent, and so Map::full_extent, shown_extent and selection_extent with them.
  • Callers that took a box as longitude/latitude now ask for one:
    • zooming to a feature: search results, the map series page, the shown feature (pop-up zoom);
    • Add Photos' zoom to the added photos;
    • the output grid of raster.project and raster.rasterize when its extent names a layer;
    • the OGC collection extent (CRS84) in a shared web map;
    • export notices (export_notes takes a longitude/latitude extent): layer export, conversion, table export, the app's download of a layer;
    • GeoLibre's working system (UTM zone from the inputs' extent).
  • Places read as longitude/latitude now converted with lonlat_conversion(): the _lon/_lat the 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

  • Already longitude/latitude by contract: Session::zoom_to and Map::fit_lonlat (they take a longitude/latitude box), SourceInfo.extent (streamed sources are read in longitude/latitude by their Reproject until C2), raster extents, bookmarks and the extent history (stored as cameras in map units).
  • Readers' checks on what they read (the Shapefile reader's "not longitude/latitude" notice, GeoLibre's looks_projected): they judge coordinates before they are stored; C2 changes them.
  • The GeoPackage gpkg_contents box: written from the features as written, in the file's system.
  • Feature boxes used for selection, hit-testing, editing and the view clipping distance: C1b and C1c.

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 as lonlat_extent; rows_extent leaves 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.
  • Existing zoom, search, map series, export notice and sharing tests pass unchanged.

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 on main too (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

  • Bug Fixes
    • Map extents, feature zooming, photo zooming, and imagery bounds now use consistent coordinate conversions, improving navigation when datasets use projected coordinates.
    • Export notes, collection extents, and browser-reported layer extents now reflect longitude and latitude coordinates.
    • Locations that cannot be converted to longitude and latitude are omitted, and empty extents remain empty.

…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.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Dataset and layer extent APIs now provide longitude/latitude coordinates. Navigation, export, locator, assistant, and working-CRS paths use these conversions or converted extents.

Changes: Extent Coordinate Conversion

Layer / File(s) Summary
Dataset extent conversion
crates/data/src/lib.rs, crates/data/src/raster/reproject.rs
Dataset now exposes methods to convert extents and points to longitude/latitude. Tests cover identity conversion and empty extents.
Layer extents and navigation
crates/map/src/lib.rs, crates/engine/src/cmd/imagery.rs, crates/engine/src/cmd/layer.rs, crates/engine/src/cmd/layout.rs, crates/engine/src/cmd/search.rs, crates/ui-egui/src/mapview.rs
Layer extent methods convert row and selection geometry extents to longitude/latitude. Navigation and imagery callers use those methods, and photo extents are converted before zooming.
Exports and coordinate outputs
crates/assistant/src/tools.rs, crates/engine/src/cmd/share*, crates/engine/src/cmd/sharing.rs, crates/engine/src/cmd/workflows.rs, crates/geolibre/src/lib.rs, crates/ui-egui/src/lib.rs
Export notes, collection extents, locator coordinates, assistant feature coordinates, and working-CRS selection now use longitude/latitude extents or conversions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

  • opengeos/RustGIS#2032: The issue describes explicit longitude/latitude conversion at extent and zoom boundaries, which this PR implements in several paths.

Possibly related PRs

  • opengeos/RustGIS#2448: It adds coordinate-system conversions for points, geometries, and extents, which this PR uses for dataset extent conversion.

Suggested reviewers: giswqs, mavrick-f

Merge Risk: Minimal · up to bf812

This change prepares extent handling for future native coordinates without altering current behavior, since all datasets are still stored in longitude/latitude. No user-visible change or merge-blocking risk is expected.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change to layer extents, which the changeset does: Layer extents and related extent helpers now convert from the dataset's own coordinates to longitude/latitude. It is specific and…
Description check Passed The description follows the template. It has a Summary section that explains the change and its rationale. It has a Testing section that lists the new tests and the CI-equivalent run, with the pre-exi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change to layer extents, which the changeset does: Layer extents and related extent helpers now convert from the dataset's own coordinates to longitude/latitude. It is specific and conventional, but the 'refactor' label is a little generous since the PR also changes some caller behavior, such as the locator filtering and the Assistant feature place conversion. The title is fully related to the main change.

Full details: Description check

Explanation

The description follows the template. It has a Summary section that explains the change and its rationale. It has a Testing section that lists the new tests and the CI-equivalent run, with the pre-existing failures noted. It has a Related issue reference (Part of #2032). The UI evidence section is missing its required 'No visible UI change.' line? No: the author states 'Surfaces: No user-visible change on any surface' but the template's UI evidence section is not explicitly filled with the 'No visible UI change.' line. The author's wording covers that intent, but the template line itself is absent.

Resolution

Optionally add the template line 'No visible UI change.' under the UI evidence heading so the section matches the template exactly.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit maps each feature’s place,
Then turns its bounds to lon-lat space.
The zoom now finds the converted view,
Export notes use coordinates true.
I twitch my nose and hop away.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9e311492-b3df-42c8-b11a-e3fa433e3ef8
Commits

Reviewing files that changed from the base of the PR and between 89385f6 and bf81237.

Files selected for processing: 15

  • crates/assistant/src/tools.rs
  • crates/data/src/lib.rs
  • crates/data/src/raster/reproject.rs
  • crates/engine/src/cmd/imagery.rs
  • crates/engine/src/cmd/layer.rs
  • crates/engine/src/cmd/layout.rs
  • crates/engine/src/cmd/search.rs
  • crates/engine/src/cmd/share.rs
  • crates/engine/src/cmd/share/table.rs
  • crates/engine/src/cmd/sharing.rs
  • crates/engine/src/cmd/workflows.rs
  • crates/geolibre/src/lib.rs
  • crates/map/src/lib.rs
  • crates/ui-egui/src/lib.rs
  • crates/ui-egui/src/mapview.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Comment on lines +938 to +941
// 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 };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
// 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").

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • crates/engine/src/cmd/sharing.rs:941: the identity shortcut in locator keeps non-finite places, although Reprojection::point already drops them. A NaN centre is saved as null and then fails to read back as f64, so the whole locator file becomes unreadable. The shortcut is also the only thing that keeps this path from matching point(). Posted inline with a fix. The NaN path predates this PR and the PR keeps it on purpose, so this is a pre-existing bug that the PR preserves. Confidence: medium-high.

Security

  • None found in the changed lines.

Performance

  • None found. For the longitude/latitude case, Crs::to returns without asking for a transformer, so the new conversion calls cost almost nothing. Layer::extent remains O(n), as it was before.

Quality

  • crates/data/src/lib.rs (extent_to_lonlat) and the locator continue: a conversion failure gives an empty extent or a skipped place with no notice. This is unreachable today because coord_crs always returns longitude/latitude, and the doc comments say a notice is needed before C2. Confidence: high that it is unreachable now, low concern. Left for C2.
  • No test covers the locator, read_features _lon/_lat, or series_page conversion. Only the identity path is tested. This is a quality point, so it can wait for the release quality pass.

AGENTS.md

  • The rules that matter are followed: no new unwrap, extent() callers were checked, and the surfaces and undo are covered in the PR body. The only remaining raw Dataset::extent() callers in non-test code are reader checks (looks_projected, the Shapefile check, the GeoPackage gpkg_contents box), which the PR says it leaves alone on purpose. I did not run cargo xtask or the wasm build, since I have no shell here.

Already raised: 0 (no prior review threads on this PR).

Change size

Compared with the base branch: the whole PR against main (merge base 89385f6 to PR head bf81237).

Measure Value
Files changed 15 (0 added, 15 modified, 0 removed, 0 renamed)
Size before 2.23 MB (2,341,419 B)
Size after 2.24 MB (2,344,776 B)
Total size change +3.3 KB (+3,357 B)
Path Before After Change
crates/data/src/lib.rs 41.8 KB 43.3 KB +1.5 KB
crates/map/src/lib.rs 203.8 KB 205.2 KB +1.4 KB
crates/engine/src/cmd/sharing.rs 90.8 KB 91.3 KB +439 B
crates/data/src/raster/reproject.rs 10.6 KB 10.9 KB +342 B
crates/engine/src/cmd/imagery.rs 123.2 KB 123.0 KB −197 B
crates/engine/src/cmd/search.rs 61.7 KB 61.5 KB −168 B
crates/engine/src/cmd/layout.rs 318.9 KB 318.8 KB −89 B
crates/ui-egui/src/mapview.rs 321.9 KB 321.8 KB −84 B
crates/assistant/src/tools.rs 59.4 KB 59.4 KB +75 B
crates/engine/src/cmd/layer.rs 359.1 KB 359.1 KB +41 B
crates/engine/src/cmd/share.rs 45.3 KB 45.3 KB +30 B
crates/ui-egui/src/lib.rs 491.3 KB 491.3 KB +30 B
crates/engine/src/cmd/share/table.rs 11.5 KB 11.5 KB +7 B
crates/engine/src/cmd/workflows.rs 108.2 KB 108.2 KB +7 B
crates/geolibre/src/lib.rs 39.1 KB 39.1 KB +7 B

@pick2510
pick2510 enabled auto-merge November 19, 2026 13:06
@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2454/
Web app https://preview.rustgis.app/pr-2454/app/
Commit bf81237

GitHub Pages takes a minute or two to publish a new commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant