Port ol.tilegrid to new extents
This commit is contained in:
@@ -5,13 +5,13 @@ goog.provide('ol.tilegrid.TileGrid');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.PixelBounds');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
|
||||
|
||||
/**
|
||||
@@ -205,10 +205,10 @@ ol.tilegrid.TileGrid.prototype.getTileRangeExtent =
|
||||
var resolution = this.getResolution(z);
|
||||
var tileSize = this.getTileSize(z);
|
||||
var minX = origin[0] + tileRange.minX * tileSize.width * resolution;
|
||||
var minY = origin[1] + tileRange.minY * tileSize.height * resolution;
|
||||
var maxX = origin[0] + (tileRange.maxX + 1) * tileSize.width * resolution;
|
||||
var minY = origin[1] + tileRange.minY * tileSize.height * resolution;
|
||||
var maxY = origin[1] + (tileRange.maxY + 1) * tileSize.height * resolution;
|
||||
return new ol.Extent(minX, minY, maxX, maxY);
|
||||
return ol.extent.createOrUpdate(minX, maxX, minY, maxY, opt_extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -222,11 +222,11 @@ ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndResolution =
|
||||
function(extent, resolution, opt_tileRange) {
|
||||
var tileCoord = ol.tilegrid.TileGrid.tmpTileCoord_;
|
||||
this.getTileCoordForXYAndResolution_(
|
||||
extent.minX, extent.minY, resolution, false, tileCoord);
|
||||
extent[0], extent[2], resolution, false, tileCoord);
|
||||
var minX = tileCoord.x;
|
||||
var minY = tileCoord.y;
|
||||
this.getTileCoordForXYAndResolution_(
|
||||
extent.maxX, extent.maxY, resolution, true, tileCoord);
|
||||
extent[1], extent[3], resolution, true, tileCoord);
|
||||
return ol.TileRange.createOrUpdate(
|
||||
minX, tileCoord.x, minY, tileCoord.y, opt_tileRange);
|
||||
};
|
||||
@@ -272,10 +272,10 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent =
|
||||
var resolution = this.getResolution(tileCoord.z);
|
||||
var tileSize = this.getTileSize(tileCoord.z);
|
||||
var minX = origin[0] + tileCoord.x * tileSize.width * resolution;
|
||||
var minY = origin[1] + tileCoord.y * tileSize.height * resolution;
|
||||
var maxX = minX + tileSize.width * resolution;
|
||||
var minY = origin[1] + tileCoord.y * tileSize.height * resolution;
|
||||
var maxY = minY + tileSize.height * resolution;
|
||||
return ol.Extent.createOrUpdate(minX, minY, maxX, maxY, opt_extent);
|
||||
return ol.extent.createOrUpdate(minX, maxX, minY, maxY, opt_extent);
|
||||
};
|
||||
|
||||
|
||||
@@ -401,8 +401,8 @@ ol.tilegrid.createForProjection =
|
||||
function(projection, opt_maxZoom, opt_tileSize) {
|
||||
var projectionExtent = projection.getExtent();
|
||||
var size = Math.max(
|
||||
projectionExtent.maxX - projectionExtent.minX,
|
||||
projectionExtent.maxY - projectionExtent.minY);
|
||||
projectionExtent[1] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[2]);
|
||||
var maxZoom = goog.isDef(opt_maxZoom) ?
|
||||
opt_maxZoom : ol.DEFAULT_MAX_ZOOM;
|
||||
var tileSize = goog.isDef(opt_tileSize) ?
|
||||
@@ -414,7 +414,7 @@ ol.tilegrid.createForProjection =
|
||||
resolutions[z] = size / Math.pow(2, z);
|
||||
}
|
||||
return new ol.tilegrid.TileGrid({
|
||||
origin: projectionExtent.getBottomLeft(),
|
||||
origin: ol.extent.getBottomLeft(projectionExtent),
|
||||
resolutions: resolutions,
|
||||
tileSize: tileSize
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
resolutions = [1000, 500, 250, 100];
|
||||
extent = new ol.Extent(0, 0, 100000, 100000);
|
||||
extent = [0, 100000, 0, 100000];
|
||||
origin = [0, 0];
|
||||
origins = [];
|
||||
tileSize = new ol.Size(100, 100);
|
||||
@@ -452,22 +452,22 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
var tileCoordExtent;
|
||||
|
||||
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(0, 0, 0));
|
||||
expect(tileCoordExtent.minX).to.eql(0);
|
||||
expect(tileCoordExtent.minY).to.eql(0);
|
||||
expect(tileCoordExtent.maxX).to.eql(100000);
|
||||
expect(tileCoordExtent.maxY).to.eql(100000);
|
||||
expect(tileCoordExtent[0]).to.eql(0);
|
||||
expect(tileCoordExtent[1]).to.eql(100000);
|
||||
expect(tileCoordExtent[2]).to.eql(0);
|
||||
expect(tileCoordExtent[3]).to.eql(100000);
|
||||
|
||||
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 9, 0));
|
||||
expect(tileCoordExtent.minX).to.eql(90000);
|
||||
expect(tileCoordExtent.minY).to.eql(0);
|
||||
expect(tileCoordExtent.maxX).to.eql(100000);
|
||||
expect(tileCoordExtent.maxY).to.eql(10000);
|
||||
expect(tileCoordExtent[0]).to.eql(90000);
|
||||
expect(tileCoordExtent[1]).to.eql(100000);
|
||||
expect(tileCoordExtent[2]).to.eql(0);
|
||||
expect(tileCoordExtent[3]).to.eql(10000);
|
||||
|
||||
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 0, 9));
|
||||
expect(tileCoordExtent.minX).to.eql(0);
|
||||
expect(tileCoordExtent.minY).to.eql(90000);
|
||||
expect(tileCoordExtent.maxX).to.eql(10000);
|
||||
expect(tileCoordExtent.maxY).to.eql(100000);
|
||||
expect(tileCoordExtent[0]).to.eql(0);
|
||||
expect(tileCoordExtent[1]).to.eql(10000);
|
||||
expect(tileCoordExtent[2]).to.eql(90000);
|
||||
expect(tileCoordExtent[3]).to.eql(100000);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -519,7 +519,7 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
origin: origin,
|
||||
tileSize: tileSize
|
||||
});
|
||||
var e = new ol.Extent(45000, 5000, 55000, 15000);
|
||||
var e = [45000, 55000, 5000, 15000];
|
||||
var tileRange;
|
||||
|
||||
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0);
|
||||
@@ -633,7 +633,6 @@ describe('ol.tilegrid.TileGrid', function() {
|
||||
});
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.projection');
|
||||
|
||||
Reference in New Issue
Block a user