diff --git a/tileserver.php b/tileserver.php
index 54103aa..323d540 100644
--- a/tileserver.php
+++ b/tileserver.php
@@ -718,6 +718,59 @@ class Wmts extends Server {
$this->getCapabilities();
}
}
+
+ /**
+ * Default TileMetrixSet for Pseudo Mercator projection 3857
+ * @return string TileMatrixSet xml
+ */
+ public function getMercatorTileMatrixSet(){
+ $name = 'GoogleMapsCompatible';
+ $corner = array(-20037508.34278925, 20037508.34278925);
+ $scalesBase = 559082264.0287178;
+ $scales = array();
+
+ for($i = 0; $i <= 18; $i++){
+ $scales[] = $scalesBase / pow(2, $i);
+ }
+
+ return $this->getTileMatrixSet($name, $scales, $corner);
+ }
+
+ /**
+ * Prints WMTS tilematrixset
+ * @param string $name
+ * @param array $scales Array of scales
+ * @param array $corner Position of TopLeft corner of matrix
+ * @param string $crs Code of crs eg: EPSG:3857
+ * @param array $matrixRatio Ratio of matrix sides
+ * @param array $tilesize Size of tile in pixels
+ * @return string TileMatrixSet xml
+ */
+ public function getTileMatrixSet($name, $scales, $corner, $crs = 'EPSG:3857', $matrixRatio = array(1, 1), $tilesize = array(256, 256)){
+ $srs = explode(':', $crs);
+ $TileMatrixSet = '
+ ' . $name . '
+ ' . $name . ' '. $crs .'
+ ' . $name . '
+ urn:ogc:def:crs:'.$srs[0].'::'.$srs[1].'';
+ // $TileMatrixSet .= 'urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible';
+ for($i = 0; $i <= sizeof($scales); $i++){
+ $matrixWidth = pow(2, $i);
+ $TileMatrixSet .= '
+
+ ' . $i . '
+ ' . $scales[$i] . '
+ '. $corner[0] . ' ' . $corner[1] .'
+ ' . $tilesize[0] . '
+ ' . $tilesize[1] . '
+ ' . $matrixWidth * $matrixRatio[0] . '
+ ' . $matrixWidth * $matrixRatio[1] . '
+ ';
+ }
+ $TileMatrixSet .= '';
+
+ return $TileMatrixSet;
+ }
/**
* Returns tilesets getCapabilities
@@ -821,358 +874,26 @@ class Wmts extends Server {
';
}
- echo '
-
- GoogleMapsCompatible
- the wellknown \'GoogleMapsCompatible\' tile matrix set defined by OGC WMTS specification
- GoogleMapsCompatible
- urn:ogc:def:crs:EPSG:6.18:3:3857
- urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible
-
- 0
- 559082264.0287178
- -20037508.34278925 20037508.34278925
- 256
- 256
- 1
- 1
-
-
- 1
- 279541132.0143589
- -20037508.34278925 20037508.34278925
- 256
- 256
- 2
- 2
-
-
- 2
- 139770566.0071794
- -20037508.34278925 20037508.34278925
- 256
- 256
- 4
- 4
-
-
- 3
- 69885283.00358972
- -20037508.34278925 20037508.34278925
- 256
- 256
- 8
- 8
-
-
- 4
- 34942641.50179486
- -20037508.34278925 20037508.34278925
- 256
- 256
- 16
- 16
-
-
- 5
- 17471320.75089743
- -20037508.34278925 20037508.34278925
- 256
- 256
- 32
- 32
-
-
- 6
- 8735660.375448715
- -20037508.34278925 20037508.34278925
- 256
- 256
- 64
- 64
-
-
- 7
- 4367830.187724357
- -20037508.34278925 20037508.34278925
- 256
- 256
- 128
- 128
-
-
- 8
- 2183915.093862179
- -20037508.34278925 20037508.34278925
- 256
- 256
- 256
- 256
-
-
- 9
- 1091957.546931089
- -20037508.34278925 20037508.34278925
- 256
- 256
- 512
- 512
-
-
- 10
- 545978.7734655447
- -20037508.34278925 20037508.34278925
- 256
- 256
- 1024
- 1024
-
-
- 11
- 272989.3867327723
- -20037508.34278925 20037508.34278925
- 256
- 256
- 2048
- 2048
-
-
- 12
- 136494.6933663862
- -20037508.34278925 20037508.34278925
- 256
- 256
- 4096
- 4096
-
-
- 13
- 68247.34668319309
- -20037508.34278925 20037508.34278925
- 256
- 256
- 8192
- 8192
-
-
- 14
- 34123.67334159654
- -20037508.34278925 20037508.34278925
- 256
- 256
- 16384
- 16384
-
-
- 15
- 17061.83667079827
- -20037508.34278925 20037508.34278925
- 256
- 256
- 32768
- 32768
-
-
- 16
- 8530.918335399136
- -20037508.34278925 20037508.34278925
- 256
- 256
- 65536
- 65536
-
-
- 17
- 4265.459167699568
- -20037508.34278925 20037508.34278925
- 256
- 256
- 131072
- 131072
-
-
- 18
- 2132.729583849784
- -20037508.34278925 20037508.34278925
- 256
- 256
- 262144
- 262144
-
-
-
- WGS84
- GoogleCRS84Quad
- urn:ogc:def:crs:EPSG:6.3:4326
-
- -180.000000 -90.000000
- 180.000000 90.000000
-
- urn:ogc:def:wkss:OGC:1.0:GoogleCRS84Quad
-
- 0
- 279541132.01435887813568115234
- 90.000000 -180.000000
- 256
- 256
- 2
- 1
-
-
- 1
- 139770566.00717943906784057617
- 90.000000 -180.000000
- 256
- 256
- 4
- 2
-
-
- 2
- 69885283.00358971953392028809
- 90.000000 -180.000000
- 256
- 256
- 8
- 4
-
-
- 3
- 34942641.50179485976696014404
- 90.000000 -180.000000
- 256
- 256
- 16
- 8
-
-
- 4
- 17471320.75089742988348007202
- 90.000000 -180.000000
- 256
- 256
- 32
- 16
-
-
- 5
- 8735660.37544871494174003601
- 90.000000 -180.000000
- 256
- 256
- 64
- 32
-
-
- 6
- 4367830.18772435747087001801
- 90.000000 -180.000000
- 256
- 256
- 128
- 64
-
-
- 7
- 2183915.09386217873543500900
- 90.000000 -180.000000
- 256
- 256
- 256
- 128
-
-
- 8
- 1091957.54693108936771750450
- 90.000000 -180.000000
- 256
- 256
- 512
- 256
-
-
- 9
- 545978.77346554468385875225
- 90.000000 -180.000000
- 256
- 256
- 1024
- 512
-
-
- 10
- 272989.38673277234192937613
- 90.000000 -180.000000
- 256
- 256
- 2048
- 1024
-
-
- 11
- 136494.69336638617096468806
- 90.000000 -180.000000
- 256
- 256
- 4096
- 2048
-
-
- 12
- 68247.34668319308548234403
- 90.000000 -180.000000
- 256
- 256
- 8192
- 4096
-
-
- 13
- 34123.67334159654274117202
- 90.000000 -180.000000
- 256
- 256
- 16384
- 8192
-
-
- 14
- 17061.83667079825318069197
- 90.000000 -180.000000
- 256
- 256
- 32768
- 16384
-
-
- 15
- 8530.91833539912659034599
- 90.000000 -180.000000
- 256
- 256
- 65536
- 32768
-
-
- 16
- 4265.45916769956329517299
- 90.000000 -180.000000
- 256
- 256
- 131072
- 65536
-
-
- 17
- 2132.72958384978574031265
- 90.000000 -180.000000
- 256
- 256
- 262144
- 131072
-
-
-
+
+ //Print mercator TileMatrixSet
+ echo $this->getMercatorTileMatrixSet();
+
+ //Print wgs84 TileMatrixSet
+ $name = 'WGS84';
+ $corner = array(-180.000000, 90.000000);
+ $scales = array(279541132.01435887813568115234, 139770566.00717943906784057617,
+ 69885283.00358971953392028809, 34942641.50179485976696014404, 17471320.75089742988348007202,
+ 8735660.37544871494174003601, 4367830.18772435747087001801, 2183915.09386217873543500900,
+ 1091957.54693108936771750450, 545978.77346554468385875225, 272989.38673277234192937613,
+ 136494.69336638617096468806, 68247.34668319308548234403, 34123.67334159654274117202,
+ 17061.83667079825318069197, 8530.91833539912659034599, 4265.45916769956329517299,
+ 2132.72958384978574031265);
+ $crs = 'EPSG::4326';
+ $matrixRatio = array(2, 1);
+
+ echo $this->getTileMatrixSet($name, $scales, $corner, $crs, $matrixRatio);
+
+ echo '
';
}