def interpolate_coordinates(row, nodes_gdf):
    """This function approximates the coordinates of a vehicle position.
    For simplicity and computational effort, it is assumed that street sections are small compared to the earth radius
    and linear interpolation has sufficient accuraccy.

    :param pos: (o_node, d_node, rel_pos) of an edge | d_node, rel_pos can be None (if vehicle is idle in o_node)
    :param nodes_gdf: GeoDataFrame with node geometry in WGS84 coordinates
    :return: lon, lat
    """
    pos = row["nw_pos"]
    p0 = nodes_gdf.loc[pos[0], "geometry"]
    p0_lon = p0.x
    p0_lat = p0.y
    if pos[1] == -1:
        return p0_lon, p0_lat
    else:
        p1 = nodes_gdf.loc[pos[1], "geometry"]
        p1_lon = p1.x
        p1_lat = p1.y
        return p0_lon + (p1_lon - p0_lon)*pos[2], p0_lat + (p1_lat - p0_lat)*pos[2]
        #return (p0_lon + p1_lon) / 2, (p0_lat + p1_lat) / 2