2018-10-21 15:34:03 +00:00
|
|
|
from geoalchemy2.types import Geometry
|
|
|
|
|
2019-02-10 17:39:06 +00:00
|
|
|
from ogn_python import db
|
2018-10-21 15:34:03 +00:00
|
|
|
|
|
|
|
|
2019-02-10 12:10:19 +00:00
|
|
|
class Flight2D(db.Model):
|
2018-10-21 15:34:03 +00:00
|
|
|
__tablename__ = "flights2d"
|
|
|
|
|
2019-02-10 12:25:24 +00:00
|
|
|
date = db.Column(db.Date, primary_key=True)
|
2019-03-06 20:11:46 +00:00
|
|
|
flight_type = db.Column(db.SmallInteger, primary_key=True)
|
2018-10-21 15:34:03 +00:00
|
|
|
|
2019-02-10 12:25:24 +00:00
|
|
|
path_wkt = db.Column('path', Geometry('MULTILINESTRING', srid=4326))
|
|
|
|
path_simple_wkt = db.Column('path_simple', Geometry('MULTILINESTRING', srid=4326)) # this is the path simplified with ST_Simplify(path, 0.0001)
|
2018-10-21 15:34:03 +00:00
|
|
|
|
|
|
|
# Relations
|
2019-02-10 12:25:24 +00:00
|
|
|
device_id = db.Column(db.Integer, db.ForeignKey('devices.id', ondelete='SET NULL'), primary_key=True)
|
|
|
|
device = db.relationship('Device', foreign_keys=[device_id], backref='flights2d')
|
2018-10-21 15:34:03 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
2019-01-04 14:18:06 +00:00
|
|
|
return "<Flight %s: %s,%s>" % (
|
2018-10-21 15:34:03 +00:00
|
|
|
self.date,
|
2019-01-04 14:18:06 +00:00
|
|
|
self.path_wkt,
|
|
|
|
self.path_simple_wkt)
|
2018-10-21 15:34:03 +00:00
|
|
|
|
2019-01-01 19:13:08 +00:00
|
|
|
|
2019-02-10 12:25:24 +00:00
|
|
|
db.Index('ix_flights2d_date_device_id', Flight2D.date, Flight2D.device_id)
|
|
|
|
#db.Index('ix_flights2d_date_path', Flight2D.date, Flight2D.path_wkt) --> CREATE INDEX ix_flights2d_date_path ON flights2d USING GIST("date", path)
|