Added position as MGRS in AircraftBeacon

pull/68/head
Konstantin Gründger 2018-01-04 12:52:19 +01:00
rodzic cb183926b8
commit 3ba9c9eaf9
4 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -1,5 +1,7 @@
import logging
from mgrs import MGRS
from ogn.commands.dbutils import session
from ogn.model import AircraftBeacon, ReceiverBeacon, Location
from ogn.parser import parse, ParseError
@ -7,11 +9,13 @@ from datetime import datetime, timedelta
logger = logging.getLogger(__name__)
myMGRS = MGRS()
def replace_lonlat_with_wkt(message):
location = Location(message['longitude'], message['latitude'])
message['location_wkt'] = location.to_wkt()
message['location_mgrs'] = myMGRS.toMGRS(message['latitude'], message['longitude'])
del message['latitude']
del message['longitude']
return message

Wyświetl plik

@ -40,6 +40,7 @@ class AircraftBeacon(Beacon):
# Calculated values
distance = Column(Float)
location_mgrs = Column(String(15), index=True)
# Relations
receiver_id = Column(Integer, ForeignKey('receiver.id', ondelete='SET NULL'))

Wyświetl plik

@ -28,6 +28,8 @@ class Beacon(AbstractConcreteBase, Base):
beacon_type = None
aprs_type = None
location_mgrs = None
@property
def location(self):
if self.location_wkt is None:

Wyświetl plik

@ -41,7 +41,8 @@ setup(
'geoalchemy2==0.4.0',
'shapely>=1.5.17,<1.6',
'ogn-client==0.8.0',
'psycopg2==2.7.3.2'
'psycopg2==2.7.3.2',
'mgrs==1.3.5'
],
extras_require={
'dev': [