Beispiel #1
0
def test_polygon():
    from flopy.utils.geospatial_utils import GeoSpatialUtil
    from flopy.utils.geometry import Shape, Polygon

    poly = Shape.from_geojson(polygon)
    gi1 = poly.__geo_interface__

    if not isinstance(poly, Polygon):
        raise AssertionError()

    gu = GeoSpatialUtil(poly)

    shp = gu.shape
    shply = gu.shapely
    points = gu.points
    geojson = gu.geojson
    fp_geo = gu.flopy_geometry

    geo_types = [shp, shply, points, geojson, fp_geo]

    for geo in geo_types:
        if geo is None:  # if shapely or geojson is not installed
            continue
        t = GeoSpatialUtil(geo, 'polygon').flopy_geometry
        gi2 = t.__geo_interface__

        is_equal = gi1 == gi2

        if not is_equal:
            raise AssertionError("GeoSpatialUtil polygon conversion error")
Beispiel #2
0
def test_multilinestring():
    from flopy.utils.geospatial_utils import GeoSpatialUtil
    from flopy.utils.geometry import Shape, MultiLineString

    mlstr = Shape.from_geojson(multilinestring)
    gi1 = mlstr.__geo_interface__

    if not isinstance(mlstr, MultiLineString):
        raise AssertionError()

    gu = GeoSpatialUtil(mlstr)

    shp = gu.shape
    shply = gu.shapely
    points = gu.points
    geojson = gu.geojson
    fp_geo = gu.flopy_geometry

    geo_types = [shp, shply, points, geojson, fp_geo]

    for geo in geo_types:
        if geo is None:  # if shapely or geojson is not installed
            continue
        t = GeoSpatialUtil(geo, 'multilinestring').flopy_geometry
        gi2 = t.__geo_interface__

        is_equal = gi1 == gi2

        if not is_equal:
            raise AssertionError("GeoSpatialUtil multilinestring "
                                 "conversion error")