Skip to content

Commit

Permalink
pyproj/geod.py - set return_back_azimuth: Optional[bool] = None to …
Browse files Browse the repository at this point in the history
…emit warning for the braking change for [fwd|inv]_intermediate
  • Loading branch information
idanmiara committed Dec 16, 2022
1 parent 3e482e5 commit 39359cb
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions pyproj/geod.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
]

import math
import warnings
from typing import Any, Dict, List, Optional, Tuple, Union

from pyproj._geod import Geod as _Geod
Expand Down Expand Up @@ -328,6 +329,7 @@ def inv(
return_back_azimuth: bool = True,
) -> Tuple[Any, Any, Any]:
"""
Inverse transformation
Determine forward and back azimuths, plus distances
Expand Down Expand Up @@ -521,7 +523,7 @@ def inv_intermediate(
out_lons: Optional[Any] = None,
out_lats: Optional[Any] = None,
out_azis: Optional[Any] = None,
return_back_azimuth: bool = True,
return_back_azimuth: Optional[bool] = None,
) -> GeodIntermediateReturn:
"""
.. versionadded:: 3.1.0
Expand Down Expand Up @@ -643,6 +645,15 @@ def inv_intermediate(
GeodIntermediateReturn:
number of points, distance and output arrays (GeodIntermediateReturn docs)
"""
if return_back_azimuth is None:
return_back_azimuth = True
warnings.warn(
"Back azimuth is being returned by default to be compatible with fwd()"
"This is a breaking change for pyproj 3.5+."
"To avoid this warning, set return_back_azimuth=True."
"Otherwise, to restore old behaviour, set return_back_azimuth=False."
"This warning will be removed in future version."
)
return super()._inv_or_fwd_intermediate(
lon1=lon1,
lat1=lat1,
Expand Down Expand Up @@ -674,7 +685,7 @@ def fwd_intermediate(
out_lons: Optional[Any] = None,
out_lats: Optional[Any] = None,
out_azis: Optional[Any] = None,
return_back_azimuth: bool = True,
return_back_azimuth: Optional[bool] = None,
) -> GeodIntermediateReturn:
"""
.. versionadded:: 3.1.0
Expand Down Expand Up @@ -781,6 +792,15 @@ def fwd_intermediate(
GeodIntermediateReturn:
number of points, distance and output arrays (GeodIntermediateReturn docs)
"""
if return_back_azimuth is None:
return_back_azimuth = True
warnings.warn(
"Back azimuth is being returned by default to be compatible with inv()"
"This is a breaking change for pyproj 3.5+."
"To avoid this warning, set return_back_azimuth=True."
"Otherwise, to restore old behaviour, set return_back_azimuth=False."
"This warning will be removed in future version."
)
return super()._inv_or_fwd_intermediate(
lon1=lon1,
lat1=lat1,
Expand Down

0 comments on commit 39359cb

Please sign in to comment.