import math


def _meters_per_pixel(zoom, lat=0.0, tilesize=256):
    """
    Return the pixel resolution for a given mercator tile zoom and lattitude.

    Parameters
    ----------
    zoom: int
        Mercator zoom level
    lat: float, optional
        Latitude in decimal degree (default: 0)
    tilesize: int, optional
        Mercator tile size (default: 256).

    Returns
    -------
    Pixel resolution in meters

    """
    return (math.cos(lat * math.pi / 180.0) * 2 * math.pi * 6378137) / (
        tilesize * 2 ** zoom
    )