Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix #534 - return correct bbox in search results

- resolve an omission from the initial porting work
- ensure internal error results in a 500 response
- minor cleanup
  • Loading branch information...
commit 1421a058bac81209581535adf5836aa9a08b8423 1 parent 0c97669
Ian Schneider ischneider authored
5 geonode/search/normalizers.py
View
@@ -45,7 +45,7 @@ def _bbox(obj):
except AttributeError:
pass
# unknown extent, just give something that works
- extent = idx.extent.extent if idx else (-180,-90,180,90)
+ extent = idx.extent.extent if idx else map(str,(obj.bbox_x0, obj.bbox_y0, obj.bbox_x1, obj.bbox_y1))
return dict(minx=extent[0], miny=extent[1], maxx=extent[2], maxy=extent[3])
@@ -147,7 +147,6 @@ def populate(self, doc, exclude):
doc['category'] = mapobj.category,
doc['detail'] = reverse('map_detail', args=(mapobj.id,))
doc['owner'] = mapobj.owner.username
-# doc['owner_detail'] = reverse('about_storyteller', args=(map.owner.username,))
doc['owner_detail'] = mapobj.owner.get_absolute_url()
doc['last_modified'] = extension.date_fmt(mapobj.last_modified)
doc['_type'] = 'map'
@@ -181,7 +180,6 @@ def populate(self, doc, exclude):
doc['title'] = layer.title
doc['detail'] = layer.get_absolute_url()
if 'download_links' not in exclude:
- all_links = layer.link_set.all()
links = {}
for l in layer.link_set.all():
link = {}
@@ -202,7 +200,6 @@ def populate(self, doc, exclude):
owner = layer.owner
if owner:
doc['owner_detail'] = layer.owner.get_absolute_url()
-# doc['owner_detail'] = reverse('about_storyteller', args=(layer.owner.username,))
return doc
13 geonode/search/tests.py
View
@@ -160,6 +160,19 @@ def test_bbox_query(self):
self.search_assert(self.request(extent='-180,180,-90,90'), n_results=8)
self.search_assert(self.request(extent='0,10,0,10'), n_results=3)
self.search_assert(self.request(extent='0,1,0,1'), n_results=1)
+
+ def test_bbox_result(self):
+ # grab one and set the bounds
+ lyr = Layer.objects.all()[0]
+ lyr.bbox_x0 = -100
+ lyr.bbox_x1 = -90
+ lyr.bbox_y0 = 38
+ lyr.bbox_y1 = 40
+ lyr.save()
+
+ response = json.loads(self.request(lyr.title,type='layer').content)
+ self.assertEquals({u'minx': u'-100', u'miny': u'38', u'maxx': u'-90', u'maxy': u'40'},
+ response['results'][0]['bbox'])
def test_date_query(self):
self.search_assert(self.request(period='1980-01-01T00:00:00Z,1995-01-01T00:00:00Z'),
1  geonode/search/views.py
View
@@ -141,6 +141,7 @@ def search_api(request, **kwargs):
except Exception, ex:
if not isinstance(ex, BadQuery):
logger.exception("error during search")
+ raise ex
return HttpResponse(json.dumps({
'success' : False,
'errors' : [str(ex)]
Please sign in to comment.
Something went wrong with that request. Please try again.