ogn-python/ogn/model/beacon.py

40 wiersze
1.0 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
2015-10-24 21:13:21 +00:00
from sqlalchemy import Column, String, Integer, Float, DateTime
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):
id = Column(Integer, primary_key=True)
# APRS data
location_wkt = Column('location', Geometry('POINT', srid=4326))
altitude = Column(Float(precision=2))
2015-10-24 21:13:21 +00:00
name = Column(String)
receiver_name = Column(String(9))
2018-01-19 18:14:57 +00:00
dstcall = Column(String)
2015-10-24 21:13:21 +00:00
timestamp = Column(DateTime, index=True)
symboltable = None
symbolcode = None
track = Column(Integer)
ground_speed = Column(Float(precision=2))
2015-10-24 21:13:21 +00:00
comment = None
2017-10-03 12:14:48 +00:00
relay = None
beacon_type = None
aprs_type = None
location_mgrs = None
@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)