Skip to content

Commit

Permalink
[UK] May 2024 Boundary-Line import.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed May 15, 2024
1 parent 4f6f274 commit 5396ef5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions mapit_gb/controls/2024-05.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# A control file for importing May 2024 Boundary-Line.

from mapit.models import Area, Generation


def check(name, type, country, geometry, ons_code, commit, **args):
"""Should return True if this area is NEW, False if we should match against
an ONS code, or an Area to be used as an override instead."""

if type != 'CED':
return False

current = Generation.objects.current()
if not current: # Fresh import
return False

# All the unit IDs have changed in this release. CEDs don't have ONS codes
# to match on, so instead we have to match on name (they should all be the same)
area = Area.objects.get(
type__code='CED',
names__type__code='O', names__name=name,
generation_low__lte=current, generation_high__gte=current,
polygons__polygon__contains=geometry.geos.point_on_surface
)
return area
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def handle_label(self, filename, **options):
except Code.DoesNotExist:
ons_code = None
elif ons_code:
m = Area.objects.get(codes__type=code_version, codes__code=ons_code)
m = Area.objects.exclude(type__code='WMCF').get(codes__type=code_version, codes__code=ons_code)
elif unit_id:
m = Area.objects.get(
codes__type=code_type_os, codes__code=unit_id, generation_high=current_generation)
Expand Down Expand Up @@ -217,4 +217,7 @@ def patch_boundary_line(self, name, ons_code, unit_id, area_code):
if area_code == 'UTW' and name == 'An Taobh Siar agus Nis Ward' and ons_code == 'S13003134':
return {'ons-code': 'S13002608'}

if area_code == 'DIW' and name == 'Loughton Fairmead Ward' and ons_code == 'E05015731':
return {'ons-code': 'E05015730'}

return {}

0 comments on commit 5396ef5

Please sign in to comment.