Scope bounded coverage to persisted extents
This commit is contained in:
@@ -422,6 +422,7 @@ class CoverageRegistryService:
|
||||
definition: _SourceDefinition,
|
||||
theme: str,
|
||||
zone: str,
|
||||
selection: Any,
|
||||
) -> list[Dataset]:
|
||||
if definition.operational_themes and theme not in definition.operational_themes:
|
||||
return []
|
||||
@@ -444,6 +445,18 @@ class CoverageRegistryService:
|
||||
coverage_zones = metadata.get("coverage_zones") or metadata.get("coverage_zone") or []
|
||||
if isinstance(coverage_zones, str):
|
||||
coverage_zones = [coverage_zones]
|
||||
acquired_bbox = metadata.get("bbox_epsg4326")
|
||||
if (
|
||||
definition.contract.acquisition_mode == "bounded_api"
|
||||
and isinstance(acquired_bbox, list)
|
||||
and len(acquired_bbox) == 4
|
||||
):
|
||||
try:
|
||||
acquired_scope = box(*(float(value) for value in acquired_bbox))
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
if not acquired_scope.is_valid or not acquired_scope.covers(selection):
|
||||
continue
|
||||
layer_matches = not layer_names or dataset.reference_layer_name in layer_names
|
||||
zone_matches = not coverage_zones or zone in coverage_zones or "belgium" in coverage_zones
|
||||
if layer_matches and zone_matches:
|
||||
@@ -456,6 +469,7 @@ class CoverageRegistryService:
|
||||
zone: str,
|
||||
theme: str,
|
||||
datasets: list[Dataset],
|
||||
selection: Any,
|
||||
) -> CoverageResolutionItem:
|
||||
definitions = [
|
||||
definition
|
||||
@@ -481,6 +495,7 @@ class CoverageRegistryService:
|
||||
definition,
|
||||
theme,
|
||||
zone,
|
||||
selection,
|
||||
)
|
||||
materialized.extend(matches)
|
||||
if matches:
|
||||
@@ -535,7 +550,12 @@ class CoverageRegistryService:
|
||||
)
|
||||
|
||||
items = [
|
||||
CoverageRegistryService._resolve_item(zone=zone, theme=theme, datasets=datasets)
|
||||
CoverageRegistryService._resolve_item(
|
||||
zone=zone,
|
||||
theme=theme,
|
||||
datasets=datasets,
|
||||
selection=selection,
|
||||
)
|
||||
for zone in zones
|
||||
for theme in requested_themes
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user