Skip to content

Commit

Permalink
Manage case if fiona doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Jul 24, 2024
1 parent 8495040 commit 5195330
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sertit/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import numpy as np
import pandas as pd
from cloudpathlib.exceptions import AnyPathTypeError
from fiona._err import CPLE_AppDefinedError
from fiona.errors import UnsupportedGeometryTypeError
from shapely import Polygon, wkt

from sertit import AnyPath, files, geometry, logs, misc, path, strings
Expand Down Expand Up @@ -65,9 +63,18 @@ def is_geopandas_1_0():

if is_geopandas_1_0():
from pyogrio.errors import DataSourceError
from shapely.errors import GEOSException

CPLE_AppDefinedError = Exception
else:
from fiona._err import CPLE_AppDefinedError
from fiona.errors import DriverError as DataSourceError
from fiona.errors import UnsupportedGeometryTypeError as GEOSException

# Handle errors changing from fiona to pyogrio
DataSourceError = DataSourceError
GEOSException = GEOSException
CPLE_AppDefinedError = CPLE_AppDefinedError


def to_utm_crs(lon: float, lat: float) -> "CRS": # noqa: F821
Expand Down Expand Up @@ -532,7 +539,7 @@ def _read_vector_core(
fiona_logger.setLevel(logging.INFO)
except DataSourceError:
raise
except (ValueError, UnsupportedGeometryTypeError, IndexError) as ex:
except (ValueError, GEOSException, IndexError) as ex:
if "Use a.any() or a.all()" in str(ex):
raise
# Do not print warning for null layer
Expand Down

0 comments on commit 5195330

Please sign in to comment.