ogn-python/ogn/model/receiver.py

32 wiersze
857 B
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
2018-01-21 20:06:27 +00:00
from sqlalchemy import Column, Float, String, Integer, DateTime
from sqlalchemy.orm import relationship
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__ = "receivers"
2015-11-15 10:59:52 +00:00
id = Column(Integer, primary_key=True)
location_wkt = Column('location', Geometry('POINT', srid=4326))
2018-01-21 20:06:27 +00:00
altitude = Column(Float(precision=2))
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)
@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)