Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions crates/engine/src/cmd/tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub const NETWORK: &[&str] = &[
pub fn commands() -> Vec<C> {
vec![
C::new("map.addTiles", "Add Tile Layer", "Home › Add", add).params(
r#"{"url": "https://…/{z}/{x}/{y}.png" | vector tiles ".pbf" or TileJSON | MapLibre style.json | a PMTiles archive (web address or file path) | an MBTiles file path, "kind"?: "raster"|"vector"|"style"|"pmtiles"|"mbtiles" (guessed from the url), "name"?: text, "bounds"?: [west, south, east, north] (longitude/latitude coverage, when known), "attribution"?: text, "minZoom"?: number, "maxZoom"?: number, "tileSize"?: 256|512 (1024 too for a WMS or map service asked for in Web Mercator by its tiles' box: their pictures are asked for that size), "singleImage"?: bool (a WMS or map service: one picture of the view instead of tiles, so symbols and labels aren't cut at tile edges; tiles on the globe, a tilted map or a projection the service doesn't offer), "tms"?: bool, "subdomains"?: [text], "layers"?: [vector tile layer names, drawn in colours of their own], "styleLayers"?: [MapLibre style layers drawing vector tiles instead (their source is the tiles')], "opacity"?: 0–1, "blend"?: "normal"|"multiply"|"screen"|"overlay"|"darken"|"lighten"|"difference" (how it combines with what is beneath), "overlay"?: bool (on top of the map's layers, as every new layer goes; without it a basemap, under them; one with the same address and role is replaced when it has the same name or the same look), "top"?: bool (on top of the map's layers, as a layer added as data goes; by default an overlay's place), "replace"?: bool (removes the other tile basemaps, not overlays), "id"?: catalog id, "view"?: bool (a MapLibre style: go to the place, zoom, bearing and pitch its root properties give, once it loads), "start"?, "end"?: dates a url with date placeholders ({date:YYYY-MM-DD}, {YYYY}) spans, turning the time slider on (or, when it is on, setting its span), "unit"?, "interval"?, "dates"?: its steps (as in time.set), "legend"?: "the web address of its legend picture (PNG or JPEG)" | [address | {"url": address, "minScale"?: scale denominator, "maxScale"?: one (the scales it is for, from minScale up to below maxScale)}] (at most 16; the Layers pane shows the one for the map's scale under the layer; service.add gives a WMS or WMTS layer its service's)}"#,
r#"{"url": "https://…/{z}/{x}/{y}.png" | vector tiles ".pbf" or TileJSON | MapLibre style.json | a PMTiles archive (web address or file path) | an MBTiles file path, "kind"?: "raster"|"vector"|"style"|"pmtiles"|"mbtiles" (guessed from the url), "name"?: text, "bounds"?: [west, south, east, north] (longitude/latitude coverage, when known), "attribution"?: text, "minZoom"?: number, "maxZoom"?: number, "tileSize"?: 256|512 (1024 too for a WMS or map service asked for in Web Mercator by its tiles' box: their pictures are asked for that size), "singleImage"?: bool (a WMS or map service: one picture of the view instead of tiles, so symbols and labels aren't cut at tile edges; tiles on the globe, a tilted map or a projection the service doesn't offer; by default on for one, unless tileSize is given), "tms"?: bool, "subdomains"?: [text], "layers"?: [vector tile layer names, drawn in colours of their own], "styleLayers"?: [MapLibre style layers drawing vector tiles instead (their source is the tiles')], "opacity"?: 0–1, "blend"?: "normal"|"multiply"|"screen"|"overlay"|"darken"|"lighten"|"difference" (how it combines with what is beneath), "overlay"?: bool (on top of the map's layers, as every new layer goes; without it a basemap, under them; one with the same address and role is replaced when it has the same name or the same look), "top"?: bool (on top of the map's layers, as a layer added as data goes; by default an overlay's place), "replace"?: bool (removes the other tile basemaps, not overlays), "id"?: catalog id, "view"?: bool (a MapLibre style: go to the place, zoom, bearing and pitch its root properties give, once it loads), "start"?, "end"?: dates a url with date placeholders ({date:YYYY-MM-DD}, {YYYY}) spans, turning the time slider on (or, when it is on, setting its span), "unit"?, "interval"?, "dates"?: its steps (as in time.set), "legend"?: "the web address of its legend picture (PNG or JPEG)" | [address | {"url": address, "minScale"?: scale denominator, "maxScale"?: one (the scales it is for, from minScale up to below maxScale)}] (at most 16; the Layers pane shows the one for the map's scale under the layer; service.add gives a WMS or WMTS layer its service's)}"#,
),
C::new("map.removeTiles", "Remove Tile Layer", "Home › Add", remove)
.params(r#"{"name"?: text, "index"?: number, "id"?: catalog id} (removes every tile layer when none is given)"#),
Expand Down Expand Up @@ -276,12 +276,12 @@ pub(crate) fn add(s: &mut Session, p: &Value) -> CmdResult {
}
t.repair()?;
// A layer its service draws on request: one picture of the view, or tiles of the size given
// (#1162).
if let Some(single) = b(p, "singleImage") {
if single && !t.on_request() {
return Err(NOT_ON_REQUEST.into());
}
t.single_image = single;
// (#1162). Added by its address as from its service: one picture unless tiles are asked for
// (`singleImage: false`, or a tile size).
match b(p, "singleImage") {
Some(true) if !t.on_request() => return Err(NOT_ON_REQUEST.into()),
Some(single) => t.single_image = single,
None => t.single_image = t.on_request() && p.get("tileSize").is_none_or(Value::is_null),
Comment thread
pick2510 marked this conversation as resolved.
Resolved
}
if f(p, "tileSize").is_some() && t.sized_tiles() {
t.size_tiles();
Expand Down
11 changes: 11 additions & 0 deletions crates/engine/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9335,6 +9335,17 @@ fn wms_layers_draw_as_one_picture_or_tiles_of_a_size() {
assert!(rustgis_map::tiles::drawn_on_request("https://maps.example.org/wms?BBOX={nbbox}&width={nw}&HEIGHT={nh}&f=png"));
assert!(rustgis_map::tiles::drawn_on_request("https://maps.example.org/wms?BBOX={bbox-epsg-3857}&WIDTH={width}&HEIGHT={height}"));
assert!(!rustgis_map::tiles::drawn_on_request("https://maps.example.org/wms?BBOX={bbox-epsg-3857}&WIDTH={w}&HEIGHT=256"));
// Added by its address, a layer drawn on request is one picture too, unless tiles are asked
// for; a bare template, and tiles cut from a tile set, are tiles.
let wms = "https://m.example.org/wms?SERVICE=WMS&REQUEST=GetMap&LAYERS=a&CRS=EPSG:3857&BBOX={bbox-epsg-3857}&WIDTH=256&HEIGHT=256&FORMAT=image%2Fpng";
let single = |s: &Session, name: &str| s.map().tiles.iter().find(|t| t.name == name).unwrap().single_image;
s.run("map.addTiles", &json!({"url": wms, "name": "ByAddress", "overlay": true})).unwrap();
assert!(single(&s, "ByAddress"));
s.run("map.addTiles", &json!({"url": wms, "name": "AsTiles", "overlay": true, "singleImage": false})).unwrap();
Comment thread
pick2510 marked this conversation as resolved.
Resolved
assert!(!single(&s, "AsTiles"));
s.run("map.addTiles", &json!({"url": wms.replace("LAYERS=a", "LAYERS=b"), "name": "Sized", "overlay": true, "tileSize": 512})).unwrap();
assert!(!single(&s, "Sized"));
assert!(!single(&s, "Bare") && !single(&s, "XYZ"));
// A map service's export added with a tile size: its size asked for.
let export = "https://s.example.org/arcgis/rest/services/x/MapServer/export?bbox={bbox-epsg-3857}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&f=image";
s.run("map.addTiles", &json!({"url": export, "name": "Export", "overlay": true, "tileSize": 512})).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion docs/user-guide/data-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ A WMS layer and an ArcGIS map or image service's export draw their pictures on r
area and size. Added from **Add Service**, the Library or the National Map (its drawn maps; its
imagery stays in tiles), such a layer is asked for **one picture of the view**: the service lays
out its symbols and labels over the whole view, so none is cut at a tile edge, and it is asked
once a view instead of for every tile (#1162).
once a view instead of for every tile (#1162). So is one added by its address (`map.addTiles`
with a GetMap or export address that has its size: `WIDTH` and `HEIGHT`, or `size`), unless
it's given `"singleImage": false` or a `"tileSize"`.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

- The picture reaches past the view, its middle on a grid, so small pans and zooms (most of a
quarter of a level) ask for nothing new; while the next picture loads, the last one stays in
Expand Down
Loading