Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show image source on horizontally wrapped worlds #4555

Merged
merged 1 commit into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
]
}