def map_tuples(func, obj):
    """
    Returns the mapped coordinates from a Geometry after applying the provided
    function to each coordinate.

    :param func: Function to apply to tuples
    :type func: function
    :param obj: A geometry or feature to extract the coordinates from.
    :type obj: Point, LineString, MultiPoint, MultiLineString, Polygon,
    MultiPolygon
    :return: The result of applying the function to each dimension in the
    array.
    :rtype: list
    :raises ValueError: if the provided object is not GeoJSON.
    """

    if obj['type'] == 'Point':
        coordinates = tuple(func(obj['coordinates']))
    elif obj['type'] in ['LineString', 'MultiPoint']:
        coordinates = [tuple(func(c)) for c in obj['coordinates']]
    elif obj['type'] in ['MultiLineString', 'Polygon']:
        coordinates = [[
            tuple(func(c)) for c in curve]
            for curve in obj['coordinates']]
    elif obj['type'] == 'MultiPolygon':
        coordinates = [[[
            tuple(func(c)) for c in curve]
            for curve in part]
            for part in obj['coordinates']]
    elif obj['type'] in ['Feature', 'FeatureCollection', 'GeometryCollection']:
        return map_geometries(lambda g: map_tuples(func, g), obj)
    else:
        raise ValueError("Invalid geometry object %s" % repr(obj))
    return {'type': obj['type'], 'coordinates': coordinates}
def map_tuples ( func , obj ) : if obj [ 'type' ] == 'Point' : coordinates = tuple ( func ( obj [ 'coordinates' ] ) ) elif obj [ 'type' ] in [ 'LineString' , 'MultiPoint' ] : coordinates = [ tuple ( func ( c ) ) for c in obj [ 'coordinates' ] ] elif obj [ 'type' ] in [ 'MultiLineString' , 'Polygon' ] : coordinates = [ [ tuple ( func ( c ) ) for c in curve ] for curve in obj [ 'coordinates' ] ] elif obj [ 'type' ] == 'MultiPolygon' : coordinates = [ [ [ tuple ( func ( c ) ) for c in curve ] for curve in part ] for part in obj [ 'coordinates' ] ] elif obj [ 'type' ] in [ 'Feature' , 'FeatureCollection' , 'GeometryCollection' ] : return map_geometries ( lambda g : map_tuples ( func , g ) , obj ) else : raise ValueError ( "Invalid geometry object %s" % repr ( obj ) ) return { 'type' : obj [ 'type' ] , 'coordinates' : coordinates }
Returns the mapped coordinates from a Geometry after applying the provided
    function to each coordinate.

    :param func: Function to apply to tuples
    :type func: function
    :param obj: A geometry or feature to extract the coordinates from.
    :type obj: Point, LineString, MultiPoint, MultiLineString, Polygon,
    MultiPolygon
    :return: The result of applying the function to each dimension in the
    array.
    :rtype: list
    :raises ValueError: if the provided object is not GeoJSON.