Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_compass_bearing_west(self):
assert calculate_initial_compass_bearing(Point(0, 0), Point(-10, 0)) == 270
def test_compass_bearing_east(self):
assert calculate_initial_compass_bearing(Point(0, 0), Point(10, 0)) == 90
def test_compass_bearing_north(self):
assert calculate_initial_compass_bearing(Point(0, 0), Point(0, 10)) == 0
def test_compass_bearing_south(self):
assert calculate_initial_compass_bearing(Point(0, 0), Point(0, -10)) == 180
def get_direction(self):
"""
Return the direction of the trajectory.
The direction is calculated between the trajectory's start and end location.
Direction values are in degrees, starting North turning clockwise.
Returns
-------
float
Direction of the trajectory in degrees
"""
pt0 = self.get_start_location()
pt1 = self.get_end_location()
if self.is_latlon:
return calculate_initial_compass_bearing(pt0, pt1)
else:
return azimuth(pt0, pt1)
def _compute_heading(self, row):
pt0 = row['prev_pt']
pt1 = row[self.get_geom_column_name()]
if not isinstance(pt0, Point):
return 0.0
if pt0 == pt1:
return 0.0
if self.is_latlon:
return calculate_initial_compass_bearing(pt0, pt1)
else:
return azimuth(pt0, pt1)