Repository navigation
chore(deps): bump proj4rs from 0.2.1 to 0.3.0 #1199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b768430
2813f33
9ff744b
a7e971d
85cb511
6fbc655
e8e922f
751307d
001377b
255d8ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bugs (CI): |
||
| crs-definitions = { version = "0.6", default-features = false, features = ["proj4"] } | ||
| base64 = "0.23" | ||
| # Deflate for PDF image streams. | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (wording, high confidence): "for which RustGIS has no WKT form" makes it sound as if these two codes have no WKT at all. ESRI's WKT1 does have a two-point form, and RustGIS refuses it (the azimuth-less case in
Suggested change
|
||||||
| //! | ||||||
| //! 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 | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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,30 @@ fn custom(p: &Node, method: &str) -> Result<Crs, String> { | |||||
| 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° (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<String, String> { | ||||||
| let azimuth = | ||||||
| get(&["AZIMUTH"]).ok_or_else(|| format!("the {} projection has no azimuth", p.child("PROJECTION").map_or("", Node::title)))?; | ||||||
| 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!( | ||||||
| "+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. 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)) | ||||||
|
|
@@ -668,6 +693,14 @@ fn custom(p: &Node, method: &str) -> Result<Crs, String> { | |||||
| { | ||||||
| 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)?, | ||||||
|
deniial00 marked this conversation as resolved.
Resolved
|
||||||
| // 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}"), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possible gap: ArcGIS's Confidence: low to medium, unverified here. If it's right, add the alias and a test with an ESRI Cassini
Suggested change
|
||||||
| "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. | ||||||
| "KROVAK" | ||||||
|
|
@@ -1189,6 +1222,36 @@ pub fn to_wkt(crs: Crs) -> Option<String> { | |||||
| ]; | ||||||
| "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 +1464,17 @@ 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); | ||||||
| // 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); | ||||||
| assert!(crs_from_wkt(&changed).is_err(), "{changed}"); | ||||||
|
|
@@ -1499,7 +1572,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 +1815,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\"]"), | ||||||
|
deniial00 marked this conversation as resolved.
Resolved
|
||||||
| (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(); | ||||||
|
|
@@ -1755,6 +1835,20 @@ 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 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_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(); | ||||||
| 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\"")); | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.