diff --git a/crates/data/src/lidar.rs b/crates/data/src/lidar.rs index c5281101d2..2d31771eed 100644 --- a/crates/data/src/lidar.rs +++ b/crates/data/src/lidar.rs @@ -692,25 +692,27 @@ mod tests { /// the source, while missing records still prevent a whole read. #[test] fn source_materializes_with_counted_losses() { - let mut bytes = las(2, 0, &[(0.0, 0.0, 3.0, 2), (1.0, 0.0, 4.0, 2)], Some("EPSG:32632")); - // A finite scale overflows only the second point's X during coordinate decoding. + let mut bytes = las(2, 0, &[(0.0, 0.0, 3.0, 2), (1.0, 0.0, 4.0, 2), (0.0, 0.0, 5.0, 2)], Some("EPSG:32632")); + // A finite scale overflows only the second point's X during coordinate decoding: the one in + // the middle. bytes[131..139].copy_from_slice(&f64::MAX.to_le_bytes()); let (direct, report) = read_bytes(&bytes, "lossy", None).unwrap(); - assert_eq!(direct.features.len(), 1); + assert_eq!(direct.features.len(), 2); assert!(!direct.crs_incomplete); assert_eq!(report.skipped, 1); assert_eq!(report.messages, ["lossy: one point has a coordinate that isn't a number (NaN or infinite) and was left out"]); let src = crate::source::open_bytes("lossy.las", bytes.clone(), None).unwrap(); - assert_eq!(src.info().count, Some(2)); + assert_eq!(src.info().count, Some(3)); let (ds, report) = crate::source::materialize(src.as_ref()).unwrap(); assert_eq!(ds.features, direct.features); assert!(!ds.crs_incomplete); assert_eq!(report.skipped, 1); assert_eq!(report.messages.len(), 1, "{:?}", report.messages); - // The sample's places stay in step with its points past the one left out. + // The sample's places stay in step with its points past the one left out: the point after + // it is found by its own place. let around = Extent::new(4.0, -1.0, 5.0, 1.0); let batch = src.read(&crate::source::Request { extent: Some(around), limit: 10, own: None }).unwrap(); - assert_eq!(batch.features.iter().map(|f| f.id).collect::>(), [0]); + assert_eq!(batch.features.iter().map(|f| f.id).collect::>(), [0, 2]); bytes.truncate(bytes.len() - usize::from(RECORD_LEN[0])); assert!(crate::io::read_bytes("truncated.las", &bytes).is_err()); let truncated = crate::source::open_bytes("truncated.las", bytes, None).unwrap(); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 0d1bb0fb2c..30af8d0dbd 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -154,6 +154,7 @@ pub use chrome::{DoubleClick, TitlebarMetrics}; pub use coordreadout::{CoordReadout, MapSystem}; pub use rustgis_assistant; pub use rustgis_engine; +pub use vertexedit::unplaced_feature_notice; pub use widgets::big_split_menu; /// Reconciles only command-result wrappers, not parameters or other arbitrary JSON. diff --git a/crates/ui-egui/src/mapview.rs b/crates/ui-egui/src/mapview.rs index 97dc521115..63da2526d5 100644 --- a/crates/ui-egui/src/mapview.rs +++ b/crates/ui-egui/src/mapview.rs @@ -313,6 +313,16 @@ pub struct MapView { pub vertex_drag: Option, /// Non-owning source identity for the held vertex gesture; never persisted with the project. pub(crate) vertex_drag_owner: Option, + /// The selected features Edit Vertices last said it can't give handles to (their place can't + /// be given in longitude/latitude), by map index, live layer ([`rustgis_engine::map::Layer::instance_id`]) + /// and row, so it says so once per selection. + pub(crate) vertex_unplaced_said: Vec<(usize, u64, usize)>, + /// Whether there were more than those, the notice saying "at least" so many. + pub(crate) vertex_unplaced_more: bool, + /// How many of each layer's selected rows that scan went through, by live layer. + pub(crate) vertex_unplaced_visited: Vec<(u64, usize)>, + /// What those features were last looked for under, so they aren't looked for each frame. + pub(crate) vertex_unplaced_seen: Option, /// Session-only opt-in for coincident polygon moves; never saved with a project or preference. pub move_shared_vertices: bool, /// A sketch vertex clicked on an edge follows that edge from the previous vertex (Trace); @@ -450,6 +460,10 @@ impl Default for MapView { vertex_owner: None, vertex_drag: None, vertex_drag_owner: None, + vertex_unplaced_said: Vec::new(), + vertex_unplaced_more: false, + vertex_unplaced_visited: Vec::new(), + vertex_unplaced_seen: None, move_shared_vertices: false, trace_edges: false, sketch_full_said: false, @@ -523,6 +537,10 @@ impl MapView { self.split_gpu = None; self.live_rev = None; self.gpu_turn_declined = None; + self.vertex_unplaced_said.clear(); + self.vertex_unplaced_more = false; + self.vertex_unplaced_visited.clear(); + self.vertex_unplaced_seen = None; self.labels.clear(); self.label_lonlat.clear(); self.label_map.clear(); @@ -810,6 +828,7 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { crate::modelbuilder::follow_view(app); view_tabs(app, ui, &t); crate::vertexedit::cancel_stale_drag(app); + crate::vertexedit::say_unplaced(app); if app.mb.shown() { crate::modelbuilder::show(app, ui); return; diff --git a/crates/ui-egui/src/vertexedit.rs b/crates/ui-egui/src/vertexedit.rs index b53c8007cb..f215498240 100644 --- a/crates/ui-egui/src/vertexedit.rs +++ b/crates/ui-egui/src/vertexedit.rs @@ -6,7 +6,7 @@ use std::borrow::Cow; use egui::{Color32, Painter, Pos2, Rect, Stroke, vec2}; -use rustgis_engine::data::{Feature, Geometry, VertexId}; +use rustgis_engine::data::{Dataset, Feature, Geometry, VertexId}; use rustgis_engine::geom::Coord; use serde_json::json; @@ -181,6 +181,152 @@ fn targets(app: &RustGisApp) -> Vec<(u32, usize, Cow<'_, Geometry>)> { out } +/// The most selected features [`say_unplaced`] looks for with no place in longitude/latitude: past +/// it, the notice says "at least" so many, and the scan stops. +const MAX_UNPLACED: usize = 1000; + +/// The selected features [`targets`] leaves out, by layer and row, while Edit Vertices is on: +/// those with a place that can't be given in longitude/latitude (#2032 C2f-4b), where handles are +/// drawn and dragged. On a map in the layer's own system such a feature is drawn and selected. +/// Up to [`MAX_UNPLACED`] of them. +struct Unplaced { + rows: Vec<(u32, usize)>, + /// There are more than [`MAX_UNPLACED`]. + more: bool, + /// How many of each layer's selected rows the scan went through, by live layer: past them, + /// nothing it says depends on the selection ([`unplaced_signature`]). + visited: Vec<(u64, usize)>, +} + +fn unplaced_targets(app: &RustGisApp) -> Unplaced { + let m = app.session.map(); + // The features `targets` looks at, in its order, until it has its cap of placed ones: a + // feature past that gets no handles either way, so isn't counted. Each layer's conversion is + // made once. A row without geometry counts towards neither bound. + let mut found = Unplaced { rows: Vec::new(), more: false, visited: Vec::new() }; + let mut placed = 0usize; + for l in m.layers.iter().filter(|l| m.shows(l) && !l.selection.is_empty() && !l.is_raster() && !l.graphics && !l.is_streamed()) { + let to = l.dataset.shown_conversion(); + let mut visited = 0; + for r in &l.selection { + if placed >= MAX_FEATURES { + break; + } + visited += 1; + if let Some(g) = l.dataset.features.geometry(*r) { + match to.as_ref().ok().and_then(|to| Dataset::converted_to_lonlat(to, g)) { + Some(_) => placed += 1, + None if found.rows.len() >= MAX_UNPLACED => { + found.more = true; + break; + } + None => found.rows.push((l.id, *r)), + } + } + } + found.visited.push((l.instance_id(), visited)); + if placed >= MAX_FEATURES || found.more { + break; + } + } + found +} + +/// What [`unplaced_targets`] depends on: the map and each layer it looks at (the live layer, its +/// replacement and geometry revisions and rows' allocation, which any mutable row access renews, +/// its system, the map system it is shown through, and its selection: its length and the rows the +/// last scan went through, `visited`, so a large selection isn't hashed whole each frame). While +/// those are unchanged, the scan would go through the same rows and stop where it did, so the +/// selection isn't converted again. +fn unplaced_signature(app: &RustGisApp) -> u64 { + use std::hash::{Hash, Hasher}; + let m = app.session.map(); + let mut h = std::collections::hash_map::DefaultHasher::new(); + app.session.project.active_map.hash(&mut h); + for l in m.layers.iter().filter(|l| m.shows(l) && !l.selection.is_empty() && !l.is_raster() && !l.graphics && !l.is_streamed()) { + let rows = l.dataset.features.allocation_key().as_ptr() as usize; + let revisions = (l.instance_id(), l.replacement_revision(), l.geometry_rev, rows); + let visited = app.map.vertex_unplaced_visited.iter().find(|(id, _)| *id == l.instance_id()).map_or(0, |(_, n)| *n); + let reached = l.selection.get(..l.selection.len().min(visited)).unwrap_or_default(); + (revisions, l.dataset.coord_crs(), l.dataset.shown_in, l.selection.len(), reached).hash(&mut h); + } + h.finish() +} + +/// The notice for a feature whose vertices can't be edited, as `layer` holds it in `system`: one of +/// its places can't be given in longitude/latitude (#2032 C2f-4b). The desktop's Edit Vertices and +/// the phone's shape editing say it alike. +pub fn unplaced_feature_notice(layer: &str, id: u64, system: &str) -> String { + crate::i18n::fmt( + "{layer}: feature {id} has a place in {system} that can't be given in longitude/latitude, so its vertices can't be edited there", + &[("layer", layer), ("id", &id.to_string()), ("system", system)], + ) +} + +/// Says once per selection which selected features Edit Vertices gives no handles to, in one +/// notice: one is named, several counted ([`unplaced_targets`]). Nothing is looked at while the +/// tool or editing is off. +pub(crate) fn say_unplaced(app: &mut RustGisApp) { + if app.session.tool != rustgis_engine::Tool::EditVertices || !app.session.map().editing.settings.enabled { + // Coming back to the tool says the selection again. + app.map.vertex_unplaced_said.clear(); + app.map.vertex_unplaced_more = false; + app.map.vertex_unplaced_seen = None; + app.map.vertex_unplaced_visited.clear(); + return; + } + let signature = unplaced_signature(app); + if app.map.vertex_unplaced_seen == Some(signature) { + return; + } + app.map.vertex_unplaced_seen = Some(signature); + // The map's index and the live layer go with the features: another map's layers, or a layer + // added in a removed one's place, may have the same ids. + let map = app.session.project.active_map; + let Unplaced { rows: found, more, visited } = unplaced_targets(app); + app.map.vertex_unplaced_visited = visited; + let m = app.session.map(); + let live = |id: u32| m.layer(id).map_or(0, |l| l.instance_id()); + let left: Vec<(usize, u64, usize)> = found.iter().map(|(l, r)| (map, live(*l), *r)).collect(); + // Whether there were more goes with them: past the bound, the count turns to "at least". + if (&left, more) == (&app.map.vertex_unplaced_said, app.map.vertex_unplaced_more) { + return; + } + let text = match (found.as_slice(), more) { + ([], _) => None, + ([(layer, r)], false) => m + .layer(*layer) + .and_then(|l| Some(unplaced_feature_notice(&l.name, l.dataset.features.row(*r)?.id(), &l.dataset.coord_crs().label()))), + (several, more) => { + let mut layers: Vec<&str> = Vec::new(); + for (id, _) in several { + if let Some(l) = m.layer(*id).filter(|l| !layers.contains(&l.name.as_str())) { + layers.push(&l.name); + } + } + let count = several.len().to_string(); + let args = [("layers", layers.join(", ")), ("count", count)]; + let args: Vec<(&str, &str)> = args.iter().map(|(k, v)| (*k, v.as_str())).collect(); + Some(if more { + crate::i18n::fmt( + "{layers}: at least {count} of the selected features have a place that can't be given in longitude/latitude, so their vertices can't be edited there", + &args, + ) + } else { + crate::i18n::fmt( + "{layers}: {count} of the selected features have a place that can't be given in longitude/latitude, so their vertices can't be edited there", + &args, + ) + }) + } + }; + app.map.vertex_unplaced_said = left; + app.map.vertex_unplaced_more = more; + if let Some(text) = text { + app.session.notify(text, true); + } +} + /// The screen points of an edge's ends, when both are in view. fn edge_on_screen(app: &RustGisApp, rect: Rect, a: Coord, b: Coord) -> Option<(Pos2, Pos2)> { Some((lonlat_to_screen(app, rect, a)?, lonlat_to_screen(app, rect, b)?)) @@ -542,6 +688,154 @@ mod tests { app } + /// A selected feature with a place that can't be given in longitude/latitude gets no handles, + /// and that is said once for the selection, naming it (#2032 C2f-4b); several are counted. + #[test] + fn a_selected_feature_with_no_place_in_longitude_latitude_is_said_once() { + let mut app = app([square(0.), square(2.), square(4.)].into_iter()); + let id = app.session.active_layer.unwrap(); + let utm = rustgis_engine::data::raster::Crs::from_epsg(32631).unwrap(); + app.session.map_mut().editing.settings.enabled = true; + app.session.map_mut().layer_mut(id).unwrap().dataset.hold_in(utm).unwrap(); + // Placed features: nothing to say. + let mark = app.session.notice_mark(); + say_unplaced(&mut app); + assert!(app.session.notices_since(mark).is_empty()); + assert_eq!(targets(&app).len(), 1); + let layer = app.session.map_mut().layer_mut(id).unwrap(); + let far = + |x: f64| Geometry::Polygon(vec![vec![vec![Coord::new(x, 0.), Coord::new(1e9, 0.), Coord::new(x, 1.), Coord::new(x, 0.)]]]); + layer.dataset.features[0].geometry = Some(far(500_000.)); + layer.touch_geometry(); + let mark = app.session.notice_mark(); + say_unplaced(&mut app); + say_unplaced(&mut app); + let said: Vec = app.session.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert_eq!(said.len(), 1, "{said:?}"); + assert!(said[0].contains("feature 0 has a place") && said[0].contains("can't be edited there"), "{said:?}"); + assert!(targets(&app).is_empty()); + // Two of them, selected: counted, once. + let layer = app.session.map_mut().layer_mut(id).unwrap(); + layer.dataset.features[1].geometry = Some(far(500_100.)); + layer.touch_geometry(); + layer.selection = vec![0, 1, 2]; + let mark = app.session.notice_mark(); + say_unplaced(&mut app); + say_unplaced(&mut app); + let said: Vec = app.session.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert_eq!(said.len(), 1, "{said:?}"); + assert!(said[0].contains("2 of the selected features"), "{said:?}"); + assert_eq!(targets(&app).len(), 1); + } + + /// The count stops where the handles do: at their cap of placed features. With 49 placed + /// ones selected first, the two unplaced after them are both counted; past 50 placed, one + /// isn't, as it gets no handles either way. + #[test] + fn the_unplaced_count_follows_the_handles_cap() { + let squares = (0..53).map(|i| square(f64::from(i) * 0.05)); + let mut app = app(squares); + let id = app.session.active_layer.unwrap(); + let utm = rustgis_engine::data::raster::Crs::from_epsg(32631).unwrap(); + app.session.map_mut().editing.settings.enabled = true; + let layer = app.session.map_mut().layer_mut(id).unwrap(); + layer.dataset.hold_in(utm).unwrap(); + let far = Geometry::Polygon(vec![vec![vec![ + Coord::new(500_000., 0.), + Coord::new(1e9, 0.), + Coord::new(500_000., 1.), + Coord::new(500_000., 0.), + ]]]); + for r in [49, 50, 52] { + layer.dataset.features.set_geometry(r, Some(far.clone())); + } + layer.selection = (0..53).collect(); + // 49 placed, two unplaced (49, 50), the 50th placed (51): the cap; 52 is past it. + let found = unplaced_targets(&app); + assert_eq!((found.rows, found.more), (vec![(id, 49), (id, 50)], false)); + assert_eq!(targets(&app).len(), MAX_FEATURES); + let mark = app.session.notice_mark(); + say_unplaced(&mut app); + let said: Vec = app.session.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!(said.len() == 1 && said[0].contains("2 of the selected features"), "{said:?}"); + // What was said is kept with its map, so another map's layer of the same id and rows is + // said for itself. + let (map, live) = (app.session.project.active_map, app.session.map().layer(id).unwrap().instance_id()); + assert_eq!(app.map.vertex_unplaced_said, [(map, live, 49), (map, live, 50)]); + // Another tool forgets it, so coming back says it again. + app.run("tool.set", json!({"tool": "explore"})).unwrap(); + say_unplaced(&mut app); + assert!(app.map.vertex_unplaced_said.is_empty()); + app.run("tool.set", json!({"tool": "editVertices"})).unwrap(); + let mark = app.session.notice_mark(); + say_unplaced(&mut app); + assert_eq!(app.session.notices_since(mark).len(), 1); + } + + /// The scan stops at [`MAX_UNPLACED`] features with no place, and the notice says "at least". + #[test] + fn a_selection_with_no_place_at_all_is_counted_up_to_a_bound() { + let far = Geometry::Polygon(vec![vec![vec![ + Coord::new(500_000., 0.), + Coord::new(1e9, 0.), + Coord::new(500_000., 1.), + Coord::new(500_000., 0.), + ]]]); + let mut app = app(std::iter::repeat_n(far, MAX_UNPLACED + 5)); + let id = app.session.active_layer.unwrap(); + app.session.map_mut().editing.settings.enabled = true; + let layer = app.session.map_mut().layer_mut(id).unwrap(); + layer.dataset.held_in = rustgis_engine::data::raster::Crs::from_epsg(32631).unwrap(); + layer.touch_geometry(); + layer.selection = (0..MAX_UNPLACED + 5).collect(); + // Exactly the bound: counted as it is. + app.session.map_mut().layer_mut(id).unwrap().selection = (0..MAX_UNPLACED).collect(); + let mark = app.session.notice_mark(); + say_unplaced(&mut app); + let said: Vec = app.session.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!(said.len() == 1 && said[0].contains(&format!(": {MAX_UNPLACED} of the selected")), "{said:?}"); + // One more: the same features found, and more, which is said. + app.session.map_mut().layer_mut(id).unwrap().selection = (0..MAX_UNPLACED + 5).collect(); + let found = unplaced_targets(&app); + assert!(found.rows.len() == MAX_UNPLACED && found.more); + let mark = app.session.notice_mark(); + say_unplaced(&mut app); + let said: Vec = app.session.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!(said.len() == 1 && said[0].contains(&format!("at least {MAX_UNPLACED} of the selected")), "{said:?}"); + } + + /// Rows without geometry count towards neither bound, so the scan goes past them, and a change + /// in the selection beyond them is looked at again: a different unplaced feature there is said. + #[test] + fn an_unplaced_feature_past_rows_without_geometry_is_said_when_it_changes() { + let far = Geometry::Polygon(vec![vec![vec![ + Coord::new(500_000., 0.), + Coord::new(1e9, 0.), + Coord::new(500_000., 1.), + Coord::new(500_000., 0.), + ]]]); + let n = MAX_FEATURES + MAX_UNPLACED + 10; + let mut app = app(std::iter::repeat_n(far, n + 2)); + let id = app.session.active_layer.unwrap(); + app.session.map_mut().editing.settings.enabled = true; + let layer = app.session.map_mut().layer_mut(id).unwrap(); + layer.dataset.held_in = rustgis_engine::data::raster::Crs::from_epsg(32631).unwrap(); + for r in 0..n { + layer.dataset.features.set_geometry(r, None); + } + layer.touch_geometry(); + let said = |app: &mut RustGisApp, rows: Vec| { + app.session.map_mut().layer_mut(id).unwrap().selection = rows; + let mark = app.session.notice_mark(); + say_unplaced(app); + app.session.notices_since(mark).iter().map(|n| n.text.clone()).collect::>() + }; + let first = said(&mut app, (0..n).chain([n]).collect()); + assert!(first.len() == 1 && first[0].contains(&format!("feature {n} has a place")), "{first:?}"); + let second = said(&mut app, (0..n).chain([n + 1]).collect()); + assert!(second.len() == 1 && second[0].contains(&format!("feature {} has a place", n + 1)), "{second:?}"); + } + /// A held gesture scans once, retains no rows, reprojects after camera changes, and drops /// its cache when any row changes. Restarting captures fresh edges under the new identity. #[test] diff --git a/crates/ui-touch/src/edit.rs b/crates/ui-touch/src/edit.rs index 76570be890..b94d2d0b8f 100644 --- a/crates/ui-touch/src/edit.rs +++ b/crates/ui-touch/src/edit.rs @@ -67,14 +67,25 @@ pub(crate) fn shape(app: &RustGisApp, id: u32, row: usize) -> Option { shape_ref(app, id, row).map(std::borrow::Cow::into_owned) } -/// [`shape`], borrowed while the layer's coordinates are longitude/latitude (as every layer's are -/// today): what is drawn and checked each frame isn't copied for it. Converted from the layer's -/// own coordinates otherwise; `None` when it can't be. +/// [`shape`], borrowed while the layer's coordinates are longitude/latitude: what is drawn and +/// checked each frame isn't copied for it. Converted from the layer's own coordinates otherwise; +/// `None` when it can't be (for a feature whose place can't be given in longitude/latitude, +/// [`unplaced`] says why). pub(crate) fn shape_ref(app: &RustGisApp, id: u32, row: usize) -> Option> { let l = app.session.map().layer(id)?; l.dataset.geometry_to_lonlat(l.dataset.features.get(row)?.geometry.as_ref()?).ok() } +/// Why the shape of the feature in row `row` of layer `id` can't be edited here ([`shape_ref`] is +/// `None`): one of its places can't be given in longitude/latitude, said naming the layer and the +/// feature. `None` when it can be, or the row is gone. +pub(crate) fn unplaced(app: &RustGisApp, id: u32, row: usize) -> Option { + let l = app.session.map().layer(id)?; + let f = l.dataset.features.row(row)?; + l.dataset.feature_to_lonlat(f.id(), f.geometry()?).err()?; + Some(rustgis_ui_egui::unplaced_feature_notice(&l.name, f.id(), &l.dataset.coord_crs().label())) +} + /// Whether putting vertex `v` of `shape` at `at` (`move`), or a new one there after it /// (`insert`), would leave two vertices in one place in a row: on the screen, within a point of /// each other. The edge between them would have no length, which the capture draft refuses too. diff --git a/crates/ui-touch/src/lib.rs b/crates/ui-touch/src/lib.rs index 49031c9c3f..b9d7696e86 100644 --- a/crates/ui-touch/src/lib.rs +++ b/crates/ui-touch/src/lib.rs @@ -1389,7 +1389,13 @@ fn edit_sheet( }; // The shape is borrowed for each look at it, not copied each frame: the buttons change it. let Some(status) = edit::shape_ref(app, target.id, row).map(|shape| edit::status(target.kind, &shape, editing.vertex)) else { + // A feature with a place that can't be given in longitude/latitude (#2032 C2f-4b): drawn + // on a map in its layer's own system, but shapes are edited here in longitude/latitude. + // Said, as editing it ends. state.editing = None; + if let Some(why) = edit::unplaced(app, target.id, row) { + app.session.notify(why, true); + } return; }; ui.label(RichText::new(status).size(14.0).color(t.text)); @@ -2456,6 +2462,24 @@ mod tests { assert_eq!(edit::Editing::feature(7).picking(Some(VertexId::new(0, 0, 9)), Some(&abc)).vertex, None); } + /// A feature with a place that can't be given in longitude/latitude (#2032 C2f-4b) has no + /// shape to edit here, and why is said, naming it; a placed one has. + #[test] + fn a_feature_with_no_place_in_longitude_latitude_says_why_it_cant_be_edited() { + use rustgis_ui_egui::rustgis_engine::data::{Coord, Geometry, raster::Crs}; + let mut app = RustGisApp::with_sample(); + let cities = target(&mut app, GeometryType::Point); + let layer = app.session.map_mut().layer_mut(cities.id).unwrap(); + layer.dataset.hold_in(Crs::from_epsg(8857).unwrap()).unwrap(); + let id = layer.dataset.features[0].id; + layer.dataset.features[0].geometry = Some(Geometry::Point(Coord::new(1e9, 0.0))); + assert!(edit::shape_ref(&app, cities.id, 0).is_none()); + let why = edit::unplaced(&app, cities.id, 0).unwrap(); + assert!(why.contains(&format!("feature {id} has a place")) && why.contains("can't be edited there"), "{why}"); + assert!(edit::shape_ref(&app, cities.id, 1).is_some()); + assert_eq!(edit::unplaced(&app, cities.id, 1), None); + } + #[test] fn move_point_here_moves_a_point_and_refuses_a_multipoint() { let mut app = RustGisApp::with_sample(); diff --git a/docs/user-guide/editing.md b/docs/user-guide/editing.md index 96d4001981..79261e3fea 100644 --- a/docs/user-guide/editing.md +++ b/docs/user-guide/editing.md @@ -133,7 +133,9 @@ you edit the value or choose units; click **Apply elevation** to apply the new i - **Edit Vertices** (Edit › Features): reshape the selected features on the map. Their vertices show as square handles and each edge has a round midpoint handle. Drag a vertex to move it; drag a midpoint, or click an edge, to insert a vertex; click a vertex and press ++delete++ to - remove it (a line keeps at least two vertices, a polygon ring three). Clicking elsewhere + remove it (a line keeps at least two vertices, a polygon ring three). A selected feature with + a place that can't be given in longitude/latitude (see [Places with no longitude/latitude](data-formats.md#places-with-no-longitudelatitude)) + gets no handles, and a notice says so once, naming it or counting them. Clicking elsewhere selects the feature there (++shift++ adds it). Multipart features and polygon holes work the same way, dragged vertices snap when snapping is on, and each move, insertion or deletion is one undo step. ++esc++ finishes. From scripts and the command line, `edit.vertex` does the diff --git a/docs/user-guide/field-work.md b/docs/user-guide/field-work.md index 965df02179..925496063a 100644 --- a/docs/user-guide/field-work.md +++ b/docs/user-guide/field-work.md @@ -110,7 +110,9 @@ marked with a green ring, when adding and editing alike. **Edit**, beside **Add** at the top of the Capture sheet, changes shapes already on the map, again at the cross: -- **Pick Feature at Cross** picks the feature under the cross and draws its vertices. +- **Pick Feature at Cross** picks the feature under the cross and draws its vertices. A feature + with a place that can't be given in longitude/latitude can't be reshaped here: a notice names it + and the pick ends. - For a line or polygon, **Pick Vertex at Cross** picks the nearest vertex. Then **Move Here** moves it to the cross, **Add After** adds a vertex there after it, and **Delete Vertex** removes it.