From add230cd03d6d0e97e6f5bfe9d0118508793ae2f Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Thu, 1 Sep 2011 23:07:03 -0700 Subject: [PATCH] Add feature_json() view. --- gazetteer/places/views.py | 6 ++++++ gazetteer/urls.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index c6a5d89..b0c6b3c 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -57,6 +57,12 @@ def search_json(request): } return render_to_json_response(d) +def feature_json(request, id): + id = str(id) + srid = int(request.GET.get("srid",4326)) + feature = get_object_or_404_json(Feature, pk=id) + return render_to_json_response(feature.get_geojson(srid)) + def search_related_json(request, id): # id = request.GET.get("id", "0") id = str(id) diff --git a/gazetteer/urls.py b/gazetteer/urls.py index 4ad1fe3..6f4fc39 100644 --- a/gazetteer/urls.py +++ b/gazetteer/urls.py @@ -10,9 +10,9 @@ urlpatterns = patterns('', # Example: # (r'^gazetteer/', include('gazetteer.foo.urls')), (r'^$', 'places.views.search'), - ('^search$', 'places.views.search'), + ('^search/?$', 'places.views.search'), ('^feature/search.json$', 'places.views.search_json'), -# ('^search_related$', 'places.views.search_related'), + ('^feature/(?P\d+).json$', 'places.views.feature_json'), ('^feature/(?P\d+)/similar.json$', 'places.views.search_related_json'), ('^auth_record.json$', 'places.views.auth_record_json'), ('^time_frame.json$', 'places.views.time_frame_json'),