Example #1
0
def test_subset_bbox_raises2():
    """Test subset GeoJSON raises AssertionError w/o bbox and only tile_type."""
    with pytest.raises(AssertionError):
        subset_geojson(token=XYZ_TOKEN,
                       gj=gj_countries,
                       tile_type="dummy",
                       clip=False)
Example #2
0
def test_subset_spatial_raises():
    """Test subset GeoJSON raises ``ValueError`` with lat, lon and bbox."""
    with pytest.raises(ValueError):
        subset_geojson(
            token=XYZ_TOKEN,
            gj=gj_countries,
            bbox=[13, 51, 14, 52],  # w, s, e, n
            lat=37.377228699000057,
            lon=74.512691691000043,
        )
Example #3
0
def test_subset_bbox_raises1():
    """Test subset GeoJSON raises ValueError for bbox and tile_type."""
    with pytest.raises(ValueError):
        subset_geojson(
            token=XYZ_TOKEN,
            gj=gj_countries,
            bbox=[13, 51, 14, 52],  # w, s, e, n
            tile_type="dummy",
            tile_id="1234",
            clip=False,
        )
Example #4
0
def test_subset_bbox_is_empty():
    """Test subset GeoJSON by tile returns empty list of features."""
    subset = subset_geojson(token=XYZ_TOKEN,
                            gj=gj_countries,
                            bbox=[0, 0, 0, 0],
                            clip=False)
    assert subset["features"] == []
Example #5
0
def test_subset_bbox_is_empty_2():
    """Test subset GeoJSON by tile returns only one feature for Germany."""
    subset = subset_geojson(
        token=XYZ_TOKEN,
        gj=gj_countries,
        bbox=[13, 51, 14, 52],  # w, s, e, n
        clip=False,
    )
    assert len(subset["features"]) == 1
    assert subset["features"][0]["properties"]["name"] == "Germany"
Example #6
0
def test_subset_spatial_search():
    """Test subset GeoJSON with lat/lon/radius returns a FeatureCollection."""
    subset = subset_geojson(
        token=XYZ_TOKEN,
        gj=gj_countries,
        lat=37.377228699000057,
        lon=74.512691691000043,
        radius=100000,
    )
    assert subset["type"] == "FeatureCollection"
Example #7
0
def test_subset_bbox_raises3():
    """Test subset GeoJSON with tile type and ID returns a FeatureCollection."""
    subset = subset_geojson(
        token=XYZ_TOKEN,
        gj=gj_countries,
        tile_type="here",
        tile_id="123",
        clip=False,
    )
    assert "type" in subset.keys()
Example #8
0
def test_subset_spatial_raises2():
    """Test subset GeoJSON raises ``ValueError`` with lat, lon and tile_id, tile_type."""
    with pytest.raises(ValueError):
        subset_geojson(
            token=XYZ_TOKEN,
            gj=gj_countries,
            tile_type="here",
            tile_id="123",
            lat=37.377228699000057,
            lon=74.512691691000043,
        )

    with pytest.raises(ValueError):
        subset_geojson(
            token=XYZ_TOKEN,
            gj=gj_countries,
            tile_id="123",
            lat=37.377228699000057,
            lon=74.512691691000043,
        )
Example #9
0
def test_subset_bbox_bbox_feature():
    """Test subset GeoJSON by tile."""
    subset = subset_geojson(
        token=XYZ_TOKEN,
        gj=gj_countries,
        bbox=[13, 51, 14, 52],  # w, s, e, n
        clip=False,
    )
    assert feature_to_bbox(subset["features"][0]) == [
        5.988658,
        47.302488,
        15.016996,
        54.983104,
    ]
Example #10
0
def test_subset_bbox_is_empty_3():
    """Test subset GeoJSON by tile returns only one feature for Germany."""
    subset = subset_geojson(
        token=XYZ_TOKEN,
        gj=gj_countries,
        bbox=[13, 51, 14, 52],
        clip=True,  # w, s, e, n
    )
    assert len(subset["features"]) == 1
    assert subset["features"][0]["geometry"]["coordinates"] == [[[13, 51, 0],
                                                                 [13, 52, 0],
                                                                 [14, 52, 0],
                                                                 [14, 51, 0],
                                                                 [13, 51, 0]]]