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
11 changes: 6 additions & 5 deletions crates/analysis/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ fn clip_on(inp: &dyn Inputs, p: &Json, threads: Option<usize>, cache_bytes: Opti
}
r.messages.extend(left.notes("Clip", &clip_ds.name));
if slivers > 0 {
r.messages.push(format!("Clip: {slivers} output feature(s) have less than one millionth of their input feature's area; they may be slivers along the clip boundary (kept unchanged)"));
r.messages.push(format!("Clip: {slivers} output feature(s) have less than one millionth of their input feature's area in the overlay plane; they may be slivers along the clip boundary (kept unchanged)"));
}
Ok(r)
}
Expand Down Expand Up @@ -5171,11 +5171,12 @@ fn ground_area_perimeter(g: &Geometry) -> (f64, f64) {
let polar = ring.0.first().zip(ring.0.last()).is_some_and(|(a, b)| (a.x - b.x).abs() > 180.0);
let orientable = !polar && ring.0.iter().all(|c| c.x.is_finite() && (-90.0..=90.0).contains(&c.y));
let polygon = geo::Polygon::new(ring, vec![]);
// Within a longitude span of 180°, the ring cannot enclose more than a hemisphere.
// Within an unwrapped longitude span of 180°, the ring cannot enclose more than a
// hemisphere.
// Use signed magnitude there: a tiny overlay sliver can have opposite planar and
// geodesic windings, making its unsigned area nearly the whole Earth (#1966).
let wide = polygon.bounding_rect().is_some_and(|bounds| bounds.width() > 180.0);
let (rp, ra) = if orientable && wide {
let wide = orientable && polygon.bounding_rect().is_some_and(|bounds| bounds.width() > 180.0);
let (rp, ra) = if wide {
polygon.orient(Direction::Default).geodesic_perimeter_area_unsigned()
} else {
// Keep smaller local rings and polar caps; invalid coordinates bypass orientation.
Expand Down Expand Up @@ -13415,7 +13416,7 @@ mod tests {
r.messages,
[
"Clip: 2 features kept",
"Clip: 2 output feature(s) have less than one millionth of their input feature's area; they may be slivers along the clip boundary (kept unchanged)",
"Clip: 2 output feature(s) have less than one millionth of their input feature's area in the overlay plane; they may be slivers along the clip boundary (kept unchanged)",
]
);
let out = layer(r);
Expand Down
6 changes: 3 additions & 3 deletions crates/analysis/src/warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ impl Method {
/// Projects `r` onto the grid `g`, through longitude/latitude when their coordinate systems
/// differ: each cell sampled at its centre, or (average, mode) taken from every pixel of `r`
/// whose centre falls in it. A cell no pixel centre falls in (a grid finer than the raster) takes
/// the pixel under its centre. Cells off the raster are its no-data (else NaN, or 0 in a
/// whole-number type), or see-through for a colour image with neither alpha nor no-data, which
/// gains an alpha band for it.
/// the pixel under its centre. Cells off the raster are its no-data (else NaN, or 0 in an
/// unlabelled whole-number type). A band with class names makes outside cells NaN in every band.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new second sentence is stated without its condition. In Canvas::of, outside cells take the raster's no-data value when it has one (outside = r.nodata.map_or(none, …)), so a labelled band with no-data gets that value, not NaN. The NaN case only holds when there is no no-data value.

Suggested change
/// unlabelled whole-number type). A band with class names makes outside cells NaN in every band.
/// unlabelled whole-number type). With class names and no no-data value, outside cells are NaN in every band.

/// A colour image with neither alpha nor no-data gains an alpha band for see-through cells.
pub fn project(r: &Raster, g: &Grid, method: Method, name: String) -> Result<Raster, String> {
project_on(None, r, g, method, name)
}
Expand Down
1 change: 1 addition & 0 deletions crates/analysis/tests/parallel_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ fn outputs(s: &Scene) -> Vec<(String, Made)> {
add("dissolve", tool("dissolve", json!({"input": "polygons", "field": "class", "statistics": stats})));
add("near", tool("near", json!({"input": "points", "near": "polygons"})));
add("convex hull", tool("convexHull", json!({"input": "polygons", "group": "None"})));
add("convex hull all", tool("convexHull", json!({"input": "polygons", "group": "All"})));
add("feature to point", tool("featureToPoint", json!({"input": "polygons"})));
add("simplify", tool("simplify", json!({"input": "polygons", "tolerance": 5})));
add("select by location", tool("selectByLocation", json!({"input": "points", "select": "polygons", "distance": 1})));
Expand Down
Loading