mirror of
https://github.com/klokantech/tileserver-php.git
synced 2025-08-01 12:10:13 +02:00
Code formating
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* TileServer.php project
|
||||
* ======================
|
||||
* https://github.com/klokantech/tileserver-php/
|
||||
* Copyright (C) 2014 - Klokan Technologies GmbH
|
||||
* Copyright (C) 2016 - Klokan Technologies GmbH
|
||||
*/
|
||||
|
||||
global $config;
|
||||
@@ -143,7 +143,7 @@ class Server {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get metadata from metadataJson
|
||||
* @param string $jsonFileName
|
||||
* @return array
|
||||
*/
|
||||
@@ -175,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');
|
||||
@@ -229,23 +231,25 @@ class Server {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -277,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;
|
||||
@@ -483,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>';
|
||||
}
|
||||
|
||||
@@ -643,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 {
|
||||
@@ -657,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) . ');';
|
||||
}
|
||||
|
||||
@@ -896,7 +900,7 @@ class Wmts extends Server {
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-type: application/xml");
|
||||
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 -->
|
||||
@@ -965,19 +969,17 @@ class Wmts extends Server {
|
||||
$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];
|
||||
|
||||
$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]);
|
||||
@@ -1094,16 +1096,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 . '" />';
|
||||
@@ -1128,12 +1130,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();
|
||||
|
Reference in New Issue
Block a user