Exemplo n.º 1
0
def test_serialization():
    class TestSchema(Schema):
        location = fields.Location()

    data = TestSchema().dump(
        dict(location=Location(longitude=7, latitude=51))).data
    assert data['location'] == [7, 51]
Exemplo n.º 2
0
def test_geoid():
    # test data from http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html
    assert egm96_height(Location(38.6281550, 269.7791550)) == pytest.approx(-31.629, abs=0.25)
    assert egm96_height(Location(-14.6212170, 305.0211140)) == pytest.approx(-2.966, abs=0.25)
    assert egm96_height(Location(46.8743190, 102.4487290)) == pytest.approx(-43.572, abs=0.25)
    assert egm96_height(Location(-23.6174460, 133.8747120)) == pytest.approx(15.868, abs=0.25)
    assert egm96_height(Location(38.6254730, 359.9995000)) == pytest.approx(50.065, abs=0.5)
    assert egm96_height(Location(-.4667440, .0023000)) == pytest.approx(17.330, abs=0.25)
Exemplo n.º 3
0
 def update_cache():
     return Location.get_clustered_locations(Flight.takeoff_location_wkt,
                                             filter=(Flight.pilot == self.user))
Exemplo n.º 4
0
# -*- coding: utf-8 -*-

import pytest

from skylines.lib.geo import geographic_distance
from skylines.model.geo import Location


@pytest.mark.parametrize(
    "loc1,loc2,expected",
    [
        (
            Location(latitude=0.0, longitude=0.0),
            Location(latitude=0.0, longitude=0.0),
            0.0,
        ),
        (
            Location(latitude=38.898556, longitude=-77.037852),
            Location(latitude=38.897147, longitude=-77.043934),
            548.812,
        ),
    ],
)
def test_geographic_distance(loc1, loc2, expected):
    result = geographic_distance(loc1, loc2)
    assert result == pytest.approx(expected)
Exemplo n.º 5
0
    def landing_location(self):
        if self.landing_location_wkt is None:
            return None

        wkt = DBSession.scalar(self.landing_location_wkt.wkt)
        return Location.from_wkt(wkt)
Exemplo n.º 6
0
    def takeoff_location(self):
        if self.takeoff_location_wkt is None:
            return None

        wkt = DBSession.scalar(self.takeoff_location_wkt.wkt)
        return Location.from_wkt(wkt)
Exemplo n.º 7
0
 def get_takeoff_locations(self):
     return Location.get_clustered_locations(Flight.takeoff_location_wkt,
                                             filter=(Flight.pilot == self.user))