nasa / opera-sds-pcm

Observational Products for End-Users from Remote Sensing Analysis (OPERA)
Apache License 2.0
16 stars 12 forks source link

[Bug]: geo_util.py::does_bbox_intersect_region effectively ignores underlying library errors #815

Open philipjyoon opened 6 months ago

philipjyoon commented 6 months ago

Checked for duplicates

Yes - I've already checked

Describe the bug

This function calls osgeo.ogr.Geometry.Intersects() fuctions. When we use the attached geojson, Intersects() function actually write out error to stderr. But Intersects() function returns True and does not even throw an exception.

We need to detect any errors that come out of that library and raise an exception

What did you expect?

n/t

Reproducible steps

Specify this geojson as the georegion in filter when running R2 historical processing. You may need to query 100s of SLC granules until running into this case.

The stderr will read something like: ERROR 1: TopologyException: side location conflict at -180 70

{
    "type": "FeatureCollection",
    "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
    "features": [
        { "type": "Feature",
          "properties": {
              "set_name": "antimeridian_east",
              "start_date": "2016-05-01T00:00:00",
              "end_date": "2023-10-05T00:00:00" },
          "geometry": {
              "type": "MultiPolygon",
              "coordinates": [ [ [ [ 179.5, -90.0 ], [ 179.5, 90.0 ], [ 180.0, 90.0 ], [ 180.0, -90.0 ], [ 179.5, -90.0 ] ] ] ] } },
        { "type": "Feature",
          "properties": {
              "set_name": "antimeridian_west",
              "start_date": "2016-05-01T00:00:00",
              "end_date": "2023-10-05T00:00:00" },
          "geometry": {
              "type": "MultiPolygon",
              "coordinates": [ [ [ [ -180.0, -90.0 ], [ -180.0, 90.0 ], [ -179.5, 90.0 ], [ -179.5, -90.0 ], [ -180.0, -90.0 ] ] ] ] } },
        { "type": "Feature",
          "properties": {
              "set_name": "high-latitude_north_of_70",
              "start_date": "2016-05-01T00:00:00",
              "end_date": "2023-10-05T00:00:00" },
          "geometry": {
              "type": "MultiPolygon",
              "coordinates": [ [ [ [ -180.0, 70.0 ], [ -180.0, 89.9 ], [ 180.0, 89.9 ], [ 180.0, 70.0 ], [ -180.0, 70.0 ] ] ] ] } }
    ]
}

Environment

2.2.1 but also develop branch circa April 24, 2024
...