Skip to content

Commit

Permalink
Allow sources to provide a ".coord" property (#3222)
Browse files Browse the repository at this point in the history
fixes #3010
  • Loading branch information
lucaswoj authored Sep 19, 2016
1 parent ed4fa37 commit c0f1c7e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
6 changes: 3 additions & 3 deletions js/source/image_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ImageSource.prototype = util.inherit(Evented, /** @lends ImageSource.prototype *
centerCoord.row = Math.round(centerCoord.row);

this.minzoom = this.maxzoom = centerCoord.zoom;
this._coord = new TileCoord(centerCoord.zoom, centerCoord.column, centerCoord.row);
this.coord = new TileCoord(centerCoord.zoom, centerCoord.column, centerCoord.row);
this._tileCoords = cornerZ0Coords.map(function(coord) {
var zoomedCoord = coord.zoomTo(centerCoord.zoom);
return new Point(
Expand Down Expand Up @@ -154,11 +154,11 @@ ImageSource.prototype = util.inherit(Evented, /** @lends ImageSource.prototype *
},

loadTile: function(tile, callback) {
// We have a single tile -- whoose coordinates are this._coord -- that
// We have a single tile -- whoose coordinates are this.coord -- that
// covers the image we want to render. If that's the one being
// requested, set it up with the image; otherwise, mark the tile as
// `errored` to indicate that we have no data for it.
if (this._coord && this._coord.toString() === tile.coord.toString()) {
if (this.coord && this.coord.toString() === tile.coord.toString()) {
this._setTile(tile);
callback(null);
} else {
Expand Down
14 changes: 11 additions & 3 deletions js/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,17 @@ SourceCache.prototype = util.inherit(Evented, {
// better, retained tiles. They are not drawn separately.
this._coveredTiles = {};

var required = this.used ? transform.coveringTiles(this._source) : [];
for (i = 0; i < required.length; i++) {
coord = required[i];
var visibleCoords;
if (!this.used) {
visibleCoords = [];
} else if (this._source.coord) {
visibleCoords = [this._source.coord];
} else {
visibleCoords = transform.coveringTiles(this._source);
}

for (i = 0; i < visibleCoords.length; i++) {
coord = visibleCoords[i];
tile = this.addTile(coord);

retain[coord.id] = true;
Expand Down
6 changes: 3 additions & 3 deletions js/source/video_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ VideoSource.prototype = util.inherit(Evented, /** @lends VideoSource.prototype *
centerCoord.row = Math.round(centerCoord.row);

this.minzoom = this.maxzoom = centerCoord.zoom;
this._coord = new TileCoord(centerCoord.zoom, centerCoord.column, centerCoord.row);
this.coord = new TileCoord(centerCoord.zoom, centerCoord.column, centerCoord.row);
this._tileCoords = cornerZ0Coords.map(function(coord) {
var zoomedCoord = coord.zoomTo(centerCoord.zoom);
return new Point(
Expand Down Expand Up @@ -179,11 +179,11 @@ VideoSource.prototype = util.inherit(Evented, /** @lends VideoSource.prototype *
},

loadTile: function(tile, callback) {
// We have a single tile -- whoose coordinates are this._coord -- that
// We have a single tile -- whoose coordinates are this.coord -- that
// covers the video frame we want to render. If that's the one being
// requested, set it up with the image; otherwise, mark the tile as
// `errored` to indicate that we have no data for it.
if (this._coord && this._coord.toString() === tile.coord.toString()) {
if (this.coord && this.coord.toString() === tile.coord.toString()) {
this._setTile(tile);
callback(null);
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"jsdom": "^9.4.2",
"json-loader": "^0.5.4",
"lodash": "^4.13.1",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#f6746fe4a0cafe5a6276f9455187b87c8263e3e4",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#01c2e8d1e7bb7a6b2a58ec0df4816eee21dd8646",
"memory-fs": "^0.3.0",
"minifyify": "^7.0.1",
"npm-run-all": "^3.0.0",
Expand Down

0 comments on commit c0f1c7e

Please sign in to comment.