Skip to content

Commit 51e8a11

Browse files
committed
Remove unnecessary additions from PR
+ revert back to not deriving `PartialOrd` for `Coordinate` + remove unused `ConvexHull` trait in graham_hull impl
1 parent 9f1af54 commit 51e8a11

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

geo-types/src/coordinate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use approx::{AbsDiffEq, RelativeEq, UlpsEq};
99
/// as an envelope, a precision model, and spatial reference system
1010
/// information), a `Coordinate` only contains ordinate values and accessor
1111
/// methods.
12-
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy, Debug, Hash)]
12+
#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash)]
1313
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
1414
pub struct Coordinate<T>
1515
where

geo/src/algorithm/graham_hull.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Coordinate, CoordinateType, LineString};
1+
use crate::{Coordinate, LineString};
22
use super::kernels::*;
33

44
// Utility function: swap idx to head(0th position), remove
@@ -87,15 +87,10 @@ where
8787
output
8888
}
8989

90-
pub trait ConvexHull {
91-
type Scalar: CoordinateType;
92-
fn convex_hull(&self) -> LineString<Self::Scalar>;
93-
}
94-
95-
9690
#[cfg(test)]
9791
mod test {
9892
use super::*;
93+
use geo_types::CoordinateType;
9994

10095
fn is_ccw_convex<T: CoordinateType + HasKernel>(mut ls: &[Coordinate<T>]) -> bool {
10196
if ls.len() > 1 && ls[0] == ls[ls.len() - 1] {

geo/src/utils.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Internal utility functions, types, and data structures.
22
33
use crate::contains::Contains;
4+
use geo_types::{CoordinateType, Coordinate};
45

56
/// Partition a mutable slice in-place so that it contains all elements for
67
/// which `predicate(e)` is `true`, followed by all elements for which
@@ -131,21 +132,14 @@ where
131132
/// other words, point with minimum `x` coord, and breaking
132133
/// ties with minimum `y` coord. Should only be called on a
133134
/// non-empty slice with no `nan` coordinates.
134-
pub fn lexicographically_least_index<T: Copy + PartialOrd>(pts: &[T]) -> usize {
135-
assert!(pts.len() > 0);
136-
137-
let mut min: Option<(usize, T)> = None;
138-
for (i, pt) in pts.iter().enumerate() {
139-
if let Some((_, min_pt)) = min {
140-
if pt < &min_pt {
141-
min = Some( (i, *pt) )
142-
}
143-
} else {
144-
min = Some( (i, *pt) )
145-
}
146-
}
135+
pub fn lexicographically_least_index<T: CoordinateType>(pts: &[Coordinate<T>]) -> usize {
136+
137+
pts.iter().enumerate().min_by(
138+
|(_, p), (_, q)| p.x.partial_cmp(&q.x).unwrap().then(
139+
p.y.partial_cmp(&q.y).unwrap()
140+
)
141+
).unwrap().0
147142

148-
min.unwrap().0
149143
}
150144

151145
#[cfg(test)]

0 commit comments

Comments
 (0)