diff --git a/crates/engine/src/cmd/field_audit_tests.rs b/crates/engine/src/cmd/field_audit_tests.rs index 3698ae186a..2f27cf4921 100644 --- a/crates/engine/src/cmd/field_audit_tests.rs +++ b/crates/engine/src/cmd/field_audit_tests.rs @@ -654,8 +654,8 @@ fn a_returned_package_opened_elsewhere_keeps_no_rows_as_given() { assert!(refused.contains("already"), "{refused}"); } -/// A layer held in another system than longitude/latitude keeps its rows as given in -/// longitude/latitude, as they are compared on sending: unedited, none is listed. +/// A layer held in another system than longitude/latitude keeps its rows as given in that system, +/// as they are compared on sending: unedited, none is listed. #[test] fn rows_held_in_another_system_are_kept_and_compared_alike() { let temp = Temp::new("held-elsewhere"); @@ -677,7 +677,7 @@ fn rows_held_in_another_system_are_kept_and_compared_alike() { } /// A layer home holds in its own system (Web Mercator) goes out held there and is kept as given in -/// longitude/latitude. Unedited rows aren't listed; one edit and one deletion come back, and home's +/// it. Unedited rows aren't listed; one edit and one deletion come back, and home's /// places stay as stored. #[test] fn a_layer_held_in_its_own_system_comes_back_with_only_its_changes() { @@ -722,7 +722,6 @@ fn a_layer_held_in_its_own_system_comes_back_with_only_its_changes() { /// longitude/latitude refused to send) comes back too, as it is held. #[test] fn a_layer_held_in_its_own_system_comes_back_exact_by_a_list_in_that_system() { - let _own = crate::cmd::field_changes::test_bases::write_own_systems(); use rustgis_data::{Coord, Geometry, raster::Crs}; let equal_earth = Crs::from_epsg(8857).unwrap(); let temp = Temp::new("native-list"); @@ -761,12 +760,39 @@ fn a_layer_held_in_its_own_system_comes_back_exact_by_a_list_in_that_system() { assert_eq!(home.map().layer(hc).unwrap().dataset.coord_crs(), equal_earth); } +/// A package opened on a phone with a release up to v0.9.0 kept its copy in longitude/latitude: +/// sent by this release, a feature moved where it has no place there sends the whole map, naming +/// it, as before (#2032 C2f-4b-6). +#[test] +fn a_copy_an_older_release_kept_sends_an_unplaced_feature_as_a_whole_map() { + use rustgis_data::{Coord, Geometry, raster::Crs}; + let temp = Temp::new("older-copy-unplaced"); + let mut home = home(&temp); + let hc = layer(&home, "Cities"); + home.map_mut().layer_mut(hc).unwrap().dataset.hold_in(Crs::from_epsg(8857).unwrap()).unwrap(); + let (_, out) = package(&mut home, &json!({"name": "Day", "extent": AREA})).unwrap(); + let mut a = { + let _older = crate::cmd::field_changes::test_bases::as_an_older_release(); + phone(&temp, &out, "a") + }; + let cities = layer(&a, "Cities"); + let far = { + let ds = &mut a.map_mut().layer_mut(cities).unwrap().dataset; + ds.features[1].geometry = Some(Geometry::Point(Coord::new(1e9, 0.0))); + ds.features[1].id + }; + let mark = a.notice_mark(); + let (_, back) = package(&mut a, &Value::Null).unwrap(); + assert!(changes_in(&back).is_none(), "a whole map"); + let said: Vec = a.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!(said.iter().any(|t| t.contains("whole map") && t.contains(&format!("feature {far}"))), "{said:?}"); +} + /// A list giving a layer's shapes in its own system comes back while home holds the layer in /// another (Define Projection meanwhile): its shapes are put in longitude/latitude to be brought /// back there, as a list of version 1's are. #[test] fn a_list_in_a_layers_own_system_comes_back_to_a_layer_held_in_another() { - let _own = crate::cmd::field_changes::test_bases::write_own_systems(); use rustgis_data::{Geometry, raster::Crs}; let temp = Temp::new("native-list-elsewhere"); let mut home = home(&temp); @@ -801,7 +827,6 @@ fn a_list_in_a_layers_own_system_comes_back_to_a_layer_held_in_another() { /// return; once the list touches it, it does, naming it. #[test] fn only_a_feature_the_list_touches_can_refuse_a_converted_return() { - let _own = crate::cmd::field_changes::test_bases::write_own_systems(); use rustgis_data::{Coord, Geometry, raster::Crs}; let temp = Temp::new("native-list-untouched"); let mut home = home(&temp); @@ -885,7 +910,6 @@ fn a_home_feature_an_addition_renumbers_around_doesnt_refuse_a_converted_return( #[test] fn a_displaced_shape_with_no_place_in_longitude_latitude_refuses_the_return() { use rustgis_data::{Coord, Geometry, raster::Crs}; - let _own = crate::cmd::field_changes::test_bases::write_own_systems(); let temp = Temp::new("native-list-placeless-conflict"); let mut home = home(&temp); let hc = layer(&home, "Cities"); diff --git a/crates/engine/src/cmd/field_changes.rs b/crates/engine/src/cmd/field_changes.rs index 6a6f39c2fb..0414884c6c 100644 --- a/crates/engine/src/cmd/field_changes.rs +++ b/crates/engine/src/cmd/field_changes.rs @@ -53,18 +53,18 @@ const LAYERS: &str = "layers.json"; const LAYERS_V2: &str = "layers.v2.json"; /// Whether a copy keeps a layer held in its own system in that system ([`BaseLayer::crs`]), so its -/// list of changes is of version 2. Off until a release that reads version 2 has shipped -/// (`docs/maintaining.md`: a new version is read a release before anything writes it): copies are -/// kept, and lists written, in longitude/latitude as before. A test turns it on for itself -/// ([`test_bases::write_own_systems`]). +/// list of changes is of version 2: on from the release after v0.9.0, which was the first to read +/// version 2 (`docs/maintaining.md`: a new version is read a release before anything writes it). +/// A test keeps copies as a release up to v0.9.0 did, in longitude/latitude +/// ([`test_bases::as_an_older_release`]). fn writes_own_systems() -> bool { #[cfg(test)] { - test_bases::OWN_SYSTEMS.with(std::cell::Cell::get) + !test_bases::OLDER_RELEASE.with(std::cell::Cell::get) } #[cfg(not(test))] { - false + true } } @@ -1310,7 +1310,6 @@ mod tests { /// [`LAYERS`], as before. This release reads either. #[test] fn a_copy_with_a_layer_in_its_own_system_is_listed_where_older_releases_dont_look() { - let _own = test_bases::write_own_systems(); let held = crate::sample::world_project(); let mut native = held.clone(); native.maps[0].layers[0].dataset.hold_in(Crs::from_epsg(8857).unwrap()).unwrap(); @@ -1325,11 +1324,13 @@ mod tests { } } - /// As a release keeps them ([`writes_own_systems`] off, as on any test's thread that doesn't - /// turn it on): a layer held in its own system is kept in longitude/latitude, listed in - /// [`LAYERS`], and an unchanged return's list is of version 1, which every release reads. + /// As a release up to v0.9.0 keeps them ([`writes_own_systems`] off): a layer held in its own + /// system is kept in longitude/latitude, listed in [`LAYERS`], and an unchanged return's list + /// is of version 1, which every release reads. This release reads such a copy as before. #[test] - fn a_release_keeps_the_copy_in_longitude_latitude_until_version_2_is_written() { + fn a_copy_an_older_release_kept_in_longitude_latitude_still_lists() { + assert!(writes_own_systems(), "a release writes version 2"); + let _older = test_bases::as_an_older_release(); assert!(!writes_own_systems()); let mut project = crate::sample::world_project(); project.maps[0].layers[0].dataset.hold_in(Crs::from_epsg(8857).unwrap()).unwrap(); @@ -1477,25 +1478,25 @@ mod tests { #[cfg(test)] pub(crate) mod test_bases { std::thread_local! { - /// Whether copies are kept, and lists written, in each layer's own system - /// ([`super::writes_own_systems`]) on this test's thread: off, as in a release, unless - /// the test turns it on. A copy is kept on the thread that runs `offline.keepRows` in - /// tests, the test's own. - pub(crate) static OWN_SYSTEMS: std::cell::Cell = const { std::cell::Cell::new(false) }; + /// Whether copies are kept, and lists written, in longitude/latitude only, as a release + /// up to v0.9.0 kept them ([`super::writes_own_systems`] off), on this test's thread: + /// off unless the test turns it on. A copy is kept on the thread that runs + /// `offline.keepRows` in tests, the test's own. + pub(crate) static OLDER_RELEASE: std::cell::Cell = const { std::cell::Cell::new(false) }; } - /// [`OWN_SYSTEMS`] on for this test, until what it returns is dropped. + /// [`OLDER_RELEASE`] on for this test, until what it returns is dropped. #[must_use = "the switch is off again once this is dropped"] - pub(crate) fn write_own_systems() -> OwnSystems { - OwnSystems(OWN_SYSTEMS.with(|on| on.replace(true))) + pub(crate) fn as_an_older_release() -> OlderRelease { + OlderRelease(OLDER_RELEASE.with(|on| on.replace(true))) } - /// Puts [`OWN_SYSTEMS`] back as it was when dropped. - pub(crate) struct OwnSystems(bool); + /// Puts [`OLDER_RELEASE`] back as it was when dropped. + pub(crate) struct OlderRelease(bool); - impl Drop for OwnSystems { + impl Drop for OlderRelease { fn drop(&mut self) { - OWN_SYSTEMS.with(|on| on.set(self.0)); + OLDER_RELEASE.with(|on| on.set(self.0)); } } diff --git a/docs/user-guide/data-formats.md b/docs/user-guide/data-formats.md index d31d34fdb8..d6b7715345 100644 --- a/docs/user-guide/data-formats.md +++ b/docs/user-guide/data-formats.md @@ -805,8 +805,9 @@ CSV's, LiDAR cloud's, MapInfo, DXF, LandXML or city model's features has a place Projection can set the one that does. Such a feature doesn't draw (the map says how many it leaves out), and each step that needs longitude/latitude (an export in WGS 84, a tool, an edit) leaves it out and says so, or refuses naming it where leaving it out would lose it (a write-back, a sync of an -offline area holding it, a Field Package's list of changes) or a plugin tool takes the layer; -written back in its own system, it is exact. A system that converts a place to beyond ±180.5° +offline area holding it, a Field Package's list of changes brought back to a layer held in +another system) or a plugin tool takes the layer; written back in its own system, it is exact. +A system that converts a place to beyond ±180.5° longitude or ±90.5° latitude (Web Mercator a billion metres east is 8983°) doesn't fit either: such a feature is kept and draws out of place. Shapefile, GeoJSON, CSV, MapInfo, DXF, LandXML, ArcGIS feature service answers, LiDAR point clouds, city models and whole reads of GeoPackage, FlatGeobuf, diff --git a/docs/user-guide/field-work.md b/docs/user-guide/field-work.md index feb5be347b..bbfcd7cfe0 100644 --- a/docs/user-guide/field-work.md +++ b/docs/user-guide/field-work.md @@ -239,12 +239,19 @@ Where a change meets one made on the computer since the package was made: given in longitude/latitude (one far past where that system reaches) stays as stored when it lies outside the area when the area is synced (**Sync**, or a package that goes back as a whole map); one the area holds can't be compared with the phone's, and the sync is refused, naming it. - Send Field Package can't list the changes of a layer holding such a feature the package gave: - the package goes back as a whole map, and the phone says why, naming it. Bring Back of a list of changes refuses - only for such a feature that the list changes, naming it: one of the computer's features that - the list edits or deletes, or one of the package's features that it adds or edits. The others - stay as stored. A change that would keep among the conflicts a version with such a place - refuses it too, naming the feature, as conflicts are kept in longitude/latitude. + Send Field Package lists the changes of a layer held in its own system in that system, so such + a feature comes back exactly as the phone holds it, while the computer's layer is still held in + the same system. A layer the computer has put in another system since (Define Projection) is + brought back through longitude/latitude: Bring Back then refuses only for such a feature that + the list changes, naming it: one of the computer's features that the list edits or deletes, or + one of the package's features that it adds or edits. The others stay as stored. A change that + would keep among the conflicts a version with such a place refuses it too, naming the feature, + as conflicts are kept in longitude/latitude. +- A list of changes with a layer in its own system is version 2, which RustGIS reads from v0.9.0 + on. A computer on an older release refuses it as made by a newer RustGIS: update it, then Bring + Back again. A package of layers all in longitude/latitude sends version 1, which every release + reads. A package opened on a phone with v0.9.0 or older keeps its copy in longitude/latitude, so a + feature with no place there makes it go back as a whole map, as before, naming it. Each of these keeps the version that lost on the offline area: the computer's values and shape the phone's replaced, the phone's edits to a feature deleted on the computer, the computer's feature