Skip to content

Commit

Permalink
removed redundant functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wowtor committed Apr 6, 2024
1 parent e263c12 commit d6e1928
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions telcell/geography.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,29 @@
import math

import geopy
import geopy.units
import pyproj


GEOD_WGS84 = pyproj.Geod(ellps="WGS84")


def _degrees_to_radians(degrees: float) -> float:
return degrees * math.pi / 180


def _radians_to_degrees(radians: float) -> float:
return radians * 180 / math.pi


class Angle:
"""
Class to represent an angle between two lines. Implements mathematical operators and can work with degrees and
radians.
"""

def __init__(self, degrees: float = None, radians: float = None):
assert (degrees is None) != (
radians is None
), "provide exactly one of degrees and radians"
assert (
degrees is None or radians is None
), "angle requires either degrees or radians; both provided"
if degrees is not None:
self._degrees = degrees
if radians is not None:
self._degrees = _radians_to_degrees(radians)
elif radians is not None:
self._degrees = geopy.units.degrees(radians=radians)
else:
raise ValueError("angle requires either degrees or radians; none provided")

def __eq__(self, other):
if isinstance(other, Angle):
Expand Down Expand Up @@ -102,7 +97,7 @@ def degrees(self):

@property
def radians(self):
return _degrees_to_radians(self._degrees)
return geopy.units.radians(degrees=self._degrees)


def normalize_angle(angle: Angle) -> Angle:
Expand Down

0 comments on commit d6e1928

Please sign in to comment.