From 2ead30dc4a811308c17345068ab341b1a37f1b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Jan=C3=A1k?= Date: Mon, 29 Aug 2016 19:06:51 +0200 Subject: [PATCH] Rename mbtilesPrefix to dataRoot --- tileserver.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tileserver.php b/tileserver.php index 87b4eb6..8c57f41 100644 --- a/tileserver.php +++ b/tileserver.php @@ -10,7 +10,7 @@ global $config; $config['serverTitle'] = 'Maps hosted with TileServer-php v2.0'; $config['availableFormats'] = array('png', 'jpg', 'jpeg', 'gif', 'webp', 'pbf', 'hybrid'); -$config['mbtilesPrefix'] = './'; +$config['dataRoot'] = ''; //$config['template'] = 'template.php'; //$config['baseUrls'] = array('t0.server.com', 't1.server.com'); @@ -87,7 +87,7 @@ public function __construct() { */ public function setDatasets() { $mjs = glob('*/metadata.json'); - $mbts = glob($this->config['mbtilesPrefix'] . '*.mbtiles'); + $mbts = glob($this->config['dataRoot'] . '*.mbtiles'); if ($mjs) { foreach (array_filter($mjs, 'is_readable') as $mj) { $layer = $this->metadataFromMetadataJson($mj); @@ -140,7 +140,7 @@ public function getGlobal($isKey) { * @return boolean */ public function isDBLayer($layer) { - if (is_file($this->config['mbtilesPrefix'] . $layer . '.mbtiles')) { + if (is_file($this->config['dataRoot'] . $layer . '.mbtiles')) { return TRUE; } else { return FALSE; @@ -311,7 +311,7 @@ public function DBconnect($tileset) { * @return boolean */ public function isModified($filename) { - $filename = $this->config['mbtilesPrefix'] . $filename . '.mbtiles'; + $filename = $this->config['dataRoot'] . $filename . '.mbtiles'; $lastModifiedTime = filemtime($filename); $eTag = md5($lastModifiedTime); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModifiedTime) . ' GMT'); @@ -339,7 +339,7 @@ public function renderTile($tileset, $z, $y, $x, $ext) { header('HTTP/1.1 304 Not Modified'); die; } - $this->DBconnect($this->config['mbtilesPrefix'] . $tileset . '.mbtiles'); + $this->DBconnect($this->config['dataRoot'] . $tileset . '.mbtiles'); $z = floatval($z); $y = floatval($y); $x = floatval($x); @@ -455,7 +455,7 @@ public function renderUTFGrid($tileset, $z, $y, $x, $flip = TRUE) { $y = pow(2, $z) - 1 - $y; } try { - $this->DBconnect($this->config['mbtilesPrefix'] . $tileset . '.mbtiles'); + $this->DBconnect($this->config['dataRoot'] . $tileset . '.mbtiles'); $query = 'SELECT grid FROM grids WHERE tile_column = ' . $x . ' AND ' . 'tile_row = ' . $y . ' AND zoom_level = ' . $z; @@ -620,7 +620,7 @@ public function metadataTileJson($metadata) { $metadata['tilejson'] = '2.0.0'; $metadata['scheme'] = 'xyz'; if ($this->isDBLayer($metadata['basename'])) { - $this->DBconnect($this->config['mbtilesPrefix'] . $metadata['basename'] . '.mbtiles'); + $this->DBconnect($this->config['dataRoot'] . $metadata['basename'] . '.mbtiles'); $res = $this->db->query('SELECT name FROM sqlite_master WHERE name="grids";'); if ($res) { foreach ($this->config['baseUrls'] as $url) {