Skip to content
Closed
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
16 changes: 2 additions & 14 deletions crates/analysis/src/rasterops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,21 +611,9 @@ fn dist_m(a: Coord, b: Coord) -> f64 {
rustgis_geom::haversine_m(a, b)
}

/// Elevation (bilinear) at a longitude/latitude point.
/// Elevation (bilinear) at a longitude/latitude point ([`Raster::bilinear`]).
pub fn elevation_at(r: &Raster, b: usize, ll: Coord) -> Option<f64> {
let w = r.transformer().from_lonlat(ll)?;
let (x, y) = r.transform.to_pixel(w);
let (x, y) = (x - 0.5, y - 0.5);
let (c0, r0) = (x.floor() as i64, y.floor() as i64);
let (fx, fy) = (x - c0 as f64, y - r0 as f64);
let v = |c: i64, rr: i64| r.value(b, c, rr).map(f64::from);
let (a, b2, c, d) = (v(c0, r0), v(c0 + 1, r0), v(c0, r0 + 1), v(c0 + 1, r0 + 1));
match (a, b2, c, d) {
(Some(a), Some(b2), Some(c), Some(d)) => {
Some(a * (1.0 - fx) * (1.0 - fy) + b2 * fx * (1.0 - fy) + c * (1.0 - fx) * fy + d * fx * fy)
}
_ => v(x.round() as i64, y.round() as i64),
}
r.bilinear(b, ll)
}

/// An elevation profile along a path: (distance from the start in metres, point, elevation).
Expand Down
19 changes: 19 additions & 0 deletions crates/data/src/raster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,25 @@ impl Raster {
if wrapped < w { wrapped } else { c }
}

/// The value of `band` at a longitude/latitude point, read bilinearly between the four cell
/// centres around it, in the raster's own system: the nearest cell's where one of the four is
/// no-data or off the grid, and `None` where that one is too. The elevation profiles read
/// this (`profile.*`, and a layout's profiles beside a map frame, #2863).
pub fn bilinear(&self, band: usize, lonlat: Coord) -> Option<f64> {
let w = self.transformer.from_lonlat(lonlat)?;
let (x, y) = self.transform.to_pixel(w);
let (x, y) = (x - 0.5, y - 0.5);
let (c0, r0) = (x.floor() as i64, y.floor() as i64);
let (fx, fy) = (x - c0 as f64, y - r0 as f64);
let v = |c: i64, r: i64| self.value(band, c, r).map(f64::from);
match (v(c0, r0), v(c0 + 1, r0), v(c0, r0 + 1), v(c0 + 1, r0 + 1)) {
(Some(a), Some(b), Some(c), Some(d)) => {
Some(a * (1.0 - fx) * (1.0 - fy) + b * fx * (1.0 - fy) + c * (1.0 - fx) * fy + d * fx * fy)
}
_ => v(x.round() as i64, y.round() as i64),
}
}

/// Cell size in the raster's units (x, y).
pub fn cell_size(&self) -> (f64, f64) {
(self.transform.pixel_width.abs(), self.transform.pixel_height.abs())
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/command-surface.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ layer.transparency layer? value
layer.visibility layer? visible?
layer.zoomTo layer?
layout.activate name layout
layout.addElement layout? kind frame? of? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? columns? textSize? classLabels? showLayerNames? orientation? ticks? tickSide? reverse? fill? width? radius? dash? dir? head? angle? length? image? path? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? hideLabels? barOutline? rows? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? name? direction? at? outline? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? x? y? w? h? background?
layout.addElement layout? kind frame? of? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? columns? textSize? classLabels? showLayerNames? orientation? ticks? tickSide? reverse? fill? width? radius? dash? dir? head? angle? length? image? path? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? hideLabels? barOutline? rows? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? name? direction? at? section? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? outline? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? x? y? w? h? background?
layout.addFrame layout? shape? points? map? x? y? w? h?
layout.arrange layout? element to
layout.arrangement favourite? save? arrangement? remove?
Expand All @@ -304,7 +304,7 @@ layout.save layout? path
layout.series layout? layer nameField? frame? margin? off?
layout.seriesPage layout? page
layout.seriesRefresh layout?
layout.update layout? element x? y? w? h? name? visible? locked? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? labels? classLabels? columns? textSize? showLayerNames? orientation? ticks? tickSide? reverse? style? fill? outline? radius? width? dash? dir? head? angle? length? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? map? scale? center? bearing? pitch? grid? extentIndicator? border? section? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? barOutline? hideLabels? rows? background?
layout.update layout? element x? y? w? h? name? visible? locked? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? allClasses? hideOther? showNoData? exclude? labels? classLabels? columns? textSize? showLayerNames? orientation? ticks? tickSide? reverse? style? fill? outline? radius? width? dash? dir? head? angle? length? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? map? scale? center? bearing? pitch? grid? extentIndicator? border? section? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? barOutline? hideLabels? rows? background?
locator.find locator? text limit? zoom?
map.activate name
map.addTiles url kind? name? bounds? attribution? minZoom? maxZoom? tileSize? singleImage? tms? subdomains? layers? styleLayers? opacity? blend? resampling? overlay? top? replace? id? view? start? end? unit? interval? dates? legend? connection?
Expand Down
10 changes: 6 additions & 4 deletions crates/engine/src/cmd/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7557,6 +7557,7 @@ fn references_follow_layer(s: &mut Session, old: &str, new: &str) {
replace(layer)
}
ElementKind::Colorbar { frame, layer: Some(layer), .. } if frames.contains(frame) => replace(layer),
ElementKind::Profile(p) if frames.contains(&p.frame) => replace(&mut p.layer),
ElementKind::Text { text, .. } if texts_read_this_map => {
match renamed_statistics(text, rustgis_map::layout::MAX_TEXT_CHARS, braces, &mut replace) {
Renamed::To(renamed) => *text = renamed,
Expand Down Expand Up @@ -7718,10 +7719,10 @@ fn removed_notice(keys: [&'static str; 2], count: usize, named: &[&str]) -> Opti
Some(crate::notice_text::NoticeText::format(key, [("count", count.to_string().into()), ("names", names.into())]))
}

/// After layers called `names` are removed: a table's, chart's or colorbar's layer, and a text's
/// layer statistics (#2853), keep the name, so a layer of that name brings them back, and are drawn
/// without it meanwhile: how many elements, said once. Which elements read the active map is as for
/// a rename (`references_follow_layer`).
/// After layers called `names` are removed: a table's, chart's, colorbar's or profile's layer, and a
/// text's layer statistics (#2853), keep the name, so a layer of that name brings them back, and are
/// drawn without it meanwhile: how many elements, said once. Which elements read the active map is
/// as for a rename (`references_follow_layer`).
fn layouts_follow_removal(s: &mut Session, names: &[String]) {
use rustgis_map::layout::ElementKind;

Expand All @@ -7739,6 +7740,7 @@ fn layouts_follow_removal(s: &mut Session, names: &[String]) {
vec![layer]
}
ElementKind::Colorbar { frame, layer: Some(layer), .. } if frames.contains(frame) => vec![layer],
ElementKind::Profile(p) if frames.contains(&p.frame) => vec![&p.layer],
ElementKind::Text { text, .. } if texts_read_this_map => {
rustgis_map::layout::stat_tokens(text).iter().map(|t| t.layer).collect()
}
Expand Down
Loading
Loading