Skip to content

Commit 3e00ef9

Browse files
etromblyfrewsxcv
authored andcommitted
Add contains point impl for bbox
1 parent d932c50 commit 3e00ef9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/algorithm/contains.rs

+9
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ impl<T> Contains<LineString<T>> for Polygon<T>
152152
}
153153
}
154154

155+
156+
impl<T> Contains<Point<T>> for Bbox<T>
157+
where T: Float
158+
{
159+
fn contains(&self, p: &Point<T>) -> bool {
160+
p.x() >= self.xmin && p.x() <= self.xmax && p.y() >= self.ymin && p.y() <= self.ymax
161+
}
162+
}
163+
155164
impl<T> Contains<Bbox<T>> for Bbox<T>
156165
where T: Float
157166
{

src/algorithm/intersects.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<T> Intersects<Bbox<T>> for Bbox<T>
7373
{
7474
fn intersects(&self, bbox: &Bbox<T>) -> bool {
7575
// line intersects inner or outer polygon edge
76-
if bbox.contains(&self) {
76+
if bbox.contains(self) {
7777
return false
7878
} else {
7979
(self.xmin >= bbox.xmin && self.xmin <= bbox.xmax || self.xmax >= bbox.xmin && self.xmax <= bbox.xmax) &&

0 commit comments

Comments
 (0)