kopia lustrzana https://github.com/glidernet/ogn-python
Added position as MGRS in AircraftBeacon
rodzic
cb183926b8
commit
3ba9c9eaf9
|
@ -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
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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:
|
||||
|
|
3
setup.py
3
setup.py
|
@ -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': [
|
||||
|
|
Ładowanie…
Reference in New Issue