Skip to content

Commit

Permalink
Show image source on horizontally wrapped worlds (#4555)
Browse files Browse the repository at this point in the history
Closes #4551
  • Loading branch information
anandthakker authored Apr 6, 2017
1 parent 13363a2 commit d210ea6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/geo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ class Transform {
);
}

/**
* Return any "wrapped" copies of a given tile coordinate that are visible
* in the current view.
*
* @private
*/
getVisibleWrappedCoordinates(tileCoord) {
const ul = this.pointCoordinate(new Point(0, 0), 0);
const ur = this.pointCoordinate(new Point(this.width, 0), 0);
const w0 = Math.floor(ul.column);
const w1 = Math.floor(ur.column);
const result = [tileCoord];
for (let w = w0; w <= w1; w++) {
if (w === 0) continue;
result.push(new TileCoord(tileCoord.z, tileCoord.x, tileCoord.y, w));
}
return result;
}

/**
* Return all coordinates that could cover this transform for a covering
* zoom level.
Expand Down
2 changes: 1 addition & 1 deletion src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class SourceCache extends Evented {
if (!this.used) {
visibleCoords = [];
} else if (this._source.coord) {
visibleCoords = [this._source.coord];
visibleCoords = transform.getVisibleWrappedCoordinates(this._source.coord);
} else {
visibleCoords = transform.coveringTiles({
tileSize: this._source.tileSize,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": 8,
"metadata": {
"test": {
"skipped": {
"native": "https://github.com/mapbox/mapbox-gl-native/issues/1350"
},
"width": 128,
"height": 64
}
},
"center": [-180, 0],
"sources": {
"image": {
"type": "image",
"coordinates": [
[ -180, 45 ],
[ 180, 45 ],
[ 180, -45 ],
[ -180, -45 ]
],
"url": "local://image/0.png"
}
},
"layers": [
{
"id": "image",
"type": "raster",
"source": "image",
"paint": {
"raster-fade-duration": 0
}
}
]
}

0 comments on commit d210ea6

Please sign in to comment.