Exemplo n.º 1
0
    def run(self, user):

        i = randint(0, 100)
        _longitude = randint(6500, 7500) / 1000.
        _latitude = randint(50500, 51500) / 1000.
        _altitude = 500

        while True:
            longitude = sin(i / 73.) * 0.001 + _longitude
            latitude = sin(i / 50.) * 0.004 + _latitude
            altitude = sin(i / 20.) * 300 + _altitude

            fix = TrackingFix()
            fix.pilot_id = user
            fix.set_location(longitude, latitude)
            fix.altitude = altitude

            db.session.add(fix)
            db.session.commit()

            print '.',
            sys.stdout.flush()

            sleep(1)

            i += 1
Exemplo n.º 2
0
    def run(self, user):

        i = randint(0, 100)
        _longitude = randint(6500, 7500) / 1000.
        _latitude = randint(50500, 51500) / 1000.
        _altitude = 500

        while True:
            longitude = sin(i / 73.) * 0.001 + _longitude
            latitude = sin(i / 50.) * 0.004 + _latitude
            altitude = sin(i / 20.) * 300 + _altitude

            fix = TrackingFix()
            fix.pilot_id = user
            fix.set_location(longitude, latitude)
            fix.altitude = altitude

            db.session.add(fix)
            db.session.commit()

            print '.',
            sys.stdout.flush()

            sleep(1)

            i += 1
Exemplo n.º 3
0
def _parse_fix(pilot_id):
    fix = TrackingFix()
    fix.ip = request.remote_addr
    fix.pilot_id = pilot_id

    # Time
    if 'tm' not in request.values:
        raise BadRequest('`tm` (time) parameter is missing.')

    try:
        fix.time = datetime.utcfromtimestamp(int(request.values['tm']))
    except ValueError:
        raise BadRequest('`tm` (time) has to be a POSIX timestamp.')

    # Location
    if 'lat' in request.values and 'lon' in request.values:
        try:
            fix.set_location(float(request.values['lon']), float(request.values['lat']))
        except ValueError:
            raise BadRequest('`lat` and `lon` have to be floating point value in degrees (WGS84).')

    # Altitude
    if 'alt' in request.values:
        try:
            fix.altitude = int(request.values['alt'])
        except ValueError:
            raise BadRequest('`alt` has to be an integer value in meters.')

        if not -1000 <= fix.altitude <= 15000:
            raise BadRequest('`alt` has to be a valid altitude in the range of -1000 to 15000 meters.')

    # Speed
    if 'sog' in request.values:
        try:
            fix.ground_speed = int(request.values['sog']) / 3.6
        except ValueError:
            raise BadRequest('`sog` (speed over ground) has to be an integer value in km/h.')

        if not 0 <= fix.ground_speed <= (500 / 3.6):
            raise BadRequest('`sog` (speed over ground) has to be a valid speed in the range of 0 to 500 km/h.')

    # Track
    if 'cog' in request.values:
        try:
            fix.track = int(request.values['cog'])
        except ValueError:
            raise BadRequest('`cog` (course over ground) has to be an integer value in degrees.')

        if not 0 <= fix.track < 360:
            raise BadRequest('`cog` (course over ground) has to be a valid angle between 0 and 360 degrees.')

    fix.elevation = Elevation.get(fix.location_wkt)

    return fix
Exemplo n.º 4
0
def _parse_fix(pilot_id):
    fix = TrackingFix()
    fix.ip = request.remote_addr
    fix.pilot_id = pilot_id

    # Time
    if 'tm' not in request.values:
        raise BadRequest('`tm` (time) parameter is missing.')

    try:
        fix.time = datetime.utcfromtimestamp(int(request.values['tm']))
    except ValueError:
        raise BadRequest('`tm` (time) has to be a POSIX timestamp.')

    # Location
    if 'lat' in request.values and 'lon' in request.values:
        try:
            fix.set_location(float(request.values['lon']), float(request.values['lat']))
        except ValueError:
            raise BadRequest('`lat` and `lon` have to be floating point value in degrees (WGS84).')

    # Altitude
    if 'alt' in request.values:
        try:
            fix.altitude = int(request.values['alt'])
        except ValueError:
            raise BadRequest('`alt` has to be an integer value in meters.')

        if not -1000 <= fix.altitude <= 15000:
            raise BadRequest('`alt` has to be a valid altitude in the range of -1000 to 15000 meters.')

    # Speed
    if 'sog' in request.values:
        try:
            fix.ground_speed = int(request.values['sog']) / 3.6
        except ValueError:
            raise BadRequest('`sog` (speed over ground) has to be an integer value in km/h.')

        if not 0 <= fix.ground_speed <= (500 / 3.6):
            raise BadRequest('`sog` (speed over ground) has to be a valid speed in the range of 0 to 500 km/h.')

    # Track
    if 'cog' in request.values:
        try:
            fix.track = int(request.values['cog'])
        except ValueError:
            raise BadRequest('`cog` (course over ground) has to be an integer value in degrees.')

        if not 0 <= fix.track < 360:
            raise BadRequest('`cog` (course over ground) has to be a valid angle between 0 and 360 degrees.')

    return fix
Exemplo n.º 5
0
from random import randint
from time import sleep
from skylines import db
from skylines.model import TrackingFix


i = randint(0, 100)
_longitude = randint(6500, 7500) / 1000.
_latitude = randint(50500, 51500) / 1000.
_altitude = 500

while True:
    longitude = sin(i / 73.) * 0.001 + _longitude
    latitude = sin(i / 50.) * 0.004 + _latitude
    altitude = sin(i / 20.) * 300 + _altitude

    fix = TrackingFix()
    fix.pilot_id = args.user
    fix.set_location(longitude, latitude)
    fix.altitude = altitude

    db.session.add(fix)
    db.session.commit()

    print '.',
    sys.stdout.flush()

    sleep(1)

    i += 1
Exemplo n.º 6
0
from math import sin
from random import randint
from time import sleep
from skylines import db
from skylines.model import TrackingFix

i = randint(0, 100)
_longitude = randint(6500, 7500) / 1000.
_latitude = randint(50500, 51500) / 1000.
_altitude = 500

while True:
    longitude = sin(i / 73.) * 0.001 + _longitude
    latitude = sin(i / 50.) * 0.004 + _latitude
    altitude = sin(i / 20.) * 300 + _altitude

    fix = TrackingFix()
    fix.pilot_id = args.user
    fix.set_location(longitude, latitude)
    fix.altitude = altitude

    db.session.add(fix)
    db.session.commit()

    print '.',
    sys.stdout.flush()

    sleep(1)

    i += 1