ogn-python/ogn/model/beacon.py

41 wiersze
1.2 KiB
Python
Czysty Zwykły widok Historia

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
from .geo import Location
2015-10-24 21:13:21 +00:00
class Beacon(AbstractConcreteBase, Base):
# APRS data
location_wkt = Column('location', Geometry('POINT', srid=4326))
altitude = Column(Float(precision=2))
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)
ground_speed = Column(Float(precision=2))
2015-10-24 21:13:21 +00:00
comment = None
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)
@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)