1
0
mirror of https://github.com/klokantech/tileserver-php.git synced 2025-08-03 13:17:34 +02:00

Correct detection of format closes #67

This commit is contained in:
Dalibor Janák
2016-02-29 14:16:17 +01:00
parent 92ddcb6e66
commit 87906da0c5

View File

@@ -9,6 +9,7 @@
global $config; global $config;
$config['serverTitle'] = 'TileServer-php v1'; $config['serverTitle'] = 'TileServer-php v1';
$config['availableFormats'] = array('png', 'jpg', 'jpeg', 'gif', 'webp', 'hybrid');
//$config['baseUrls'] = array('t0.server.com', 't1.server.com'); //$config['baseUrls'] = array('t0.server.com', 't1.server.com');
Router::serve(array( Router::serve(array(
@@ -241,7 +242,14 @@ class Server {
$metadata['maxzoom'] = 18; $metadata['maxzoom'] = 18;
} }
if (!array_key_exists('format', $metadata)) { if (!array_key_exists('format', $metadata)) {
$metadata['format'] = 'png'; if(array_key_exists('tiles', $metadata)){
$pos = strrpos($metadata['tiles'][0], '.');
$metadata['format'] = trim(substr($metadata['tiles'][0], $pos + 1));
}
}
$formats = $this->config['availableFormats'];
if(!in_array(strtolower($metadata['format']), $formats)){
$metadata['format'] = 'png';
} }
if (!array_key_exists('scale', $metadata)) { if (!array_key_exists('scale', $metadata)) {
$metadata['scale'] = 1; $metadata['scale'] = 1;
@@ -264,6 +272,16 @@ class Server {
return $metadata; return $metadata;
} }
/**
*
* @param string $url
* @return string
*/
private function parseFormat($url){
return $mime;
}
/** /**
* SQLite connection * SQLite connection
* @param string $tileset * @param string $tileset