Skip to content

Remove utility functions that are duplicate with branca #1676

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

Merged
merged 1 commit into from
Dec 21, 2022
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
59 changes: 8 additions & 51 deletions folium/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@

import numpy as np

# import here for backwards compatibility
from branca.utilities import ( # noqa F401
_locations_mirror,
_parse_size,
none_max,
none_min,
)

try:
import pandas as pd
except ImportError:
Expand Down Expand Up @@ -321,24 +329,6 @@ def mercator(x):
return out


def none_min(x, y):
if x is None:
return y
elif y is None:
return x
else:
return min(x, y)


def none_max(x, y):
if x is None:
return y
elif y is None:
return x
else:
return max(x, y)


def iter_coords(obj):
"""
Returns all the coordinate tuples from a geometry or feature.
Expand All @@ -362,23 +352,6 @@ def iter_coords(obj):
yield from iter_coords(coord)


def _locations_mirror(x):
"""
Mirrors the points in a list-of-list-of-...-of-list-of-points.
For example:
>>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]])
[[[2, 1], [4, 3]], [6, 5], [8, 7]]

"""
if hasattr(x, "__iter__"):
if hasattr(x[0], "__iter__"):
return list(map(_locations_mirror, x))
else:
return list(x[::-1])
else:
return x


def get_bounds(locations, lonlat=False):
"""
Computes the bounds of the object in the form
Expand Down Expand Up @@ -415,22 +388,6 @@ def camelize(key):
return "".join(x.capitalize() if i > 0 else x for i, x in enumerate(key.split("_")))


def _parse_size(value):
try:
if isinstance(value, (int, float)):
value_type = "px"
value = float(value)
assert value > 0
else:
value_type = "%"
value = float(value.strip("%"))
assert 0 <= value <= 100
except Exception:
msg = "Cannot parse value {!r} as {!r}".format
raise ValueError(msg(value, value_type))
return value, value_type


def compare_rendered(obj1, obj2):
"""
Return True/False if the normalized rendered version of
Expand Down