add some generic datatypes
This commit is contained in:
11
aman/types/ArrivalRoute.py
Normal file
11
aman/types/ArrivalRoute.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
class ArrivalRoute:
|
||||||
|
def __init__(self, name : str, runway : str, waypoints : list):
|
||||||
|
self.name = name
|
||||||
|
self.runway = runway
|
||||||
|
self.iaf = waypoints[0]
|
||||||
|
self.route = waypoints
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return 'Name: ' + self.name + ', IAF: ' + self.iaf.name + ', RWY: ' + self.runway
|
||||||
13
aman/types/Exception.py
Normal file
13
aman/types/Exception.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
class Error(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class FormatError(Error):
|
||||||
|
def __init__(self, message):
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
class InputError(Error):
|
||||||
|
def __init__(self, expression, message):
|
||||||
|
self.expression = expression
|
||||||
|
self.message = message
|
||||||
33
aman/types/Waypoint.py
Normal file
33
aman/types/Waypoint.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from sklearn.metrics.pairwise import haversine_distances
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
class Waypoint:
|
||||||
|
def dms2dd(coordinate : str):
|
||||||
|
split = coordinate.split('.')
|
||||||
|
if 4 != len(split):
|
||||||
|
return 0.0
|
||||||
|
|
||||||
|
direction = split[0][1]
|
||||||
|
degrees = float(split[0][1:])
|
||||||
|
minutes = float(split[1])
|
||||||
|
seconds = float(split[2]) * (float(split[3]) / 1000.0)
|
||||||
|
|
||||||
|
dd = degrees + minutes / 60.0 + seconds / (60 * 60)
|
||||||
|
if 'E' == direction or 'S' == direction:
|
||||||
|
dd *= -1.0
|
||||||
|
|
||||||
|
return dd
|
||||||
|
|
||||||
|
def __init__(self, name : str, latitude : float, longitude : float):
|
||||||
|
self.name = name
|
||||||
|
self.coordinate = np.array([ latitude, longitude ])
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
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]
|
||||||
0
aman/types/__init__.py
Normal file
0
aman/types/__init__.py
Normal file
3
setup.py
3
setup.py
@@ -75,7 +75,8 @@ setup(
|
|||||||
'aman',
|
'aman',
|
||||||
'aman.com',
|
'aman.com',
|
||||||
'aman.config',
|
'aman.config',
|
||||||
'aman.tools'
|
'aman.tools',
|
||||||
|
'aman.types'
|
||||||
],
|
],
|
||||||
namespace_packages = [ 'aman' ],
|
namespace_packages = [ 'aman' ],
|
||||||
description = 'AMAN optimization backend',
|
description = 'AMAN optimization backend',
|
||||||
|
|||||||
Reference in New Issue
Block a user