Skip to content

Commit 975a28d

Browse files
committed
fixup! Implement ConvexHull for all geometry types
1 parent ca9c584 commit 975a28d

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

geo/src/algorithm/convex_hull/mod.rs

+1-29
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,4 @@ fn swap_remove_to_first<'a, T>(slice: &mut &'a mut [T], idx: usize) -> &'a mut T
106106
}
107107

108108
#[cfg(test)]
109-
mod tests {
110-
use crate::ConvexHull;
111-
use geo_types::{coord, polygon};
112-
113-
#[test]
114-
fn collection() {
115-
use crate::geometry::*;
116-
117-
let collection = GeometryCollection(vec![
118-
Point::new(0.0, 0.0).into(),
119-
Triangle::new(
120-
coord! { x: 1.0, y: 0.0},
121-
coord! { x: 4.0, y: 0.0},
122-
coord! { x: 4.0, y: 4.0 },
123-
)
124-
.into(),
125-
]);
126-
127-
let convex_hull = collection.convex_hull();
128-
assert_eq!(
129-
convex_hull,
130-
polygon![
131-
coord! { x: 4.0, y: 0.0 },
132-
coord! { x: 4.0, y: 4.0 },
133-
coord! { x: 0.0, y: 0.0 }
134-
]
135-
);
136-
}
137-
}
109+
mod test;

geo/src/algorithm/convex_hull/test.rs

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use super::ConvexHull;
2-
use crate::*;
1+
use super::*;
2+
use crate::geometry::*;
3+
use crate::{coord, line_string, polygon};
34

45
#[test]
56
fn convex_hull_multipoint_test() {
@@ -78,3 +79,26 @@ fn convex_hull_multipolygon_test() {
7879
let res = mp.convex_hull();
7980
assert_eq!(res.exterior().0, correct);
8081
}
82+
83+
#[test]
84+
fn collection() {
85+
let collection = GeometryCollection(vec![
86+
Point::new(0.0, 0.0).into(),
87+
Triangle::new(
88+
coord! { x: 1.0, y: 0.0},
89+
coord! { x: 4.0, y: 0.0},
90+
coord! { x: 4.0, y: 4.0 },
91+
)
92+
.into(),
93+
]);
94+
95+
let convex_hull = collection.convex_hull();
96+
assert_eq!(
97+
convex_hull,
98+
polygon![
99+
coord! { x: 4.0, y: 0.0 },
100+
coord! { x: 4.0, y: 4.0 },
101+
coord! { x: 0.0, y: 0.0 }
102+
]
103+
);
104+
}

0 commit comments

Comments
 (0)