|
|
|
|
@@ -138,7 +138,7 @@ ol.tilegrid.TileGrid.tmpTileCoord_ = [0, 0, 0];
|
|
|
|
|
* Call a function with each tile coordinate for a given extent and zoom level.
|
|
|
|
|
*
|
|
|
|
|
* @param {ol.Extent} extent Extent.
|
|
|
|
|
* @param {number} zoom Zoom level.
|
|
|
|
|
* @param {number} zoom Integer zoom level.
|
|
|
|
|
* @param {function(ol.TileCoord)} callback Function called with each tile coordinate.
|
|
|
|
|
* @api
|
|
|
|
|
*/
|
|
|
|
|
@@ -206,7 +206,7 @@ ol.tilegrid.TileGrid.prototype.getMinZoom = function() {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the origin for the grid at the given zoom level.
|
|
|
|
|
* @param {number} z Z.
|
|
|
|
|
* @param {number} z Integer zoom level.
|
|
|
|
|
* @return {ol.Coordinate} Origin.
|
|
|
|
|
* @api
|
|
|
|
|
*/
|
|
|
|
|
@@ -221,7 +221,7 @@ ol.tilegrid.TileGrid.prototype.getOrigin = function(z) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the resolution for the given zoom level.
|
|
|
|
|
* @param {number} z Z.
|
|
|
|
|
* @param {number} z Integer zoom level.
|
|
|
|
|
* @return {number} Resolution.
|
|
|
|
|
* @api
|
|
|
|
|
*/
|
|
|
|
|
@@ -258,7 +258,8 @@ ol.tilegrid.TileGrid.prototype.getTileCoordChildTileRange = function(tileCoord,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {number} z Z.
|
|
|
|
|
* Get the extent for a tile range.
|
|
|
|
|
* @param {number} z Integer zoom level.
|
|
|
|
|
* @param {ol.TileRange} tileRange Tile range.
|
|
|
|
|
* @param {ol.Extent=} opt_extent Temporary ol.Extent object.
|
|
|
|
|
* @return {ol.Extent} Extent.
|
|
|
|
|
@@ -276,34 +277,20 @@ ol.tilegrid.TileGrid.prototype.getTileRangeExtent = function(z, tileRange, opt_e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a tile range for the given extent and integer zoom level.
|
|
|
|
|
* @param {ol.Extent} extent Extent.
|
|
|
|
|
* @param {number} resolution Resolution.
|
|
|
|
|
* @param {ol.TileRange=} opt_tileRange Temporary tile range object.
|
|
|
|
|
* @return {ol.TileRange} Tile range.
|
|
|
|
|
*/
|
|
|
|
|
ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndResolution = function(extent, resolution, opt_tileRange) {
|
|
|
|
|
var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_;
|
|
|
|
|
this.getTileCoordForXYAndResolution_(
|
|
|
|
|
extent[0], extent[1], resolution, false, tileCoord);
|
|
|
|
|
var minX = tileCoord[1];
|
|
|
|
|
var minY = tileCoord[2];
|
|
|
|
|
this.getTileCoordForXYAndResolution_(
|
|
|
|
|
extent[2], extent[3], resolution, true, tileCoord);
|
|
|
|
|
return ol.TileRange.createOrUpdate(
|
|
|
|
|
minX, tileCoord[1], minY, tileCoord[2], opt_tileRange);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {ol.Extent} extent Extent.
|
|
|
|
|
* @param {number} z Z.
|
|
|
|
|
* @param {number} z Integer zoom level.
|
|
|
|
|
* @param {ol.TileRange=} opt_tileRange Temporary tile range object.
|
|
|
|
|
* @return {ol.TileRange} Tile range.
|
|
|
|
|
*/
|
|
|
|
|
ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndZ = function(extent, z, opt_tileRange) {
|
|
|
|
|
var resolution = this.getResolution(z);
|
|
|
|
|
return this.getTileRangeForExtentAndResolution(
|
|
|
|
|
extent, resolution, opt_tileRange);
|
|
|
|
|
var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_;
|
|
|
|
|
this.getTileCoordForXYAndZ_(extent[0], extent[1], z, false, tileCoord);
|
|
|
|
|
var minX = tileCoord[1];
|
|
|
|
|
var minY = tileCoord[2];
|
|
|
|
|
this.getTileCoordForXYAndZ_(extent[2], extent[3], z, true, tileCoord);
|
|
|
|
|
return ol.TileRange.createOrUpdate(
|
|
|
|
|
minX, tileCoord[1], minY, tileCoord[2], opt_tileRange);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -360,9 +347,11 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution = function(coor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Note that this method should not be called for resolutions that correspond
|
|
|
|
|
* to an integer zoom level. Instead call the `getTileCoordForXYAndZ_` method.
|
|
|
|
|
* @param {number} x X.
|
|
|
|
|
* @param {number} y Y.
|
|
|
|
|
* @param {number} resolution Resolution.
|
|
|
|
|
* @param {number} resolution Resolution (for a non-integer zoom level).
|
|
|
|
|
* @param {boolean} reverseIntersectionPolicy Instead of letting edge
|
|
|
|
|
* intersections go to the higher tile coordinate, let edge intersections
|
|
|
|
|
* go to the lower tile coordinate.
|
|
|
|
|
@@ -396,6 +385,45 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
|
|
|
|
|
* they should have separate implementations. This method is for integer zoom
|
|
|
|
|
* levels. The other method should only be called for resolutions corresponding
|
|
|
|
|
* to non-integer zoom levels.
|
|
|
|
|
* @param {number} x Map x coordinate.
|
|
|
|
|
* @param {number} y Map y coordinate.
|
|
|
|
|
* @param {number} z Integer zoom level.
|
|
|
|
|
* @param {boolean} reverseIntersectionPolicy Instead of letting edge
|
|
|
|
|
* intersections go to the higher tile coordinate, let edge intersections
|
|
|
|
|
* go to the lower tile coordinate.
|
|
|
|
|
* @param {ol.TileCoord=} opt_tileCoord Temporary ol.TileCoord object.
|
|
|
|
|
* @return {ol.TileCoord} Tile coordinate.
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndZ_ = function(x, y, z, reverseIntersectionPolicy, opt_tileCoord) {
|
|
|
|
|
var origin = this.getOrigin(z);
|
|
|
|
|
var resolution = this.getResolution(z);
|
|
|
|
|
var tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_);
|
|
|
|
|
|
|
|
|
|
var adjustX = reverseIntersectionPolicy ? 0.5 : 0;
|
|
|
|
|
var adjustY = reverseIntersectionPolicy ? 0 : 0.5;
|
|
|
|
|
var xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX);
|
|
|
|
|
var yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY);
|
|
|
|
|
var tileCoordX = xFromOrigin / tileSize[0];
|
|
|
|
|
var tileCoordY = yFromOrigin / tileSize[1];
|
|
|
|
|
|
|
|
|
|
if (reverseIntersectionPolicy) {
|
|
|
|
|
tileCoordX = Math.ceil(tileCoordX) - 1;
|
|
|
|
|
tileCoordY = Math.ceil(tileCoordY) - 1;
|
|
|
|
|
} else {
|
|
|
|
|
tileCoordX = Math.floor(tileCoordX);
|
|
|
|
|
tileCoordY = Math.floor(tileCoordY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ol.tilecoord.createOrUpdate(z, tileCoordX, tileCoordY, opt_tileCoord);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a tile coordinate given a map coordinate and zoom level.
|
|
|
|
|
* @param {ol.Coordinate} coordinate Coordinate.
|
|
|
|
|
@@ -405,9 +433,8 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
|
|
|
|
|
* @api
|
|
|
|
|
*/
|
|
|
|
|
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ = function(coordinate, z, opt_tileCoord) {
|
|
|
|
|
var resolution = this.getResolution(z);
|
|
|
|
|
return this.getTileCoordForXYAndResolution_(
|
|
|
|
|
coordinate[0], coordinate[1], resolution, false, opt_tileCoord);
|
|
|
|
|
return this.getTileCoordForXYAndZ_(
|
|
|
|
|
coordinate[0], coordinate[1], z, false, opt_tileCoord);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|