use poly bboxes

This commit is contained in:
Josh Baker 2018-03-08 12:16:12 -07:00
parent 70bdd49acb
commit 86887ae60f
2 changed files with 11 additions and 0 deletions

View File

@ -29,6 +29,7 @@ func fillMultiPolygon(coordinates [][][]Position, bbox *BBox, err error) (MultiP
Coordinates: coordinates,
BBox: bbox,
bboxDefined: bboxDefined,
polygons: polygons,
}, err
}

View File

@ -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 {