diff --git a/CHANGELOG.md b/CHANGELOG.md index 60cac2ce..676210f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ versions may change the store format and the API; the release notes say how to u ## [Unreleased] +## 0.3.5 - unreleased + +### Security + +- Updates the spreadsheet reader to fix RUSTSEC-2026-0628 (#828). + +### Fixed + +- `st:ST_SnapToGrid` and `st:ST_ReducePrecision` keep Z and M (#783). They dropped Z from a line as soon as a coordinate moved, so rounding a transformed 3D track lost its heights. In a `GEOMETRYCOLLECTION`, `ST_SnapToGrid` left a point unsnapped and `ST_ReducePrecision` gave it a wrong Z taken from the line next to it. Now every member of a collection is snapped alike and each moved coordinate keeps its own Z and M, as in PostGIS. Where snapping merges points, the first one's are kept. When `ST_ReducePrecision` has to add a vertex to keep the result valid, the result has no Z or M rather than an invented one. +- `geof:length(?g, uom:metre)` answers on a projected CRS (#786): GeoSPARQL 1.1's form with a unit was unbound for `geof:length`, `geof:perimeter`, `geof:area` and `geof:size` on every CRS, while `geof:metricLength` and `st:ST_Length` gave the length. They now give the `metric*` value in metres or kilometres (square metres or kilometres for an area); another unit is still unbound. `geof:distance` and `geof:buffer` took a unit already. See [docs/spatial.md](docs/spatial.md). +- `st:ST_LineSubstring`, `st:ST_LineInterpolatePoint` and `st:ST_LineLocatePoint` measure a `MULTILINESTRING` as one line, as the `rail:` functions do (#787): the parts in order, with a gap adding no length. Before, they answered unbound without a message, so a rule silently dropped net elements whose geometry came as touching parts. A substring across a gap is a `MULTILINESTRING`. An empty or non-line input still gives no value. See [the spatial functions](docs/spatial.md). + ## 0.3.4 - 2026-12-03 Fixes for map servers under load: a map tile could take several times the query memory limit, tiles with a text filter read whole collections, and a cold server built all its facet indexes at once. Uncached OGC API items pages are fast again on stores with a geometry path through a parent, and the all-collections tiles take a plain facet filter. Map servers should upgrade. diff --git a/Cargo.lock b/Cargo.lock index c170d622..b2c67da9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -519,12 +519,13 @@ dependencies = [ [[package]] name = "calamine" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f431b67cba6122a1f7d26b7adafc71bbdf07026095fe811f5efc025d8748e1d8" +checksum = "9398389a38765d5f346e2c6fff6515d2b222b3d1578c1177bc2222e9e5f17710" dependencies = [ "atoi_simd", "byteorder", + "cfb", "codepage", "encoding_rs", "fast-float2", @@ -555,6 +556,17 @@ dependencies = [ "nom", ] +[[package]] +name = "cfb" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef29b910ef2b9dbecc60168d1568d643c633b0518af970c17e83bd5f6e2c94f" +dependencies = [ + "fnv", + "uuid", + "web-time", +] + [[package]] name = "cfg-if" version = "1.0.5" @@ -5039,6 +5051,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" +[[package]] +name = "uuid" +version = "1.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "version_check" version = "0.9.5" @@ -5142,6 +5164,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "web_atoms" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index 651bbe43..2ec75cc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ tokio-postgres-rustls = { version = "0.14", default-features = false } rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"] } webpki-roots = "1" csv = "1" -calamine = { version = "0.38", default-features = false } +calamine = { version = "0.39", default-features = false } flate2 = "1" # Pure-Rust bzip2 decoder with no dependencies, for .tar.bz2 archives in Facade-X (MIT). crabz2 = { version = "0.7", default-features = false, features = ["std"] } diff --git a/crates/tripletrail-geo/src/functions.rs b/crates/tripletrail-geo/src/functions.rs index 4ce165e7..2491cdb5 100644 --- a/crates/tripletrail-geo/src/functions.rs +++ b/crates/tripletrail-geo/src/functions.rs @@ -185,6 +185,36 @@ pub(crate) fn same_space(a: &Geom, b: &Geom) -> bool { a.crs == b.crs || (a.crs.is_geographic() && b.crs.is_geographic()) } +/// The geometry and the unit of a measure that takes one (GeoSPARQL 1.1's `geof:length`, +/// `geof:area`, `geof:perimeter`, `geof:size`): `(geometry)` or `(geometry, unit)` (#786). +fn measured(args: &[Term]) -> Option<(&Term, Option<&Term>)> { + match args { + [a] => Some((a, None)), + [a, u] => Some((a, Some(u))), + _ => None, + } +} + +/// Metres in one of a length unit the measures take (metres when none is given), or `None` for +/// a unit they cannot convert to. +fn metres_in(unit: Option<&Term>) -> Option { + match unit_iri(unit)? { + "metre" => Some(1.0), + "kilometre" => Some(1000.0), + _ => None, + } +} + +/// Square metres in one of an area unit: square metres or kilometres, or the metre or +/// kilometre the area is squared from (square metres when no unit is given). +fn square_metres_in(unit: Option<&Term>) -> Option { + match unit_iri(unit)? { + "metre" | "squareMetre" => Some(1.0), + "kilometre" | "squareKilometre" => Some(1e6), + _ => None, + } +} + fn unit_iri(t: Option<&Term>) -> Option<&str> { match t { None => Some("metre"), @@ -847,7 +877,16 @@ pub fn function_table() -> FunctionTable { double(metric_length(&*geom(a)?)) }); add(GEOF, "metricLength", Arc::clone(&metric_len)); - add(GEOF, "length", Arc::clone(&metric_len)); + // GeoSPARQL 1.1's form with a unit (#786), in metres or kilometres on any CRS whose + // length `geof:metricLength` gives. + add( + GEOF, + "length", + func(|args| { + let (a, unit) = measured(args)?; + double(metric_length(&*geom(a)?) / metres_in(unit)?) + }), + ); add(ST, "ST_LengthSpheroid", metric_len); add( ST, @@ -865,10 +904,17 @@ pub fn function_table() -> FunctionTable { let [a] = args else { return None }; double(geom(a)?.metric_area()) }); - add(GEOF, "metricArea", Arc::clone(&metric_area)); - add(GEOF, "area", metric_area); + add(GEOF, "metricArea", metric_area); + add( + GEOF, + "area", + func(|args| { + let (a, unit) = measured(args)?; + double(geom(a)?.metric_area() / square_metres_in(unit)?) + }), + ); // Perimeter: the length of every ring (GeoSPARQL 1.1 geof:perimeter, metricPerimeter). - let perimeter: Func = func(|args| { + let perimeter = |args: &[Term]| -> Option { let [a] = args else { return None }; let g = geom(a)?; let mut rings = Vec::new(); @@ -888,22 +934,40 @@ pub fn function_table() -> FunctionTable { } walk(&g.geometry, &mut push); let rings = Geometry::MultiLineString(geo::MultiLineString(rings)); - double(metric_length(&Geom::new(rings, g.crs.clone()))) - }); - add(GEOF, "metricPerimeter", Arc::clone(&perimeter)); - add(GEOF, "perimeter", perimeter); + Some(metric_length(&Geom::new(rings, g.crs.clone()))) + }; + add( + GEOF, + "metricPerimeter", + func(move |args| double(perimeter(args)?)), + ); + add( + GEOF, + "perimeter", + func(move |args| { + let (a, unit) = measured(args)?; + double(perimeter(std::slice::from_ref(a))? / metres_in(unit)?) + }), + ); // Size: length of curves, area of surfaces, 0 for points (GeoSPARQL 1.1 geof:size). - let size: Func = func(|args| { - let [a] = args else { return None }; + let size = |args: &[Term]| -> Option { + let (a, unit) = measured(args)?; let g = geom(a)?; - double(match g.geometry.dimensions() { - Dimensions::TwoDimensional => g.metric_area(), - Dimensions::OneDimensional => metric_length(&g), + Some(match g.geometry.dimensions() { + Dimensions::TwoDimensional => g.metric_area() / square_metres_in(unit)?, + Dimensions::OneDimensional => metric_length(&g) / metres_in(unit)?, _ => 0.0, }) - }); - add(GEOF, "metricSize", Arc::clone(&size)); - add(GEOF, "size", size); + }; + add( + GEOF, + "metricSize", + func(move |args| { + let [_] = args else { return None }; + double(size(args)?) + }), + ); + add(GEOF, "size", func(move |args| double(size(args)?))); add( ST, "ST_Area", @@ -1241,7 +1305,11 @@ pub fn function_table() -> FunctionTable { let Geometry::Point(p) = p.geometry else { return None; }; - double(as_linestring(&l.geometry)?.line_locate_point(&p)?) + match &l.geometry { + // Measured as one line, as the `rail:` functions measure it (#787). + Geometry::MultiLineString(_) => double(crate::rail::multi_line_locate(&l, p.0)?), + g => double(as_linestring(g)?.line_locate_point(&p)?), + } }), ); add( @@ -1254,7 +1322,10 @@ pub fn function_table() -> FunctionTable { if !(0.0..=1.0).contains(&f) { return None; } - let p = Euclidean.point_at_ratio_from_start(as_linestring(&g.geometry)?, f)?; + let p = match &g.geometry { + Geometry::MultiLineString(_) => Point(crate::rail::multi_line_point(&g, f)?), + l => Euclidean.point_at_ratio_from_start(as_linestring(l)?, f)?, + }; Some(wkt_literal(&Geometry::Point(p), &g.crs)) }), ); @@ -1264,10 +1335,17 @@ pub fn function_table() -> FunctionTable { func(|args| { let [l, a, b] = args else { return None }; let g = geom(l)?; - Some(wkt_literal( - &line_substring(as_linestring(&g.geometry)?, num(a)?, num(b)?)?, - &g.crs, - )) + let (a, b) = (num(a)?, num(b)?); + let piece = match &g.geometry { + Geometry::MultiLineString(_) => { + if !(0.0..=1.0).contains(&a) || !(0.0..=1.0).contains(&b) || a > b { + return None; + } + crate::rail::multi_line_substring(&g, a, b)? + } + l => line_substring(as_linestring(l)?, a, b)?, + }; + Some(wkt_literal(&piece, &g.crs)) }), ); crate::geosparql11::add_functions(&mut add); @@ -1648,6 +1726,133 @@ mod tests { assert!((pl - 566.0).abs() < 10.0, "{pl}"); } + /// GeoSPARQL 1.1's measures with a unit (#786) answer on a projected CRS and on CRS84 as + /// their `metric*` forms do, in kilometres too; a unit they cannot convert to is unbound. + #[test] + fn measures_with_a_unit_answer_on_projected_and_geographic_crss() { + let unit = |u: &str| Term::from(NamedNode::new_unchecked(format!("{UOM}{u}"))); + let g = |name: &str| format!("{GEOF}{name}"); + let utm = " "; + let crs84 = " "; + for crs in [utm, crs84] { + let (line, square, point) = if crs == utm { + ( + wkt(&format!( + "{crs}LINESTRING(597000 6643000, 597100 6643000, 597100 6643100)" + )), + wkt(&format!( + "{crs}POLYGON((597000 6643000, 597100 6643000, 597100 6643100, 597000 6643100, 597000 6643000))" + )), + wkt(&format!("{crs}POINT(597000 6643000)")), + ) + } else { + ( + wkt(&format!( + "{crs}LINESTRING(10.7 59.9, 10.702 59.9, 10.702 59.901)" + )), + wkt(&format!( + "{crs}POLYGON((10.7 59.9, 10.702 59.9, 10.702 59.901, 10.7 59.901, 10.7 59.9))" + )), + wkt(&format!("{crs}POINT(10.7 59.9)")), + ) + }; + let close = |a: f64, b: f64| (a - b).abs() <= b.abs() * 1e-9 + 1e-9; + let cases = [ + ( + "length", + "metricLength", + &line, + ["metre", "kilometre"], + 1000.0, + ), + ( + "perimeter", + "metricPerimeter", + &square, + ["metre", "kilometre"], + 1000.0, + ), + ( + "area", + "metricArea", + &square, + ["squareMetre", "squareKilometre"], + 1e6, + ), + ("area", "metricArea", &square, ["metre", "kilometre"], 1e6), + ("size", "metricSize", &line, ["metre", "kilometre"], 1000.0), + ( + "size", + "metricSize", + &square, + ["squareMetre", "squareKilometre"], + 1e6, + ), + ]; + for (name, metric, geometry, [base, large], factor) in cases { + let want = f(call(&g(metric), std::slice::from_ref(geometry))); + assert!(want > 0.0, "{crs}{name}"); + let at = format!("{crs}{name} {base}"); + assert!( + close(f(call(&g(name), std::slice::from_ref(geometry))), want), + "{at}" + ); + assert!( + close(f(call(&g(name), &[geometry.clone(), unit(base)])), want), + "{at}" + ); + assert!( + close( + f(call(&g(name), &[geometry.clone(), unit(large)])), + want / factor + ), + "{at}" + ); + assert_eq!( + call(&g(name), &[geometry.clone(), unit("radian")]), + None, + "{at}" + ); + } + if crs == utm { + // The issue's example: 200 m. + assert!(close( + f(call(&g("length"), &[line.clone(), unit("metre")])), + 200.0 + )); + assert!(close( + f(call(&g("area"), &[square.clone(), unit("squareMetre")])), + 10_000.0 + )); + } + assert!(close( + f(call(&g("size"), &[point.clone(), unit("metre")])), + 0.0 + )); + // Distance and buffer took a unit already, on both CRSs. + let d = f(call( + &g("distance"), + &[point.clone(), line.clone(), unit("metre")], + )); + assert!(d.abs() < 1e-6, "{crs}{d}"); + assert!( + call( + &g("buffer"), + &[point.clone(), Literal::from(10.0).into(), unit("metre")] + ) + .is_some(), + "{crs}" + ); + assert_eq!( + call( + &g("distance"), + &[point.clone(), line.clone(), unit("radian")] + ), + None + ); + } + } + #[test] fn projected_distances_are_in_metres_whatever_the_crs_unit() { // EPSG:2263 (NAD83 / New York Long Island) is in US survey feet. Reference: PROJ 9 diff --git a/crates/tripletrail-geo/src/postgis_processing.rs b/crates/tripletrail-geo/src/postgis_processing.rs index ea5722d2..466c868d 100644 --- a/crates/tripletrail-geo/src/postgis_processing.rs +++ b/crates/tripletrail-geo/src/postgis_processing.rs @@ -117,6 +117,29 @@ pub(crate) fn remove_repeated(c: &[Coord], tol: f64, ring: bool) -> Vec) -> Coord, +) -> (Geometry, Option) { + let moved = map_lines(&geo::MapCoords::map_coords(&g.geometry, &f), &|c, ring| { + remove_repeated(c, 0.0, ring) + }); + let zm = g.zm.as_deref().filter(|z| z.has_z || z.has_m).map(|zm| { + Zm::from_pairs( + zm.has_z, + zm.has_m, + g.geometry + .coords_iter() + .filter_map(|c| Some((f(c), zm.at(c)?))), + ) + }); + (moved, zm) +} + fn snap_coord(c: Coord, origin: Coord, size: Coord) -> Coord { let snap = |v: f64, o: f64, s: f64| { if s > 0.0 { @@ -1694,14 +1717,8 @@ pub(crate) fn add_functions(add: &mut dyn FnMut(&str, &str, Func)) { _ => return None, }; let g = geom(a)?; - let snapped = match &g.geometry { - Geometry::Point(p) => Geometry::Point(Point(snap_coord(p.0, origin, size))), - other => map_lines(other, &|c, ring| { - let c: Vec<_> = c.iter().map(|&c| snap_coord(c, origin, size)).collect(); - remove_repeated(&c, 0.0, ring) - }), - }; - out(snapped, &g.crs) + let (snapped, zm) = move_keeping_zm(&g, |c| snap_coord(c, origin, size)); + out_zm(snapped, g.crs.clone(), zm) }), ); add( diff --git a/crates/tripletrail-geo/src/postgis_zm.rs b/crates/tripletrail-geo/src/postgis_zm.rs index 6308477a..0e005e9d 100644 --- a/crates/tripletrail-geo/src/postgis_zm.rs +++ b/crates/tripletrail-geo/src/postgis_zm.rs @@ -6,7 +6,8 @@ use crate::functions::{Func, GEOF, ST, boolean, double, func, geom, integer, num use crate::literal::{Crs, Geom, Zm, geom_literal}; use crate::postgis::{crs_of_srid, envelope, int, out, polygon, string}; use crate::postgis_processing::{ - lines_of, make_valid, map_lines, offset_curve, out_zm, polygons_of, remove_repeated, + lines_of, make_valid, map_lines, move_keeping_zm, offset_curve, out_zm, polygons_of, + remove_repeated, }; use geo::line_measures::{Distance, Euclidean, Length}; use geo::{ @@ -1575,14 +1576,13 @@ pub(crate) fn add_functions(add: &mut dyn FnMut(&str, &str, Func)) { let s = num(size)?; (s > 0.0).then_some(())?; let scale = 1.0 / s; - let snapped = g.geometry.map_coords(|c| Coord { + let (snapped, zm) = move_keeping_zm(&g, |c| Coord { x: (c.x * scale).round() / scale, y: (c.y * scale).round() / scale, }); - let cleaned = map_lines(&snapped, &|pts: &[Coord], ring: bool| { - remove_repeated(pts, 0.0, ring) - }); - out(make_valid(&cleaned)?, &g.crs) + // A vertex that making the result valid adds has no Z or M of its own: the result + // is then written without them rather than with invented ones. + out_zm(make_valid(&snapped)?, g.crs.clone(), zm) }), ); add( diff --git a/crates/tripletrail-geo/src/rail.rs b/crates/tripletrail-geo/src/rail.rs index 3436b6ac..0e488d7c 100644 --- a/crates/tripletrail-geo/src/rail.rs +++ b/crates/tripletrail-geo/src/rail.rs @@ -56,6 +56,15 @@ struct Measured { impl Measured { fn new(g: &Geom) -> Option { + Self::measure(g, g.crs.is_geographic()) + } + + /// Measures in the plane, in the units of the CRS, whatever the CRS (the `st:` functions). + fn planar(g: &Geom) -> Option { + Self::measure(g, false) + } + + fn measure(g: &Geom, geographic: bool) -> Option { let parts: Vec>> = lines_of(&g.geometry) .into_iter() .map(|l| l.0) @@ -69,7 +78,6 @@ impl Measured { { return None; } - let geographic = g.crs.is_geographic(); let mut segs = Vec::new(); let mut vertex_at = Vec::new(); let mut walked = 0.0; @@ -713,6 +721,39 @@ pub fn conflate( // --- Functions ----------------------------------------------------------------------------- +// --- A multi-line as one line, for the `st:` linear referencing functions ----------------- + +/// The parts of a `MULTILINESTRING` measured in the plane as one line, in order; a gap between +/// two parts adds no length. `None` for any other geometry and for an empty one. +fn planar_multi_line(g: &Geom) -> Option { + matches!(g.geometry, Geometry::MultiLineString(_)) + .then(|| Measured::planar(g)) + .flatten() +} + +/// `ST_LineLocatePoint` on a `MULTILINESTRING`: the fraction of its length nearest to `c`. +pub(crate) fn multi_line_locate(g: &Geom, c: Coord) -> Option { + let m = planar_multi_line(g)?; + Some(if m.total > 0.0 { + m.locate(c) / m.total + } else { + 0.0 + }) +} + +/// `ST_LineInterpolatePoint` on a `MULTILINESTRING`: the point at fraction `f` of its length. +pub(crate) fn multi_line_point(g: &Geom, f: f64) -> Option> { + let m = planar_multi_line(g)?; + Some(m.point_at(f * m.total).0) +} + +/// `ST_LineSubstring` on a `MULTILINESTRING`: the line between fractions `f1 <= f2` of its +/// length, one line per run of touching parts (a `MULTILINESTRING` when it spans a gap). +pub(crate) fn multi_line_substring(g: &Geom, f1: f64, f2: f64) -> Option> { + let m = planar_multi_line(g)?; + lines_result(m.substring(f1 * m.total, f2 * m.total)) +} + /// The line and, for a second geometry, that geometry in the line's CRS. fn line_arg(t: &Term) -> Option<(Arc, Measured)> { let g = geom(t)?; diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/VERSION b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/VERSION new file mode 100644 index 00000000..42045aca --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/VERSION @@ -0,0 +1 @@ +0.3.4 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg.networks/ecde92f9b11a525e.net b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg.networks/ecde92f9b11a525e.net new file mode 100644 index 00000000..ade7beb6 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg.networks/ecde92f9b11a525e.net differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg.networks/generation b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg.networks/generation new file mode 100644 index 00000000..d8263ee9 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg.networks/generation @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/CURRENT b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/CURRENT new file mode 100644 index 00000000..0cfbf088 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/CURRENT @@ -0,0 +1 @@ +2 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/FORMAT b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/FORMAT new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/FORMAT @@ -0,0 +1 @@ +1 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/RETIRED b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/RETIRED new file mode 100644 index 00000000..207e22d4 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/RETIRED @@ -0,0 +1,2 @@ +0 16 +1 19803 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/TIMELINE b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/TIMELINE new file mode 100644 index 00000000..dbe62615 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/TIMELINE @@ -0,0 +1 @@ +cd2cf5c0ba7fab3a3927fdd7f4488c2e diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/checksums b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/checksums new file mode 100644 index 00000000..b8fc7755 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/checksums @@ -0,0 +1,16 @@ +dict.bin 84008 1f803b7f +dict.idx 46848 5441c35d +geoms.bin 40 9e723d74 +dict-1.bin 2536 75bfef42 +dict-1.idx 1320 55ce3fca +stats.bin 1686960 ff152545 +namespaces.bin 206 9e7a3f8f +spog.seg 40488 1860f1c3 +posg.seg 26456 9596bad3 +ospg.seg 33504 1b46b27f +gspo.seg 40520 f2806194 +gpos.seg 26432 ca6c8377 +gosp.seg 33344 f827d71b +psog.seg 26232 a79db389 +gpso.seg 26208 0325857d +geoms-1.bin 88 4aa5d307 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/compact-keys b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/compact-keys new file mode 100644 index 00000000..e69de29b diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict-1.bin b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict-1.bin new file mode 100644 index 00000000..8b0c487e Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict-1.bin differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict-1.idx b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict-1.idx new file mode 100644 index 00000000..44f37679 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict-1.idx differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict.bin b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict.bin new file mode 100644 index 00000000..d24e1973 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict.bin differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict.idx b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict.idx new file mode 100644 index 00000000..d2a9ae4c Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/dict.idx differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/geoms-1.bin b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/geoms-1.bin new file mode 100644 index 00000000..32c71593 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/geoms-1.bin differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/geoms.bin b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/geoms.bin new file mode 100644 index 00000000..a272d716 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/geoms.bin differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gosp.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gosp.seg new file mode 100644 index 00000000..ea0d6885 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gosp.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gpos.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gpos.seg new file mode 100644 index 00000000..dcabb2eb Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gpos.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gpso.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gpso.seg new file mode 100644 index 00000000..1ab1d7e3 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gpso.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gspo.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gspo.seg new file mode 100644 index 00000000..a2b59476 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/gspo.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/namespaces.bin b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/namespaces.bin new file mode 100644 index 00000000..3503c05c Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/namespaces.bin differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/ospg.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/ospg.seg new file mode 100644 index 00000000..ab1673dd Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/ospg.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/posg.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/posg.seg new file mode 100644 index 00000000..6f2a1e4f Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/posg.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/psog.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/psog.seg new file mode 100644 index 00000000..5fd51a9f Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/psog.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/spog.seg b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/spog.seg new file mode 100644 index 00000000..5152be3f Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/spog.seg differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/stats.bin b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/stats.bin new file mode 100644 index 00000000..3046cd52 Binary files /dev/null and b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/checkpoint-2/stats.bin differ diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/render-wkt b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/render-wkt new file mode 100644 index 00000000..e69de29b diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/wal-1.log b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/wal-1.log new file mode 100644 index 00000000..66121c49 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/wal-1.log @@ -0,0 +1,175 @@ ++ . ++ "27"^^ . ++ . ++ "Maintenance note 44" . +- "3"^^ . ++ . ++ "13"^^ . ++ "Maintenance note 45" . ++ . ++ "3"^^ . ++ "12"^^ . ++ "11"^^ . ++ "Maintenance note 12" . ++ "24"^^ . ++ "Maintenance note 26" . ++ "Maintenance note 36" . ++ "37"^^ . ++ "36"^^ . ++ "40"^^ . +- "17"^^ . +- "19"^^ . ++ . ++ "49"^^ . ++ "10"^^ . +- "14"^^ . ++ "28"^^ . ++ . +- "18"^^ . ++ "48"^^ . ++ "47"^^ . ++ . ++ . ++ . ++ "33"^^ . ++ "Maintenance note 6" . ++ "Maintenance note 30" . ++ "32"^^ . ++ . ++ "18"^^ . ++ . ++ "Maintenance note 10" . ++ "Maintenance note 7" . ++ "Maintenance note 18" . ++ . +- "2"^^ . ++ "Maintenance note 34" . ++ "5"^^ . ++ "Maintenance note 38" . +- "5"^^ . +- "1"^^ . ++ "Maintenance note 22" . ++ "9"^^ . ++ "Maintenance note 5" . ++ . ++ "2"^^ . ++ . ++ . ++ "Maintenance note 19" . ++ "Maintenance note 25" . ++ "31"^^ . ++ "Maintenance note 35" . ++ "41"^^ . ++ "43"^^ . +- "0"^^ . ++ . +- "8"^^ . +- "11"^^ . ++ "14"^^ . ++ "Maintenance note 13" . ++ "17"^^ . ++ "45"^^ . ++ . ++ . ++ . ++ "Maintenance note 24" . ++ "46"^^ . ++ "20"^^ . ++ . ++ "44"^^ . ++ "Maintenance note 21" . ++ "26"^^ . ++ . ++ "Maintenance note 27" . ++ "Maintenance note 2" . ++ "Maintenance note 3" . ++ . ++ "Maintenance note 40" . ++ "0"^^ . ++ "Maintenance note 41" . ++ "Maintenance note 46" . ++ "Maintenance note 32" . ++ "Maintenance note 11" . +- "4"^^ . ++ . ++ "30"^^ . ++ "23"^^ . ++ "25"^^ . ++ "Maintenance note 4" . ++ "Maintenance note 29" . ++ "Maintenance note 37" . ++ "Maintenance note 0" . ++ "Maintenance note 9" . ++ . +- "6"^^ . ++ . ++ "39"^^ . +- "7"^^ . ++ "8"^^ . ++ . ++ . ++ "Maintenance note 28" . ++ . ++ . ++ "34"^^ . ++ . ++ "1"^^ . +- "9"^^ . ++ . ++ . +- "12"^^ . ++ "Maintenance note 49" . ++ . ++ "15"^^ . ++ . ++ . ++ . ++ . ++ "Maintenance note 8" . ++ "Maintenance note 43" . ++ "Maintenance note 47" . ++ "Maintenance note 33" . +- "10"^^ . ++ "4"^^ . +- "15"^^ . ++ "16"^^ . ++ "Maintenance note 20" . ++ "22"^^ . ++ "Service area" . ++ "Maintenance note 17" . ++ . ++ . ++ . ++ "29"^^ . ++ "Maintenance note 39" . ++ "Maintenance note 16" . ++ "Maintenance note 42" . ++ "38"^^ . ++ "6"^^ . ++ "Maintenance note 31" . ++ . ++ "21"^^ . ++ . ++ "Maintenance note 48" . ++ . +- "13"^^ . ++ . ++ . +- "16"^^ . ++ "42"^^ . ++ "Maintenance note 1" . ++ . ++ "Maintenance note 14" . ++ "35"^^ . ++ "7"^^ . ++ . ++ . ++ . ++ . ++ . ++ "Maintenance note 15" . ++ "19"^^ . ++ "Maintenance note 23" . ++ . ++ "POLYGON((4.2150 50.0950, 4.2135 50.1138, 4.2091 50.1321, 4.2019 50.1495, 4.1921 50.1655, 4.1799 50.1799, 4.1655 50.1921, 4.1495 50.2019, 4.1321 50.2091, 4.1138 50.2135, 4.0950 50.2150, 4.0762 50.2135, 4.0579 50.2091, 4.0405 50.2019, 4.0245 50.1921, 4.0101 50.1799, 3.9979 50.1655, 3.9881 50.1495, 3.9809 50.1321, 3.9765 50.1138, 3.9750 50.0950, 3.9765 50.0762, 3.9809 50.0579, 3.9881 50.0405, 3.9979 50.0245, 4.0101 50.0101, 4.0245 49.9979, 4.0405 49.9881, 4.0579 49.9809, 4.0762 49.9765, 4.0950 49.9750, 4.1138 49.9765, 4.1321 49.9809, 4.1495 49.9881, 4.1655 49.9979, 4.1799 50.0101, 4.1921 50.0245, 4.2019 50.0405, 4.2091 50.0579, 4.2135 50.0762, 4.2150 50.0950))"^^ . +C 1796259142861 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/wal-2.log b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/data/kg/wal-2.log new file mode 100644 index 00000000..e69de29b diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/counts.csv b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/counts.csv new file mode 100644 index 00000000..f9eb6cba --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/counts.csv @@ -0,0 +1,3 @@ +g,n +http://example.org/up/meta,3 +default,6696 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/route.csv b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/route.csv new file mode 100644 index 00000000..8b2e4a04 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/route.csv @@ -0,0 +1,12 @@ +seq,node,agg_cost +1,http://example.org/up/s0_0,0 +2,http://example.org/up/s1_0,1000 +3,http://example.org/up/s2_0,2001 +4,http://example.org/up/s3_0,3003 +5,http://example.org/up/s4_0,4006 +6,http://example.org/up/s4_1,5010 +7,http://example.org/up/s4_2,6024 +8,http://example.org/up/s4_3,7048 +9,http://example.org/up/s4_4,8082 +10,http://example.org/up/s4_5,9126 +11,http://example.org/up/s4_6,10180 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/search.csv b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/search.csv new file mode 100644 index 00000000..13b9da71 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/search.csv @@ -0,0 +1,3 @@ +q,n +hal*,342 +junction,58 diff --git a/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/spatial.csv b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/spatial.csv new file mode 100644 index 00000000..ab9e4457 --- /dev/null +++ b/crates/tripletrail-server/tests/upgrade/fixtures/0.3.4/expected/spatial.csv @@ -0,0 +1,7 @@ +s +http://example.org/up/s5_5 +http://example.org/up/s5_6 +http://example.org/up/s6_5 +http://example.org/up/s6_6 +http://example.org/up/s7_5 +http://example.org/up/s7_6 diff --git a/crates/tripletrail-server/tests/upgrade/formats.tsv b/crates/tripletrail-server/tests/upgrade/formats.tsv index a8e8a319..1865b80a 100644 --- a/crates/tripletrail-server/tests/upgrade/formats.tsv +++ b/crates/tripletrail-server/tests/upgrade/formats.tsv @@ -7,3 +7,4 @@ 0.3.1 1 0.3.2 1 0.3.3 1 +0.3.4 1 diff --git a/crates/tripletrail/tests/geosparql11.rs b/crates/tripletrail/tests/geosparql11.rs index c300f3fe..bc7c43ae 100644 --- a/crates/tripletrail/tests/geosparql11.rs +++ b/crates/tripletrail/tests/geosparql11.rs @@ -385,3 +385,27 @@ fn dggs_cells() { None ); } + +/// `geof:length` and the other measures with a unit answer on a projected CRS (#786), as +/// `geof:metricLength` and `st:ST_Length` do. +#[test] +fn measures_with_a_unit_on_a_projected_crs() { + let e = Engine::new().unwrap(); + let line = wkt( + " LINESTRING(597000 6643000, 597100 6643000, 597100 6643100)", + ); + let uom = " f64 { + value(&e, expr) + .unwrap_or_else(|| panic!("{expr} is unbound")) + .parse() + .unwrap() + }; + assert_eq!(num(&format!("geof:length({line}, {uom}metre>)")), 200.0); + assert_eq!(num(&format!("geof:length({line}, {uom}kilometre>)")), 0.2); + assert_eq!(num(&format!("geof:metricLength({line})")), 200.0); + assert_eq!( + value(&e, &format!("geof:length({line}, {uom}radian>)")), + None + ); +} diff --git a/crates/tripletrail/tests/postgis_processing.rs b/crates/tripletrail/tests/postgis_processing.rs index 3f37f026..56088ba8 100644 --- a/crates/tripletrail/tests/postgis_processing.rs +++ b/crates/tripletrail/tests/postgis_processing.rs @@ -526,3 +526,142 @@ fn aggregates() { "GEOMETRYCOLLECTION(POINT(0 0),POINT(2 1))" ); } + +/// `ST_LineSubstring`, `ST_LineInterpolatePoint` and `ST_LineLocatePoint` measure a +/// `MULTILINESTRING` as one line, its parts in order, a gap adding no length (#787). +#[test] +fn linear_referencing_measures_a_multi_line_as_one_line() { + let e = Engine::new().unwrap(); + let utm = " "; + let touching = wkt(&format!("{utm}MULTILINESTRING((0 0,10 0),(10 0,20 0))")); + let gap = wkt("MULTILINESTRING((0 0,10 0),(20 0,30 0))"); + let single = wkt("MULTILINESTRING((0 0,10 0))"); + check( + &e, + &[ + // Parts that touch: one line, keeping the vertex where they meet, as a vertex of a + // line is kept. + ( + format!("st:ST_LineSubstring({touching}, 0.25, 0.75)"), + Some(" LINESTRING(5 0,10 0,15 0)"), + ), + ( + format!("st:ST_LineInterpolatePoint({touching}, 0.75)"), + Some(" POINT(15 0)"), + ), + ( + format!( + "str(st:ST_LineLocatePoint({touching}, {}))", + wkt(&format!("{utm}POINT(15 3)")) + ), + Some("0.75"), + ), + // A gap adds no length: the piece across it is a MULTILINESTRING. + ( + format!("st:ST_LineSubstring({gap}, 0.25, 0.75)"), + Some("MULTILINESTRING((5 0,10 0),(20 0,25 0))"), + ), + ( + format!("st:ST_LineInterpolatePoint({gap}, 0.5)"), + Some("POINT(10 0)"), + ), + ( + format!("st:ST_LineInterpolatePoint({gap}, 0.6)"), + Some("POINT(22 0)"), + ), + ( + format!("str(st:ST_LineLocatePoint({gap}, {}))", wkt("POINT(25 1)")), + Some("0.75"), + ), + // One part: as the line itself. + ( + format!("st:ST_LineSubstring({single}, 0.25, 0.75)"), + Some("LINESTRING(2.5 0,7.5 0)"), + ), + ( + format!("st:ST_LineInterpolatePoint({single}, 0.5)"), + Some("POINT(5 0)"), + ), + // An empty multi-line, another geometry and fractions out of order stay unbound. + ( + format!( + "st:ST_LineSubstring({}, 0.25, 0.75)", + wkt("MULTILINESTRING EMPTY") + ), + None, + ), + ( + format!( + "st:ST_LineInterpolatePoint({}, 0.5)", + wkt("POLYGON((0 0,1 0,1 1,0 0))") + ), + None, + ), + (format!("st:ST_LineSubstring({touching}, 0.75, 0.25)"), None), + ], + ); +} + +/// `ST_SnapToGrid` and `ST_ReducePrecision` move X and Y and keep Z and M, for every member of +/// a collection (#783). +#[test] +fn snapping_keeps_z_and_m() { + let e = Engine::new().unwrap(); + let utm = " "; + for f in ["ST_SnapToGrid", "ST_ReducePrecision"] { + check( + &e, + &[ + // 2D. + ( + format!("st:{f}({}, 0.001)", wkt("LINESTRING(1.12345 2, 3 4.00049)")), + Some("LINESTRING(1.123 2,3 4)"), + ), + // Z, in a projected CRS and in CRS84. + ( + format!( + "st:{f}({}, 0.001)", + wkt(&format!( + "{utm}LINESTRING Z(597000.12345 6643000 1.5, 597100 6643000 2.5)" + )) + ), + Some( + " \ + LINESTRING Z(597000.123 6643000 1.5,597100 6643000 2.5)", + ), + ), + ( + format!( + "st:{f}({}, 0.00000001)", + wkt("LINESTRING Z(10.734629822 59.913063647 1.5, \ + 10.736417144 59.913040116 2.5)") + ), + Some("LINESTRING Z(10.73462982 59.91306365 1.5,10.73641714 59.91304012 2.5)"), + ), + // A point and a line in a collection: the point is snapped and keeps its Z. + ( + format!( + "st:{f}({}, 0.001)", + wkt(&format!( + "{utm}GEOMETRYCOLLECTION Z(LINESTRING Z(597000 6643000 1, \ + 597100 6643000 2), POINT Z(597000.12345 6643000 3))" + )) + ), + Some( + " GEOMETRYCOLLECTION Z(\ + LINESTRING Z(597000 6643000 1,597100 6643000 2),\ + POINT Z(597000.123 6643000 3))", + ), + ), + // M, and a repeated point after snapping keeps the first one's ordinates. + ( + format!( + "st:{f}({}, 0.5)", + wkt("LINESTRING ZM(0 0 1 10, 0.1 0 2 20, 2.2 0 3 30)") + ), + Some("LINESTRING ZM(0 0 1 10,2 0 3 30)"), + ), + ], + ); + } +} diff --git a/docs/spatial.md b/docs/spatial.md index b119ac09..a810fad0 100644 --- a/docs/spatial.md +++ b/docs/spatial.md @@ -67,6 +67,13 @@ asserts one of them for a subject, the asserted value is used instead. `ST_Intersection`, `ST_Union`, `ST_Difference`, `ST_SymDifference`, `ST_Simplify`, `ST_Reverse`, `ST_ClosestPoint`, `ST_LineLocatePoint`, `ST_LineInterpolatePoint`, `ST_LineSubstring`. +`ST_LineLocatePoint`, `ST_LineInterpolatePoint` and `ST_LineSubstring` also take a +`MULTILINESTRING`, where PostGIS raises an error. They measure it as one line, as the `rail:` +functions do: the parts in their order, with a gap between two parts adding no length. A substring +across a gap is a `MULTILINESTRING`, one line for each run of touching parts. Parts that are out +of order are not reordered. An empty multi-line, any geometry other than a line, and fractions +outside 0 to 1 or in the wrong order give no value (unbound). + More PostGIS functions: - Accessors: `ST_GeometryType`, `GeometryType`, `ST_SRID`, `ST_NumPoints`, `ST_PointN`, @@ -101,7 +108,8 @@ More PostGIS functions: `ST_IsPolygonCW`, `ST_IsPolygonCCW`, `ST_ContainsProperly`, `ST_RelateMatch`, `ST_PointInsideCircle`, `ST_Angle`, `ST_LongestLine`, `ST_Length2D`, `ST_Perimeter2D`. - More editors: `ST_ForceCollection`, `ST_ForceRHR`, `ST_SwapOrdinates` (x and y), - `ST_RemoveRepeatedPoints`, `ST_SnapToGrid`, `ST_Snap` (to vertices, else to segments), + `ST_RemoveRepeatedPoints`, `ST_SnapToGrid` (X and Y, keeping Z and M, for every member of a + collection), `ST_Snap` (to vertices, else to segments), `ST_Affine` (the 2-D part of the 3-D form), `ST_TransScale`, `ST_ShiftLongitude`. - Validation and processing: `ST_MakeValid`, `ST_SimplifyPreserveTopology` (Douglas-Peucker, keeping a part as it is where simplifying would make it invalid), `ST_OrientedEnvelope`, @@ -152,7 +160,8 @@ More PostGIS functions: (constrained Delaunay), `ST_Hexagon`, `ST_Square`. - More editors: `ST_CollectionHomogenize`, `ST_ForceSFS`, `ST_Scroll`, `ST_Normalize`, `ST_LineExtend`, `ST_RemoveSmallParts`, `ST_RemoveIrrelevantPointsForView`, - `ST_QuantizeCoordinates`, `ST_ReducePrecision`, `ST_WrapX`. + `ST_QuantizeCoordinates`, `ST_ReducePrecision` (X and Y, keeping Z and M; a vertex added to + keep the result valid leaves it without them), `ST_WrapX`. - More formats and accessors: `ST_AsTWKB`, `ST_GeomFromTWKB`, `ST_PointFromWKB`, `ST_LineFromWKB`, `ST_LinestringFromWKB`, `ST_GeogFromWKB`, `ST_GeogFromText`, `ST_GeographyFromText`, `ST_NumInteriorRing`, `ST_MemSize`, `ST_Summary`, and `geof:latitude`, @@ -272,6 +281,14 @@ definition gives (`+units` or `+to_meter`: US survey feet for EPSG:2263, say). A not known (one `geof:transform` cannot convert either, or a unit PROJ does not list) gives no value rather than a number in the wrong unit. `st:ST_Distance` and `st:ST_DWithin` stay in the CRS's unit, as in PostGIS. + +GeoSPARQL 1.1's measures with a unit, `geof:length(?g, uom:metre)`, `geof:perimeter`, +`geof:area` and `geof:size`, give what `geof:metricLength`, `metricPerimeter`, `metricArea` and +`metricSize` give, on a projected CRS as on CRS84 (#786; before, the form with a unit was +unbound): lengths in `uom:metre` or `uom:kilometre`, areas in `uom:squareMetre` or +`uom:squareKilometre` (or `uom:metre` and `uom:kilometre`, squared). Without a unit they are in +metres and square metres. Another unit gives no value, as for `geof:distance` (which also takes +`uom:degree` on a geographic CRS) and `geof:buffer`. `geof:transform` converts between CRS84, EPSG:4326, EPSG:3857 (Web Mercator), UTM (EPSG:326zz, 327zz and ETRS89 258zz), EPSG:3006 (SWEREF99 TM) and EPSG:3035 (ETRS89-LAEA), computed in TripleTrail, and 65 national and regional CRSs through `proj4rs` (pure Rust, no PROJ library): diff --git a/python/Cargo.lock b/python/Cargo.lock index bcd049e1..9f279592 100644 --- a/python/Cargo.lock +++ b/python/Cargo.lock @@ -311,12 +311,13 @@ checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c" [[package]] name = "calamine" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f431b67cba6122a1f7d26b7adafc71bbdf07026095fe811f5efc025d8748e1d8" +checksum = "9398389a38765d5f346e2c6fff6515d2b222b3d1578c1177bc2222e9e5f17710" dependencies = [ "atoi_simd", "byteorder", + "cfb", "codepage", "encoding_rs", "fast-float2", @@ -347,6 +348,17 @@ dependencies = [ "nom", ] +[[package]] +name = "cfb" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef29b910ef2b9dbecc60168d1568d643c633b0518af970c17e83bd5f6e2c94f" +dependencies = [ + "fnv", + "uuid", + "web-time", +] + [[package]] name = "cfg-if" version = "1.0.5" @@ -765,6 +777,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37007738a80ea34f969af54a3390dd72cacdef654974cfd449c9f6f72dbaac10" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foldhash" version = "0.2.0" @@ -2954,6 +2972,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +[[package]] +name = "uuid" +version = "1.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "version_check" version = "0.9.5" @@ -3047,6 +3075,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "web_atoms" version = "0.3.0"