From e6f5c2a00847056fb4b2c2a6ee13f996f6c63836 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Thu, 18 Jun 2015 09:49:03 +0200 Subject: [PATCH] Cleanup and example updates --- examples/canvas-tiles.html | 6 +++++- examples/xyz-esri-4326-512.js | 2 +- src/ol/tilegrid/wmtstilegrid.js | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/canvas-tiles.html b/examples/canvas-tiles.html index beddc26767..2b2c2f3ff1 100644 --- a/examples/canvas-tiles.html +++ b/examples/canvas-tiles.html @@ -3,7 +3,11 @@ template: example.html title: Canvas tiles example shortdesc: Renders tiles with coordinates for debugging. docs: > - The black grid tiles are generated on the client with an HTML5 canvas. In this example, the `ol.source.TileDebug` source uses the tile grid of the `ol.source.OSM` source, so the displayed tile coordinates are the same as those for OSM tile requests. + The black grid tiles are generated on the client with an HTML5 canvas. The + displayed tile coordinates are OpenLayers tile coordinates. These increase + from bottom to top, but standard XYZ tiling scheme coordinates increase from + top to bottom. To calculate the `y` for a standard XYZ tile coordinate, use + `-y - 1`. tags: "layers, openstreetmap, canvas" ---
diff --git a/examples/xyz-esri-4326-512.js b/examples/xyz-esri-4326-512.js index ac6d8f850b..7c76e54f5f 100644 --- a/examples/xyz-esri-4326-512.js +++ b/examples/xyz-esri-4326-512.js @@ -29,7 +29,7 @@ var map = new ol.Map({ tileUrlFunction: function(tileCoord) { return urlTemplate.replace('{z}', (tileCoord[0] - 1).toString()) .replace('{x}', tileCoord[1].toString()) - .replace('{y}', tileCoord[2].toString()); + .replace('{y}', (-tileCoord[2] - 1).toString()); }, wrapX: true }) diff --git a/src/ol/tilegrid/wmtstilegrid.js b/src/ol/tilegrid/wmtstilegrid.js index 74838aa2e9..793d0274d7 100644 --- a/src/ol/tilegrid/wmtstilegrid.js +++ b/src/ol/tilegrid/wmtstilegrid.js @@ -115,7 +115,6 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = metersPerUnit; var tileWidth = elt[tileWidthPropName]; var tileHeight = elt[tileHeightPropName]; - var matrixHeight = elt['MatrixHeight']; if (switchOriginXY) { origins.push([elt[topLeftCornerPropName][1], elt[topLeftCornerPropName][0]]); @@ -126,7 +125,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet = tileSizes.push(tileWidth == tileHeight ? tileWidth : [tileWidth, tileHeight]); // top-left origin, so height is negative - sizes.push([elt['MatrixWidth'], -matrixHeight]); + sizes.push([elt['MatrixWidth'], -elt['MatrixHeight']]); }); return new ol.tilegrid.WMTS({