Skip to content

Commit

Permalink
Deprecate measure_distance_spherical, fixes #251
Browse files Browse the repository at this point in the history
  • Loading branch information
anitagraser committed May 11, 2024
1 parent e157868 commit 81e312c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions movingpandas/geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from packaging.version import Version
from shapely.geometry import LineString, Point

from movingpandas.tools._warnings import deprecated

try:
SHAPELY_GE_2 = Version(shapely.__version__) >= Version("2.0.0")
Expand All @@ -25,6 +26,7 @@ def _is_point(input):
)


@deprecated
def measure_distance_spherical(point1, point2):
"""
Return spherical distance between two shapely Points as a float.
Expand Down Expand Up @@ -83,12 +85,12 @@ def measure_distance_geodesic(point1, point2):
return dist


def measure_distance(point1, point2, spherical=False, conversion=None):
def measure_distance(point1, point2, geodesic=False, conversion=None):
"""
Convenience function that returns either euclidean or geodesic distance
between two points
"""
if spherical:
if geodesic:
d = measure_distance_geodesic(point1, point2)
else:
d = measure_distance_euclidean(point1, point2)
Expand Down
18 changes: 18 additions & 0 deletions movingpandas/tools/_warnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import warnings
import functools

# source: https://stackoverflow.com/a/30253848

def deprecated(func):
"""This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used."""
@functools.wraps(func)
def new_func(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning) # turn off filter
warnings.warn("Call to deprecated function {}.".format(func.__name__),
category=DeprecationWarning,
stacklevel=2)
warnings.simplefilter('default', DeprecationWarning) # reset filter
return func(*args, **kwargs)
return new_func

0 comments on commit 81e312c

Please sign in to comment.