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