|
@@ -1,7 +1,7 @@
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
-from sklearn.metrics.pairwise import haversine_distances
|
|
|
import numpy as np
|
|
|
+import pyproj
|
|
|
|
|
|
class Waypoint:
|
|
|
def dms2dd(coordinate : str):
|
|
@@ -28,6 +28,11 @@ class Waypoint:
|
|
|
return 'Name: ' + self.name + ', Lat: ' + str(self.coordinate[0]) + ', Lon: ' + str(self.coordinate[1])
|
|
|
|
|
|
def haversine(self, other):
|
|
|
- self_radians = [np.radians(_) for _ in self.coordinate]
|
|
|
- other_radians = [np.radians(_) for _ in other.coordinate]
|
|
|
- return 6371.0 * haversine_distances([self_radians, other_radians])[0][1]
|
|
|
+ geodesic = pyproj.Geod(ellps='WGS84')
|
|
|
+ forward, backward, distance = geodesic.inv(self.coordinate[1], self.coordinate[0], other.coordinate[1], other.coordinate[0])
|
|
|
+ return distance / 1000.0
|
|
|
+
|
|
|
+ def bearing(self, other):
|
|
|
+ geodesic = pyproj.Geod(ellps='WGS84')
|
|
|
+ forward, backward, distance = geodesic.inv(self.coordinate[1], self.coordinate[0], other.coordinate[1], other.coordinate[0])
|
|
|
+ return forward
|