Merge pull request #3780 from ahocevar/call-tileurlfunction-with-transformed-tilecoord
Only expose transformed tile coordinates to the API
This commit is contained in:
@@ -99,8 +99,8 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
var url = source.tileUrlFunction.call(source,
|
||||
[1, 1, -2], 1, projection);
|
||||
var url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
'layer/default/EPSG:3857/1/1/1.jpg');
|
||||
|
||||
@@ -125,8 +125,8 @@ describe('ol.source.WMTS', function() {
|
||||
});
|
||||
|
||||
var projection = ol.proj.get('EPSG:3857');
|
||||
var url = source.tileUrlFunction.call(source,
|
||||
[1, 1, -2], 1, projection);
|
||||
var url = source.tileUrlFunction(
|
||||
source.getTileCoordForTileUrlFunction([1, 1, -2]), 1, projection);
|
||||
expect(url).to.be.eql('http://www.example.com/wmts/coastlines/' +
|
||||
'layer/default/EPSG:3857/1/1/1.jpg');
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('ol.source.XYZ', function() {
|
||||
tileGrid = xyzTileSource.getTileGrid();
|
||||
});
|
||||
|
||||
it('return the expected URL', function() {
|
||||
it('returns the expected URL', function() {
|
||||
|
||||
var coordinate = [829330.2064098881, 5933916.615134273];
|
||||
var tileUrl;
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('ol.TileCoord', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('restrictByExtentAndZ', function() {
|
||||
describe('withinExtentAndZ', function() {
|
||||
|
||||
it('restricts by z', function() {
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
@@ -56,12 +56,9 @@ describe('ol.TileCoord', function() {
|
||||
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);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(false);
|
||||
expect(ol.tilecoord.withinExtentAndZ([1, 0, 0], tileGrid)).to.be(true);
|
||||
expect(ol.tilecoord.withinExtentAndZ([2, 0, 0], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when extent defines tile ranges', function() {
|
||||
@@ -71,12 +68,9 @@ describe('ol.TileCoord', function() {
|
||||
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);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 1, 1], tileGrid)).to.be(true);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 2, 0], tileGrid)).to.be(false);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 0, 2], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('restricts by extent when sizes define tile ranges', function() {
|
||||
@@ -86,18 +80,12 @@ describe('ol.TileCoord', function() {
|
||||
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);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 0, 0], tileGrid)).to.be(true);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, -1, 0], tileGrid)).to.be(false);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 0, -1], tileGrid)).to.be(false);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 2, 2], tileGrid)).to.be(true);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 3, 0], tileGrid)).to.be(false);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 0, 3], tileGrid)).to.be(false);
|
||||
});
|
||||
|
||||
it('does not restrict by extent with no extent or sizes', function() {
|
||||
@@ -106,14 +94,14 @@ describe('ol.TileCoord', function() {
|
||||
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]);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, Infinity, 0], tileGrid))
|
||||
.to.be(true);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
.to.be(true);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, -Infinity, 0], tileGrid))
|
||||
.to.be(true);
|
||||
expect(ol.tilecoord.withinExtentAndZ([0, 0, Infinity], tileGrid))
|
||||
.to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -379,8 +379,8 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var transformFn =
|
||||
ol.tilegrid.createOriginTopLeftTileCoordTransform(tileGrid);
|
||||
var transformFn = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid);
|
||||
expect(transformFn([0, 0, -2])).to.eql([0, 0, 1]);
|
||||
expect(transformFn([0, 0, -1])).to.eql([0, 0, 0]);
|
||||
expect(transformFn([1, 0, -4])).to.eql([1, 0, 3]);
|
||||
@@ -398,10 +398,10 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var transformFn1 =
|
||||
ol.tilegrid.createOriginTopLeftTileCoordTransform(tileGrid);
|
||||
var transformFn2 =
|
||||
ol.tilegrid.createOriginTopLeftTileCoordTransform(tileGrid1);
|
||||
var transformFn1 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid);
|
||||
var transformFn2 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid1);
|
||||
expect(transformFn1([0, 0, -2])).to.eql([0, 0, 1]);
|
||||
expect(transformFn2([0, 0, -2])).to.eql([0, 0, 1]);
|
||||
expect(transformFn1([0, 0, -1])).to.eql([0, 0, 0]);
|
||||
@@ -424,10 +424,10 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
resolutions: [1, 0.5],
|
||||
tileSize: 10
|
||||
});
|
||||
var transformFn1 =
|
||||
ol.tilegrid.createOriginTopLeftTileCoordTransform(tileGrid1);
|
||||
var transformFn2 =
|
||||
ol.tilegrid.createOriginTopLeftTileCoordTransform(tileGrid2);
|
||||
var transformFn1 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid1);
|
||||
var transformFn2 = goog.bind(
|
||||
ol.tilegrid.originTopLeftTileCoordTransform, tileGrid2);
|
||||
expect(tileGrid1.getFullTileRange(0).getHeight()).to.equal(2);
|
||||
expect(transformFn1([0, 0, 0])).to.eql([0, 0, 1]);
|
||||
expect(transformFn2([0, 0, 0])).to.eql([0, 0, 1]);
|
||||
|
||||
@@ -67,18 +67,6 @@ describe('ol.TileUrlFunction', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('withTileCoordTransform', function() {
|
||||
it('creates expected URL', function() {
|
||||
var tileUrl = ol.TileUrlFunction.withTileCoordTransform(
|
||||
function(tileCoord) {
|
||||
return [tileCoord[0], tileCoord[1], -tileCoord[2]];
|
||||
},
|
||||
ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}'));
|
||||
expect(tileUrl([3, 2, -1])).to.eql('3/2/1');
|
||||
expect(tileUrl(null)).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createFromTileUrlFunctions', function() {
|
||||
it('creates expected URL', function() {
|
||||
var tileUrl = ol.TileUrlFunction.createFromTileUrlFunctions([
|
||||
|
||||
Reference in New Issue
Block a user