Skip to content

Commit

Permalink
chore(CI/CD): bump version 0.10.0 -> 0.11.0 (#159)
Browse files Browse the repository at this point in the history
* chore(CI/CD): bump version 0.10.0 -> 0.11.0

* docs: update CHANGELOG.md

* chore: change geometry reading to be compatible with multiple duckdb versions

* fix: keep support for old geopandas api

---------

Co-authored-by: Kamil Raczycki <[email protected]>
  • Loading branch information
kraina-cicd and RaczeQ authored Sep 24, 2024
1 parent 86c5884 commit 5ca9558
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 19 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.11.0] - 2024-09-24

### Changed

- Bumped minimal DuckDB version to `1.1.0`
Expand Down Expand Up @@ -381,7 +383,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Created QuackOSM repository
- Implemented PbfFileReader

[Unreleased]: https://github.com/kraina-ai/quackosm/compare/0.10.0...HEAD
[Unreleased]: https://github.com/kraina-ai/quackosm/compare/0.11.0...HEAD

[0.11.0]: https://github.com/kraina-ai/quackosm/compare/0.10.0...0.11.0

[0.10.0]: https://github.com/kraina-ai/quackosm/compare/0.9.4...0.10.0

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "QuackOSM"
version = "0.10.0"
version = "0.11.0"
description = "An open-source tool for reading OpenStreetMap PBF files using DuckDB"
authors = [{ name = "Kamil Raczycki", email = "[email protected]" }]
dependencies = [
Expand Down Expand Up @@ -173,7 +173,7 @@ close-quotes-on-newline = true
wrap-one-line = true

[tool.bumpver]
current_version = "0.10.0"
current_version = "0.11.0"
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
commit_message = "chore(CI/CD): bump version {old_version} -> {new_version}"
commit = true
Expand Down
2 changes: 1 addition & 1 deletion quackosm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from quackosm.pbf_file_reader import PbfFileReader

__app_name__ = "QuackOSM"
__version__ = "0.10.0"
__version__ = "0.11.0"

__all__ = [
"PbfFileReader",
Expand Down
4 changes: 4 additions & 0 deletions quackosm/_geopandas_api_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import geopandas as gpd
from packaging import version

GEOPANDAS_NEW_API = version.parse(gpd.__version__) >= version.parse("1.0.0")
24 changes: 19 additions & 5 deletions quackosm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import click
import typer

from quackosm._geopandas_api_version import GEOPANDAS_NEW_API
from quackosm._osm_tags_filters import GroupedOsmTagsFilter, OsmTagsFilter
from quackosm.osm_extracts.extract import OsmExtractSource
from quackosm.pbf_file_reader import _is_url_path
Expand Down Expand Up @@ -96,7 +97,10 @@ def convert(self, value, param=None, ctx=None): # type: ignore
import geopandas as gpd

gdf = gpd.read_file(value)
return gdf.union_all()
if GEOPANDAS_NEW_API:
return gdf.union_all()
else:
return gdf.unary_union
except Exception:
raise typer.BadParameter("Cannot parse provided geo file") from None

Expand Down Expand Up @@ -140,9 +144,13 @@ def convert(self, value, param=None, ctx=None): # type: ignore
geometries.append(
box(minx=bounds["w"], miny=bounds["s"], maxx=bounds["e"], maxy=bounds["n"])
)
return gpd.GeoSeries(geometries).union_all()
if GEOPANDAS_NEW_API:
return gpd.GeoSeries(geometries).union_all()
else:
return gpd.GeoSeries(geometries).unary_union
except Exception:
raise typer.BadParameter(f"Cannot parse provided Geohash value: {geohash}") from None
raise
# raise typer.BadParameter(f"Cannot parse provided Geohash value: {geohash}") from None


class H3GeometryParser(click.ParamType): # type: ignore
Expand All @@ -165,7 +173,10 @@ def convert(self, value, param=None, ctx=None): # type: ignore
geometries.append(
Polygon([coords[::-1] for coords in h3.cell_to_boundary(h3_cell.strip())])
)
return gpd.GeoSeries(geometries).union_all()
if GEOPANDAS_NEW_API:
return gpd.GeoSeries(geometries).union_all()
else:
return gpd.GeoSeries(geometries).unary_union
except Exception as ex:
raise typer.BadParameter(f"Cannot parse provided H3 values: {value}") from ex

Expand All @@ -190,7 +201,10 @@ def convert(self, value, param=None, ctx=None): # type: ignore
geometries.append(
Polygon(s2.s2_to_geo_boundary(s2_index.strip(), geo_json_conformant=True))
)
return gpd.GeoSeries(geometries).union_all()
if GEOPANDAS_NEW_API:
return gpd.GeoSeries(geometries).union_all()
else:
return gpd.GeoSeries(geometries).unary_union
except Exception:
raise typer.BadParameter(f"Cannot parse provided S2 value: {s2_index}") from None

Expand Down
9 changes: 7 additions & 2 deletions quackosm/osm_extracts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
OsmExtractMultipleMatchesError,
OsmExtractZeroMatchesError,
)
from quackosm._geopandas_api_version import GEOPANDAS_NEW_API
from quackosm.osm_extracts.bbbike import _get_bbbike_index
from quackosm.osm_extracts.extract import OpenStreetMapExtract, OsmExtractSource
from quackosm.osm_extracts.extracts_tree import get_available_extracts_as_rich_tree
Expand Down Expand Up @@ -817,9 +818,13 @@ def _simplify_selected_extracts(
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
other_geometries = matching_extracts.loc[
other_geometries_gdf = matching_extracts.loc[
sorted_extracts_gdf["id"] != extract_id
].union_all()
]
if GEOPANDAS_NEW_API:
other_geometries = other_geometries_gdf.union_all()
else:
other_geometries = other_geometries_gdf.unary_union
if extract_geometry.covered_by(other_geometries):
extract_to_remove = extract_id
simplify_again = True
Expand Down
17 changes: 10 additions & 7 deletions quackosm/pbf_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2275,14 +2275,17 @@ def _save_parquet_file_with_geometry(
is_empty = not any(file_path.iterdir())
if is_empty:
relation.to_parquet(str(file_path / "empty.parquet"))
return self.connection.sql(
f"""
SELECT * REPLACE (ST_GeomFromWKB(geometry) AS geometry)
FROM read_parquet('{file_path}/**')
"""
)

return self.connection.sql(f"SELECT * FROM read_parquet('{file_path}/**')")
return self.connection.sql(
f"""
SELECT * EXCLUDE(geometry),
CASE WHEN typeof(geometry) = 'GEOMETRY'
THEN geometry::GEOMETRY
ELSE ST_GeomFromWKB(geometry::BLOB)
END AS geometry
FROM read_parquet('{file_path}/**')
"""
)

def _concatenate_results_to_geoparquet(
self,
Expand Down
6 changes: 5 additions & 1 deletion tests/base/test_geocoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from quackosm import geocode_to_geometry
from quackosm._exceptions import QueryNotGeocodedError
from quackosm._geopandas_api_version import GEOPANDAS_NEW_API


@pytest.mark.parametrize( # type: ignore
Expand All @@ -21,7 +22,10 @@
)
def test_geocoding(query: Union[str, list[str]]) -> None:
"""Test if geocoding works the same as osmnx."""
assert geocode_to_gdf(query).union_all().equals(geocode_to_geometry(query))
if GEOPANDAS_NEW_API:
assert geocode_to_gdf(query).union_all().equals(geocode_to_geometry(query))
else:
assert geocode_to_gdf(query).unary_union.equals(geocode_to_geometry(query))


@pytest.mark.parametrize( # type: ignore
Expand Down

0 comments on commit 5ca9558

Please sign in to comment.