def geo_to_h3shape()

in src/h3/_h3shape.py [0:0]


def geo_to_h3shape(geo):
    """
    Translate from ``__geo_interface__`` to H3Shape.

    ``geo`` either implements ``__geo_interface__`` or is a dict matching the format

    Returns
    -------
    H3Shape
    """

    # geo can be dict, a __geo_interface__, a string, LatLngPoly or LatLngMultiPoly
    if isinstance(geo, H3Shape):
        return geo

    if hasattr(geo, '__geo_interface__'):
        # get dict
        geo = geo.__geo_interface__

    assert isinstance(geo, dict)  # todo: remove

    t = geo['type']
    coord = geo['coordinates']

    if t == 'Polygon':
        ll2 = coord
        shape = _LL2_to_polygon(ll2)
    elif t == 'MultiPolygon':
        ll3 = coord
        shape = _LL3_to_mpoly(ll3)
    else:
        raise ValueError('Unrecognized type: ' + str(t))

    return shape