Skip to content

Commit cd2bc18

Browse files
committed
lint
1 parent daa6ea6 commit cd2bc18

File tree

1 file changed

+24
-68
lines changed

1 file changed

+24
-68
lines changed

src/curves.rs

+24-68
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> {
@@ -299,8 +299,10 @@ impl Curve for SphericalLineStringCurve {
299299

300300
fn is_valid(&self) -> bool {
301301
self.geom.coords_count() >= 2
302-
&& (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))
302+
&& (self.geom.coords_count() > 2 || !self.geom.is_closed())
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
@@ -667,11 +657,8 @@ mod tests {
667657
assert_eq!(1963056.4000812047, projected.distance_along_curve);
668658
assert_eq!(625574.8001320735, projected.offset);
669659

670-
// ################################################################################
671-
let mut new_york_to_paris = SphericalLineStringCurve::new(
672-
line_string![NEW_YORK, PARIS],
673-
1.,
674-
);
660+
let mut new_york_to_paris =
661+
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,8 @@ 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 =
689+
SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.);
705690

706691
let mut projection = CurveProjection {
707692
distance_along_curve: 1000000.,
@@ -720,10 +705,7 @@ mod tests {
720705
assert!(paris_to_new_york.resolve(projection).is_err());
721706

722707
// 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-
);
708+
let lille_to_perpignan = SphericalLineStringCurve::new(line_string![LILLE, PERPIGNAN], 1.);
727709

728710
let projection = CurveProjection {
729711
distance_along_curve: 500000.,
@@ -734,10 +716,7 @@ mod tests {
734716
assert_eq!(46.13397259680868, lille_to_perpignan_p.y());
735717

736718
// 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-
);
719+
let brest_to_nancy = SphericalLineStringCurve::new(line_string![BREST, NANCY], 1.);
741720

742721
let projection = CurveProjection {
743722
distance_along_curve: 500000.,
@@ -750,45 +729,27 @@ mod tests {
750729

751730
#[test]
752731
fn spherical_bbox() {
753-
let paris_to_new_york = SphericalLineStringCurve::new(
754-
line_string![PARIS, NEW_YORK],
755-
1.,
756-
);
732+
let paris_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.);
757733
let bbox = paris_to_new_york.bbox();
758734

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-
);
735+
assert_eq!(bbox.min(), coord! {x: -75.01, y: 39.71});
736+
assert_eq!(bbox.max(), coord! {x: 3.35, y: 49.86});
767737
}
768738

769739
#[test]
770740
fn spherical_intersect_segment() {
771741
// Note: following tests have been computed with a maximum length of curve of 100m, otherwise the curve is densified.
772742

773743
// 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-
);
744+
let paris_to_new_york = SphericalLineStringCurve::new(line_string![PARIS, NEW_YORK], 1.);
745+
let segment = Line::new(coord! {x: -36.77, y: 69.73}, coord! {x: -53.52, y: 15.34});
782746
assert_eq!(
783747
Some(point! {x: -42.50207557067806, y: 51.11700953497436}),
784748
paris_to_new_york.intersect_segment(segment)
785749
);
786750

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

794755
// Collinear: not tested
@@ -797,15 +758,10 @@ mod tests {
797758
// - is very rare in reality
798759

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

805-
let segment = Line::new(
806-
coord! {x: -70.78, y: 47.84},
807-
coord! {x: 9.29, y: 54.83},
808-
);
764+
let segment = Line::new(coord! {x: -70.78, y: 47.84}, coord! {x: 9.29, y: 54.83});
809765
assert!(paris_to_reykjavik_to_new_york
810766
.intersect_segment(segment)
811767
.is_some());

0 commit comments

Comments
 (0)