import math


def latlng2tile_terrain(lat_deg, lng_deg, z):
    """
    convert latitude, longitude and zoom into tile in x and y axis, cesium terrain rule
    :param lat_deg: latitude in degree
    :param lng_deg: longitude in degree
    :param z:       map scale (0-18)
    :return:        Return two parameters as tile numbers in x axis and y axis
    """
    n = math.pow(2, int(z + 1))
    reg = 360.0 / n
    x = (lng_deg + 180.0) // reg
    y = (lat_deg + 90.0) // reg
    return x, y