Do not require projection extent for x-wrapping tile sources
This commit is contained in:
@@ -231,7 +231,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction =
|
|||||||
opt_projection : this.getProjection();
|
opt_projection : this.getProjection();
|
||||||
var tileGrid = this.getTileGridForProjection(projection);
|
var tileGrid = this.getTileGridForProjection(projection);
|
||||||
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed');
|
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);
|
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
|
||||||
}
|
}
|
||||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
|
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ ol.source.TileVector.prototype.getTileCoordForTileUrlFunction =
|
|||||||
function(tileCoord, projection) {
|
function(tileCoord, projection) {
|
||||||
var tileGrid = this.tileGrid_;
|
var tileGrid = this.tileGrid_;
|
||||||
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed');
|
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);
|
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
|
||||||
}
|
}
|
||||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ?
|
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ?
|
||||||
|
|||||||
@@ -148,6 +148,20 @@ describe('ol.source.Tile', function() {
|
|||||||
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]);
|
tileCoord = tileSource.getTileCoordForTileUrlFunction([6, 97, -23]);
|
||||||
expect(tileCoord).to.eql(null);
|
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]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -241,6 +255,7 @@ goog.require('ol.Tile');
|
|||||||
goog.require('ol.TileRange');
|
goog.require('ol.TileRange');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.source.Source');
|
goog.require('ol.source.Source');
|
||||||
goog.require('ol.source.Tile');
|
goog.require('ol.source.Tile');
|
||||||
goog.require('ol.tilegrid.TileGrid');
|
goog.require('ol.tilegrid.TileGrid');
|
||||||
|
|||||||
@@ -75,6 +75,25 @@ describe('ol.source.TileVector', function() {
|
|||||||
[6, 97, -23], projection);
|
[6, 97, -23], projection);
|
||||||
expect(tileCoord).to.eql(null);
|
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]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -82,4 +101,5 @@ describe('ol.source.TileVector', function() {
|
|||||||
|
|
||||||
goog.require('ol.format.TopoJSON');
|
goog.require('ol.format.TopoJSON');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
|
goog.require('ol.proj.Projection');
|
||||||
goog.require('ol.source.TileVector');
|
goog.require('ol.source.TileVector');
|
||||||
|
|||||||
Reference in New Issue
Block a user