Example #1
0
def test_check_for_metadata_get_max_height():
    height_info = HeightInfo()
    data = height_info.get_max_height(51, 7, 52, 8)
    assert data['h_max'] != height_info.NODATA
    assert isinstance(data['h_max'], float)
    assert isinstance(data['location_max'], list)
    assert data['counter_max'] >= 0
    assert isinstance(data['source'], str)
    assert isinstance(data['attributions'], list)
Example #2
0
def test_check_bounds_get_max_height():
    height_info = HeightInfo()
    # in bounds
    assert height_info.get_max_height(52.5, 5, 53,
                                      5.5)['h_max'] != height_info.NODATA
    # invalid coordinates
    with pytest.raises(ValueError):
        height_info.get_max_height(52.5, 5, 91, 5.5)
    with pytest.raises(ValueError):
        height_info.get_max_height(-91, 5, 53, 5.5)
    with pytest.raises(ValueError):
        height_info.get_max_height(52.5, -181, 53, 5.5)
    with pytest.raises(ValueError):
        height_info.get_max_height(52.5, 5, 53, 181)
    # incorrect rectangle
    assert height_info.get_max_height(54.886907, 15.570925, 47.240591,
                                      6.093066)['h_max'] == height_info.NODATA
    # highest location in the bounding box of Germany
    assert math.isclose(height_info.get_max_height(47.240591, 6.093066,
                                                   54.886907,
                                                   15.570925)['h_max'],
                        2920,
                        abs_tol=16)
    # highest location of the world
    assert math.isclose(height_info.get_max_height(-90, -180, 90,
                                                   180)['h_max'],
                        8613.2,
                        abs_tol=16)