From 261b2e6d3b9582596b96ad2d0a41427ad8ecb922 Mon Sep 17 00:00:00 2001 From: CI Date: Wed, 28 Jul 2021 16:46:08 +0000 Subject: [PATCH] Documentating and linting --- docs/sertit/ci.html | 8 ++++---- docs/sertit/index.html | 2 +- docs/sertit/vectors.html | 26 ++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/docs/sertit/ci.html b/docs/sertit/ci.html index 074cadb..c28c3fb 100644 --- a/docs/sertit/ci.html +++ b/docs/sertit/ci.html @@ -303,9 +303,9 @@

Module sertit.ci

geom_1 (gpd.GeoDataFrame): Geometry 1 geom_2 (gpd.GeoDataFrame): Geometry 2 """ - if not isinstance(geom_1, gpd.GeoDataFrame): + if not isinstance(geom_1, (gpd.GeoDataFrame, gpd.GeoSeries)): geom_1 = vectors.read(geom_1) - if not isinstance(geom_2, gpd.GeoDataFrame): + if not isinstance(geom_2, (gpd.GeoDataFrame, gpd.GeoSeries)): geom_2 = vectors.read(geom_2) assert len(geom_1) == len(geom_2) @@ -720,9 +720,9 @@

Args

geom_1 (gpd.GeoDataFrame): Geometry 1 geom_2 (gpd.GeoDataFrame): Geometry 2 """ - if not isinstance(geom_1, gpd.GeoDataFrame): + if not isinstance(geom_1, (gpd.GeoDataFrame, gpd.GeoSeries)): geom_1 = vectors.read(geom_1) - if not isinstance(geom_2, gpd.GeoDataFrame): + if not isinstance(geom_2, (gpd.GeoDataFrame, gpd.GeoSeries)): geom_2 = vectors.read(geom_2) assert len(geom_1) == len(geom_2) diff --git a/docs/sertit/index.html b/docs/sertit/index.html index bf82b1c..d26bbad 100644 --- a/docs/sertit/index.html +++ b/docs/sertit/index.html @@ -159,7 +159,7 @@

Documentation

.. include:: ../README.md """ -__version__ = "1.4.6" +__version__ = "1.4.7"
diff --git a/docs/sertit/vectors.html b/docs/sertit/vectors.html index 44eb303..d130a5a 100644 --- a/docs/sertit/vectors.html +++ b/docs/sertit/vectors.html @@ -400,7 +400,15 @@

Module sertit.vectors

# Load vector in cache if needed (geopandas do not use correctly S3 paths for now) if isinstance(path, CloudPath): - path = AnyPath(path.fspath) + tmp_dir = tempfile.TemporaryDirectory() + if path.suffix == ".shp": + # Download everything to disk + for shp_file in path.parent.glob(path.with_suffix(".*").name): + cached_path = shp_file.download_to(tmp_dir.name) + if cached_path.suffix == ".shp": + path = cached_path + else: + path = AnyPath(path.fspath) # Manage archive case if path.suffix in [".tar", ".zip"]: @@ -460,7 +468,8 @@

Module sertit.vectors

# Workaround for archived KML -> they may be empty # Convert KML to GeoJSON if vect.empty and shutil.which("ogr2ogr"): # Needs ogr2ogr here - tmp_dir = tempfile.TemporaryDirectory() + if not tmp_dir: + tmp_dir = tempfile.TemporaryDirectory() if path.suffix == ".zip": with zipfile.ZipFile(path, "r") as zip_ds: vect_path = zip_ds.extract(arch_vect_path, tmp_dir.name) @@ -1022,7 +1031,15 @@

Returns

# Load vector in cache if needed (geopandas do not use correctly S3 paths for now) if isinstance(path, CloudPath): - path = AnyPath(path.fspath) + tmp_dir = tempfile.TemporaryDirectory() + if path.suffix == ".shp": + # Download everything to disk + for shp_file in path.parent.glob(path.with_suffix(".*").name): + cached_path = shp_file.download_to(tmp_dir.name) + if cached_path.suffix == ".shp": + path = cached_path + else: + path = AnyPath(path.fspath) # Manage archive case if path.suffix in [".tar", ".zip"]: @@ -1082,7 +1099,8 @@

Returns

# Workaround for archived KML -> they may be empty # Convert KML to GeoJSON if vect.empty and shutil.which("ogr2ogr"): # Needs ogr2ogr here - tmp_dir = tempfile.TemporaryDirectory() + if not tmp_dir: + tmp_dir = tempfile.TemporaryDirectory() if path.suffix == ".zip": with zipfile.ZipFile(path, "r") as zip_ds: vect_path = zip_ds.extract(arch_vect_path, tmp_dir.name)