Move quadKey function to the one place it is used
This commit is contained in:
@@ -8,10 +8,35 @@ import {jsonp as requestJSONP} from '../net.js';
|
||||
import {get as getProjection, getTransformFromProjections} from '../proj.js';
|
||||
import SourceState from './State.js';
|
||||
import TileImage from './TileImage.js';
|
||||
import {createOrUpdate, quadKey} from '../tilecoord.js';
|
||||
import {createOrUpdate} from '../tilecoord.js';
|
||||
import {createXYZ, extentFromProjection} from '../tilegrid.js';
|
||||
|
||||
|
||||
/**
|
||||
* @param {import('../tilecoord.js').TileCoord} tileCoord Tile coord.
|
||||
* @return {string} Quad key.
|
||||
*/
|
||||
export function quadKey(tileCoord) {
|
||||
const z = tileCoord[0];
|
||||
const digits = new Array(z);
|
||||
let mask = 1 << (z - 1);
|
||||
let i, charCode;
|
||||
for (i = 0; i < z; ++i) {
|
||||
// 48 is charCode for 0 - '0'.charCodeAt(0)
|
||||
charCode = 48;
|
||||
if (tileCoord[1] & mask) {
|
||||
charCode += 1;
|
||||
}
|
||||
if (tileCoord[2] & mask) {
|
||||
charCode += 2;
|
||||
}
|
||||
digits[i] = String.fromCharCode(charCode);
|
||||
mask >>= 1;
|
||||
}
|
||||
return digits.join('');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The attribution containing a link to the Microsoft® Bing™ Maps Platform APIs’
|
||||
* Terms Of Use.
|
||||
@@ -209,6 +234,7 @@ class BingMaps extends TileImage {
|
||||
const hidpi = this.hidpi_;
|
||||
this.tileUrlFunction = createFromTileUrlFunctions(
|
||||
resource.imageUrlSubdomains.map(function(subdomain) {
|
||||
/** @type {import('../tilecoord.js').TileCoord} */
|
||||
const quadKeyTileCoord = [0, 0, 0];
|
||||
const imageUrl = resource.imageUrl
|
||||
.replace('{subdomain}', subdomain)
|
||||
|
||||
Reference in New Issue
Block a user