Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 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
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
28 changes: 19 additions & 9 deletions apps/rustgis-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,20 @@ impl Engine {
if let Some(note) = rustgis_engine::data::zm_export_note([&ds], &format!("{name} as GeoJSON")) {
session.notify(note, false);
}
// GeoJSON is longitude/latitude, whatever system the source holds its coordinates in.
return Ok(rustgis_engine::data::io::to_geojson(&*ds.in_lonlat()?).to_string());
// GeoJSON is longitude/latitude, whatever system the source holds its coordinates in;
// a feature with a place that can't be given there is in it without its geometry.
let (lonlat, unplaced) = ds.in_lonlat_leaving_out()?;
if let Some(note) = rustgis_engine::data::unplaced_note(&format!("{name} as GeoJSON"), &ds.name, unplaced) {
session.notify(note, false);
}
return Ok(rustgis_engine::data::io::to_geojson(&lonlat).to_string());
}
if !selected {
let text = rustgis_engine::data::io::to_geojson(&*found.dataset.in_lonlat()?).to_string();
let (lonlat, unplaced) = found.dataset.in_lonlat_leaving_out()?;
let text = rustgis_engine::data::io::to_geojson(&lonlat).to_string();
let note = rustgis_engine::data::zm_export_note([&found.dataset], &format!("{} as GeoJSON", found.name));
if let Some(note) = note {
let unplaced = rustgis_engine::data::unplaced_note(&format!("{} as GeoJSON", found.name), &found.name, unplaced);
for note in note.into_iter().chain(unplaced) {
session.notify(note, false);
}
return Ok(text);
Expand All @@ -249,16 +256,16 @@ impl Engine {
// exactly through WGS 84, as the whole layer's GeoJSON is, whatever map it is shown on.
// A layer whose system can't be converted fails only with a geometry to convert, as
// it did when each geometry was converted on its own.
// A geometry with a place that can't be given there is left out, and counted.
let to = found.dataset.lonlat_conversion();
let mut unplaced = 0usize;
for r in found.selection.iter().filter_map(|&i| found.dataset.features.row(i)) {
let g = match r.geometry() {
Some(g) => {
let to = to.as_ref().map_err(|e| format!("{}: {e}", found.name))?;
Some(
rustgis_engine::data::Dataset::geometry_to_lonlat_by(to, g)
.map_err(|e| format!("{}: feature {}: {e}", found.name, r.id()))?
.into_owned(),
)
let g = rustgis_engine::data::Dataset::geometry_to_lonlat_by(to, g).ok().map(std::borrow::Cow::into_owned);
unplaced += usize::from(g.is_none());
g
}
None => None,
};
Expand All @@ -268,6 +275,9 @@ impl Engine {
if let Some(note) = rustgis_engine::data::zm_export_note([&ds], &format!("{} as GeoJSON", ds.name)) {
session.notify(note, false);
}
if let Some(note) = rustgis_engine::data::unplaced_note(&format!("{} as GeoJSON", ds.name), &ds.name, unplaced) {
session.notify(note, false);
}
Ok::<String, String>(text)
});
self.flush(py);
Expand Down
13 changes: 10 additions & 3 deletions crates/data/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::{borrow::Cow, path::Path};

use crate::io::{CsvWriter, GeoJsonWriter, GpkgTable, GpkgWritten, check_projected, project_each, write_atomic_with};
use crate::io::{CsvWriter, GeoJsonWriter, GpkgTable, GpkgWritten, check_projected, project_each_leaving_out, write_atomic_with};
use crate::raster::Crs;
use crate::rows::Query;
use crate::source::FeatureSource;
Expand Down Expand Up @@ -44,6 +44,9 @@ pub struct Exported {
/// Vertices beyond 85.05° north or south, written at 85.05° by an export in Web Mercator,
/// where it ends (0 in another system). See [`crate::web_mercator_moved_note`].
pub beyond_web_mercator: usize,
/// Features with a place the export's system can't hold, written without their geometry
/// ([`crate::io::unplaced_export_note`]).
pub unplaced: usize,
/// Geometry and text changed by CSV export, counted over all chunks.
pub csv: crate::io::CsvLosses,
/// Text a CSV changes when read back, counted over all chunks (none for the other formats).
Expand Down Expand Up @@ -245,6 +248,7 @@ fn write_chunks_as(
let mut filtered = 0usize;
let mut skipped = 0usize;
let mut beyond_web_mercator = 0usize;
let mut unplaced = 0usize;
let mut null_numbers = 0usize;
let mut csv = crate::io::CsvLosses::default();
let mut text = crate::io::TextLosses::default();
Expand All @@ -267,6 +271,7 @@ fn write_chunks_as(
total = 0;
filtered = 0;
beyond_web_mercator = 0;
unplaced = 0;
null_numbers = 0;
csv = crate::io::CsvLosses::default();
text = crate::io::TextLosses::default();
Expand Down Expand Up @@ -296,8 +301,9 @@ fn write_chunks_as(
}
}
if let Some(t) = &t {
// Counted by the source scan, so only stopped on a cancel here.
project_each(&mut chunk, t, false)?;
// Counted by the source scan, so only stopped on a cancel here. A feature with a
// place the export's system can't hold is written without its geometry, and said.
unplaced = unplaced.saturating_add(project_each_leaving_out(&mut chunk, t, false)?);
}
total = total.saturating_add(chunk.len());
null_numbers = null_numbers.saturating_add(numbers_written_as_null(&chunk, &layer.fields, ext));
Expand Down Expand Up @@ -369,6 +375,7 @@ fn write_chunks_as(
null_numbers,
unfit,
beyond_web_mercator,
unplaced,
csv,
text,
unread_dates,
Expand Down
35 changes: 33 additions & 2 deletions crates/data/src/export/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ fn a_streamed_export_writes_what_a_whole_export_writes() {
null_numbers: 0,
unfit,
beyond_web_mercator: 0,
unplaced: 0,
// Counted over the chunks as the whole layer counts it.
csv: if ext == "csv" {
crate::io::CsvLosses::of(&whole.features, whole.geometry_type, &whole.fields).unwrap()
Expand Down Expand Up @@ -481,8 +482,9 @@ fn a_streamed_export_into_an_existing_geopackage_starts_again_inside_its_transac
assert_eq!((e.written, table), (20, Some(GpkgWritten { table: "both".into(), replaced: false, dependents: vec![] })));
let whole = d.join("whole.gpkg");
crate::io::write_path(&both, &whole).unwrap();
let read =
|p: &Path, t: &str| crate::source::open_path(p, Some(t)).unwrap().read(&Request { extent: None, limit: 100 }).unwrap().features;
let read = |p: &Path, t: &str| {
crate::source::open_path(p, Some(t)).unwrap().read(&Request { extent: None, limit: 100, own: None }).unwrap().features
};
assert_eq!(read(&county, "both"), read(&whole, "both"));
assert_eq!(read(&county, "parcels").len(), 1);
let c = rusqlite::Connection::open(&county).unwrap();
Expand Down Expand Up @@ -708,3 +710,32 @@ fn a_streamed_export_is_written_from_the_system_its_source_gives() {
assert!((p.x - want.x).abs() < 1e-7 && (p.y - want.y).abs() < 1e-7, "{name}: {p:?} {want:?}");
}
}

/// A source read a chunk at a time, written to a system it holds a place that can't be given in:
/// the feature is written without its geometry and counted, rather than failing the export; one
/// whose places all convert counts none (#2032 C2f-4b).
#[test]
fn a_streamed_export_writes_a_feature_it_cant_place_without_its_geometry_and_counts_it() {
let d = folder("unplaced");
let utm = Crs::from_epsg(32631).unwrap();
let line = |a: (f64, f64), b: (f64, f64)| Some(Geometry::Line(vec![vec![Coord::new(a.0, a.1), Coord::new(b.0, b.1)]]));
for (far, want) in [(false, 0), (true, 1)] {
let mut ds = Dataset::new("lines", GeometryType::Polyline, vec![Field::new("name", FieldType::Text)]);
ds.push_next(line((451_000.0, 5_411_000.0), (452_000.0, 5_412_000.0)), vec![Value::Text("paris".into())]);
if far {
ds.push_next(line((451_500.0, 5_411_500.0), (1e9, 5_411_500.0)), vec![Value::Text("far east".into())]);
}
ds.held_in = utm;
let mut src = Runs::new(&ds, 1);
src.held = utm;
let path = d.join(format!("lines-{far}.geojson"));
let e = write_source_in(&src, &ds, &path, Crs::LonLat).unwrap();
assert_eq!((e.written, e.unplaced), (ds.features.len(), want));
let (back, _) = crate::io::read_path(&path).unwrap();
assert_eq!(back.features.iter().filter(|f| f.geometry.is_none()).count(), want);
// In its own system nothing is converted, and nothing is counted.
let e = write_source_in(&src, &ds, &d.join(format!("lines-{far}.fgb")), utm).unwrap();
assert_eq!((e.left_out, e.unplaced), (0, 0));
}
let _ = std::fs::remove_dir_all(&d);
}
Loading
Loading