import math


def get_meters_per_pixel(zoom):
    """
    Get meters per pixel in order to determine appropriate 
    simplification for geometry at particular zoom level

    Formula for calculating distance (m) per pixel at zoom level is:
    d = C * cos(latitude) / 2^(zoom + 8)
    where C = 40075016.686 (equatorial circumference)

    https://wiki.openstreetmap.org/wiki/Zoom_levels
    """

    # We assume smallest distance for UK, so choose northernmost point, eg. Shetland, 61 degrees north
    C = 40075016.686
    d = C * math.cos((61 / 360) * (2 * math.pi)) / (2 ** (zoom + 8))

    return d