diff --git a/geojson/multipolygon.go b/geojson/multipolygon.go index 17343974..af2dc96a 100644 --- a/geojson/multipolygon.go +++ b/geojson/multipolygon.go @@ -29,6 +29,7 @@ func fillMultiPolygon(coordinates [][][]Position, bbox *BBox, err error) (MultiP Coordinates: coordinates, BBox: bbox, bboxDefined: bboxDefined, + polygons: polygons, }, err } diff --git a/geojson/polygon.go b/geojson/polygon.go index 4e6db8bf..375b06c3 100644 --- a/geojson/polygon.go +++ b/geojson/polygon.go @@ -103,6 +103,11 @@ func (g Polygon) WithinBBox(bbox BBox) bool { if len(g.Coordinates) == 0 { return false } + if g.BBox != nil { + if !rectBBox(*g.BBox).IntersectsRect(rectBBox(bbox)) { + return false + } + } rbbox := rectBBox(bbox) ext, holes := polyExteriorHoles(g.Coordinates) if len(holes) > 0 { @@ -122,6 +127,11 @@ func (g Polygon) IntersectsBBox(bbox BBox) bool { if len(g.Coordinates) == 0 { return false } + if g.BBox != nil { + if !rectBBox(*g.BBox).IntersectsRect(rectBBox(bbox)) { + return false + } + } rbbox := rectBBox(bbox) ext, holes := polyExteriorHoles(g.Coordinates) if len(holes) > 0 {