Repository navigation
Save layers kept in a project in their own coordinate system (native-coordinates) #2598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -862,8 +862,8 @@ fn package_map(s: &mut Session, mobile: bool, tol: f64) -> Result<Vec<u8>, Strin | |
| if l.is_raster() || tol <= 0.0 { | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test gap (confidence about 60%). The PR body says a mobile package at tolerance 0 keeps a held layer in its own system and requires |
||
| continue; | ||
| } | ||
| // Simplified in longitude/latitude, as the package saves it, whatever system the | ||
| // layer holds its coordinates in. | ||
| // Simplified in longitude/latitude, as the tolerance is in degrees, whatever system | ||
| // the layer holds its coordinates in; the package saves it there. | ||
| if let std::borrow::Cow::Owned(ds) = l.dataset.in_lonlat()? { | ||
| l.dataset = ds; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,10 @@ impl Project { | |
| { | ||
| required.push("field-generation"); | ||
| } | ||
| // A table saved in a coordinate system of its own, as a layer's is (map_capabilities). | ||
| if !required.contains(&super::NATIVE_COORDINATES) && self.tables.iter().any(|t| held_natively(&t.dataset)) { | ||
| required.push(super::NATIVE_COORDINATES); | ||
| } | ||
| // Saved symbology keeps its images too. | ||
| if !required.contains(&"picture-markers") && self.styles.iter().any(|s| s.renderer.has_picture_markers()) { | ||
| required.push("picture-markers"); | ||
|
|
@@ -402,6 +406,13 @@ fn zarr_window(layer: &Layer) -> bool { | |
| layer.raster.as_ref().and_then(|r| r.time_zarr.as_ref()).is_some_and(|z| z.window.is_some()) | ||
| } | ||
|
|
||
| /// Whether a dataset is saved in a coordinate system of its own (`Dataset::held_in`): an older | ||
| /// reader would take its coordinates for longitude/latitude, and save it again without its | ||
| /// system (one with no features too, such as a template's layers). | ||
| fn held_natively(ds: &rustgis_data::Dataset) -> bool { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible rule conflict (confidence about 50%).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 4da2da1: the exemption is gone. A held layer with no features requires |
||
| !ds.windowed && ds.coord_crs() != rustgis_data::raster::Crs::LonLat | ||
| } | ||
|
|
||
| /// The capabilities a layer needs, in [`map_capabilities`]'s order. | ||
| fn layer_capabilities(layer: &Layer) -> Vec<&'static str> { | ||
| [ | ||
|
|
@@ -410,6 +421,7 @@ fn layer_capabilities(layer: &Layer) -> Vec<&'static str> { | |
| (layer.size_by.is_some(), super::SIZE_BY_CAPABILITY), | ||
| (layer.has_picture_markers(), "picture-markers"), | ||
| (zarr_window(layer), "zarr-window"), | ||
| (held_natively(&layer.dataset), super::NATIVE_COORDINATES), | ||
| ] | ||
| .into_iter() | ||
| .filter_map(|(used, name)| used.then_some(name)) | ||
|
|
@@ -430,7 +442,7 @@ fn map_capabilities<'a>(maps: impl IntoIterator<Item = &'a Map>) -> Vec<&'static | |
| mut pictures, | ||
| mut zarr, | ||
| ) = (false, false, false, false, false, false, false, false, false, false, false); | ||
| let (mut offline_area_id, mut paper) = (false, false); | ||
| let (mut offline_area_id, mut paper, mut native) = (false, false, false); | ||
| for map in maps { | ||
| offline_area_id |= map.offline_area_id.is_some(); | ||
| // A blank basemap's paper colour (#2532), which an older reader would draw and save white. | ||
|
|
@@ -450,6 +462,7 @@ fn map_capabilities<'a>(maps: impl IntoIterator<Item = &'a Map>) -> Vec<&'static | |
| sized |= map.layers.iter().any(|layer| layer.size_by.is_some()); | ||
| pictures |= map.layers.iter().any(Layer::has_picture_markers); | ||
| zarr |= map.layers.iter().any(zarr_window); | ||
| native |= map.layers.iter().any(|layer| held_natively(&layer.dataset)); | ||
| legends |= map.tiles.iter().any(|tile| { | ||
| tile.legends.iter().any(|legend| rustgis_data::login_address::inner(&legend.url).len() > rustgis_map::tiles::MAX_LEGEND_URL) | ||
| }); | ||
|
|
@@ -468,6 +481,7 @@ fn map_capabilities<'a>(maps: impl IntoIterator<Item = &'a Map>) -> Vec<&'static | |
| (zarr, "zarr-window"), | ||
| (offline_area_id, "offline-map-area-id"), | ||
| (paper, "blank-paper"), | ||
| (native, super::NATIVE_COORDINATES), | ||
| ] | ||
| .into_iter() | ||
| .filter_map(|(used, name)| used.then_some(name)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible cancellation regression (confidence about 40%). The removed
SavedInLonLatpath checked Cancel per row (stop_when_asked(i)) when it converted a held layer. Now a held layer is oneserializecall overfeatures.as_slice(), with no check. Lon/lat layers already worked this way, so the PR matches them. But a held layer used to be cancellable during save, and the PR body doesn't mention losing that. Please check whether a project save runs with Cancel. If it does, a long check here is needed, or the doc comment should say the step is not cancellable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept as is. The per-row check belonged to the conversion to lon/lat while writing, which was the slow part. That conversion is gone, so a held layer is now written as its rows are, exactly as lon/lat layers always were, with no per-row Cancel check. A save is no longer slower for a held layer than for a lon/lat one.