(context)
Returns a new, independent geometry with coordinates *copied* from the
    context.
Returns a new, independent geometry with coordinates *copied* from the
    context.
Returns a new independent geometry with coordinates * copied * from the context .
def shape(context):
    """Returns a new, independent geometry with coordinates *copied* from the
    context.
    """
    if hasattr(context, "__geo_interface__"):
        ob = context.__geo_interface__
    else:
        ob = context
    geom_type = ob.get("type").lower()
    if geom_type == "point":
        return Point(ob["coordinates"])
    elif geom_type == "linestring":
        return LineString(ob["coordinates"])
    elif geom_type == "polygon":
        return Polygon(ob["coordinates"][0], ob["coordinates"][1:])
    elif geom_type == "multipoint":
        return MultiPoint(ob["coordinates"])
    elif geom_type == "multilinestring":
        return MultiLineString(ob["coordinates"])
    elif geom_type == "multipolygon":
        return MultiPolygon(ob["coordinates"], context_type='geojson')
    elif geom_type == "geometrycollection":
        geoms = [shape(g) for g in ob.get("geometries", [])]
        return GeometryCollection(geoms)
    else:
        raise ValueError("Unknown geometry type: %s" % geom_type)
def shape ( context ) : if hasattr ( context , "__geo_interface__" ) : ob = context . __geo_interface__ else : ob = context geom_type = ob . get ( "type" ) . lower ( ) if geom_type == "point" : return Point ( ob [ "coordinates" ] ) elif geom_type == "linestring" : return LineString ( ob [ "coordinates" ] ) elif geom_type == "polygon" : return Polygon ( ob [ "coordinates" ] [ 0 ] , ob [ "coordinates" ] [ 1 : ] ) elif geom_type == "multipoint" : return MultiPoint ( ob [ "coordinates" ] ) elif geom_type == "multilinestring" : return MultiLineString ( ob [ "coordinates" ] ) elif geom_type == "multipolygon" : return MultiPolygon ( ob [ "coordinates" ] , context_type = 'geojson' ) elif geom_type == "geometrycollection" : geoms = [ shape ( g ) for g in ob . get ( "geometries" , [ ] ) ] return GeometryCollection ( geoms ) else : raise ValueError ( "Unknown geometry type: %s" % geom_type )