Esempio n. 1
0
def test_reimport_track(db):
    updated = Track.query.one().updated

    filename = get_test_resource('json/97684385.json')

    with open(filename) as f:
        data = json.load(f)

    track = Track.from_rk_json(data)

    assert Track.query.count() == 1
    assert track.updated > updated
Esempio n. 2
0
def test_import_track(db):
    filename = get_test_resource('json/97684385.json')

    with open(filename) as f:
        data = json.load(f)

    # we need to insert this user_id into the database
    db.session.add(User(user_id=data['userID']))
    db.session.commit()

    track = Track.from_rk_json(data)

    assert Track.query.count() == 1

    npoints = db.session.scalar(track.points.num_points())

    assert len(data['path']) == npoints

    # FIXME: how to determine the UTM zone automatically?
    length = db.session.scalar(track.points.transform(32755).length())

    assert np.abs(data['total_distance'] - length) < 10 # within 10m