def _centroid(gen):
    """Find the centroid of the coordinates given by the generator.  The
    generator should yield pairs (longitude, latitude).

    :return: Pair (longitude, latitude) of the centroid.
    """
    n, lon, lat = 0, 0, 0
    for pair in gen:
        lon += pair[0]
        lat += pair[1]
        n += 1
    if n == 0:
        raise ValueError("No points found to compute centroid from")
    return lon / n, lat / n