Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ It counts only the libraries and programs built for the host, not tests, example
built only for other targets, nor a row indexed without reading a field (`features[i]` alone); use
the accessors there too.
While you work, `cargo xtask changed` runs the same checks on only the packages your branch changes
and those that depend on them (and `test-hygiene` on the whole workspace), or everything when a
and those that depend on them (and `test-hygiene` on the whole workspace, and formatting, `layers` and
`rows` when packages are checked), or everything when a
changed file such as `Cargo.lock` is outside every package and nothing includes it.
A new dependency must have a licence `deny.toml` allows (CI runs `cargo deny check licenses`); after
changing dependencies, run `cargo xtask notices` to refresh the `THIRD-PARTY-LICENSES.txt` files the
Expand Down
9 changes: 5 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ features build on.
save, not built in memory first.
- A snapshot test of command ids and parameters, so a removal is always deliberate (the project
file's JSON Schema, its fixtures and the files past releases saved are checked today).
- A compressed encoding of today's project JSON, read one release before it is written; a
reference system: named connections, copies that remember their source, missing and changed
states, a place for results ([#1653](https://github.com/opengeos/RustGIS/issues/1653)).
_Coordinate first._
- A compressed encoding of today's project JSON, read one release before it is written.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
_Coordinate first_: an issue is needed.
- A system for the data a project refers to: named connections, copies that remember their
source, missing and changed states, a place for results
([#1653](https://github.com/opengeos/RustGIS/issues/1653)). _Coordinate first._
- What a project holds by default, its own data or links to it
([poll #1660](https://github.com/opengeos/RustGIS/discussions/1660)), and storage that opens a
large project without reading it whole. _Decide first._
Expand Down
2 changes: 1 addition & 1 deletion apps/rustgis-mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ On the Android 15 emulator (x86_64, software GPU), from this crate as it is:
| HTTPS basemap tiles | Yes, with the bundled roots |
| Rotation | Yes, without a restart |
| Suspend and resume | Yes: the surface is dropped and made again, the session is kept |
| The activity destroyed by the system | The session is lost. winit's event loop can't be made twice in a process, so the app ends its process and the next launch starts afresh; without that, the next launch showed nothing |
| The activity destroyed by the system | The session is lost. winit's event loop can't be made twice in a process, so the app ends its process if the loop returns; destroying the activity alone doesn't make it return, so the process may survive, and a launch in that same process may not start. Once the system ends the process, the next launch starts a new one, and the recovery copies written while editing let it offer a complete copy |
| Typing | Key events reach text fields. The soft keyboard itself needs a phone to judge |
| Size | 78 MB for arm64 without symbols, 89 MB in the APK for x86_64 |

Expand Down
2 changes: 1 addition & 1 deletion crates/data/src/gml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ pub fn read(file_name: &str, bytes: &[u8]) -> Result<Vec<(Dataset, ReadReport)>>
let what = if unplaced == 1 { "feature has" } else { "features have" };
let system = file_srs.map_or_else(String::new, |(c, _)| format!(" in {}", c.label()));
rep.messages.push(format!(
"{}: {unplaced} {what} places{system} that can't be given in longitude/latitude; they are left out of the shapes",
"{}: {unplaced} {what} places{system} that can't be given in longitude/latitude; they are kept as missing coordinates and don't draw",
ds.name
));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/data/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ fn in_file<'a>(ds: &'a Dataset, crs: Option<Crs>, as_held: Option<(&Dataset, &Da
crate::progress::check()?;
if f.geometry.is_none() && r.geometry.is_some() {
return Err(DataError::Format(format!(
"source shape {} couldn't be converted to longitude/latitude, so its native geometry can't be matched safely; check the source projection and add the file again; nothing was written",
"source shape {} couldn't be converted from the source projection when it was read, so its native geometry can't be matched safely; check the source projection and add the file again; nothing was written",
i + 1
)));
}
Expand Down
78 changes: 70 additions & 8 deletions crates/engine/src/cmd/design.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,8 @@ struct TopologyInput {
data: rustgis_data::Dataset,
query: Option<String>,
by: Option<rustgis_data::Dataset>,
/// The covering layer's name on the map, which its data's own name may not be.
by_layer: String,
}

/// Captures the rules and their raw inputs; a rule whose layer is gone is left out, as before.
Expand All @@ -2304,11 +2306,18 @@ fn topology_checks(s: &Session) -> Vec<TopologyInput> {
// A covering layer that is gone leaves the rule with nothing to check (its primary
// latitudes are still checked). Its whole resident dataset supplies coverage,
// independently of selection, definition query, display filters and time window.
let by = match &rule {
TopologyRule::MustBeCoveredBy { by, .. } => s.map().layer_by_name(by).map(|b| b.dataset.clone()),
_ => None,
let (by, by_layer) = match &rule {
TopologyRule::MustBeCoveredBy { by, .. } => (s.map().layer_by_name(by).map(|b| b.dataset.clone()), by.clone()),
_ => (None, String::new()),
};
inputs.push(TopologyInput { rule, layer: l.name.clone(), data: l.dataset.clone(), query: l.definition_query.clone(), by });
inputs.push(TopologyInput {
rule,
layer: l.name.clone(),
data: l.dataset.clone(),
query: l.definition_query.clone(),
by,
by_layer,
});
}
inputs
}
Expand Down Expand Up @@ -2377,15 +2386,19 @@ fn check_topology(inputs: &[TopologyInput], tol: f64) -> Result<TopologyChecked,
// Preserve the existing coordinate boundary and error precedence. A primary failure
// wins over a covering-layer failure; neither can run on coordinates of another system.
rustgis_data::progress::check().map_err(|_| cancelled())?;
let named = |e: String| {
// A conversion's error starts with its data's own name, which the map's name for the
// layer may not be (a name taken on a clash): that is replaced by the map's, so the layer
// is named once. A covering layer's is named as that layer, not the one checked.
let named = |source: &str, layer: &str, e: String| {
if matches!(rustgis_data::DataError::of_conversion(e.clone()), rustgis_data::DataError::Cancelled) {
cancelled()
} else {
format!("{}: {e}", i.layer)
let rest = e.strip_prefix(&format!("{source}: ")).unwrap_or(&e);
format!("{layer}: {rest}")
}
};
let data = i.data.in_lonlat().map_err(named)?;
let by = i.by.as_ref().map(|b| b.in_lonlat().map_err(named)).transpose()?;
let data = i.data.in_lonlat().map_err(|e| named(&i.data.name, &i.layer, e))?;
let by = i.by.as_ref().map(|b| b.in_lonlat().map_err(|e| named(&b.name, &i.by_layer, e))).transpose()?;
rustgis_data::progress::check().map_err(|_| cancelled())?;
rustgis_analysis::validate_latitudes(&data, rows.iter().copied())?;
rustgis_data::progress::check().map_err(|_| cancelled())?;
Expand Down Expand Up @@ -2736,6 +2749,55 @@ mod tests {
assert!(errors[0] > 0, "the overlap is found");
}

/// A held layer with a place that can't be given in longitude/latitude is refused, naming
/// the layer once; a covering layer's is named as that layer, not the one checked.
#[test]
fn a_topology_refusal_names_its_layer_once() {
let held = |name: &str, kind: GeometryType, far: bool| {
let mut ds = rustgis_data::Dataset::new(name, kind, vec![]);
ds.hold_in(rustgis_data::raster::Crs::Epsg(32632)).unwrap();
// Far beyond any place UTM 32N holds, or in it.
let (x, y) = if far { (1e12, 1e12) } else { (500_000.0, 5_400_000.0) };
let ring = vec![Coord::new(x, y), Coord::new(x + 10.0, y), Coord::new(x + 10.0, y + 10.0), Coord::new(x, y)];
let shape = match kind {
GeometryType::Polygon => Geometry::Polygon(vec![vec![ring]]),
GeometryType::Point => Geometry::Point(Coord::new(x, y)),
_ => Geometry::Line(vec![ring]),
};
ds.push(Some(shape), vec![]);
ds
};
let mut s = Session::new(crate::Project::default());
Comment thread
giswqs marked this conversation as resolved.
Resolved
s.map_mut().add_dataset(held("Parcels", GeometryType::Polyline, true));
s.run("topology.rules", &json!({"add": {"rule": "mustNotHaveDangles", "layer": "Parcels"}})).unwrap();
let Err(e) = check_topology(&topology_checks(&s), 1.0) else { panic!("the check is refused") };
assert!(e.starts_with("Parcels: feature"), "{e}");
assert_eq!(e.matches("Parcels").count(), 1, "{e}");
// A checked layer whose map name isn't its data's (a name taken on a clash) is named as
// the map has it, once.
s.map_mut().layers.iter_mut().find(|l| l.name == "Parcels").unwrap().name = "Parcels (2)".into();
s.map_mut().editing.topology = vec![TopologyRule::MustNotHaveDangles { layer: "Parcels (2)".into() }];
let Err(e) = check_topology(&topology_checks(&s), 1.0) else { panic!("the check is refused") };
assert!(e.starts_with("Parcels (2): feature"), "{e}");
assert_eq!(e.matches("Parcels").count(), 1, "{e}");

let mut s = Session::new(crate::Project::default());
s.map_mut().add_dataset(held("Cities", GeometryType::Point, false));
s.map_mut().add_dataset(held("Countries", GeometryType::Polygon, true));
s.run("topology.rules", &json!({"add": {"rule": "mustBeCoveredBy", "layer": "Cities", "by": "Countries"}})).unwrap();
let Err(e) = check_topology(&topology_checks(&s), 1.0) else { panic!("the check is refused") };
assert!(e.starts_with("Countries: feature"), "{e}");
assert!(!e.contains("Cities"), "{e}");
// A covering layer whose map name isn't its data's (a name taken on a clash) is named as
// the map has it.
s.map_mut().layers.iter_mut().find(|l| l.name == "Countries").unwrap().name = "Borders".into();
s.map_mut().editing.topology = vec![TopologyRule::MustBeCoveredBy { layer: "Cities".into(), by: "Borders".into() }];
let Err(e) = check_topology(&topology_checks(&s), 1.0) else { panic!("the check is refused") };
assert!(e.starts_with("Borders: feature"), "{e}");
assert_eq!(e.matches("Countries").count() + e.matches("Borders").count(), 1, "{e}");
assert!(!e.contains("Cities"), "{e}");
}

#[test]
fn a_center_is_found_within_the_commands_budget() {
// A line at 89.9°N whose ten edges each span 170° of longitude: 340 half-degree stretches
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/cmd/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BASEMAPS: &str = "basemaps";
/// The folder of a field package that holds its features' photos.
const PHOTOS: &str = "photos";
/// What an offline area's map is called after: `<area> (offline)`.
pub(crate) const OFFLINE: &str = " (offline)";
pub const OFFLINE: &str = " (offline)";
/// The most bytes read from one field package's entries when it is opened.
const MOST_UNPACKED: usize = rustgis_data::zip::MAX_TOTAL;
/// Optional information for the crew. Older readers extract it like any other companion file.
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/tests/integration/project_save_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! changes nothing.
//!
//! Pull requests run a fixed seed; the nightly a new one with more cases. To run a seed again, or
//! deeper: `PROPERTY_SEED=7 PROPERTY_CASES=2000 cargo test -p rustgis-engine --test project_save_roundtrip`.
//! deeper: `PROPERTY_SEED=7 PROPERTY_CASES=2000 cargo test -p rustgis-engine --test integration project_save_roundtrip`.
use proptest::prelude::*;
use proptest::test_runner::{Config, RngAlgorithm, TestCaseError, TestRng, TestRunner};
use rustgis_engine::{
Expand Down
2 changes: 1 addition & 1 deletion crates/geom/src/utm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ mod tests {
/// GeographicLib's GeoConvert documentation converts 33.3° N 44.4° E (Baghdad) to
/// `38n 444140.54 3684706.36` and MGRS `38SMB4414084706`
/// (https://geographiclib.sourceforge.io/C++/doc/GeoConvert.1.html). Also checked against
/// terrio-crs in `crates/data/tests/utm_vs_proj.rs`.
/// terrio-crs in `crates/data/tests/integration/utm_vs_proj.rs`.
#[test]
fn published_reference_point() {
let u = to_utm(c(44.4, 33.3)).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/plugins/src/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl PanelDecl {
}
if options.len() != item.options.len() {
return Err(what(&format!(
"a dropdown's options are at most {MAX_CHOICES} objects, each with a unique id of 1 to {MAX_TREE_ID} characters"
"options (dropdown or tab row) are at most {MAX_CHOICES} objects, each with a unique id of 1 to {MAX_TREE_ID} characters"
)));
}
if kind != "text" && !item.text.is_empty() {
Expand Down
14 changes: 10 additions & 4 deletions crates/ui-egui/src/pluginpanel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,14 @@ fn tabs(app: &mut RustGisApp, ui: &mut Ui, pid: &str, item: &PanelItemDecl, stat
}
}

/// The weekday of a date, 0 for Monday.
/// The weekday of a date, 0 for Monday. A month outside 1 to 12 (callers pass only those) gives
/// some weekday rather than failing.
fn weekday(y: i32, m: u32, d: u32) -> u32 {
// Sakamoto's method, which counts from Sunday.
const T: [i32; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];
let y = if m < 3 { y - 1 } else { y };
let sunday = (y + y / 4 - y / 100 + y / 400 + T[(m - 1) as usize] + d as i32).rem_euclid(7) as u32;
const T: [i64; 12] = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];
let y = i64::from(y) - i64::from(m < 3);
let offset = m.checked_sub(1).and_then(|i| T.get(i as usize)).copied().unwrap_or(0);
let sunday = (y + y / 4 - y / 100 + y / 400 + offset + i64::from(d)).rem_euclid(7) as u32;
(sunday + 6) % 7
}

Expand Down Expand Up @@ -1296,6 +1298,10 @@ mod tests {
assert_eq!(weekday(2023, 4, 1), 5);
assert_eq!(weekday(2024, 2, 29), 3);
assert_eq!(weekday(2000, 1, 1), 5);
// A month outside 1 to 12, or a far year or day, gives a weekday rather than failing.
for (y, m, d) in [(2024, 0, 1), (2024, 13, 1), (i32::MAX, 2, u32::MAX), (i32::MIN, 0, 0)] {
assert!(weekday(y, m, d) < 7);
}
assert_eq!(month_step(2023, 1, -1), (2022, 12));
assert_eq!(month_step(2023, 12, 1), (2024, 1));
assert_eq!(month_step(9999, 12, 1), (9999, 12), "kept within years 1 to 9999");
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-touch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn can_send_field_package(app: &RustGisApp) -> bool {
}
// An area ID with no area (a damaged file) is no copy to send.
let area = map.offline_area_id.as_deref().map(|id| project.offline_areas.iter().any(|a| a.id == id));
area.unwrap_or_else(|| map.name.ends_with(" (offline)"))
area.unwrap_or_else(|| map.name.ends_with(rustgis_ui_egui::rustgis_engine::cmd::field::OFFLINE))
}

/// Draws where the device is: a dot, in a ring as wide as the position is good to.
Expand Down
4 changes: 3 additions & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ RustGIS also runs in the browser, compiled to WebAssembly: open
after it, and **Save** downloads it under that name again. The browser doesn't tell RustGIS
whether it saved a download (its save prompt can be cancelled), so **Save** keeps any unsaved
changes, and **Save As** to a different name makes the project unsaved. Closing or leaving
the tab asks first while there are unsaved changes; an unchanged project stays clean.
the tab may ask first while there are unsaved changes, but browsers don't promise to (mobile
browsers often skip it when a tab is closed from the tab switcher), so check that the saved
file downloaded before you leave; an unchanged project stays clean.
- The interface uses the built-in font, because a web page can't read installed fonts. Choosing
Chinese, Japanese, Korean or Persian downloads a font for that script.
- Process plugins (including Python plugins), and the formats read through GDAL or DuckDB,
Expand Down
2 changes: 1 addition & 1 deletion docs/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ These behavioral tests in `crates/assistant/src/relay.rs` check the requirements

| Tool | What it does |
| --- | --- |
| `list_layers` | The whole project in one call: path and unsaved changes, the view (centre, longitude/latitude extent, scale, projection), the active layer, layers in table-of-contents order (group, type, source, extent, feature count, selection, definition query, renderer, labels, fields, visibility, transparency), web tile layers, basemap, tables and layouts with their page size in millimetres and their map frames. `name_filter` keeps the layers and tables whose name holds it; `include_fields: false` leaves fields out |
| `list_layers` | The whole project in one call: path and unsaved changes, the view (centre, longitude/latitude extent, scale, projection), the active layer, layers in table-of-contents order (group, type, source, extent (rounded outwards to six decimals, so it still holds every coordinate), feature count, selection, definition query, renderer, labels, fields, visibility, transparency), web tile layers, basemap, tables and layouts with their page size in millimetres and their map frames. `name_filter` keeps the layers and tables whose name holds it; `include_fields: false` leaves fields out |
| `view_map` | The map as a PNG image at the current view; `width` and `height` default to 1024 × 640, each clamped to 64–2048 pixels. A picture over 3.75 MiB (a satellite basemap near 2048 pixels) is drawn again smaller, and its caption gives the size drawn and the size asked. `layout` (a layout's name) draws its page instead, fitted to `width` (and `height` when given); `region` draws part of either at full detail: `[x, y, w, h]` in mm on a layout (up to 600 dpi), `[west, south, east, north]` in degrees on the map. What drawing it said (texts cut off, layers without their cast shadows) follows the caption |
| `snapshot` | The map as a PNG with JSON metadata: `mode`, `width`, `height`, `extent` (longitude/latitude), `center`, `scale`, `projection`, `render_settled`, `saved` and `note`. `mode: "screen"` captures the RustGIS window through the relay, once the map has finished drawing or after `wait_s` seconds (default 5, clamped to 0–30); `overlays: false` leaves out the map's controls, scale bar, north arrow and sketches. `mode: "render"` draws offscreen at `max_width` (default 1024, clamped to 64–2048 pixels); height follows the view's shape, with each side capped at 2048. It works while the window is hidden. `mode: "auto"` (default) takes the screen when the map is on it. Unavailable screen captures fall back to render. `save_path` also writes the PNG to a file, which needs file access |
| `search_commands` | Finds RustGIS commands by words: their ids, ribbon locations and parameters |
Expand Down
Loading
Loading