import math


def calculate_circle_spacing(radius_m, overlap_m=0):
    """
    Takes a radius in meters and an overlap in meters. Calculates the minimum
    spacing of circles of the given radius that will ensure no gaps between
    them. This is equal to the width of a square that fits inside the circle.
    The overlap insures against gaps between circles when used to calculate
    geographic coordinates.
    """
    if radius_m <= overlap_m:  # pragma: no cover
        raise ValueError('radius_m must be greater than overlap_m')
    return (2 * radius_m / math.sqrt(2)) - overlap_m