(context)
Adapts the context to a geometry interface. The coordinates remain
    stored in the context.
Adapts the context to a geometry interface. The coordinates remain
    stored in the context.
Adapts the context to a geometry interface . The coordinates remain stored in the context .
def asShape(context):
    """Adapts the context to a geometry interface. The coordinates remain
    stored in the context.
    """
    if hasattr(context, "__geo_interface__"):
        ob = context.__geo_interface__
    else:
        ob = context

    try:
        geom_type = ob.get("type").lower()
    except AttributeError:
        raise ValueError("Context does not provide geo interface")

    if geom_type == "point":
        return asPoint(ob["coordinates"])
    elif geom_type == "linestring":
        return asLineString(ob["coordinates"])
    elif geom_type == "polygon":
        return asPolygon(ob["coordinates"][0], ob["coordinates"][1:])
    elif geom_type == "multipoint":
        return asMultiPoint(ob["coordinates"])
    elif geom_type == "multilinestring":
        return asMultiLineString(ob["coordinates"])
    elif geom_type == "multipolygon":
        return MultiPolygonAdapter(ob["coordinates"], context_type='geojson')
    elif geom_type == "geometrycollection":
        geoms = [asShape(g) for g in ob.get("geometries", [])]
        return GeometryCollection(geoms)
    else:
        raise ValueError("Unknown geometry type: %s" % geom_type)
def asShape ( context ) : if hasattr ( context , "__geo_interface__" ) : ob = context . __geo_interface__ else : ob = context try : geom_type = ob . get ( "type" ) . lower ( ) except AttributeError : raise ValueError ( "Context does not provide geo interface" ) if geom_type == "point" : return asPoint ( ob [ "coordinates" ] ) elif geom_type == "linestring" : return asLineString ( ob [ "coordinates" ] ) elif geom_type == "polygon" : return asPolygon ( ob [ "coordinates" ] [ 0 ] , ob [ "coordinates" ] [ 1 : ] ) elif geom_type == "multipoint" : return asMultiPoint ( ob [ "coordinates" ] ) elif geom_type == "multilinestring" : return asMultiLineString ( ob [ "coordinates" ] ) elif geom_type == "multipolygon" : return MultiPolygonAdapter ( ob [ "coordinates" ] , context_type = 'geojson' ) elif geom_type == "geometrycollection" : geoms = [ asShape ( g ) for g in ob . get ( "geometries" , [ ] ) ] return GeometryCollection ( geoms ) else : raise ValueError ( "Unknown geometry type: %s" % geom_type )