Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
73e63d2
WFS and downloaded feature services asked in their own coordinate sys…
pick2510 Nov 23, 2026
8a08b7c
Main's Notes: the message rewrite rebuilds the list
pick2510 Nov 23, 2026
6e2804e
WCS coverages asked in their own coordinate system (#2032 C2f-3c)
pick2510 Nov 23, 2026
563c283
Merge remote-tracking branch 'upstream/main' into crs-coverage-own
pick2510 Nov 23, 2026
a93ad1d
Review fixes: a coverage answer without its system is read in the one…
pick2510 Nov 23, 2026
2643901
Review fixes: the coverage request names its system, read back from t…
pick2510 Nov 23, 2026
cde1b53
Review fixes: grid axes paired by name, offsets, then columns; the sy…
pick2510 Nov 23, 2026
49ff4d5
Review fixes: no bounds across the antimeridian, WCS 1.0 native syste…
pick2510 Nov 23, 2026
ab660e3
Merge remote-tracking branch 'upstream/main' into crs-streamed-native
pick2510 Nov 23, 2026
bb05153
Streamed reads in the source's own system: a map in it reads its wind…
pick2510 Nov 23, 2026
837d130
Merge remote-tracking branch 'upstream/main' into crs-streamed-native
pick2510 Nov 23, 2026
5ddf935
What leaves the session takes a feature it can't place without that g…
pick2510 Nov 23, 2026
e9fb954
Review fixes: a map-unit window reused only by a map-unit view and ne…
pick2510 Nov 23, 2026
a305868
Review fixes: a missing vertex stays missing, notices say the feature…
pick2510 Nov 23, 2026
f5c791c
Merge branch 'crs-streamed-native' into crs-unplaced-kept
pick2510 Nov 23, 2026
12cd802
Review fixes: map-unit windows only for sources that read by the box,…
pick2510 Nov 23, 2026
cb16a0f
Review fixes: placed extent through the row accessors, a coordinate t…
pick2510 Nov 23, 2026
fd5b119
Merge branch 'crs-streamed-native' into crs-unplaced-kept
pick2510 Nov 23, 2026
b690986
Merge remote-tracking branch 'upstream/main' into crs-unplaced-kept
pick2510 Nov 23, 2026
5cdcd4b
Review fixes: unread-value tallies kept apart by a window's box in ma…
pick2510 Nov 23, 2026
8b519ae
Merge branch 'crs-streamed-native' into crs-unplaced-kept
pick2510 Nov 23, 2026
4d51984
Merge remote-tracking branch 'upstream/main' into crs-unplaced-gp
pick2510 Nov 23, 2026
3aa99f6
Merge remote-tracking branch 'upstream/main' into crs-unplaced-gp
pick2510 Nov 23, 2026
96238c6
fix(analysis): geoprocessing reads a feature it can't place in longit…
pick2510 Nov 23, 2026
fefc503
Merge remote-tracking branch 'upstream/main' into crs-unplaced-gp
pick2510 Nov 23, 2026
c67c18a
Review: a streamed layer updated in place is written back against its…
pick2510 Nov 23, 2026
32de197
Review: no second read of a streamed source; an update of one in its …
pick2510 Nov 23, 2026
1828da4
Review: a far feature with no label text isn't counted as left out (t…
pick2510 Nov 23, 2026
6f1d762
Review: the guide names the refused update of a streamed layer; the r…
pick2510 Nov 23, 2026
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
51 changes: 45 additions & 6 deletions crates/data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,9 +1182,16 @@ impl Dataset {
/// `results`, a dataset in longitude/latitude made from this one (a tool's update of it), in
/// its own coordinates: as it is while they are longitude/latitude; otherwise each geometry
/// written back as an edit is ([`Dataset::edit_from_lonlat`]), its stored places kept as
/// stored. Every stored place is read, but only those the results read as are held, so what is
/// held is as large as the results, not the layer. Refused, naming the first feature, when one
/// of its places can't be held in its system.
/// stored. Every stored place of `self` is read (for a streamed layer, its window: a place
/// outside it is converted back, exact to the conversion's round trip, not kept as stored),
/// but only those the results read as are held, so what is held is as large as the results,
/// not the layer. Refused, naming the first feature, when one
/// of its places can't be held in its system. A feature of the results without geometry whose
/// stored one has a place that can't be given in longitude/latitude, so it was read without it
/// ([`Dataset::in_lonlat_leaving_out`]), is left as stored, a field the results add empty:
/// every result field of it is taken from the stored feature (or empty), which assumes the
/// update's fields are worked out from geometry, as Calculate Geometry Attributes' are, the
/// only in-place update today. A tool updating attributes alone would need its own values kept.
pub fn results_from_lonlat(&self, mut results: Dataset) -> std::result::Result<Dataset, String> {
// Exact through WGS 84 both ways, as the results were read (`in_lonlat`), whatever map
// the layer is shown on.
Expand All @@ -1201,13 +1208,45 @@ impl Dataset {
Self::hold_places_by(&read, g, None, &mut held);
}
}
// The stored features of the results without geometry whose stored geometry has a place
// that can't be given in longitude/latitude, by id: only those are converted again. The
// ids of the results without geometry, sorted (8 bytes each, at most the results' count;
// nothing when every result has geometry), and of the unplaced among them.
let mut bare: Vec<u64> = results.features.rows().filter(|r| r.geometry().is_none()).map(|r| r.id()).collect();
bare.sort_unstable();
let mut unplaced = std::collections::HashMap::new();
if !bare.is_empty() {
for (i, f) in self.features.iter().enumerate() {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
stop_when_asked(i)?;
if bare.binary_search(&f.id).is_ok()
&& let Some(g) = &f.geometry
&& convert_keeping_missing(&read, g, &HeldPlaces::default()).is_none()
{
unplaced.insert(f.id, f);
}
}
}
// Before the rows are copied out of what shares them.
stop_when_asked(0)?;
for (i, f) in results.features.iter_mut().enumerate() {
stop_when_asked(i)?;
if let Some(g) = f.geometry.take() {
f.geometry =
Some(Self::edit_from_lonlat_by(&write, g, &held).map_err(|e| format!("{}: feature {}: {e}", self.name, f.id))?);
match f.geometry.take() {
Some(g) => {
f.geometry =
Some(Self::edit_from_lonlat_by(&write, g, &held).map_err(|e| format!("{}: feature {}: {e}", self.name, f.id))?);
}
// Read without its geometry: left as it was, what the results add to it empty, as
// nothing was worked out from a geometry it wasn't given.
None => {
if let Some(stored) = unplaced.get(&f.id) {
f.geometry.clone_from(&stored.geometry);
for (k, field) in results.fields.iter().enumerate() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restore overwrites every result field of a geometry-less feature with its stored value (or Null). That is right for Calculate Geometry Attributes, the only built-in tool that produces Output::Update today, since it writes only geometry-derived fields. A future in-place tool that also sets attribute-only values (a join, a constant tag) would silently lose them for these features, while the notice only says the feature was read without geometry. Low confidence this is hit now. Worth a note in the doc comment that restoration assumes the update's fields are geometry-derived, or restoring only the fields the tool did not write.

Category: quality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6f1d762: the doc comment says the restore takes every result field from the stored feature, which assumes the update's fields are geometry-derived. Calculate Geometry Attributes, the only in-place update today, is. A tool that updates attributes alone would need its own values kept, and that tool would have to add it.

if let Some(a) = f.attrs.get_mut(k) {
*a = self.field_index(&field.name).and_then(|j| stored.attrs.get(j)).cloned().unwrap_or(Value::Null);
}
}
}
}
}
}
results.held_in = self.held_in;
Expand Down
81 changes: 71 additions & 10 deletions crates/engine/src/cmd/gp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,10 @@ struct MapInputs<'a> {
/// Streamed layers the tool reads, loaded whole, and copies of layers in another system than
/// the one it works in, converted ([`work_inputs`]), by lowercase name.
loaded: std::collections::HashMap<String, Dataset>,
/// The layers read whole for the run (streamed ones) with features read without their
/// geometry, a place of theirs having none in longitude/latitude: an update of one is refused,
/// as the map holds only its window, where such a feature's stored geometry may not be.
left_out_whole: std::collections::HashSet<String>,
/// The system the tool works in ([`work_system`]): the one its inputs are given in and its
/// outputs are made in.
work: Crs,
Expand Down Expand Up @@ -1339,6 +1343,15 @@ impl MapInputs<'_> {
/// the project is; one with a place it can't hold stays in longitude/latitude, said. Tables
/// have no coordinates to hold.
fn hold_results(&self, result: &mut rustgis_analysis::ToolResult) -> Result<(), String> {
// An update writes back into the window the map holds of a streamed layer, which may not
// have the stored geometry of a feature read without it: refused, rather than lost.
if let Output::Update { layer, .. } = &result.output
&& self.left_out_whole.contains(&layer.to_ascii_lowercase())
{
return Err(format!(
"{layer} is read in place and has features with a place that can't be given in longitude/latitude, which an update would lose: Load All Features (layer.loadAll) before a tool updates it"
));
}
// A geocentric system holds no map coordinates: outputs stay in longitude/latitude then.
let project = self.snap.project.filter(|c| *c != Crs::LonLat && !c.is_geocentric());
if self.work == Crs::LonLat && project.is_none() {
Expand Down Expand Up @@ -1448,7 +1461,8 @@ fn inputs_of<'a>(snap: Snapshot<'a>, spec: Option<&rustgis_analysis::ToolSpec>,
}
}
}
let work = work_inputs(&snap.map, &snap.tables, spec, params, &mut full, &mut messages)?;
let mut left_out_whole = std::collections::HashSet::new();
let work = work_inputs(&snap.map, &snap.tables, spec, params, &mut full, &mut messages, &mut left_out_whole)?;
let mut rows = env_inputs(&snap.map, &full, &snap.env, params)?;
narrow_to_queries(&snap.map, spec, params, &full, &mut rows, &mut messages)?;
let unread = if work == Crs::LonLat { std::collections::HashSet::new() } else { attributes_only(spec, params) };
Expand All @@ -1457,6 +1471,7 @@ fn inputs_of<'a>(snap: Snapshot<'a>, spec: Option<&rustgis_analysis::ToolSpec>,
rows,
loaded: full,
work,
left_out_whole,
unread,
messages,
losses,
Expand Down Expand Up @@ -1645,18 +1660,20 @@ fn attributes_only(spec: Option<&rustgis_analysis::ToolSpec>, params: &Value) ->
/// its first input's own for a tool that works in it, every other input converted into it; else
/// longitude/latitude. An input with a place that system can't hold has the run work in
/// longitude/latitude instead, and a message says so (the conversions made for the first attempt
/// are dropped then, and the inputs read again in longitude/latitude). Returns the system.
/// are dropped then, and the inputs read again in longitude/latitude, a feature with a place
/// that has none there either read without its geometry, [`inputs_in`]). Returns the system.
fn work_inputs(
map: &rustgis_map::Map,
tables: &[crate::project::Table],
spec: Option<&rustgis_analysis::ToolSpec>,
params: &Value,
full: &mut std::collections::HashMap<String, Dataset>,
messages: &mut Vec<String>,
left_out_whole: &mut std::collections::HashSet<String>,
) -> Result<Crs, String> {
let work = work_system(map, spec, params, full);
if work != Crs::LonLat {
match inputs_in(map, tables, spec, params, full, work) {
match inputs_in(map, tables, spec, params, full, work, left_out_whole) {
Ok((converted, said)) => {
full.extend(converted);
messages.extend(said);
Expand All @@ -1670,21 +1687,25 @@ fn work_inputs(
}
}
}
let (converted, _) = inputs_in(map, tables, spec, params, full, Crs::LonLat)?;
let (converted, said) = inputs_in(map, tables, spec, params, full, Crs::LonLat, left_out_whole)?;
full.extend(converted);
messages.extend(said);
Ok(Crs::LonLat)
}

/// Copies of the layers a tool reads converted into `work`, by lowercase name: those read whole
/// (streamed layers, files) and each other layer or standalone table with geometry it names whose
/// coordinates are in another system. Nothing is copied for a layer already in `work`.
/// coordinates are in another system. Nothing is copied for a layer already in `work`. In
/// longitude/latitude, a feature with a place that can't be given there is read without its
/// geometry, and one notice says how many of each layer were.
fn inputs_in(
map: &rustgis_map::Map,
tables: &[crate::project::Table],
spec: Option<&rustgis_analysis::ToolSpec>,
params: &Value,
full: &std::collections::HashMap<String, Dataset>,
work: Crs,
left_out_whole: &mut std::collections::HashSet<String>,
) -> Result<(std::collections::HashMap<String, Dataset>, Vec<String>), String> {
let mut converted = std::collections::HashMap::new();
// The converted inputs with edges that bend ([`bent_edges`]): name, how many, how far.
Expand All @@ -1699,14 +1720,35 @@ fn inputs_in(
}
Ok(())
};
// The inputs with features read without their geometry, a place of theirs having none in
// longitude/latitude: name, how many. In `work`, another system, such a place sends the run
// to longitude/latitude instead ([`work_inputs`]), where the feature is read without it,
// rather than the run refused.
let mut unplaced: Vec<(String, usize)> = Vec::new();
let mut convert = |ds: &'_ Dataset| -> Result<Option<Dataset>, String> {
if work != Crs::LonLat {
return Ok(match ds.in_crs(work)? {
std::borrow::Cow::Owned(c) => Some(c),
std::borrow::Cow::Borrowed(_) => None,
});
}
let (c, n) = ds.in_lonlat_leaving_out()?;
if n > 0 {
unplaced.push((ds.name.clone(), n));
}
Ok(match c {
std::borrow::Cow::Owned(c) => Some(c),
std::borrow::Cow::Borrowed(_) => None,
})
};
// Read only for its attributes in a run in its first input's system: as it is. (The first
// input, if it is named there too, is in that system already.)
let unread = if work == Crs::LonLat { std::collections::HashSet::new() } else { attributes_only(spec, params) };
for (key, ds) in full {
if unread.contains(&key.to_ascii_lowercase()) {
continue;
}
if let std::borrow::Cow::Owned(c) = ds.in_crs(work)? {
if let Some(c) = convert(ds)? {
say(ds, &c)?;
converted.insert(key.clone(), c);
}
Expand Down Expand Up @@ -1737,7 +1779,7 @@ fn inputs_in(
.filter(|i| !matches!(i, ProjectInput::Layer(l) if l.is_raster()))
.map(|i| i.dataset())
.filter(|d| d.geometry_type != rustgis_data::GeometryType::None)
&& let std::borrow::Cow::Owned(c) = ds.in_crs(work)?
&& let Some(c) = convert(ds)?
{
say(ds, &c)?;
converted.insert(key, c);
Expand Down Expand Up @@ -1766,13 +1808,27 @@ fn inputs_in(
if t.dataset.geometry_type == rustgis_data::GeometryType::None {
continue;
}
if let std::borrow::Cow::Owned(c) = t.dataset.in_crs(work)? {
if let Some(c) = convert(&t.dataset)? {
say(&t.dataset, &c)?;
converted.insert(table_key(t.id), c);
}
}
// One notice for them all, naming each layer.
let mut said = Vec::new();
// The layers read whole (streamed ones, files) with features read without their geometry.
for (key, ds) in full {
if unplaced.iter().any(|(name, _)| *name == ds.name) {
left_out_whole.insert(key.to_ascii_lowercase());
}
}
if !unplaced.is_empty() {
let name = spec.map_or("The tool", |t| t.name);
let n: usize = unplaced.iter().map(|(_, n)| n).sum();
let layers = unplaced.iter().map(|(layer, n)| format!("'{layer}' ({n})")).collect::<Vec<_>>().join(", ");
said.push(format!(
"{name}: {n} feature(s) of {layers} have a place that can't be given in longitude/latitude, so the tool reads them without their geometry"
));
}
if !bent.is_empty() {
let name = spec.map_or("The tool", |t| t.name);
let n: usize = bent.iter().map(|(_, n, _)| n).sum();
Expand Down Expand Up @@ -3602,8 +3658,13 @@ fn apply_with(
let l = s.map_mut().layers.iter_mut().find(|l| l.name.eq_ignore_ascii_case(&layer)).ok_or("the input layer disappeared")?;
// Made in the system the tool worked in ([`MapInputs::hold_results`]): taken as made
// when that is the layer's own, else written back in its own coordinates from
// longitude/latitude.
l.dataset = if dataset.coord_crs() == l.dataset.coord_crs() {
// longitude/latitude. (A streamed layer whose whole read left a feature out is refused
// before this: [`MapInputs::hold_results`].)
// A streamed layer's window may be in another system than its source (longitude/latitude
// unless the map is in the source's own), while the tool read the whole source: a
// result in the source's own system is taken as made too, the layer then holding it.
let own = l.source.as_ref().map(|src| src.coord_crs());
l.dataset = if dataset.coord_crs() == l.dataset.coord_crs() || Some(dataset.coord_crs()) == own {
dataset
} else {
let lonlat = if dataset.coord_crs() == Crs::LonLat { dataset } else { dataset.in_lonlat()?.into_owned() };
Expand Down
53 changes: 36 additions & 17 deletions crates/engine/src/cmd/labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,8 @@ fn convert(s: &mut Session, p: &Value) -> CmdResult {
// said.
let astray = std::cell::Cell::new(0usize);
let unplaced = std::cell::Cell::new(0usize);
// Features left without annotation, a place of theirs having none in longitude/latitude.
let mut unplaced_features = 0usize;
// `None` for one left at its feature's label point, which isn't moved there any more.
let put_at = |[x, y]: [f64; 2]| -> Option<Coord> {
let c = Coord::new(x, y);
Expand Down Expand Up @@ -993,34 +995,40 @@ fn convert(s: &mut Session, p: &Value) -> CmdResult {
},
}
};
// A class's label text for a row, and whether it was cut: `None` when it gives none (no
// expression or field, an expression with no value, a null field), so no label is made.
let text_of = |i: usize, row: usize| -> Option<(String, bool)> {
match by_text(i).and_then(|e| e.text_cut(&l.dataset, row)) {
Some(Some((t, was_cut))) => Some((t, was_cut)),
Some(None) => None,
None => {
let fi = fields.get(i).copied().flatten()?;
let v = l.dataset.value(row, fi);
(!v.is_null()).then(|| (v.to_string(), false))
}
}
};
for (row, ft) in l.dataset.features.rows().enumerate() {
if rows.get(row) != Some(&true) {
continue;
}
// In the system the annotation layer is made in (above).
let Some(g) = ft.geometry() else { continue };
// One with a place that can't be given in longitude/latitude, which the map doesn't
// draw either, becomes no annotation, and is said.
let g = if own {
std::borrow::Cow::Borrowed(g)
} else if let Some(g) = rustgis_data::Dataset::converted_to_lonlat(&to, g) {
g
} else {
rustgis_data::Dataset::geometry_to_lonlat_by(&to, g).map_err(|e| format!("{}: feature {}: {e}", l.name, ft.id()))?
// Counted only when it has a label to convert: a visible class giving it text.
unplaced_features += usize::from(matcher.classes_of(&l.dataset, row).any(|(i, c)| c.visible && text_of(i, row).is_some()));
continue;
};
let Some(at) = g.label_point() else { continue };
for (i, class) in matcher.classes_of(&l.dataset, row).filter(|(_, c)| c.visible) {
let text = match by_text(i).and_then(|e| e.text_cut(&l.dataset, row)) {
Some(Some((t, was_cut))) => {
cut += usize::from(was_cut);
t
}
Some(None) => continue,
None => {
let Some(fi) = fields.get(i).copied().flatten() else { continue };
let v = l.dataset.value(row, fi);
if v.is_null() {
continue;
}
v.to_string()
}
};
let Some((text, was_cut)) = text_of(i, row) else { continue };
cut += usize::from(was_cut);
let mut attrs = vec![Attr::Text(text)];
if classes {
attrs.push(Attr::Text(class.name.clone()));
Expand Down Expand Up @@ -1057,9 +1065,20 @@ fn convert(s: &mut Session, p: &Value) -> CmdResult {
}
}
if ds.features.is_empty() {
if unplaced_features > 0 {
return Err(format!(
"the layer has no labels to convert: {unplaced_features} feature(s) have a place that can't be given in longitude/latitude"
));
}
return Err("the layer has no labels to convert".into());
}
let n = ds.features.len();
let unplaced_features_note = (unplaced_features > 0).then(|| {
NoticeText::format(
"{name}: {n} feature(s) of {layer} have a place that can't be given in longitude/latitude, so their labels aren't converted",
[("name", ds.name.clone().into()), ("n", unplaced_features.to_string().into()), ("layer", l.name.clone().into())],
)
});
let flattened_note = (flattened > 0).then(|| {
NoticeText::format(
"{name}: {n} label(s) along lines made upright points at their lines' middle vertex, no longer laid along the line",
Expand Down Expand Up @@ -1143,7 +1162,7 @@ fn convert(s: &mut Session, p: &Value) -> CmdResult {
if let Some(note) = cut_note {
s.notify(note, false);
}
for note in [flattened_note, repeated_note, astray_note, unplaced_note].into_iter().flatten() {
for note in [flattened_note, repeated_note, astray_note, unplaced_note, unplaced_features_note].into_iter().flatten() {
s.notify_text(note, false);
}
if let Some((_, unread)) = &whole {
Expand Down
Loading
Loading