Fix canonical municipality partition parsing
This commit is contained in:
@@ -198,15 +198,9 @@ class VectorFeatureService:
|
|||||||
return None
|
return None
|
||||||
normalized_name = str(selection_area_name or "").strip()
|
normalized_name = str(selection_area_name or "").strip()
|
||||||
prefix = "Gemeente "
|
prefix = "Gemeente "
|
||||||
suffixes = (" - officiële grens", " - officiele grens")
|
|
||||||
if not normalized_name.startswith(prefix):
|
if not normalized_name.startswith(prefix):
|
||||||
return None
|
return None
|
||||||
municipality = normalized_name[len(prefix):]
|
municipality = normalized_name[len(prefix):].split(" - ", 1)[0].strip()
|
||||||
for suffix in suffixes:
|
|
||||||
if municipality.endswith(suffix):
|
|
||||||
municipality = municipality[: -len(suffix)]
|
|
||||||
break
|
|
||||||
municipality = municipality.strip()
|
|
||||||
return ("municipality", municipality) if municipality else None
|
return ("municipality", municipality) if municipality else None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ def test_regional_bwk_uses_only_canonical_preclipped_municipality_partitions() -
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert VectorFeatureService.preclipped_partition_filter(
|
assert VectorFeatureService.preclipped_partition_filter(
|
||||||
dataset, "Gemeente Mol - officiële grens"
|
dataset, "Gemeente Mol - officiele grens"
|
||||||
) == ("municipality", "Mol")
|
) == ("municipality", "Mol")
|
||||||
assert VectorFeatureService.preclipped_partition_filter(
|
assert VectorFeatureService.preclipped_partition_filter(
|
||||||
dataset, "Vervoerregio Kempen - officiële operationele grens"
|
dataset, "Vervoerregio Kempen - officiële operationele grens"
|
||||||
@@ -266,5 +266,5 @@ def test_regional_bwk_uses_only_canonical_preclipped_municipality_partitions() -
|
|||||||
|
|
||||||
dataset.provenance_metadata = {"operator_tool": "unrelated_operator.py"}
|
dataset.provenance_metadata = {"operator_tool": "unrelated_operator.py"}
|
||||||
assert VectorFeatureService.preclipped_partition_filter(
|
assert VectorFeatureService.preclipped_partition_filter(
|
||||||
dataset, "Gemeente Mol - officiële grens"
|
dataset, "Gemeente Mol - officiele grens"
|
||||||
) is None
|
) is None
|
||||||
|
|||||||
Reference in New Issue
Block a user