Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slowly deprecate old encode and decode parameters #129

Merged
merged 1 commit into from
Jan 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mapbox_vector_tile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import warnings

from mapbox_vector_tile import decoder, encoder


def decode(tile, per_layer_options=None, default_options=None):
def decode(tile, per_layer_options=None, default_options=None, **kwargs):
"""Decode the provided `tile`

Args:
Expand Down Expand Up @@ -30,12 +32,15 @@ def decode(tile, per_layer_options=None, default_options=None):
* `geojson`: when set to `False`, the behaviour of mapbox-vector-tile version 1.* is used. When set
to `False`, the retrieved dictionary is a valid geojson file. Default to `True`.
"""
if kwargs:
warnings.warn("`decode` signature has changed, use `default_options` instead", DeprecationWarning)
default_options = {**kwargs, **(default_options or {})}
vector_tile = decoder.TileData(pbf_data=tile, per_layer_options=per_layer_options, default_options=default_options)
message = vector_tile.get_message()
return message


def encode(layers, per_layer_options=None, default_options=None):
def encode(layers, per_layer_options=None, default_options=None, **kwargs):
"""Encode the `layers` into a MVT tile.

Args:
Expand Down Expand Up @@ -74,6 +79,9 @@ def encode(layers, per_layer_options=None, default_options=None):
* `max_geometry_validate_tries`: the number of tries when trying to enforce the good winding order. Default
to 5.
"""
if kwargs:
warnings.warn("`encode` signature has changed, use `default_options` instead", DeprecationWarning)
default_options = {**kwargs, **(default_options or {})}
vector_tile = encoder.VectorTile(default_options=default_options)
if per_layer_options is None:
per_layer_options = dict()
Expand Down