2017-10-03 11:31:24 +00:00
|
|
|
from geoalchemy2.shape import to_shape
|
|
|
|
from geoalchemy2.types import Geometry
|
2019-01-01 19:13:08 +00:00
|
|
|
from sqlalchemy import Column, String, SmallInteger, Float, DateTime
|
2015-10-24 21:13:21 +00:00
|
|
|
from sqlalchemy.ext.declarative import AbstractConcreteBase
|
|
|
|
|
2015-10-30 20:19:03 +00:00
|
|
|
from .base import Base
|
2016-04-24 17:34:25 +00:00
|
|
|
from .geo import Location
|
2015-10-24 21:13:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Beacon(AbstractConcreteBase, Base):
|
|
|
|
# APRS data
|
2016-04-24 17:34:25 +00:00
|
|
|
location_wkt = Column('location', Geometry('POINT', srid=4326))
|
2018-01-21 19:14:35 +00:00
|
|
|
altitude = Column(Float(precision=2))
|
2016-04-24 17:34:25 +00:00
|
|
|
|
2019-01-03 15:54:06 +00:00
|
|
|
name = Column(String, primary_key=True, nullable=True)
|
2018-01-19 18:14:57 +00:00
|
|
|
dstcall = Column(String)
|
2018-09-03 17:58:35 +00:00
|
|
|
relay = Column(String)
|
2019-01-03 15:54:06 +00:00
|
|
|
receiver_name = Column(String(9), primary_key=True, nullable=True)
|
|
|
|
timestamp = Column(DateTime, primary_key=True, nullable=True)
|
2015-10-24 21:13:21 +00:00
|
|
|
symboltable = None
|
|
|
|
symbolcode = None
|
2018-01-21 20:06:27 +00:00
|
|
|
track = Column(SmallInteger)
|
2018-01-21 19:14:35 +00:00
|
|
|
ground_speed = Column(Float(precision=2))
|
2015-10-24 21:13:21 +00:00
|
|
|
comment = None
|
2016-04-24 17:34:25 +00:00
|
|
|
|
2018-09-03 17:58:35 +00:00
|
|
|
# Type information
|
2017-10-03 12:14:48 +00:00
|
|
|
beacon_type = None
|
|
|
|
aprs_type = None
|
|
|
|
|
2018-09-03 17:58:35 +00:00
|
|
|
# Debug information
|
|
|
|
raw_message = None #Column(String)
|
|
|
|
reference_timestamp = None #Column(DateTime, index=True)
|
2018-01-04 11:52:19 +00:00
|
|
|
|
2016-04-24 17:34:25 +00:00
|
|
|
@property
|
|
|
|
def location(self):
|
|
|
|
if self.location_wkt is None:
|
|
|
|
return None
|
|
|
|
|
|
|
|
coords = to_shape(self.location_wkt)
|
|
|
|
return Location(lat=coords.y, lon=coords.x)
|