mirror of
https://github.com/klokantech/tileserver-php.git
synced 2025-08-21 21:56:18 +02:00
Compare commits
33 Commits
vectortile
...
customtile
Author | SHA1 | Date | |
---|---|---|---|
|
e36a7e6a06 | ||
|
7190e90845 | ||
|
f3f2a995e5 | ||
|
8233047097 | ||
|
46d79107e8 | ||
|
a2162eeb99 | ||
|
27fc9a73ca | ||
|
4ff5d95a38 | ||
|
6da6b13fed | ||
|
0609b25905 | ||
|
ce485c6713 | ||
|
ab7862209a | ||
|
8b49aa2b8c | ||
|
ea100ad8c2 | ||
|
86527eeedb | ||
|
3a9e74e3b0 | ||
|
0446445248 | ||
|
853ca41ce0 | ||
|
5b5f5e7905 | ||
|
b7960baaaa | ||
|
250512168c | ||
|
6b5933e21f | ||
|
f5408fd108 | ||
|
dc26c831f1 | ||
|
28aba6f9e2 | ||
|
8f6a2ced68 | ||
|
79926b92fc | ||
|
3343f80e09 | ||
|
c660ab8f41 | ||
|
21d7a409fe | ||
|
abb4087942 | ||
|
0acdc04e32 | ||
|
b783c59585 |
9
.travis.yml
Normal file
9
.travis.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
script:
|
||||
- php tileserver.php
|
@@ -1,6 +1,9 @@
|
||||
TileServer PHP: MapTiler and MBTiles maps via WMTS
|
||||
==================================================
|
||||
|
||||
[](https://travis-ci.org/klokantech/tileserver-php)
|
||||
[](https://hub.docker.com/r/klokantech/tileserver-php/)
|
||||
|
||||
This server distributes maps to desktop, web, and mobile applications from
|
||||
a standard Apache+PHP web hosting.
|
||||
|
||||
@@ -38,9 +41,9 @@ Requirements:
|
||||
-------------
|
||||
|
||||
- Apache webserver (with mod_rewrite / .htaccess supported)
|
||||
- PHP 5.2+
|
||||
- PHP 5.2+ with SQLite module (php5-sqlite)
|
||||
|
||||
(or anther webserver implementing mod_rewrite rules and PHP)
|
||||
(or another webserver implementing mod_rewrite rules and PHP)
|
||||
|
||||
Installation:
|
||||
-------------
|
||||
|
754
tileserver.php
754
tileserver.php
@@ -4,26 +4,26 @@
|
||||
* TileServer.php project
|
||||
* ======================
|
||||
* https://github.com/klokantech/tileserver-php/
|
||||
* Copyright (C) 2014 - Klokan Technologies GmbH
|
||||
* Copyright (C) 2016 - Klokan Technologies GmbH
|
||||
*/
|
||||
|
||||
global $config;
|
||||
$config['serverTitle'] = 'TileServer-php v1';
|
||||
//$config['baseUrls'] = ['t0.server.com', 't1.server.com'];
|
||||
//$config['baseUrls'] = array('t0.server.com', 't1.server.com');
|
||||
|
||||
Router::serve(array(
|
||||
'/' => 'Server:getHtml',
|
||||
'/test' => 'Server:getInfo',
|
||||
'/html' => 'Server:getHtml',
|
||||
'/:alpha/:number/:number/:number.grid.json' => 'Json:getUTFGrid',
|
||||
'/:alpha.json' => 'Json:getJson',
|
||||
'/:alpha.jsonp' => 'Json:getJsonp',
|
||||
'/:alpha/:number/:number/:number.:alpha.json' => 'Json:getUTFGrid',
|
||||
'/wmts' => 'Wmts:get',
|
||||
'/wmts/1.0.0/WMTSCapabilities.xml' => 'Wmts:get',
|
||||
'/wmts/:alpha/:number/:number/:number.:alpha' => 'Wmts:getTile',
|
||||
'/wmts/:alpha/:alpha/:number/:number/:number.:alpha' => 'Wmts:getTile',
|
||||
'/wmts/:alpha/:alpha/:alpha/:number/:number/:number.:alpha' => 'Wmts:getTile',
|
||||
'/:alpha/:number/:number/:number.:alpha' => 'Wmts:getTile',
|
||||
'/wmts/:alpha/:number/:number/:alpha' => 'Wmts:getTile',
|
||||
'/wmts/:alpha/:alpha/:number/:number/:alpha' => 'Wmts:getTile',
|
||||
'/wmts/:alpha/:alpha/:alpha/:number/:number/:alpha' => 'Wmts:getTile',
|
||||
'/:alpha/:number/:number/:alpha' => 'Wmts:getTile',
|
||||
'/tms' => 'Tms:getCapabilities',
|
||||
'/tms/:alpha' => 'Tms:getLayerCapabilities',
|
||||
));
|
||||
@@ -92,13 +92,12 @@ class Server {
|
||||
$this->layer = $params[1];
|
||||
}
|
||||
$params = array_reverse($params);
|
||||
if (isset($params[3])) {
|
||||
$this->z = $params[3];
|
||||
$this->x = $params[2];
|
||||
$this->y = $params[1];
|
||||
}
|
||||
if (isset($params[0])) {
|
||||
$this->ext = $params[0];
|
||||
if (isset($params[2])) {
|
||||
$this->z = $params[2];
|
||||
$this->x = $params[1];
|
||||
$file = explode('.', $params[0]);
|
||||
$this->y = $file[0];
|
||||
$this->ext = isset($file[1]) ? $file[1] : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +143,7 @@ class Server {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get metadata from metadataJson
|
||||
* @param string $jsonFileName
|
||||
* @return array
|
||||
*/
|
||||
@@ -176,11 +175,13 @@ class Server {
|
||||
// autodetect minzoom and maxzoom
|
||||
$result = $this->db->query('select min(zoom_level) as min, max(zoom_level) as max from tiles');
|
||||
$resultdata = $result->fetchAll();
|
||||
if (!array_key_exists('minzoom', $metadata))
|
||||
if (!array_key_exists('minzoom', $metadata)){
|
||||
$metadata['minzoom'] = $resultdata[0]['min'];
|
||||
if (!array_key_exists('maxzoom', $metadata))
|
||||
}
|
||||
if (!array_key_exists('maxzoom', $metadata)){
|
||||
$metadata['maxzoom'] = $resultdata[0]['max'];
|
||||
}
|
||||
}
|
||||
// autodetect format using JPEG magic number FFD8
|
||||
if (!array_key_exists('format', $metadata)) {
|
||||
$result = $this->db->query('select hex(substr(tile_data,1,2)) as magic from tiles limit 1');
|
||||
@@ -222,26 +223,33 @@ class Server {
|
||||
* @return object
|
||||
*/
|
||||
public function metadataValidation($metadata) {
|
||||
if (array_key_exists('bounds', $metadata)) {
|
||||
if (!array_key_exists('bounds', $metadata)) {
|
||||
$metadata['bounds'] = array(-180, -85.06, 180, 85.06);
|
||||
} elseif (!is_array($metadata['bounds'])) {
|
||||
$metadata['bounds'] = array_map('floatval', explode(',', $metadata['bounds']));
|
||||
} else {
|
||||
$metadata['bounds'] = array(-180, -85.051128779807, 180, 85.051128779807);
|
||||
}
|
||||
if (!array_key_exists('profile', $metadata)) {
|
||||
$metadata['profile'] = 'mercator';
|
||||
}
|
||||
// TODO: detect thumb / SQL for mbtiles
|
||||
if (array_key_exists('minzoom', $metadata))
|
||||
if (array_key_exists('minzoom', $metadata)){
|
||||
$metadata['minzoom'] = intval($metadata['minzoom']);
|
||||
else
|
||||
}else{
|
||||
$metadata['minzoom'] = 0;
|
||||
if (array_key_exists('maxzoom', $metadata))
|
||||
}
|
||||
if (array_key_exists('maxzoom', $metadata)){
|
||||
$metadata['maxzoom'] = intval($metadata['maxzoom']);
|
||||
else
|
||||
}else{
|
||||
$metadata['maxzoom'] = 18;
|
||||
}
|
||||
if (!array_key_exists('format', $metadata)) {
|
||||
$metadata['format'] = 'png';
|
||||
}
|
||||
if (!array_key_exists('scale', $metadata)) {
|
||||
$metadata['scale'] = 1;
|
||||
}
|
||||
|
||||
// TODO: detect thumb / SQL for mbtiles
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
@@ -273,8 +281,8 @@ class Server {
|
||||
$filename = $filename . '.mbtiles';
|
||||
$lastModifiedTime = filemtime($filename);
|
||||
$eTag = md5($lastModifiedTime);
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModifiedTime) . " GMT");
|
||||
header("Etag:" . $eTag);
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModifiedTime) . ' GMT');
|
||||
header('Etag:' . $eTag);
|
||||
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModifiedTime ||
|
||||
@trim($_SERVER['HTTP_IF_NONE_MATCH']) == $eTag) {
|
||||
return TRUE;
|
||||
@@ -309,11 +317,12 @@ class Server {
|
||||
$result = $this->db->query('select tile_data as t from tiles where zoom_level=' . $z . ' and tile_column=' . $x . ' and tile_row=' . $y);
|
||||
$data = $result->fetchColumn();
|
||||
if (!isset($data) || $data === FALSE) {
|
||||
//scale of tile (for retina tiles)
|
||||
//if tile doesn't exist
|
||||
//select scale of tile (for retina tiles)
|
||||
$result = $this->db->query('select value from metadata where name="scale"');
|
||||
$resultdata = $result->fetchColumn();
|
||||
$scale = isset($resultdata) && $resultdata !== FALSE ? $resultdata : 1;
|
||||
$this->getCleanTile($scale);
|
||||
$this->getCleanTile($scale, $ext);
|
||||
} else {
|
||||
$result = $this->db->query('select value from metadata where name="format"');
|
||||
$resultdata = $result->fetchColumn();
|
||||
@@ -331,10 +340,21 @@ class Server {
|
||||
echo $data;
|
||||
}
|
||||
} elseif ($this->isFileLayer($tileset)) {
|
||||
$name = './' . $tileset . '/' . $z . '/' . $x . '/' . $y . '.' . $ext;
|
||||
$name = './' . $tileset . '/' . $z . '/' . $x . '/' . $y;
|
||||
$mime = 'image/';
|
||||
if($ext != NULL){
|
||||
$name .= '.' . $ext;
|
||||
}
|
||||
if ($fp = @fopen($name, 'rb')) {
|
||||
if($ext != NULL){
|
||||
$mime .= $ext;
|
||||
}else{
|
||||
//detect image type from file
|
||||
$mimetypes = array('gif', 'jpeg', 'png');
|
||||
$mime .= $mimetypes[exif_imagetype($name) - 1];
|
||||
}
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Content-Type: image/' . $ext);
|
||||
header('Content-Type: ' . $mime);
|
||||
header('Content-Length: ' . filesize($name));
|
||||
fpassthru($fp);
|
||||
die;
|
||||
@@ -344,14 +364,8 @@ class Server {
|
||||
if(!isset($meta->scale)){
|
||||
$meta->scale = 1;
|
||||
}
|
||||
if ($ext == 'pbf') {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo '{"message":"Tile does not exist"}';
|
||||
die;
|
||||
}
|
||||
$this->getCleanTile($meta->scale);
|
||||
}
|
||||
$this->getCleanTile($meta->scale, $ext);
|
||||
} else {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
echo 'Server: Unknown or not specified dataset "' . $tileset . '"';
|
||||
@@ -363,7 +377,15 @@ class Server {
|
||||
* Returns clean tile
|
||||
* @param integer $scale Default 1
|
||||
*/
|
||||
public function getCleanTile($scale = 1) {
|
||||
public function getCleanTile($scale = 1, $format = 'png') {
|
||||
switch ($format) {
|
||||
case 'pbf':
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo '{"message":"Tile does not exist"}';
|
||||
die;
|
||||
case 'png':
|
||||
default:
|
||||
$tileSize = 256 * $scale;
|
||||
$png = imagecreatetruecolor($tileSize, $tileSize);
|
||||
imagesavealpha($png, true);
|
||||
@@ -374,6 +396,7 @@ class Server {
|
||||
imagepng($png);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tile's UTFGrid
|
||||
@@ -392,20 +415,22 @@ class Server {
|
||||
}
|
||||
try {
|
||||
$this->DBconnect($tileset . '.mbtiles');
|
||||
$result = $this->db->query('SELECT grid FROM grids WHERE tile_column = ' . $x . ' AND tile_row = ' . $y . ' AND zoom_level = ' . $z);
|
||||
if (!isset($result) || $result === FALSE) {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
echo '{}';
|
||||
die;
|
||||
} else {
|
||||
$data = $result->fetchColumn();
|
||||
|
||||
$grid = gzuncompress($data);
|
||||
$query = 'SELECT grid FROM grids WHERE tile_column = ' . $x . ' AND '
|
||||
. 'tile_row = ' . $y . ' AND zoom_level = ' . $z;
|
||||
$result = $this->db->query($query);
|
||||
$data = $result->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($data !== FALSE) {
|
||||
$grid = gzuncompress($data['grid']);
|
||||
$grid = substr(trim($grid), 0, -1);
|
||||
|
||||
//adds legend (data) to output
|
||||
$grid .= ',"data":{';
|
||||
$result = $this->db->query('SELECT key_name as key, key_json as json FROM grid_data WHERE zoom_level=' . $z . ' and tile_column=' . $x . ' and tile_row=' . $y);
|
||||
$kquery = 'SELECT key_name as key, key_json as json FROM grid_data '
|
||||
. 'WHERE zoom_level=' . $z . ' and '
|
||||
. 'tile_column=' . $x . ' and tile_row=' . $y;
|
||||
$result = $this->db->query($kquery);
|
||||
while ($r = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$grid .= '"' . $r['key'] . '":' . $r['json'] . ',';
|
||||
}
|
||||
@@ -413,14 +438,18 @@ class Server {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
if (isset($_GET['callback']) && !empty($_GET['callback'])) {
|
||||
header("Content-Type:text/javascript charset=utf-8");
|
||||
header('Content-Type:text/javascript charset=utf-8');
|
||||
echo $_GET['callback'] . '(' . $grid . ');';
|
||||
} else {
|
||||
header("Content-Type:text/javascript; charset=utf-8");
|
||||
header('Content-Type:text/javascript; charset=utf-8');
|
||||
echo $grid;
|
||||
}
|
||||
} else {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
echo '{}';
|
||||
die;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
} catch (Exception $e) {
|
||||
header('Content-type: text/plain');
|
||||
print 'Error querying the database: ' . $e->getMessage();
|
||||
}
|
||||
@@ -458,7 +487,7 @@ class Server {
|
||||
. $this->config['baseUrls'][0] . '/' . $map['basename'] . '.json</a><br>';
|
||||
echo 'Bounds: ' . $extend . '</p>';
|
||||
}
|
||||
echo '<p>Copyright (C) 2014 - Klokan Technologies GmbH</p>';
|
||||
echo '<p>Copyright (C) 2016 - Klokan Technologies GmbH</p>';
|
||||
echo '</body></html>';
|
||||
}
|
||||
|
||||
@@ -470,8 +499,8 @@ class Server {
|
||||
$maps = array_merge($this->fileLayer, $this->dbLayer);
|
||||
header('Content-Type: text/html;charset=UTF-8');
|
||||
echo '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>' . $this->config['serverTitle'] . '</title>';
|
||||
echo '<link rel="stylesheet" type="text/css" href="//tileserver.com/v1/index.css" />
|
||||
<script src="//tileserver.com/v1/index.js"></script><body>
|
||||
echo '<link rel="stylesheet" type="text/css" href="//cdn.klokantech.com/tileviewer/v1/index.css" />
|
||||
<script src="//cdn.klokantech.com/tileviewer/v1/index.js"></script><body>
|
||||
<script>tileserver({index:"' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/index.json", tilejson:"' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/%n.json", tms:"' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/tms", wmts:"' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/wmts"});</script>
|
||||
<h1>Welcome to ' . $this->config['serverTitle'] . '</h1>
|
||||
<p>This server distributes maps to desktop, web, and mobile applications.</p>
|
||||
@@ -552,12 +581,17 @@ class Json extends Server {
|
||||
$metadata['scheme'] = 'xyz';
|
||||
$tiles = array();
|
||||
foreach ($this->config['baseUrls'] as $url) {
|
||||
$tiles[] = '' . $this->config['protocol'] . '://' . $url . '/' . $metadata['basename'] . '/{z}/{x}/{y}.' . $metadata['format'];
|
||||
$url = '' . $this->config['protocol'] . '://' . $url . '/' .
|
||||
$metadata['basename'] . '/{z}/{x}/{y}';
|
||||
if(strlen($metadata['format']) <= 4){
|
||||
$url .= '.' . $metadata['format'];
|
||||
}
|
||||
$tiles[] = $url;
|
||||
}
|
||||
$metadata['tiles'] = $tiles;
|
||||
if ($this->isDBLayer($metadata['basename'])) {
|
||||
$this->DBconnect($metadata['basename'] . '.mbtiles');
|
||||
$res = $this->db->query('SELECT name FROM sqlite_master WHERE name="grids";');
|
||||
$res = $this->db->query('SELECT * FROM grids LIMIT 1;');
|
||||
if ($res) {
|
||||
foreach ($this->config['baseUrls'] as $url) {
|
||||
$grids[] = '' . $this->config['protocol'] . '://' . $url . '/' . $metadata['basename'] . '/{z}/{x}/{y}.grid.json';
|
||||
@@ -613,7 +647,7 @@ class Json extends Server {
|
||||
public function getJson() {
|
||||
parent::setDatasets();
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
if ($this->callback !== 'grid') {
|
||||
echo $this->callback . '(' . $this->createJson($this->layer) . ');'; die;
|
||||
} else {
|
||||
@@ -627,7 +661,7 @@ class Json extends Server {
|
||||
public function getJsonp() {
|
||||
parent::setDatasets();
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header("Content-Type: application/javascript; charset=utf-8");
|
||||
header('Content-Type: application/javascript; charset=utf-8');
|
||||
echo $this->callback . '(' . $this->createJson($this->layer) . ');';
|
||||
}
|
||||
|
||||
@@ -694,11 +728,190 @@ class Wmts extends Server {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates tilematrixset, calculates missing params
|
||||
* @param Obrject $tileMatrix
|
||||
* @return Object
|
||||
*/
|
||||
public function parseTileMatrix($layer, $tileMatrix){
|
||||
|
||||
//process projection
|
||||
if(isset($layer['proj4'])){
|
||||
preg_match_all("/([^+= ]+)=([^= ]+)/", $layer['proj4'], $res);
|
||||
$proj4 = array_combine($res[1], $res[2]);
|
||||
}
|
||||
|
||||
for($i = 0; $i < count($tileMatrix); $i++){
|
||||
|
||||
if(!isset($tileMatrix[$i]['id'])){
|
||||
$tileMatrix[$i]['id'] = (string) $i;
|
||||
}
|
||||
if (!isset($tileMatrix[$i]['extent']) && isset($layer['extent'])) {
|
||||
$tileMatrix[$i]['extent'] = $layer['extent'];
|
||||
}
|
||||
if (!isset($tileMatrix[$i]['matrix_size'])) {
|
||||
$tileExtent = $this->tilesOfExtent(
|
||||
$tileMatrix[$i]['extent'],
|
||||
$tileMatrix[$i]['origin'],
|
||||
$tileMatrix[$i]['pixel_size'],
|
||||
$tileMatrix[$i]['tile_size']
|
||||
);
|
||||
$tileMatrix[$i]['matrix_size'] = array(
|
||||
$tileExtent[2] + 1,
|
||||
$tileExtent[1] + 1
|
||||
);
|
||||
}
|
||||
if(!isset($tileMatrix[$i]['origin']) && isset($tileMatrix[$i]['extent'])){
|
||||
$tileMatrix[$i]['origin'] = array(
|
||||
$tileMatrix[$i]['extent'][0], $tileMatrix[$i]['extent'][3]
|
||||
);
|
||||
}
|
||||
// Origins of geographic coordinate systems are setting in opposite order
|
||||
if (isset($proj4) && $proj4['proj'] === 'longlat') {
|
||||
$tileMatrix[$i]['origin'] = array_reverse($tileMatrix[$i]['origin']);
|
||||
}
|
||||
if(!isset($tileMatrix[$i]['scale_denominator'])){
|
||||
$tileMatrix[$i]['scale_denominator'] = count($tileMatrix) - $i;
|
||||
}
|
||||
if(!isset($tileMatrix[$i]['tile_size'])){
|
||||
$tileSize = 256 * (int) $layer['scale'];
|
||||
$tileMatrix[$i]['tile_size'] = array($tileSize, $tileSize);
|
||||
}
|
||||
}
|
||||
|
||||
return $tileMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates corners of tilematrix
|
||||
* @param array $extent
|
||||
* @param array $origin
|
||||
* @param array $pixel_size
|
||||
* @param array $tile_size
|
||||
* @return array
|
||||
*/
|
||||
public function tilesOfExtent($extent, $origin, $pixel_size, $tile_size) {
|
||||
$tiles = array(
|
||||
$this->minsample($extent[0] - $origin[0], $pixel_size[0] * $tile_size[0]),
|
||||
$this->minsample($extent[1] - $origin[1], $pixel_size[1] * $tile_size[1]),
|
||||
$this->maxsample($extent[2] - $origin[0], $pixel_size[0] * $tile_size[0]),
|
||||
$this->maxsample($extent[3] - $origin[1], $pixel_size[1] * $tile_size[1]),
|
||||
);
|
||||
return $tiles;
|
||||
}
|
||||
|
||||
private function minsample($x, $f){
|
||||
return $f > 0 ? floor($x / $f) : ceil(($x / $f) - 1);
|
||||
}
|
||||
|
||||
private function maxsample($x, $f){
|
||||
return $f < 0 ? floor($x / $f) : ceil(($x / $f) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default TileMetrixSet for Pseudo Mercator projection 3857
|
||||
* @return string TileMatrixSet xml
|
||||
*/
|
||||
public function getMercatorTileMatrixSet(){
|
||||
$denominatorBase = 559082264.0287178;
|
||||
$extent = array(-20037508.34,-20037508.34,20037508.34,20037508.34);
|
||||
$tileMatrixSet = array();
|
||||
|
||||
for($i = 0; $i <= 18; $i++){
|
||||
$matrixSize = pow(2, $i);
|
||||
$tileMatrixSet[] = array(
|
||||
'extent' => $extent,
|
||||
'id' => (string) $i,
|
||||
'matrix_size' => array($matrixSize, $matrixSize),
|
||||
'origin' => array($extent[0], $extent[3]),
|
||||
'scale_denominator' => $denominatorBase / pow(2, $i),
|
||||
'tile_size' => array(256, 256)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getTileMatrixSet('GoogleMapsCompatible', $tileMatrixSet, 'EPSG:3857');
|
||||
}
|
||||
|
||||
/**
|
||||
* Default TileMetrixSet for WGS84 projection 4326
|
||||
* @return string Xml
|
||||
*/
|
||||
public function getWGS84TileMatrixSet(){
|
||||
$extent = array(-180.000000, -90.000000, 180.000000, 90.000000);
|
||||
$scaleDenominators = 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);
|
||||
$tileMatrixSet = array();
|
||||
|
||||
for($i = 0; $i <= count($scaleDenominators); $i++){
|
||||
$matrixSize = pow(2, $i);
|
||||
$tileMatrixSet[] = array(
|
||||
'extent' => $extent,
|
||||
'id' => (string) $i,
|
||||
'matrix_size' => array($matrixSize * 2, $matrixSize),
|
||||
'origin' => array($extent[3], $extent[0]),
|
||||
'scale_denominator' => $scaleDenominators[$i],
|
||||
'tile_size' => array(256, 256)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->getTileMatrixSet('WGS84', $tileMatrixSet, 'EPSG:4326');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints WMTS TileMatrixSet
|
||||
* @param string $name
|
||||
* @param array $tileMatrixSet Array of levels
|
||||
* @param string $crs Code of crs eg: EPSG:3857
|
||||
* @return string TileMatrixSet xml
|
||||
*/
|
||||
public function getTileMatrixSet($name, $tileMatrixSet, $crs = 'EPSG:3857'){
|
||||
$srs = explode(':', $crs);
|
||||
$TileMatrixSet = '<TileMatrixSet>
|
||||
<ows:Title>' . $name . '</ows:Title>
|
||||
<ows:Abstract>' . $name . ' '. $crs .'</ows:Abstract>
|
||||
<ows:Identifier>' . $name . '</ows:Identifier>
|
||||
<ows:SupportedCRS>urn:ogc:def:crs:'.$srs[0].'::'.$srs[1].'</ows:SupportedCRS>';
|
||||
// <WellKnownScaleSet>urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible</WellKnownScaleSet>;
|
||||
foreach($tileMatrixSet as $level){
|
||||
$TileMatrixSet .= '
|
||||
<TileMatrix>
|
||||
<ows:Identifier>' . $level['id'] . '</ows:Identifier>
|
||||
<ScaleDenominator>' . $level['scale_denominator'] . '</ScaleDenominator>
|
||||
<TopLeftCorner>'. $level['origin'][0] . ' ' . $level['origin'][1] .'</TopLeftCorner>
|
||||
<TileWidth>' . $level['tile_size'][0] . '</TileWidth>
|
||||
<TileHeight>' . $level['tile_size'][1] . '</TileHeight>
|
||||
<MatrixWidth>' . $level['matrix_size'][0] . '</MatrixWidth>
|
||||
<MatrixHeight>' . $level['matrix_size'][1] . '</MatrixHeight>
|
||||
</TileMatrix>';
|
||||
}
|
||||
$TileMatrixSet .= '</TileMatrixSet>';
|
||||
|
||||
return $TileMatrixSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tilesets getCapabilities
|
||||
*/
|
||||
public function getCapabilities() {
|
||||
header("Content-type: application/xml");
|
||||
|
||||
$layers = array_merge($this->fileLayer, $this->dbLayer);
|
||||
|
||||
//if TileMatrixSet is provided validate it
|
||||
for($i = 0; $i < count($layers); $i++){
|
||||
if($layers[$i]['profile'] == 'custom'){
|
||||
$layers[$i]['tile_matrix'] = $this->parseTileMatrix(
|
||||
$layers[$i],
|
||||
$layers[$i]['tile_matrix']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
header('Content-type: application/xml');
|
||||
echo '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
|
||||
<!-- Service Identification -->
|
||||
@@ -752,27 +965,42 @@ class Wmts extends Server {
|
||||
</ows:Operation>
|
||||
</ows:OperationsMetadata>
|
||||
<Contents>';
|
||||
$maps = array_merge($this->fileLayer, $this->dbLayer);
|
||||
|
||||
$customtileMatrixSets = '';
|
||||
|
||||
//layers
|
||||
$mercator = new GlobalMercator();
|
||||
foreach ($maps as $m) {
|
||||
if (strpos($m['basename'], '.') !== false) {
|
||||
$basename = explode('.', $m['basename']);
|
||||
} else {
|
||||
foreach ($layers as $m) {
|
||||
|
||||
$basename = $m['basename'];
|
||||
}
|
||||
$title = (array_key_exists('name', $m)) ? $m['name'] : $basename;
|
||||
$profile = $m['profile'];
|
||||
$bounds = $m['bounds'];
|
||||
$format = $m['format'];
|
||||
$mime = ($format == 'jpg') ? 'image/jpeg' : 'image/png';
|
||||
$format = $m['format'] == 'hybrid' ? 'jpgpng' : $m['format'];
|
||||
$mime = ($format == 'jpg') ? 'image/jpeg' : 'image/' . $format;
|
||||
|
||||
if ($profile == 'geodetic') {
|
||||
$tileMatrixSet = "WGS84";
|
||||
$tileMatrixSet = 'WGS84';
|
||||
}elseif ($m['profile'] == 'custom') {
|
||||
$crs = explode(':', $m['crs']);
|
||||
$tileMatrixSet = 'custom' . $crs[1] . $m['basename'];
|
||||
$customtileMatrixSets .= $this->getTileMatrixSet(
|
||||
$tileMatrixSet,
|
||||
$m['tile_matrix'],
|
||||
$m['crs']
|
||||
);
|
||||
} else {
|
||||
$tileMatrixSet = "GoogleMapsCompatible";
|
||||
$tileMatrixSet = 'GoogleMapsCompatible';
|
||||
|
||||
list( $minx, $miny ) = $mercator->LatLonToMeters($bounds[1], $bounds[0]);
|
||||
list( $maxx, $maxy ) = $mercator->LatLonToMeters($bounds[3], $bounds[2]);
|
||||
$bounds3857 = array($minx, $miny, $maxx, $maxy);
|
||||
}
|
||||
$resourceUrlTemplate = $this->config['protocol'] . '://'
|
||||
. $this->config['baseUrls'][0] . '/wmts/' . $basename . '/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}';
|
||||
if(strlen($format) <= 4){
|
||||
$resourceUrlTemplate .= '.' . $format;
|
||||
}
|
||||
echo'
|
||||
<Layer>
|
||||
<ows:Title>' . $title . '</ows:Title>
|
||||
@@ -788,362 +1016,22 @@ class Wmts extends Server {
|
||||
<TileMatrixSetLink>
|
||||
<TileMatrixSet>' . $tileMatrixSet . '</TileMatrixSet>
|
||||
</TileMatrixSetLink>
|
||||
<ResourceURL format="' . $mime . '" resourceType="tile" template="' . $this->config['protocol'] . '://'
|
||||
. $this->config['baseUrls'][0] . '/wmts/' . $basename . '/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.' . $format . '"/>
|
||||
<ResourceURL format="' . $mime . '" resourceType="tile" template="' . $resourceUrlTemplate . '"/>
|
||||
</Layer>';
|
||||
}
|
||||
echo '
|
||||
<TileMatrixSet>
|
||||
<ows:Title>GoogleMapsCompatible</ows:Title>
|
||||
<ows:Abstract>the wellknown \'GoogleMapsCompatible\' tile matrix set defined by OGC WMTS specification</ows:Abstract>
|
||||
<ows:Identifier>GoogleMapsCompatible</ows:Identifier>
|
||||
<ows:SupportedCRS>urn:ogc:def:crs:EPSG:6.18:3:3857</ows:SupportedCRS>
|
||||
<WellKnownScaleSet>urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible</WellKnownScaleSet>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>0</ows:Identifier>
|
||||
<ScaleDenominator>559082264.0287178</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>1</MatrixWidth>
|
||||
<MatrixHeight>1</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>1</ows:Identifier>
|
||||
<ScaleDenominator>279541132.0143589</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>2</MatrixWidth>
|
||||
<MatrixHeight>2</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>2</ows:Identifier>
|
||||
<ScaleDenominator>139770566.0071794</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>4</MatrixWidth>
|
||||
<MatrixHeight>4</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>3</ows:Identifier>
|
||||
<ScaleDenominator>69885283.00358972</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>8</MatrixWidth>
|
||||
<MatrixHeight>8</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>4</ows:Identifier>
|
||||
<ScaleDenominator>34942641.50179486</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>16</MatrixWidth>
|
||||
<MatrixHeight>16</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>5</ows:Identifier>
|
||||
<ScaleDenominator>17471320.75089743</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>32</MatrixWidth>
|
||||
<MatrixHeight>32</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>6</ows:Identifier>
|
||||
<ScaleDenominator>8735660.375448715</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>64</MatrixWidth>
|
||||
<MatrixHeight>64</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>7</ows:Identifier>
|
||||
<ScaleDenominator>4367830.187724357</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>128</MatrixWidth>
|
||||
<MatrixHeight>128</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>8</ows:Identifier>
|
||||
<ScaleDenominator>2183915.093862179</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>256</MatrixWidth>
|
||||
<MatrixHeight>256</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>9</ows:Identifier>
|
||||
<ScaleDenominator>1091957.546931089</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>512</MatrixWidth>
|
||||
<MatrixHeight>512</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>10</ows:Identifier>
|
||||
<ScaleDenominator>545978.7734655447</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>1024</MatrixWidth>
|
||||
<MatrixHeight>1024</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>11</ows:Identifier>
|
||||
<ScaleDenominator>272989.3867327723</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>2048</MatrixWidth>
|
||||
<MatrixHeight>2048</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>12</ows:Identifier>
|
||||
<ScaleDenominator>136494.6933663862</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>4096</MatrixWidth>
|
||||
<MatrixHeight>4096</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>13</ows:Identifier>
|
||||
<ScaleDenominator>68247.34668319309</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>8192</MatrixWidth>
|
||||
<MatrixHeight>8192</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>14</ows:Identifier>
|
||||
<ScaleDenominator>34123.67334159654</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>16384</MatrixWidth>
|
||||
<MatrixHeight>16384</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>15</ows:Identifier>
|
||||
<ScaleDenominator>17061.83667079827</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>32768</MatrixWidth>
|
||||
<MatrixHeight>32768</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>16</ows:Identifier>
|
||||
<ScaleDenominator>8530.918335399136</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>65536</MatrixWidth>
|
||||
<MatrixHeight>65536</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>17</ows:Identifier>
|
||||
<ScaleDenominator>4265.459167699568</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>131072</MatrixWidth>
|
||||
<MatrixHeight>131072</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>18</ows:Identifier>
|
||||
<ScaleDenominator>2132.729583849784</ScaleDenominator>
|
||||
<TopLeftCorner>-20037508.34278925 20037508.34278925</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>262144</MatrixWidth>
|
||||
<MatrixHeight>262144</MatrixHeight>
|
||||
</TileMatrix>
|
||||
</TileMatrixSet>
|
||||
<TileMatrixSet>
|
||||
<ows:Identifier>WGS84</ows:Identifier>
|
||||
<ows:Title>GoogleCRS84Quad</ows:Title>
|
||||
<ows:SupportedCRS>urn:ogc:def:crs:EPSG:6.3:4326</ows:SupportedCRS>
|
||||
<ows:BoundingBox crs="urn:ogc:def:crs:EPSG:6.3:4326">
|
||||
<LowerCorner>-180.000000 -90.000000</LowerCorner>
|
||||
<UpperCorner>180.000000 90.000000</UpperCorner>
|
||||
</ows:BoundingBox>
|
||||
<WellKnownScaleSet>urn:ogc:def:wkss:OGC:1.0:GoogleCRS84Quad</WellKnownScaleSet>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>0</ows:Identifier>
|
||||
<ScaleDenominator>279541132.01435887813568115234</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>2</MatrixWidth>
|
||||
<MatrixHeight>1</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>1</ows:Identifier>
|
||||
<ScaleDenominator>139770566.00717943906784057617</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>4</MatrixWidth>
|
||||
<MatrixHeight>2</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>2</ows:Identifier>
|
||||
<ScaleDenominator>69885283.00358971953392028809</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>8</MatrixWidth>
|
||||
<MatrixHeight>4</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>3</ows:Identifier>
|
||||
<ScaleDenominator>34942641.50179485976696014404</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>16</MatrixWidth>
|
||||
<MatrixHeight>8</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>4</ows:Identifier>
|
||||
<ScaleDenominator>17471320.75089742988348007202</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>32</MatrixWidth>
|
||||
<MatrixHeight>16</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>5</ows:Identifier>
|
||||
<ScaleDenominator>8735660.37544871494174003601</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>64</MatrixWidth>
|
||||
<MatrixHeight>32</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>6</ows:Identifier>
|
||||
<ScaleDenominator>4367830.18772435747087001801</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>128</MatrixWidth>
|
||||
<MatrixHeight>64</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>7</ows:Identifier>
|
||||
<ScaleDenominator>2183915.09386217873543500900</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>256</MatrixWidth>
|
||||
<MatrixHeight>128</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>8</ows:Identifier>
|
||||
<ScaleDenominator>1091957.54693108936771750450</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>512</MatrixWidth>
|
||||
<MatrixHeight>256</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>9</ows:Identifier>
|
||||
<ScaleDenominator>545978.77346554468385875225</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>1024</MatrixWidth>
|
||||
<MatrixHeight>512</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>10</ows:Identifier>
|
||||
<ScaleDenominator>272989.38673277234192937613</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>2048</MatrixWidth>
|
||||
<MatrixHeight>1024</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>11</ows:Identifier>
|
||||
<ScaleDenominator>136494.69336638617096468806</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>4096</MatrixWidth>
|
||||
<MatrixHeight>2048</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>12</ows:Identifier>
|
||||
<ScaleDenominator>68247.34668319308548234403</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>8192</MatrixWidth>
|
||||
<MatrixHeight>4096</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>13</ows:Identifier>
|
||||
<ScaleDenominator>34123.67334159654274117202</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>16384</MatrixWidth>
|
||||
<MatrixHeight>8192</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>14</ows:Identifier>
|
||||
<ScaleDenominator>17061.83667079825318069197</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>32768</MatrixWidth>
|
||||
<MatrixHeight>16384</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>15</ows:Identifier>
|
||||
<ScaleDenominator>8530.91833539912659034599</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>65536</MatrixWidth>
|
||||
<MatrixHeight>32768</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>16</ows:Identifier>
|
||||
<ScaleDenominator>4265.45916769956329517299</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>131072</MatrixWidth>
|
||||
<MatrixHeight>65536</MatrixHeight>
|
||||
</TileMatrix>
|
||||
<TileMatrix>
|
||||
<ows:Identifier>17</ows:Identifier>
|
||||
<ScaleDenominator>2132.72958384978574031265</ScaleDenominator>
|
||||
<TopLeftCorner>90.000000 -180.000000</TopLeftCorner>
|
||||
<TileWidth>256</TileWidth>
|
||||
<TileHeight>256</TileHeight>
|
||||
<MatrixWidth>262144</MatrixWidth>
|
||||
<MatrixHeight>131072</MatrixHeight>
|
||||
</TileMatrix>
|
||||
</TileMatrixSet>
|
||||
</Contents>
|
||||
|
||||
// Print custom TileMatrixSets
|
||||
if (strlen($customtileMatrixSets) > 0) {
|
||||
echo $customtileMatrixSets;
|
||||
}
|
||||
|
||||
// Print PseudoMercator TileMatrixSet
|
||||
echo $this->getMercatorTileMatrixSet();
|
||||
|
||||
// Print WGS84 TileMatrixSet
|
||||
echo $this->getWGS84TileMatrixSet();
|
||||
|
||||
echo '</Contents>
|
||||
<ServiceMetadataURL xlink:href="' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/wmts/1.0.0/WMTSCapabilities.xml"/>
|
||||
</Capabilities>';
|
||||
}
|
||||
@@ -1160,7 +1048,13 @@ class Wmts extends Server {
|
||||
} else {
|
||||
$format = $this->getGlobal('Format');
|
||||
}
|
||||
parent::renderTile($this->getGlobal('Layer'), $this->getGlobal('TileMatrix'), $this->getGlobal('TileRow'), $this->getGlobal('TileCol'), $format);
|
||||
parent::renderTile(
|
||||
$this->getGlobal('Layer'),
|
||||
$this->getGlobal('TileMatrix'),
|
||||
$this->getGlobal('TileRow'),
|
||||
$this->getGlobal('TileCol'),
|
||||
$format
|
||||
);
|
||||
} else {
|
||||
parent::renderTile($this->layer, $this->z, $this->y, $this->x, $this->ext);
|
||||
}
|
||||
@@ -1213,16 +1107,16 @@ class Tms extends Server {
|
||||
public function getCapabilities() {
|
||||
parent::setDatasets();
|
||||
$maps = array_merge($this->fileLayer, $this->dbLayer);
|
||||
header("Content-type: application/xml");
|
||||
header('Content-type: application/xml');
|
||||
echo'<TileMapService version="1.0.0"><TileMaps>';
|
||||
foreach ($maps as $m) {
|
||||
$basename = $m['basename'];
|
||||
$title = (array_key_exists('name', $m) ) ? $m['name'] : $basename;
|
||||
$profile = $m['profile'];
|
||||
if ($profile == 'geodetic') {
|
||||
$srs = "EPSG:4326";
|
||||
$srs = 'EPSG:4326';
|
||||
} else {
|
||||
$srs = "EPSG:3857";
|
||||
$srs = 'EPSG:3857';
|
||||
echo '<TileMap title="' . $title . '" srs="' . $srs
|
||||
. '" type="InvertedTMS" ' . 'profile="global-' . $profile
|
||||
. '" href="' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/tms/' . $basename . '" />';
|
||||
@@ -1247,12 +1141,12 @@ class Tms extends Server {
|
||||
$description = (array_key_exists('description', $m)) ? $m['description'] : "";
|
||||
$bounds = $m['bounds'];
|
||||
if ($m['profile'] == 'geodetic') {
|
||||
$srs = "EPSG:4326";
|
||||
$srs = 'EPSG:4326';
|
||||
$originx = -180.0;
|
||||
$originy = -90.0;
|
||||
$initialResolution = 0.703125;
|
||||
} else {
|
||||
$srs = "EPSG:3857";
|
||||
$srs = 'EPSG:3857';
|
||||
$originx = -20037508.342789;
|
||||
$originy = -20037508.342789;
|
||||
$mercator = new GlobalMercator();
|
||||
@@ -1446,7 +1340,7 @@ class Router {
|
||||
$tokens = array(
|
||||
':string' => '([a-zA-Z]+)',
|
||||
':number' => '([0-9]+)',
|
||||
':alpha' => '([a-zA-Z0-9-_@]+)'
|
||||
':alpha' => '([a-zA-Z0-9-_@\.]+)'
|
||||
);
|
||||
//global $config;
|
||||
foreach ($routes as $pattern => $handler_name) {
|
||||
|
Reference in New Issue
Block a user