From 2dfd2fcb5fe333c9e430a38a10892edde4418619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Jan=C3=A1k?= Date: Mon, 21 Mar 2016 10:59:29 +0100 Subject: [PATCH] Max zoom of Mercator TileMatrixSet is affected with max of layers maxzoom (closes #76) --- tileserver.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tileserver.php b/tileserver.php index 883e05d..882cfd6 100644 --- a/tileserver.php +++ b/tileserver.php @@ -830,14 +830,15 @@ class Wmts extends Server { /** * Default TileMetrixSet for Pseudo Mercator projection 3857 + * @param ?number $maxZoom * @return string TileMatrixSet xml */ - public function getMercatorTileMatrixSet(){ + public function getMercatorTileMatrixSet($maxZoom = 18){ $denominatorBase = 559082264.0287178; $extent = array(-20037508.34,-20037508.34,20037508.34,20037508.34); $tileMatrixSet = array(); - for($i = 0; $i <= 18; $i++){ + for($i = 0; $i <= $maxZoom; $i++){ $matrixSize = pow(2, $i); $tileMatrixSet[] = array( 'extent' => $extent, @@ -1010,6 +1011,7 @@ class Wmts extends Server { ); } else { $tileMatrixSet = 'GoogleMapsCompatible'; + $maxMercatorZoom = max(18, $maxMercatorZoom, $m['maxzoom']); } $wmtsHost = substr($m['tiles'][0], 0, strpos($m['tiles'][0], $m['basename'])); @@ -1044,7 +1046,7 @@ class Wmts extends Server { } // Print PseudoMercator TileMatrixSet - echo $this->getMercatorTileMatrixSet(); + echo $this->getMercatorTileMatrixSet($maxMercatorZoom); // Print WGS84 TileMatrixSet echo $this->getWGS84TileMatrixSet();