import math


def pixel_coords_zoom_to_lat_lon(PixelX, PixelY, zoom):
    """Convert pixel coordinates and zoom from Bing maps to lan, lot

    Parameters
    ----------
    PixelX : int
        horizontal distance from upper left corner in pixels
    PixelY : int
        vertical distance from upper left corner in pixels
    zoom : int
        zoom of the map (essentially size of a pixel)

    Returns
    -------
    tuple of floats
        latitude, longitude
    """
    MapSize = 256 * math.pow(2, zoom)
    x = (PixelX / MapSize) - 0.5
    y = 0.5 - (PixelY / MapSize)
    lon = 360 * x
    lat = 90 - 360 * math.atan(math.exp(-y * 2 * math.pi)) / math.pi

    return lon, lat