diff --git a/geonode/layers/models.py b/geonode/layers/models.py index ed019b06821..4ce7694c3d4 100644 --- a/geonode/layers/models.py +++ b/geonode/layers/models.py @@ -271,6 +271,19 @@ def keyword_csv(self): class Meta: abstract = True + + +def add_bbox_query(q, bbox): + '''modify the queryset q to limit to the provided bbox + + bbox - 4 tuple of floats representing x0,x1,y0,y1 + returns the modified query + ''' + q = q.filter(bbox_x0__gte=bbox[0]) + q = q.filter(bbox_x1__lte=bbox[1]) + q = q.filter(bbox_y0__gte=bbox[2]) + return q.filter(bbox_y1__lte=bbox[3]) + class Layer(ResourceBase): """ diff --git a/geonode/layers/templates/layers/layer_search.html b/geonode/layers/templates/layers/layer_search.html index 34e6cb2a2b4..7f58e06a9b4 100644 --- a/geonode/layers/templates/layers/layer_search.html +++ b/geonode/layers/templates/layers/layer_search.html @@ -79,14 +79,14 @@