MCPcopy
hub / github.com/django/django / from_bbox

Method from_bbox

django/contrib/gis/geos/polygon.py:58–67  ·  view source on GitHub ↗

Construct a Polygon from a bounding box (4-tuple).

(cls, bbox)

Source from the content-addressed store, hash-verified

56
57 @classmethod
58 def from_bbox(cls, bbox):
59 "Construct a Polygon from a bounding box (4-tuple)."
60 x0, y0, x1, y1 = bbox
61 for z in bbox:
62 if not isinstance(z, (float, int)):
63 return GEOSGeometry(
64 "POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))"
65 % (x0, y0, x0, y1, x1, y1, x1, y0, x0, y0)
66 )
67 return Polygon(((x0, y0), (x0, y1), (x1, y1), (x1, y0), (x0, y0)))
68
69 # ### These routines are needed for list-like operation w/ListMixin ###
70 def _create_polygon(self, length, items):

Callers 5

test_polygonsMethod · 0.45
test06_spatial_filterMethod · 0.45

Calls 2

GEOSGeometryClass · 0.90
PolygonClass · 0.70

Tested by 5

test_polygonsMethod · 0.36
test06_spatial_filterMethod · 0.36