Make the tile debug source useful for understanding tiles
This commit is contained in:
@@ -6,7 +6,7 @@ import Tile from '../Tile.js';
|
||||
import TileState from '../TileState.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import {toSize} from '../size.js';
|
||||
import TileSource from './Tile.js';
|
||||
import XYZ from './XYZ.js';
|
||||
import {getKeyZXY} from '../tilecoord.js';
|
||||
|
||||
|
||||
@@ -51,10 +51,10 @@ class LabeledTile extends Tile {
|
||||
const tileSize = this.tileSize_;
|
||||
const context = createCanvasContext2D(tileSize[0], tileSize[1]);
|
||||
|
||||
context.strokeStyle = 'black';
|
||||
context.strokeStyle = 'grey';
|
||||
context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5);
|
||||
|
||||
context.fillStyle = 'black';
|
||||
context.fillStyle = 'grey';
|
||||
context.textAlign = 'center';
|
||||
context.textBaseline = 'middle';
|
||||
context.font = '24px sans-serif';
|
||||
@@ -74,7 +74,7 @@ class LabeledTile extends Tile {
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {import("../proj.js").ProjectionLike} projection Projection.
|
||||
* @property {import("../proj.js").ProjectionLike} [projection='EPSG:3857'] Optional projection.
|
||||
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid] Tile grid.
|
||||
* @property {boolean} [wrapX=true] Whether to wrap the world horizontally.
|
||||
*/
|
||||
@@ -89,11 +89,15 @@ class LabeledTile extends Tile {
|
||||
* Uses Canvas context2d, so requires Canvas support.
|
||||
* @api
|
||||
*/
|
||||
class TileDebug extends TileSource {
|
||||
class TileDebug extends XYZ {
|
||||
/**
|
||||
* @param {Options} options Debug tile options.
|
||||
* @param {Options=} opt_options Debug tile options.
|
||||
*/
|
||||
constructor(options) {
|
||||
constructor(opt_options) {
|
||||
/**
|
||||
* @type {Options}
|
||||
*/
|
||||
const options = opt_options || {};
|
||||
|
||||
super({
|
||||
opaque: false,
|
||||
@@ -115,8 +119,12 @@ class TileDebug extends TileSource {
|
||||
const tileSize = toSize(this.tileGrid.getTileSize(z));
|
||||
const tileCoord = [z, x, y];
|
||||
const textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
|
||||
const text = !textTileCoord ? '' :
|
||||
this.getTileCoordForTileUrlFunction(textTileCoord).toString();
|
||||
let text;
|
||||
if (textTileCoord) {
|
||||
text = 'z:' + textTileCoord[0] + ' x:' + textTileCoord[1] + ' y:' + (-textTileCoord[2] - 1);
|
||||
} else {
|
||||
text = 'none';
|
||||
}
|
||||
const tile = new LabeledTile(tileCoord, tileSize, text);
|
||||
this.tileCache.set(tileCoordKey, tile);
|
||||
return tile;
|
||||
|
||||
Reference in New Issue
Block a user