diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d334b9f..10eac46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: - uses: actions/checkout@v3 - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - run: cargo clippy -- --deny warnings + - run: cargo clippy --tests -- --deny warnings - run: cargo fmt --check - run: cargo build --verbose - run: cargo test --verbose diff --git a/justfile b/justfile index 58161ae..5af94c0 100644 --- a/justfile +++ b/justfile @@ -13,17 +13,18 @@ default: list list: just -l -# Basic test: Just library unit tests. Use target "test-all" or "check" for successively more in depth check ups. +# Basic test: Just library unit tests. Use target "test-all", "check" or "clean-check" for successively more in depth check ups. test: cargo test --lib -# Unit tests, doc tests, pile test, and compiling of examples +# Unit tests, doc tests, and compiling of examples test-all: - cargo test + cargo test --all # Check that all tests pass, and that formatting and coding conventions are OK. check: - cargo clippy + cargo clippy -- --deny warnings + cargo clippy --tests -- --deny warnings cargo fmt -- --check cargo test cargo doc --all-features --no-deps diff --git a/src/context/plain.rs b/src/context/plain.rs index fe8370e..64b0fb7 100644 --- a/src/context/plain.rs +++ b/src/context/plain.rs @@ -272,7 +272,7 @@ mod tests { assert!(ctx.get_resource("stupid:way_three")?.starts_with("addone")); // And just to be sure: once again for the plain resource file - assert!(ctx.get_resource("stupid:way")?.starts_with("#")); + assert!(ctx.get_resource("stupid:way")?.starts_with('#')); assert!(ctx.get_resource("stupid:way")?.ends_with("addone")); // Now make sure, we can actually also *instantiate* a recipe diff --git a/src/coordinate/set.rs b/src/coordinate/set.rs index f26c854..69d99f7 100644 --- a/src/coordinate/set.rs +++ b/src/coordinate/set.rs @@ -279,7 +279,7 @@ mod tests { fn array() { let mut operands = some_basic_coor4dinates(); assert_eq!(operands.len(), 2); - assert_eq!(operands.is_empty(), false); + assert!(!operands.is_empty()); let cph = operands.get_coord(0); assert_eq!(cph[0], 55.); @@ -301,7 +301,7 @@ mod tests { fn vector() { let mut operands = Vec::from(some_basic_coor4dinates()); assert_eq!(operands.len(), 2); - assert_eq!(operands.is_empty(), false); + assert!(!operands.is_empty()); let cph = operands.get_coord(0); assert_eq!(cph[0], 55.); diff --git a/src/ellipsoid/latitudes.rs b/src/ellipsoid/latitudes.rs index f90207d..865a870 100644 --- a/src/ellipsoid/latitudes.rs +++ b/src/ellipsoid/latitudes.rs @@ -156,7 +156,7 @@ mod tests { let ellps = Ellipsoid::named("GRS80")?; let lats = Vec::from([35., 45., 55.]); for lat in &lats { - let lat = *lat as f64; + let lat: f64 = *lat; let theta = ellps.latitude_geographic_to_geocentric(lat.to_radians()); let roundtrip = ellps.latitude_geocentric_to_geographic(theta).to_degrees(); assert!((lat - roundtrip).abs() < 1e-14); @@ -195,9 +195,10 @@ mod tests { #[test] fn rectifying() -> Result<(), Error> { let ellps = Ellipsoid::named("GRS80")?; - let latitudes = vec![35., 45., 55., -35., -45., -55., 0., 90.]; + let latitudes = [35., 45., 55., -35., -45., -55., 0., 90.]; let coefficients = ellps.coefficients_for_rectifying_latitude_computations(); // Roundtrip 𝜙 -> 𝜇 -> 𝜙 + #[allow(clippy::unnecessary_cast)] for phi in latitudes { let lat = (phi as f64).to_radians(); let mu = ellps.latitude_geographic_to_rectifying(lat, &coefficients); @@ -213,9 +214,10 @@ mod tests { #[test] fn conformal() -> Result<(), Error> { let ellps = Ellipsoid::named("GRS80")?; - let latitudes = vec![35., 45., 55., -35., -45., -55., 0., 90.]; + let latitudes = [35., 45., 55., -35., -45., -55., 0., 90.]; #[rustfmt::skip] - let conformal_latitudes = vec![ + #[allow(clippy::excessive_precision)] + let conformal_latitudes = [ 34.819454814955349775, 44.807684055145067248, 54.819109023689023275, // Northern hemisphere -34.819454814955349775, -44.807684055145067248, -54.819109023689023275, // Symmetry wrt. the Equator 0., 90., // Extreme values are invariant @@ -224,6 +226,7 @@ mod tests { let chi_coefs = ellps.latitude_fourier_coefficients(&constants::CONFORMAL); let pairs = latitudes.iter().zip(conformal_latitudes.iter()); + #[allow(clippy::unnecessary_cast)] for pair in pairs { // The casts are necessary, at least as of Rust 1.66 let phi = (*(pair.0) as f64).to_radians(); @@ -235,7 +238,7 @@ mod tests { let lat = 55_f64.to_radians(); let chi = ellps.latitude_geographic_to_conformal(lat, &chi_coefs); let phi = ellps.latitude_conformal_to_geographic(chi, &chi_coefs); - assert!((chi.to_degrees() - 54.819109023689023275).abs() < 1e-12); + assert!((chi.to_degrees() - 54.819_109_023_689_02).abs() < 1e-12); assert_eq!(phi.to_degrees(), 55.0); Ok(()) } @@ -264,8 +267,9 @@ mod tests { let pairs = geographic_latitudes.iter().zip(authalic_latitudes.iter()); + #[allow(clippy::unnecessary_cast)] for pair in pairs.clone() { - // These casts to f64 are necessary, at least as of Rust 1.66. It appears that the 'Chalk' + // These casts to f64 are necessary, at least as of Rust 1.66..1.73. It appears that the 'Chalk' // trait checker used in Rust-Analyzer has this correctly, so perhaps the need for these // casts may be eliminated in a later Rust version let phi = (*(pair.0) as f64).to_radians(); @@ -287,6 +291,7 @@ mod tests { // Despite the name "authlat", the PROJ implementation appears to go from // authalic to geographic latitudes. let proj_coefs = authset(ellps.eccentricity_squared()); + #[allow(clippy::unnecessary_cast)] for pair in pairs { let phi = (*(pair.0) as f64).to_radians(); let xi = (*(pair.1) as f64).to_radians(); diff --git a/src/ellipsoid/meridians.rs b/src/ellipsoid/meridians.rs index c05c4e9..620afe5 100644 --- a/src/ellipsoid/meridians.rs +++ b/src/ellipsoid/meridians.rs @@ -167,19 +167,21 @@ mod tests { // Meridional distances for angles 0, 10, 20, 30 ... 90, obtained from Charles Karney's // online geodesic solver, https://geographiclib.sourceforge.io/cgi-bin/GeodSolve + #[allow(clippy::excessive_precision)] let s = [ - 0_000_000.000000000, - 1_105_854.833198446, - 2_212_366.254102976, - 3_320_113.397845014, - 4_429_529.030236580, - 5_540_847.041560960, - 6_654_072.819367435, - 7_768_980.727655508, - 8_885_139.871836751, - 10_001_965.729230457, + 0_000_000.000_000_000, + 1_105_854.833_198_446, + 2_212_366.254_102_976, + 3_320_113.397_845_014, + 4_429_529.030_236_580, + 5_540_847.041_560_960, + 6_654_072.819_367_435, + 7_768_980.727_655_508, + 8_885_139.871_836_751, + 10_001_965.729_230_457, ]; + #[allow(clippy::needless_range_loop)] for i in 0..s.len() { let angle = (10.0 * i as f64).to_radians(); assert!((ellps.meridian_latitude_to_distance(angle) - s[i]).abs() < 6e-6); @@ -188,7 +190,7 @@ mod tests { // Since we suspect the deviation might be worst at 45°, we check that as well let angle = 45f64.to_radians(); - let length = 4984944.377857987; + let length = 4_984_944.377_857_987; assert!((ellps.meridian_latitude_to_distance(angle) - length).abs() < 4e-6); assert!((ellps.meridian_distance_to_latitude(length) - angle).abs() < 4e-6); Ok(()) diff --git a/src/ellipsoid/mod.rs b/src/ellipsoid/mod.rs index 2ccfcd1..6e6f93e 100644 --- a/src/ellipsoid/mod.rs +++ b/src/ellipsoid/mod.rs @@ -202,10 +202,10 @@ mod tests { let ellps = Ellipsoid::named("GRS80")?; assert_eq!(ellps.semimajor_axis(), 6378137.0); - assert_eq!(ellps.flattening(), 1. / 298.25722_21008_82711_24316); + assert_eq!(ellps.flattening(), 1. / 298.257_222_100_882_7); - assert!((ellps.normalized_meridian_arc_unit() - 0.9983242984230415).abs() < 1e-13); - assert!((4.0 * ellps.meridian_quadrant() - 40007862.9169218).abs() < 1e-7); + assert!((ellps.normalized_meridian_arc_unit() - 0.998_324_298_423_041_5).abs() < 1e-13); + assert!((4.0 * ellps.meridian_quadrant() - 40_007_862.916_921_8).abs() < 1e-7); Ok(()) } @@ -215,11 +215,11 @@ mod tests { let ellps = Ellipsoid::new(ellps.semimajor_axis(), ellps.flattening()); let ellps = Ellipsoid::triaxial(ellps.a, ellps.a - 1., ellps.f); assert_eq!(ellps.semimajor_axis(), 6378137.0); - assert_eq!(ellps.flattening(), 1. / 298.25722_21008_82711_24316); + assert_eq!(ellps.flattening(), 1. / 298.257_222_100_882_7); // Additional shape descriptors assert!((ellps.eccentricity() - 0.081819191).abs() < 1.0e-10); - assert!((ellps.eccentricity_squared() - 0.00669_43800_22903_41574).abs() < 1.0e-10); + assert!((ellps.eccentricity_squared() - 0.006_694_380_022_903_416).abs() < 1.0e-10); // Additional size descriptors assert!((ellps.semiminor_axis() - 6_356_752.31414_0347).abs() < 1e-9); @@ -245,10 +245,11 @@ mod tests { let ellps = Ellipsoid::named("GRS80")?; // The curvatures at the North Pole assert!( - (ellps.meridian_radius_of_curvature(90_f64.to_radians()) - 6_399_593.6259).abs() < 1e-4 + (ellps.meridian_radius_of_curvature(90_f64.to_radians()) - 6_399_593.625_9).abs() + < 1e-4 ); assert!( - (ellps.prime_vertical_radius_of_curvature(90_f64.to_radians()) - 6_399_593.6259).abs() + (ellps.prime_vertical_radius_of_curvature(90_f64.to_radians()) - 6_399_593.625_9).abs() < 1e-4 ); assert!( @@ -265,7 +266,7 @@ mod tests { ); // The curvatures at the Equator - assert!((ellps.meridian_radius_of_curvature(0.0) - 6_335_439.3271).abs() < 1.0e-4); + assert!((ellps.meridian_radius_of_curvature(0.0) - 6_335_439.327_1).abs() < 1.0e-4); assert!( (ellps.prime_vertical_radius_of_curvature(0.0) - ellps.semimajor_axis()).abs() < 1.0e-4 ); @@ -274,6 +275,8 @@ mod tests { let latitudes = [ 50f64, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, ]; + + #[allow(clippy::excessive_precision)] let prime_vertical_radii_of_curvature = [ 6390702.044256360, 6391069.984921544, @@ -288,6 +291,7 @@ mod tests { 6394209.173926849, ]; + #[allow(clippy::excessive_precision)] let meridian_radii_of_curvature = [ 6372955.9257095090, 6374056.7459167000, @@ -301,16 +305,12 @@ mod tests { 6382470.6113096075, 6383453.8572549970, ]; - // println!("lat; N; M; R"); for (i, lat) in latitudes.iter().enumerate() { let n = ellps.prime_vertical_radius_of_curvature(lat.to_radians()); let m = ellps.meridian_radius_of_curvature(lat.to_radians()); - // let r = (n*m).sqrt(); assert!((n - prime_vertical_radii_of_curvature[i]).abs() < 1e-9); assert!((m - meridian_radii_of_curvature[i]).abs() < 1e-9); - - // println!("{lat}; {n}; {m}; {r}"); } Ok(()) } diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 40a24fd..dd9d45e 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -376,7 +376,7 @@ mod tests { // Interpolation let c = Coor4D::geo(55.06, 12.03, 0., 0.); // Check that we're not extrapolating - assert_eq!(datum.contains(&c, 0.0), true); + assert!(datum.contains(&c, 0.0)); // ...with output converted back to arcsec let d = datum.at(&c, 0.0).unwrap().to_arcsec(); // We can do slightly better for interpolation than for extrapolation, @@ -391,8 +391,8 @@ mod tests { let geoid = BaseGrid::plain(&geoid_header, Some(&geoid_grid), None)?; let c = Coor4D::geo(58.75, 08.25, 0., 0.); - assert_eq!(geoid.contains(&c, 0.0), false); - assert_eq!(geoid.contains(&c, 1.0), true); + assert!(!geoid.contains(&c, 0.0)); + assert!(geoid.contains(&c, 1.0)); let n = geoid.at(&c, 1.0).unwrap(); assert!((n[0] - (58.75 + 0.0825)).abs() < 0.0001); diff --git a/src/grid/ntv2/mod.rs b/src/grid/ntv2/mod.rs index ee8bf64..3a66556 100644 --- a/src/grid/ntv2/mod.rs +++ b/src/grid/ntv2/mod.rs @@ -199,7 +199,7 @@ mod tests { let ntv2_grid = Ntv2Grid::new(&grid_buff)?; assert!(ntv2_grid.subgrids.len() == 2); - assert!(ntv2_grid.lookup_table.get("NONE").unwrap().len() > 0); + assert!(!ntv2_grid.lookup_table.get("NONE").unwrap().is_empty()); assert!(ntv2_grid .lookup_table .get("NONE") diff --git a/src/inner_op/adapt.rs b/src/inner_op/adapt.rs index 0f02bb6..a44f55c 100644 --- a/src/inner_op/adapt.rs +++ b/src/inner_op/adapt.rs @@ -301,11 +301,11 @@ mod tests { assert_eq!([-1., 1., -1., 1.], descriptor("sedf_any").unwrap().mult); // noop - assert_eq!(false, descriptor("sedf_any").unwrap().noop); - assert_eq!(true, descriptor("enuf_any").unwrap().noop); - assert_eq!(true, descriptor("enuf_rad").unwrap().noop); - assert_eq!(true, descriptor("enuf").unwrap().noop); - assert_eq!(true, descriptor("pass").unwrap().noop); + assert!(!descriptor("sedf_any").unwrap().noop); + assert!(descriptor("enuf_any").unwrap().noop); + assert!(descriptor("enuf_rad").unwrap().noop); + assert!(descriptor("enuf").unwrap().noop); + assert!(descriptor("pass").unwrap().noop); // Invalid angular unit "pap" assert!(descriptor("sedf_pap").is_none()); @@ -322,7 +322,7 @@ mod tests { assert!(give.mult[1] - 400. / 360. < 1e-10); // mult[1] is positive for northish assert!(give.mult[2] + 1.0 < 1e-10); // mult[2] is negative for downish assert!(give.mult[3] - 1.0 < 1e-10); // mult[3] is positive for timeish - assert!(give.noop == false); + assert!(!give.noop); } // Test the basic adapt functionality diff --git a/src/inner_op/btmerc.rs b/src/inner_op/btmerc.rs index 15bb2f8..1ebacca 100644 --- a/src/inner_op/btmerc.rs +++ b/src/inner_op/btmerc.rs @@ -194,7 +194,7 @@ mod tests { Coor4D::raw(-455_673.814_189_040,-6_198_246.671_090_279, 0., 0.) ]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 5e-3); @@ -231,7 +231,7 @@ mod tests { Coor4D::raw(-455_673.814_189_040,-6_198_246.671_090_279, 0., 0.) ]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 5e-3); @@ -265,7 +265,7 @@ mod tests { Coor4D::raw(-455_673.814_189_040, 1e7-6_198_246.671_090_279, 0., 0.) ]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 5e-3); diff --git a/src/inner_op/cart.rs b/src/inner_op/cart.rs index 85bbe38..9f33213 100644 --- a/src/inner_op/cart.rs +++ b/src/inner_op/cart.rs @@ -135,42 +135,42 @@ mod tests { ]; let cart = [ - Coor4D::raw(566462.633537476765923, 0.0, 6432020.33369012735784, 0.0), + Coor4D::raw(566_462.633_537_476_8, 0.0, 6_432_020.333_690_127, 0.0), Coor4D::raw( - 3554403.47587193036451, - 626737.23312017065473, - 5119468.31865925621241, + 3_554_403.475_871_930_4, + 626_737.233_120_170_7, + 5_119_468.318_659_256, 0., ), Coor4D::raw( - 5435195.38214521575719, - 1978249.33652197546325, - 2679074.46287727775052, + 5_435_195.382_145_216, + 1_978_249.336_521_975_5, + 2_679_074.462_877_277_8, 0., ), - Coor4D::raw(5993488.27326157130301, -2181451.33089075051248, 0., 0.), + Coor4D::raw(5_993_488.273_261_571, -2_181_451.330_890_750_5, 0., 0.), Coor4D::raw( - 5435203.89865261223167, - 1978252.43627716740593, - -2679078.68905989499763, + 5_435_203.898_652_612, + 1_978_252.436_277_167_4, + -2_679_078.689_059_895, 0., ), Coor4D::raw( - 5435203.89865261223167, - -1978252.43627716740593, - -2679078.68905989499763, + 5_435_203.898_652_612, + -1_978_252.436_277_167_4, + -2_679_078.689_059_895, 0., ), Coor4D::raw( - 5435203.89865261223167, - -1978252.43627716740593, - 2679078.68905989499763, + 5_435_203.898_652_612, + -1_978_252.436_277_167_4, + 2_679_078.689_059_895, 0., ), ]; // Forward - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..4 { assert!(operands[i].hypot3(&cart[i]) < 20e-9); diff --git a/src/inner_op/curvature.rs b/src/inner_op/curvature.rs index bd8bce6..34c06b2 100644 --- a/src/inner_op/curvature.rs +++ b/src/inner_op/curvature.rs @@ -150,32 +150,35 @@ mod tests { let latitudes = [ 50f64, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, ]; + + #[allow(clippy::excessive_precision)] let prime_vertical_radii_of_curvature = [ - 6390702.044256360, - 6391069.984921544, - 6391435.268276582, - 6391797.447784556, - 6392156.080476415, - 6392510.727498910, - 6392860.954658516, - 6393206.332960654, - 6393546.439143487, - 6393880.856205599, - 6394209.173926849, + 6_390_702.044_256_360, + 6_391_069.984_921_544, + 6_391_435.268_276_582, + 6_391_797.447_784_556, + 6_392_156.080_476_415, + 6_392_510.727_498_910, + 6_392_860.954_658_516, + 6_393_206.332_960_654, + 6_393_546.439_143_487, + 6_393_880.856_205_599, + 6_394_209.173_926_849, ]; + #[allow(clippy::excessive_precision)] let meridian_radii_of_curvature = [ - 6372955.9257095090, - 6374056.7459167000, - 6375149.7412608800, - 6376233.5726736350, - 6377306.9111838430, - 6378368.4395775950, - 6379416.8540488490, - 6380450.8658386090, - 6381469.2028603740, - 6382470.6113096075, - 6383453.8572549970, + 6_372_955.925_709_509_0, + 6_374_056.745_916_700_0, + 6_375_149.741_260_880_0, + 6_376_233.572_673_635_0, + 6_377_306.911_183_843_0, + 6_378_368.439_577_595_0, + 6_379_416.854_048_849_0, + 6_380_450.865_838_609_0, + 6_381_469.202_860_374_0, + 6_382_470.611_309_607_5, + 6_383_453.857_254_997_0, ]; // Prime vertical diff --git a/src/inner_op/laea.rs b/src/inner_op/laea.rs index 2578792..07e3f5c 100644 --- a/src/inner_op/laea.rs +++ b/src/inner_op/laea.rs @@ -294,7 +294,7 @@ mod tests { let p = Coor2D::raw(3962799.45, 2999718.85); let projected = [p]; - let mut operands = geo.clone(); + let mut operands = geo; // Forward ctx.apply(op, Fwd, &mut operands)?; diff --git a/src/inner_op/latitude.rs b/src/inner_op/latitude.rs index 02ba908..a73f974 100644 --- a/src/inner_op/latitude.rs +++ b/src/inner_op/latitude.rs @@ -212,7 +212,7 @@ mod tests { let op = ctx.op("latitude conformal ellps=GRS80")?; let mut operands = [Coor4D::geo(55., 12., 0., 0.)]; ctx.apply(op, Fwd, &mut operands)?; - assert!((operands[0][1].to_degrees() - 54.819_109_023_689_023_275).abs() < 1e-12); + assert!((operands[0][1].to_degrees() - 54.819_109_023_689_02).abs() < 1e-12); ctx.apply(op, Inv, &mut operands)?; assert!((operands[0][1].to_degrees() - 55.).abs() < 1e-12); diff --git a/src/inner_op/lcc.rs b/src/inner_op/lcc.rs index 002f41a..cfa0f1c 100644 --- a/src/inner_op/lcc.rs +++ b/src/inner_op/lcc.rs @@ -239,12 +239,12 @@ mod tests { ]; let projected = [ - Coor4D::raw(-0.000000000101829246, -222728.122307816054672003, 0., 0.), - Coor4D::raw(-128046.4724386522429995, -220853.7001605064142495, 0., 0.), - Coor4D::raw(115005.41456620067765471, 224484.5143763388914522, 0., 0.), + Coor4D::raw(-0.000000000101829246, -222_728.122_307_816_05, 0., 0.), + Coor4D::raw(-128_046.472_438_652_24, -220_853.700_160_506_4, 0., 0.), + Coor4D::raw(115_005.414_566_200_68, 224_484.514_376_338_9, 0., 0.), ]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 2e-9); @@ -267,13 +267,13 @@ mod tests { // echo 12 40 0 0 | cct -d12 proj=lcc lat_1=33 lat_2=45 lon_0=10 -- | clip let geo = [Coor4D::geo(40., 12., 0., 0.)]; let projected = [Coor4D::raw( - 169863.026093938301, - 4735925.219292450696, + 169_863.026_093_938_3, + 4_735_925.219_292_451, 0., 0., )]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 9e-9); @@ -295,9 +295,14 @@ mod tests { // Validation value from PROJ: // echo 12 40 0 0 | cct -d12 proj=lcc lat_1=39 lat_0=35 lon_0=10 -- | clip let geo = [Coor4D::geo(40., 12., 0., 0.)]; - let projected = [Coor4D([170800.011728740647, 557172.361112929415, 0., 0.])]; + let projected = [Coor4D([ + 170_800.011_728_740_65, + 557_172.361_112_929_4, + 0., + 0., + ])]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 2e-9); @@ -320,13 +325,13 @@ mod tests { // echo 12 40 0 0 | cct -d12 proj=lcc lat_1=33 lat_2=45 lat_0=35 lon_0=10 -- | clip let geo = [Coor4D::geo(40., 12., 0., 0.)]; let projected = [Coor4D::raw( - 169863.026093938359, - 554155.440793916583, + 169_863.026_093_938_36, + 554_155.440_793_916_6, 0., 0., )]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 2e-9); @@ -348,9 +353,14 @@ mod tests { // Validation value from PROJ: // echo 12 40 0 0 | cct -d12 proj=lcc lat_1=33 lat_2=45 lat_0=35 lon_0=10 x_0=12345 y_0=67890 -- | clip let geo = [Coor4D::geo(40., 12., 0., 0.)]; - let projected = [Coor4D([182208.026093938301, 622045.440793916583, 0., 0.])]; + let projected = [Coor4D([ + 182_208.026_093_938_3, + 622_045.440_793_916_6, + 0., + 0., + ])]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 2e-9); @@ -372,9 +382,14 @@ mod tests { // Validation value from PROJ: // echo 12 40 0 0 | cct -d12 proj=lcc lat_1=33 lat_2=45 lat_0=35 lon_0=10 x_0=12345 y_0=67890 k_0=0.99 -- | clip let geo = [Coor4D::geo(40., 12., 0., 0.)]; - let projected = [Coor4D([180509.395832998911, 616503.886385977501, 0., 0.])]; + let projected = [Coor4D([ + 180_509.395_832_998_9, + 616_503.886_385_977_5, + 0., + 0., + ])]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 2e-9); diff --git a/src/inner_op/merc.rs b/src/inner_op/merc.rs index 32d5ff5..a9a35fe 100644 --- a/src/inner_op/merc.rs +++ b/src/inner_op/merc.rs @@ -131,15 +131,15 @@ mod tests { ]; let projected = [ - Coor4D::raw(1335833.889519282850, 7326837.714873877354, 0., 0.), - Coor4D::raw(222638.981586547, 110579.965218249, 0., 0.), - Coor4D::raw(222638.981586547, -110579.965218249, 0., 0.), - Coor4D::raw(-222638.981586547, 110579.965218249, 0., 0.), - Coor4D::raw(-222638.981586547, -110579.965218249, 0., 0.), + Coor4D::raw(1_335_833.889_519_282_8, 7_326_837.714_873_877, 0., 0.), + Coor4D::raw(222_638.981_586_547, 110_579.965_218_249, 0., 0.), + Coor4D::raw(222_638.981_586_547, -110_579.965_218_249, 0., 0.), + Coor4D::raw(-222_638.981_586_547, 110_579.965_218_249, 0., 0.), + Coor4D::raw(-222_638.981_586_547, -110_579.965_218_249, 0., 0.), ]; // Forward - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 20e-9); @@ -164,14 +164,14 @@ mod tests { let geo = [Coor4D::geo(55., 12., 0., 0.)]; let projected = [Coor4D::raw( - 748_713.257_925_886_777, - 4_106_573.862_841_270_398, + 748_713.257_925_886_8, + 4_106_573.862_841_270_4, 0., 0., )]; // Forward - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 20e-9); diff --git a/src/inner_op/omerc.rs b/src/inner_op/omerc.rs index f9818c8..cea5f6e 100644 --- a/src/inner_op/omerc.rs +++ b/src/inner_op/omerc.rs @@ -294,7 +294,7 @@ mod tests { let projected = [Coor2D::raw(679245.7281740266, 596562.7774687681)]; // Forward - let mut operands = geo.clone(); + let mut operands = geo; assert_eq!(1, ctx.apply(op, Fwd, &mut operands)?); for i in 0..operands.len() { @@ -308,7 +308,7 @@ mod tests { } // Forward - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { diff --git a/src/inner_op/somerc.rs b/src/inner_op/somerc.rs index 89ea473..8c2ad29 100644 --- a/src/inner_op/somerc.rs +++ b/src/inner_op/somerc.rs @@ -212,7 +212,7 @@ mod tests { let op = ctx.op("somerc lat_0=46.9524055555556 lon_0=7.43958333333333 k_0=1 x_0=2600000 y_0=1200000 ellps=bessel")?; let input = [Coor4D::raw(2531098.0, 1167363.0, 452.0, 0.0)]; - let mut operands = input.clone(); + let mut operands = input; let expected = [Coor4D::raw( 0.11413236074541264, @@ -239,7 +239,7 @@ mod tests { 452.0, 0.0, )]; - let mut operands = input.clone(); + let mut operands = input; let expected = [Coor4D::raw(2531098.0, 1167363.0, 452.0, 0.0)]; ctx.apply(op, Fwd, &mut operands)?; @@ -265,7 +265,7 @@ mod tests { Coor4D::gis(-2., -1., 0., 0.0), ]; - let mut operands = input.clone(); + let mut operands = input; let expected = [ Coor4D::raw(222638.98158654713, 110579.96521824898, 0., 0.0), diff --git a/src/inner_op/tmerc.rs b/src/inner_op/tmerc.rs index 74f1e72..b163b6b 100644 --- a/src/inner_op/tmerc.rs +++ b/src/inner_op/tmerc.rs @@ -327,7 +327,7 @@ mod tests { let definition = "tmerc k_0=0.9996 lon_0=9 x_0=500000"; let op = ctx.op(definition)?; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { @@ -350,9 +350,9 @@ mod tests { // Expected value from PROJ: // echo 1 52 0 0 | cct -d 15 proj=tmerc lat_0=49 lon_0=-2 k_0=0.9996012717 x_0=400000 y_0=-100000 ellps=airy -- - let projected = [Coor2D::raw(605909.130344302393496, 237803.365171569399536)]; + let projected = [Coor2D::raw(605_909.130_344_302_4, 237_803.365_171_569_4)]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { @@ -386,7 +386,7 @@ mod tests { Coor2D::raw(-455_673.814_189_040,-6_198_246.671_090_279) ]; - let mut operands = geo.clone(); + let mut operands = geo; assert_eq!(ctx.apply(op, Fwd, &mut operands)?, 4); for i in 0..operands.len() { assert_float_eq!(operands[i].0, projected[i].0, abs_all <= 1e-8); @@ -421,7 +421,7 @@ mod tests { Coor4D::raw(-455_673.814_189_040, 1e7-6_198_246.671_090_279, 0., 0.) ]; - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert!(operands[i].hypot2(&projected[i]) < 5e-3); diff --git a/src/inner_op/webmerc.rs b/src/inner_op/webmerc.rs index 7fbd80c..5daf22e 100644 --- a/src/inner_op/webmerc.rs +++ b/src/inner_op/webmerc.rs @@ -93,14 +93,14 @@ mod tests { let geo = [Coor4D::geo(55., 12., 0., 0.)]; let projected = [Coor4D::raw( - 1335833.889519282849505544, - 7361866.113051188178360462, + 1_335_833.889_519_282_8, + 7_361_866.113_051_188, 0., 0., )]; // Forward - let mut operands = geo.clone(); + let mut operands = geo; ctx.apply(op, Fwd, &mut operands)?; for i in 0..operands.len() { assert_float_eq!(operands[i].0, projected[i].0, abs_all <= 1e-8); diff --git a/src/math/series.rs b/src/math/series.rs index b7f3cec..3ce05d7 100644 --- a/src/math/series.rs +++ b/src/math/series.rs @@ -248,8 +248,8 @@ mod tests { let coefficients = [6., 5., 4., 3., 2., 1.]; let arg = [30f64.to_radians(), 60f64.to_radians()]; // Canonical result from Poder/Engsager implementation - let r = 248.658846388817693; - let i = -463.436347907636559; + let r = 248.658_846_388_817_7; + let i = -463.436_347_907_636_56; // Let's see if we can reproduce that... let sum = fourier::complex_sin(arg, &coefficients); assert!((sum[0] - r).abs() < 1e-14);