src/client/rsys.js
function wRectangleTiles (z, wr) {
    const [wMinx, wMiny, wMaxx, wMaxy] = wr;
    const n = (1 << z); // for 0 <= z <= 30 equals Math.pow(2, z)

    const clamp = x => Math.min(Math.max(x, 0), n - 1);
    // compute tile coordinate ranges
    const tMinx = clamp(Math.floor(n * (wMinx + 1) * 0.5));
    const tMaxx = clamp(Math.ceil(n * (wMaxx + 1) * 0.5) - 1);
    const tMiny = clamp(Math.floor(n * (1 - wMaxy) * 0.5));
    const tMaxy = clamp(Math.ceil(n * (1 - wMiny) * 0.5) - 1);
    let tiles = [];
    for (let x = tMinx; x <= tMaxx; ++x) {
        for (let y = tMiny; y <= tMaxy; ++y) {
            tiles.push({ x: x, y: y, z: z });
        }
    }
    return tiles;
}
function wRectangleTiles (z, wr) {
    const [wMinx, wMiny, wMaxx, wMaxy] = wr;
    const n = (1 << z); // for 0 <= z <= 30 equals Math.pow(2, z)

    const clamp = x => Math.min(Math.max(x, 0), n - 1);
    // compute tile coordinate ranges
    const tMinx = clamp(Math.floor(n * (wMinx + 1) * 0.5));
    const tMaxx = clamp(Math.ceil(n * (wMaxx + 1) * 0.5) - 1);
    const tMiny = clamp(Math.floor(n * (1 - wMaxy) * 0.5));
    const tMaxy = clamp(Math.ceil(n * (1 - wMiny) * 0.5) - 1);
    let tiles = [];
    for (let x = tMinx; x <= tMaxx; ++x) {
        for (let y = tMiny; y <= tMaxy; ++y) {
            tiles.push({ x: x, y: y, z: z });
        }
    }
    return tiles;
}
function wRectangleTiles ( z , wr ) { const [ wMinx , wMiny , wMaxx , wMaxy ] = wr ; const n = ( 1 << z ) ; // for 0 <= z <= 30 equals Math.pow(2, z) const clamp = x => Math . min ( Math . max ( x , 0 ) , n - 1 ) ; // compute tile coordinate ranges const tMinx = clamp ( Math . floor ( n * ( wMinx + 1 ) * 0.5 ) ) ; const tMaxx = clamp ( Math . ceil ( n * ( wMaxx + 1 ) * 0.5 ) - 1 ) ; const tMiny = clamp ( Math . floor ( n * ( 1 - wMaxy ) * 0.5 ) ) ; const tMaxy = clamp ( Math . ceil ( n * ( 1 - wMiny ) * 0.5 ) - 1 ) ; let tiles = [ ] ; for ( let x = tMinx ; x <= tMaxx ; ++ x ) { for ( let y = tMiny ; y <= tMaxy ; ++ y ) { tiles . push ( { x : x , y : y , z : z } ) ; } } return tiles ; }
TC tiles of a given zoom level that intersect a W rectangle
@param {number} z
@param {Array} - rectangle extents [minx, miny, maxx, maxy]
@return {Array} - array of TC tiles {x, y, z}
TC tiles of a given zoom level that intersect a W rectangle