Only support square tiles

This commit is contained in:
Tom Payne
2014-01-15 09:45:49 +01:00
parent 50a322208a
commit d5c1e53e48
13 changed files with 89 additions and 93 deletions

View File

@@ -79,10 +79,11 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
//var copyright = response.copyright; // FIXME do we need to display this?
var resource = response.resourceSets[0].resources[0];
goog.asserts.assert(resource.imageWidth == resource.imageHeight);
var tileGrid = new ol.tilegrid.XYZ({
minZoom: resource.zoomMin,
maxZoom: resource.zoomMax,
tileSize: [resource.imageWidth, resource.imageHeight]
tileSize: resource.imageWidth
});
this.tileGrid = tileGrid;

View File

@@ -2,7 +2,6 @@ goog.provide('ol.source.TileDebug');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('ol.Size');
goog.require('ol.Tile');
goog.require('ol.TileCache');
goog.require('ol.TileCoord');
@@ -31,7 +30,7 @@ ol.DebugTile_ = function(tileCoord, tileGrid) {
/**
* @private
* @type {ol.Size}
* @type {number}
*/
this.tileSize_ = tileGrid.getTileSize(tileCoord.z);
@@ -58,21 +57,21 @@ ol.DebugTile_.prototype.getImage = function(opt_context) {
var canvas = /** @type {HTMLCanvasElement} */
(goog.dom.createElement(goog.dom.TagName.CANVAS));
canvas.width = tileSize[0];
canvas.height = tileSize[1];
canvas.width = tileSize;
canvas.height = tileSize;
var context = /** @type {CanvasRenderingContext2D} */
(canvas.getContext('2d'));
context.strokeStyle = 'black';
context.strokeRect(0.5, 0.5, tileSize[0] + 0.5, tileSize[1] + 0.5);
context.strokeRect(0.5, 0.5, tileSize + 0.5, tileSize + 0.5);
context.fillStyle = 'black';
context.textAlign = 'center';
context.textBaseline = 'middle';
context.font = '24px sans-serif';
context.fillText(
this.tileCoord_.toString(), tileSize[0] / 2, tileSize[1] / 2);
this.tileCoord_.toString(), tileSize / 2, tileSize / 2);
this.canvasByContext_[key] = canvas;
return canvas;

View File

@@ -167,11 +167,11 @@ ol.source.TileWMS.prototype.tileUrlFunction_ = function(tileCoord, projection) {
var tileSize = tileGrid.getTileSize(tileCoord.z);
var gutter = this.gutter_;
if (gutter === 0) {
goog.object.set(params, 'WIDTH', tileSize[0]);
goog.object.set(params, 'HEIGHT', tileSize[1]);
goog.object.set(params, 'WIDTH', tileSize);
goog.object.set(params, 'HEIGHT', tileSize);
} else {
goog.object.set(params, 'WIDTH', tileSize[0] + 2 * gutter);
goog.object.set(params, 'HEIGHT', tileSize[1] + 2 * gutter);
goog.object.set(params, 'WIDTH', tileSize + 2 * gutter);
goog.object.set(params, 'HEIGHT', tileSize + 2 * gutter);
tileExtent =
ol.extent.buffer(tileExtent, tileResolution * gutter, this.tmpExtent_);
}