Add ol.TileRange#containsXY function
This commit is contained in:
@@ -48,7 +48,6 @@ ol.tilegrid.XYZ.prototype.createTileCoordTransform = function(opt_options) {
|
||||
var minZ = this.minZoom;
|
||||
var maxZ = this.maxZoom;
|
||||
var wrapX = goog.isDef(options.wrapX) ? options.wrapX : true;
|
||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||
/** @type {Array.<ol.TileRange>} */
|
||||
var tileRangeByZ = null;
|
||||
if (goog.isDef(options.extent)) {
|
||||
@@ -86,10 +85,7 @@ ol.tilegrid.XYZ.prototype.createTileCoordTransform = function(opt_options) {
|
||||
return null;
|
||||
}
|
||||
if (!goog.isNull(tileRangeByZ)) {
|
||||
tmpTileCoord.z = z;
|
||||
tmpTileCoord.x = x;
|
||||
tmpTileCoord.y = y;
|
||||
if (!tileRangeByZ[z].contains(tmpTileCoord)) {
|
||||
if (!tileRangeByZ[z].containsXY(x, y)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ ol.tilegrid.Zoomify.prototype.createTileCoordTransform = function(opt_options) {
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
var minZ = this.minZoom;
|
||||
var maxZ = this.maxZoom;
|
||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||
/** @type {Array.<ol.TileRange>} */
|
||||
var tileRangeByZ = null;
|
||||
if (goog.isDef(options.extent)) {
|
||||
@@ -70,10 +69,7 @@ ol.tilegrid.Zoomify.prototype.createTileCoordTransform = function(opt_options) {
|
||||
return null;
|
||||
}
|
||||
if (!goog.isNull(tileRangeByZ)) {
|
||||
tmpTileCoord.z = z;
|
||||
tmpTileCoord.x = x;
|
||||
tmpTileCoord.y = -y - 1;
|
||||
if (!tileRangeByZ[z].contains(tmpTileCoord)) {
|
||||
if (!tileRangeByZ[z].containsXY(x, -y - 1)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,7 @@ ol.TileRange.createOrUpdate = function(minX, maxX, minY, maxY, tileRange) {
|
||||
* @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;
|
||||
return this.containsXY(tileCoord.x, tileCoord.y);
|
||||
};
|
||||
|
||||
|
||||
@@ -104,6 +103,16 @@ ol.TileRange.prototype.containsTileRange = function(tileRange) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} x Tile coordinate x.
|
||||
* @param {number} y Tile coordinate y.
|
||||
* @return {boolean} Contains coordinate.
|
||||
*/
|
||||
ol.TileRange.prototype.containsXY = function(x, y) {
|
||||
return this.minX <= x && x <= this.maxX && this.minY <= y && y <= this.maxY;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileRange} tileRange Tile range.
|
||||
* @return {boolean} Equals.
|
||||
|
||||
Reference in New Issue
Block a user