コード例 #1
0
def test_reproject_stops_with_transformer():
    a = Stop(id='0',
             x=528504.1342843144,
             y=182155.7435136598,
             epsg='epsg:27700')
    transformer = Transformer.from_proj(Proj('epsg:27700'),
                                        Proj('epsg:4326'),
                                        always_xy=True)
    a.reproject('epsg:4326', transformer)

    correct_lat = 51.52370573323939
    correct_lon = -0.14910908709500162

    assert_semantically_equal({
        'x': a.x,
        'y': a.y
    }, {
        'x': correct_lon,
        'y': correct_lat
    })
    assert round(a.lat, SPATIAL_TOLERANCE) == round(correct_lat,
                                                    SPATIAL_TOLERANCE)
    assert round(a.lon, SPATIAL_TOLERANCE) == round(correct_lon,
                                                    SPATIAL_TOLERANCE)
    assert a.epsg == 'epsg:4326'
コード例 #2
0
def test_reproject_stops_without_transformer():
    a = Stop(id='0',
             x=528504.1342843144,
             y=182155.7435136598,
             epsg='epsg:27700')
    a.reproject('epsg:4326')

    assert_semantically_equal({
        'x': a.x,
        'y': a.y
    }, {
        'x': 51.52370573323939,
        'y': -0.14910908709500162
    })
    assert a.epsg == 'epsg:4326'