From 4ef84228a275e7a082a05e3f574969984dad2f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 18:33:49 -0500 Subject: [PATCH 01/17] fix(map): QGIS and ArcGIS imports of picture markers note an expression, a file address, a // path and a height of 0 truly (#2986) --- crates/map/src/arcgis_style.rs | 54 +++++++++++++++++++++++++------ crates/map/src/qgis/source.rs | 10 ++++-- crates/map/src/qgis/symbol.rs | 59 ++++++++++++++++++++++++++-------- crates/map/src/qgis/tests.rs | 55 +++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+), 25 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index ce634868e6..157b57c092 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -491,17 +491,25 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict // Sized by its width, as a picture marker is: its height follows the image's own // proportion, which a service draws its symbol at. Without a width above 0, its // height stands in as its width, said, since an image that isn't square is then - // drawn that wide, not that tall; with neither, RustGIS's size does. + // drawn that wide, not that tall; with neither (a height of 0 is none), RustGIS's + // size does. A height of 0 beside a width is said: ArcGIS draws nothing of it. Ok(p) => { let wide = s.get("width").and_then(Value::as_f64).is_some_and(|w| w.is_finite() && w > 0.0); - if !wide { - notes.add(if s.get("height").is_some_and(|h| !h.is_null()) { - "picture markers with no width, drawn with their height as their width" - } else { - "picture markers with no size, drawn at RustGIS's" - }); - } - let size = size(s.get(if wide { "width" } else { "height" }), base.size, notes); + let height = s.get("height").filter(|h| !h.is_null()); + let flat = height.and_then(Value::as_f64).is_some_and(|h| h <= 0.0); + let sized_by = if wide { + if flat { + notes.add("picture markers of no height, drawn as tall as their image is"); + } + s.get("width") + } else if height.is_some() && !flat { + notes.add("picture markers with no width, drawn with their height as their width"); + height + } else { + notes.add("picture markers with no size, drawn at RustGIS's"); + None + }; + let size = size(sized_by, base.size, notes); return Some((Symbol { fill, size, marker: Marker::Picture(p), ..base }, None)); } Err(why) => notes.add(why), @@ -782,6 +790,34 @@ mod tests { assert_eq!(notes.text(), "markers' angles and offsets, left out"); } + /// A picture marker with a height of 0 isn't drawn at 0 (not shown) under a note saying it is + /// drawn as wide as its height: a height of 0 is no height. + #[test] + fn a_picture_marker_of_no_height_is_said_so() { + let image = "iVBORw0KGgoSIMPLE="; + let styled_pms = |width: Value, height: Value| { + let info = json!({"renderer": {"type": "simple", "symbol": {"type": "esriPMS", "imageData": image, "width": width, "height": height}}}); + let (l, notes) = styled(GeometryType::Point, info); + let Renderer::Single(s) = l.renderer else { panic!("a single symbol") }; + (s, notes.text()) + }; + let Renderer::Single(base) = layer(GeometryType::Point).renderer else { panic!("a single symbol") }; + // With no width above 0 either, it has no size: RustGIS's. + for (width, height) in [(json!(null), json!(0)), (json!(0), json!(0)), (json!(0), json!(-4))] { + let (s, text) = styled_pms(width.clone(), height.clone()); + assert_eq!(s.size, base.size, "width {width}, height {height}"); + assert_eq!(text, "picture markers with no size, drawn at RustGIS's", "width {width}, height {height}"); + } + // With a width, it is drawn by it, and the height's 0 said. + let (s, text) = styled_pms(json!(15), json!(0)); + assert_eq!(s.size, 15.0); + assert_eq!(text, "picture markers of no height, drawn as tall as their image is"); + // A height above 0 says nothing of the kind. + let (s, text) = styled_pms(json!(15), json!(18)); + assert_eq!(s.size, 15.0); + assert!(text.is_empty(), "{text}"); + } + #[test] fn a_picture_marker_rustgis_cant_draw_is_a_grey_circle_of_its_size_and_said_why() { let circle = |symbol: Value| { diff --git a/crates/map/src/qgis/source.rs b/crates/map/src/qgis/source.rs index 6cdea893db..2c049e2bea 100644 --- a/crates/map/src/qgis/source.rs +++ b/crates/map/src/qgis/source.rs @@ -595,13 +595,19 @@ fn file_url_path(url: &str) -> Option<&str> { Some(if drive { path.get(1..).unwrap_or(path) } else { path }) } +/// A `file:` address's path (see [`file_url_path`]) decoded as any address's parts are; `None` for any +/// other address and for one with a host. +pub(super) fn file_address_path(url: &str) -> Option { + file_url_path(url).map(rustgis_data::address::percent_decode) +} + /// A tile archive's path: a `file://` address (`file:../x` when relative) as its path, a relative /// one from the project's folder; a web address as it is. fn archive_path(url: &str, dir: &str) -> String { let url = url.trim(); - match file_url_path(url) { + match file_address_path(url) { // (Its parts are encoded as in any address.) - Some(path) => absolute(&rustgis_data::address::percent_decode(path), dir), + Some(path) => absolute(&path, dir), None if url.contains("://") => url.to_string(), None => absolute(url, dir), } diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index f9de955686..e6e0f682e2 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -663,7 +663,7 @@ fn along(l: Node, p: &[(String, String)], hash: bool, reference: Option, la let stroke = if hash { hash_mark(class, &sp, p, base, reference, layer, report) } else { - marker_mark(class, &sp, base, reference, layer, report) + marker_mark(class, &sp, class == "RasterMarker" && name_from_expression(sub), base, reference, layer, report) }; if let Some(mut st) = stroke { // An image mark is drawn at the layer's opacity alone. @@ -710,10 +710,12 @@ fn placements(p: &[(String, String)], layer: &str, report: &mut Report) -> Place } /// A marker line's marker layer `class` (its settings `p`) as a stroke of markers at `base`'s -/// places, or `None` for one RustGIS has no match for (noted). +/// places, or `None` for one RustGIS has no match for (noted). `from_expression`: its image path is +/// set by a field or an expression. fn marker_mark( class: &str, p: &[(String, String)], + from_expression: bool, base: LineMarkers, reference: Option, layer: &str, @@ -728,7 +730,7 @@ fn marker_mark( }) } "FontMarker" => font_char(p, layer, report)?, - "RasterMarker" => raster_image(p, layer, report).map_or(Marker::Circle, |(picture, _)| Marker::Picture(picture)), + "RasterMarker" => raster_image(p, from_expression, layer, report).map_or(Marker::Circle, |(picture, _)| Marker::Picture(picture)), "SvgMarker" | "EllipseMarker" | "FilledMarker" => { report.approximated(layer, format!("{} markers, drawn as circles in their colour", marker_name(class))); Marker::Circle @@ -833,7 +835,7 @@ fn marker(layers: &[(Node, Props)], reference: Option, still: bool, layer: Some(m) => m, None => continue, }, - "RasterMarker" => match raster_image(p, layer, report) { + "RasterMarker" => match raster_image(p, name_from_expression(*l), layer, report) { Some((picture, a)) => { aspect = a; Marker::Picture(picture) @@ -889,11 +891,19 @@ fn marker(layers: &[(Node, Props)], reference: Option, still: bool, layer: Converted { symbol, strokes, rotation: None, by: SymbolBy::default(), fills: Vec::new() } } +/// Whether image path `file` names a network share (`\\host\share`, `//host/share`), which isn't +/// opened: looking one up can sign in to the host, and a project may be opened on Windows, where +/// `//` is one (as `paths::is_absolute_local` refuses it on every platform). +pub(super) fn network_share(file: &str) -> bool { + file.len() > 1 && file.chars().take(2).all(|c| c == '\\' || c == '/') +} + /// Reads the images of the raster image markers under `root` (a project or a style), each /// `imageFile` once (a file once for each spelling of its path from the folder: a leading `./` is /// dropped, so `./a.png` and `a.png` are one), into the report for [`raster_image`]: a `base64:` -/// one as it is, a file's through `read` (relative to `dir`). One at a web address isn't fetched, -/// nor one on a network share (`\\host\share`, `//host/share`), nor one kept inside a `.qgz` +/// one as it is, a file's through `read` (relative to `dir`; a `file:` address is the file it names). +/// One at a web address isn't fetched, nor one on a network share (`\\host\share`, `//host/share`, +/// `file://host/share`), nor one kept inside a `.qgz` /// (`attachment:`); one relative to no folder (or to a drive's working folder) isn't looked /// for, and those past the pictures a run keeps ([`MAX_PICTURES`], /// [`MAX_PICTURES_BYTES`]) aren't read. An image is kept when read, before its symbol is: one @@ -910,22 +920,33 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & if report.images.contains_key(file) { continue; } + // A `file:` address is the file it names, decoded as a tile archive's address is; one with + // a host is a network share. + let address = file.starts_with("file:"); + let (path, share) = if address { + match super::source::file_address_path(file) { + Some(path) => (path, false), + None => (file.to_string(), true), + } + } else { + (file.to_string(), false) + }; let source = if file.starts_with("base64:") { Ok(None) } else if file.starts_with("attachment:") { Err("whose image is kept inside the .qgz project, which RustGIS doesn't read it from") - } else if file.contains("://") { - Err("whose image is at a web address, which RustGIS doesn't fetch") - } else if file.len() > 1 && file.chars().take(2).all(|c| c == '\\' || c == '/') { + } else if share || network_share(&path) { // Looking a share up can sign in to the host the file names, which a style or // project chose (as an archive on one isn't opened either). Err("whose image is on a network share, which RustGIS doesn't open") - } else if super::is_drive_relative(file) { + } else if path.contains("://") && (!address || file.contains("://")) { + Err("whose image is at a web address, which RustGIS doesn't fetch") + } else if super::is_drive_relative(&path) { Err("whose image file is relative to a drive's working folder, which no project folder tells") - } else if super::is_relative(file) && dir.is_empty() { + } else if super::is_relative(&path) && dir.is_empty() { Err("whose image file is relative to a folder the import wasn't given") } else { - Ok(Some(super::source::absolute(file, dir))) + Ok(Some(super::source::absolute(&path, dir))) }; if let Ok(Some(path)) = &source && let Some(got) = files.get(path) @@ -964,10 +985,15 @@ const SEE_THROUGH_IMAGES: &str = "see-through raster image markers, drawn opaque /// A raster image marker's image (read before the symbols: [`read_images`]) and its height over /// its width, or `None` (noted, with why) for it to be drawn as a circle. What QGIS draws -/// otherwise than RustGIS is noted: a ratio of its own, see-through. -fn raster_image(p: &[(String, String)], layer: &str, report: &mut Report) -> Option<(Picture, f32)> { +/// otherwise than RustGIS is noted: a ratio of its own, see-through. `from_expression`: its image +/// path is set by a field or an expression. +fn raster_image(p: &[(String, String)], from_expression: bool, layer: &str, report: &mut Report) -> Option<(Picture, f32)> { let file = prop(p, "imageFile").map(str::trim).unwrap_or_default(); let why = match report.images.get(file) { + // QGIS's image path as a field or an expression (`name`) has nothing in `imageFile` to read. + _ if file.is_empty() && from_expression => { + "whose image comes from a field or an expression, which RustGIS doesn't evaluate".to_string() + } _ if file.is_empty() => "with no image".to_string(), Some(Ok(got)) => { let got = *got; @@ -1021,6 +1047,11 @@ fn point_offset( (x, y) } +/// Whether `node`'s image path (`name`) is set by a field or an expression. +fn name_from_expression(node: Node) -> bool { + active_properties(node).iter().any(|(name, _)| *name == "name") +} + /// The data-defined properties switched on in `node`'s own `data_defined_properties`, by name. fn active_properties<'a, 'i>(node: Node<'a, 'i>) -> Vec<(&'a str, Node<'a, 'i>)> { active_properties_in(node, "data_defined_properties") diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index b60cc0ef85..0e1ab5a403 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1473,6 +1473,60 @@ fn raster_image_markers_draw_their_image_read_once_from_the_style_folder() { assert_eq!(notes, [("see-through raster image markers, drawn opaque", 1)]); } +/// A `file:` address is the file it names, read as a tile archive's address is (decoded, from the +/// folder when relative); with a host it is a network share. +#[test] +fn raster_image_markers_read_a_file_address_as_the_file_it_names() { + use crate::symbology::Picture; + let asked = std::cell::RefCell::new(Vec::new()); + let mut read = |source: &str| { + asked.borrow_mut().push(source.to_string()); + Ok(("QUJD".to_string(), 1.0)) + }; + let cases = [ + ("file:///data/my%20pin.png", "/data/my pin.png"), + ("file:///C:/data/a.png", "C:/data/a.png"), + ("file://C:/data/a.png", "C:/data/a.png"), + ("file:./pins/a.png", "/styles/pins/a.png"), + ]; + for (file, path) in cases { + asked.borrow_mut().clear(); + let mut report = Report::default(); + let s = super::read_style(&marker_qml("1", &raster_marker(file, "")), "Pins", "/styles", &mut read, &mut report).unwrap(); + let Some(Renderer::Single(sym)) = &s.renderer else { panic!("{file}") }; + assert_eq!(sym.marker, Marker::Picture(Picture::new("QUJD")), "{file}"); + assert_eq!(*asked.borrow(), [path], "{file}"); + assert!(report.notes.is_empty(), "{file}: {:?}", report.notes); + } +} + +/// A raster image marker whose image a field or an expression gives has no image of its own to +/// read; the note says that, not that it has none. +#[test] +fn a_raster_image_from_an_expression_is_noted_as_one_not_as_no_image() { + let by_expression = r#" + "#; + let mut read = |_: &str| Ok(("QUJD".to_string(), 1.0)); + let mut report = Report::default(); + let s = super::read_style(&marker_qml("1", by_expression), "Pins", "", &mut read, &mut report).unwrap(); + let Some(Renderer::Single(sym)) = &s.renderer else { panic!() }; + assert_eq!(sym.marker, Marker::Circle); + let notes: Vec<&str> = report.notes.iter().map(|n| n.text.as_str()).collect(); + assert!( + notes.contains( + &"raster image markers whose image comes from a field or an expression, which RustGIS doesn't evaluate, drawn as circles" + ), + "{notes:?}" + ); + assert!(!notes.iter().any(|n| n.contains("no image")), "{notes:?}"); + // With no expression, an empty image is still no image. + let mut report = Report::default(); + super::read_style(&marker_qml("1", &raster_marker("", "")), "Pins", "", &mut read, &mut report).unwrap(); + assert_eq!(report.notes.iter().map(|n| n.text.as_str()).collect::>(), ["raster image markers with no image, drawn as circles"]); +} + #[test] fn raster_image_markers_that_cant_be_drawn_are_circles_saying_why() { // Each kind of image the reader isn't asked for, or can't give, with what the note says. @@ -1498,6 +1552,7 @@ fn raster_image_markers_that_cant_be_drawn_are_circles_saying_why() { ), ("\\\\host\\share\\a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), ("//host/share/a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), + ("file://host/share/a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), ("/data/gone.png", "raster image markers whose image file doesn't open, drawn as circles"), ]; for (file, note) in cases { From 4ffce51a387140671f6d1e020c13119321c803e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 19:29:29 -0500 Subject: [PATCH 02/17] fix(map): an esriPMS height that isn't a number sizes nothing, said once as no size --- crates/map/src/arcgis_style.rs | 9 ++++++--- crates/map/src/qgis/symbol.rs | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index 157b57c092..2f9c983dfe 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -492,7 +492,7 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict // proportion, which a service draws its symbol at. Without a width above 0, its // height stands in as its width, said, since an image that isn't square is then // drawn that wide, not that tall; with neither (a height of 0 is none), RustGIS's - // size does. A height of 0 beside a width is said: ArcGIS draws nothing of it. + // size does. A height of 0 beside a width is said: the width alone draws it. Ok(p) => { let wide = s.get("width").and_then(Value::as_f64).is_some_and(|w| w.is_finite() && w > 0.0); let height = s.get("height").filter(|h| !h.is_null()); @@ -502,7 +502,7 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict notes.add("picture markers of no height, drawn as tall as their image is"); } s.get("width") - } else if height.is_some() && !flat { + } else if height.and_then(Value::as_f64).is_some_and(|h| h > 0.0) { notes.add("picture markers with no width, drawn with their height as their width"); height } else { @@ -803,7 +803,10 @@ mod tests { }; let Renderer::Single(base) = layer(GeometryType::Point).renderer else { panic!("a single symbol") }; // With no width above 0 either, it has no size: RustGIS's. - for (width, height) in [(json!(null), json!(0)), (json!(0), json!(0)), (json!(0), json!(-4))] { + // (A height that isn't a number can't size it either: said once, as no size.) + let cases = + [(json!(null), json!(0)), (json!(0), json!(0)), (json!(0), json!(-4)), (json!(null), json!("18")), (json!(0), json!("abc"))]; + for (width, height) in cases { let (s, text) = styled_pms(width.clone(), height.clone()); assert_eq!(s.size, base.size, "width {width}, height {height}"); assert_eq!(text, "picture markers with no size, drawn at RustGIS's", "width {width}, height {height}"); diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index e6e0f682e2..f77b4ec91e 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -939,6 +939,7 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & // Looking a share up can sign in to the host the file names, which a style or // project chose (as an archive on one isn't opened either). Err("whose image is on a network share, which RustGIS doesn't open") + // (A `file:` address is a web address only as written: `%3A%2F%2F` in a decoded name is a name.) } else if path.contains("://") && (!address || file.contains("://")) { Err("whose image is at a web address, which RustGIS doesn't fetch") } else if super::is_drive_relative(&path) { From e3830dc726cbcc8373823e99e1f64ac58d04e323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 19:41:46 -0500 Subject: [PATCH 03/17] fix(map): an encoded :// in a file address is a name; a negative height isn't no height --- crates/map/src/arcgis_style.rs | 13 ++++++----- crates/map/src/qgis/symbol.rs | 4 ++-- crates/map/src/qgis/tests.rs | 40 ++++++++++++++++++++++++++-------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index 2f9c983dfe..b8c8ca5963 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -496,7 +496,7 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict Ok(p) => { let wide = s.get("width").and_then(Value::as_f64).is_some_and(|w| w.is_finite() && w > 0.0); let height = s.get("height").filter(|h| !h.is_null()); - let flat = height.and_then(Value::as_f64).is_some_and(|h| h <= 0.0); + let flat = height.and_then(Value::as_f64).is_some_and(|h| h == 0.0); let sized_by = if wide { if flat { notes.add("picture markers of no height, drawn as tall as their image is"); @@ -815,10 +815,13 @@ mod tests { let (s, text) = styled_pms(json!(15), json!(0)); assert_eq!(s.size, 15.0); assert_eq!(text, "picture markers of no height, drawn as tall as their image is"); - // A height above 0 says nothing of the kind. - let (s, text) = styled_pms(json!(15), json!(18)); - assert_eq!(s.size, 15.0); - assert!(text.is_empty(), "{text}"); + // A height above 0 says nothing of the kind; nor does one below 0 or not a number, which a width + // makes no use of. + for height in [json!(18), json!(-4), json!("18")] { + let (s, text) = styled_pms(json!(15), height.clone()); + assert_eq!(s.size, 15.0, "height {height}"); + assert!(text.is_empty(), "height {height}: {text}"); + } } #[test] diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index f77b4ec91e..d79231c9e8 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -894,7 +894,7 @@ fn marker(layers: &[(Node, Props)], reference: Option, still: bool, layer: /// Whether image path `file` names a network share (`\\host\share`, `//host/share`), which isn't /// opened: looking one up can sign in to the host, and a project may be opened on Windows, where /// `//` is one (as `paths::is_absolute_local` refuses it on every platform). -pub(super) fn network_share(file: &str) -> bool { +fn network_share(file: &str) -> bool { file.len() > 1 && file.chars().take(2).all(|c| c == '\\' || c == '/') } @@ -940,7 +940,7 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & // project chose (as an archive on one isn't opened either). Err("whose image is on a network share, which RustGIS doesn't open") // (A `file:` address is a web address only as written: `%3A%2F%2F` in a decoded name is a name.) - } else if path.contains("://") && (!address || file.contains("://")) { + } else if path.contains("://") && (!address || file.trim_start_matches("file:").trim_start_matches('/').contains("://")) { Err("whose image is at a web address, which RustGIS doesn't fetch") } else if super::is_drive_relative(&path) { Err("whose image file is relative to a drive's working folder, which no project folder tells") diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index 0e1ab5a403..e59972c50f 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1488,6 +1488,8 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { ("file:///C:/data/a.png", "C:/data/a.png"), ("file://C:/data/a.png", "C:/data/a.png"), ("file:./pins/a.png", "/styles/pins/a.png"), + // `://` encoded in a name is a name, not a web address. + ("file:///data/a%3A%2F%2Fb.png", "/data/a://b.png"), ]; for (file, path) in cases { asked.borrow_mut().clear(); @@ -1504,23 +1506,43 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { /// read; the note says that, not that it has none. #[test] fn a_raster_image_from_an_expression_is_noted_as_one_not_as_no_image() { - let by_expression = r#" + // A raster image marker layer of `file` whose image path is also set by an expression. + let by_expression = |file: &str| { + format!( + r#" "#; + "# + ) + }; + let from = "raster image markers whose image comes from a field or an expression, which RustGIS doesn't evaluate, drawn as circles"; + let generic = "data-defined symbol settings (from fields or expressions)"; let mut read = |_: &str| Ok(("QUJD".to_string(), 1.0)); let mut report = Report::default(); - let s = super::read_style(&marker_qml("1", by_expression), "Pins", "", &mut read, &mut report).unwrap(); + let s = super::read_style(&marker_qml("1", &by_expression("")), "Pins", "", &mut read, &mut report).unwrap(); let Some(Renderer::Single(sym)) = &s.renderer else { panic!() }; assert_eq!(sym.marker, Marker::Circle); let notes: Vec<&str> = report.notes.iter().map(|n| n.text.as_str()).collect(); - assert!( - notes.contains( - &"raster image markers whose image comes from a field or an expression, which RustGIS doesn't evaluate, drawn as circles" - ), - "{notes:?}" - ); + assert!(notes.contains(&from), "{notes:?}"); assert!(!notes.iter().any(|n| n.contains("no image")), "{notes:?}"); + // Along a line, the same. + let line = format!( + r#" + + {}"#, + by_expression("") + ); + let mut report = Report::default(); + super::read_style(&line, "Road", "", &mut read, &mut report).unwrap(); + let notes: Vec<&str> = report.notes.iter().map(|n| n.text.as_str()).collect(); + assert!(notes.contains(&from), "{notes:?}"); + // With an image of its own too, it is drawn, and the expression is said (the generic note). + let mut report = Report::default(); + let s = super::read_style(&marker_qml("1", &by_expression("base64:QUJD")), "Pins", "", &mut read, &mut report).unwrap(); + let Some(Renderer::Single(sym)) = &s.renderer else { panic!() }; + assert!(matches!(sym.marker, Marker::Picture(_)), "{:?}", sym.marker); + let notes: Vec<&str> = report.notes.iter().map(|n| n.text.as_str()).collect(); + assert!(notes.contains(&generic) && !notes.contains(&from), "{notes:?}"); // With no expression, an empty image is still no image. let mut report = Report::default(); super::read_style(&marker_qml("1", &raster_marker("", "")), "Pins", "", &mut read, &mut report).unwrap(); From c5b359b7caa2a9d53f8a66687cccbdc3bc0fc977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 19:50:23 -0500 Subject: [PATCH 04/17] fix(map): a picture marker's circle of no size is RustGIS's, said; a relative file address with :// in it isn't read from the working folder --- crates/map/src/arcgis_style.rs | 19 ++++++++++++++++++- crates/map/src/qgis/symbol.rs | 13 +++++++++++-- crates/map/src/qgis/tests.rs | 8 ++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index b8c8ca5963..7dc1e67d51 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -518,7 +518,12 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict // said once. let points = |k: &str| s.get(k).and_then(Value::as_f64).filter(|v| v.is_finite()).unwrap_or(f64::NEG_INFINITY); let larger = if points("height") > points("width") { s.get("height") } else { s.get("width") }; - let size = size(larger, base.size, notes); + // With a size given and none above 0 (a size of 0 isn't shown), RustGIS's, said. + let none = points("height").max(points("width")) <= 0.0 && points("height").max(points("width")) > f64::NEG_INFINITY; + if none { + notes.add("picture markers with no size, drawn at RustGIS's"); + } + let size = size(if none { None } else { larger }, base.size, notes); Some((Symbol { fill, size, ..base }, None)) } ("esriPFS", GeometryType::Polygon) => { @@ -846,6 +851,18 @@ mod tests { // Its image only at its `url`, which RustGIS doesn't fetch. let url = json!({"type": "esriPMS", "url": "4d1f6b3c", "width": 15, "height": 18}); assert_eq!(circle(url), "picture markers whose image is only at a URL, drawn as circles"); + // With no size above 0 either, the circle is RustGIS's size (not 0, not shown), said. + let (l, notes) = styled( + GeometryType::Point, + json!({"renderer": {"type": "simple", "symbol": {"type": "esriPMS", "imageData": gif, "width": 0, "height": 0}}}), + ); + let Renderer::Single(s) = l.renderer else { panic!("a single symbol") }; + let Renderer::Single(base) = layer(GeometryType::Point).renderer else { panic!("a single symbol") }; + assert_eq!((s.marker, s.size), (Marker::Circle, base.size)); + assert_eq!( + notes.text(), + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; picture markers with no size, drawn at RustGIS's" + ); assert_eq!(Picture::kept(gif), None, "an image that isn't drawn isn't kept"); } diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index d79231c9e8..7db778de5e 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -891,6 +891,12 @@ fn marker(layers: &[(Node, Props)], reference: Option, still: bool, layer: Converted { symbol, strokes, rotation: None, by: SymbolBy::default(), fills: Vec::new() } } +/// Whether `path` starts from a root (`/…`, `\\…`, `C:\…`), not from the project's folder. +fn rooted(path: &str) -> bool { + let b = path.as_bytes(); + path.starts_with(['/', '\\']) || (b.first().is_some_and(u8::is_ascii_alphabetic) && b.get(1) == Some(&b':')) +} + /// Whether image path `file` names a network share (`\\host\share`, `//host/share`), which isn't /// opened: looking one up can sign in to the host, and a project may be opened on Windows, where /// `//` is one (as `paths::is_absolute_local` refuses it on every platform). @@ -939,8 +945,11 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & // Looking a share up can sign in to the host the file names, which a style or // project chose (as an archive on one isn't opened either). Err("whose image is on a network share, which RustGIS doesn't open") - // (A `file:` address is a web address only as written: `%3A%2F%2F` in a decoded name is a name.) - } else if path.contains("://") && (!address || file.trim_start_matches("file:").trim_start_matches('/').contains("://")) { + // (A `file:` address is a web address only as written: `%3A%2F%2F` in a decoded name is a name, but one + // from the project's folder is refused, as `absolute` would leave it to the working folder.) + } else if path.contains("://") + && (!address || !rooted(&path) || file.trim_start_matches("file:").trim_start_matches('/').contains("://")) + { Err("whose image is at a web address, which RustGIS doesn't fetch") } else if super::is_drive_relative(&path) { Err("whose image file is relative to a drive's working folder, which no project folder tells") diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index e59972c50f..d5eb2a5d89 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1500,6 +1500,14 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { assert_eq!(*asked.borrow(), [path], "{file}"); assert!(report.notes.is_empty(), "{file}: {:?}", report.notes); } + // A relative name with `://` encoded in it isn't read from wherever the program runs, though. + asked.borrow_mut().clear(); + let mut report = Report::default(); + let s = super::read_style(&marker_qml("1", &raster_marker("file:./a%3A%2F%2Fb.png", "")), "Pins", "/styles", &mut read, &mut report) + .unwrap(); + let Some(Renderer::Single(sym)) = &s.renderer else { panic!() }; + assert_eq!(sym.marker, Marker::Circle); + assert!(asked.borrow().is_empty(), "{:?}", asked.borrow()); } /// A raster image marker whose image a field or an expression gives has no image of its own to From 492664db4cbdf6515602028ba30fa5a2090445bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 20:01:18 -0500 Subject: [PATCH 05/17] fix(map): an esriPMS height that isn't a number isn't lost silently in the circle of an image that doesn't draw --- crates/map/src/arcgis_style.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index 7dc1e67d51..9544bbf7b9 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -517,9 +517,15 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict // As a circle, the larger of its width and height, so that one past the largest is // said once. let points = |k: &str| s.get(k).and_then(Value::as_f64).filter(|v| v.is_finite()).unwrap_or(f64::NEG_INFINITY); - let larger = if points("height") > points("width") { s.get("height") } else { s.get("width") }; + // (A width that is none lets the height speak: size() says one it can't read.) + let larger = if points("height") > points("width") || s.get("width").is_none_or(Value::is_null) { + s.get("height") + } else { + s.get("width") + }; // With a size given and none above 0 (a size of 0 isn't shown), RustGIS's, said. - let none = points("height").max(points("width")) <= 0.0 && points("height").max(points("width")) > f64::NEG_INFINITY; + let top = points("height").max(points("width")); + let none = top.is_finite() && top <= 0.0; if none { notes.add("picture markers with no size, drawn at RustGIS's"); } @@ -851,6 +857,18 @@ mod tests { // Its image only at its `url`, which RustGIS doesn't fetch. let url = json!({"type": "esriPMS", "url": "4d1f6b3c", "width": 15, "height": 18}); assert_eq!(circle(url), "picture markers whose image is only at a URL, drawn as circles"); + // A height that isn't a number, with no width, isn't lost silently: size() says it can't read it. + let (l, notes) = styled( + GeometryType::Point, + json!({"renderer": {"type": "simple", "symbol": {"type": "esriPMS", "imageData": gif, "width": null, "height": "18"}}}), + ); + let Renderer::Single(s) = l.renderer else { panic!("a single symbol") }; + let Renderer::Single(base) = layer(GeometryType::Point).renderer else { panic!("a single symbol") }; + assert_eq!(s.size, base.size); + assert_eq!( + notes.text(), + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, drawn at RustGIS's" + ); // With no size above 0 either, the circle is RustGIS's size (not 0, not shown), said. let (l, notes) = styled( GeometryType::Point, From 077baa8fbced24b05b1a68aacac8384208f54f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 20:10:38 -0500 Subject: [PATCH 06/17] fix(map): a relative file name with an encoded :// is refused for its own reason --- crates/map/src/qgis/symbol.rs | 10 +++++----- crates/map/src/qgis/tests.rs | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index 7db778de5e..ddf5cee5de 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -945,11 +945,11 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & // Looking a share up can sign in to the host the file names, which a style or // project chose (as an archive on one isn't opened either). Err("whose image is on a network share, which RustGIS doesn't open") - // (A `file:` address is a web address only as written: `%3A%2F%2F` in a decoded name is a name, but one - // from the project's folder is refused, as `absolute` would leave it to the working folder.) - } else if path.contains("://") - && (!address || !rooted(&path) || file.trim_start_matches("file:").trim_start_matches('/').contains("://")) - { + } else if address && !rooted(&path) && path.contains("://") { + // `%3A%2F%2F` in a name is a name, but `absolute` would leave one from the project's folder to + // the working folder. + Err("whose image is a relative file name with `://` in it, which RustGIS doesn't read") + } else if path.contains("://") && (!address || file.trim_start_matches("file:").trim_start_matches('/').contains("://")) { Err("whose image is at a web address, which RustGIS doesn't fetch") } else if super::is_drive_relative(&path) { Err("whose image file is relative to a drive's working folder, which no project folder tells") diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index d5eb2a5d89..01984dea40 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1508,6 +1508,10 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { let Some(Renderer::Single(sym)) = &s.renderer else { panic!() }; assert_eq!(sym.marker, Marker::Circle); assert!(asked.borrow().is_empty(), "{:?}", asked.borrow()); + assert_eq!( + report.notes.iter().map(|n| n.text.as_str()).collect::>(), + ["raster image markers whose image is a relative file name with `://` in it, which RustGIS doesn't read, drawn as circles"] + ); } /// A raster image marker whose image a field or an expression gives has no image of its own to From 3932592f42c2b51ca934460c84649b1177d1495b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 20:38:56 -0500 Subject: [PATCH 07/17] fix(map): a file address is trimmed once decoded, before it is checked for a network share --- crates/map/src/qgis/source.rs | 3 ++- crates/map/src/qgis/tests.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/map/src/qgis/source.rs b/crates/map/src/qgis/source.rs index 2c049e2bea..b1c5a271b9 100644 --- a/crates/map/src/qgis/source.rs +++ b/crates/map/src/qgis/source.rs @@ -598,7 +598,8 @@ fn file_url_path(url: &str) -> Option<&str> { /// A `file:` address's path (see [`file_url_path`]) decoded as any address's parts are; `None` for any /// other address and for one with a host. pub(super) fn file_address_path(url: &str) -> Option { - file_url_path(url).map(rustgis_data::address::percent_decode) + // Trimmed: what `absolute` trims after the checks must not decide them (`%20%2F%2Fhost` is `//host`). + file_url_path(url).map(|path| rustgis_data::address::percent_decode(path).trim().to_string()) } /// A tile archive's path: a `file://` address (`file:../x` when relative) as its path, a relative diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index 01984dea40..d4e06b15bc 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1587,6 +1587,15 @@ fn raster_image_markers_that_cant_be_drawn_are_circles_saying_why() { ("\\\\host\\share\\a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), ("//host/share/a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), ("file://host/share/a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), + // A share written so that decoding leaves a space before it, which `absolute` would trim. + ( + "file:%20%2F%2Fhost/share/a.png", + "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles", + ), + ( + "file:%09%5C%5Chost%5Cshare%5Ca.png", + "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles", + ), ("/data/gone.png", "raster image markers whose image file doesn't open, drawn as circles"), ]; for (file, note) in cases { From 3adf936cea2aa6229dfcdcaf3b4d973e1399cbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 21:00:48 -0500 Subject: [PATCH 08/17] fix(map): the circle of an image that doesn't draw says each size it can't read; an encoded drive colon in a file address is a drive --- crates/map/src/arcgis_style.rs | 48 +++++++++++++++++++++++++++------- crates/map/src/qgis/source.rs | 6 ++++- crates/map/src/qgis/tests.rs | 2 ++ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index 9544bbf7b9..8abf5afbc3 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -515,21 +515,24 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict Err(why) => notes.add(why), } // As a circle, the larger of its width and height, so that one past the largest is - // said once. - let points = |k: &str| s.get(k).and_then(Value::as_f64).filter(|v| v.is_finite()).unwrap_or(f64::NEG_INFINITY); - // (A width that is none lets the height speak: size() says one it can't read.) - let larger = if points("height") > points("width") || s.get("width").is_none_or(Value::is_null) { - s.get("height") - } else { - s.get("width") + // said once; each side that isn't a number is said, as `size()` says one it can't read. + let num = |k: &str| s.get(k).and_then(Value::as_f64).filter(|v| v.is_finite()); + for k in ["width", "height"] { + if s.get(k).is_some_and(|v| !v.is_null()) && num(k).is_none() { + notes.add("marker sizes RustGIS can't read, drawn at RustGIS's"); + } + } + let top = match (num("height"), num("width")) { + (Some(h), Some(w)) => Some(h.max(w)), + (h, w) => h.or(w), }; + let larger = if num("height") > num("width") { s.get("height") } else { s.get("width") }; // With a size given and none above 0 (a size of 0 isn't shown), RustGIS's, said. - let top = points("height").max(points("width")); - let none = top.is_finite() && top <= 0.0; + let none = top.is_some_and(|t| t <= 0.0); if none { notes.add("picture markers with no size, drawn at RustGIS's"); } - let size = size(if none { None } else { larger }, base.size, notes); + let size = size(if none || top.is_none() { None } else { larger }, base.size, notes); Some((Symbol { fill, size, ..base }, None)) } ("esriPFS", GeometryType::Polygon) => { @@ -869,6 +872,31 @@ mod tests { notes.text(), "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, drawn at RustGIS's" ); + // Each side that isn't a number is said, whichever one the circle takes its size from. + for (width, height, size, text) in [ + ( + json!("abc"), + json!(18), + 18.0, + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, drawn at RustGIS's", + ), + ( + json!(0), + json!("abc"), + 0.0, + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, drawn at RustGIS's; picture markers with no size, drawn at RustGIS's", + ), + ] { + let (l, notes) = styled( + GeometryType::Point, + json!({"renderer": {"type": "simple", "symbol": {"type": "esriPMS", "imageData": gif, "width": width, "height": height}}}), + ); + let Renderer::Single(s) = l.renderer else { panic!("a single symbol") }; + let Renderer::Single(base) = layer(GeometryType::Point).renderer else { panic!("a single symbol") }; + let expected = if size == 0.0 { base.size } else { size }; + assert_eq!(s.size, expected, "width {width}, height {height}"); + assert_eq!(notes.text(), text, "width {width}, height {height}"); + } // With no size above 0 either, the circle is RustGIS's size (not 0, not shown), said. let (l, notes) = styled( GeometryType::Point, diff --git a/crates/map/src/qgis/source.rs b/crates/map/src/qgis/source.rs index b1c5a271b9..4fc25a0ec4 100644 --- a/crates/map/src/qgis/source.rs +++ b/crates/map/src/qgis/source.rs @@ -599,7 +599,11 @@ fn file_url_path(url: &str) -> Option<&str> { /// other address and for one with a host. pub(super) fn file_address_path(url: &str) -> Option { // Trimmed: what `absolute` trims after the checks must not decide them (`%20%2F%2Fhost` is `//host`). - file_url_path(url).map(|path| rustgis_data::address::percent_decode(path).trim().to_string()) + let path = rustgis_data::address::percent_decode(file_url_path(url)?).trim().to_string(); + // A drive's colon may be encoded (`/C%3A/x`): the drive form is recognized once decoded. + let b = path.as_bytes(); + let drive = b.first() == Some(&b'/') && b.get(1).is_some_and(u8::is_ascii_alphabetic) && b.get(2) == Some(&b':'); + Some(if drive { path[1..].to_string() } else { path }) } /// A tile archive's path: a `file://` address (`file:../x` when relative) as its path, a relative diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index d4e06b15bc..542eb32e64 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1486,6 +1486,8 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { let cases = [ ("file:///data/my%20pin.png", "/data/my pin.png"), ("file:///C:/data/a.png", "C:/data/a.png"), + // A drive's colon may be encoded. + ("file:///C%3A/data/a.png", "C:/data/a.png"), ("file://C:/data/a.png", "C:/data/a.png"), ("file:./pins/a.png", "/styles/pins/a.png"), // `://` encoded in a name is a name, not a web address. From 7ca9058b48f80494505e3676c7278674f9343879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 21:17:17 -0500 Subject: [PATCH 09/17] fix(map): a tile archive with an encoded drive colon is pinned to its drive; the drive's path is read with get (#2986) --- crates/map/src/qgis/source.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/map/src/qgis/source.rs b/crates/map/src/qgis/source.rs index 4fc25a0ec4..8a333f1f60 100644 --- a/crates/map/src/qgis/source.rs +++ b/crates/map/src/qgis/source.rs @@ -603,7 +603,7 @@ pub(super) fn file_address_path(url: &str) -> Option { // A drive's colon may be encoded (`/C%3A/x`): the drive form is recognized once decoded. let b = path.as_bytes(); let drive = b.first() == Some(&b'/') && b.get(1).is_some_and(u8::is_ascii_alphabetic) && b.get(2) == Some(&b':'); - Some(if drive { path[1..].to_string() } else { path }) + Some(if drive { path.get(1..).unwrap_or_default().to_string() } else { path }) } /// A tile archive's path: a `file://` address (`file:../x` when relative) as its path, a relative @@ -1828,4 +1828,17 @@ mod tests { assert_eq!(filtered("").as_deref(), Some(r#""kind" = 'a'"#)); assert!(matches!(unnamed("pts"), Some(VirtualFrom::Missing(_)))); } + + /// A tile archive at a `file:` address whose drive's colon is encoded is on that drive, as a + /// picture marker's image is (`file:///C%3A/…` is `C:/…`, not `/C:/…`). + #[test] + fn a_tile_archive_with_an_encoded_drive_colon_is_on_that_drive() { + for (url, path) in [ + ("file:///C%3A/maps/t.mbtiles", "C:/maps/t.mbtiles"), + ("file:///C:/maps/t.mbtiles", "C:/maps/t.mbtiles"), + ("file:///maps/t.mbtiles", "/maps/t.mbtiles"), + ] { + assert_eq!(archive_path(url, "/p"), path, "{url}"); + } + } } From 5aed04127375ae9af77f1b09f8365fde26c7c4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 21:43:59 -0500 Subject: [PATCH 10/17] fix(map): a delimitedtext address with an encoded drive colon is on that drive (#2986) --- crates/map/src/qgis/source.rs | 8 ++++++-- crates/map/src/qgis/symbol.rs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/map/src/qgis/source.rs b/crates/map/src/qgis/source.rs index 8a333f1f60..6677db955a 100644 --- a/crates/map/src/qgis/source.rs +++ b/crates/map/src/qgis/source.rs @@ -898,11 +898,12 @@ fn select_all(query: &str) -> Option<(String, Option)> { fn csv(datasource: &str, dir: &str) -> Source { let (path, q) = datasource.split_once('?').unwrap_or((datasource, "")); // file:///absolute/path, or a relative one as file:./path. - let path = file_url_path(path).unwrap_or(path); + // A `file:` address is its path decoded, a drive's colon encoded or not; anything else is decoded as it is. + let path = file_address_path(path).unwrap_or_else(|| rustgis_data::address::percent_decode(path)); let q = query(q); let get = |k: &str| q.iter().find(|(n, _)| n == k).map(|(_, v)| v.clone()).filter(|v| !v.is_empty()); Source::Csv { - path: absolute(&rustgis_data::address::percent_decode(path), dir), + path: absolute(&path, dir), x: get("xField"), y: get("yField"), wkt: get("wktField"), @@ -1397,6 +1398,9 @@ mod tests { ); let Source::Csv { path, .. } = read("delimitedtext", "file:///C:/maps/p.csv?xField=x", dir) else { panic!() }; assert_eq!(path, "C:/maps/p.csv"); + // A drive's colon may be encoded, as an image's and an archive's is. + let Source::Csv { path, .. } = read("delimitedtext", "file:///C%3A/maps/p.csv?xField=x", dir) else { panic!() }; + assert_eq!(path, "C:/maps/p.csv"); // An encoded file address is decoded once (QGIS encodes the address again as a parameter). assert_eq!( read("mbtilesvectortiles", "type=mbtiles&url=file:///maps/my%2520tiles.mbtiles", dir), diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index ddf5cee5de..42a7f59a7c 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -891,7 +891,8 @@ fn marker(layers: &[(Node, Props)], reference: Option, still: bool, layer: Converted { symbol, strokes, rotation: None, by: SymbolBy::default(), fills: Vec::new() } } -/// Whether `path` starts from a root (`/…`, `\\…`, `C:\…`), not from the project's folder. +/// Whether `path` starts from a root (`/…`, `\\…`) or names a drive (`C:\…`, or `C:x`, as `is_relative` counts +/// it), not from the project's folder. fn rooted(path: &str) -> bool { let b = path.as_bytes(); path.starts_with(['/', '\\']) || (b.first().is_some_and(u8::is_ascii_alphabetic) && b.get(1) == Some(&b':')) From 86717b805188201b7bc4467b74ea1804126be130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 22:08:55 -0500 Subject: [PATCH 11/17] fix(map): a picture marker that draws says a width or height it can't read, as its circle does (#2986) --- crates/map/src/arcgis_style.rs | 44 +++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index 8abf5afbc3..781c6288f3 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -494,6 +494,8 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict // drawn that wide, not that tall; with neither (a height of 0 is none), RustGIS's // size does. A height of 0 beside a width is said: the width alone draws it. Ok(p) => { + // A side that isn't a number is said as the circle says it, whether this uses it or not. + say_unreadable_sizes(s, notes); let wide = s.get("width").and_then(Value::as_f64).is_some_and(|w| w.is_finite() && w > 0.0); let height = s.get("height").filter(|h| !h.is_null()); let flat = height.and_then(Value::as_f64).is_some_and(|h| h == 0.0); @@ -517,11 +519,7 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict // As a circle, the larger of its width and height, so that one past the largest is // said once; each side that isn't a number is said, as `size()` says one it can't read. let num = |k: &str| s.get(k).and_then(Value::as_f64).filter(|v| v.is_finite()); - for k in ["width", "height"] { - if s.get(k).is_some_and(|v| !v.is_null()) && num(k).is_none() { - notes.add("marker sizes RustGIS can't read, drawn at RustGIS's"); - } - } + say_unreadable_sizes(s, notes); let top = match (num("height"), num("width")) { (Some(h), Some(w)) => Some(h.max(w)), (h, w) => h.or(w), @@ -643,6 +641,14 @@ fn size(v: Option<&Value>, default: f32, notes: &mut Notes) -> f32 { }) } +/// Says a picture marker's `width` or `height` that is given but isn't a number, once for either or both. +fn say_unreadable_sizes(s: &Value, notes: &mut Notes) { + let unreadable = |k: &str| s.get(k).is_some_and(|v| !v.is_null()) && !s.get(k).and_then(Value::as_f64).is_some_and(f64::is_finite); + if unreadable("width") || unreadable("height") { + notes.add("marker sizes RustGIS can't read, drawn at RustGIS's"); + } +} + /// A symbol's style (`style`), `None` when it names none; one that isn't text is noted and taken as /// none (ArcGIS's default style). fn style<'a>(s: &'a Value, notes: &mut Notes) -> Option<&'a str> { @@ -817,21 +823,37 @@ mod tests { }; let Renderer::Single(base) = layer(GeometryType::Point).renderer else { panic!("a single symbol") }; // With no width above 0 either, it has no size: RustGIS's. - // (A height that isn't a number can't size it either: said once, as no size.) - let cases = - [(json!(null), json!(0)), (json!(0), json!(0)), (json!(0), json!(-4)), (json!(null), json!("18")), (json!(0), json!("abc"))]; + let cases = [(json!(null), json!(0)), (json!(0), json!(0)), (json!(0), json!(-4))]; for (width, height) in cases { let (s, text) = styled_pms(width.clone(), height.clone()); assert_eq!(s.size, base.size, "width {width}, height {height}"); assert_eq!(text, "picture markers with no size, drawn at RustGIS's", "width {width}, height {height}"); } + // A side that isn't a number can't size it either, and is said, as the circle says it. + for (width, height) in [(json!(null), json!("18")), (json!(0), json!("abc"))] { + let (s, text) = styled_pms(width.clone(), height.clone()); + assert_eq!(s.size, base.size, "width {width}, height {height}"); + assert_eq!( + text, "marker sizes RustGIS can't read, drawn at RustGIS's; picture markers with no size, drawn at RustGIS's", + "width {width}, height {height}" + ); + } + // So is one a width makes no use of, and a width that isn't a number beside a height that is. + let (s, text) = styled_pms(json!(15), json!("abc")); + assert_eq!(s.size, 15.0); + assert_eq!(text, "marker sizes RustGIS can't read, drawn at RustGIS's"); + let (s, text) = styled_pms(json!("abc"), json!(18)); + assert_eq!(s.size, 18.0); + assert_eq!( + text, + "marker sizes RustGIS can't read, drawn at RustGIS's; picture markers with no width, drawn with their height as their width" + ); // With a width, it is drawn by it, and the height's 0 said. let (s, text) = styled_pms(json!(15), json!(0)); assert_eq!(s.size, 15.0); assert_eq!(text, "picture markers of no height, drawn as tall as their image is"); - // A height above 0 says nothing of the kind; nor does one below 0 or not a number, which a width - // makes no use of. - for height in [json!(18), json!(-4), json!("18")] { + // A height above 0 says nothing of the kind; nor does one below 0, which a width makes no use of. + for height in [json!(18), json!(-4)] { let (s, text) = styled_pms(json!(15), height.clone()); assert_eq!(s.size, 15.0, "height {height}"); assert!(text.is_empty(), "height {height}: {text}"); From 63b8947fe386a350d2c13510830efd76bac8c64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 22:23:33 -0500 Subject: [PATCH 12/17] style(map): format the csv source's struct literal (#2986) --- crates/map/src/qgis/source.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/map/src/qgis/source.rs b/crates/map/src/qgis/source.rs index 6677db955a..03e7ce4d57 100644 --- a/crates/map/src/qgis/source.rs +++ b/crates/map/src/qgis/source.rs @@ -902,13 +902,7 @@ fn csv(datasource: &str, dir: &str) -> Source { let path = file_address_path(path).unwrap_or_else(|| rustgis_data::address::percent_decode(path)); let q = query(q); let get = |k: &str| q.iter().find(|(n, _)| n == k).map(|(_, v)| v.clone()).filter(|v| !v.is_empty()); - Source::Csv { - path: absolute(&path, dir), - x: get("xField"), - y: get("yField"), - wkt: get("wktField"), - crs: get("crs"), - } + Source::Csv { path: absolute(&path, dir), x: get("xField"), y: get("yField"), wkt: get("wktField"), crs: get("crs") } } /// The most `&`-joined parts of a web source, or of an address's query, read; the rest are From c348df508e8b7bb08eba991b8f05e34c51d17b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 22:40:35 -0500 Subject: [PATCH 13/17] fix(map): an image address that joins a root project folder into a network share is refused as one (#2986) --- crates/map/src/qgis/symbol.rs | 9 ++++++++- crates/map/src/qgis/tests.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index 42a7f59a7c..93313f154a 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -957,7 +957,14 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & } else if super::is_relative(&path) && dir.is_empty() { Err("whose image file is relative to a folder the import wasn't given") } else { - Ok(Some(super::source::absolute(&path, dir))) + let joined = super::source::absolute(&path, dir); + // `.//host/share` from a project at a drive's root (`/`) is `//host/share` once joined; a project + // that is itself on a share reads its own images. + if network_share(&joined) && !network_share(dir) { + Err("whose image is on a network share, which RustGIS doesn't open") + } else { + Ok(Some(joined)) + } }; if let Ok(Some(path)) = &source && let Some(got) = files.get(path) diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index 542eb32e64..1db0b1e25f 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1514,6 +1514,32 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { report.notes.iter().map(|n| n.text.as_str()).collect::>(), ["raster image markers whose image is a relative file name with `://` in it, which RustGIS doesn't read, drawn as circles"] ); + // A relative name that starts with a separator isn't joined to a project at a drive's root into a share + // (`.//host/share` from `/` is `//host/share`), though a project that is itself on a share reads its own. + for (file, dir, shared) in [ + ("file:.//host/share/a.png", "/", true), + ("file:.//host/share/a.png", "\\", true), + (".//host/share/a.png", "/", true), + ("file:./a.png", "/", false), + ("file:./a.png", "//server/proj", false), + ] { + asked.borrow_mut().clear(); + let mut report = Report::default(); + let s = super::read_style(&marker_qml("1", &raster_marker(file, "")), "Pins", dir, &mut read, &mut report).unwrap(); + let Some(Renderer::Single(sym)) = &s.renderer else { panic!("{file}") }; + if shared { + assert_eq!(sym.marker, Marker::Circle, "{file} from {dir}"); + assert!(asked.borrow().is_empty(), "{file} from {dir}: {:?}", asked.borrow()); + assert_eq!( + report.notes.iter().map(|n| n.text.as_str()).collect::>(), + ["raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"], + "{file} from {dir}" + ); + } else { + assert_eq!(sym.marker, Marker::Picture(crate::symbology::Picture::new("QUJD")), "{file} from {dir}"); + assert_eq!(asked.borrow().len(), 1, "{file} from {dir}"); + } + } } /// A raster image marker whose image a field or an expression gives has no image of its own to From 5aaf6047b1f209310c4bbd091e0641b06c7a8a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 22:49:01 -0500 Subject: [PATCH 14/17] fix(map): unreadable marker sizes are said as left out, a negative height as none, a web address after file: as one, and the guide names the new reasons (#2986) --- crates/map/src/arcgis_style.rs | 24 ++++++++++++++---------- crates/map/src/qgis/symbol.rs | 4 ++-- crates/map/src/qgis/tests.rs | 9 +++++++++ docs/user-guide/workspace.md | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index 781c6288f3..9745da18cd 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -498,7 +498,7 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict say_unreadable_sizes(s, notes); let wide = s.get("width").and_then(Value::as_f64).is_some_and(|w| w.is_finite() && w > 0.0); let height = s.get("height").filter(|h| !h.is_null()); - let flat = height.and_then(Value::as_f64).is_some_and(|h| h == 0.0); + let flat = height.and_then(Value::as_f64).is_some_and(|h| h <= 0.0); let sized_by = if wide { if flat { notes.add("picture markers of no height, drawn as tall as their image is"); @@ -645,7 +645,7 @@ fn size(v: Option<&Value>, default: f32, notes: &mut Notes) -> f32 { fn say_unreadable_sizes(s: &Value, notes: &mut Notes) { let unreadable = |k: &str| s.get(k).is_some_and(|v| !v.is_null()) && !s.get(k).and_then(Value::as_f64).is_some_and(f64::is_finite); if unreadable("width") || unreadable("height") { - notes.add("marker sizes RustGIS can't read, drawn at RustGIS's"); + notes.add("marker sizes RustGIS can't read, left out"); } } @@ -834,26 +834,30 @@ mod tests { let (s, text) = styled_pms(width.clone(), height.clone()); assert_eq!(s.size, base.size, "width {width}, height {height}"); assert_eq!( - text, "marker sizes RustGIS can't read, drawn at RustGIS's; picture markers with no size, drawn at RustGIS's", + text, "marker sizes RustGIS can't read, left out; picture markers with no size, drawn at RustGIS's", "width {width}, height {height}" ); } // So is one a width makes no use of, and a width that isn't a number beside a height that is. let (s, text) = styled_pms(json!(15), json!("abc")); assert_eq!(s.size, 15.0); - assert_eq!(text, "marker sizes RustGIS can't read, drawn at RustGIS's"); + assert_eq!(text, "marker sizes RustGIS can't read, left out"); let (s, text) = styled_pms(json!("abc"), json!(18)); assert_eq!(s.size, 18.0); assert_eq!( text, - "marker sizes RustGIS can't read, drawn at RustGIS's; picture markers with no width, drawn with their height as their width" + "marker sizes RustGIS can't read, left out; picture markers with no width, drawn with their height as their width" ); // With a width, it is drawn by it, and the height's 0 said. let (s, text) = styled_pms(json!(15), json!(0)); assert_eq!(s.size, 15.0); assert_eq!(text, "picture markers of no height, drawn as tall as their image is"); - // A height above 0 says nothing of the kind; nor does one below 0, which a width makes no use of. - for height in [json!(18), json!(-4)] { + // A height below 0 is no height either: the width alone draws it, and the height is said. + let (s, text) = styled_pms(json!(15), json!(-4)); + assert_eq!(s.size, 15.0); + assert_eq!(text, "picture markers of no height, drawn as tall as their image is"); + // A height above 0 says nothing of the kind. + for height in [json!(18)] { let (s, text) = styled_pms(json!(15), height.clone()); assert_eq!(s.size, 15.0, "height {height}"); assert!(text.is_empty(), "height {height}: {text}"); @@ -892,7 +896,7 @@ mod tests { assert_eq!(s.size, base.size); assert_eq!( notes.text(), - "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, drawn at RustGIS's" + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out" ); // Each side that isn't a number is said, whichever one the circle takes its size from. for (width, height, size, text) in [ @@ -900,13 +904,13 @@ mod tests { json!("abc"), json!(18), 18.0, - "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, drawn at RustGIS's", + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out", ), ( json!(0), json!("abc"), 0.0, - "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, drawn at RustGIS's; picture markers with no size, drawn at RustGIS's", + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out; picture markers with no size, drawn at RustGIS's", ), ] { let (l, notes) = styled( diff --git a/crates/map/src/qgis/symbol.rs b/crates/map/src/qgis/symbol.rs index 93313f154a..6746d73436 100644 --- a/crates/map/src/qgis/symbol.rs +++ b/crates/map/src/qgis/symbol.rs @@ -942,6 +942,8 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & Ok(None) } else if file.starts_with("attachment:") { Err("whose image is kept inside the .qgz project, which RustGIS doesn't read it from") + } else if path.contains("://") && (!address || file.trim_start_matches("file:").trim_start_matches('/').contains("://")) { + Err("whose image is at a web address, which RustGIS doesn't fetch") } else if share || network_share(&path) { // Looking a share up can sign in to the host the file names, which a style or // project chose (as an archive on one isn't opened either). @@ -950,8 +952,6 @@ pub(super) fn read_images(root: Node, dir: &str, read: &mut ReadImage, report: & // `%3A%2F%2F` in a name is a name, but `absolute` would leave one from the project's folder to // the working folder. Err("whose image is a relative file name with `://` in it, which RustGIS doesn't read") - } else if path.contains("://") && (!address || file.trim_start_matches("file:").trim_start_matches('/').contains("://")) { - Err("whose image is at a web address, which RustGIS doesn't fetch") } else if super::is_drive_relative(&path) { Err("whose image file is relative to a drive's working folder, which no project folder tells") } else if super::is_relative(&path) && dir.is_empty() { diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index 1db0b1e25f..e2efdc7b71 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1614,6 +1614,15 @@ fn raster_image_markers_that_cant_be_drawn_are_circles_saying_why() { ), ("\\\\host\\share\\a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), ("//host/share/a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), + // A web address written after `file:` is still one, whatever else its form looks like. + ( + "file://https://example.invalid/a.png", + "raster image markers whose image is at a web address, which RustGIS doesn't fetch, drawn as circles", + ), + ( + "file:https://example.invalid/a.png", + "raster image markers whose image is at a web address, which RustGIS doesn't fetch, drawn as circles", + ), ("file://host/share/a.png", "raster image markers whose image is on a network share, which RustGIS doesn't open, drawn as circles"), // A share written so that decoding leaves a space before it, which `absolute` would trim. ( diff --git a/docs/user-guide/workspace.md b/docs/user-guide/workspace.md index d28e820c46..de2a7ac6fa 100644 --- a/docs/user-guide/workspace.md +++ b/docs/user-guide/workspace.md @@ -432,7 +432,7 @@ holding `NULL`, which QGIS takes as unknown and RustGIS skips. What RustGIS does near as it can, or left out, and said: the import's notes list, layer by layer, what was approximated (vector tile styles, text matched ignoring letter case, a memory layer's fields of kinds RustGIS hasn't as text, gradient and shapeburst fills' offsets left out and colour ramps other than gradients drawn from their first colour to their last, SVG, raster and random fills and dense brushes as a tint of their colour, SVG markers as circles, raster image markers whose image RustGIS can't use as circles (one at a web address, which it -doesn't fetch, or kept inside a `.qgz`; a file that doesn't open or isn't a PNG, JPEG or SVG; one past +doesn't fetch, on a network share (`\\host\share`, `file://host/share`), a relative name with `://` in it, or kept inside a `.qgz`; one a field or an expression gives, which RustGIS doesn't evaluate; a file that doesn't open or isn't a PNG, JPEG or SVG; one past 2 MiB of base64, 2048 × 2048 pixels or as much to draw, an SVG with filters, text, images, animation or links to other files, the images it keeps or the pixels or memory of marker images it decodes until it restarts), those of a fixed aspect ratio in their image's own, see-through ones opaque and those anchored off their centre along lines centred, From 2f0662fa5776afaf7f09b5722e20b44f4c3bcfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 23:02:31 -0500 Subject: [PATCH 15/17] test(map): a plain assertion for a single height, a clearer name in the share test (#2986) --- crates/map/src/arcgis_style.rs | 8 +++----- crates/map/src/qgis/tests.rs | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index 9745da18cd..f64c11a434 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -857,11 +857,9 @@ mod tests { assert_eq!(s.size, 15.0); assert_eq!(text, "picture markers of no height, drawn as tall as their image is"); // A height above 0 says nothing of the kind. - for height in [json!(18)] { - let (s, text) = styled_pms(json!(15), height.clone()); - assert_eq!(s.size, 15.0, "height {height}"); - assert!(text.is_empty(), "height {height}: {text}"); - } + let (s, text) = styled_pms(json!(15), json!(18)); + assert_eq!(s.size, 15.0); + assert!(text.is_empty(), "{text}"); } #[test] diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index e2efdc7b71..194faafe4e 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -1516,7 +1516,7 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { ); // A relative name that starts with a separator isn't joined to a project at a drive's root into a share // (`.//host/share` from `/` is `//host/share`), though a project that is itself on a share reads its own. - for (file, dir, shared) in [ + for (file, dir, refused) in [ ("file:.//host/share/a.png", "/", true), ("file:.//host/share/a.png", "\\", true), (".//host/share/a.png", "/", true), @@ -1527,7 +1527,7 @@ fn raster_image_markers_read_a_file_address_as_the_file_it_names() { let mut report = Report::default(); let s = super::read_style(&marker_qml("1", &raster_marker(file, "")), "Pins", dir, &mut read, &mut report).unwrap(); let Some(Renderer::Single(sym)) = &s.renderer else { panic!("{file}") }; - if shared { + if refused { assert_eq!(sym.marker, Marker::Circle, "{file} from {dir}"); assert!(asked.borrow().is_empty(), "{file} from {dir}: {:?}", asked.borrow()); assert_eq!( From 9a564c8f6a910f44ea933e7c1af79544e1a2bcc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 23:18:16 -0500 Subject: [PATCH 16/17] fix(map): the circle of an image that doesn't draw says it has no size when it has no readable one, as the drawn picture does (#2986) --- crates/map/src/arcgis_style.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index f64c11a434..ba3a0190f8 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -525,12 +525,12 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict (h, w) => h.or(w), }; let larger = if num("height") > num("width") { s.get("height") } else { s.get("width") }; - // With a size given and none above 0 (a size of 0 isn't shown), RustGIS's, said. - let none = top.is_some_and(|t| t <= 0.0); + // With no size above 0 (a size of 0 isn't shown), or none given, RustGIS's, said as the drawn one is. + let none = top.is_none_or(|t| t <= 0.0); if none { notes.add("picture markers with no size, drawn at RustGIS's"); } - let size = size(if none || top.is_none() { None } else { larger }, base.size, notes); + let size = size(if none { None } else { larger }, base.size, notes); Some((Symbol { fill, size, ..base }, None)) } ("esriPFS", GeometryType::Polygon) => { @@ -894,7 +894,7 @@ mod tests { assert_eq!(s.size, base.size); assert_eq!( notes.text(), - "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out" + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out; picture markers with no size, drawn at RustGIS's" ); // Each side that isn't a number is said, whichever one the circle takes its size from. for (width, height, size, text) in [ @@ -910,6 +910,19 @@ mod tests { 0.0, "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out; picture markers with no size, drawn at RustGIS's", ), + // With neither side given at all, it has no size, as the drawn picture has none. + ( + json!(null), + json!(null), + 0.0, + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; picture markers with no size, drawn at RustGIS's", + ), + ( + json!("abc"), + json!("abc"), + 0.0, + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out; picture markers with no size, drawn at RustGIS's", + ), ] { let (l, notes) = styled( GeometryType::Point, From 7504d8a5ae584941d408bd3e7cf819212eabc910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Wed, 25 Nov 2026 23:33:16 -0500 Subject: [PATCH 17/17] test(map): a circle's size below 0 is pinned as no size; the height flag says what it is (#2986) --- crates/map/src/arcgis_style.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/map/src/arcgis_style.rs b/crates/map/src/arcgis_style.rs index ba3a0190f8..bed3ce4431 100644 --- a/crates/map/src/arcgis_style.rs +++ b/crates/map/src/arcgis_style.rs @@ -498,9 +498,9 @@ fn symbol(s: &Value, g: GeometryType, picture: Option, pictures: &mut Pict say_unreadable_sizes(s, notes); let wide = s.get("width").and_then(Value::as_f64).is_some_and(|w| w.is_finite() && w > 0.0); let height = s.get("height").filter(|h| !h.is_null()); - let flat = height.and_then(Value::as_f64).is_some_and(|h| h <= 0.0); + let no_height = height.and_then(Value::as_f64).is_some_and(|h| h <= 0.0); let sized_by = if wide { - if flat { + if no_height { notes.add("picture markers of no height, drawn as tall as their image is"); } s.get("width") @@ -910,6 +910,13 @@ mod tests { 0.0, "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; marker sizes RustGIS can't read, left out; picture markers with no size, drawn at RustGIS's", ), + // A size below 0 is no size (not drawn at 0, not shown), as it is for the drawn picture. + ( + json!(-5), + json!(null), + 0.0, + "picture markers whose image isn't a PNG, JPEG or SVG RustGIS reads, drawn as circles; picture markers with no size, drawn at RustGIS's", + ), // With neither side given at all, it has no size, as the drawn picture has none. ( json!(null),