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 authored and ryanhamley committed Sep 21, 2018
1 parent 016d95c commit 52b3da2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/render/draw_debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function drawDebugTile(painter, sourceCache, coord) {
debugUniformValues(posMatrix, Color.red), id,
painter.debugBuffer, painter.tileBorderIndexBuffer, painter.debugSegments);

const vertices = createTextVertices(coord.toString(), 50, 200, 5);
const vertices = createTextVerticies(coord.canonical.toString(), 50, 200, 5);
const debugTextArray = new PosArray();
const debugTextIndices = new LineIndexArray();
for (let v = 0; v < vertices.length; v += 2) {
Expand Down
21 changes: 18 additions & 3 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import EXTENT from '../data/extent';
import pixelsToTileUnits from '../source/pixels_to_tile_units';
import SegmentVector from '../data/segment';
import { RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray } from '../data/array_types';
import { filterObject, values } from '../util/util';
import VertexArrayObject from './vertex_array_object';
import rasterBoundsAttributes from '../data/raster_bounds_attributes';
import posAttributes from '../data/pos_attributes';
import ProgramConfiguration from '../data/program_configuration';
Expand Down Expand Up @@ -395,9 +397,22 @@ class Painter {
}

if (this.options.showTileBoundaries) {
for (const id in sourceCaches) {
draw.debug(this, sourceCaches[id], coordsAscending[id]);
break;
//Use source with highest maxzoom
let selectedSource;
let sourceCache;
const layers = 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
4 changes: 4 additions & 0 deletions src/source/tile_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class CanonicalTileID {
.replace('{quadkey}', quadkey)
.replace('{bbox-epsg-3857}', bbox);
}

toString() {
return `${this.z}/${this.x}/${this.y}`;
}
}

export class UnwrappedTileID {
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 52b3da2

Please sign in to comment.