Skip to content

Commit 2570fcb

Browse files
committed
lint
1 parent daa6ea6 commit 2570fcb

File tree

1 file changed

+20
-66
lines changed

1 file changed

+20
-66
lines changed

src/curves.rs

+20-66
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub struct SphericalLineStringCurve {
259259

260260
impl SphericalLineStringCurve {
261261
const DEFAULT_DENSIFY_BY: f64 = 100.0;
262-
262+
263263
/// Splits the [`LineString`] into smaller [`Curve`]s of at most `max_len` length.
264264
/// If the initial geometry is invalid, it returns an empty vector.
265265
pub fn new_fragmented(geom: LineString, max_len: f64, max_extent: f64) -> Vec<Self> {
@@ -300,7 +300,9 @@ impl Curve for SphericalLineStringCurve {
300300
fn is_valid(&self) -> bool {
301301
self.geom.coords_count() >= 2
302302
&& (self.geom.coords_count() > 2 || !self.geom.is_closed())
303-
&& (self.geom.coords().all(|coord| coord.x > -180.0 && coord.x < 180.0 && coord.y > -90.0 && coord.y < 90.0))
303+
&& (self.geom.coords().all(|coord| {
304+
coord.x > -180.0 && coord.x < 180.0 && coord.y > -90.0 && coord.y < 90.0
305+
}))
304306
}
305307

306308
fn project(&self, point: Point) -> Result<CurveProjection, CurveError> {
@@ -584,22 +586,13 @@ mod tests {
584586

585587
#[test]
586588
fn spherical_length() {
587-
let paris_to_new_york = SphericalLineStringCurve::new(
588-
line_string![PARIS, NEW_YORK],
589-
1.,
590-
);
589+
let paris_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.);
591590
assert_eq!(5837415.205720471, paris_to_new_york.length()); // 5837415.205720471 using [`HaversineLength`] and 5853101.331803938 using [`GeodesicLength`]
592591

593-
let lille_to_perpignan = SphericalLineStringCurve::new(
594-
line_string![LILLE, PERPIGNAN],
595-
1.,
596-
);
592+
let lille_to_perpignan = SphericalLineStringCurve::new(line_string![LILLE, PERPIGNAN], 1.);
597593
assert_eq!(882995.0489150163, lille_to_perpignan.length()); // 882995.0489150163 using [`HaversineLength`] and 882749.856002331 using [`GeodesicLength`]
598594

599-
let brest_to_nancy = SphericalLineStringCurve::new(
600-
line_string![BREST, NANCY],
601-
1.,
602-
);
595+
let brest_to_nancy = SphericalLineStringCurve::new(line_string![BREST, NANCY], 1.);
603596
assert_eq!(785611.8752324395, brest_to_nancy.length()); // 785611.8752324395 using [`HaversineLength`] and 787969.3534391255 using [`GeodesicLength`]
604597
}
605598

@@ -640,10 +633,7 @@ mod tests {
640633

641634
#[test]
642635
fn spherical_projection() {
643-
let mut paris_to_new_york = SphericalLineStringCurve::new(
644-
line_string![PARIS, NEW_YORK],
645-
1.,
646-
);
636+
let mut paris_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.,);
647637

648638
// Point is located on the right (north) of the curve
649639
let projected = paris_to_new_york
@@ -668,10 +658,7 @@ mod tests {
668658
assert_eq!(625574.8001320735, projected.offset);
669659

670660
// ################################################################################
671-
let mut new_york_to_paris = SphericalLineStringCurve::new(
672-
line_string![NEW_YORK, PARIS],
673-
1.,
674-
);
661+
let mut new_york_to_paris = SphericalLineStringCurve::new(line_string![NEW_YORK, PARIS], 1.);
675662

676663
// Point is located on the left (north) of the curve
677664
let projected = new_york_to_paris
@@ -698,10 +685,7 @@ mod tests {
698685

699686
#[test]
700687
fn spherical_resolve() {
701-
let mut paris_to_new_york = SphericalLineStringCurve::new(
702-
line_string![PARIS, NEW_YORK],
703-
1.,
704-
);
688+
let mut paris_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.);
705689

706690
let mut projection = CurveProjection {
707691
distance_along_curve: 1000000.,
@@ -720,10 +704,7 @@ mod tests {
720704
assert!(paris_to_new_york.resolve(projection).is_err());
721705

722706
// Test on a linestring where only the longitude changes (latitude remains almost the same)
723-
let lille_to_perpignan = SphericalLineStringCurve::new(
724-
line_string![LILLE, PERPIGNAN],
725-
1.,
726-
);
707+
let lille_to_perpignan = SphericalLineStringCurve::new(line_string![LILLE, PERPIGNAN], 1.);
727708

728709
let projection = CurveProjection {
729710
distance_along_curve: 500000.,
@@ -734,10 +715,7 @@ mod tests {
734715
assert_eq!(46.13397259680868, lille_to_perpignan_p.y());
735716

736717
// Test on a linestring where only the latitude changes (longitude remains almost the same)
737-
let brest_to_nancy = SphericalLineStringCurve::new(
738-
line_string![BREST, NANCY],
739-
1.,
740-
);
718+
let brest_to_nancy = SphericalLineStringCurve::new(line_string![BREST, NANCY], 1.);
741719

742720
let projection = CurveProjection {
743721
distance_along_curve: 500000.,
@@ -750,45 +728,27 @@ mod tests {
750728

751729
#[test]
752730
fn spherical_bbox() {
753-
let paris_to_new_york = SphericalLineStringCurve::new(
754-
line_string![PARIS, NEW_YORK],
755-
1.,
756-
);
731+
let paris_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.);
757732
let bbox = paris_to_new_york.bbox();
758733

759-
assert_eq!(
760-
bbox.min(),
761-
coord! {x: -75.01, y: 39.71}
762-
);
763-
assert_eq!(
764-
bbox.max(),
765-
coord! {x: 3.35, y: 49.86}
766-
);
734+
assert_eq!(bbox.min(), coord! {x: -75.01, y: 39.71});
735+
assert_eq!(bbox.max(), coord! {x: 3.35, y: 49.86});
767736
}
768737

769738
#[test]
770739
fn spherical_intersect_segment() {
771740
// Note: following tests have been computed with a maximum length of curve of 100m, otherwise the curve is densified.
772741

773742
// Intersection
774-
let paris_to_new_york = SphericalLineStringCurve::new(
775-
line_string![PARIS, NEW_YORK],
776-
1.,
777-
);
778-
let segment = Line::new(
779-
coord! {x: -36.77, y: 69.73},
780-
coord! {x: -53.52, y: 15.34},
781-
);
743+
let paris_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.);
744+
let segment = Line::new(coord! {x: -36.77, y: 69.73}, coord! {x: -53.52, y: 15.34});
782745
assert_eq!(
783746
Some(point! {x: -42.50207557067806, y: 51.11700953497436}),
784747
paris_to_new_york.intersect_segment(segment)
785748
);
786749

787750
// No intersection
788-
let segment = Line::new(
789-
coord! {x: -88.45, y: 20.76},
790-
coord! {x:19.04, y: 41.32},
791-
);
751+
let segment = Line::new(coord! {x: -88.45, y: 20.76}, coord! {x:19.04, y: 41.32});
792752
assert!(paris_to_new_york.intersect_segment(segment).is_none());
793753

794754
// Collinear: not tested
@@ -797,15 +757,9 @@ mod tests {
797757
// - is very rare in reality
798758

799759
// Multiple intersection
800-
let paris_to_reykjavik_to_new_york = SphericalLineStringCurve::new(
801-
line_string![PARIS, REYKJAVIK, NEW_YORK],
802-
1.,
803-
);
760+
let paris_to_reykjavik_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, REYKJAVIK, NEW_YORK], 1.);
804761

805-
let segment = Line::new(
806-
coord! {x: -70.78, y: 47.84},
807-
coord! {x: 9.29, y: 54.83},
808-
);
762+
let segment = Line::new(coord! {x: -70.78, y: 47.84}, coord! {x: 9.29, y: 54.83});
809763
assert!(paris_to_reykjavik_to_new_york
810764
.intersect_segment(segment)
811765
.is_some());

0 commit comments

Comments
 (0)