Skip to content

Commit

Permalink
Merge #431
Browse files Browse the repository at this point in the history
431: Add conditional Eq impl for Coordinate, maybe other types? r=frewsxcv a=nick-parker

I haven't written tests or anything for this but I wanted to throw the PR in to get discussion started.

Many geometry algorithms eg this [optimal algorithm for computing mesh cross-sections and reconstructing the polygons](https://www.researchgate.net/publication/309619647_An_Optimal_Algorithm_for_3D_Triangle_Mesh_Slicing) use Hashtables or similar to keep track of coordinates. This impl lets me put geo Coordinate structs in the Hashtable instead of dealing with a separate struct just for this step.

I haven't put much thought into whether similar one-liner Eq impl's should be added for Linestring, Polygon, etc but I don't really see why not. The use cases are rarer but probably still exist.

Co-authored-by: Nick Parker <nmp67@cornell.edu>
  • Loading branch information
bors[bot] and nick-parker committed Mar 29, 2020
2 parents 2b69b04 + 5887f91 commit 2763279
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions geo-types/src/coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ where
pub y: T,
}

impl<T: CoordinateType> std::cmp::Eq for Coordinate<T> where T: std::cmp::Eq {}

impl<T: CoordinateType> From<(T, T)> for Coordinate<T> {
fn from(coords: (T, T)) -> Self {
Coordinate {
Expand Down

0 comments on commit 2763279

Please sign in to comment.