Add library of test areas

This is a temporary addition so we can test out some functionality.
This commit is contained in:
Chris Hill-Scott
2021-02-19 10:43:24 +00:00
parent b4b1fd641c
commit f55a8bf4b8
5 changed files with 68 additions and 2 deletions

View File

@@ -85,6 +85,7 @@ def estimate_number_of_smartphones_in_area(country_or_ward_code):
)
test_filepath = source_files_path / "Test.geojson"
ctry19_filepath = source_files_path / "Countries.geojson"
# https://geoportal.statistics.gov.uk/datasets/wards-may-2020-boundaries-uk-bgc
@@ -147,6 +148,37 @@ for population_filepath in (
]
def add_test_areas():
dataset_id = 'test'
dataset_geojson = geojson.loads(test_filepath.read_text())
repo.insert_broadcast_area_library(
dataset_id,
name='Test areas',
name_singular='test area',
is_group=False,
)
areas_to_add = []
for feature in dataset_geojson["features"]:
f_id = feature["properties"]['id']
f_name = feature["properties"]['name']
print() # noqa: T001
print(f_name) # noqa: T001
feature, _ = polygons_and_simplified_polygons(
feature["geometry"]
)
areas_to_add.append([
f'{dataset_id}-{f_id}', f_name,
dataset_id, None,
feature, feature,
0,
])
repo.insert_broadcast_areas(areas_to_add, keep_old_polygons)
def add_countries():
dataset_id = 'ctry19'
dataset_geojson = geojson.loads(ctry19_filepath.read_text())
@@ -291,6 +323,7 @@ if keep_old_polygons:
else:
repo.delete_db()
repo.create_tables()
add_test_areas()
add_countries()
add_wards_local_authorities_and_counties()

View File

@@ -0,0 +1,20 @@
{
"type":"FeatureCollection",
"features":[{
"type": "Feature",
"properties": {
"id": "santa-claus-village-rovaniemi",
"name": "Santa Claus Village, Rovaniemi"
},
"geometry": {
"type":"Polygon",
"coordinates": [[
[25.8890, 66.5500],
[25.8890, 66.551],
[25.8910, 66.551],
[25.8910, 66.5500],
[25.889, 66.55000]
]]
}
}]
}