ogn-python/ogn/model/receiver.py

36 wiersze
963 B
Python
Czysty Zwykły widok Historia

from sqlalchemy import Column, String, Integer, DateTime
from sqlalchemy.orm import relationship
from geoalchemy2.types import Geometry
from geoalchemy2.shape import to_shape
2015-11-15 10:59:52 +00:00
from .base import Base
from .geo import Location
2015-11-15 10:59:52 +00:00
2015-11-16 19:09:26 +00:00
class Receiver(Base):
__tablename__ = "receiver"
2015-11-15 10:59:52 +00:00
id = Column(Integer, primary_key=True)
location_wkt = Column('location', Geometry('POINT', srid=4326))
2015-11-15 10:59:52 +00:00
altitude = Column(Integer)
name = Column(String(9))
2015-11-15 10:59:52 +00:00
firstseen = Column(DateTime, index=True)
lastseen = Column(DateTime, index=True)
country_code = Column(String(2))
version = Column(String)
platform = Column(String)
# Relations
aircraft_beacons = relationship('AircraftBeacon')
receiver_beacons = relationship('ReceiverBeacon')
@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)