Repository navigation
Geoprocessing reads a feature it can't place in longitude/latitude without its geometry, and says so (#2032 C2f-4b-1b) #2798
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
73e63d2
8a08b7c
6e2804e
563c283
a93ad1d
2643901
cde1b53
49ff4d5
ab660e3
bb05153
837d130
5ddf935
e9fb954
a305868
f5c791c
12cd802
cb16a0f
fd5b119
b690986
5cdcd4b
8b519ae
4d51984
3aa99f6
96238c6
fefc503
c67c18a
32de197
1828da4
6f1d762
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 |
|---|---|---|
|
|
@@ -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. | ||
|
|
@@ -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() { | ||
| 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() { | ||
|
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. 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 Category: quality
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. 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; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.