From 740915175acc412b9342f285a976f0d289a7266d Mon Sep 17 00:00:00 2001 From: chrispreee <117157625+chrispreee@users.noreply.github.com> Date: Fri, 20 Jan 2023 15:17:19 +0700 Subject: [PATCH 1/2] Update `mapbox_vector_tile.decode` call to v2.0 signature Version 2.0.0 of mapbox_vector_tile was released Jan 16, and (sloppily) includes the breaking change that `y_coord_down` must now be passed inside the `default_options` dict argument. https://github.com/tilezen/mapbox-vector-tile/blob/master/mapbox_vector_tile/__init__.py#L4 This PR enables vt2geojson to support either. --- vt2geojson/tools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vt2geojson/tools.py b/vt2geojson/tools.py index b56db62..2b2e8a8 100644 --- a/vt2geojson/tools.py +++ b/vt2geojson/tools.py @@ -24,7 +24,10 @@ def vt_bytes_to_geojson(b_content: bytes, x: int, y: int, z: int, layer=None) -> :param layer: include only the specified layer. :return: a features collection (GeoJSON). """ - data = decode(b_content, y_coord_down=True) + try: + data = decode(b_content, y_coord_down=True) + except TypeError: + data = decode(b_content, default_options={"y_coord_down": True}) features_collections = [Layer(x=x, y=y, z=z, name=name, obj=layer_obj).toGeoJSON() for name, layer_obj in data.items() if layer is None or name == layer] return { From 2c8e5feac90685f35e188c1bade014202441aeff Mon Sep 17 00:00:00 2001 From: chrispreee <117157625+chrispreee@users.noreply.github.com> Date: Fri, 20 Jan 2023 16:14:24 +0700 Subject: [PATCH 2/2] Make the new signature the default, not the old --- vt2geojson/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vt2geojson/tools.py b/vt2geojson/tools.py index 2b2e8a8..c2750e6 100644 --- a/vt2geojson/tools.py +++ b/vt2geojson/tools.py @@ -25,9 +25,9 @@ def vt_bytes_to_geojson(b_content: bytes, x: int, y: int, z: int, layer=None) -> :return: a features collection (GeoJSON). """ try: - data = decode(b_content, y_coord_down=True) - except TypeError: data = decode(b_content, default_options={"y_coord_down": True}) + except TypeError: + data = decode(b_content, y_coord_down=True) features_collections = [Layer(x=x, y=y, z=z, name=name, obj=layer_obj).toGeoJSON() for name, layer_obj in data.items() if layer is None or name == layer] return {