diff --git a/crates/engine/command-surface.txt b/crates/engine/command-surface.txt index b257a8c359..2499fb3030 100644 --- a/crates/engine/command-surface.txt +++ b/crates/engine/command-surface.txt @@ -486,7 +486,7 @@ raster.rotation layer? angle raster.setDefaultStyle fromLayer? layer? ramp? invert? stretch? low? high? n? resampling? reset? raster.spectral layer lon? lat? points? zone? raster.stretch layer? type low? high? n? min? max? like? -raster.symbology layer? type band? ramp? invert? classes? method? azimuth? altitude? zFactor? shadow? sky? fill? ambient? balanced? shadowSoftness? aerial? rock? grey? +raster.symbology layer? type band? ramp? invert? classes? method? azimuth? altitude? zFactor? shadow? sky? fill? ambient? balanced? shadowSoftness? aerial? terrain? rock? grey? raster.zarrInfo path url bbox? variable? report.activate report report.attachments report? field diff --git a/crates/engine/src/cmd/raster.rs b/crates/engine/src/cmd/raster.rs index 914794013d..15d9fa658f 100644 --- a/crates/engine/src/cmd/raster.rs +++ b/crates/engine/src/cmd/raster.rs @@ -39,7 +39,7 @@ pub fn commands() -> Vec { C::new("layer.addDataBytes", "Add Data (from file contents)", "Home › Add", add_bytes::).roles(&[]).effects(crate::policy::Effects::NONE) .params(r#"{"fileName": "name.tif|.tiff|.asc|.grb|.grib|.grb2|.grib2 (GRIB)|.hgt|.dt0|.dt1|.dt2|.geojson|.csv|.zip|.kml|.kmz|.gpx|.parquet|.fgb|.gpkg|.mbtiles|.jp2|.j2k|.dxf|.pdf (JPEG 2000: desktop, through GDAL; PDF: desktop, command line and Python)", "data": base64, "zoom"?: bool, "layer"?: "one layer of a zip, KML or GPX by name, or a PDF's page number (the first when left out or blank)", "name"?: text, "x"?, "y"?, "wkt"?, "crs"?, "delimiter"?, "paperSpace"?, "blocks"?, "stream"?, "as"? (as layer.addData)}"#), C::new("raster.symbology", "Symbology", "Style › Rendering", symbology).when(need_raster).roles(&[]).effects(crate::policy::Effects::NONE).params( - r#"{"layer"?, "type": "stretch"|"rgb"|"classify"|"unique"|"colormap"|"shadedRelief", "band"?: 1.., "ramp"?, "invert"?: bool, "classes"?: 1..32, "method"?, "azimuth"?, "altitude"?, "zFactor"?, "shadow"?: 0..1 (shadedRelief: how dark the shadows the terrain casts are; left out, kept; 0 casts none), "sky"?: 0..1 (shadedRelief: how much the share of the sky each cell sees dims its ambient light; left out, kept; 0 leaves it whole), "fill"?: 0..1 (shadedRelief: a fill light from the side opposite the sun that lightens the slopes turned toward it; left out, kept; 0 has none), "ambient"?: 0..1|null (shadedRelief: the share of the colour a slope turned fully from the sun keeps; left out, kept; null, the default: 0.25, or 0.5 balanced), "balanced"?: bool (shadedRelief: flat ground keeps the ramp's colour and slopes facing the sun brighten, up to 1.3; left out, kept; false, the default, lights as before), "shadowSoftness"?: 0.5..15|null (shadedRelief: how soft the edges of its cast shadows are, as half the sun's apparent size in degrees; left out, kept; outside 0.5 to 15, refused; null, the default: 5), "aerial"?: 0..1|null (shadedRelief: aerial perspective, low ground on the layer's stretch lit with less contrast and hazed toward #ECECEC, the more the lower; left out, kept; outside 0 to 1, refused; null or 0, the default: none), "rock"?: {"from"?: 0..90, "to"?: 0..90, "color"?: #RRGGBB} | false (shadedRelief: steep slopes tinted toward a rock colour before the light, from the ground's own slope in degrees, without the Z factor: the ramp below from, the colour above to, blended between; left out, kept; an object's missing keys keep the current rock's, or 25, 40 and #B2ACA4; false or null removes it), "grey"?: bool (shadedRelief without its colour ramp)}"#, + r#"{"layer"?, "type": "stretch"|"rgb"|"classify"|"unique"|"colormap"|"shadedRelief", "band"?: 1.., "ramp"?, "invert"?: bool, "classes"?: 1..32, "method"?, "azimuth"?, "altitude"?, "zFactor"?, "shadow"?: 0..1 (shadedRelief: how dark the shadows the terrain casts are; left out, kept; 0 casts none), "sky"?: 0..1 (shadedRelief: how much the share of the sky each cell sees dims its ambient light; left out, kept; 0 leaves it whole), "fill"?: 0..1 (shadedRelief: a fill light from the side opposite the sun that lightens the slopes turned toward it; left out, kept; 0 has none), "ambient"?: 0..1|null (shadedRelief: the share of the colour a slope turned fully from the sun keeps; left out, kept; null, the default: 0.25, or 0.5 balanced), "balanced"?: bool (shadedRelief: flat ground keeps the ramp's colour and slopes facing the sun brighten, up to 1.3; left out, kept; false, the default, lights as before), "shadowSoftness"?: 0.5..15|null (shadedRelief: how soft the edges of its cast shadows are, as half the sun's apparent size in degrees; left out, kept; outside 0.5 to 15, refused; null, the default: 5), "aerial"?: 0..1|null (shadedRelief: aerial perspective, low ground on the layer's stretch lit with less contrast and hazed toward #ECECEC, the more the lower; left out, kept; outside 0 to 1, refused; null or 0, the default: none), "terrain"?: -1..1|null (shadedRelief: terrain type, each cell's gradient g reshaped for the sun's light only as tan 30° × (g / tan 30°)^(1 − 0.5 × terrain), steepened at most 8 times: above 0 gentle relief shows, below 0 steep ground stands out; cast shadows, sky, fill light and rock keep the ground's slope; left out, kept; outside -1 to 1, refused; null or 0, the default: lit as before), "rock"?: {"from"?: 0..90, "to"?: 0..90, "color"?: #RRGGBB} | false (shadedRelief: steep slopes tinted toward a rock colour before the light, from the ground's own slope in degrees, without the Z factor: the ramp below from, the colour above to, blended between; left out, kept; an object's missing keys keep the current rock's, or 25, 40 and #B2ACA4; false or null removes it), "grey"?: bool (shadedRelief without its colour ramp)}"#, ), C::new("raster.stretch", "Stretch Type", "Style › Rendering", stretch).inputs(stretch_inputs).roles(&[]).effects(crate::policy::Effects::NONE) .when(need_raster) @@ -1044,6 +1044,11 @@ fn symbology(s: &mut Session, p: &Value) -> CmdResult { } _ => (0.0, 0.0, 0.0, None, None, false, None, 0.0), }; + // And its terrain type, likewise. + let cur_terrain = match rl.style.renderer { + RasterRenderer::ShadedRelief { terrain_type, .. } => terrain_type, + _ => 0.0, + }; RasterRenderer::ShadedRelief { band: bi, ramp: ramp.or(Some(Ramp::Terrain)).filter(|_| !b(p, "grey").unwrap_or(false)), @@ -1074,6 +1079,11 @@ fn symbology(s: &mut Session, p: &Value) -> CmdResult { Some(Value::Null) => 0.0, Some(_) => relief_aerial(f(p, "aerial"))?, }, + terrain_type: match p.get("terrain") { + None => cur_terrain, + Some(Value::Null) => 0.0, + Some(_) => relief_terrain_type(f(p, "terrain"))?, + }, } } other => return Err(format!("unknown raster symbology '{other}'")), @@ -1120,6 +1130,15 @@ fn relief_aerial(v: Option) -> Result { } } +/// A Shaded Relief's `"terrain"` (see `raster.symbology`), `v` being the number given, if it is +/// one: refused by name outside −1 to 1, never brought into it. +fn relief_terrain_type(v: Option) -> Result { + match v { + Some(v) if (-1.0..=1.0).contains(&v) => Ok(v), + _ => Err("\"terrain\" must be a number from -1 to 1, or null for 0".into()), + } +} + /// The rock of a Shaded Relief's `"rock"` (see `raster.symbology`): `false` or null for none, or /// an object whose missing keys keep `cur`'s, or else [`Rock::DEFAULT`]'s. fn relief_rock(v: &Value, cur: Option) -> Result, String> { diff --git a/crates/engine/src/project.rs b/crates/engine/src/project.rs index 0777e25ea3..d1948b5ab7 100644 --- a/crates/engine/src/project.rs +++ b/crates/engine/src/project.rs @@ -139,6 +139,7 @@ pub const CAPABILITIES: &[&str] = &[ "layout-publication-legend", "shaded-relief-shadow-softness", "shaded-relief-aerial", + "shaded-relief-terrain-type", ]; /// An offline area keeping the versions that lost a sync or a Bring Back /// (`OfflineArea::conflicts`, #2468): an older reader would save it again without them. diff --git a/crates/engine/src/project_capabilities.rs b/crates/engine/src/project_capabilities.rs index b5a4a0702d..027344f143 100644 --- a/crates/engine/src/project_capabilities.rs +++ b/crates/engine/src/project_capabilities.rs @@ -188,6 +188,7 @@ const COMMAND_CAPABILITIES: &[(&str, CommandCheck)] = &[ ("layout-publication-legend", command_sets_publication_legend), ("shaded-relief-shadow-softness", command_sets_shadow_softness), ("shaded-relief-aerial", command_sets_aerial), + ("shaded-relief-terrain-type", command_sets_terrain_type), ]; /// A saved `layout.publication` that leaves out or sets up its grid, scale bar or north arrow @@ -247,6 +248,18 @@ fn command_sets_aerial(id: &str, params: &Value) -> bool { } } +/// A saved `raster.symbology` that sets a Shaded Relief's terrain type (#3142): an older reader runs +/// it without the key, saying nothing, so the relief would be lit from its unshaped slopes. Read as +/// the command reads it (its type, and a numeric string is its number): `null` and 0 light as an +/// older reader does; another renderer reads no terrain type. +fn command_sets_terrain_type(id: &str, params: &Value) -> bool { + match id { + "raster.symbology" => crate::cmd::raster::symbology_is_relief(params) && crate::cmd::f(params, "terrain").is_some_and(|v| v != 0.0), + "script.run" => params.get("script").and_then(Value::as_str).is_some_and(|s| script_uses(s, command_sets_terrain_type)), + _ => false, + } +} + /// A saved `labels.placement` that has a class remove duplicates, read as the command reads it /// (#2847): an older reader runs it without the key, saying nothing, so every label would show. /// False or null is what an older reader keeps. @@ -1079,6 +1092,15 @@ fn sets_aerial(layer: &Layer) -> bool { layer.raster.as_ref().is_some_and(|r| matches!(&r.style.renderer, RasterRenderer::ShadedRelief { aerial, .. } if *aerial != 0.0)) } +/// Whether a layer sets its Shaded Relief's terrain type (#3142): an older reader would light it +/// from its unshaped slopes and save the layer again without the setting. +fn sets_terrain_type(layer: &Layer) -> bool { + layer + .raster + .as_ref() + .is_some_and(|r| matches!(&r.style.renderer, RasterRenderer::ShadedRelief { terrain_type, .. } if *terrain_type != 0.0)) +} + /// Whether a layer is a window of a Zarr variable following the time slider (#1720): an older /// reader would drop the window and read the whole map at each step. fn zarr_window(layer: &Layer) -> bool { @@ -1123,6 +1145,7 @@ fn layer_capabilities(layer: &Layer) -> Vec<&'static str> { (relief_light(layer), "shaded-relief-light"), (sets_shadow_softness(layer), "shaded-relief-shadow-softness"), (sets_aerial(layer), "shaded-relief-aerial"), + (sets_terrain_type(layer), "shaded-relief-terrain-type"), (layer.size_by.is_some(), super::SIZE_BY_CAPABILITY), (layer.has_picture_markers(), "picture-markers"), (layer.any_picture(svg_picture), "svg-markers"), @@ -1159,7 +1182,7 @@ fn map_capabilities<'a>(maps: impl IntoIterator) -> Vec<&'static let (mut polygon, mut svg) = (false, false); let (mut offline_area_id, mut paper, mut native, mut guided, mut weighed, mut cleared, mut deduped) = (false, false, false, false, false, false, false); - let (mut crisp, mut bed, mut walls_top, mut soft, mut aerial) = (false, false, false, false, false); + let (mut crisp, mut bed, mut walls_top, mut soft, mut aerial, mut terrain_type) = (false, false, false, false, false, false); for map in maps { offline_area_id |= map.offline_area_id.is_some(); // A blank basemap's paper colour (#2532), which an older reader would draw and save white. @@ -1198,6 +1221,7 @@ fn map_capabilities<'a>(maps: impl IntoIterator) -> Vec<&'static light |= map.layers.iter().any(relief_light); soft |= map.layers.iter().any(sets_shadow_softness); aerial |= map.layers.iter().any(sets_aerial); + terrain_type |= map.layers.iter().any(sets_terrain_type); sized |= map.layers.iter().any(|layer| layer.size_by.is_some()); pictures |= map.layers.iter().any(Layer::has_picture_markers); svg |= map.layers.iter().any(|layer| layer.any_picture(svg_picture)); @@ -1221,6 +1245,7 @@ fn map_capabilities<'a>(maps: impl IntoIterator) -> Vec<&'static (light, "shaded-relief-light"), (soft, "shaded-relief-shadow-softness"), (aerial, "shaded-relief-aerial"), + (terrain_type, "shaded-relief-terrain-type"), (legends, "normalized-legend-urls"), (sized, super::SIZE_BY_CAPABILITY), (pictures, "picture-markers"), @@ -1757,6 +1782,14 @@ mod tests { (&[], "raster.symbology", json!({"type": "shadedRelief", "shadowSoftness": 5})), (&[], "raster.symbology", json!({"type": "shadedRelief", "shadowSoftness": "5"})), (&["shaded-relief-shadow-softness"], "raster.symbology", json!({"type": "shadedRelief", "shadowSoftness": "1.5"})), + (&["shaded-relief-terrain-type"], "raster.symbology", json!({"type": "shadedRelief", "terrain": -0.6})), + (&["shaded-relief-terrain-type"], "raster.symbology", json!({"type": "Shaded Relief", "terrain": "0.6"})), + // null and 0 (a numeric string too) light as an older reader does; only a Shaded + // Relief, its type read as the command reads it (left out, a stretch), reads the key. + (&[], "raster.symbology", json!({"type": "shadedRelief", "terrain": null})), + (&[], "raster.symbology", json!({"type": "hillshade", "terrain": "0"})), + (&[], "raster.symbology", json!({"type": "stretch", "terrain": 0.6})), + (&[], "raster.symbology", json!({"terrain": 0.6})), // An SVG image is a picture marker as well, in a node as in a saved command. (&["picture-markers", "svg-markers"], "layer.marker", json!({"image": svg})), (&[], "buffer", json!({"input": "Cities", "distance": 1})), @@ -1786,6 +1819,10 @@ mod tests { assert_eq!(uses("script.run", &json!({ "script": script })), needs && kind == "shadedRelief", "{kind} {key} {value}"); } } + for (kind, terrain, needs) in [("shadedRelief", "0", false), ("shadedRelief", "0.6", true), ("stretch", "0.6", false)] { + let script = format!(r#"raster.symbology {{"type": "{kind}", "terrain": "{terrain}"}}"#); + assert_eq!(command_sets_terrain_type("script.run", &json!({ "script": script })), needs, "{kind} {terrain}"); + } } /// `report.existingTemplate` imports a layout file as `layout.import` does, so a step of it @@ -3469,7 +3506,7 @@ mod tests { })) .unwrap(); let clean = Layer::new_raster(1, "DEM", raster); - for field in ["shadow", "sky", "fill", "rock", "ambient", "balanced", "shadow_softness", "aerial"] { + for field in ["shadow", "sky", "fill", "rock", "ambient", "balanced", "shadow_softness", "aerial", "terrain_type"] { let mut value = serde_json::to_value(&clean).unwrap(); value["raster"]["style"]["renderer"]["ShadedRelief"][field] = match field { "rock" => serde_json::to_value(rustgis_map::raster::Rock::DEFAULT).unwrap(), @@ -3488,6 +3525,7 @@ mod tests { "ambient" | "balanced" => "shaded-relief-light", "shadow_softness" => "shaded-relief-shadow-softness", "aerial" => "shaded-relief-aerial", + "terrain_type" => "shaded-relief-terrain-type", _ => "shaded-relief-effects", }; assert_eq!(document["requires"], json!([needs]), "{field}: {document}"); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 43521b021c..7fdc746bfc 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -7962,6 +7962,56 @@ fn shaded_relief_keeps_its_aerial_perspective() { assert_eq!(serde_json::to_value(&fixture).unwrap()["requires"], json!(["shaded-relief-aerial"])); } +/// Shaded Relief's terrain type (#3142) is set, kept when left out, refused by name outside −1 to 1 +/// (never brought into it), saved only when set, and back when the project is opened again; null +/// or 0 lights as before again, which saves nothing new. +#[test] +fn shaded_relief_keeps_its_terrain_type() { + let mut s = with_raster(); + let terrain = |s: &Session| match s.map().layers.iter().find_map(|l| l.raster.as_ref()).map(|r| &r.style.renderer) { + Some(rustgis_map::RasterRenderer::ShadedRelief { terrain_type, .. }) => *terrain_type, + other => panic!("{other:?}"), + }; + let saved = |s: &mut Session| s.project.saved_text(None).unwrap().0; + s.run("raster.symbology", &json!({"type": "shadedRelief", "shadow": 0.8})).unwrap(); + assert_eq!(terrain(&s), 0.0); + assert!(!saved(&mut s).contains("\"terrain_type\":"), "none saves nothing new"); + s.run("raster.symbology", &json!({"type": "shadedRelief", "terrain": -0.6})).unwrap(); + s.run("raster.symbology", &json!({"type": "shadedRelief", "azimuth": 200})).unwrap(); + assert_eq!(terrain(&s), -0.6, "left out, kept"); + for refused in [json!(-1.5), json!(1.01), json!("hills"), json!(true)] { + let e = s.run("raster.symbology", &json!({"type": "shadedRelief", "terrain": refused})).unwrap_err(); + assert!(e.contains("\"terrain\"") && e.contains("-1 to 1"), "{refused}: {e}"); + assert_eq!(terrain(&s), -0.6, "{refused}: refused, nothing changed"); + } + s.run("raster.symbology", &json!({"type": "shadedRelief", "terrain": "1"})).unwrap(); + assert_eq!(terrain(&s), 1.0, "a numeric string is its number"); + let text = saved(&mut s); + assert!(text.contains("\"terrain_type\":1.0") && text.contains("shaded-relief-terrain-type"), "saved, and required by name"); + let nanos = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_or(0, |d| d.as_nanos()); + let dir = std::env::temp_dir().join(format!("rustgis-terrain-type-{}-{nanos}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let path = dir.join("terrain.rgis"); + s.run("project.saveAs", &json!({"path": path.display().to_string()})).unwrap(); + let mut t = Session::new(Project::default()); + t.run("project.open", &json!({"path": path.display().to_string()})).unwrap(); + let _ = std::fs::remove_dir_all(&dir); + assert_eq!(terrain(&t), 1.0, "back when opened"); + for none in [json!(null), json!(0)] { + s.run("raster.symbology", &json!({"type": "shadedRelief", "terrain": 0.3})).unwrap(); + s.run("raster.symbology", &json!({"type": "shadedRelief", "terrain": none})).unwrap(); + assert_eq!(terrain(&s), 0.0, "{none}: none"); + } + s.run("raster.symbology", &json!({"type": "shadedRelief", "terrain": 0.3})).unwrap(); + s.run("edit.undo", &json!({})).unwrap(); + assert_eq!(terrain(&s), 0.0, "undone"); + assert!(!saved(&mut s).contains("\"terrain_type\":"), "none saves nothing new"); + // The fixture reads back as saved, requiring what it sets by name. + let fixture = Project::from_json(include_str!("../../../schema/fixtures/shaded_relief_terrain_type.rgis")).unwrap(); + assert_eq!(terrain(&Session::new(fixture.clone())), 0.6); + assert_eq!(serde_json::to_value(&fixture).unwrap()["requires"], json!(["shaded-relief-terrain-type"])); +} + /// Shaded Relief's rock on steep slopes (#1913): an object turns it on, its missing keys from the /// current rock or the defaults; kept when left out; `false` removes it; a `from` not below `to` /// or a bad colour is refused; saved with the project only when set. diff --git a/crates/map/src/layout/tests.rs b/crates/map/src/layout/tests.rs index 1f4a9a9359..c728dcc4b4 100644 --- a/crates/map/src/layout/tests.rs +++ b/crates/map/src/layout/tests.rs @@ -771,6 +771,7 @@ fn a_balanced_reliefs_colour_bar_is_its_flat_ground() { balanced, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let Some(ColorScale::Ramp { lo, hi, colors }) = color_scale(&rl) else { panic!("a ramp") }; let colorizer = Colorizer::new(&rl.style, &r, None); diff --git a/crates/map/src/qgis/raster.rs b/crates/map/src/qgis/raster.rs index f1155715c2..21b552f3ad 100644 --- a/crates/map/src/qgis/raster.rs +++ b/crates/map/src/qgis/raster.rs @@ -102,6 +102,7 @@ fn renderer_style(node: Node, pipe: Node, r: Node, kind: &str, layer: &str, repo balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; (renderer, Stretch::None) } diff --git a/crates/map/src/qgis/tests.rs b/crates/map/src/qgis/tests.rs index 405737d2bc..91e9cb200f 100644 --- a/crates/map/src/qgis/tests.rs +++ b/crates/map/src/qgis/tests.rs @@ -914,6 +914,7 @@ fn raster_renderers_read_as_rustgis_raster_styles() { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, } ); assert!(report.notes.iter().any(|n| n.text.contains("saturation"))); diff --git a/crates/map/src/raster.rs b/crates/map/src/raster.rs index 2e65b9726b..874ef8a408 100644 --- a/crates/map/src/raster.rs +++ b/crates/map/src/raster.rs @@ -1484,6 +1484,46 @@ pub fn aerial_share(aerial: f64, t: f64) -> f64 { (aerial.min(1.0) * low.powf(1.5)).clamp(0.0, 1.0) } +/// The slope whose gradient a Shaded Relief's terrain type leaves as it is (#3142), in degrees. +pub const TERRAIN_TYPE_PIVOT: f64 = 30.0; +/// The most a Shaded Relief's terrain type multiplies a gradient by, so that nearly flat noise (a +/// surface model's canopy steps) isn't blown up. +pub const TERRAIN_TYPE_MAX_STEEPEN: f64 = 8.0; +/// The smallest gradient a terrain type reshapes from: below it the steepening is at its cap. +const TERRAIN_TYPE_MIN_GRADIENT: f64 = 1e-6; + +/// What a Shaded Relief's terrain type (#3142, −1 to 1) multiplies the ground's own `gradient` (the +/// tangent of its slope) by before the light is worked out: `g′ = g₀ × (g / g₀)^p`, with +/// `p = 1 − 0.5 × terrain_type` and `g₀` the tangent of [`TERRAIN_TYPE_PIVOT`], so the factor is +/// `(g / g₀)^(p − 1)`, at most [`TERRAIN_TYPE_MAX_STEEPEN`]. Above 0 gentle slopes are steepened +/// more than steep ones, below 0 steep ground is stressed and gentle ground calmed. 1 for a setting +/// of 0 or not a number (drawn as before); a setting past ±1 counts as ±1. +pub fn terrain_type_factor(terrain_type: f64, gradient: f64) -> f64 { + if terrain_type.is_nan() || terrain_type == 0.0 { + return 1.0; + } + let p = 1.0 - 0.5 * terrain_type.clamp(-1.0, 1.0); + let g = if gradient.is_nan() { 0.0 } else { gradient.abs() }.max(TERRAIN_TYPE_MIN_GRADIENT); + (g / TERRAIN_TYPE_PIVOT.to_radians().tan()).powf(p - 1.0).min(TERRAIN_TYPE_MAX_STEEPEN) +} + +/// A Shaded Relief cell's [`hillshade`] with its terrain type (#3142): the gradient reshaped by +/// [`terrain_type_factor`] from the ground's own, then the Z factor. Both of its components are +/// scaled alike, so the aspect, and the light's direction, never change. 0 is [`hillshade`] itself. +pub fn relief_hillshade(z: &[f64; 9], cell_x: f64, cell_y: f64, azimuth: f64, altitude: f64, z_factor: f64, terrain_type: f64) -> u8 { + if terrain_type.is_nan() || terrain_type == 0.0 { + return hillshade(z, cell_x, cell_y, azimuth, altitude, z_factor); + } + let (dzdx, dzdy) = horn(z, cell_x, cell_y); + let gradient = dzdx.hypot(dzdy); + // An infinite gradient stays infinite at any setting: lit as before, where its factor (0) would + // multiply infinity into a black cell. + if gradient.is_infinite() { + return hillshade(z, cell_x, cell_y, azimuth, altitude, z_factor); + } + hillshade(z, cell_x, cell_y, azimuth, altitude, z_factor * terrain_type_factor(terrain_type, gradient)) +} + fn is_no_light(v: &f64) -> bool { *v == 0.0 } @@ -1706,7 +1746,11 @@ pub enum RasterRenderer { /// [`crate::shadow::SOFT_EDGE_MAX`]): how soft their edges are (#3144); none, the default, is /// [`crate::shadow::SOFT_EDGE`]. `aerial` (0 to 1) is its aerial perspective (#3141): low ground, /// by the cell's height on the layer's stretch, is lit with less contrast and hazed toward - /// [`AERIAL_HAZE`] (see [`aerial_share`]); 0, the default, draws it as before. + /// [`AERIAL_HAZE`] (see [`aerial_share`]); 0, the default, draws it as before. `terrain_type` + /// (−1 to 1) reshapes each cell's gradient for the sun's light only (#3142, see + /// [`relief_hillshade`]): above 0 gentle relief shows, below 0 steep ground stands out; 0, the + /// default, lights as before. Cast shadows, the sky, the fill light and rock keep the ground's + /// own slope. ShadedRelief { band: usize, ramp: Option, @@ -1729,6 +1773,8 @@ pub enum RasterRenderer { shadow_softness: Option, #[serde(default, skip_serializing_if = "is_no_light")] aerial: f64, + #[serde(default, skip_serializing_if = "is_no_light")] + terrain_type: f64, }, } @@ -2800,6 +2846,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, } } @@ -3392,6 +3439,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let (mut rocky, mut plain) = (RasterStyle::default_for(&r), RasterStyle::default_for(&r)); (rocky.renderer, plain.renderer) = (relief(Some(rock)), relief(None)); @@ -3449,6 +3497,7 @@ mod tests { balanced, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let relief = |altitude, ambient, balanced| tinted_relief(None, altitude, ambient, balanced); // Grey relief: white shaded, so a channel is 255 times the light. @@ -3537,6 +3586,7 @@ mod tests { balanced, shadow_softness: None, aerial, + terrain_type: 0.0, } } @@ -3649,6 +3699,97 @@ mod tests { assert_eq!(c.key_color(&[100.0], Some(255)), Some(ramp(100.0)), "the top: the ramp itself"); } + /// Without a terrain type (#3142), its default, a Shaded Relief cell is lit exactly as before it + /// existed: every hillshade against the formula main lit with, copied here, over windows from + /// flat to steep facing every way, cell sizes, suns and Z factors; not a number is none too. A + /// project from before it reads as none, and none saves nothing new. + #[test] + fn no_terrain_type_lights_as_before() { + // Main's hillshade before #3142, as it was. + let before = |z: &[f64; 9], cx: f64, cy: f64, azimuth: f64, altitude: f64, zf: f64| { + let [a, b, c, d, _, f, g, h, i] = *z; + let dzdx = ((c + 2.0 * f + i) - (a + 2.0 * d + g)) / (8.0 * cx.max(1e-9)); + let dzdy = ((g + 2.0 * h + i) - (a + 2.0 * b + c)) / (8.0 * cy.max(1e-9)); + let tilt = (zf * (dzdx * dzdx + dzdy * dzdy).sqrt()).atan(); + let aspect = if dzdx != 0.0 || dzdy != 0.0 { dzdy.atan2(-dzdx) } else { 0.0 }; + let zenith = (90.0 - altitude.clamp(0.0, 90.0)).to_radians(); + let az = (360.0 - azimuth + 90.0).rem_euclid(360.0).to_radians(); + let v = zenith.cos() * tilt.cos() + zenith.sin() * tilt.sin() * (az - aspect).cos(); + (v.max(0.0) * 255.0).round().clamp(0.0, 255.0) as u8 + }; + // Heights from a linear congruential sequence, 0 to `relief`: windows of every slope and aspect. + let mut seed = 12_345u64; + let mut next = move || { + seed = seed.wrapping_mul(6_364_136_223_846_793_005).wrapping_add(1_442_695_040_888_963_407); + (seed >> 11) as f64 / (1u64 << 53) as f64 + }; + let mut lit = 0; + for relief in [0.0, 0.5, 5.0, 50.0, 500.0] { + for _ in 0..200 { + let z: [f64; 9] = std::array::from_fn(|_| next() * relief); + for (cx, cy) in [(1.0, 1.0), (30.0, 30.0), (90.0, 60.0)] { + for (azimuth, altitude) in [(315.0, 45.0), (90.0, 20.0), (200.0, 70.0)] { + for zf in [1.0, 2.0] { + for none in [0.0, -0.0, f64::NAN] { + let want = before(&z, cx, cy, azimuth, altitude, zf); + assert_eq!(relief_hillshade(&z, cx, cy, azimuth, altitude, zf, none), want, "{z:?} {none}"); + lit += 1; + } + } + } + } + } + } + assert!(lit > 50_000, "{lit}"); + let old = r#"{"ShadedRelief":{"band":0,"ramp":null,"azimuth":315.0,"altitude":45.0,"z_factor":1.0}}"#; + let read: RasterRenderer = serde_json::from_str(old).unwrap(); + assert!(matches!(read, RasterRenderer::ShadedRelief { terrain_type, .. } if terrain_type == 0.0)); + assert_eq!(serde_json::to_string(&read).unwrap(), old, "none saves nothing new"); + } + + /// The terrain type's curve (#3142): `g′ = g₀ × (g / g₀)^p`, `p = 1 − 0.5 × terrain_type`, + /// pivoting on 30°, the steepening at most 8 times; above 0 gentle slopes are steepened and + /// steep ones calmed, below 0 the reverse; flat ground stays flat. + #[test] + fn the_terrain_type_reshapes_the_gradient_about_30_degrees() { + let g0 = 30f64.to_radians().tan(); + let shaped = |terrain_type: f64, g: f64| g * terrain_type_factor(terrain_type, g); + for terrain_type in [-1.0, -0.6, 0.3, 0.6, 1.0] { + assert!((shaped(terrain_type, g0) - g0).abs() < 1e-12, "{terrain_type}: 30° unchanged"); + for degrees in [2.0, 5.0, 15.0, 45.0, 70.0] { + let g = f64::to_radians(degrees).tan(); + let p = 1.0 - 0.5 * terrain_type; + assert!((shaped(terrain_type, g) - g0 * (g / g0).powf(p)).abs() < 1e-12, "{terrain_type} {degrees}°"); + // Toward 30° above 0, away from it below. + assert_eq!(shaped(terrain_type, g) > g, (terrain_type > 0.0) == (degrees < 30.0), "{terrain_type} {degrees}°"); + } + } + // At most 8 times steeper: nearly flat noise, flat ground and not a number. + for g in [1e-4, 1e-9, 0.0, f64::NAN] { + assert_eq!(terrain_type_factor(1.0, g), TERRAIN_TYPE_MAX_STEEPEN, "{g}"); + } + // None for 0 or not a number; past ±1 counts as ±1. + let g = 5f64.to_radians().tan(); + assert_eq!((terrain_type_factor(0.0, g), terrain_type_factor(f64::NAN, g)), (1.0, 1.0)); + assert_eq!(terrain_type_factor(3.0, g), terrain_type_factor(1.0, g)); + assert_eq!(terrain_type_factor(-3.0, g), terrain_type_factor(-1.0, g)); + // A gentle slope turned from the sun darkens above 0 and lightens below; flat ground keeps + // its light at any setting. + let east: [f64; 9] = std::array::from_fn(|k| [10.0, 5.0, 0.0][k % 3]); + let lit = |terrain_type: f64| relief_hillshade(&east, 50.0, 50.0, 270.0, 45.0, 1.0, terrain_type); + assert!(lit(0.6) < lit(0.0) && lit(-0.6) > lit(0.0), "{} {} {}", lit(0.6), lit(0.0), lit(-0.6)); + assert_eq!(relief_hillshade(&[7.0; 9], 50.0, 50.0, 270.0, 45.0, 1.0, 1.0), hillshade(&[7.0; 9], 50.0, 50.0, 270.0, 45.0, 1.0)); + // An infinite gradient (an infinite height in a float model) stays infinite at any setting, + // so it is lit as without one, never drawn black. + let mut wall = [0.0; 9]; + wall[5] = f64::INFINITY; + for (terrain_type, azimuth) in [(0.6, 270.0), (0.6, 90.0), (-0.6, 90.0), (1.0, 0.0)] { + let want = hillshade(&wall, 50.0, 50.0, azimuth, 45.0, 2.0); + assert_eq!(relief_hillshade(&wall, 50.0, 50.0, azimuth, 45.0, 2.0, terrain_type), want, "{terrain_type} {azimuth}"); + } + assert!(hillshade(&wall, 50.0, 50.0, 270.0, 45.0, 2.0) > 0, "lit without a terrain type"); + } + /// A tower lit from the east, drawn as Shaded Relief with `shadow`. fn tower(shadow: f64) -> RasterLayer { let gt = GeoTransform { origin_x: 0.0, origin_y: 0.0, pixel_width: 30.0, pixel_height: -30.0 }; diff --git a/crates/render/src/layout/tests.rs b/crates/render/src/layout/tests.rs index ecac96ea32..91e73d5517 100644 --- a/crates/render/src/layout/tests.rs +++ b/crates/render/src/layout/tests.rs @@ -2974,6 +2974,7 @@ fn a_page_says_why_a_frame_drew_no_cast_shadows() { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; for shadow in [0.0, 1.0] { let map = ramp_map(relief(shadow), rustgis_map::raster::Stretch::MinMax); @@ -3028,6 +3029,7 @@ fn page_settles_with_suns(suns: &[f64]) { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let mut m = Map::new(name.clone()); assert_eq!(m.add_raster("dem", copy), 1); @@ -3101,6 +3103,7 @@ fn a_reliefs_shadow_softness_changes_its_page_only_off_the_default() { balanced: false, shadow_softness: softness, aerial: 0.0, + terrain_type: 0.0, }; let mut m = Map::new("m"); assert_eq!(m.add_raster("dem", rl), 1); @@ -3156,6 +3159,7 @@ fn a_reliefs_aerial_perspective_lightens_its_page() { balanced: false, shadow_softness: None, aerial, + terrain_type: 0.0, }; let map = ramp_map(relief, rustgis_map::raster::Stretch::MinMax); colorbar_page(&map, Orientation::Horizontal, false, "").data().iter().map(|c| u64::from(*c)).sum::() diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rs index 428cf84f9c..e304eed2b8 100644 --- a/crates/render/src/lib.rs +++ b/crates/render/src/lib.rs @@ -12445,6 +12445,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; }; let camera = Camera { center: lonlat_to_merc(Coord::new(0.0, 0.0)), res: 1200.0, bearing: 0.0, pitch: 0.0 }; @@ -12484,6 +12485,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; // Drawn only zoomed out past a scale between the centre's and the far band's. l.max_scale = Some((centre + farthest) / 2.0); @@ -12534,6 +12536,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; // Drawn only zoomed in past 1:1: or in a group drawn only there. if grouped { diff --git a/crates/render/src/raster.rs b/crates/render/src/raster.rs index 04d3fb7684..663a2feb98 100644 --- a/crates/render/src/raster.rs +++ b/crates/render/src/raster.rs @@ -10,7 +10,7 @@ use rustgis_data::raster::{BandStats, ColorHint, Raster, Reprojection}; use rustgis_geom::{Coord, Extent, extent_to_merc, lonlat_to_merc}; use rustgis_map::Globe; use rustgis_map::projection::Flat; -use rustgis_map::raster::{Colorizer, RasterMask, RasterRenderer, RasterStyle, Resampling, Rock, hillshade, slope}; +use rustgis_map::raster::{Colorizer, RasterMask, RasterRenderer, RasterStyle, Resampling, Rock, hillshade, relief_hillshade, slope}; use tiny_skia::{FilterQuality, Pixmap, PixmapPaint, Transform}; use crate::View; @@ -529,6 +529,11 @@ fn draw_with( RasterRenderer::ShadedRelief { rock, .. } => rock, _ => None, }; + // The terrain type reshapes the gradient the sun lights (#3142); 0 lights as before. + let terrain_type = match style.renderer { + RasterRenderer::ShadedRelief { terrain_type, .. } => terrain_type, + _ => 0.0, + }; // Blending neighbours would invent values that aren't classes or palette entries. let resampling = match style.renderer { RasterRenderer::UniqueValues { .. } | RasterRenderer::Colormap => Resampling::Nearest, @@ -562,6 +567,7 @@ fn draw_with( sky, fill, rock, + terrain_type, water: light.water.filter(|_| relief.is_some()).map(|w| WaterCells::new(w, r, &grid)), resampling, alpha_band, @@ -770,6 +776,8 @@ struct Pass1<'a> { fill: f64, /// Shaded Relief's rock on steep slopes, when it has one. rock: Option, + /// Shaded Relief's terrain type (see [`relief_hillshade`]): the sun's light only. + terrain_type: f64, /// The terrain's water, for Shaded Relief: its cells take its level and flat ground's light. water: Option>, resampling: Resampling, @@ -968,7 +976,8 @@ impl Pass1<'_> { } /// The lights on the relief's cell `(ci, ri)`, from 0 to 255 and not rounded: the direct - /// light, the hillshade of its 3 × 3 window times what the cast shadows leave on it; and the + /// light, the hillshade of its 3 × 3 window (its gradient reshaped by the terrain type, see + /// [`relief_hillshade`]) times what the cast shadows leave on it; and the /// ambient light, scaled by the sky the cell sees; the fill light (see [`FILL_ALTITUDE`]), which /// nothing shadows; and its share of rock (see [`Rock::share`]), from the ground's own slope in /// the same window. `centre` is the cell's height, and stands in for a neighbour that is no @@ -992,7 +1001,9 @@ impl Pass1<'_> { let left = |grid: Option<(&[u8], f64)>| { grid.and_then(|(grid, strength)| grid.get(at).map(|v| 1.0 - strength * (1.0 - f64::from(*v) / 255.0))) }; - let mut direct = f64::from(hillshade(&z, self.cell.0, self.cell.1, az, alt, zf)); + // The terrain type reshapes the gradient for the sun's light alone (#3142): the fill light + // and rock below, like the cast shadows and the sky, keep the ground's own slope. + let mut direct = f64::from(relief_hillshade(&z, self.cell.0, self.cell.1, az, alt, zf, self.terrain_type)); if let Some(left) = left(self.shadow) { direct *= left; } @@ -1140,6 +1151,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, } } @@ -1238,6 +1250,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; style.resampling = Resampling::Nearest; let mut pm = Pixmap::new(1, 1).unwrap(); @@ -1415,6 +1428,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; style.resampling = Resampling::Nearest; let view = View { @@ -1445,6 +1459,65 @@ mod tests { assert!(drawn(to_fill, 0.3) > drawn(to_fill, 0.0) && drawn(to_fill, 1.0) > drawn(to_fill, 0.3), "a slope turned to the fill"); } + /// The terrain type (#3142) reshapes only the sun's light: on a gentle slope turned from a western + /// sun toward the fill light, the hillshade is [`relief_hillshade`]'s, while the fill light and + /// rock keep the ground's own slope; 0 draws today's pixels. + #[test] + fn the_terrain_type_reshapes_only_the_suns_light() { + let rock = Rock { from: 2.0, to: 20.0, color: rustgis_map::Rgba::rgb(0xB2, 0xAC, 0xA4) }; + // Three columns of 100 m cells falling 10 m a cell to the east (5.7°): the middle cell. + let east = [120.0, 110.0, 100.0]; + let gt = GeoTransform { origin_x: 0.0, origin_y: 300.0, pixel_width: 100.0, pixel_height: -100.0 }; + let r = Raster::new("relief", 3, 3, vec![east.map(|h| h as f32).repeat(3)], gt, Crs::WebMercator, None, ColorHint::Gray, "Float32") + .unwrap(); + let z: [f64; 9] = std::array::from_fn(|k| east[k % 3]); + let painted = |terrain_type: f64| { + let mut style = RasterStyle::default_for(&r); + style.renderer = RasterRenderer::ShadedRelief { + band: 0, + ramp: None, + azimuth: 270.0, + altitude: 45.0, + z_factor: 2.0, + shadow: 0.0, + sky: 0.0, + fill: 0.5, + rock: Some(rock), + ambient: None, + balanced: false, + shadow_softness: None, + aerial: 0.0, + terrain_type, + }; + style.resampling = Resampling::Nearest; + let view = View { + width: 1.0, + height: 1.0, + pixels_per_point: 1.0, + camera: Camera { center: Coord::new(150.0, 150.0), res: 1.0, bearing: 0.0, pitch: 0.0 }, + sky: false, + }; + let mut pm = Pixmap::new(1, 1).unwrap(); + draw(&mut pm, &r, &style, None, &view, 1.0, false, Place::Flat(&Flat::Mercator, "mercator"), Lights::default()); + let p = pm.pixel(0, 0).unwrap(); + // The sun's light reshaped; the fill light and rock from the ground's own slope. + let sun = relief_hillshade(&z, 100.0, 100.0, 270.0, 45.0, 2.0, terrain_type); + let toward = f64::from(hillshade(&z, 100.0, 100.0, 90.0, FILL_ALTITUDE, 2.0)); + let fill = (0.5 * (toward - FILL_FLAT).max(0.0)).round() as u8; + let rocky = (rock.share(slope(&z, 100.0, 100.0)) * 255.0).round() as u8; + let want = Colorizer::new(&style, &r, None).color_lit(&[110.0], Some(sun), None, Some(fill), Some(rocky)).unwrap(); + ([p.red(), p.green(), p.blue(), p.alpha()], want, sun) + }; + let (today, want, sun) = painted(0.0); + assert_eq!(today, want, "0 draws today's pixels"); + assert_eq!(sun, hillshade(&z, 100.0, 100.0, 270.0, 45.0, 2.0)); + for terrain_type in [0.6, -0.6, 1.0] { + let (drawn, want, sun) = painted(terrain_type); + assert_eq!(drawn, want, "{terrain_type}"); + assert_ne!(drawn, today, "{terrain_type}: {sun}"); + } + } + /// A 0–360° grid seen across its seam: the part in view is two strips, one at each end of /// the grid, not the whole width. #[test] @@ -1782,6 +1855,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; style.resampling = resampling; let view = View { diff --git a/crates/render/src/raster_export.rs b/crates/render/src/raster_export.rs index 3148f8dda2..dc076ec829 100644 --- a/crates/render/src/raster_export.rs +++ b/crates/render/src/raster_export.rs @@ -267,6 +267,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let e = export(&layer, 2, 2, 1.0).err().unwrap_or_else(|| panic!("an archive without its shadows")); assert!(e.contains("cast shadows") && e.contains("read in place"), "{e}"); @@ -303,6 +304,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let _cancelled = rustgis_data::progress::install(Some(std::sync::Arc::new(Cancelled))); let e = export(&layer, 0, 0, 1.0).err().unwrap_or_else(|| panic!("an archive without its shadows")); diff --git a/crates/render/src/terrain/water.rs b/crates/render/src/terrain/water.rs index bd1db116cb..87f9823c98 100644 --- a/crates/render/src/terrain/water.rs +++ b/crates/render/src/terrain/water.rs @@ -1394,6 +1394,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; }; let camera = rustgis_map::Camera { center: lonlat_to_merc(Coord::new(0.35, -0.05)), res: 300.0, bearing: 0.0, pitch: 0.0 }; @@ -1451,6 +1452,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; camera.center = lonlat_to_merc(Coord::new(0.35, -0.3)); let view = crate::View { width: 300.0, height: 200.0, pixels_per_point: 1.0, camera, sky: false }; @@ -1504,6 +1506,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let camera = rustgis_map::Camera { center: lonlat_to_merc(Coord::new(0.25, -0.1)), res: 300.0, bearing: 0.0, pitch: 0.0 }; let view = crate::View { width: 200.0, height: 200.0, pixels_per_point: 1.0, camera, sky: false }; @@ -1540,6 +1543,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let camera = rustgis_map::Camera { center: lonlat_to_merc(Coord::new(0.35, -0.05)), res: 300.0, bearing: 0.0, pitch: 0.0 }; let view = crate::View { width: 200.0, height: 200.0, pixels_per_point: 1.0, camera, sky: false }; @@ -1587,6 +1591,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; m.view.terrain.as_mut().unwrap().water.as_mut().unwrap().glint = glint; camera.center = lonlat_to_merc(Coord::new(0.35, -0.3)); diff --git a/crates/ui-egui/src/mapview.rs b/crates/ui-egui/src/mapview.rs index b96fc7b918..1679dac726 100644 --- a/crates/ui-egui/src/mapview.rs +++ b/crates/ui-egui/src/mapview.rs @@ -5902,6 +5902,7 @@ mod tests { balanced: false, shadow_softness: None, aerial: 0.0, + terrain_type: 0.0, }; let set = |map: &mut Map, shadow: f64, visible: bool| { let l = map.layer_mut(id).unwrap(); diff --git a/crates/ui-egui/src/panes.rs b/crates/ui-egui/src/panes.rs index 35f06cf0aa..6e94868b89 100644 --- a/crates/ui-egui/src/panes.rs +++ b/crates/ui-egui/src/panes.rs @@ -7528,6 +7528,8 @@ fn raster_symbology(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, t: &Tokens) { balanced, shadow_softness, aerial, + // Not in this pane yet (#3142). + terrain_type: _, } => { use rustgis_engine::map::shadow::{SOFT_EDGE_MAX, SOFT_EDGE_MIN, soft_edge}; let (az, alt, zf, sh, sk, fl) = (*azimuth, *altitude, *z_factor, *shadow, *sky, *fill); diff --git a/docs/maintaining.md b/docs/maintaining.md index 998501f17b..c10fe17765 100644 --- a/docs/maintaining.md +++ b/docs/maintaining.md @@ -122,6 +122,8 @@ diagram cut to a circle or to polygons), `terrain-block-polygon` (one cut to pol `raster.symbology` stores the default as none), `shaded-relief-aerial` (a Shaded Relief's aerial perspective, stored or set by a saved step; 0 and `null` are none), +`shaded-relief-terrain-type` (a Shaded Relief's terrain type, stored as `terrain_type`, left out at +0, or set by a saved step's `"terrain"` on a Shaded Relief, where 0 and `null` light as before), `blank-paper` (a blank basemap's paper colour) and `normalized-legend-urls` for normalized legend addresses. Project requirements include offline map snapshots. `table-export-order` protects saved task commands, diff --git a/schema/fixtures/shaded_relief_terrain_type.rgis b/schema/fixtures/shaded_relief_terrain_type.rgis new file mode 100644 index 0000000000..bb09e9a5eb --- /dev/null +++ b/schema/fixtures/shaded_relief_terrain_type.rgis @@ -0,0 +1 @@ +{"requires":["shaded-relief-terrain-type"],"format":2,"name":"Shaded relief terrain type","maps":[{"name":"Map","layers":[{"id":1,"name":"dem","visible":true,"dataset":{"name":"dem","geometry_type":"None","fields":[],"features":[],"source":null},"renderer":{"Single":{"fill":[224,123,57,170],"stroke":[134,74,34,255],"stroke_width":0.7,"size":0.0,"marker":"Circle"}},"labels":{"enabled":false,"field":"","size":10.0,"color":[43,43,43,255],"halo":true,"bold":false,"min_scale":null,"max_scale":null,"closest":null,"farthest":null,"placement":"Auto"},"transparency":0.0,"min_scale":null,"max_scale":null,"definition_query":null,"selection":[],"expanded":true,"selectable":false,"graphics":false,"blend":"Normal","mask":null,"display_filters":[],"aggregation":null,"extrusion":null,"priority":0,"raster":{"path":"dem.tif","file_name":null,"style":{"renderer":{"ShadedRelief":{"band":0,"ramp":"Terrain","azimuth":315.0,"altitude":45.0,"z_factor":2.0,"terrain_type":0.6}},"stretch":{"PercentClip":{"low":0.5,"high":0.5}},"dra":false,"resampling":"Nearest","brightness":0.0,"contrast":0.0,"gamma":1.0,"rotation":0.0}},"geometry_rev":0}],"basemap":"Paper","camera":{"center":{"x":-4654314.293187932,"y":-2329385.2820357964},"res":64.69445270508425,"bearing":0.0,"pitch":0.0},"bookmarks":[],"graticule":true,"projection":"WebMercator","popup_mode":"Topmost","label_display":{"paused":false,"locked":false,"show_unplaced":false},"editing":{"relationships":[],"snapping":{"enabled":false,"tolerance_px":10.0,"vertex":true,"edge":true,"end":true},"topology":[],"settings":{"enabled":true,"show_vertices":true,"elevation":"None","ground_to_grid":null}},"swipe":null,"view":{"effects":{"stars":true,"sun_time":null,"weather":"None","vignette":false,"edges":false,"tilt_shift":false,"grain":false,"brightness":0.0,"contrast":0.0,"saturation":0.0,"sepia":0.0},"wireframe":false,"clip_distance":null,"terrain":null},"animation":[],"next_layer_id":2}],"active_map":0,"tables":[],"next_table_id":1,"gp_history":[],"layouts":[],"folders":[],"styles":[],"ramps":[],"tasks":[],"gp_env":{"extent":null,"cell_size":null},"models":[],"workspaces":[],"link_views":false,"jobs":[],"offline_areas":[],"reports":[],"presentations":[],"notebooks":[],"dl_models":[],"shared":[],"data_stores":[]} diff --git a/schema/project.schema.json b/schema/project.schema.json index 53ff5df51c..1a5f3cd00f 100644 --- a/schema/project.schema.json +++ b/schema/project.schema.json @@ -1298,7 +1298,8 @@ "layout-publication-parts", "layout-publication-legend", "shaded-relief-shadow-softness", - "shaded-relief-aerial" + "shaded-relief-aerial", + "shaded-relief-terrain-type" ], "type": "string" }, @@ -1425,7 +1426,8 @@ "layout-publication-parts", "layout-publication-legend", "shaded-relief-shadow-softness", - "shaded-relief-aerial" + "shaded-relief-aerial", + "shaded-relief-terrain-type" ], "x-rustgis-reads-format": 2, "x-rustgis-writes-format": 2