Port ol.source.TileSource to new extents
This commit is contained in:
@@ -5,11 +5,11 @@ goog.provide('ol.source.XYZOptions');
|
|||||||
|
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.Extent');
|
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
goog.require('ol.TileUrlFunction');
|
goog.require('ol.TileUrlFunction');
|
||||||
goog.require('ol.TileUrlFunctionType');
|
goog.require('ol.TileUrlFunctionType');
|
||||||
|
goog.require('ol.extent');
|
||||||
goog.require('ol.projection');
|
goog.require('ol.projection');
|
||||||
goog.require('ol.source.ImageTileSource');
|
goog.require('ol.source.ImageTileSource');
|
||||||
goog.require('ol.tilegrid.XYZ');
|
goog.require('ol.tilegrid.XYZ');
|
||||||
@@ -58,10 +58,10 @@ ol.source.XYZ = function(options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// FIXME factor out common code
|
// FIXME factor out common code
|
||||||
var extent = options.extent;
|
if (goog.isDef(options.extent)) {
|
||||||
if (goog.isDefAndNotNull(extent)) {
|
|
||||||
|
|
||||||
var tmpExtent = new ol.Extent(0, 0, 0, 0);
|
var extent = options.extent;
|
||||||
|
var tmpExtent = ol.extent.createEmptyExtent();
|
||||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||||
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||||
function(tileCoord) {
|
function(tileCoord) {
|
||||||
@@ -78,8 +78,7 @@ ol.source.XYZ = function(options) {
|
|||||||
tmpTileCoord.x = x;
|
tmpTileCoord.x = x;
|
||||||
tmpTileCoord.y = tileCoord.y;
|
tmpTileCoord.y = tileCoord.y;
|
||||||
var tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
|
var tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
|
||||||
// FIXME we shouldn't need a typecast here
|
if (!ol.extent.intersects(tileExtent, extent)) {
|
||||||
if (!tileExtent.intersects(/** @type {ol.Extent} */ (extent))) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new ol.TileCoord(tileCoord.z, x, y);
|
return new ol.TileCoord(tileCoord.z, x, y);
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ describe('ol.source.TileSource', function() {
|
|||||||
* @param {Object.<string, boolean>} loaded Lookup of already loaded tiles.
|
* @param {Object.<string, boolean>} loaded Lookup of already loaded tiles.
|
||||||
*/
|
*/
|
||||||
ol.test.source.MockTileSource = function(loaded) {
|
ol.test.source.MockTileSource = function(loaded) {
|
||||||
var extent = new ol.Extent(-180, -180, 180, 180);
|
var extent = [-180, 180, -180, 180];
|
||||||
var tileGrid = new ol.tilegrid.TileGrid({
|
var tileGrid = new ol.tilegrid.TileGrid({
|
||||||
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
|
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
|
||||||
extent: extent,
|
extent: extent,
|
||||||
@@ -265,7 +265,6 @@ describe('ol.test.source.MockTileSource', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('ol.Extent');
|
|
||||||
goog.require('ol.Size');
|
goog.require('ol.Size');
|
||||||
goog.require('ol.Tile');
|
goog.require('ol.Tile');
|
||||||
goog.require('ol.TileCoord');
|
goog.require('ol.TileCoord');
|
||||||
|
|||||||
Reference in New Issue
Block a user