Skip to content

Commit

Permalink
Merge pull request openlayers#3867 from ahocevar/no-proj-extent-required
Browse files Browse the repository at this point in the history
Do not require projection extent for x-wrapping tile sources
  • Loading branch information
ahocevar committed Jul 3, 2015
2 parents 96eaf2d + da66a37 commit 0690877
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ol/source/tilesource.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction =
opt_projection : this.getProjection();
var tileGrid = this.getTileGridForProjection(projection);
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed');
if (this.getWrapX() && projection.canWrapX()) {
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
}
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
Expand Down
2 changes: 1 addition & 1 deletion src/ol/source/tilevectorsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ ol.source.TileVector.prototype.getTileCoordForTileUrlFunction =
function(tileCoord, projection) {
var tileGrid = this.tileGrid_;
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed');
if (this.getWrapX() && projection.canWrapX()) {
if (this.getWrapX() && projection.isGlobal()) {
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
}
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ?
Expand Down
15 changes: 15 additions & 0 deletions test/spec/ol/source/tilesource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ describe('ol.source.Tile', function() {
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]);
expect(tileCoord).to.eql(null);
});

it('works with wrapX and custom projection without extent', function() {
var tileSource = new ol.source.Tile({
projection: new ol.proj.Projection({
code: 'foo',
global: true,
units: 'm'
}),
wrapX: true
});

var tileCoord = tileSource.getTileCoordForTileUrlFunction([6, -31, -23]);
expect(tileCoord).to.eql([6, 33, -23]);
});
});

});
Expand Down Expand Up @@ -241,6 +255,7 @@ goog.require('ol.Tile');
goog.require('ol.TileRange');
goog.require('ol.TileState');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.source.Source');
goog.require('ol.source.Tile');
goog.require('ol.tilegrid.TileGrid');
20 changes: 20 additions & 0 deletions test/spec/ol/source/tilevectorsource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,31 @@ describe('ol.source.TileVector', function() {
[6, 97, -23], projection);
expect(tileCoord).to.eql(null);
});

it('works with wrapX and custom projection without extent', function() {
var tileSource = new ol.source.TileVector({
format: new ol.format.TopoJSON(),
tileGrid: ol.tilegrid.createXYZ({
maxZoom: 19
}),
wrapX: true
});
var projection = new ol.proj.Projection({
code: 'foo',
global: true,
units: 'm'
});

var tileCoord = tileSource.getTileCoordForTileUrlFunction(
[6, -31, -23], projection);
expect(tileCoord).to.eql([6, 33, -23]);
});
});

});


goog.require('ol.format.TopoJSON');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.source.TileVector');

0 comments on commit 0690877

Please sign in to comment.