Skip to content

Commit

Permalink
fix: renamed shapely exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato committed Sep 14, 2023
1 parent 18b22d5 commit ffd4df6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions eodag/api/product/_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

import requests
from requests import RequestException
from shapely import geometry, geos, wkb, wkt
from shapely import geometry, wkb, wkt
from shapely.errors import ShapelyError

from eodag.api.product.drivers import DRIVERS, NoDriver
from eodag.api.product.metadata_mapping import NOT_AVAILABLE, NOT_MAPPED
Expand Down Expand Up @@ -96,7 +97,10 @@ def __init__(self, provider, properties, **kwargs):
and NOT_AVAILABLE not in str(value)
}
if "geometry" not in properties or (
properties["geometry"] == NOT_AVAILABLE
(
properties["geometry"] == NOT_AVAILABLE
or properties["geometry"] == NOT_MAPPED
)
and "defaultGeometry" not in properties
):
raise MisconfiguredError(
Expand Down Expand Up @@ -127,12 +131,12 @@ def __init__(self, provider, properties, **kwargs):
if isinstance(product_geometry, str):
try:
product_geometry = wkt.loads(product_geometry)
except geos.WKTReadingError:
except (ShapelyError, GEOSException):
try:
product_geometry = wkb.loads(product_geometry)
# Also catching TypeError because product_geometry can be a
# string and not a bytes string
except (geos.WKBReadingError, TypeError):
except (ShapelyError, GEOSException, TypeError):
# Giv up!
raise
self.geometry = self.search_intersection = geometry.shape(product_geometry)
Expand All @@ -143,7 +147,7 @@ def __init__(self, provider, properties, **kwargs):
)
try:
self.search_intersection = self.geometry.intersection(searched_geom)
except GEOSException:
except (GEOSException, ShapelyError):
logger.warning(
"Unable to intersect the requested extent: %s with the product "
"geometry: %s",
Expand Down

0 comments on commit ffd4df6

Please sign in to comment.