Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove checking against crs valid extent #1076

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions datacube_ows/index/postgis/product_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ def create_range_entry(layer: OWSNamedLayer, cache: dict[LayerSignature, list[st
base_extent = prod_extent
else:
base_extent = base_extent | prod_extent
assert base_extent is not None
if base_extent is None:
click.echo(f"Layer {layer.name} has no extent in CRS {base_crs}. Skipping.")
return
Comment on lines +171 to +173
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is a good idea, probably needs testing. Empty products were failing in update ranges though.


all_bboxes = bbox_projections(base_extent, layer.global_cfg.crses)

conn.execute(text("""
Expand Down Expand Up @@ -197,19 +200,8 @@ def create_range_entry(layer: OWSNamedLayer, cache: dict[LayerSignature, list[st
def bbox_projections(starting_box: odc.geo.Geometry, crses: dict[str, odc.geo.CRS]) -> dict[str, dict[str, float]]:
result = {}
for crsid, crs in crses.items():
if crs.valid_region is not None:
test_box = starting_box.to_crs("epsg:4326")
clipped_crs_region = (test_box & crs.valid_region)
if clipped_crs_region.wkt == 'POLYGON EMPTY':
continue
clipped_crs_bbox = clipped_crs_region.to_crs(crs).boundingbox
else:
clipped_crs_bbox = None
if clipped_crs_bbox is not None:
result[crsid] = jsonise_bbox(clipped_crs_bbox)
else:
projbbox = starting_box.to_crs(crs).boundingbox
result[crsid] = sanitise_bbox(projbbox)
projbbox = starting_box.to_crs(crs).boundingbox
result[crsid] = sanitise_bbox(projbbox)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see issues with this, but with the way WMS is defined I'm not sure we can do better.

return result


Expand Down
Loading