Allow extents to restrict tile ranges requested from the server
The addition of full extent tile ranges also allows us to simplify wrapX handling for tile layers. By limiting wrapX to true and false as possible values, we can remove a lot of guessing logic.
This commit is contained in:
@@ -46,7 +46,79 @@ describe('ol.TileCoord', function() {
|
||||
ol.tilecoord.hash(tileCoord2));
|
||||
});
|
||||
});
|
||||
|
||||
describe('restrictByExtentAndZ', function() {
|
||||
|
||||
it('restricts by z', function() {
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
extent: [10, 20, 30, 40],
|
||||
tileSize: 10,
|
||||
resolutions: [2, 1],
|
||||
minZoom: 1
|
||||
});
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 0, 0], tileGrid))
|
||||
.to.equal(null);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([1, 0, 0], tileGrid))
|
||||
.to.eql([1, 0, 0]);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([2, 0, 0], tileGrid))
|
||||
.to.equal(null);
|
||||
});
|
||||
|
||||
it('restricts by extent when extent defines tile ranges', function() {
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
extent: [10, 20, 30, 40],
|
||||
sizes: [[3, 3]],
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
});
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 1, 1], tileGrid))
|
||||
.to.eql([0, 1, 1]);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 2, 0], tileGrid))
|
||||
.to.equal(null);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 0, 2], tileGrid))
|
||||
.to.equal(null);
|
||||
});
|
||||
|
||||
it('restricts by extent when sizes define tile ranges', function() {
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
origin: [10, 20],
|
||||
sizes: [[3, 3]],
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
});
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 0, 0], tileGrid))
|
||||
.to.eql([0, 0, 0]);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, -1, 0], tileGrid))
|
||||
.to.equal(null);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 0, -1], tileGrid))
|
||||
.to.equal(null);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 2, 2], tileGrid))
|
||||
.to.eql([0, 2, 2]);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 3, 0], tileGrid))
|
||||
.to.equal(null);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 0, 3], tileGrid))
|
||||
.to.equal(null);
|
||||
});
|
||||
|
||||
it('does not restrict by extent with no extent or sizes', function() {
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
origin: [10, 20],
|
||||
tileSize: 10,
|
||||
resolutions: [1]
|
||||
});
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, Infinity, 0], tileGrid))
|
||||
.to.eql([0, Infinity, 0]);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
.to.eql([0, 0, Infinity]);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, -Infinity, 0], tileGrid))
|
||||
.to.eql([0, -Infinity, 0]);
|
||||
expect(ol.tilecoord.restrictByExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
.to.eql([0, 0, Infinity]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
Reference in New Issue
Block a user