Repository navigation
feat(crs): write GeoJSON, CSV, KML and GPX in longitude/latitude from the system a layer holds (#2032 C1e part 2) - #2510
Conversation
… the system a layer holds (opengeos#2032 C1e part 2) The engine's direct writers (Convert/export workflow formats, packaged gp results, OGC collection and web layer zips, the plugin features call, the Python layer_geojson) convert the layer to longitude/latitude at the writer instead of assuming its coordinates are. Behaviour-neutral: every dataset holds longitude/latitude today.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| // Every format here is longitude/latitude. | ||
| let target = ps(p, "path").unwrap_or(&ds.name); | ||
| let mut notes = rustgis_data::export_notes([(ds, ds.lonlat_extent())], target, rustgis_data::raster::Crs::LonLat); | ||
| notes.extend(rustgis_data::io::export_losses_notes(ds, format, name_field, target).map_err(|e| e.to_string())?); |
There was a problem hiding this comment.
Memory: the CSV branch converts the layer twice once a layer holds another system. lonlat (line 2094) lives until the function returns, and export_losses_notes calls ds.in_lonlat() again for CSV (crates/data/src/io.rs:4324), so the peak is about 2× the layer, not the "≈1×, nothing converted twice" the PR body states. Today this is the identity path, so there is no cost yet.
Passing the already-converted copy here avoids the second copy. The losses notes only read coordinates in longitude/latitude, so the notes do not change. export_notes must keep ds, since it reads ds.crs.
| notes.extend(rustgis_data::io::export_losses_notes(ds, format, name_field, target).map_err(|e| e.to_string())?); | |
| notes.extend(rustgis_data::io::export_losses_notes(&lonlat, format, name_field, target).map_err(|e| e.to_string())?); |
Confidence: high on the code path, medium on how much this matters before a layer can hold another system.
| features.push_row(r.to_feature()); | ||
| if let Some(g) = r.geometry() | ||
| && let std::borrow::Cow::Owned(g) = | ||
| l.dataset.geometry_to_lonlat(g).map_err(|e| format!("{}: feature {}: {e}", l.name, r.id()))? |
There was a problem hiding this comment.
Performance (latent): Dataset::geometry_to_lonlat calls self.coord_crs().to(LonLat) on every call. For a layer in another system, that builds a Crs::transformer() per feature. ogc_warp::transformer caches the same construction for this reason. The per-feature loops here (also sharing.rs styled_features and the Python layer_geojson selection branch) would pay that cost once per feature.
Behaviour is unchanged today, since coord_crs() is always LonLat and the call returns early. Before a layer can hold another system, build the Reprojection once per layer (Dataset::lonlat_conversion() is already public) and convert each row with it, or add a helper that does so. No change is needed in this PR if the follow-up is tracked for C2.
Confidence: medium. The mechanism is clear from the code. The cost depends on how expensive Crs::transformer is for the systems in use.
Code reviewBehaviour is unchanged today: every dataset is held in longitude/latitude, so each Bugs
Security
Performance
Quality
AGENTS.md
Change sizeCompared with main (merge base e6f6e7b to PR head 72f7177).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
Part of #2032 (C1e, part 2 of 2; part 1 was #2507).
The engine's own writers of longitude/latitude formats convert the layer to longitude/latitude at the writer (
Dataset::in_lonlat,Dataset::geometry_to_lonlat) instead of assuming the layer already holds it. Behaviour-neutral: every dataset holds longitude/latitude today (coord_crs()isLonLat), so each conversion is the identity and borrows.Reached:
results/*.geojson).styled_features, which now returns an error naming the feature instead of writing raw coordinates).featurescall (with or withoutcrs: the target conversion now starts from longitude/latitude).layer_geojson(whole layer, read in place, selection).Not touched, already converting: clipboard copy (C1c), embeddings (fresh longitude/latitude datasets), analysis tool inputs for GeoLibre and plugin tools (
lonlat_inputsin gp.rs). Desktop, browser, phone and the Assistant reach these through the same commands; the CLI and MCP have no separate writer.Left for C2 (not longitude/latitude formats, but they read raw coordinates as degrees): STL mesh, glTF scene, the mobile package's simplify tolerance.
Size: no extra copy today. Once a layer holds another system,
in_lonlatmakes one converted copy of the layer (≈1× the layer) for the duration of the write; the plugin and web-map paths convert feature by feature.Rows: the touched loops now use the
Features/RowRefaccessors;xtask/row-uses.txtgoes 839 → 833.Tests: no new tests here. The hook that makes
coord_crs()return another system iscfg(test)in rustgis-data only; command-path tests on layers held natively come with C2, as promised in #2469/#2466. Local CI: fmt, clippy, workspace tests (only the three known box-only failures: damaged shapefiles, GDAL FileGDB, streamed shapefile framing), schema, notices, wasm,cargo xtask rows.Summary by CodeRabbit