Skip to content

Commit

Permalink
Add contains point impl for bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
etrombly authored and frewsxcv committed May 7, 2017
1 parent d932c50 commit 3e00ef9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/algorithm/contains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ impl<T> Contains<LineString<T>> for Polygon<T>
}
}


impl<T> Contains<Point<T>> for Bbox<T>
where T: Float
{
fn contains(&self, p: &Point<T>) -> bool {
p.x() >= self.xmin && p.x() <= self.xmax && p.y() >= self.ymin && p.y() <= self.ymax
}
}

impl<T> Contains<Bbox<T>> for Bbox<T>
where T: Float
{
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/intersects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<T> Intersects<Bbox<T>> for Bbox<T>
{
fn intersects(&self, bbox: &Bbox<T>) -> bool {
// line intersects inner or outer polygon edge
if bbox.contains(&self) {
if bbox.contains(self) {
return false
} else {
(self.xmin >= bbox.xmin && self.xmin <= bbox.xmax || self.xmax >= bbox.xmin && self.xmax <= bbox.xmax) &&
Expand Down

0 comments on commit 3e00ef9

Please sign in to comment.