From 5ace28e95c2a02ed777fe400e426a25e40906f31 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:35:31 -0500 Subject: [PATCH 1/7] fix(geom): judge an MGRS zone before its band; correct two comments parse_mgrs now refuses a zone outside 1 to 60 before reading the band letter, as parse_utm does, so 0AAA and 61AVE report the bad zone rather than an unsupported polar reference. POLE_TOLERANCE's doc said only the tests use it; the engine's polar edits and analysis's topology, conversion and network code do. The EPSG:5880 test comment now says the million-odd metre offset is in the northing, not the easting. --- crates/geom/src/lib.rs | 5 +++-- crates/geom/src/utm.rs | 6 ++++++ crates/map/src/projection.rs | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/geom/src/lib.rs b/crates/geom/src/lib.rs index 5dc15faa19..11587ed871 100644 --- a/crates/geom/src/lib.rs +++ b/crates/geom/src/lib.rs @@ -36,8 +36,9 @@ pub const MERCATOR_R: f64 = 6_378_137.0; /// Latitude limit of Web Mercator. pub const MAX_LAT: f64 = 85.051_128_78; /// How near ±90° (degrees) a latitude counts as the pole: about a centimeter, more than geometry -/// operations' rounding moves a pole vertex (around 1e-8°). For the polar edits and the features -/// meeting at a pole that build on this (#1033); here only the tests use it. +/// operations' rounding moves a pole vertex (around 1e-8°). The engine's polar edits +/// (`cmd/design.rs`) and analysis's topology, conversion and network code use it to find the +/// features meeting at a pole (#1033). pub const POLE_TOLERANCE: f64 = 1e-7; /// Screen pixel size assumed when converting resolution to a map scale (0.28 mm, OGC). pub const PIXEL_M: f64 = 0.000_28; diff --git a/crates/geom/src/utm.rs b/crates/geom/src/utm.rs index 36bc4dac40..7633884da8 100644 --- a/crates/geom/src/utm.rs +++ b/crates/geom/src/utm.rs @@ -585,6 +585,10 @@ pub fn parse_mgrs(text: &str) -> Result { } _ => return Err(GridError::Digits), }; + // The zone first, as `parse_utm` does: `0AAA` names a bad zone, not a polar reference. + if !(1..=60).contains(&zone) { + return Err(GridError::Zone); + } let band = band_letter(band)?; let [column, row] = letters; let digit = |s: &str| if s.is_empty() { Ok(0) } else { s.parse::().map_err(|_| GridError::Digits) }; @@ -976,6 +980,8 @@ mod tests { ("123SMB", GridError::Syntax), ("0SMB", GridError::Zone), ("61SMB", GridError::Zone), + ("0AAA", GridError::Zone), + ("61AVE", GridError::Zone), // The zone is judged once the text is written as a reference: a number past 60 // before a word is ordinary text. ("75 Main St", GridError::Syntax), diff --git a/crates/map/src/projection.rs b/crates/map/src/projection.rs index 8e18326b5d..cb236e3c48 100644 --- a/crates/map/src/projection.rs +++ b/crates/map/src/projection.rs @@ -1228,8 +1228,9 @@ mod tests { assert!(e.contains("labrd"), "{e}"); // proj4rs 0.3 added Cassini, the polyconic, Equal Earth and the oblique Mercator: their // codes are accepted (EPSG:5880's polyconic, whose refusal was #208), and draw where PROJ - // does: 54°W 10°S lands at (5 000 000, 8 894 145.167) in pyproj 3.8.0's EPSG:5880, its - // false easting less a million-odd metres. + // does: 54°W 10°S lands at (5 000 000, 8 894 145.167) in pyproj 3.8.0's EPSG:5880. On the + // central meridian x is the false easting itself; y is the false northing (10 000 000) + // less a million-odd metres. for ok in ["EPSG:5880", "EPSG:2057", "EPSG:3068", "EPSG:8858"] { crate::Projection::from_code(ok).unwrap_or_else(|e| panic!("{ok}: {e}")); } From 8044a525c28c132dd5ba1cf26811f74facd914e1 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:35:48 -0500 Subject: [PATCH 2/7] fix(render): clip placed pixels; keep colour-vision frames as pixels Canvas::place drew a pixel child without its clip, though the recording branch clips and the doc promises it: the pixel branch now draws through a mask of the clip. render_frame records vectors only when no colour-vision simulation applies, so a change to the full-resolution rule can't let vectors skip the simulation. --- crates/render/src/canvas.rs | 27 ++++++++++++++++++++++++++- crates/render/src/lib.rs | 11 ++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/crates/render/src/canvas.rs b/crates/render/src/canvas.rs index 0d22ee871b..8188d1dd40 100644 --- a/crates/render/src/canvas.rs +++ b/crates/render/src/canvas.rs @@ -241,7 +241,16 @@ impl Canvas { pub fn place(&mut self, child: Canvas, transform: Transform, opacity: f32, blend: Blend, clip: Option) { if self.rec.is_none() || !child.is_recording() { let paint = PixmapPaint { opacity, blend_mode: crate::blend_mode(blend), quality: tiny_skia::FilterQuality::Bilinear }; - self.pixels().draw_pixmap(0, 0, child.pm.as_ref(), &paint, transform, None); + // Cut to `clip` as the recording is: a mask the size of these pixels. + let mask = match &clip { + Some(c) => { + let Some(mut m) = Mask::new(self.pm.width(), self.pm.height()) else { return }; + m.fill_path(&c.path, c.rule, true, c.transform); + Some(m) + } + None => None, + }; + self.pixels().draw_pixmap(0, 0, child.pm.as_ref(), &paint, transform, mask.as_ref()); return; } let Some(drawing) = child.into_drawing() else { return }; @@ -394,6 +403,22 @@ mod tests { assert!(stroke.width == 2.0 && path.segments().filter(|s| matches!(s, tiny_skia::PathSegment::MoveTo(_))).count() == 10); } + #[test] + fn placing_pixels_keeps_inside_the_clip() { + let mut c = Canvas::new(40, 20).unwrap(); + let mut child = c.sub(40, 20).unwrap(); + child.pixels().fill(Color::from_rgba8(200, 0, 0, 255)); + let clip = Clip { + path: PathBuilder::from_rect(Rect::from_xywh(0.0, 0.0, 20.0, 20.0).unwrap()), + rule: FillRule::Winding, + transform: Transform::identity(), + }; + c.place(child, Transform::identity(), 1.0, Blend::Normal, Some(clip)); + let pm = c.into_pixmap(); + assert_eq!(pm.pixel(5, 10).map(|p| p.alpha()), Some(255), "inside the clip"); + assert_eq!(pm.pixel(30, 10).map(|p| p.alpha()), Some(0), "outside the clip"); + } + #[test] fn a_label_keeps_its_halo_as_a_shape_and_its_text_once() { let label = crate::PlacedLabel { diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rs index 5f1d9da013..9614ef608f 100644 --- a/crates/render/src/lib.rs +++ b/crates/render/src/lib.rs @@ -3159,9 +3159,14 @@ fn render_frame( record: bool, ) -> Option { let (w, h) = view.pixel_size(); - // Kept as vectors (`record`) on the CPU, for a flat frame without view effects (a pixel - // filter over the whole frame); anything else draws its pixels. - let record = record && !backend.is_gpu() && !map.projection.is_globe() && map.view.effects.is_none(); + // Kept as vectors (`record`) on the CPU, for a flat frame without view effects or a + // colour-vision simulation (pixel filters over the whole frame); anything else draws its + // pixels. + let record = record + && !backend.is_gpu() + && !map.projection.is_globe() + && map.view.effects.is_none() + && map.view.color_vision == rustgis_map::view::ColorVision::Normal; let mut pm = if record { Canvas::recording(w, h)? } else { Canvas::new(w, h)? }; // Streamed layers read the view: in the background for the screen, in place for an export // (the full-resolution render), which waits for them; only the layers drawn at the view's From 39192f451543c000431363ed8dd576dcff62c8b4 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 00:36:05 -0500 Subject: [PATCH 3/7] fix(engine): say when a STAC asset draws retrieval codes as values stac.addAsset now warns when the asset's metadata names codes for a failed retrieval (JAXA Earth's je:rasters dn.error), which a single file draws as values; a data cube already skipped them. The Print Map PDF's overflow notice spoke of pages; it now says the map is drawn as one picture. A connection parameter that isn't text gets an error saying what it must be, and an unknown id in a web request reads as NO_SUCH_CONNECTION. --- crates/engine/src/cmd/share.rs | 3 ++- crates/engine/src/cmd/stac.rs | 20 ++++++++++++++++++- crates/engine/src/service_logins.rs | 14 +++++-------- crates/engine/src/tests.rs | 31 +++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd/share.rs b/crates/engine/src/cmd/share.rs index 9f347ef027..3e7c483ca3 100644 --- a/crates/engine/src/cmd/share.rs +++ b/crates/engine/src/cmd/share.rs @@ -190,7 +190,8 @@ pub fn map_pdf(s: &mut Session, dpi: f64) -> Result, String> { let (w, h) = (mm(view.width), mm(view.height)); let page = if drawing.overflowed() { // Too large for vectors: the map as one picture, as it is drawn on screen. - super::layout::pictured_notices(s, &[], &[1]); + let mb = rustgis_render::vector::MAX_COST >> 20; + s.warn(format!("The map is drawn as one picture, not vectors: its vectors would pass {mb} MB")); let png = rustgis_render::render_png(s.map_mut(), &view)?; let pm = rustgis_render::decode_png(&png).ok_or("could not draw the map")?; rustgis_render::pdf::Page::new(&pm, w, h) diff --git a/crates/engine/src/cmd/stac.rs b/crates/engine/src/cmd/stac.rs index a8b1edc58e..d9f5ce3e66 100644 --- a/crates/engine/src/cmd/stac.rs +++ b/crates/engine/src/cmd/stac.rs @@ -250,6 +250,9 @@ fn add_asset(s: &mut Session, p: &Value) -> CmdResult { let p = bound.as_ref(); let i = item(p)?; let (key, href) = i.asset_href(ps(p, "asset"))?; + // Codes for a failed retrieval (JAXA Earth's `dn.error`), which a data cube skips but a + // single file draws as values. + let codes = i.pick(Some(&key)).ok().map(|a| (a.invalid.clone(), a.codes_unread)).unwrap_or_default(); let name = ps(p, "name").map(str::trim).filter(|n| !n.is_empty()).map(str::to_string).unwrap_or_else(|| format!("{} {key}", i.id)); // A Planetary Computer asset is read with its storage container's token. #[cfg(not(target_arch = "wasm32"))] @@ -258,7 +261,22 @@ fn add_asset(s: &mut Session, p: &Value) -> CmdResult { if let Some(connection) = p.get("connection") { add["connection"] = connection.clone(); } - super::layer::add_url(s, &add) + let added = super::layer::add_url(s, &add)?; + match codes { + (_, true) => s.warn(format!( + "{name}: its metadata marks failed retrievals with codes that couldn't be read whole, and the map draws them as values" + )), + (invalid, false) if !invalid.is_empty() => { + let listed: Vec = invalid.iter().map(f64::to_string).collect(); + s.warn(format!( + "{name}: its metadata marks failed retrievals with {} code(s) ({}), which the map draws as values", + invalid.len(), + listed.join(", ") + )); + } + _ => {} + } + Ok(added) } /// The most items a data cube on the time slider takes (its search is paged up to this). diff --git a/crates/engine/src/service_logins.rs b/crates/engine/src/service_logins.rs index 6a86ede41f..9d77222b1c 100644 --- a/crates/engine/src/service_logins.rs +++ b/crates/engine/src/service_logins.rs @@ -46,6 +46,8 @@ pub const NOT_THIS_SESSION: &str = "This request's login does not belong to this pub const CHOOSE_CONNECTION: &str = "Several saved connections match this address. Choose a connection explicitly."; /// A `connection` that is not a saved web-service connection's id. pub const NO_SUCH_CONNECTION: &str = "No saved web-service connection with this id."; +/// A request's `connection` that isn't text. +const CONNECTION_TEXT: &str = "connection must be a saved web-service connection id (text)"; /// The commands that add layers from a service, and so may record the connection they came from /// (their `connection` parameter, or the connection whose login their address is read with). pub const ADD_COMMANDS: &[&str] = &[ @@ -364,7 +366,7 @@ pub fn request_params<'a>(s: &mut Session, p: &'a Value) -> Result None, Some(Value::String(id)) if id.trim().is_empty() => None, Some(Value::String(id)) => Some(id.as_str()), - Some(_) => return Err("connection is a saved web-service connection id.".into()), + Some(_) => return Err(CONNECTION_TEXT.into()), }; if id.is_none() && (s.web_logins.anonymous || p.get("anonymous").and_then(Value::as_bool) == Some(true)) { // An address bound to a login is no authority for it here either. @@ -801,16 +803,10 @@ fn named(s: &Session, params: &Value) -> Result, String> { None | Some(Value::Null) => Ok(None), Some(Value::String(id)) if id.trim().is_empty() => Ok(None), Some(Value::String(id)) => { - let c = s - .connections - .connections - .iter() - .find(|c| &c.id == id) - .filter(|c| is_service(c)) - .ok_or("connection is the id of a saved web-service connection (connection.list)")?; + let c = s.connections.connections.iter().find(|c| &c.id == id).filter(|c| is_service(c)).ok_or(NO_SUCH_CONNECTION)?; Ok(Some(c.clone())) } - Some(_) => Err("connection is the id of a saved web-service connection (connection.list)".into()), + Some(_) => Err(CONNECTION_TEXT.into()), } } diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index c488a4749c..781273a38a 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -15961,6 +15961,37 @@ fn stac_search_and_assets() { assert!(s.run("stac.addAsset", &json!({"item": {"type": "Feature", "id": "x", "assets": {}}})).is_err()); } +/// A single STAC asset whose metadata names codes for a failed retrieval (JAXA Earth's +/// `je:rasters` `dn.error`) draws them as values, and says so; an asset without them says nothing. +#[test] +fn a_stac_asset_with_retrieval_codes_says_they_draw_as_values() { + let item = |id: &str, extra: &str| { + format!( + r#"{{"type": "Feature", "id": "{id}", "collection": "c", "bbox": [7, 46, 8, 47], "geometry": null, + "properties": {{"datetime": "2024-06-02T10:30:00Z"}}, + "assets": {{"places": {{"href": "{{base}}/data/places.geojson", "type": "application/geo+json", "roles": ["data"]{extra}}}}}}}"# + ) + }; + let geojson = r#"{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"n": 1}, "geometry": {"type": "Point", "coordinates": [7.5, 46.5]}}]}"#; + let base = serve_routes( + vec![ + ("/items/clean", item("clean", "")), + ("/items/coded", item("coded", r#", "je:rasters": {"dn": {"error": [5.0, 7.0]}}"#)), + ("/data/places.geojson", geojson.to_string()), + ], + 4, + ); + let mut s = Session::new(Project::default()); + let mark = s.notice_mark(); + s.run("stac.addAsset", &json!({"url": format!("{base}/items/clean"), "name": "Clean"})).unwrap(); + let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!(!said.iter().any(|t| t.contains("failed retrievals")), "clean input tells nothing: {said:?}"); + let mark = s.notice_mark(); + s.run("stac.addAsset", &json!({"url": format!("{base}/items/coded"), "name": "Coded"})).unwrap(); + let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!(said.iter().any(|t| t.contains("Coded: its metadata marks failed retrievals with 2 code(s) (5, 7)")), "{said:?}"); +} + /// Directions through a routing server of one's own (a local Valhalla answer here): the route /// and its steps as layers; the app's answer can be passed in instead, and nothing is fetched. #[test] From 97bf0837d577dc482b478ff58f8a53849d4fd52a Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 04:52:47 -0500 Subject: [PATCH 4/7] Address review feedback - render_frame keeps recording an export with a colour-vision view: exports never simulate colour vision, so the gate only applies on screen; a test checks the Print Map PDF stays vectors with no notice, with and without colour vision. - The Print Map PDF's picture notice names the drawing limit (size or item count) rather than only vector size. - stac.addAsset reads the retrieval codes of the asset picked by the same selector, lists at most five (large ones in exponent form), and a test covers codes that can't be read whole. - CONNECTION_TEXT is translated in connectionui::translated. - search tests check a bad MGRS zone (0AAA, 61AVE) reaches the result. - A Canvas::place test with separate clip and child transforms. --- crates/engine/src/cmd/search.rs | 3 +++ crates/engine/src/cmd/share.rs | 7 +++++-- crates/engine/src/cmd/stac.rs | 17 +++++++++++------ crates/engine/src/service_logins.rs | 2 +- crates/engine/src/tests.rs | 27 ++++++++++++++++++++++++++- crates/render/src/canvas.rs | 19 +++++++++++++++++++ crates/render/src/lib.rs | 6 +++--- crates/ui-egui/src/connectionui.rs | 1 + 8 files changed, 69 insertions(+), 13 deletions(-) diff --git a/crates/engine/src/cmd/search.rs b/crates/engine/src/cmd/search.rs index 777ad4f5bf..cf838e4181 100644 --- a/crates/engine/src/cmd/search.rs +++ b/crates/engine/src/cmd/search.rs @@ -721,6 +721,9 @@ mod tests { ("38Z 444141 3684706", GridError::Polar), ("38ZMB4414084706", GridError::Polar), ("99X 1 2", GridError::Zone), + // A bad zone is judged before a polar or unknown band. + ("0AAA", GridError::Zone), + ("61AVE", GridError::Zone), ("33U 1000000 5523456", GridError::OutsideZone), ] { assert_eq!(read_grid_reference(q), Err(why), "{q}"); diff --git a/crates/engine/src/cmd/share.rs b/crates/engine/src/cmd/share.rs index 3f04d62694..c5e59dd9be 100644 --- a/crates/engine/src/cmd/share.rs +++ b/crates/engine/src/cmd/share.rs @@ -327,8 +327,11 @@ pub fn map_pdf(s: &mut Session, dpi: f64) -> Result, String> { let (w, h) = (mm(view.width), mm(view.height)); let page = if drawing.overflowed() { // Too large for vectors: the map as one picture, as it is drawn on screen. - let mb = rustgis_render::vector::MAX_COST >> 20; - s.warn(format!("The map is drawn as one picture, not vectors: its vectors would pass {mb} MB")); + // The budget counts the drawing's pictures (rasters, tiles) as well as its shapes. + let (mb, items) = (rustgis_render::vector::MAX_COST >> 20, rustgis_render::vector::MAX_ITEMS / 1_000_000); + s.warn(format!( + "The map is drawn as one picture, not vectors: kept as vectors, it would pass the drawing limit ({mb} MB or {items} million items)" + )); let png = rustgis_render::render_png(s.map_mut(), &view)?; let pm = rustgis_render::decode_png(&png).ok_or("could not draw the map")?; rustgis_render::pdf::Page::new(&pm, w, h) diff --git a/crates/engine/src/cmd/stac.rs b/crates/engine/src/cmd/stac.rs index d9f5ce3e66..8a94de2fa1 100644 --- a/crates/engine/src/cmd/stac.rs +++ b/crates/engine/src/cmd/stac.rs @@ -251,8 +251,8 @@ fn add_asset(s: &mut Session, p: &Value) -> CmdResult { let i = item(p)?; let (key, href) = i.asset_href(ps(p, "asset"))?; // Codes for a failed retrieval (JAXA Earth's `dn.error`), which a data cube skips but a - // single file draws as values. - let codes = i.pick(Some(&key)).ok().map(|a| (a.invalid.clone(), a.codes_unread)).unwrap_or_default(); + // single file draws as values: of the asset `asset_href` picked, by the same selector. + let codes = i.pick(ps(p, "asset")).ok().map(|a| (a.invalid.clone(), a.codes_unread)).unwrap_or_default(); let name = ps(p, "name").map(str::trim).filter(|n| !n.is_empty()).map(str::to_string).unwrap_or_else(|| format!("{} {key}", i.id)); // A Planetary Computer asset is read with its storage container's token. #[cfg(not(target_arch = "wasm32"))] @@ -267,11 +267,16 @@ fn add_asset(s: &mut Session, p: &Value) -> CmdResult { "{name}: its metadata marks failed retrievals with codes that couldn't be read whole, and the map draws them as values" )), (invalid, false) if !invalid.is_empty() => { - let listed: Vec = invalid.iter().map(f64::to_string).collect(); + // The first few, large ones (a float's lowest, -3.4e38) in exponent form. + const SHOWN: usize = 5; + let code = |v: &f64| if v.abs() >= 1e6 { format!("{v:e}") } else { v.to_string() }; + let mut listed = invalid.iter().take(SHOWN).map(code).collect::>().join(", "); + if invalid.len() > SHOWN { + listed.push_str(&format!(" and {} more", invalid.len() - SHOWN)); + } s.warn(format!( - "{name}: its metadata marks failed retrievals with {} code(s) ({}), which the map draws as values", - invalid.len(), - listed.join(", ") + "{name}: its metadata marks failed retrievals with {} code(s) ({listed}), which the map draws as values", + invalid.len() )); } _ => {} diff --git a/crates/engine/src/service_logins.rs b/crates/engine/src/service_logins.rs index 9d77222b1c..5301a7172c 100644 --- a/crates/engine/src/service_logins.rs +++ b/crates/engine/src/service_logins.rs @@ -47,7 +47,7 @@ pub const CHOOSE_CONNECTION: &str = "Several saved connections match this addres /// A `connection` that is not a saved web-service connection's id. pub const NO_SUCH_CONNECTION: &str = "No saved web-service connection with this id."; /// A request's `connection` that isn't text. -const CONNECTION_TEXT: &str = "connection must be a saved web-service connection id (text)"; +pub const CONNECTION_TEXT: &str = "connection must be a saved web-service connection id (text)"; /// The commands that add layers from a service, and so may record the connection they came from /// (their `connection` parameter, or the connection whose login their address is read with). pub const ADD_COMMANDS: &[&str] = &[ diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index afa4ededee..de4fdc6d6e 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -15977,9 +15977,10 @@ fn a_stac_asset_with_retrieval_codes_says_they_draw_as_values() { vec![ ("/items/clean", item("clean", "")), ("/items/coded", item("coded", r#", "je:rasters": {"dn": {"error": [5.0, 7.0]}}"#)), + ("/items/unread", item("unread", r#", "je:rasters": {"dn": {"error": [5.0, "x"]}}"#)), ("/data/places.geojson", geojson.to_string()), ], - 4, + 6, ); let mut s = Session::new(Project::default()); let mark = s.notice_mark(); @@ -15990,6 +15991,30 @@ fn a_stac_asset_with_retrieval_codes_says_they_draw_as_values() { s.run("stac.addAsset", &json!({"url": format!("{base}/items/coded"), "name": "Coded"})).unwrap(); let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); assert!(said.iter().any(|t| t.contains("Coded: its metadata marks failed retrievals with 2 code(s) (5, 7)")), "{said:?}"); + // Codes that can't be read whole (a word among them) say so. + let mark = s.notice_mark(); + s.run("stac.addAsset", &json!({"url": format!("{base}/items/unread"), "name": "Unread"})).unwrap(); + let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!( + said.iter().any(|t| t.contains("Unread: its metadata marks failed retrievals with codes that couldn't be read whole")), + "{said:?}" + ); +} + +/// The Print Map PDF keeps a map within the vector budget as vectors and says nothing, a +/// colour-vision view too (exports don't simulate it, so it needn't be a picture). +#[test] +fn the_map_pdf_keeps_vectors_and_says_nothing_with_or_without_colour_vision() { + let mut s = Session::new(crate::sample::world_project()); + for mode in ["normal", "deuteranopia"] { + s.run("map.colorVision", &json!({"mode": mode})).unwrap(); + let mark = s.notice_mark(); + let pdf = crate::cmd::share::map_pdf(&mut s, 96.0).unwrap(); + let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); + assert!(!said.iter().any(|t| t.contains("one picture")), "{mode}: {said:?}"); + let text = String::from_utf8_lossy(&pdf); + assert!(!text.contains("/Subtype /Image"), "{mode}: the map as vectors, not a picture"); + } } /// Directions through a routing server of one's own (a local Valhalla answer here): the route diff --git a/crates/render/src/canvas.rs b/crates/render/src/canvas.rs index 8188d1dd40..9e2a75be57 100644 --- a/crates/render/src/canvas.rs +++ b/crates/render/src/canvas.rs @@ -419,6 +419,25 @@ mod tests { assert_eq!(pm.pixel(30, 10).map(|p| p.alpha()), Some(0), "outside the clip"); } + #[test] + fn placing_pixels_cuts_to_the_clip_where_its_own_transform_puts_it() { + let mut c = Canvas::new(40, 20).unwrap(); + let mut child = c.sub(10, 20).unwrap(); + child.pixels().fill(Color::from_rgba8(200, 0, 0, 255)); + // The clip covers x 20 to 30, the child x 15 to 25: only 20 to 25 is drawn. + let clip = Clip { + path: PathBuilder::from_rect(Rect::from_xywh(0.0, 0.0, 10.0, 20.0).unwrap()), + rule: FillRule::Winding, + transform: Transform::from_translate(20.0, 0.0), + }; + c.place(child, Transform::from_translate(15.0, 0.0), 1.0, Blend::Normal, Some(clip)); + let pm = c.into_pixmap(); + let alpha = |x| pm.pixel(x, 10).map(|p| p.alpha()); + assert_eq!(alpha(22), Some(255), "the child inside the clip"); + assert_eq!(alpha(17), Some(0), "the child outside the clip"); + assert_eq!(alpha(27), Some(0), "the clip past the child"); + } + #[test] fn a_label_keeps_its_halo_as_a_shape_and_its_text_once() { let label = crate::PlacedLabel { diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rs index ed58238cbc..109411dde1 100644 --- a/crates/render/src/lib.rs +++ b/crates/render/src/lib.rs @@ -3160,13 +3160,13 @@ fn render_frame( ) -> Option { let (w, h) = view.pixel_size(); // Kept as vectors (`record`) on the CPU, for a flat frame without view effects or a - // colour-vision simulation (pixel filters over the whole frame); anything else draws its - // pixels. + // colour-vision simulation it applies (pixel filters over the whole frame; an export, + // `full_res_rasters`, never simulates colour vision); anything else draws its pixels. let record = record && !backend.is_gpu() && !map.projection.is_globe() && map.view.effects.is_none() - && map.view.color_vision == rustgis_map::view::ColorVision::Normal; + && (full_res_rasters || map.view.color_vision == rustgis_map::view::ColorVision::Normal); let mut pm = if record { Canvas::recording(w, h)? } else { Canvas::new(w, h)? }; // Streamed layers read the view: in the background for the screen, in place for an export // (the full-resolution render), which waits for them; only the layers drawn at the view's diff --git a/crates/ui-egui/src/connectionui.rs b/crates/ui-egui/src/connectionui.rs index e7f169ceeb..9fa77895e8 100644 --- a/crates/ui-egui/src/connectionui.rs +++ b/crates/ui-egui/src/connectionui.rs @@ -89,6 +89,7 @@ pub(crate) fn translated(e: &str) -> String { web::NOT_THIS_SESSION => tl!("This request's login does not belong to this session."), web::CHOOSE_CONNECTION => tl!("Several saved connections match this address. Choose a connection explicitly."), web::NO_SUCH_CONNECTION => tl!("No saved web-service connection with this id."), + web::CONNECTION_TEXT => tl!("connection must be a saved web-service connection id (text)"), other => other, } .to_string() From b4def782242cb7a46a6409dc018f2ba76e645237 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 05:22:16 -0500 Subject: [PATCH 5/7] Address CodeRabbit review feedback - The Print Map PDF says its map is a picture only once the picture is drawn, so a failed render gives the error alone. --- crates/engine/src/cmd/share.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/share.rs b/crates/engine/src/cmd/share.rs index c5e59dd9be..805d33a484 100644 --- a/crates/engine/src/cmd/share.rs +++ b/crates/engine/src/cmd/share.rs @@ -327,13 +327,14 @@ pub fn map_pdf(s: &mut Session, dpi: f64) -> Result, String> { let (w, h) = (mm(view.width), mm(view.height)); let page = if drawing.overflowed() { // Too large for vectors: the map as one picture, as it is drawn on screen. - // The budget counts the drawing's pictures (rasters, tiles) as well as its shapes. + let png = rustgis_render::render_png(s.map_mut(), &view)?; + let pm = rustgis_render::decode_png(&png).ok_or("could not draw the map")?; + // Said once the picture is drawn. The budget counts the drawing's pictures (rasters, + // tiles) as well as its shapes. let (mb, items) = (rustgis_render::vector::MAX_COST >> 20, rustgis_render::vector::MAX_ITEMS / 1_000_000); s.warn(format!( "The map is drawn as one picture, not vectors: kept as vectors, it would pass the drawing limit ({mb} MB or {items} million items)" )); - let png = rustgis_render::render_png(s.map_mut(), &view)?; - let pm = rustgis_render::decode_png(&png).ok_or("could not draw the map")?; rustgis_render::pdf::Page::new(&pm, w, h) } else { rustgis_render::pdf::Page::drawing(drawing, w, h) From a8e880ff3949199157af6f19db79104291e722bc Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 05:54:54 -0500 Subject: [PATCH 6/7] Address Claude review feedback - stac.addAsset's notice for codes that can't be read says what was wrong (the dn.error field isn't a list of numbers, or has too many) and that any such codes in the file draw as values, rather than claiming the metadata names codes. --- crates/engine/src/cmd/stac.rs | 2 +- crates/engine/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/stac.rs b/crates/engine/src/cmd/stac.rs index 8a94de2fa1..8481224ece 100644 --- a/crates/engine/src/cmd/stac.rs +++ b/crates/engine/src/cmd/stac.rs @@ -264,7 +264,7 @@ fn add_asset(s: &mut Session, p: &Value) -> CmdResult { let added = super::layer::add_url(s, &add)?; match codes { (_, true) => s.warn(format!( - "{name}: its metadata marks failed retrievals with codes that couldn't be read whole, and the map draws them as values" + "{name}: its metadata's codes for a failed retrieval (je:rasters dn.error) couldn't be read whole (not a list of numbers, or too many), so the map draws any such codes in the file as values" )), (invalid, false) if !invalid.is_empty() => { // The first few, large ones (a float's lowest, -3.4e38) in exponent form. diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index de4fdc6d6e..0780d9c470 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -15996,7 +15996,7 @@ fn a_stac_asset_with_retrieval_codes_says_they_draw_as_values() { s.run("stac.addAsset", &json!({"url": format!("{base}/items/unread"), "name": "Unread"})).unwrap(); let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); assert!( - said.iter().any(|t| t.contains("Unread: its metadata marks failed retrievals with codes that couldn't be read whole")), + said.iter().any(|t| t.contains("Unread: its metadata's codes for a failed retrieval (je:rasters dn.error) couldn't be read whole")), "{said:?}" ); } From c6d442b63d836152e6ae5403d0f2692dbd81d20a Mon Sep 17 00:00:00 2001 From: giswqs Date: Sun, 8 Nov 2026 06:17:32 -0500 Subject: [PATCH 7/7] Address CodeRabbit review feedback - The clean STAC asset test rejects both retrieval-code notices, the unreadable-codes one included. --- crates/engine/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 0780d9c470..bf8309f290 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -15986,7 +15986,7 @@ fn a_stac_asset_with_retrieval_codes_says_they_draw_as_values() { let mark = s.notice_mark(); s.run("stac.addAsset", &json!({"url": format!("{base}/items/clean"), "name": "Clean"})).unwrap(); let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect(); - assert!(!said.iter().any(|t| t.contains("failed retrievals")), "clean input tells nothing: {said:?}"); + assert!(!said.iter().any(|t| t.contains("failed retrieval")), "clean input tells nothing: {said:?}"); let mark = s.notice_mark(); s.run("stac.addAsset", &json!({"url": format!("{base}/items/coded"), "name": "Coded"})).unwrap(); let said: Vec = s.notices_since(mark).iter().map(|n| n.text.clone()).collect();