示例#1
0
def test_linestring_collection():
    from flopy.utils.geospatial_utils import GeoSpatialCollection
    from flopy.utils.geometry import Shape, Collection

    col = [Shape.from_geojson(linestring),
           Shape.from_geojson(multilinestring)]

    gi1 = [i.__geo_interface__ for i in col]
    col = Collection(col)

    gc1 = GeoSpatialCollection(col)
    shapetype = gc1.shapetype
    shp = gc1.shape
    shply = gc1.shapely
    points = gc1.points
    geojson = gc1.geojson
    fp_geo = gc1.flopy_geometry

    collections = [shp, shply, points, geojson, fp_geo]
    for col in collections:
        if col is None:  # if geojson or shapely is not installed
            continue

        gc2 = GeoSpatialCollection(col, shapetype)
        gi2 = [i.flopy_geometry.__geo_interface__ for i in gc2]

        for ix, gi in enumerate(gi2):
            is_equal = gi == gi1[ix]

            if not is_equal:
                raise AssertionError("GeoSpatialCollection Linestring "
                                     "conversion error")
示例#2
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")
示例#3
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")
示例#4
0
    def flopy_geometry(self):
        """
        Returns a flopy geometry object to the user

        Returns
        -------
            flopy.utils.geometry.<Shape>
        """
        if self._flopy_geometry is None:
            self._flopy_geometry = Shape.from_geojson(self.__geo_interface)
        return self._flopy_geometry