def get_bbox_intersect(one, two): """ Finds the intersection of two bounding boxes in the same SRS :param one: The first bbox tuple (w, s, e, n) :param two: The second bbox tuple (w, s, e, n) :return: A bounding box tuple where one and two overlap, or None if there is no overlap """ a_x0, a_y0, a_x1, a_y1 = one b_x0, b_y0, b_x1, b_y1 = two if mapproxy_grid.bbox_intersects(one, two): return max(a_x0, b_x0), max(a_y0, b_y0), min(a_x1, b_x1), min(a_y1, b_y1) else: return None
def intersects(self, bbox, srs): bbox = self._bbox_in_coverage_srs(bbox, srs) return bbox_intersects(self.bbox, bbox)
def intersects(self, other): if not isinstance(other, MapExtent): raise NotImplemented return bbox_intersects(self.bbox, other.bbox_for(self.srs))
def test_overlap(self): b1 = (0, 0, 10, 10) b2 = (-5, -5, 5, 5) assert bbox_intersects(b1, b2) assert bbox_intersects(b2, b1)
def test_full_contains(self): b1 = (0, 0, 10, 10) b2 = (2, 2, 8, 8) assert bbox_intersects(b1, b2) assert bbox_intersects(b2, b1)
def test_no_intersect_touch_side(self): b1 = (0, 0, 10, 10) b2 = (0, 10, 10, 20) assert not bbox_intersects(b1, b2) assert not bbox_intersects(b2, b1)
def test_no_intersect_only_vertical(self): b1 = (0, 0, 10, 10) b2 = (20, 0, 30, 10) assert not bbox_intersects(b1, b2) assert not bbox_intersects(b2, b1)
def test_no_intersect(self): b1 = (0, 0, 10, 10) b2 = (20, 20, 30, 30) assert not bbox_intersects(b1, b2) assert not bbox_intersects(b2, b1)