def edge_coord_in_direction(tile_id, direction):
    """
    Returns the edge coordinate in the given direction at the given tile identifier.

    :param tile_id: tile identifier, int
    :param direction: direction, str
    :return: edge coord, int
    """
    tile_coord = tile_id_to_coord(tile_id)
    for edge_coord in edges_touching_tile(tile_id):
        if tile_edge_offset_to_direction(edge_coord - tile_coord) == direction:
            return edge_coord
    raise ValueError('No edge found in direction={} at tile_id={}'.format(
        direction,
        tile_id
    ))