s/TileBounds/TileRange/
This commit is contained in:
+4
-4
@@ -43,12 +43,12 @@ goog.inherits(ol.tilegrid.XYZ, ol.TileGrid);
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileBounds =
|
ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileRange =
|
||||||
function(tileCoord, callback, opt_obj) {
|
function(tileCoord, callback, opt_obj) {
|
||||||
var x = tileCoord.x;
|
var x = tileCoord.x;
|
||||||
var y = tileCoord.y;
|
var y = tileCoord.y;
|
||||||
var z = tileCoord.z;
|
var z = tileCoord.z;
|
||||||
var tileBounds;
|
var tileRange;
|
||||||
while (true) {
|
while (true) {
|
||||||
z -= 1;
|
z -= 1;
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
@@ -56,8 +56,8 @@ ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileBounds =
|
|||||||
}
|
}
|
||||||
x = Math.floor(x / 2);
|
x = Math.floor(x / 2);
|
||||||
y = Math.floor(y / 2);
|
y = Math.floor(y / 2);
|
||||||
tileBounds = new ol.TileBounds(x, y, x, y);
|
tileRange = new ol.TileRange(x, y, x, y);
|
||||||
if (callback.call(opt_obj, z, tileBounds)) {
|
if (callback.call(opt_obj, z, tileRange)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-26
@@ -79,51 +79,51 @@ function testXYZCropY() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testXYZTileGridForEachTileCoordParentTileBounds() {
|
function testXYZTileGridForEachTileCoordParentTileRange() {
|
||||||
|
|
||||||
var xyzTileGrid = new ol.tilegrid.XYZ(6);
|
var xyzTileGrid = new ol.tilegrid.XYZ(6);
|
||||||
|
|
||||||
var tileCoord = new ol.TileCoord(5, 11, 21);
|
var tileCoord = new ol.TileCoord(5, 11, 21);
|
||||||
var zs = [], tileBoundss = [];
|
var zs = [], tileRanges = [];
|
||||||
xyzTileGrid.forEachTileCoordParentTileBounds(
|
xyzTileGrid.forEachTileCoordParentTileRange(
|
||||||
tileCoord,
|
tileCoord,
|
||||||
function(z, tileBounds) {
|
function(z, tileRange) {
|
||||||
zs.push(z);
|
zs.push(z);
|
||||||
tileBoundss.push(tileBounds);
|
tileRanges.push(tileRange);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(5, zs.length);
|
assertEquals(5, zs.length);
|
||||||
assertEquals(5, tileBoundss.length);
|
assertEquals(5, tileRanges.length);
|
||||||
|
|
||||||
assertEquals(4, zs[0]);
|
assertEquals(4, zs[0]);
|
||||||
assertEquals(5, tileBoundss[0].minX);
|
assertEquals(5, tileRanges[0].minX);
|
||||||
assertEquals(10, tileBoundss[0].minY);
|
assertEquals(10, tileRanges[0].minY);
|
||||||
assertEquals(5, tileBoundss[0].maxX);
|
assertEquals(5, tileRanges[0].maxX);
|
||||||
assertEquals(10, tileBoundss[0].maxY);
|
assertEquals(10, tileRanges[0].maxY);
|
||||||
|
|
||||||
assertEquals(3, zs[1]);
|
assertEquals(3, zs[1]);
|
||||||
assertEquals(2, tileBoundss[1].minX);
|
assertEquals(2, tileRanges[1].minX);
|
||||||
assertEquals(5, tileBoundss[1].minY);
|
assertEquals(5, tileRanges[1].minY);
|
||||||
assertEquals(2, tileBoundss[1].maxX);
|
assertEquals(2, tileRanges[1].maxX);
|
||||||
assertEquals(5, tileBoundss[1].maxY);
|
assertEquals(5, tileRanges[1].maxY);
|
||||||
|
|
||||||
assertEquals(2, zs[2]);
|
assertEquals(2, zs[2]);
|
||||||
assertEquals(1, tileBoundss[2].minX);
|
assertEquals(1, tileRanges[2].minX);
|
||||||
assertEquals(2, tileBoundss[2].minY);
|
assertEquals(2, tileRanges[2].minY);
|
||||||
assertEquals(1, tileBoundss[2].maxX);
|
assertEquals(1, tileRanges[2].maxX);
|
||||||
assertEquals(2, tileBoundss[2].maxY);
|
assertEquals(2, tileRanges[2].maxY);
|
||||||
|
|
||||||
assertEquals(1, zs[3]);
|
assertEquals(1, zs[3]);
|
||||||
assertEquals(0, tileBoundss[3].minX);
|
assertEquals(0, tileRanges[3].minX);
|
||||||
assertEquals(1, tileBoundss[3].minY);
|
assertEquals(1, tileRanges[3].minY);
|
||||||
assertEquals(0, tileBoundss[3].maxX);
|
assertEquals(0, tileRanges[3].maxX);
|
||||||
assertEquals(1, tileBoundss[3].maxY);
|
assertEquals(1, tileRanges[3].maxY);
|
||||||
|
|
||||||
assertEquals(0, zs[4]);
|
assertEquals(0, zs[4]);
|
||||||
assertEquals(0, tileBoundss[4].minX);
|
assertEquals(0, tileRanges[4].minX);
|
||||||
assertEquals(0, tileBoundss[4].minY);
|
assertEquals(0, tileRanges[4].minY);
|
||||||
assertEquals(0, tileBoundss[4].maxX);
|
assertEquals(0, tileRanges[4].maxX);
|
||||||
assertEquals(0, tileBoundss[4].maxY);
|
assertEquals(0, tileRanges[4].maxY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,19 +63,19 @@ ol.renderer.dom.TileLayer.prototype.getTileOffset_ = function(z, resolution) {
|
|||||||
/**
|
/**
|
||||||
* Get rid of tiles outside the rendered extent.
|
* Get rid of tiles outside the rendered extent.
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.TileBounds} tileBounds Tile bounds.
|
* @param {ol.TileRange} tileRange Tile range.
|
||||||
* @param {number} z Z.
|
* @param {number} z Z.
|
||||||
*/
|
*/
|
||||||
ol.renderer.dom.TileLayer.prototype.removeInvisibleTiles_ = function(
|
ol.renderer.dom.TileLayer.prototype.removeInvisibleTiles_ = function(
|
||||||
tileBounds, z) {
|
tileRange, z) {
|
||||||
var key, tileCoord, prune, tile;
|
var key, tileCoord, prune, tile;
|
||||||
for (key in this.renderedTiles_) {
|
for (key in this.renderedTiles_) {
|
||||||
tileCoord = ol.TileCoord.createFromString(key);
|
tileCoord = ol.TileCoord.createFromString(key);
|
||||||
prune = z !== tileCoord.z ||
|
prune = z !== tileCoord.z ||
|
||||||
tileCoord.x < tileBounds.minX ||
|
tileCoord.x < tileRange.minX ||
|
||||||
tileCoord.x > tileBounds.maxX ||
|
tileCoord.x > tileRange.maxX ||
|
||||||
tileCoord.y < tileBounds.minY ||
|
tileCoord.y < tileRange.minY ||
|
||||||
tileCoord.y > tileBounds.maxY;
|
tileCoord.y > tileRange.maxY;
|
||||||
if (prune) {
|
if (prune) {
|
||||||
tile = this.renderedTiles_[key];
|
tile = this.renderedTiles_[key];
|
||||||
delete this.renderedTiles_[key];
|
delete this.renderedTiles_[key];
|
||||||
@@ -109,14 +109,14 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
|||||||
// z represents the "best" resolution
|
// z represents the "best" resolution
|
||||||
var z = tileGrid.getZForResolution(mapResolution);
|
var z = tileGrid.getZForResolution(mapResolution);
|
||||||
|
|
||||||
var tileBounds =
|
var tileRange =
|
||||||
tileGrid.getTileBoundsForExtentAndResolution(mapExtent, mapResolution);
|
tileGrid.getTileRangeForExtentAndResolution(mapExtent, mapResolution);
|
||||||
var tileOffset = this.getTileOffset_(z, mapResolution);
|
var tileOffset = this.getTileOffset_(z, mapResolution);
|
||||||
|
|
||||||
var fragment = document.createDocumentFragment();
|
var fragment = document.createDocumentFragment();
|
||||||
|
|
||||||
var key, tile, pixelBounds, img, newTiles = false;
|
var key, tile, pixelBounds, img, newTiles = false;
|
||||||
tileBounds.forEachTileCoord(z, function(tileCoord) {
|
tileRange.forEachTileCoord(z, function(tileCoord) {
|
||||||
key = tileCoord.toString();
|
key = tileCoord.toString();
|
||||||
tile = this.renderedTiles_[key];
|
tile = this.renderedTiles_[key];
|
||||||
if (!goog.isDef(tile)) {
|
if (!goog.isDef(tile)) {
|
||||||
@@ -143,6 +143,6 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
|
|||||||
goog.dom.appendChild(this.target, fragment);
|
goog.dom.appendChild(this.target, fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeInvisibleTiles_(tileBounds, z);
|
this.removeInvisibleTiles_(tileRange, z);
|
||||||
this.renderedMapResolution_ = mapResolution;
|
this.renderedMapResolution_ = mapResolution;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -308,22 +308,22 @@ ol.renderer.webgl.TileLayer.prototype.render = function() {
|
|||||||
var tileGrid = tileStore.getTileGrid();
|
var tileGrid = tileStore.getTileGrid();
|
||||||
var z = tileGrid.getZForResolution(mapResolution);
|
var z = tileGrid.getZForResolution(mapResolution);
|
||||||
var tileResolution = tileGrid.getResolution(z);
|
var tileResolution = tileGrid.getResolution(z);
|
||||||
var tileBounds = tileGrid.getTileBoundsForExtentAndResolution(
|
var tileRange = tileGrid.getTileRangeForExtentAndResolution(
|
||||||
mapRotatedExtent, tileResolution);
|
mapRotatedExtent, tileResolution);
|
||||||
var tileBoundsSize = tileBounds.getSize();
|
var tileRangeSize = tileRange.getSize();
|
||||||
var tileSize = tileGrid.getTileSize();
|
var tileSize = tileGrid.getTileSize();
|
||||||
|
|
||||||
var maxDimension = Math.max(
|
var maxDimension = Math.max(
|
||||||
tileBoundsSize.width * tileSize.width,
|
tileRangeSize.width * tileSize.width,
|
||||||
tileBoundsSize.height * tileSize.height);
|
tileRangeSize.height * tileSize.height);
|
||||||
var framebufferDimension =
|
var framebufferDimension =
|
||||||
Math.pow(2, Math.ceil(Math.log(maxDimension) / Math.log(2)));
|
Math.pow(2, Math.ceil(Math.log(maxDimension) / Math.log(2)));
|
||||||
var framebufferExtentSize = new ol.Size(
|
var framebufferExtentSize = new ol.Size(
|
||||||
tileResolution * framebufferDimension,
|
tileResolution * framebufferDimension,
|
||||||
tileResolution * framebufferDimension);
|
tileResolution * framebufferDimension);
|
||||||
var origin = tileGrid.getOrigin(z);
|
var origin = tileGrid.getOrigin(z);
|
||||||
var minX = origin.x + tileBounds.minX * tileSize.width * tileResolution;
|
var minX = origin.x + tileRange.minX * tileSize.width * tileResolution;
|
||||||
var minY = origin.y + tileBounds.minY * tileSize.height * tileResolution;
|
var minY = origin.y + tileRange.minY * tileSize.height * tileResolution;
|
||||||
var framebufferExtent = new ol.Extent(
|
var framebufferExtent = new ol.Extent(
|
||||||
minX,
|
minX,
|
||||||
minY,
|
minY,
|
||||||
@@ -382,7 +382,7 @@ ol.renderer.webgl.TileLayer.prototype.render = function() {
|
|||||||
var imagesToLoad = [];
|
var imagesToLoad = [];
|
||||||
|
|
||||||
tilesToDrawByZ[z] = {};
|
tilesToDrawByZ[z] = {};
|
||||||
tileBounds.forEachTileCoord(z, function(tileCoord) {
|
tileRange.forEachTileCoord(z, function(tileCoord) {
|
||||||
|
|
||||||
var tile = tileStore.getTile(tileCoord);
|
var tile = tileStore.getTile(tileCoord);
|
||||||
|
|
||||||
@@ -405,11 +405,11 @@ ol.renderer.webgl.TileLayer.prototype.render = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME this could be more efficient about filling partial holes
|
// FIXME this could be more efficient about filling partial holes
|
||||||
tileGrid.forEachTileCoordParentTileBounds(
|
tileGrid.forEachTileCoordParentTileRange(
|
||||||
tileCoord,
|
tileCoord,
|
||||||
function(z, tileBounds) {
|
function(z, tileRange) {
|
||||||
var fullyCovered = true;
|
var fullyCovered = true;
|
||||||
tileBounds.forEachTileCoord(z, function(tileCoord) {
|
tileRange.forEachTileCoord(z, function(tileCoord) {
|
||||||
var tileCoordKey = tileCoord.toString();
|
var tileCoordKey = tileCoord.toString();
|
||||||
if (tilesToDrawByZ[z] && tilesToDrawByZ[z][tileCoordKey]) {
|
if (tilesToDrawByZ[z] && tilesToDrawByZ[z][tileCoordKey]) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
goog.provide('ol.TileBounds');
|
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
|
||||||
goog.require('ol.Rectangle');
|
|
||||||
goog.require('ol.TileCoord');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.Rectangle}
|
|
||||||
* @param {number} minX Minimum X.
|
|
||||||
* @param {number} minY Minimum Y.
|
|
||||||
* @param {number} maxX Maximum X.
|
|
||||||
* @param {number} maxY Maximum Y.
|
|
||||||
*/
|
|
||||||
ol.TileBounds = function(minX, minY, maxX, maxY) {
|
|
||||||
goog.base(this, minX, minY, maxX, maxY);
|
|
||||||
};
|
|
||||||
goog.inherits(ol.TileBounds, ol.Rectangle);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {...ol.TileCoord} var_args Tile coordinates.
|
|
||||||
* @return {!ol.TileBounds} Bounding tile box.
|
|
||||||
*/
|
|
||||||
ol.TileBounds.boundingTileBounds = function(var_args) {
|
|
||||||
var tileCoord0 = arguments[0];
|
|
||||||
var tileBounds = new ol.TileBounds(tileCoord0.x, tileCoord0.y,
|
|
||||||
tileCoord0.x, tileCoord0.y);
|
|
||||||
var i;
|
|
||||||
for (i = 1; i < arguments.length; ++i) {
|
|
||||||
var tileCoord = arguments[i];
|
|
||||||
goog.asserts.assert(tileCoord.z == tileCoord0.z);
|
|
||||||
tileBounds.minX = Math.min(tileBounds.minX, tileCoord.x);
|
|
||||||
tileBounds.minY = Math.min(tileBounds.minY, tileCoord.y);
|
|
||||||
tileBounds.maxX = Math.max(tileBounds.maxX, tileCoord.x);
|
|
||||||
tileBounds.maxY = Math.max(tileBounds.maxY, tileCoord.y);
|
|
||||||
}
|
|
||||||
return tileBounds;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {ol.TileBounds} Clone.
|
|
||||||
*/
|
|
||||||
ol.TileBounds.prototype.clone = function() {
|
|
||||||
return new ol.TileBounds(this.minX, this.minY, this.maxX, this.maxY);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
|
||||||
* @return {boolean} Contains tile coordinate.
|
|
||||||
*/
|
|
||||||
ol.TileBounds.prototype.contains = function(tileCoord) {
|
|
||||||
return this.minX <= tileCoord.x && tileCoord.x <= this.maxX &&
|
|
||||||
this.minY <= tileCoord.y && tileCoord.y <= this.maxY;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.TileBounds} tileBounds Tile bounds.
|
|
||||||
* @return {boolean} Contains.
|
|
||||||
*/
|
|
||||||
ol.TileBounds.prototype.containsTileBounds = function(tileBounds) {
|
|
||||||
return this.minX <= tileBounds.minX && tileBounds.maxX <= this.maxX &&
|
|
||||||
this.minY <= tileBounds.minY && tileBounds.minY <= this.maxY;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.TileBounds} tileBounds Tile bounds.
|
|
||||||
* @return {boolean} Equals.
|
|
||||||
*/
|
|
||||||
ol.TileBounds.prototype.equals = function(tileBounds) {
|
|
||||||
return this.minX == tileBounds.minX && tileBounds.maxX == this.maxX &&
|
|
||||||
this.minY == tileBounds.minY && tileBounds.minY == this.minY;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} z Z.
|
|
||||||
* @param {function(this: T, ol.TileCoord)} f Callback.
|
|
||||||
* @param {T=} opt_obj The object to be used for the value of 'this' within f.
|
|
||||||
* @template T
|
|
||||||
*/
|
|
||||||
ol.TileBounds.prototype.forEachTileCoord = function(z, f, opt_obj) {
|
|
||||||
var x, y;
|
|
||||||
for (x = this.minX; x <= this.maxX; ++x) {
|
|
||||||
for (y = this.minY; y <= this.maxY; ++y) {
|
|
||||||
f.call(opt_obj, new ol.TileCoord(z, x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @return {number} Height.
|
|
||||||
*/
|
|
||||||
ol.TileBounds.prototype.getHeight = function() {
|
|
||||||
return this.maxY - this.minY + 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
* @return {number} Width.
|
|
||||||
*/
|
|
||||||
ol.TileBounds.prototype.getWidth = function() {
|
|
||||||
return this.maxX - this.minX + 1;
|
|
||||||
};
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
goog.require('goog.testing.jsunit');
|
|
||||||
goog.require('ol.TileBounds');
|
|
||||||
|
|
||||||
|
|
||||||
function testClone() {
|
|
||||||
var tileBounds = new ol.TileBounds(1, 2, 3, 4);
|
|
||||||
var clonedTileBounds = tileBounds.clone();
|
|
||||||
assertTrue(clonedTileBounds instanceof ol.TileBounds);
|
|
||||||
assertFalse(clonedTileBounds === tileBounds);
|
|
||||||
assertEquals(tileBounds.minX, clonedTileBounds.minX);
|
|
||||||
assertEquals(tileBounds.minY, clonedTileBounds.minY);
|
|
||||||
assertEquals(tileBounds.maxX, clonedTileBounds.maxX);
|
|
||||||
assertEquals(tileBounds.maxY, clonedTileBounds.maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testContains() {
|
|
||||||
var tileBounds = new ol.TileBounds(1, 1, 3, 3);
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 0)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 1)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 2)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 1, 0)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 1)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 2)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 1, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 2, 0)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 2, 1)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 2, 2)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 2, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 2, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 3, 0)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 3, 1)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 3, 2)));
|
|
||||||
assertTrue(tileBounds.contains(new ol.TileCoord(0, 3, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 3, 4)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 0)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 1)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 2)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 3)));
|
|
||||||
assertFalse(tileBounds.contains(new ol.TileCoord(0, 4, 4)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testBoundingTileBounds() {
|
|
||||||
var tileBounds = new ol.TileBounds.boundingTileBounds(
|
|
||||||
new ol.TileCoord(3, 1, 3),
|
|
||||||
new ol.TileCoord(3, 2, 0));
|
|
||||||
assertEquals(1, tileBounds.minX);
|
|
||||||
assertEquals(0, tileBounds.minY);
|
|
||||||
assertEquals(2, tileBounds.maxX);
|
|
||||||
assertEquals(3, tileBounds.maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testBoundingTileBoundsMixedZ() {
|
|
||||||
assertThrows(function() {
|
|
||||||
var tileBounds = new ol.TileBounds.boundingTileBounds(
|
|
||||||
new ol.TileCoord(3, 1, 3),
|
|
||||||
new ol.TileCoord(4, 2, 0));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testForEachTileCoord() {
|
|
||||||
|
|
||||||
var tileBounds = new ol.TileBounds(0, 2, 1, 3);
|
|
||||||
|
|
||||||
var tileCoords = [];
|
|
||||||
tileBounds.forEachTileCoord(5, function(tileCoord) {
|
|
||||||
tileCoords.push(tileCoord.clone());
|
|
||||||
});
|
|
||||||
|
|
||||||
assertEquals(4, tileCoords.length);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[0].z);
|
|
||||||
assertEquals(0, tileCoords[0].x);
|
|
||||||
assertEquals(2, tileCoords[0].y);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[1].z);
|
|
||||||
assertEquals(0, tileCoords[1].x);
|
|
||||||
assertEquals(3, tileCoords[1].y);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[2].z);
|
|
||||||
assertEquals(1, tileCoords[2].x);
|
|
||||||
assertEquals(2, tileCoords[2].y);
|
|
||||||
|
|
||||||
assertEquals(5, tileCoords[3].z);
|
|
||||||
assertEquals(1, tileCoords[3].x);
|
|
||||||
assertEquals(3, tileCoords[3].y);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function testSize() {
|
|
||||||
var tileBounds = new ol.TileBounds(0, 1, 2, 4);
|
|
||||||
var size = tileBounds.getSize();
|
|
||||||
assertEquals(3, size.width);
|
|
||||||
assertEquals(4, size.height);
|
|
||||||
}
|
|
||||||
+16
-16
@@ -8,8 +8,8 @@ goog.require('ol.Coordinate');
|
|||||||
goog.require('ol.Extent');
|
goog.require('ol.Extent');
|
||||||
goog.require('ol.PixelBounds');
|
goog.require('ol.PixelBounds');
|
||||||
goog.require('ol.Size');
|
goog.require('ol.Size');
|
||||||
goog.require('ol.TileBounds');
|
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
|
goog.require('ol.TileRange');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
|
|
||||||
|
|
||||||
@@ -76,18 +76,18 @@ ol.TileGrid = function(resolutions, extent, origin, opt_tileSize) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
* @param {function(this: T, number, ol.TileBounds): boolean} callback
|
* @param {function(this: T, number, ol.TileRange): boolean} callback
|
||||||
* Callback.
|
* Callback.
|
||||||
* @param {T=} opt_obj Object.
|
* @param {T=} opt_obj Object.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.TileGrid.prototype.forEachTileCoordParentTileBounds =
|
ol.TileGrid.prototype.forEachTileCoordParentTileRange =
|
||||||
function(tileCoord, callback, opt_obj) {
|
function(tileCoord, callback, opt_obj) {
|
||||||
var tileCoordExtent = this.getTileCoordExtent(tileCoord);
|
var tileCoordExtent = this.getTileCoordExtent(tileCoord);
|
||||||
var z = tileCoord.z - 1;
|
var z = tileCoord.z - 1;
|
||||||
while (z >= 0) {
|
while (z >= 0) {
|
||||||
if (callback.call(
|
if (callback.call(
|
||||||
opt_obj, z, this.getTileBoundsForExtentAndZ(tileCoordExtent, z))) {
|
opt_obj, z, this.getTileRangeForExtentAndZ(tileCoordExtent, z))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
--z;
|
--z;
|
||||||
@@ -158,17 +158,17 @@ ol.TileGrid.prototype.getResolutions = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} z Z.
|
* @param {number} z Z.
|
||||||
* @param {ol.TileBounds} tileBounds Tile bounds.
|
* @param {ol.TileRange} tileRange Tile range.
|
||||||
* @return {ol.Extent} Extent.
|
* @return {ol.Extent} Extent.
|
||||||
*/
|
*/
|
||||||
ol.TileGrid.prototype.getTileBoundsExtent = function(z, tileBounds) {
|
ol.TileGrid.prototype.getTileRangeExtent = function(z, tileRange) {
|
||||||
var origin = this.getOrigin(z);
|
var origin = this.getOrigin(z);
|
||||||
var resolution = this.getResolution(z);
|
var resolution = this.getResolution(z);
|
||||||
var tileSize = this.tileSize_;
|
var tileSize = this.tileSize_;
|
||||||
var minX = origin.x + tileBounds.minX * tileSize.width * resolution;
|
var minX = origin.x + tileRange.minX * tileSize.width * resolution;
|
||||||
var minY = origin.y + tileBounds.minY * tileSize.height * resolution;
|
var minY = origin.y + tileRange.minY * tileSize.height * resolution;
|
||||||
var maxX = origin.x + (tileBounds.maxX + 1) * tileSize.width * resolution;
|
var maxX = origin.x + (tileRange.maxX + 1) * tileSize.width * resolution;
|
||||||
var maxY = origin.y + (tileBounds.maxY + 1) * tileSize.height * resolution;
|
var maxY = origin.y + (tileRange.maxY + 1) * tileSize.height * resolution;
|
||||||
return new ol.Extent(minX, minY, maxX, maxY);
|
return new ol.Extent(minX, minY, maxX, maxY);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -176,26 +176,26 @@ ol.TileGrid.prototype.getTileBoundsExtent = function(z, tileBounds) {
|
|||||||
/**
|
/**
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @return {ol.TileBounds} Tile bounds.
|
* @return {ol.TileRange} Tile range.
|
||||||
*/
|
*/
|
||||||
ol.TileGrid.prototype.getTileBoundsForExtentAndResolution = function(
|
ol.TileGrid.prototype.getTileRangeForExtentAndResolution = function(
|
||||||
extent, resolution) {
|
extent, resolution) {
|
||||||
var min = this.getTileCoordForCoordAndResolution(
|
var min = this.getTileCoordForCoordAndResolution(
|
||||||
new ol.Coordinate(extent.minX, extent.minY), resolution);
|
new ol.Coordinate(extent.minX, extent.minY), resolution);
|
||||||
var max = this.getTileCoordForCoordAndResolution(
|
var max = this.getTileCoordForCoordAndResolution(
|
||||||
new ol.Coordinate(extent.maxX, extent.maxY), resolution);
|
new ol.Coordinate(extent.maxX, extent.maxY), resolution);
|
||||||
return new ol.TileBounds(min.x, min.y, max.x, max.y);
|
return new ol.TileRange(min.x, min.y, max.x, max.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Extent} extent Extent.
|
* @param {ol.Extent} extent Extent.
|
||||||
* @param {number} z Z.
|
* @param {number} z Z.
|
||||||
* @return {ol.TileBounds} Tile bounds.
|
* @return {ol.TileRange} Tile range.
|
||||||
*/
|
*/
|
||||||
ol.TileGrid.prototype.getTileBoundsForExtentAndZ = function(extent, z) {
|
ol.TileGrid.prototype.getTileRangeForExtentAndZ = function(extent, z) {
|
||||||
var resolution = this.getResolution(z);
|
var resolution = this.getResolution(z);
|
||||||
return this.getTileBoundsForExtentAndResolution(extent, resolution);
|
return this.getTileRangeForExtentAndResolution(extent, resolution);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+39
-39
@@ -360,35 +360,35 @@ function testGetTileCoordExtent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testGetExtentTileBounds() {
|
function testGetExtentTileRange() {
|
||||||
|
|
||||||
var tileGrid = new ol.TileGrid(resolutions, extent, origin, tileSize);
|
var tileGrid = new ol.TileGrid(resolutions, extent, origin, tileSize);
|
||||||
var e = new ol.Extent(45000, 5000, 55000, 15000);
|
var e = new ol.Extent(45000, 5000, 55000, 15000);
|
||||||
var tileBounds;
|
var tileRange;
|
||||||
|
|
||||||
tileBounds = tileGrid.getTileBoundsForExtentAndZ(e, 0);
|
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0);
|
||||||
assertEquals(0, tileBounds.minY);
|
assertEquals(0, tileRange.minY);
|
||||||
assertEquals(0, tileBounds.minX);
|
assertEquals(0, tileRange.minX);
|
||||||
assertEquals(0, tileBounds.maxX);
|
assertEquals(0, tileRange.maxX);
|
||||||
assertEquals(0, tileBounds.maxY);
|
assertEquals(0, tileRange.maxY);
|
||||||
|
|
||||||
tileBounds = tileGrid.getTileBoundsForExtentAndZ(e, 1);
|
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 1);
|
||||||
assertEquals(0, tileBounds.minX);
|
assertEquals(0, tileRange.minX);
|
||||||
assertEquals(0, tileBounds.minY);
|
assertEquals(0, tileRange.minY);
|
||||||
assertEquals(1, tileBounds.maxX);
|
assertEquals(1, tileRange.maxX);
|
||||||
assertEquals(0, tileBounds.maxY);
|
assertEquals(0, tileRange.maxY);
|
||||||
|
|
||||||
tileBounds = tileGrid.getTileBoundsForExtentAndZ(e, 2);
|
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 2);
|
||||||
assertEquals(1, tileBounds.minX);
|
assertEquals(1, tileRange.minX);
|
||||||
assertEquals(0, tileBounds.minY);
|
assertEquals(0, tileRange.minY);
|
||||||
assertEquals(2, tileBounds.maxX);
|
assertEquals(2, tileRange.maxX);
|
||||||
assertEquals(0, tileBounds.maxY);
|
assertEquals(0, tileRange.maxY);
|
||||||
|
|
||||||
tileBounds = tileGrid.getTileBoundsForExtentAndZ(e, 3);
|
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 3);
|
||||||
assertEquals(4, tileBounds.minX);
|
assertEquals(4, tileRange.minX);
|
||||||
assertEquals(0, tileBounds.minY);
|
assertEquals(0, tileRange.minY);
|
||||||
assertEquals(5, tileBounds.maxX);
|
assertEquals(5, tileRange.maxX);
|
||||||
assertEquals(1, tileBounds.maxY);
|
assertEquals(1, tileRange.maxY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,36 +396,36 @@ function testGetExtentTileBounds() {
|
|||||||
function testForEachTileCoordParent() {
|
function testForEachTileCoordParent() {
|
||||||
|
|
||||||
var tileGrid = new ol.TileGrid(resolutions, extent, origin, tileSize);
|
var tileGrid = new ol.TileGrid(resolutions, extent, origin, tileSize);
|
||||||
var zs = [], tileBoundss = [];
|
var zs = [], tileRanges = [];
|
||||||
|
|
||||||
tileGrid.forEachTileCoordParentTileBounds(
|
tileGrid.forEachTileCoordParentTileRange(
|
||||||
new ol.TileCoord(3, 7, 3),
|
new ol.TileCoord(3, 7, 3),
|
||||||
function(z, tileBounds) {
|
function(z, tileRange) {
|
||||||
zs.push(z);
|
zs.push(z);
|
||||||
tileBoundss.push(tileBounds);
|
tileRanges.push(tileRange);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(3, zs.length);
|
assertEquals(3, zs.length);
|
||||||
assertEquals(3, tileBoundss.length);
|
assertEquals(3, tileRanges.length);
|
||||||
|
|
||||||
assertEquals(2, zs[0]);
|
assertEquals(2, zs[0]);
|
||||||
assertEquals(2, tileBoundss[0].minX);
|
assertEquals(2, tileRanges[0].minX);
|
||||||
assertEquals(1, tileBoundss[0].minY);
|
assertEquals(1, tileRanges[0].minY);
|
||||||
assertEquals(3, tileBoundss[0].maxX);
|
assertEquals(3, tileRanges[0].maxX);
|
||||||
assertEquals(1, tileBoundss[0].maxY);
|
assertEquals(1, tileRanges[0].maxY);
|
||||||
|
|
||||||
assertEquals(1, zs[1]);
|
assertEquals(1, zs[1]);
|
||||||
assertEquals(1, tileBoundss[1].minX);
|
assertEquals(1, tileRanges[1].minX);
|
||||||
assertEquals(0, tileBoundss[1].minY);
|
assertEquals(0, tileRanges[1].minY);
|
||||||
assertEquals(1, tileBoundss[1].maxX);
|
assertEquals(1, tileRanges[1].maxX);
|
||||||
assertEquals(0, tileBoundss[1].maxY);
|
assertEquals(0, tileRanges[1].maxY);
|
||||||
|
|
||||||
assertEquals(0, zs[2]);
|
assertEquals(0, zs[2]);
|
||||||
assertEquals(0, tileBoundss[2].minX);
|
assertEquals(0, tileRanges[2].minX);
|
||||||
assertEquals(0, tileBoundss[2].minY);
|
assertEquals(0, tileRanges[2].minY);
|
||||||
assertEquals(0, tileBoundss[2].maxX);
|
assertEquals(0, tileRanges[2].maxX);
|
||||||
assertEquals(0, tileBoundss[2].maxY);
|
assertEquals(0, tileRanges[2].maxY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
goog.provide('ol.TileRange');
|
||||||
|
|
||||||
|
goog.require('goog.asserts');
|
||||||
|
goog.require('ol.Rectangle');
|
||||||
|
goog.require('ol.TileCoord');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.Rectangle}
|
||||||
|
* @param {number} minX Minimum X.
|
||||||
|
* @param {number} minY Minimum Y.
|
||||||
|
* @param {number} maxX Maximum X.
|
||||||
|
* @param {number} maxY Maximum Y.
|
||||||
|
*/
|
||||||
|
ol.TileRange = function(minX, minY, maxX, maxY) {
|
||||||
|
goog.base(this, minX, minY, maxX, maxY);
|
||||||
|
};
|
||||||
|
goog.inherits(ol.TileRange, ol.Rectangle);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {...ol.TileCoord} var_args Tile coordinates.
|
||||||
|
* @return {!ol.TileRange} Bounding tile box.
|
||||||
|
*/
|
||||||
|
ol.TileRange.boundingTileRange = function(var_args) {
|
||||||
|
var tileCoord0 = arguments[0];
|
||||||
|
var tileRange = new ol.TileRange(tileCoord0.x, tileCoord0.y,
|
||||||
|
tileCoord0.x, tileCoord0.y);
|
||||||
|
var i;
|
||||||
|
for (i = 1; i < arguments.length; ++i) {
|
||||||
|
var tileCoord = arguments[i];
|
||||||
|
goog.asserts.assert(tileCoord.z == tileCoord0.z);
|
||||||
|
tileRange.minX = Math.min(tileRange.minX, tileCoord.x);
|
||||||
|
tileRange.minY = Math.min(tileRange.minY, tileCoord.y);
|
||||||
|
tileRange.maxX = Math.max(tileRange.maxX, tileCoord.x);
|
||||||
|
tileRange.maxY = Math.max(tileRange.maxY, tileCoord.y);
|
||||||
|
}
|
||||||
|
return tileRange;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.TileRange} Clone.
|
||||||
|
*/
|
||||||
|
ol.TileRange.prototype.clone = function() {
|
||||||
|
return new ol.TileRange(this.minX, this.minY, this.maxX, this.maxY);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
|
* @return {boolean} Contains tile coordinate.
|
||||||
|
*/
|
||||||
|
ol.TileRange.prototype.contains = function(tileCoord) {
|
||||||
|
return this.minX <= tileCoord.x && tileCoord.x <= this.maxX &&
|
||||||
|
this.minY <= tileCoord.y && tileCoord.y <= this.maxY;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.TileRange} tileRange Tile range.
|
||||||
|
* @return {boolean} Contains.
|
||||||
|
*/
|
||||||
|
ol.TileRange.prototype.containsTileRange = function(tileRange) {
|
||||||
|
return this.minX <= tileRange.minX && tileRange.maxX <= this.maxX &&
|
||||||
|
this.minY <= tileRange.minY && tileRange.minY <= this.maxY;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.TileRange} tileRange Tile range.
|
||||||
|
* @return {boolean} Equals.
|
||||||
|
*/
|
||||||
|
ol.TileRange.prototype.equals = function(tileRange) {
|
||||||
|
return this.minX == tileRange.minX && tileRange.maxX == this.maxX &&
|
||||||
|
this.minY == tileRange.minY && tileRange.minY == this.minY;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} z Z.
|
||||||
|
* @param {function(this: T, ol.TileCoord)} f Callback.
|
||||||
|
* @param {T=} opt_obj The object to be used for the value of 'this' within f.
|
||||||
|
* @template T
|
||||||
|
*/
|
||||||
|
ol.TileRange.prototype.forEachTileCoord = function(z, f, opt_obj) {
|
||||||
|
var x, y;
|
||||||
|
for (x = this.minX; x <= this.maxX; ++x) {
|
||||||
|
for (y = this.minY; y <= this.maxY; ++y) {
|
||||||
|
f.call(opt_obj, new ol.TileCoord(z, x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @return {number} Height.
|
||||||
|
*/
|
||||||
|
ol.TileRange.prototype.getHeight = function() {
|
||||||
|
return this.maxY - this.minY + 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @return {number} Width.
|
||||||
|
*/
|
||||||
|
ol.TileRange.prototype.getWidth = function() {
|
||||||
|
return this.maxX - this.minX + 1;
|
||||||
|
};
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
goog.require('goog.testing.jsunit');
|
||||||
|
goog.require('ol.TileRange');
|
||||||
|
|
||||||
|
|
||||||
|
function testClone() {
|
||||||
|
var tileRange = new ol.TileRange(1, 2, 3, 4);
|
||||||
|
var clonedTileRange = tileRange.clone();
|
||||||
|
assertTrue(clonedTileRange instanceof ol.TileRange);
|
||||||
|
assertFalse(clonedTileRange === tileRange);
|
||||||
|
assertEquals(tileRange.minX, clonedTileRange.minX);
|
||||||
|
assertEquals(tileRange.minY, clonedTileRange.minY);
|
||||||
|
assertEquals(tileRange.maxX, clonedTileRange.maxX);
|
||||||
|
assertEquals(tileRange.maxY, clonedTileRange.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testContains() {
|
||||||
|
var tileRange = new ol.TileRange(1, 1, 3, 3);
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 0, 0)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 0, 1)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 0, 2)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 0, 3)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 0, 4)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 1, 0)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 1, 1)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 1, 2)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 1, 3)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 1, 4)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 2, 0)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 2, 1)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 2, 2)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 2, 3)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 2, 4)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 3, 0)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 3, 1)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 3, 2)));
|
||||||
|
assertTrue(tileRange.contains(new ol.TileCoord(0, 3, 3)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 3, 4)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 4, 0)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 4, 1)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 4, 2)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 4, 3)));
|
||||||
|
assertFalse(tileRange.contains(new ol.TileCoord(0, 4, 4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testBoundingTileRange() {
|
||||||
|
var tileRange = new ol.TileRange.boundingTileRange(
|
||||||
|
new ol.TileCoord(3, 1, 3),
|
||||||
|
new ol.TileCoord(3, 2, 0));
|
||||||
|
assertEquals(1, tileRange.minX);
|
||||||
|
assertEquals(0, tileRange.minY);
|
||||||
|
assertEquals(2, tileRange.maxX);
|
||||||
|
assertEquals(3, tileRange.maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testBoundingTileRangeMixedZ() {
|
||||||
|
assertThrows(function() {
|
||||||
|
var tileRange = new ol.TileRange.boundingTileRange(
|
||||||
|
new ol.TileCoord(3, 1, 3),
|
||||||
|
new ol.TileCoord(4, 2, 0));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testForEachTileCoord() {
|
||||||
|
|
||||||
|
var tileRange = new ol.TileRange(0, 2, 1, 3);
|
||||||
|
|
||||||
|
var tileCoords = [];
|
||||||
|
tileRange.forEachTileCoord(5, function(tileCoord) {
|
||||||
|
tileCoords.push(tileCoord.clone());
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(4, tileCoords.length);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[0].z);
|
||||||
|
assertEquals(0, tileCoords[0].x);
|
||||||
|
assertEquals(2, tileCoords[0].y);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[1].z);
|
||||||
|
assertEquals(0, tileCoords[1].x);
|
||||||
|
assertEquals(3, tileCoords[1].y);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[2].z);
|
||||||
|
assertEquals(1, tileCoords[2].x);
|
||||||
|
assertEquals(2, tileCoords[2].y);
|
||||||
|
|
||||||
|
assertEquals(5, tileCoords[3].z);
|
||||||
|
assertEquals(1, tileCoords[3].x);
|
||||||
|
assertEquals(3, tileCoords[3].y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function testSize() {
|
||||||
|
var tileRange = new ol.TileRange(0, 1, 2, 4);
|
||||||
|
var size = tileRange.getSize();
|
||||||
|
assertEquals(3, size.width);
|
||||||
|
assertEquals(4, size.height);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user