Example #1
0
def test_to_geojson_indent(indent):
    separators = (",", ":") if indent is None else (",", ": ")
    expected = json.dumps(json.loads(GEOJSON_GEOMETRY),
                          indent=indent,
                          separators=separators)
    actual = shapely.to_geojson(GEOJSON_GEOMETRY_EXPECTED, indent=indent)
    assert actual == expected
Example #2
0
def test_geojson_all_types(geom):
    if shapely.get_type_id(geom) == shapely.GeometryType.LINEARRING:
        pytest.skip("Linearrings are not preserved in GeoJSON")
    geojson = shapely.to_geojson(geom)
    actual = shapely.from_geojson(geojson)
    assert_geometries_equal(actual, geom)
Example #3
0
def test_to_geojson_point_empty(geom):
    # Pending GEOS ticket: https://trac.osgeo.org/geos/ticket/1139
    with pytest.raises(ValueError):
        assert shapely.to_geojson(geom)
Example #4
0
def test_to_geojson_exceptions():
    with pytest.raises(TypeError):
        shapely.to_geojson(1)
Example #5
0
def test_to_geojson(geometry, expected):
    actual = shapely.to_geojson(geometry, indent=4)
    assert np.all(actual == np.asarray(expected))