Skip to content

Commit

Permalink
Draw debug tiles for source with greatest max zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
Asheem Mamoowala committed Nov 2, 2017
1 parent 575e42d commit 519ca77
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/render/draw_debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function drawDebugTile(painter, sourceCache, coord) {
painter.debugVAO.bind(gl, program, painter.debugBuffer);
gl.drawArrays(gl.LINE_STRIP, 0, painter.debugBuffer.length);

const vertices = createTextVerticies(coord.toString(), 50, 200, 5);
const vertices = createTextVerticies(coord.toString(sourceCache.getSource().maxzoom), 50, 200, 5);
const debugTextArray = new PosArray();
for (let v = 0; v < vertices.length; v += 2) {
debugTextArray.emplaceBack(vertices[v], vertices[v + 1]);
Expand Down
19 changes: 16 additions & 3 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,22 @@ class Painter {
}

if (this.options.showTileBoundaries) {
const sourceCache = this.style.sourceCaches[Object.keys(this.style.sourceCaches)[0]];
if (sourceCache) {
draw.debug(this, sourceCache, sourceCache.getVisibleCoordinates());
//Use source with highest maxzoom
let selectedSource;
let sourceCache;
const layers = util.values(this.style._layers);
layers.forEach((layer) => {
if (layer.source && !layer.isHidden(this.transform.zoom)) {
if (layer.source !== (sourceCache && sourceCache.id)) {
sourceCache = this.style.sourceCaches[layer.source];
}
if (!selectedSource || (selectedSource.getSource().maxzoom < sourceCache.getSource().maxzoom)) {
selectedSource = sourceCache;
}
}
});
if (selectedSource) {
draw.debug(this, selectedSource, selectedSource.getVisibleCoordinates());
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/source/tile_coord.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class TileCoord {
(this: any).posMatrix = null;
}

toString() {
return `${this.z}/${this.x}/${this.y}`;
toString(sourceMaxZoom: number | void) {
if (sourceMaxZoom && sourceMaxZoom < this.z) {
return `${sourceMaxZoom}/${this.x}/${this.y} => ${this.z}`;
} else {
return `${this.z}/${this.x}/${this.y}`;
}
}

toCoordinate(sourceMaxZoom: number | void) {
Expand Down
Binary file modified test/integration/render-tests/debug/tile-overscaled/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/integration/render-tests/debug/tile/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions test/integration/render-tests/debug/tile/style.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
],
"zoom": 14,
"sources": {
"satellite": {
"type": "raster",
"tiles": [
"local://tiles/{z}-{x}-{y}.satellite.png"
],
"maxzoom": 1,
"tileSize": 256
},
"mapbox": {
"type": "vector",
"maxzoom": 14,
Expand All @@ -30,6 +38,14 @@
"background-color": "white"
}
},
{
"id": "raster",
"type": "raster",
"source": "satellite",
"paint": {
"raster-fade-duration": 0
}
},
{
"id": "line",
"type": "symbol",
Expand Down

0 comments on commit 519ca77

Please sign in to comment.