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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ weezl = "0.2"
# The tests' Zstandard-compressed GeoTIFFs (the version the tiff crate decodes with).
zstd = { version = "0.14", default-features = false }
# Coordinate systems and transformations: EPSG, ESRI and IAU tables, datum shifts and grids, in pure
# Rust (opengeos/RustGIS#2032). From opengeos/terrio until a release after terrio-crs 0.2.4 carries
# the WKT reading RustGIS uses (opengeos/terrio#1012).
terrio-crs = { git = "https://github.com/opengeos/terrio", rev = "bbc0aaef92c21844c4adfaa8808e9ba15f0faa8f", default-features = false }
# Rust (opengeos/RustGIS#2032).
terrio-crs = { version = "0.3.0", default-features = false }
base64 = "0.23"
# Deflate for PDF image streams.
miniz_oxide = "0.9"
Expand Down
38 changes: 35 additions & 3 deletions THIRD-PARTY-LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9470,7 +9470,7 @@ SOFTWARE.
====================================================================================================
MIT License
Used by: block2, bufrw, dispatch, dpi, i_key_sort, libm, objc-sys, objc2, objc2-app-kit, objc2-encode,
objc2-foundation, rsqlite-vfs, yore
objc2-foundation, rsqlite-vfs, yore, zrip-core, zrip-decode, zrip-encode
====================================================================================================

MIT License
Expand Down Expand Up @@ -11377,6 +11377,33 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

====================================================================================================
MIT License
Used by: zrip
====================================================================================================

MIT License

Copyright (c) 2026 Patrik Wenger

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

====================================================================================================
SIL Open Font License 1.1
Used by: epaint_default_fonts
Expand Down Expand Up @@ -12361,6 +12388,7 @@ Terrio files derived from PROJ source files (each file's header names them):
crates/terrio-crs/src/def.rs
crates/terrio-crs/src/grid.rs
crates/terrio-crs/src/math.rs
crates/terrio-crs/src/methods.rs
crates/terrio-crs/src/params.rs
crates/terrio-crs/src/projections.rs
crates/terrio-crs/src/projections/perspective.rs
Expand Down Expand Up @@ -12481,8 +12509,8 @@ Geodetic Parameter Dataset (https://epsg.org), owned by the International Associ
Gas Producers (IOGP), through PROJ's database and GDAL. They are redistributed under the EPSG
Dataset Terms of Use (https://epsg.org/terms-of-use.html), with this attribution. They are not the EPSG Dataset itself, and
terrio is not endorsed by IOGP. The EPSG method and parameter names and codes in
crates/terrio-crs/src/projjson_write.rs and crates/terrio/src/drivers/vector/projjson.rs come
from the same dataset.
crates/terrio-crs/src/projjson_write.rs, crates/terrio-crs/src/methods.rs and
crates/terrio/src/drivers/vector/projjson.rs come from the same dataset.
crates/terrio-crs/src/projjson_db.tsv.zst is derived from the same dataset (EPSG v12.029), through
PROJ 9.7.1's database, under the same terms; the EPSG method and parameter names and codes in
crates/terrio-crs/src/projjson_gdal.rs come from it too.
Expand Down Expand Up @@ -12521,6 +12549,10 @@ terms.
The test data crates/terrio-crs/tests/data/helmert_to_wgs84.tsv (PROJ 9.9.0's datum
transformations to WGS 84 of EPSG geographic CRSs, by scripts/gen_helmert_to_wgs84.py) is derived
from the same dataset, under the same terms.
The EPSG codes and areas of use in the height reference data
crates/terrio-crs/tests/data/compound_heights.tsv and geodetic_3d.tsv (PROJ 9.9.0's placements,
by scripts/gen_compound_heights.py and scripts/gen_geodetic_3d.py) derive from the same dataset,
under the same terms.

-------------------------------------------------------------------------------
Esri projection engine data
Expand Down
38 changes: 35 additions & 3 deletions apps/rustgis-mobile/THIRD-PARTY-LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8431,7 +8431,7 @@ SOFTWARE.
====================================================================================================
MIT License
Used by: block2, bufrw, dispatch, dpi, i_key_sort, libm, objc-sys, objc2, objc2-encode, objc2-foundation,
objc2-ui-kit, yore
objc2-ui-kit, yore, zrip-core, zrip-decode, zrip-encode
====================================================================================================

MIT License
Expand Down Expand Up @@ -9753,6 +9753,33 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

====================================================================================================
MIT License
Used by: zrip
====================================================================================================

MIT License

Copyright (c) 2026 Patrik Wenger

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

====================================================================================================
SIL Open Font License 1.1
Used by: epaint_default_fonts
Expand Down Expand Up @@ -10712,6 +10739,7 @@ Terrio files derived from PROJ source files (each file's header names them):
crates/terrio-crs/src/def.rs
crates/terrio-crs/src/grid.rs
crates/terrio-crs/src/math.rs
crates/terrio-crs/src/methods.rs
crates/terrio-crs/src/params.rs
crates/terrio-crs/src/projections.rs
crates/terrio-crs/src/projections/perspective.rs
Expand Down Expand Up @@ -10832,8 +10860,8 @@ Geodetic Parameter Dataset (https://epsg.org), owned by the International Associ
Gas Producers (IOGP), through PROJ's database and GDAL. They are redistributed under the EPSG
Dataset Terms of Use (https://epsg.org/terms-of-use.html), with this attribution. They are not the EPSG Dataset itself, and
terrio is not endorsed by IOGP. The EPSG method and parameter names and codes in
crates/terrio-crs/src/projjson_write.rs and crates/terrio/src/drivers/vector/projjson.rs come
from the same dataset.
crates/terrio-crs/src/projjson_write.rs, crates/terrio-crs/src/methods.rs and
crates/terrio/src/drivers/vector/projjson.rs come from the same dataset.
crates/terrio-crs/src/projjson_db.tsv.zst is derived from the same dataset (EPSG v12.029), through
PROJ 9.7.1's database, under the same terms; the EPSG method and parameter names and codes in
crates/terrio-crs/src/projjson_gdal.rs come from it too.
Expand Down Expand Up @@ -10872,6 +10900,10 @@ terms.
The test data crates/terrio-crs/tests/data/helmert_to_wgs84.tsv (PROJ 9.9.0's datum
transformations to WGS 84 of EPSG geographic CRSs, by scripts/gen_helmert_to_wgs84.py) is derived
from the same dataset, under the same terms.
The EPSG codes and areas of use in the height reference data
crates/terrio-crs/tests/data/compound_heights.tsv and geodetic_3d.tsv (PROJ 9.9.0's placements,
by scripts/gen_compound_heights.py and scripts/gen_geodetic_3d.py) derive from the same dataset,
under the same terms.

-------------------------------------------------------------------------------
Esri projection engine data
Expand Down
38 changes: 35 additions & 3 deletions apps/rustgis-python/THIRD-PARTY-LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8131,7 +8131,7 @@ THE SOFTWARE.

====================================================================================================
MIT License
Used by: bufrw, i_key_sort, libm, rsqlite-vfs, yore
Used by: bufrw, i_key_sort, libm, rsqlite-vfs, yore, zrip-core, zrip-decode, zrip-encode
====================================================================================================

MIT License
Expand Down Expand Up @@ -9502,6 +9502,33 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

====================================================================================================
MIT License
Used by: zrip
====================================================================================================

MIT License

Copyright (c) 2026 Patrik Wenger

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

====================================================================================================
SIL Open Font License 1.1
Used by: epaint_default_fonts
Expand Down Expand Up @@ -10461,6 +10488,7 @@ Terrio files derived from PROJ source files (each file's header names them):
crates/terrio-crs/src/def.rs
crates/terrio-crs/src/grid.rs
crates/terrio-crs/src/math.rs
crates/terrio-crs/src/methods.rs
crates/terrio-crs/src/params.rs
crates/terrio-crs/src/projections.rs
crates/terrio-crs/src/projections/perspective.rs
Expand Down Expand Up @@ -10581,8 +10609,8 @@ Geodetic Parameter Dataset (https://epsg.org), owned by the International Associ
Gas Producers (IOGP), through PROJ's database and GDAL. They are redistributed under the EPSG
Dataset Terms of Use (https://epsg.org/terms-of-use.html), with this attribution. They are not the EPSG Dataset itself, and
terrio is not endorsed by IOGP. The EPSG method and parameter names and codes in
crates/terrio-crs/src/projjson_write.rs and crates/terrio/src/drivers/vector/projjson.rs come
from the same dataset.
crates/terrio-crs/src/projjson_write.rs, crates/terrio-crs/src/methods.rs and
crates/terrio/src/drivers/vector/projjson.rs come from the same dataset.
crates/terrio-crs/src/projjson_db.tsv.zst is derived from the same dataset (EPSG v12.029), through
PROJ 9.7.1's database, under the same terms; the EPSG method and parameter names and codes in
crates/terrio-crs/src/projjson_gdal.rs come from it too.
Expand Down Expand Up @@ -10621,6 +10649,10 @@ terms.
The test data crates/terrio-crs/tests/data/helmert_to_wgs84.tsv (PROJ 9.9.0's datum
transformations to WGS 84 of EPSG geographic CRSs, by scripts/gen_helmert_to_wgs84.py) is derived
from the same dataset, under the same terms.
The EPSG codes and areas of use in the height reference data
crates/terrio-crs/tests/data/compound_heights.tsv and geodetic_3d.tsv (PROJ 9.9.0's placements,
by scripts/gen_compound_heights.py and scripts/gen_geodetic_3d.py) derive from the same dataset,
under the same terms.

-------------------------------------------------------------------------------
Esri projection engine data
Expand Down
31 changes: 29 additions & 2 deletions crates/data/src/raster/wkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,18 @@ fn read_root(root: &Node, code: Option<u32>, text: &str) -> Result<(Crs, Option<
/// WGS 84 that is its code's transformation then reads as the code. Only there: the text RustGIS
/// writes for some codes approximates them away from it (Guam's projection, EPSG:3993, 1.5 cm at
/// 0.1°) and is read back as the code; and a shift on WGS 84 itself, which a WGS 84 or Web
/// Mercator code's file may give, is none for PROJ 9.8.1 anywhere.
/// Mercator code's file may give, is none for PROJ anywhere. Web Mercator, which has no area of
/// use to take the centre of, is compared at 10°E 45°N.
pub(crate) fn places_as(text: &str, crs: Crs) -> bool {
let (Ok(file), Ok(code)) = (super::crs::transformer_of_wkt(text), super::crs::not_waiting_for_grids(|| crs.transformer())) else {
return false;
};
let centre = match crs {
Crs::Epsg(c) => super::crs::area_centre(c),
// Away from the equator, where Web Mercator's sphere and an ellipsoid's Mercator (World
// Mercator, or GDAL 1's EPSG:900913 without its `PROJ4` extension, as PROJ reads it) are
// 21 km apart at 45°; at the origin they meet.
Crs::WebMercator => Some(rustgis_geom::Coord::new(10.0, 45.0)),

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.

This new comparison is only reached when the file gives a shift. read_root (line 500, unchanged) returns by_code straight away when files_shift.is_none(), so a GDAL 1 EPSG:900913 WKT whose datum has no TOWGS84 clause still reads as Crs::WebMercator, the sphere, about 21 km off at 45°N. The PR body calls the no-shift case "wrong all along", so this looks like the case it means to fix. The new tests only cover a datum with TOWGS84[0,0,0,0,0,0,0], so they would not catch it. I have not run this. Suggested fix: add a regression test with a 900913 WKT that has no TOWGS84. If it reads as Web Mercator, run places_as for Crs::WebMercator even when there is no shift.

Confidence: medium (about 60%).

Category: bug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #2961: a Web Mercator code without a TOWGS84 now goes through places_as too, so the 900913 text without its PROJ4 extension and without a shift reads as ellipsoidal Mercator (PROJ 9.9.0: 60°E 45.1923152°N), with a test for it.

_ => None,
}
.unwrap_or(rustgis_geom::Coord::new(0.0, 0.0));
Expand Down Expand Up @@ -4882,7 +4887,15 @@ pub(crate) mod tests {
let utm = format!(r#"{},AUTHORITY["EPSG","32631"]]"#, ESRI_32631.strip_suffix(']').unwrap());
let towgs84 = |t: &str| utm.replace("298.257223563]]", &format!("298.257223563],{t}]"));
assert_eq!(crs_from_wkt(&towgs84("TOWGS84[0,0,0]")), Ok(Crs::Epsg(32631)));
assert!(matches!(crs_from_wkt(&towgs84("TOWGS84[1,2,3]")), Ok(Crs::Custom(_))));
// Nor with another: a shift on WGS 84 itself is none. PROJ 9.9.0 reads this text as a
// bound CRS and transforms it to EPSG:4326 without the shift (conda-forge PROJ 9.9.0 with
// pyproj 3.8.0 built on it, network off: `Transformer.from_crs(CRS.from_wkt(text),
// "EPSG:4326", always_xy=True).transform(500000, 5000000)` is 3°E 45.1534772°N), as
// EPSG:32631 does.
let shifted = crs_from_wkt(&towgs84("TOWGS84[1,2,3]"));
assert_eq!(shifted, Ok(Crs::Epsg(32631)));

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 UTM text with TOWGS84[1,2,3] now reads as Crs::Epsg(32631), which drops the file's shift with no note. Before this PR the same text read as Crs::Custom and kept its shift. PROJ 9.9.0 ignores that shift on WGS 84, so the positions match PROJ. AGENTS.md still says a reader that drops a value must say what it dropped. This test uses crs_from_wkt, which discards the note, so it can't check that. Suggested fix: have the places_as path (read_root, around line 501) say the file's shift on WGS 84 is set aside because WGS 84 has none, and assert that note with read_wkt here.

Confidence: about 50%. I have not run the code.

Category: agents-md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #2961: the shift set aside on a code without one is said ("the file's own shift to WGS 84 is set aside, as EPSG:32631 has none, as in PROJ"), asserted through read_wkt; the stale comment and the 9.8.1 citation are updated there too.

let ll = Crs::Epsg(32631).transformer().unwrap().to_lonlat(Coord::new(500_000.0, 5_000_000.0)).unwrap();
assert!((ll.x - 3.0).abs() < 1e-9 && (ll.y - 45.153_477_2).abs() < 1e-7, "{ll:?}");
}

/// Another body's system with an EPSG code (the Earth's) is read from its parameters, not as
Expand Down Expand Up @@ -5117,6 +5130,20 @@ pub(crate) mod tests {
assert_eq!(crs_from_wkt(&shifted), Ok(Crs::WebMercator));
let shifted = without_proj4_extension(&shifted).unwrap();
assert!(matches!(crs_from_wkt(&shifted), Ok(Crs::Custom(_))), "{:?}", crs_from_wkt(&shifted));
// Without the extension it is Mercator on the WGS 84 ellipsoid, as PROJ 9.9.0 reads it
// (conda-forge PROJ 9.9.0 with pyproj 3.8.0 built on it, network off:
// `Transformer.from_crs(CRS.from_wkt(text), "EPSG:4326", always_xy=True)` puts
// 6 679 169.4476 m E, 5 621 521.4862 m N at 60°E 45.1923152°N, with or without the
// shift), not Web Mercator's sphere (45°N).
for text in [without_proj4_extension(google).unwrap(), shifted] {
let ll = crs_from_wkt(&text)
.unwrap()
.transformer()
.unwrap()
.to_lonlat(Coord::new(6_679_169.447_596_414, 5_621_521.486_192_066))
.unwrap();
assert!((ll.y - 45.192_315).abs() < 1e-4, "{ll:?}");
}
// A system named and projected as Web Mercator stays Web Mercator, and a shift its file
// gives is said to be set aside.
let esri = ESRI_3857.replace("6378137.0,298.257223563]]", "6378137.0,298.257223563],TOWGS84[1,2,3]]");
Expand Down
3 changes: 1 addition & 2 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ ignore = true
unknown-registry = "deny"
unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
# terrio-crs, pinned by `rev` in Cargo.toml until a release after 0.2.4 (opengeos/RustGIS#2032).
allow-git = ["https://github.com/opengeos/terrio"]
allow-git = []
required-git-spec = "rev"
Loading
Loading