From b76843050639e594ef5eb0db3910e5017dd11f1e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:17:46 +0000 Subject: [PATCH 1/7] chore(deps): bump proj4rs from 0.2.1 to 0.3.0 Bumps [proj4rs](https://github.com/3liz/proj4rs) from 0.2.1 to 0.3.0. - [Commits](https://github.com/3liz/proj4rs/commits) --- updated-dependencies: - dependency-name: proj4rs dependency-version: 0.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e69b80fc3c..7aed0a43b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4231,9 +4231,9 @@ checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" [[package]] name = "proj4rs" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0841627768f16ea6d37fe491695bde62d7b10a8e1a2ae2cf0c878580c16e2b3" +checksum = "c237a4e4da4e0f2eae7a5d078df926894ccf1b315043dbccebc413888487d562" dependencies = [ "console_log", "js-sys", @@ -4245,11 +4245,11 @@ dependencies = [ [[package]] name = "proj4rs-geodesic" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8306e043dfe0c8c2fb1776300649dd0143b39d00f1bc68ddc2e4f62937404d99" +checksum = "bdb2ff6e4d7329dc428ca2cb40f4c1ea85ef6c10aa6bd410294a1c835cd55567" dependencies = [ - "cc", + "wasm-bindgen", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9e68d4f65b..6853faa705 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ tiff = "0.11" weezl = "0.2" # The tests' Zstandard-compressed GeoTIFFs (the version the tiff crate decodes with). zstd = { version = "0.14", default-features = false } -proj4rs = { version = "0.2", default-features = false } +proj4rs = { version = "0.3", default-features = false } crs-definitions = { version = "0.6", default-features = false, features = ["proj4"] } base64 = "0.23" # Deflate for PDF image streams. From 2813f33df4305d77264c1cb4ae1904af0fccef6b Mon Sep 17 00:00:00 2001 From: Daniel Hofbauer Date: Sat, 31 Oct 2026 17:06:01 +0100 Subject: [PATCH 2/7] fix(data): the projections proj4rs 0.3 added get their .prj form and read back MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bump to 0.3.0 makes the oblique Mercator, Cassini-Soldner, the polyconic and Equal Earth parse, so the EPSG codes using them (Oman's grid, Malaysia's RSO, Tobago's and Berlin's, Brazil's polyconic, Equal Earth) are written as WKT and read back by their parameters, checked against PROJ 9.9. An oblique Mercator at azimuth 90° stays refused (proj4rs' omerc is degenerate there; the Swiss case keeps somerc). The map and engine tests that refused +proj=poly pin the still-unimplemented Laborde instead, the EPSG:2056 row of the WKT2 corpus takes the ground truth of PROJ's own pipeline, and the user guide's list of refused methods names Laborde now. (#1199) --- crates/data/src/raster/wkt.rs | 77 +++++++++++++++++++++++++- crates/data/src/raster/wkt2_corpus.tsv | 2 +- crates/engine/src/tests.rs | 9 +-- crates/map/src/projection.rs | 36 ++++++++---- docs/user-guide/maps.md | 6 +- 5 files changed, 107 insertions(+), 23 deletions(-) diff --git a/crates/data/src/raster/wkt.rs b/crates/data/src/raster/wkt.rs index af84531a85..e2992999f3 100644 --- a/crates/data/src/raster/wkt.rs +++ b/crates/data/src/raster/wkt.rs @@ -364,6 +364,8 @@ const METHODS: &[(u32, &str, &str)] = &[ (9810, "POLAR_STEREOGRAPHIC_VARIANT_A", "Polar_Stereographic"), (9829, "POLAR_STEREOGRAPHIC_VARIANT_B", "Polar_Stereographic"), (9809, "OBLIQUE_STEREOGRAPHIC", "Oblique_Stereographic"), + (9812, "HOTINE_OBLIQUE_MERCATOR_VARIANT_A", "Hotine_Oblique_Mercator"), + (9815, "HOTINE_OBLIQUE_MERCATOR_VARIANT_B", "Hotine_Oblique_Mercator_Azimuth_Center"), (1028, "EQUIDISTANT_CYLINDRICAL", "Equirectangular"), (1029, "EQUIDISTANT_CYLINDRICAL_SPHERICAL", "Equirectangular"), (9823, "EQUIDISTANT_CYLINDRICAL_SPHERICAL", "Equirectangular"), @@ -391,6 +393,8 @@ const PARAMETERS: &[(u32, &str, &str, Measure)] = &[ (8815, "SCALE_FACTOR_ON_INITIAL_LINE", "Scale_Factor", Measure::Scale), (8816, "EASTING_AT_PROJECTION_CENTRE", "False_Easting", Measure::Length), (8817, "NORTHING_AT_PROJECTION_CENTRE", "False_Northing", Measure::Length), + (8813, "AZIMUTH_OF_INITIAL_LINE", "Azimuth", Measure::Angle), + (8814, "ANGLE_FROM_RECTIFIED_TO_SKEW_GRID", "Rectified_Grid_Angle", Measure::Angle), ]; /// The EPSG code in a node's `ID["EPSG",n]`. @@ -657,9 +661,27 @@ fn custom(p: &Node, method: &str) -> Result { let lat1 = get(&["STANDARD_PARALLEL_1"]); let lat2 = get(&["STANDARD_PARALLEL_2"]); let at = format!("+lon_0={lon0} +x_0={x0} +y_0={y0}"); + // Hotine's oblique Mercator by its azimuth: `no_uoff` puts the origin at the natural origin + // on the centre line (EPSG's variant A, WKT1's plain `Hotine_Oblique_Mercator`), else at the + // centre (EPSG's variant B, `…_Azimuth_Center`). An azimuth of 90° isn't oblique, and + // proj4rs' omerc is degenerate there (the Swiss case is `somerc` below), so refuse it + // instead of placing points wrong. + let omerc = |no_uoff: bool| -> Result { + let azimuth = + get(&["AZIMUTH"]).ok_or_else(|| format!("the {} projection has no azimuth", p.child("PROJECTION").map_or("", Node::title)))?; + if (azimuth.abs() - 90.0).abs() < 1e-10 { + return Err("a Hotine projection with its azimuth at 90° isn't supported".into()); + } + let gamma = get(&["RECTIFIED_GRID_ANGLE"]).unwrap_or(azimuth); + Ok(format!( + "+proj=omerc +lat_0={lat0} +lonc={lon0} +alpha={azimuth} +gamma={gamma} +k_0={k0} {} {at}", + if no_uoff { "+no_uoff" } else { "" } + )) + }; let proj = match method { "TRANSVERSE_MERCATOR" | "GAUSS_KRUGER" => format!("+proj=tmerc +lat_0={lat0} +k_0={k0} {at}"), - // proj4rs supports the Swiss special case, not arbitrary Hotine projections. + // proj4rs supports the Swiss special case and, since 0.3, the azimuth forms in general; + // the two-point one (no AZIMUTH) isn't supported. "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_CENTER" if national_datum(p.child("GEOGCS").and_then(|g| g.child("DATUM"))) .is_some_and(|d| Some(d) == epsg_proj4(4149) || Some(d) == epsg_proj4(4150)) @@ -668,6 +690,11 @@ fn custom(p: &Node, method: &str) -> Result { { format!("+proj=somerc +lat_0={lat0} +k_0={k0} {at}") } + "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_CENTER" => omerc(false)?, + "HOTINE_OBLIQUE_MERCATOR" | "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_NATURAL_ORIGIN" if get(&["AZIMUTH"]).is_some() => omerc(true)?, + "CASSINI_SOLDNER" => format!("+proj=cass +lat_0={lat0} +k_0={k0} {at}"), + "POLYCONIC" => format!("+proj=poly +lat_0={lat0} +k_0={k0} {at}"), + "EQUAL_EARTH" => format!("+proj=eqearth {at}"), // The implementation fixes the cone axis and pseudo standard parallel. Refuse other // variants and axis conventions instead of treating their coordinates as East/North. "KROVAK" @@ -1189,6 +1216,36 @@ pub fn to_wkt(crs: Crs) -> Option { ]; "Krovak" } + // Cassini-Soldner and the polyconic: an origin and a central meridian, no scale (EPSG's + // methods 9806 and 9818 have none). + "cass" => { + ps = vec![("latitude_of_origin", lat0), ("central_meridian", lon0)]; + "Cassini_Soldner" + } + "poly" => { + ps = vec![("latitude_of_origin", lat0), ("central_meridian", lon0)]; + "Polyconic" + } + // Equal Earth is younger than WKT1; GDAL's name for it. + "eqearth" => { + ps = vec![("central_meridian", lon0)]; + "Equal_Earth" + } + // Hotine's oblique Mercator by its azimuth, the general form proj4rs 0.3 projects (the + // Swiss case is `somerc` above). EPSG's variant B puts the origin at the centre; its + // variant A, PROJ's `+no_uoff`, at the natural origin on the centre line, which WKT1 says + // with the plain name, as GDAL writes it. + "omerc" if get("alpha").is_some() => { + let alpha = get("alpha").unwrap_or(0.0); + ps = vec![ + ("latitude_of_center", lat0), + ("longitude_of_center", get("lonc").unwrap_or(lon0)), + ("azimuth", alpha), + ("rectified_grid_angle", get("gamma").unwrap_or(alpha)), + ("scale_factor", k0), + ]; + if flag("no_uoff") || flag("no_off") { "Hotine_Oblique_Mercator" } else { "Hotine_Oblique_Mercator_Azimuth_Center" } + } _ => return None, }; if kind != "utm" { @@ -1401,7 +1458,14 @@ mod tests { let geog = parse(wkt).unwrap().child("GEOGCS").unwrap().clone(); assert!(earth(Some(&geog)).contains("+towgs84=-104.1,-49.1,-9.9")); assert!(datum_note(Some(&geog)).is_none()); - for (code, from, to) in [("21781", "90.0", "45.0"), ("5514", "78.5", "77.5"), ("5514", r#""X_Scale",-1.0"#, r#""X_Scale",1.0"#)] { + // An altered azimuth isn't the Swiss special case: it reads as the oblique Mercator its + // parameters say, never as Swiss. The Krovak mutations stay refused: proj4rs fixes the + // cone axis and pseudo standard parallel. + let swiss = include_str!("esri_datum_corpus.tsv").lines().find(|l| l.starts_with("21781\t")).unwrap(); + let changed = swiss.split('\t').nth(5).unwrap().replace("90.0", "45.0"); + let def = crs_from_wkt(&changed).unwrap().custom_def().unwrap(); + assert!(def.proj4.contains("+proj=omerc") && !def.proj4.contains("+proj=somerc"), "{}", def.proj4); + for (code, from, to) in [("5514", "78.5", "77.5"), ("5514", r#""X_Scale",-1.0"#, r#""X_Scale",1.0"#)] { let row = include_str!("esri_datum_corpus.tsv").lines().find(|l| l.starts_with(&format!("{code}\t"))).unwrap(); let changed = row.split('\t').nth(5).unwrap().replace(from, to); assert!(crs_from_wkt(&changed).is_err(), "{changed}"); @@ -1499,7 +1563,7 @@ mod tests { fn wkt2_corpus() { // Projections RustGIS builds no PROJ definition for: read by their EPSG code only, as in // WKT1. - let by_code_only = ["EPSG:2056", "EPSG:5514", "EPSG:3375", "EPSG:3168", "EPSG:2066", "ESRI:54008"]; + let by_code_only = ["EPSG:5514", "ESRI:54008"]; let rows = corpus(); assert_eq!(rows.len(), 84); for (code, [x, y, lon, lat], wkt) in rows { @@ -1742,6 +1806,13 @@ mod tests { (4802, (-74.08, 4.6), "PRIMEM[\"Bogota\""), (4813, (106.8, -6.2), "PRIMEM[\"Jakarta\""), (3003, (9.19, 45.46), "DATUM[\"Monte_Mario\""), + // Oman's oblique Mercator about its centre, Michigan's about its natural origin; + // Equal Earth, Brazil's SAD69 polyconic and Berlin's Cassini-Soldner. + (2057, (58.5, 23.6), "PROJECTION[\"Hotine_Oblique_Mercator_Azimuth_Center\"]"), + (3078, (-84.6, 46.47), "PROJECTION[\"Hotine_Oblique_Mercator\"]"), + (8857, (10.0, 40.0), "PROJECTION[\"Equal_Earth\"]"), + (29100, (-54.0, -10.0), "PROJECTION[\"Polyconic\"]"), + (3068, (13.4, 52.4), "PROJECTION[\"Cassini_Soldner\"]"), ]; for (code, (lon, lat), says) in systems { let crs = Crs::from_epsg(u32::from(code)).unwrap(); diff --git a/crates/data/src/raster/wkt2_corpus.tsv b/crates/data/src/raster/wkt2_corpus.tsv index 92c4c74a64..5b150d17b3 100644 --- a/crates/data/src/raster/wkt2_corpus.tsv +++ b/crates/data/src/raster/wkt2_corpus.tsv @@ -50,7 +50,7 @@ EPSG:3414 27630.671900054072 31372.9137690611 103.83 1.2999999999999998 PROJCRS[ EPSG:6933 0.0 0.0 0.0 0.0 PROJCRS["WGS 84 / NSIDC EASE-Grid 2.0 Global",BASEGEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],MEMBER["World Geodetic System 1984 (G2296)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["US NSIDC EASE-Grid 2.0 Global",METHOD["Lambert Cylindrical Equal Area",ID["EPSG",9835]],PARAMETER["Latitude of 1st standard parallel",30,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] EPSG:4087 0.0 0.0 0.0 0.0 PROJCRS["WGS 84 / World Equidistant Cylindrical",BASEGEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],MEMBER["World Geodetic System 1984 (G2296)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["World Equidistant Cylindrical",METHOD["Equidistant Cylindrical",ID["EPSG",1028]],PARAMETER["Latitude of 1st standard parallel",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8823]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] EPSG:27572 549771.5393519275 2192985.1139478907 1.6800000000000002 46.735 PROJCRS["NTF (Paris) / Lambert zone II",BASEGEOGCRS["NTF (Paris)",DATUM["Nouvelle Triangulation Francaise (Paris)",ELLIPSOID["Clarke 1880 (IGN)",6378249.2,293.466021293627,LENGTHUNIT["metre",1]]],PRIMEM["Paris",2.5969213,ANGLEUNIT["grad",0.0157079632679489]],ID["EPSG",4807]],CONVERSION["Lambert zone II",METHOD["Lambert Conic Conformal (1SP)",ID["EPSG",9801]],PARAMETER["Latitude of natural origin",52,ANGLEUNIT["grad",0.0157079632679489],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["grad",0.0157079632679489],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.99987742,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",600000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",2200000,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] -EPSG:2056 2659938.9861671347 1184470.9666418221 8.225 46.81 PROJCRS["CH1903+ / LV95",BASEGEOGCRS["CH1903+",DATUM["CH1903+",ELLIPSOID["Bessel 1841",6377397.155,299.1528128,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4150]],CONVERSION["Swiss Oblique Mercator 1995",METHOD["Hotine Oblique Mercator (variant B)",ID["EPSG",9815]],PARAMETER["Latitude of projection centre",46.9524055555556,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8811]],PARAMETER["Longitude of projection centre",7.43958333333333,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8812]],PARAMETER["Azimuth at projection centre",90,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8813]],PARAMETER["Angle from Rectified to Skew Grid",90,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8814]],PARAMETER["Scale factor at projection centre",1,SCALEUNIT["unity",1],ID["EPSG",8815]],PARAMETER["Easting at projection centre",2600000,LENGTHUNIT["metre",1],ID["EPSG",8816]],PARAMETER["Northing at projection centre",1200000,LENGTHUNIT["metre",1],ID["EPSG",8817]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] +EPSG:2056 2660019.111857919 1184616.167839863 8.225 46.81 PROJCRS["CH1903+ / LV95",BASEGEOGCRS["CH1903+",DATUM["CH1903+",ELLIPSOID["Bessel 1841",6377397.155,299.1528128,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4150]],CONVERSION["Swiss Oblique Mercator 1995",METHOD["Hotine Oblique Mercator (variant B)",ID["EPSG",9815]],PARAMETER["Latitude of projection centre",46.9524055555556,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8811]],PARAMETER["Longitude of projection centre",7.43958333333333,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8812]],PARAMETER["Azimuth at projection centre",90,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8813]],PARAMETER["Angle from Rectified to Skew Grid",90,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8814]],PARAMETER["Scale factor at projection centre",1,SCALEUNIT["unity",1],ID["EPSG",8815]],PARAMETER["Easting at projection centre",2600000,LENGTHUNIT["metre",1],ID["EPSG",8816]],PARAMETER["Northing at projection centre",1200000,LENGTHUNIT["metre",1],ID["EPSG",8817]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] EPSG:5514 -544115.4743788177 -1144058.330762452 17.325 49.394999999999996 PROJCRS["S-JTSK / Krovak East North",BASEGEOGCRS["S-JTSK",DATUM["System of the Unified Trigonometrical Cadastral Network",ELLIPSOID["Bessel 1841",6377397.155,299.1528128,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4156]],CONVERSION["Krovak East North (Greenwich)",METHOD["Krovak (North Orientated)",ID["EPSG",1041]],PARAMETER["Latitude of projection centre",49.5,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8811]],PARAMETER["Longitude of origin",24.8333333333333,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8833]],PARAMETER["Co-latitude of cone axis",30.2881397527778,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",1036]],PARAMETER["Latitude of pseudo standard parallel",78.5,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8818]],PARAMETER["Scale factor on pseudo standard parallel",0.9999,SCALEUNIT["unity",1],ID["EPSG",8819]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] EPSG:3375 436306.0884087617 494492.74517072795 101.91999999999999 4.47 PROJCRS["GDM2000 / Peninsula RSO",BASEGEOGCRS["GDM2000",DATUM["Geodetic Datum of Malaysia 2000",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4742]],CONVERSION["Peninsular RSO",METHOD["Hotine Oblique Mercator (variant A)",ID["EPSG",9812]],PARAMETER["Latitude of projection centre",4,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8811]],PARAMETER["Longitude of projection centre",102.25,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8812]],PARAMETER["Azimuth at projection centre",323.025796466667,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8813]],PARAMETER["Angle from Rectified to Skew Grid",323.130102361111,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8814]],PARAMETER["Scale factor at projection centre",0.99984,SCALEUNIT["unity",1],ID["EPSG",8815]],PARAMETER["False easting",804671,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] EPSG:3168 455639.208408625 438584.28533625626 102.095 3.965 PROJCRS["Kertau (RSO) / RSO Malaya (m)",BASEGEOGCRS["Kertau (RSO)",DATUM["Kertau (RSO)",ELLIPSOID["Everest 1830 (RSO 1969)",6377295.664,300.8017,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4751]],CONVERSION["Rectified Skew Orthomorphic Malaya Grid (metre)",METHOD["Hotine Oblique Mercator (variant A)",ID["EPSG",9812]],PARAMETER["Latitude of projection centre",4,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8811]],PARAMETER["Longitude of projection centre",102.25,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8812]],PARAMETER["Azimuth at projection centre",323.0257905,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8813]],PARAMETER["Angle from Rectified to Skew Grid",323.130102361111,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8814]],PARAMETER["Scale factor at projection centre",0.99984,SCALEUNIT["unity",1],ID["EPSG",8815]],PARAMETER["False easting",804670.24,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]] diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index cfb047fd1b..ffb019a1db 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -1796,10 +1796,11 @@ fn custom_projections_switch_keep_scale_query_and_render() { assert!(crate::cmd::share::map_png(&mut s, Some(400.0), Some(300.0), None).unwrap().len() > 1000); assert!(s.run("map.projection", &json!({"type": "EPSG:4326"})).is_err(), "degrees are refused"); assert!(s.run("map.projection", &json!({"type": "nope"})).is_err()); - // A known code whose method isn't implemented (Brazil Polyconic) is refused, not drawn in - // Web Mercator under its own name; the map keeps its projection (#208). - let e = s.run("map.projection", &json!({"type": "EPSG:5880"})).unwrap_err(); - assert!(e.contains("poly"), "{e}"); + // A known code whose method isn't implemented (EPSG:8441, Laborde) is refused, not drawn in + // Web Mercator under its own name; the map keeps its projection (#208). proj4rs 0.3 grew + // Brazil Polyconic, so EPSG:5880 switches now. + let e = s.run("map.projection", &json!({"type": "EPSG:8441"})).unwrap_err(); + assert!(e.contains("labrd"), "{e}"); assert_eq!(s.map().projection.code(), "EPSG:32617"); assert!(s.run("map.goToXY", &json!({"lon": 100.0, "lat": 0.0})).is_err(), "folded far side of the UTM zone"); // Undo and save/reload keep the projection. diff --git a/crates/map/src/projection.rs b/crates/map/src/projection.rs index df94b48764..1074814eef 100644 --- a/crates/map/src/projection.rs +++ b/crates/map/src/projection.rs @@ -438,7 +438,9 @@ impl Domain { let lon0 = if proj == "utm" { param("zone").map(|z| z * 6.0 - 183.0 + pm).unwrap_or(lon0) } else { lon0 }; Domain::Band { lon0, half: 30.0 } } - "stere" | "sterea" | "somerc" | "krovak" => Domain::Cap { center: Coord::new(lon0, lat0), radius: 60.0 }, + "stere" | "sterea" | "somerc" | "krovak" | "cass" | "poly" | "omerc" => { + Domain::Cap { center: Coord::new(lon0, lat0), radius: 60.0 } + } "laea" | "aeqd" => Domain::Cap { center: Coord::new(lon0, lat0), radius: 120.0 }, "aea" | "lcc" => { let (a, b) = (param("lat_1").unwrap_or(lat0), param("lat_2").unwrap_or(lat0)); @@ -613,7 +615,7 @@ impl Projector { return Ok(Projector { engine, to_meter: 1.0, domain, lon0, edge: std::sync::OnceLock::new() }); } let native = proj4rs::Proj::from_proj_string(&def).map_err(|e| match e { - // A known code whose method isn't implemented (EPSG:5880's +proj=poly, say): name it. + // A known code whose method isn't implemented (EPSG:8441's +proj=labrd, say): name it. proj4rs::errors::Error::ProjectionNotFound => format!("{code}: its projection method (+proj={proj}) isn't supported"), e => format!("{code}: {e}"), })?; @@ -1036,8 +1038,8 @@ mod tests { assert!(p.domain.contains(Coord::new(-50.0, -15.0)) && !p.domain.contains(Coord::new(-55.0, 60.0))); } - /// Sinusoidal (opengeos/RustGIS#563), which proj4rs lacks: Esri's systems draw, against - /// pyproj 3.7.1 (PROJ 9.5.1), and wrap opposite their central meridian. + /// Sinusoidal (opengeos/RustGIS#563), computed here before proj4rs 0.3 grew one: Esri's + /// systems draw, against pyproj 3.7.1 (PROJ 9.5.1), and wrap opposite their central meridian. #[test] fn sinusoidal_codes_draw() { let check = |code: &str, (lon, lat): (f64, f64), (x, y): (f64, f64), lon0: f64| { @@ -1163,14 +1165,24 @@ mod tests { #[test] fn codes_whose_method_cannot_be_drawn_are_refused() { - // EPSG:5880 (SIRGAS 2000 / Brazil Polyconic) is in the EPSG table, but its method - // (+proj=poly) has no implementation: refuse it rather than accept it and draw the map - // in Web Mercator while naming EPSG:5880 (opengeos/RustGIS#208). - assert!(lookup("EPSG:5880").is_ok(), "the code itself is known"); - let e = Projector::new("EPSG:5880").unwrap_err(); - assert!(e.contains("EPSG:5880") && e.contains("poly"), "{e}"); - let e = crate::Projection::from_code("EPSG:5880").unwrap_err(); - assert!(e.contains("poly"), "{e}"); + // EPSG:8441 (Laborde) is in the EPSG table, but its method (+proj=labrd) has no + // implementation: refuse it rather than accept it and draw the map in Web Mercator while + // naming EPSG:8441 (opengeos/RustGIS#208). + assert!(lookup("EPSG:8441").is_ok(), "the code itself is known"); + let e = Projector::new("EPSG:8441").unwrap_err(); + assert!(e.contains("EPSG:8441") && e.contains("labrd"), "{e}"); + let e = crate::Projection::from_code("EPSG:8441").unwrap_err(); + assert!(e.contains("labrd"), "{e}"); + // proj4rs 0.3 added Cassini, the polyconic, Equal Earth and the oblique Mercator: their + // codes are accepted (EPSG:5880's polyconic, whose refusal was #208), and draw where PROJ + // does: (5 000 000, 8 894 145) for 10°W 54°S of SIRGAS 2000's origin, its false northing + // less a million-odd metres. + for ok in ["EPSG:5880", "EPSG:2057", "EPSG:3068", "EPSG:8858"] { + crate::Projection::from_code(ok).unwrap_or_else(|e| panic!("{ok}: {e}")); + } + let brazil = Projector::new("EPSG:5880").unwrap_or_else(|e| panic!("{e}")); + let m = brazil.forward(Coord::new(-54.0, -10.0)).unwrap(); + assert!((m.x - 5_000_000.0).abs() < 0.01 && (m.y - 8_894_145.167).abs() < 0.01, "{m:?}"); // Codes that can be drawn are still accepted, by number or preset. for ok in ["EPSG:3035", "epsg:32633", "EPSG:8858", "equalEarth", "usaAlbers", "mercator", "globe"] { crate::Projection::from_code(ok).unwrap_or_else(|e| panic!("{ok}: {e}")); diff --git a/docs/user-guide/maps.md b/docs/user-guide/maps.md index fdbd903f67..f112d6ade0 100644 --- a/docs/user-guide/maps.md +++ b/docs/user-guide/maps.md @@ -326,9 +326,9 @@ projection, and clicking the coordinate system in the status bar opens the **Coo System** dialog, which also takes a projected EPSG code (such as `3035`, `32633` for UTM zone 33N or `2056` for Switzerland) or an ESRI code, the one `.prj` files and ArcGIS name (such as `ESRI:102033` for South America Albers Equal Area Conic, or `ESRI:54030` for World Robinson). A -code whose projection method or datum grid RustGIS can't use (Polyconic such as `5880`, Cassini, -oblique Mercator, or a NAD27 code that needs a grid) is refused with the reason, rather than drawn -in another projection. RustGIS supports a subset of Esri's projected systems, checked against +code whose projection method or datum grid RustGIS can't use (Laborde such as `8441`, or a NAD27 +code that needs a grid) is refused with the reason, rather than drawn in another projection. +RustGIS supports a subset of Esri's projected systems, checked against PROJ at representative points; unsupported codes such as World Miller (`ESRI:54003`) are refused as unknown codes. The presets: From 9ff744b3634b58048b3529c1825c9437cabd078a Mon Sep 17 00:00:00 2001 From: Daniel Hofbauer Date: Sat, 31 Oct 2026 17:24:10 +0100 Subject: [PATCH 3/7] =?UTF-8?q?fix(data):=20the=20oblique=20Mercator=20gua?= =?UTF-8?q?rd=20covers=20270=C2=B0=20too,=20and=20docs=20catch=20up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An azimuth of 270° is the same east-west centre line as 90°, and the omerc formula is degenerate there in proj4rs and PROJ alike (verified: PROJ 9.9's own `omerc +no_uoff +alpha=90` lands 10 Mm off), so the guard matches modulo 180°. Cassini and the polyconic take no scale factor, so the reader stops emitting `+k_0`. The ESRI table's notes say they were checked against proj4rs 0.2, and the user guide lists the methods that read from parameters now. --- crates/data/src/raster/esri.rs | 8 +++++--- crates/data/src/raster/wkt.rs | 19 ++++++++++++------- docs/user-guide/data.md | 5 +++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crates/data/src/raster/esri.rs b/crates/data/src/raster/esri.rs index e358b5abe1..4af3d4204d 100644 --- a/crates/data/src/raster/esri.rs +++ b/crates/data/src/raster/esri.rs @@ -12,8 +12,10 @@ //! from the south-west corner; 20°E 30°N and 40°W 40°N for world systems) with RustGIS's //! `Projector` and with pyproj, and kept only when they agree within 1 m. Left out: //! -//! - systems whose method proj4rs lacks (`col_urban`, `omerc`, `cass`, `eqdc`, `poly`, `ortho`, -//! `bonne`, `wink2` and more), and the NAD27 ones whose grids proj4rs can't load: 167; +//! - systems whose method proj4rs 0.2, against which the table was checked, lacks (`col_urban`, +//! `omerc`, `cass`, `eqdc`, `poly`, `ortho`, `bonne`, `wink2` and more; 0.3 grew the oblique +//! Mercator, Cassini, the polyconic, the equidistant conic and the orthographic, whose ESRI +//! systems are candidates to add), and the NAD27 ones whose grids proj4rs can't load: 167; //! - six world systems RustGIS computes on a sphere where PROJ uses the ellipsoid or other //! parameters, kilometres apart: World Miller (54003), the WGS 84 Equal Earths (54035–54037) //! and the Winkel Tripel NGS pair (53042, 54042), whose `lat_1` RustGIS doesn't read. The @@ -22,7 +24,7 @@ //! (Molodensky–Badekas for Korean 1985, a chain of operations for NGO 1948 …), and the 11 //! planetary ones (Moon, Mars), whose bodies the map can't hold; //! - the seven PROJ can't write as a PROJ string (Hammer–Aitoff, Fuller, Cube, Tobler …) and the -//! two oblique Mercators it refuses (53025, 54025). +//! two two-point oblique Mercators (53025, 54025), for which RustGIS has no WKT form. //! //! The three Earth sinusoidal systems (Sphere and World Sinusoidal, 53008 and 54008, and Africa //! Sinusoidal, 102011) were added afterwards (opengeos/RustGIS#563): RustGIS computes the diff --git a/crates/data/src/raster/wkt.rs b/crates/data/src/raster/wkt.rs index e2992999f3..12e6439d1c 100644 --- a/crates/data/src/raster/wkt.rs +++ b/crates/data/src/raster/wkt.rs @@ -663,14 +663,15 @@ fn custom(p: &Node, method: &str) -> Result { let at = format!("+lon_0={lon0} +x_0={x0} +y_0={y0}"); // Hotine's oblique Mercator by its azimuth: `no_uoff` puts the origin at the natural origin // on the centre line (EPSG's variant A, WKT1's plain `Hotine_Oblique_Mercator`), else at the - // centre (EPSG's variant B, `…_Azimuth_Center`). An azimuth of 90° isn't oblique, and - // proj4rs' omerc is degenerate there (the Swiss case is `somerc` below), so refuse it - // instead of placing points wrong. + // centre (EPSG's variant B, `…_Azimuth_Center`). An azimuth of 90° (or 270°, the same + // east-west centre line) isn't oblique, and the omerc formula is degenerate there in proj4rs + // and PROJ alike (the Swiss case is `somerc` below), so refuse it instead of placing points + // wrong. let omerc = |no_uoff: bool| -> Result { let azimuth = get(&["AZIMUTH"]).ok_or_else(|| format!("the {} projection has no azimuth", p.child("PROJECTION").map_or("", Node::title)))?; - if (azimuth.abs() - 90.0).abs() < 1e-10 { - return Err("a Hotine projection with its azimuth at 90° isn't supported".into()); + if (azimuth.rem_euclid(180.0) - 90.0).abs() < 1e-10 { + return Err("a Hotine projection with its azimuth at 90° (or 270°) isn't supported".into()); } let gamma = get(&["RECTIFIED_GRID_ANGLE"]).unwrap_or(azimuth); Ok(format!( @@ -692,8 +693,9 @@ fn custom(p: &Node, method: &str) -> Result { } "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_CENTER" => omerc(false)?, "HOTINE_OBLIQUE_MERCATOR" | "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_NATURAL_ORIGIN" if get(&["AZIMUTH"]).is_some() => omerc(true)?, - "CASSINI_SOLDNER" => format!("+proj=cass +lat_0={lat0} +k_0={k0} {at}"), - "POLYCONIC" => format!("+proj=poly +lat_0={lat0} +k_0={k0} {at}"), + // EPSG's methods 9806 and 9818 have no scale factor; PROJ's cass and poly ignore one. + "CASSINI_SOLDNER" => format!("+proj=cass +lat_0={lat0} {at}"), + "POLYCONIC" => format!("+proj=poly +lat_0={lat0} {at}"), "EQUAL_EARTH" => format!("+proj=eqearth {at}"), // The implementation fixes the cone axis and pseudo standard parallel. Refuse other // variants and axis conventions instead of treating their coordinates as East/North. @@ -1465,6 +1467,9 @@ mod tests { let changed = swiss.split('\t').nth(5).unwrap().replace("90.0", "45.0"); let def = crs_from_wkt(&changed).unwrap().custom_def().unwrap(); assert!(def.proj4.contains("+proj=omerc") && !def.proj4.contains("+proj=somerc"), "{}", def.proj4); + // 270° is the same east-west centre line read the other way, and just as degenerate. + let changed = swiss.split('\t').nth(5).unwrap().replace("90.0", "270.0"); + assert!(crs_from_wkt(&changed).is_err(), "{changed}"); for (code, from, to) in [("5514", "78.5", "77.5"), ("5514", r#""X_Scale",-1.0"#, r#""X_Scale",1.0"#)] { let row = include_str!("esri_datum_corpus.tsv").lines().find(|l| l.starts_with(&format!("{code}\t"))).unwrap(); let changed = row.split('\t').nth(5).unwrap().replace(from, to); diff --git a/docs/user-guide/data.md b/docs/user-guide/data.md index 72e9ef1ec0..3fcdb07b21 100644 --- a/docs/user-guide/data.md +++ b/docs/user-guide/data.md @@ -74,8 +74,9 @@ and S-JTSK, the same built-in Helmert datum transformation as the EPSG definitio transformation in the file takes precedence. RDN2008 and IGM95 are treated as WGS 84-like datums. These transformations do not replace regional grid corrections for survey accuracy. An unrecognized datum keeps its ellipsoid and produces a notice when no transformation is -available. Swiss oblique Mercator and the standard Krovak East/North variant are supported from -their parameters. +available. Swiss oblique Mercator, the standard Krovak East/North variant, and the oblique +Mercator, Cassini-Soldner, polyconic and Equal Earth methods are supported from their +parameters. Shapefile text uses a supported `.cpg` encoding, otherwise the `.dbf` code page, with UTF-8 as the fallback. Keep the sidecar files together. From a7e971d3044136b6a86faab400596990710213b4 Mon Sep 17 00:00:00 2001 From: Daniel Hofbauer Date: Sat, 31 Oct 2026 17:50:58 +0100 Subject: [PATCH 4/7] fix(data): pyproj-checked points for the new methods, and notes they asked for MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The oblique Mercator, Equal Earth, Cassini and polyconic round trips couldn't catch a wrong formula, both sides being the same code: each now has a point checked against pyproj 3.8.0 (EPSG:4326 to the code). The corpus header says the Swiss row's x,y is pyproj's own EPSG:2056 pipeline of its round point, and lists CH1903+ among the systems whose longitude and latitude are WGS 84. The ESRI WKT1 name for the Hotine variant A is real input (ArcGIS writes Hotine_Oblique_Mercator_Azimuth_Natural_Origin, pyproj's EPSG:3078 included), so the reader arm stays, said so; the Swiss guard gets a note on why it checks the azimuth exactly, and the polyconic test says 54°W 10°S, not 10°W 54°S. --- crates/data/src/raster/wkt.rs | 19 ++++++++++++++++++- crates/data/src/raster/wkt2_corpus.tsv | 5 +++-- crates/map/src/projection.rs | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/crates/data/src/raster/wkt.rs b/crates/data/src/raster/wkt.rs index 12e6439d1c..cf3cc30a00 100644 --- a/crates/data/src/raster/wkt.rs +++ b/crates/data/src/raster/wkt.rs @@ -682,7 +682,9 @@ fn custom(p: &Node, method: &str) -> Result { let proj = match method { "TRANSVERSE_MERCATOR" | "GAUSS_KRUGER" => format!("+proj=tmerc +lat_0={lat0} +k_0={k0} {at}"), // proj4rs supports the Swiss special case and, since 0.3, the azimuth forms in general; - // the two-point one (no AZIMUTH) isn't supported. + // the two-point one (no AZIMUTH) isn't supported. The Swiss system is the azimuth-90° + // Hotine on a Swiss datum — the one azimuth the guard below refuses, because an oblique + // Mercator at exactly 90° is either Swiss or degenerate. "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_CENTER" if national_datum(p.child("GEOGCS").and_then(|g| g.child("DATUM"))) .is_some_and(|d| Some(d) == epsg_proj4(4149) || Some(d) == epsg_proj4(4150)) @@ -692,6 +694,8 @@ fn custom(p: &Node, method: &str) -> Result { format!("+proj=somerc +lat_0={lat0} +k_0={k0} {at}") } "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_CENTER" => omerc(false)?, + // ESRI's WKT1 name for EPSG's variant A (ArcGIS writes it to `.prj`); WKT2's variant A + // arrives as the plain name through the METHODS table. "HOTINE_OBLIQUE_MERCATOR" | "HOTINE_OBLIQUE_MERCATOR_AZIMUTH_NATURAL_ORIGIN" if get(&["AZIMUTH"]).is_some() => omerc(true)?, // EPSG's methods 9806 and 9818 have no scale factor; PROJ's cass and poly ignore one. "CASSINI_SOLDNER" => format!("+proj=cass +lat_0={lat0} {at}"), @@ -1831,6 +1835,19 @@ mod tests { let tolerance = if crs.is_geographic() { 1e-8 } else { 0.01 }; assert!((a.x - b.x).abs() < tolerance && (a.y - b.y).abs() < tolerance, "EPSG:{code}: {a:?} {b:?}\n{bare}"); } + // Each new method against PROJ (pyproj 3.8.0, EPSG:4326 to the code): the round trip + // above can't catch a wrong formula, both sides being the same code. + let checked = [ + (2057u16, (58.5, 23.6), (1_260_860.830, 2_623_439.977)), + (3078, (-84.6, 46.47), (607_329.382, 658_531.220)), + (8857, (10.0, 40.0), (849_749.831, 4_921_020.062)), + (3068, (13.4, 52.4), (24_656.900, 8_104.416)), + (29100, (-54.0, -10.0), (5_000_000.000, 8_894_141.426)), + ]; + for (code, (lon, lat), (x, y)) in checked { + let m = Crs::from_epsg(u32::from(code)).unwrap().transformer().unwrap().from_lonlat(Coord::new(lon, lat)).unwrap(); + assert!((m.x - x).abs() < 1.0 && (m.y - y).abs() < 1.0, "EPSG:{code}: {m:?}"); + } // LV95 takes CH1903+'s name, LV03 CH1903's. assert!(to_wkt(Crs::from_epsg(2056).unwrap()).unwrap().contains("DATUM[\"CH1903+\"")); assert!(to_wkt(Crs::from_epsg(21781).unwrap()).unwrap().contains("DATUM[\"CH1903\"")); diff --git a/crates/data/src/raster/wkt2_corpus.tsv b/crates/data/src/raster/wkt2_corpus.tsv index 5b150d17b3..45676ea419 100644 --- a/crates/data/src/raster/wkt2_corpus.tsv +++ b/crates/data/src/raster/wkt2_corpus.tsv @@ -1,6 +1,7 @@ -# WKT2 2019 of 84 coordinate systems, written by pyproj 3.7.2 (PROJ 9.7.1; PROJ 9.8.1 for the Italian ones) without +# WKT2 2019 of 84 coordinate systems, written by pyproj 3.7.2 (PROJ 9.7.1; PROJ 9.8.1 for the Italian ones and the Swiss row, whose x,y is its EPSG:4326 to EPSG:2056 of the round point below) without # their top-level ID and usage. Columns: code, x, y, and the longitude and latitude of x, y on the -# system's own datum, except OSGB36, Amersfoort, GGRS87, Monte Mario and ED50, which use WGS 84 and the bundled +# system's own datum, except OSGB36, Amersfoort, GGRS87, Monte Mario, ED50 and CH1903+ (EPSG:2056), +# which use WGS 84 and the bundled # Helmert shift. EPSG:4326 0.0 0.0 0.0 0.0 GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)",ID["EPSG",1166]],MEMBER["World Geodetic System 1984 (G730)",ID["EPSG",1152]],MEMBER["World Geodetic System 1984 (G873)",ID["EPSG",1153]],MEMBER["World Geodetic System 1984 (G1150)",ID["EPSG",1154]],MEMBER["World Geodetic System 1984 (G1674)",ID["EPSG",1155]],MEMBER["World Geodetic System 1984 (G1762)",ID["EPSG",1156]],MEMBER["World Geodetic System 1984 (G2139)",ID["EPSG",1309]],MEMBER["World Geodetic System 1984 (G2296)",ID["EPSG",1383]],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1],ID["EPSG",7030]],ENSEMBLEACCURACY[2.0],ID["EPSG",6326]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]] EPSG:4269 180.0 50.685 180.0 50.685 GEOGCRS["NAD83",DATUM["North American Datum 1983",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]] diff --git a/crates/map/src/projection.rs b/crates/map/src/projection.rs index 1074814eef..ffc1fb7df0 100644 --- a/crates/map/src/projection.rs +++ b/crates/map/src/projection.rs @@ -1175,8 +1175,8 @@ mod tests { assert!(e.contains("labrd"), "{e}"); // proj4rs 0.3 added Cassini, the polyconic, Equal Earth and the oblique Mercator: their // codes are accepted (EPSG:5880's polyconic, whose refusal was #208), and draw where PROJ - // does: (5 000 000, 8 894 145) for 10°W 54°S of SIRGAS 2000's origin, its false northing - // less a million-odd metres. + // does: 54°W 10°S lands at (5 000 000, 8 894 145.167) in pyproj 3.8.0's EPSG:5880, its + // false easting less a million-odd metres. for ok in ["EPSG:5880", "EPSG:2057", "EPSG:3068", "EPSG:8858"] { crate::Projection::from_code(ok).unwrap_or_else(|e| panic!("{ok}: {e}")); } From 85cb511d391340f9ea919e2cbbfa0109c9d48f69 Mon Sep 17 00:00:00 2001 From: Daniel Hofbauer Date: Sat, 31 Oct 2026 18:10:59 +0100 Subject: [PATCH 5/7] fix(data): the checked points use each system's own definition pyproj's EPSG:4326 to the EPSG code applies the datum registry's own transformation, which for SAD69 (EPSG:29100) differs from the definition's bundled three-parameter shift by some 46 m. Against the definition itself, pyproj and proj4rs agree bit for bit, and the comparison keeps the bundled shift the reader emits. --- crates/data/src/raster/wkt.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/data/src/raster/wkt.rs b/crates/data/src/raster/wkt.rs index cf3cc30a00..125e2bb0c4 100644 --- a/crates/data/src/raster/wkt.rs +++ b/crates/data/src/raster/wkt.rs @@ -1835,14 +1835,15 @@ mod tests { let tolerance = if crs.is_geographic() { 1e-8 } else { 0.01 }; assert!((a.x - b.x).abs() < tolerance && (a.y - b.y).abs() < tolerance, "EPSG:{code}: {a:?} {b:?}\n{bare}"); } - // Each new method against PROJ (pyproj 3.8.0, EPSG:4326 to the code): the round trip - // above can't catch a wrong formula, both sides being the same code. + // Each new method against PROJ (pyproj 3.8.0 on the system's own PROJ definition, from + // EPSG:4326): the round trip above can't catch a wrong formula, both sides being the same + // code, and the same definition keeps the bundled datum shift in the comparison. let checked = [ (2057u16, (58.5, 23.6), (1_260_860.830, 2_623_439.977)), (3078, (-84.6, 46.47), (607_329.382, 658_531.220)), (8857, (10.0, 40.0), (849_749.831, 4_921_020.062)), (3068, (13.4, 52.4), (24_656.900, 8_104.416)), - (29100, (-54.0, -10.0), (5_000_000.000, 8_894_141.426)), + (29100, (-54.0, -10.0), (5_000_045.526, 8_894_187.489)), ]; for (code, (lon, lat), (x, y)) in checked { let m = Crs::from_epsg(u32::from(code)).unwrap().transformer().unwrap().from_lonlat(Coord::new(lon, lat)).unwrap(); From 6fbc655cff7ef212d4d80f948a5643f16ad24a59 Mon Sep 17 00:00:00 2001 From: giswqs Date: Sat, 31 Oct 2026 13:17:16 -0400 Subject: [PATCH 6/7] test(analysis): drop the known marks #1207 made stale Buffer's fix lets a long line and polygons agree with the reference, and the test fails on a marked case that agrees. The point and road cases still differ, within their looser tolerance, so they keep theirs. --- crates/analysis/tests/reference/cases.json | 12 ------------ crates/analysis/tests/reference/generate.py | 6 +++--- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/crates/analysis/tests/reference/cases.json b/crates/analysis/tests/reference/cases.json index 58f6172840..c725501bf3 100644 --- a/crates/analysis/tests/reference/cases.json +++ b/crates/analysis/tests/reference/cases.json @@ -963,10 +963,6 @@ "expect": { "features": "expected/buffer_long_5km.geojson", "tolerance": 0.001 - }, - "known": { - "issue": "#1159: Buffer outlines sit up to 10 % of the distance off", - "tolerance": 0.1 } }, { @@ -980,10 +976,6 @@ "expect": { "features": "expected/buffer_parcels_1km.geojson", "tolerance": 0.001 - }, - "known": { - "issue": "#1159: Buffer outlines sit up to 10 % of the distance off", - "tolerance": 0.1 } }, { @@ -997,10 +989,6 @@ "expect": { "features": "expected/buffer_parcels_-2km.geojson", "tolerance": 0.001 - }, - "known": { - "issue": "#1159: Buffer outlines sit up to 10 % of the distance off", - "tolerance": 0.1 } } ] diff --git a/crates/analysis/tests/reference/generate.py b/crates/analysis/tests/reference/generate.py index e1d4d1ff66..ffa23df51a 100644 --- a/crates/analysis/tests/reference/generate.py +++ b/crates/analysis/tests/reference/generate.py @@ -515,11 +515,11 @@ def buffered(name, rows, d): case("buffer lines", "buffer", {"input": "roads", "distance": 2000, "units": "Meters"}, {"features": buffered("buffer_roads_2km", ROADS, 2000.0), "tolerance": tol}, known) case("buffer a long line", "buffer", {"input": "long", "distance": 5, "units": "Kilometers"}, - {"features": buffered("buffer_long_5km", LONG, 5000.0), "tolerance": tol}, known) + {"features": buffered("buffer_long_5km", LONG, 5000.0), "tolerance": tol}) case("buffer polygons", "buffer", {"input": "parcels", "distance": 1, "units": "Kilometers"}, - {"features": buffered("buffer_parcels_1km", parcels, 1000.0), "tolerance": tol}, known) + {"features": buffered("buffer_parcels_1km", parcels, 1000.0), "tolerance": tol}) case("buffer polygons inward", "buffer", {"input": "parcels", "distance": -2, "units": "Kilometers"}, - {"features": buffered("buffer_parcels_-2km", parcels, -2000.0), "tolerance": tol}, known) + {"features": buffered("buffer_parcels_-2km", parcels, -2000.0), "tolerance": tol}) meta = { "about": "Answers from GEOS; regenerate with `uv run generate.py` (see its header).", From 255d8cebd3634e4f0719c6ff8bcb2b51ea667b30 Mon Sep 17 00:00:00 2001 From: Daniel Hofbauer Date: Sun, 1 Nov 2026 19:15:49 +0100 Subject: [PATCH 7/7] chore(fuzz): lock proj4rs 0.3.0 and proj4rs-geodesic 0.2.0 --- fuzz/Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index a8890fe6f1..8e06e7e786 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -2035,9 +2035,9 @@ dependencies = [ [[package]] name = "proj4rs" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0841627768f16ea6d37fe491695bde62d7b10a8e1a2ae2cf0c878580c16e2b3" +checksum = "c237a4e4da4e0f2eae7a5d078df926894ccf1b315043dbccebc413888487d562" dependencies = [ "console_log", "js-sys", @@ -2049,11 +2049,11 @@ dependencies = [ [[package]] name = "proj4rs-geodesic" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8306e043dfe0c8c2fb1776300649dd0143b39d00f1bc68ddc2e4f62937404d99" +checksum = "bdb2ff6e4d7329dc428ca2cb40f4c1ea85ef6c10aa6bd410294a1c835cd55567" dependencies = [ - "cc", + "wasm-bindgen", ] [[package]]