mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
broadcast-areas: import LAs to wards dataset groups
instead of our shonky groupings Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -145,31 +145,16 @@ for f in geojson.loads(wards_filepath.read_text())["features"]:
|
|||||||
repo.insert_broadcast_areas(areas_to_add)
|
repo.insert_broadcast_areas(areas_to_add)
|
||||||
areas_to_add = []
|
areas_to_add = []
|
||||||
|
|
||||||
seen = set()
|
las_filepath = package_path / "Local Authorities May 2020.geojson"
|
||||||
for feature in geojson.loads(las_filepath.read_text())["features"]:
|
|
||||||
la_id = feature["properties"]["LAD19CD"]
|
|
||||||
group_name = feature["properties"]["LAD19NM"]
|
|
||||||
|
|
||||||
if la_id in seen:
|
for feature in geojson.loads(las_filepath.read_text())["features"]:
|
||||||
continue
|
la_id = feature["properties"]["lad20cd"]
|
||||||
seen.add(la_id)
|
group_name = feature["properties"]["lad20nm"]
|
||||||
|
|
||||||
print(group_name) # noqa: T001
|
print(group_name) # noqa: T001
|
||||||
|
|
||||||
group_id = dataset_id + "-" + la_id
|
group_id = dataset_id + "-" + la_id
|
||||||
areas = repo.get_all_areas_for_group(group_id)
|
|
||||||
|
|
||||||
features = [geojson.loads(f) for _, _, f, _ in areas]
|
|
||||||
shapes = [sgeom.shape(f["geometry"]) for f in features]
|
|
||||||
|
|
||||||
if len(shapes) == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
shape = shapes[0]
|
|
||||||
for other in shapes[1:]:
|
|
||||||
shape = shape.buffer(0).union(other.buffer(0))
|
|
||||||
|
|
||||||
feature = convert_shape_to_feature(shape)
|
|
||||||
simple_feature = deepcopy(feature)
|
simple_feature = deepcopy(feature)
|
||||||
simple_feature["geometry"] = simplify_geometry(simple_feature["geometry"])
|
simple_feature["geometry"] = simplify_geometry(simple_feature["geometry"])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user