Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add point lookup.

  • Loading branch information...
commit 439f57f583becdc1c9f0ad756393978cb7f2e43e 1 parent 5d85eee
@dracos authored
Showing with 12 additions and 1 deletion.
  1. +1 −1  README.textile
  2. +1 −0  boundaryline/urls.py
  3. +10 −0 boundaryline/views.py
View
2  README.textile
@@ -19,7 +19,7 @@ bc. ./manage.py import_councils ../data/county_region.shp ../data/district_borou
Make sure DEBUG is False, otherwise you'll soon run out of memory as it tries to remember all the SQL queries made.
-Those two commands import all the shape files for councils in Great Britain and pre-2010 Birmingham constituencies into a spatial database. That should be all you need to do - start up the dev web server, or whatever. The admin interface should let you view all the areas ("example screenshot":http://boundaryline.dracos.vm.bytemark.co.uk/static/bl-scrshot.png), including their boundaries. The front end will by default display Birmingham Council, but stick a different SNAC code on the end to view a different council, or /brum to view all the constituencies. Firefox 3 runs out of stack space on some of the larger shapes, and it's all a bit slow, but I'm sure there will be some way to display less detail at lower zoom levels.
+Those two commands import all the shape files for councils in Great Britain and pre-2010 Birmingham constituencies into a spatial database. That should be all you need to do - start up the dev web server, or whatever. The admin interface should let you view all the areas ("example screenshot":http://boundaryline.dracos.vm.bytemark.co.uk/static/bl-scrshot.png), including their boundaries. The front end will by default display Birmingham Council, but stick a different SNAC code on the end to view a different council, /brum to view all the constituencies, or /{E},{N} for which area is at that grid reference. Firefox 3 runs out of stack space on some of the larger shapes, and it's all a bit slow, but I'm sure there will be some way to display less detail at lower zoom levels.
The relevant bits of my Apache VirtualHost, for what it's worth, are as follows:
View
1  boundaryline/urls.py
@@ -2,6 +2,7 @@
urlpatterns = patterns('boundaryline.views',
(r'^wkt(?:/(?P<snac>.*?))$', 'wkt'),
+ (r'^(?P<easting>\d+),(?P<northing>\d+)$', 'point'),
(r'^brum$', 'brum'),
(r'^(?:(?P<snac>.*?))$', 'home'),
)
View
10 boundaryline/views.py
@@ -1,5 +1,6 @@
from django.shortcuts import render_to_response
from django.http import HttpResponse, Http404
+from django.contrib.gis.geos import Point
from models import Council
@@ -34,3 +35,12 @@ def wkt(request, snac='00CN'):
c.shape.transform(900913)
return HttpResponse(c.shape.wkt, content_type='text/plain')
+def point(request, easting, northing):
+ point = Point(int(easting), int(northing), srid=27700)
+ c = Council.objects.filter(shape__contains=point).exclude(code='999999')
+ if not c:
+ raise Http404
+ return render_to_response('council.html', {
+ 'council': c[0],
+ })
+
Please sign in to comment.
Something went wrong with that request. Please try again.