Add feature_json() view.

This commit is contained in:
Schuyler Erle 2011-09-01 23:07:03 -07:00
parent 958264127a
commit add230cd03
2 changed files with 8 additions and 2 deletions

View File

@ -57,6 +57,12 @@ def search_json(request):
} }
return render_to_json_response(d) 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): def search_related_json(request, id):
# id = request.GET.get("id", "0") # id = request.GET.get("id", "0")
id = str(id) id = str(id)

View File

@ -10,9 +10,9 @@ urlpatterns = patterns('',
# Example: # Example:
# (r'^gazetteer/', include('gazetteer.foo.urls')), # (r'^gazetteer/', include('gazetteer.foo.urls')),
(r'^$', 'places.views.search'), (r'^$', 'places.views.search'),
('^search$', 'places.views.search'), ('^search/?$', 'places.views.search'),
('^feature/search.json$', 'places.views.search_json'), ('^feature/search.json$', 'places.views.search_json'),
# ('^search_related$', 'places.views.search_related'), ('^feature/(?P<id>\d+).json$', 'places.views.feature_json'),
('^feature/(?P<id>\d+)/similar.json$', 'places.views.search_related_json'), ('^feature/(?P<id>\d+)/similar.json$', 'places.views.search_related_json'),
('^auth_record.json$', 'places.views.auth_record_json'), ('^auth_record.json$', 'places.views.auth_record_json'),
('^time_frame.json$', 'places.views.time_frame_json'), ('^time_frame.json$', 'places.views.time_frame_json'),