Skip to content
This repository
Browse code

Add an 'intersects' query type

This new query type finds any areas that intersect the given
area.
  • Loading branch information...
commit 3350406aa7619d14e4236bc6160a6183d3403c7b 1 parent 473387d
Mark Longair authored January 10, 2013
5  mapit/templates/mapit/api/area.html
@@ -76,6 +76,7 @@
76 76
                     <li>/area/<i>[area ID]</i>/covers
77 77
                     <li>/area/<i>[area ID]</i>/covered
78 78
                     <li>/area/<i>[area ID]</i>/coverlaps
  79
+                    <li>/area/<i>[area ID]</i>/intersects
79 80
 {% endif %}
80 81
                 </ul></dd>
81 82
                 <dt>Optional query parameters:</dt>
@@ -101,6 +102,8 @@
101 102
     <a rel="nofollow" href="{% url mapit_index %}area/65622/covered.html">/area/65622/covered.html</a>
102 103
     <li>All constituencies covered by or overlapping Barking and Dagenham:
103 104
     <a rel="nofollow" href="{% url mapit_index %}area/2511/coverlaps.html?type=WMC">/area/2511/coverlaps.html?type=WMC</a>
  105
+    <li>All areas that intersect Cambridgeshire:
  106
+    <a rel="nofollow" href="{% url mapit_index %}area/2218/intersects.html">/area/2511/intersects.html</a>
104 107
 </ul>
105 108
 {% endif %}
106 109
 {% if country == 'NO' %}
@@ -121,6 +124,8 @@
121 124
     <a rel="nofollow" href="{% url mapit_index %}area/25495/covered.html">/area/25495/covered.html</a>
122 125
     <li>All areas covered by or overlapping Cambridgeshire:
123 126
     <a rel="nofollow" href="{% url mapit_index %}area/25495/coverlaps.html">/area/25495/coverlaps.html</a>
  127
+    <li>All areas that intersect Cambridgeshire:
  128
+    <a rel="nofollow" href="{% url mapit_index %}area/25495/intersects.html">/area/25495/intersects.html</a>
124 129
 </ul>
125 130
 {% endif %}
126 131
                 </dd>
1  mapit/templates/mapit/area.html
@@ -87,6 +87,7 @@
87 87
                     <li><a rel="nofollow" href="{% url mapit_index %}area/{{ area.id }}/covered.html">Covering this area</a></li>
88 88
                     <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>
89 89
                     <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>
  90
+                    <li><a rel="nofollow" href="{% url mapit_index %}area/{{ area.id }}/intersects.html{{ geotype.intersects.0 }}">Intersects this area{{ geotype.intersects.1 }}</a></li>
90 91
                 </ul>
91 92
 {% endif %}
92 93
             </li>
1  mapit/urls.py
@@ -25,6 +25,7 @@
25 25
     (r'^area/(?P<area_id>[0-9]+)/covers%s$' % format_end, 'mapit.views.areas.area_covers'),
26 26
     (r'^area/(?P<area_id>[0-9]+)/covered%s$' % format_end, 'mapit.views.areas.area_covered'),
27 27
     (r'^area/(?P<area_id>[0-9]+)/coverlaps%s$' % format_end, 'mapit.views.areas.area_coverlaps'),
  28
+    (r'^area/(?P<area_id>[0-9]+)/intersects%s$' % format_end, 'mapit.views.areas.area_intersects'),
28 29
     (r'^area/(?P<area_id>[0-9A-Z]+)\.(?P<format>kml|geojson|wkt)$', 'mapit.views.areas.area_polygon'),
29 30
     (r'^area/(?P<srid>[0-9]+)/(?P<area_id>[0-9]+)\.(?P<format>kml|json|geojson|wkt)$', 'mapit.views.areas.area_polygon'),
30 31
 
4  mapit/views/areas.py
@@ -173,6 +173,10 @@ def area_coverlaps(request, area_id, format='json'):
173 173
 def area_covered(request, area_id, format='json'):
174 174
     return area_intersect('covers', 'Areas that cover %s', request, area_id, format)
175 175
 
  176
+@ratelimit(minutes=3, requests=100)
  177
+def area_intersects(request, area_id, format='json'):
  178
+    return area_intersect('intersects', 'Areas that intersect %s', request, area_id, format)
  179
+
176 180
 def add_codes(areas):
177 181
     codes = Code.objects.select_related('type').filter(area__in=areas)
178 182
     lookup = {}

0 notes on commit 3350406

Please sign in to comment.
Something went wrong with that request. Please try again.