Fix some stupid bugs in ol.TileBounds
This commit is contained in:
@@ -49,13 +49,23 @@ ol.TileBounds.prototype.clone = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
* @param {ol.TileBounds} tileBounds Tile bounds.
|
||||||
* @return {boolean} Contains.
|
* @return {boolean} Contains.
|
||||||
*/
|
*/
|
||||||
ol.TileBounds.prototype.contains = function(tileBounds) {
|
ol.TileBounds.prototype.containsTileBounds = function(tileBounds) {
|
||||||
return this.minX <= tileBounds.minX && tileBounds.maxX <= this.maxX &&
|
return this.minX <= tileBounds.minX && tileBounds.maxX <= this.maxX &&
|
||||||
this.minY <= tileBounds.minY && tileBounds.minY <= this.minY;
|
this.minY <= tileBounds.minY && tileBounds.minY <= this.maxY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,17 +14,33 @@ function testClone() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function testContainsPositive() {
|
function testContains() {
|
||||||
var tileBounds = new ol.TileBounds(0, 0, 2, 2);
|
var tileBounds = new ol.TileBounds(1, 1, 3, 3);
|
||||||
var tileCoord = new ol.TileCoord(3, 1, 1);
|
assertFalse(tileBounds.contains(new ol.TileCoord(0, 0, 0)));
|
||||||
assertTrue(tileBounds.contains(tileCoord));
|
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)));
|
||||||
function testContainsNegative() {
|
assertFalse(tileBounds.contains(new ol.TileCoord(0, 1, 0)));
|
||||||
var tileBounds = new ol.TileBounds(0, 0, 2, 2);
|
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 1)));
|
||||||
var tileCoord = new ol.TileCoord(3, 1, 3);
|
assertTrue(tileBounds.contains(new ol.TileCoord(0, 1, 2)));
|
||||||
assertFalse(tileBounds.contains(tileCoord));
|
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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ ol.webgl.TileLayerRenderer.prototype.render = function() {
|
|||||||
tileBounds.minY,
|
tileBounds.minY,
|
||||||
tileBounds.minX + nTilesX - 1,
|
tileBounds.minX + nTilesX - 1,
|
||||||
tileBounds.minY + nTilesY - 1);
|
tileBounds.minY + nTilesY - 1);
|
||||||
goog.asserts.assert(framebufferTileBounds.contains(tileBounds));
|
goog.asserts.assert(framebufferTileBounds.containsTileBounds(tileBounds));
|
||||||
|
|
||||||
this.bindFramebuffer_(framebufferDimension);
|
this.bindFramebuffer_(framebufferDimension);
|
||||||
gl.viewport(0, 0, framebufferDimension, framebufferDimension);
|
gl.viewport(0, 0, framebufferDimension, framebufferDimension);
|
||||||
|
|||||||
Reference in New Issue
Block a user