mirror of
https://github.com/klokantech/tileserver-php.git
synced 2025-08-01 12:10:13 +02:00
Path to app problem fixed
This commit is contained in:
@@ -189,11 +189,32 @@ class Server {
|
||||
? 'jpg'
|
||||
: 'png';
|
||||
}
|
||||
// autodetect bounds
|
||||
if (!array_key_exists('bounds', $metadata)) {
|
||||
$result = $this->db->query('select min(tile_column) as w, max(tile_column) as e, min(tile_row) as s, max(tile_row) as n from tiles where zoom_level='.$metadata['maxzoom']);
|
||||
$resultdata = $result->fetchAll();
|
||||
$w = -180 + 360 * ($resultdata[0]['w'] / pow(2,$metadata['maxzoom']));
|
||||
$e = -180 + 360 * ((1+$resultdata[0]['e']) / pow(2,$metadata['maxzoom']));
|
||||
$n = $this->row2lat($resultdata[0]['n'], $metadata['maxzoom']);
|
||||
$s = $this->row2lat($resultdata[0]['s']-1, $metadata['maxzoom']);
|
||||
$metadata['bounds'] = implode(',', array($w, $s, $e, $n));
|
||||
}
|
||||
$metadata = $this->metadataValidation($metadata);
|
||||
$mbt = explode('.', $mbt);
|
||||
$metadata['basename'] = $mbt[0];
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert row number to latitude of the top of the row
|
||||
* @param integer $r
|
||||
* @param integer $zoom
|
||||
* @return integer
|
||||
*/
|
||||
public function row2lat($r, $zoom) {
|
||||
$y = $r / pow(2,$zoom-1) - 1;
|
||||
return rad2deg(2.0 * atan(exp(3.191459196*$y)) - 1.57079632679489661922);
|
||||
}
|
||||
|
||||
/**
|
||||
* Valids metaJSON
|
||||
@@ -202,7 +223,6 @@ class Server {
|
||||
*/
|
||||
public function metadataValidation($metadata) {
|
||||
if (array_key_exists('bounds', $metadata)) {
|
||||
// TODO: Calculate bounds from tiles if bounds is missing - with GlobalMercator
|
||||
$metadata['bounds'] = array_map('floatval', explode(',', $metadata['bounds']));
|
||||
} else {
|
||||
$metadata['bounds'] = array(-180, -85.051128779807, 180, 85.051128779807);
|
||||
@@ -210,7 +230,6 @@ class Server {
|
||||
if (!array_key_exists('profile', $metadata)) {
|
||||
$metadata['profile'] = 'mercator';
|
||||
}
|
||||
// TODO: detect format, minzoom, maxzoom, thumb / scandir() for directory
|
||||
// TODO: detect thumb / SQL for mbtiles
|
||||
if (array_key_exists('minzoom', $metadata))
|
||||
$metadata['minzoom'] = intval($metadata['minzoom']);
|
||||
@@ -223,11 +242,6 @@ class Server {
|
||||
if (!array_key_exists('format', $metadata)) {
|
||||
$metadata['format'] = 'png';
|
||||
}
|
||||
/*
|
||||
if (!array_key_exists('profile', $metadata )) {
|
||||
$metadata['profile'] = 'mercator';
|
||||
}
|
||||
*/
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user