Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add an 'intersects' query type

This new query type finds any areas that intersect the given
area.
  • Loading branch information...
commit 4db3a89aca2703f599c3d33d32dc140956c8361d 1 parent e88e2a4
@mhl mhl authored
View
5 mapit/templates/mapit/api/area.html
@@ -76,6 +76,7 @@
<li>/area/<i>[area ID]</i>/covers
<li>/area/<i>[area ID]</i>/covered
<li>/area/<i>[area ID]</i>/coverlaps
+ <li>/area/<i>[area ID]</i>/intersects
{% endif %}
</ul></dd>
<dt>Optional query parameters:</dt>
@@ -101,6 +102,8 @@
<a rel="nofollow" href="{% url mapit_index %}area/65622/covered.html">/area/65622/covered.html</a>
<li>All constituencies covered by or overlapping Barking and Dagenham:
<a rel="nofollow" href="{% url mapit_index %}area/2511/coverlaps.html?type=WMC">/area/2511/coverlaps.html?type=WMC</a>
+ <li>All areas that intersect Cambridgeshire:
+ <a rel="nofollow" href="{% url mapit_index %}area/2218/intersects.html">/area/2511/intersects.html</a>
</ul>
{% endif %}
{% if country == 'NO' %}
@@ -121,6 +124,8 @@
<a rel="nofollow" href="{% url mapit_index %}area/25495/covered.html">/area/25495/covered.html</a>
<li>All areas covered by or overlapping Cambridgeshire:
<a rel="nofollow" href="{% url mapit_index %}area/25495/coverlaps.html">/area/25495/coverlaps.html</a>
+ <li>All areas that intersect Cambridgeshire:
+ <a rel="nofollow" href="{% url mapit_index %}area/25495/intersects.html">/area/25495/intersects.html</a>
</ul>
{% endif %}
</dd>
View
1  mapit/templates/mapit/area.html
@@ -87,6 +87,7 @@
<li><a rel="nofollow" href="{% url mapit_index %}area/{{ area.id }}/covered.html">Covering this area</a></li>
<li><a rel="nofollow" href="{% url mapit_index %}area/{{ area.id }}/covers.html{{ geotype.covers.0 }}">Covered by this area{{ geotype.covers.1 }}</a></li>
<li><a rel="nofollow" href="{% url mapit_index %}area/{{ area.id }}/coverlaps.html{{ geotype.coverlaps.0 }}">Covered by or overlapping this area{{ geotype.coverlaps.1 }}</a></li>
+ <li><a rel="nofollow" href="{% url mapit_index %}area/{{ area.id }}/intersects.html{{ geotype.intersects.0 }}">Intersects this area{{ geotype.intersects.1 }}</a></li>
</ul>
{% endif %}
</li>
View
1  mapit/urls.py
@@ -25,6 +25,7 @@
(r'^area/(?P<area_id>[0-9]+)/covers%s$' % format_end, 'mapit.views.areas.area_covers'),
(r'^area/(?P<area_id>[0-9]+)/covered%s$' % format_end, 'mapit.views.areas.area_covered'),
(r'^area/(?P<area_id>[0-9]+)/coverlaps%s$' % format_end, 'mapit.views.areas.area_coverlaps'),
+ (r'^area/(?P<area_id>[0-9]+)/intersects%s$' % format_end, 'mapit.views.areas.area_intersects'),
(r'^area/(?P<area_id>[0-9A-Z]+)\.(?P<format>kml|geojson|wkt)$', 'mapit.views.areas.area_polygon'),
(r'^area/(?P<srid>[0-9]+)/(?P<area_id>[0-9]+)\.(?P<format>kml|json|geojson|wkt)$', 'mapit.views.areas.area_polygon'),
View
4 mapit/views/areas.py
@@ -173,6 +173,10 @@ def area_coverlaps(request, area_id, format='json'):
def area_covered(request, area_id, format='json'):
return area_intersect('covers', 'Areas that cover %s', request, area_id, format)
+@ratelimit(minutes=3, requests=100)
+def area_intersects(request, area_id, format='json'):
+ return area_intersect('intersects', 'Areas that intersect %s', request, area_id, format)
+
def add_codes(areas):
codes = Code.objects.select_related('type').filter(area__in=areas)
lookup = {}
Please sign in to comment.
Something went wrong with that request. Please try again.