Ejemplo n.º 1
0
def get_gpx(id):
    session=Session()
    site=session.query(Sites).get(id)
    path= os.path.dirname( os.path.dirname(os.path.abspath(__file__)))
    data_folder=Path(os.path.join(path,'files/gpx/'))
    name_off_file=''.join([str(site.name),'_',str(site.create_at),'.gpx'])
    file_open=data_folder/name_off_file
    f=open(file_open,'w')
    f.write(
    "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><gpx version=\"1.1\" creator=\"Josue MALENGELA - Elie KABUNDA\" xmlns=\"http://www.topografix.com/GPX/1/1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">"
    "\n\t<trk>"
    "\n\t\t<trkseg>"
    )
    for c in site.coordonnates:

        f.write(
            "\n\t\t\t<trkpt lat=\""+c.lat +"\" lon=\""+c.long+"\">"
            "\n\t\t\t\t<ele>"+c.alt[0:len(c.alt)-1]+"</ele>"
            "\n\t\t\t\t<time>"+str(c.moment)+"</time>"
          
            "\n\t\t\t\t<extensions>"
            "\n\t\t\t\t\t<speed>"+c.speed+"</speed>"
            "\n\t\t\t\t</extensions>"
            "\n\t\t\t </trkpt>"
        )


    f.write(

    "\n\t\t</trkseg>"
    "\n\t</trk>"
    "\n</gpx>"
    )

    return name_off_file
Ejemplo n.º 2
0
def getdata_timeline():
    """Video streaming home page."""
    session = Session()
    sites = session.query(Sites).limit(10).order_by(desc(Sites.id))
    session.close()

    return render_template('data.html', sites=sites)
Ejemplo n.º 3
0
def get_user():
    session = Session()
    type_utilisateur = session.query(Type_utilisateur).order_by(
        desc(Type_utilisateur.id))
    session.close()

    return render_template('user_data.html', typeUtilisateur=type_utilisateur)
Ejemplo n.º 4
0
def sites(field):

    field = "" + field + ""
    session = Session()
    sites = session.query(Sites).filter(
        or_(Sites.name.ilike(field),
            Sites.description.ilike(field))).order_by(desc(Sites.id))

    return render_template('timeline.html', sites=sites)
Ejemplo n.º 5
0
class Details():
    def __init__(self):
        self.session = Session()

    def get_details(self, id):

        r = self.session.query(Sites).get(id)
        coord = r.coordonnates
        myList = []
        myList.append({'type': r.type_prelevement})
        for i in coord:
            mydic = {}
            mydic['lat'] = i.lat
            mydic['lng'] = i.long
            myList.append(mydic)

        self.session.close()
        return myList
Ejemplo n.º 6
0
    def on_message(self, message):

        message = ast.literal_eval(message)
        print(message)
        coordonates = {}

        if message.get('action') == 'get_position':
            coordonates = self.getPosition()
        elif message.get('action') == 'start_persiste':
            print("start persisting....")
            self.site_name = str(message.get('site_name'))
            self.capture_type = str(message.get('type'))
            self.description = str(message.get('description'))

            _name = self.site_name
            _description = self.description
            _type = self.capture_type

            mySite = Sites(name=_name,
                           description=_description,
                           type_prelevement=_type)
            self.mysite = mySite
            self.persit = True
        elif message.get('action') == 'stop_persiste':
            self.persit = False
            session = Session()
            session.add(self.mysite)
            session.commit()
            session.close()
        elif message.get('action') == 'gps_test':
            self.getPosition()
            print('gps test')
        elif message.get('action') == 'multiwii_test':
            self.getPosition()
            print('Multiwii test')
        elif message.get('action') == 'arm_test':
            self.getPosition()
            print('Arm test')
Ejemplo n.º 7
0
 def saveNow(self):
     session=Session()
     session.add(self.mysite)
     session.commit()
     session.close()
Ejemplo n.º 8
0
from datetime import date
from models.model import Sites, Type_utilisateur, Type_prelevement, Utilisateur
from models.model import Coordonnates
from models.db_connection import Session, engine, Base

Base.metadata.create_all(engine)
session = Session()
username = '******'
user = session.query(Utilisateur).filter(
    Utilisateur.username.like('%' + username + '%')).all()
if user == []:
    print('vide')
else:

    print(user[0])
Ejemplo n.º 9
0
 def __init__(self):
     self.session = Session()
Ejemplo n.º 10
0
from datetime import date
from models.model import Sites
from models.model import Coordonnates
from models.db_connection import Session, engine, Base
from sqlalchemy import or_

session = Session()

coord = session.query(Sites).filter(
    or_(Sites.name.ilike("%%"), Sites.description.ilike("%%")))

for c in coord:
    print(f'{c.id} ')
    for x in c.coordonnates:
        print(x.lat)