Esempio n. 1
0
class Log(Base):
    __tablename__ = 'log'
    id = Column('id', Integer, primary_key=True, autoincrement=True)
    infomarker = Column('infomarker', types.Integer,
                        ForeignKey('trackpoint.id'))
    topic = Column('topic', types.UnicodeText)
    content = Column('content', types.UnicodeText)
    #author = Column(Integer, ForeignKey('author.id',onupdate='CASCADE', ondelete='CASCADE'))
    etappe = Column(
        Integer, ForeignKey('etappe.id',
                            onupdate='CASCADE',
                            ondelete='CASCADE'))
    created = Column('created',
                     types.TIMESTAMP(timezone=False),
                     default=timetools.now())
    published = Column('published',
                       types.TIMESTAMP(timezone=False),
                       default=timetools.now())
    uuid = Column('uuid', postgresql.UUID, unique=True)
    image = relationship('Image', secondary=log_image_table, backref='logs')
    track = relationship('Track', secondary=log_track_table, backref='logs')

    def __init__(self, infomarker, topic, content, etappe, created, published,
                 uuid):
        self.infomarker = infomarker
        self.topic = topic
        self.content = content
        self.etappe = etappe
        self.created = created
        self.published = published
        self.uuid = uuid
Esempio n. 2
0
 def __init__(self, tour, name, description, start_timestamp=timetools.now(), 
             end_timestamp=timetools.now(), trackpoints=None, epsilon=Decimal(0.0005), 
             bbox=None, center_id=None, uuid=str(uuidlib.uuid4())):
     self.tour = tour.id
     self.description = description
     self.name = name
     self.start_timestamp = start_timestamp
     self.end_timestamp = end_timestamp
     self.reduced_trackpoints = reduce_trackpoints(trackpoints, epsilon)
     self.bbox = bbox
     self.center_id = center_id
     self.uuid = uuid
Esempio n. 3
0
 def __init__(self,
              name,
              description,
              start_timestamp=timetools.now(),
              end_timestamp=timetools.now(),
              center_id=None,
              uuid=str(uuidlib.uuid4())):
     self.name = name
     self.description = description
     self.start_timestamp = start_timestamp
     self.end_timestamp = end_timestamp
     self.reduced_trackpoints = reduce_trackpoints(trackpoints, epsilon)
     self.bbox = bbox
     self.center_id = center_id
     self.uuid = uuid
Esempio n. 4
0
class Image(Base):
    __tablename__ = 'image'
    id = Column(Integer, primary_key=True)
    name = Column('name', types.UnicodeText)
    location = Column('location', types.UnicodeText)
    title = Column('title', types.UnicodeText)
    comment = Column('comment', types.UnicodeText)
    alt = Column('alt', types.UnicodeText)
    aperture = Column(Text)
    shutter = Column(Text)
    focal_length = Column(Text)
    iso = Column(Text)
    timestamp_original = Column(types.TIMESTAMP(timezone=False))
    hash = Column('hash', types.UnicodeText)
    hash_large = Column('hash_large',
                        types.UnicodeText)  #hash of the image with 990px width
    #author = Column(Integer, ForeignKey('author.id',onupdate='CASCADE', ondelete='CASCADE'))
    trackpoint = Column(
        Integer,
        ForeignKey('trackpoint.id', onupdate='CASCADE', ondelete='CASCADE'))
    last_change = Column(types.TIMESTAMP(timezone=False),
                         default=timetools.now())
    published = Column(types.TIMESTAMP(timezone=False))
    uuid = Column('uuid', postgresql.UUID, unique=True)
    log = relationship('Log', secondary=log_image_table)
    __table_args__ = (UniqueConstraint('location',
                                       'name',
                                       name='image_location_name'), {})

    def __init__(self, name, location, title, comment, alt, aperture, shutter, focal_length, iso, \
                timestamp_original, hash, hash_large, author, trackpoint, uuid, last_change=timetools.now(), published=None):
        self.name = name
        self.location = location
        self.title = title
        self.comment = comment
        self.alt = alt
        self.aperture = aperture
        self.shutter = shutter
        self.focal_length = focal_length
        self.iso = iso
        self.timestamp_original = timestamp_original
        self.hash = hash
        self.hash_large = hash_large
        self.author = author
        self.trackpoint = trackpoint
        self.uuid = uuid
        self.last_change = last_change
        self.published = published
Esempio n. 5
0
 def __init__(self, name, location, title, comment, alt, aperture, shutter, focal_length, iso, \
             timestamp_original, hash, hash_large, author, trackpoint, uuid, last_change=timetools.now(), published=None):
     self.name = name
     self.location = location
     self.title = title
     self.comment = comment
     self.alt = alt
     self.aperture = aperture
     self.shutter = shutter
     self.focal_length = focal_length
     self.iso = iso
     self.timestamp_original = timestamp_original
     self.hash = hash
     self.hash_large = hash_large
     self.author = author
     self.trackpoint = trackpoint
     self.uuid = uuid
     self.last_change = last_change
     self.published = published
Esempio n. 6
0
 def __init__(self, name, location, title, comment, alt, aperture, shutter, focal_length, iso, \
             timestamp_original, hash, hash_large, author, trackpoint, uuid, last_change=timetools.now(), published=None):
     self.name = name
     self.location = location
     self.title = title
     self.comment = comment
     self.alt = alt
     self.aperture = aperture
     self.shutter = shutter
     self.focal_length = focal_length
     self.iso = iso
     self.timestamp_original = timestamp_original
     self.hash = hash
     self.hash_large = hash_large
     self.author = author
     self.trackpoint = trackpoint
     self.uuid = uuid
     self.last_change = last_change
     self.published = published
Esempio n. 7
0
class Etappe(Base):
    __tablename__ = 'etappe'
    id = Column(Integer, primary_key=True)
    tour = Column(
        Integer, ForeignKey('tour.id', onupdate='CASCADE', ondelete='CASCADE'))
    name = Column(Text)
    description = Column(Text)
    start_timestamp = Column(types.TIMESTAMP(timezone=False),
                             default=timetools.now())
    end_timestamp = Column(types.TIMESTAMP(timezone=False),
                           default=timetools.now())
    reduced_trackpoints = Column('reduced_trackpoints', Text)
    bbox = Column('bbox', Geometry)
    center_id = Column('center_id', types.Integer, ForeignKey('trackpoint.id'))
    uuid = Column(Text, unique=True)
    tracks = relationship('Track', order_by='desc(Track.start_timestamp)')
    center = relationship('Trackpoint', foreign_keys=center_id, uselist=False)
    images = relationship('Image', secondary=etappe_image_table)
    __table_args__ = (UniqueConstraint('start_timestamp',
                                       'end_timestamp',
                                       name='etappe_start_end'), {})

    def __init__(self,
                 tour,
                 name,
                 description,
                 start_timestamp=timetools.now(),
                 end_timestamp=timetools.now(),
                 trackpoints=None,
                 epsilon=Decimal(0.0005),
                 bbox=None,
                 center_id=None,
                 uuid=str(uuidlib.uuid4())):
        self.tour = tour.id
        self.description = description
        self.name = name
        self.start_timestamp = start_timestamp
        self.end_timestamp = end_timestamp
        self.reduced_trackpoints = reduce_trackpoints(trackpoints, epsilon)
        self.bbox = bbox
        self.center_id = center_id
        self.uuid = uuid

    def reprGeoJSON(self):  #returns own columns only
        start_timestamp = self.start_timestamp.strftime('%Y-%m-%d %H:%M:%S')
        end_timestamp = self.end_timestamp.strftime('%Y-%m-%d %H:%M:%S')
        children = [track.id for track in self.tracks]
        center = [float(self.center.longitude), float(self.center.latitude)]
        return dict(id=self.id,
                    name=self.name,
                    description=self.description,
                    start_timestamp=start_timestamp,
                    end_timestamp=end_timestamp,
                    bbox=self.bbox,
                    center=center,
                    uuid=self.uuid,
                    level='etappe',
                    grandparent=dict(level=None, id_list=None),
                    parent=dict(level='tour', id_list=[self.tour]),
                    children=dict(level='track', id_list=children),
                    grandchildren=dict(level=None, id_list=None))