Skip to content

Commit 5ca9558

Browse files
kraina-cicdRaczeQ
andauthored
chore(CI/CD): bump version 0.10.0 -> 0.11.0 (#159)
* 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 <raczyckikamil@gmail.com>
1 parent 86c5884 commit 5ca9558

File tree

8 files changed

+53
-19
lines changed

8 files changed

+53
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.11.0] - 2024-09-24
11+
1012
### Changed
1113

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

384-
[Unreleased]: https://github.com/kraina-ai/quackosm/compare/0.10.0...HEAD
386+
[Unreleased]: https://github.com/kraina-ai/quackosm/compare/0.11.0...HEAD
387+
388+
[0.11.0]: https://github.com/kraina-ai/quackosm/compare/0.10.0...0.11.0
385389

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

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "QuackOSM"
3-
version = "0.10.0"
3+
version = "0.11.0"
44
description = "An open-source tool for reading OpenStreetMap PBF files using DuckDB"
55
authors = [{ name = "Kamil Raczycki", email = "kraczycki@kraina.ai" }]
66
dependencies = [
@@ -173,7 +173,7 @@ close-quotes-on-newline = true
173173
wrap-one-line = true
174174

175175
[tool.bumpver]
176-
current_version = "0.10.0"
176+
current_version = "0.11.0"
177177
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
178178
commit_message = "chore(CI/CD): bump version {old_version} -> {new_version}"
179179
commit = true

quackosm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from quackosm.pbf_file_reader import PbfFileReader
1919

2020
__app_name__ = "QuackOSM"
21-
__version__ = "0.10.0"
21+
__version__ = "0.11.0"
2222

2323
__all__ = [
2424
"PbfFileReader",

quackosm/_geopandas_api_version.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import geopandas as gpd
2+
from packaging import version
3+
4+
GEOPANDAS_NEW_API = version.parse(gpd.__version__) >= version.parse("1.0.0")

quackosm/cli.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import click
99
import typer
1010

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

9899
gdf = gpd.read_file(value)
99-
return gdf.union_all()
100+
if GEOPANDAS_NEW_API:
101+
return gdf.union_all()
102+
else:
103+
return gdf.unary_union
100104
except Exception:
101105
raise typer.BadParameter("Cannot parse provided geo file") from None
102106

@@ -140,9 +144,13 @@ def convert(self, value, param=None, ctx=None): # type: ignore
140144
geometries.append(
141145
box(minx=bounds["w"], miny=bounds["s"], maxx=bounds["e"], maxy=bounds["n"])
142146
)
143-
return gpd.GeoSeries(geometries).union_all()
147+
if GEOPANDAS_NEW_API:
148+
return gpd.GeoSeries(geometries).union_all()
149+
else:
150+
return gpd.GeoSeries(geometries).unary_union
144151
except Exception:
145-
raise typer.BadParameter(f"Cannot parse provided Geohash value: {geohash}") from None
152+
raise
153+
# raise typer.BadParameter(f"Cannot parse provided Geohash value: {geohash}") from None
146154

147155

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

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

quackosm/osm_extracts/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
OsmExtractMultipleMatchesError,
3131
OsmExtractZeroMatchesError,
3232
)
33+
from quackosm._geopandas_api_version import GEOPANDAS_NEW_API
3334
from quackosm.osm_extracts.bbbike import _get_bbbike_index
3435
from quackosm.osm_extracts.extract import OpenStreetMapExtract, OsmExtractSource
3536
from quackosm.osm_extracts.extracts_tree import get_available_extracts_as_rich_tree
@@ -817,9 +818,13 @@ def _simplify_selected_extracts(
817818
)
818819
with warnings.catch_warnings():
819820
warnings.simplefilter("ignore", category=FutureWarning)
820-
other_geometries = matching_extracts.loc[
821+
other_geometries_gdf = matching_extracts.loc[
821822
sorted_extracts_gdf["id"] != extract_id
822-
].union_all()
823+
]
824+
if GEOPANDAS_NEW_API:
825+
other_geometries = other_geometries_gdf.union_all()
826+
else:
827+
other_geometries = other_geometries_gdf.unary_union
823828
if extract_geometry.covered_by(other_geometries):
824829
extract_to_remove = extract_id
825830
simplify_again = True

quackosm/pbf_file_reader.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,14 +2275,17 @@ def _save_parquet_file_with_geometry(
22752275
is_empty = not any(file_path.iterdir())
22762276
if is_empty:
22772277
relation.to_parquet(str(file_path / "empty.parquet"))
2278-
return self.connection.sql(
2279-
f"""
2280-
SELECT * REPLACE (ST_GeomFromWKB(geometry) AS geometry)
2281-
FROM read_parquet('{file_path}/**')
2282-
"""
2283-
)
22842278

2285-
return self.connection.sql(f"SELECT * FROM read_parquet('{file_path}/**')")
2279+
return self.connection.sql(
2280+
f"""
2281+
SELECT * EXCLUDE(geometry),
2282+
CASE WHEN typeof(geometry) = 'GEOMETRY'
2283+
THEN geometry::GEOMETRY
2284+
ELSE ST_GeomFromWKB(geometry::BLOB)
2285+
END AS geometry
2286+
FROM read_parquet('{file_path}/**')
2287+
"""
2288+
)
22862289

22872290
def _concatenate_results_to_geoparquet(
22882291
self,

tests/base/test_geocoding.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from quackosm import geocode_to_geometry
99
from quackosm._exceptions import QueryNotGeocodedError
10+
from quackosm._geopandas_api_version import GEOPANDAS_NEW_API
1011

1112

1213
@pytest.mark.parametrize( # type: ignore
@@ -21,7 +22,10 @@
2122
)
2223
def test_geocoding(query: Union[str, list[str]]) -> None:
2324
"""Test if geocoding works the same as osmnx."""
24-
assert geocode_to_gdf(query).union_all().equals(geocode_to_geometry(query))
25+
if GEOPANDAS_NEW_API:
26+
assert geocode_to_gdf(query).union_all().equals(geocode_to_geometry(query))
27+
else:
28+
assert geocode_to_gdf(query).unary_union.equals(geocode_to_geometry(query))
2529

2630

2731
@pytest.mark.parametrize( # type: ignore

0 commit comments

Comments
 (0)