Federate official Belgium data sources
This commit is contained in:
@@ -27,6 +27,7 @@ class GeographicScope:
|
||||
scope_type: str
|
||||
limitation_message: str
|
||||
members: tuple[ScopeMember, ...]
|
||||
all_municipalities: bool = False
|
||||
|
||||
@property
|
||||
def nis_codes(self) -> tuple[str, ...]:
|
||||
@@ -96,18 +97,37 @@ KEMPEN_TRANSPORT_REGION_SCOPE = GeographicScope(
|
||||
),
|
||||
)
|
||||
|
||||
BELGIUM_SCOPE = GeographicScope(
|
||||
key="belgium",
|
||||
display_name="België",
|
||||
project_name="Belgium and North Sea Workbench",
|
||||
project_region="Belgium and Belgian North Sea",
|
||||
area_name="Belgium land",
|
||||
authority_name="National Geographic Institute (NGI), AdminVector",
|
||||
authority_url="https://www.geo.be/catalog/details/fb1e2993-2020-428c-9188-eb5f75e284b9",
|
||||
scope_type="country",
|
||||
limitation_message=(
|
||||
"De nationale Statbel-sectorlaag dekt het Belgische landgebied. "
|
||||
"Belgische maritieme zones bevatten geen statistische bevolkingssectoren."
|
||||
),
|
||||
members=(),
|
||||
all_municipalities=True,
|
||||
)
|
||||
|
||||
|
||||
GEOGRAPHIC_SCOPES = {
|
||||
scope.key: scope
|
||||
for scope in (MOL_SCOPE, KEMPEN_TRANSPORT_REGION_SCOPE)
|
||||
for scope in (MOL_SCOPE, KEMPEN_TRANSPORT_REGION_SCOPE, BELGIUM_SCOPE)
|
||||
}
|
||||
|
||||
|
||||
def validate_scope(scope: GeographicScope) -> None:
|
||||
if not scope.key or not scope.project_name or not scope.area_name:
|
||||
raise ValueError("Geographic scope identity fields must not be empty")
|
||||
if len(scope.members) == 0:
|
||||
if len(scope.members) == 0 and not scope.all_municipalities:
|
||||
raise ValueError(f"Geographic scope {scope.key} has no members")
|
||||
if scope.all_municipalities and scope.scope_type != "country":
|
||||
raise ValueError(f"Geographic scope {scope.key} can include all municipalities only for a country scope")
|
||||
names = [member.name.casefold() for member in scope.members]
|
||||
codes = [member.nis_code for member in scope.members]
|
||||
if len(names) != len(set(names)):
|
||||
|
||||
Reference in New Issue
Block a user