1
0
mirror of https://github.com/klokantech/tileserver-php.git synced 2025-08-23 22:52:55 +02:00

25 Commits

Author SHA1 Message Date
Dalibor Janák
e4148733ed Empty tile response for jpg and webp 2016-05-03 23:36:31 +02:00
Dalibor Janák
c28d188e0d Empty tile response for jpg and webp 2016-05-03 23:21:40 +02:00
Dalibor Janák
ef5de0607d Unpack empty png tile PHP 5.2 compatible 2016-05-03 22:48:23 +02:00
Dalibor Janák
494669f5d7 Merge pull request #79 from ramunasd/patch-1
Faster and ~70% smaller empty png tile
2016-05-03 22:13:08 +02:00
Petr Pridal
4b53b4c351 Sample MBTiles file for OpenShift deploy 2016-05-03 17:15:54 +02:00
Petr Pridal
86a1c68888 Update .travis.yml 2016-04-23 00:34:40 +02:00
Petr Pridal
f834ec7fd9 Deploy to OpenShift via travis 2016-04-23 00:08:21 +02:00
Ramūnas Dronga
ac68e90870 Faster and ~70% smaller empty png tile 2016-04-18 21:25:38 +03:00
Dalibor Janák
bb48534fe3 Removing of useless code. 2016-03-21 13:42:53 +01:00
Dalibor Janák
c158bcbe57 Minor warning with some php configurations fixed. 2016-03-21 13:40:33 +01:00
Dalibor Janák
2dfd2fcb5f Max zoom of Mercator TileMatrixSet is affected with max of layers maxzoom (closes #76) 2016-03-21 10:59:29 +01:00
Dalibor Janák
6b4fb0fec7 WMTS url to tiles simplified for fastest tile serving 2016-03-07 14:57:29 +01:00
Dalibor Janák
8f2b068c4f Custom template implementation #31 2016-03-07 14:39:28 +01:00
Dalibor Janák
709ed4ffce Revert "Fix of utfgid detection"
This reverts commit 8f6a2ced68.
2016-03-07 14:00:29 +01:00
Dalibor Janák
7320f426a1 Autodetection fix or warning in router, closes #49 2016-03-04 13:28:05 +01:00
Dalibor Janák
2e36338720 Removed dependency of GlobalMercator class closes #74 2016-03-04 13:20:46 +01:00
Dalibor Janák
70159a5b29 Layer list improved 2016-03-04 12:07:37 +01:00
Dalibor Janák
fdeb010831 Get global vars via getenv 2016-03-01 19:17:46 +01:00
Dalibor Janák
8bbfa1d367 Config from eniviroment if is provided 2016-03-01 15:05:58 +01:00
Dalibor Janák
50630fe1c7 Get config from docker volumes if is provided 2016-03-01 11:57:18 +01:00
Dalibor Janák
8206bcccc7 GD module dependency closes #53 2016-02-29 20:21:13 +01:00
Dalibor Janák
d304b89eb2 Removed unused code 2016-02-29 14:19:09 +01:00
Dalibor Janák
87906da0c5 Correct detection of format closes #67 2016-02-29 14:16:17 +01:00
Dalibor Janák
92ddcb6e66 WMTS / TileJSON for remote tiles #69 2016-02-29 12:16:24 +01:00
Dalibor Janák
7efd117884 Merge pull request #71 from klokantech/customtiles
Customtiles
2016-02-29 09:52:13 +01:00
2 changed files with 144 additions and 224 deletions

View File

@@ -7,3 +7,17 @@ php:
- hhvm
script:
- php tileserver.php
after_success:
- wget https://github.com/klokantech/tileserver-php/releases/download/v0.1/grandcanyon.mbtiles
- git config --global user.email "travis@localhost.localdomain"
- git config --global user.name "Travis CI"
- git add --all
- git commit -am "Travis change"
deploy:
provider: openshift
user: osm2vectortiles@klokantech.com
password:
secure: hiWKBaqh/CMdnQ2qxsRSKYAnk4tP/q2J50TaO+2sH09x+0Q85ygfICCDrEx457xqmGW0e4zZPsL83mMPvGt5KJO6g9DIncj6BFhpZA0ysnRJ3X1fczTiVN5hQfqNpa+/YIrQ0whu1Ur/IfdYTtvArYhuAPeigCloumGk9gNgSIQ=
domain: tileserver
app: php
skip_cleanup: true

View File

@@ -9,11 +9,13 @@
global $config;
$config['serverTitle'] = 'TileServer-php v1';
$config['availableFormats'] = array('png', 'jpg', 'jpeg', 'gif', 'webp', 'pbf', 'hybrid');
//$config['template'] = 'template.php';
//$config['baseUrls'] = array('t0.server.com', 't1.server.com');
Router::serve(array(
'/' => 'Server:getHtml',
'/test' => 'Server:getInfo',
'/maps' => 'Server:getInfo',
'/html' => 'Server:getHtml',
'/:alpha/:number/:number/:number.grid.json' => 'Json:getUTFGrid',
'/:alpha.json' => 'Json:getJson',
@@ -62,6 +64,21 @@ class Server {
*/
public function __construct() {
$this->config = $GLOBALS['config'];
//Get config from enviroment
$envServerTitle = getenv('serverTitle');
if($envServerTitle !== FALSE){
$this->config['serverTitle'] = $envServerTitle;
}
$envBaseUrls = getenv('baseUrls');
if($envBaseUrls !== FALSE){
$this->config['baseUrls'] = is_array($envBaseUrls) ?
$envBaseUrls : explode(',', $envBaseUrls);
}
$envTemplate = getenv('template');
if($envBaseUrls !== FALSE){
$this->config['template'] = $envTemplate;
}
}
/**
@@ -149,9 +166,8 @@ class Server {
*/
public function metadataFromMetadataJson($jsonFileName) {
$metadata = json_decode(file_get_contents($jsonFileName), true);
$metadata = $this->metadataValidation($metadata);
$metadata['basename'] = str_replace('/metadata.json', '', $jsonFileName);
return $metadata;
return $this->metadataValidation($metadata);
}
/**
@@ -200,9 +216,9 @@ class Server {
$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];
$metadata = $this->metadataValidation($metadata);
return $metadata;
}
@@ -242,14 +258,30 @@ class Server {
$metadata['maxzoom'] = 18;
}
if (!array_key_exists('format', $metadata)) {
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)) {
$metadata['scale'] = 1;
}
// TODO: detect thumb / SQL for mbtiles
if(!array_key_exists('tiles', $metadata)){
$tiles = array();
foreach ($this->config['baseUrls'] as $url) {
$url = '' . $this->config['protocol'] . '://' . $url . '/' .
$metadata['basename'] . '/{z}/{x}/{y}';
if(strlen($metadata['format']) <= 4){
$url .= '.' . $metadata['format'];
}
$tiles[] = $url;
}
$metadata['tiles'] = $tiles;
}
return $metadata;
}
@@ -383,19 +415,26 @@ class Server {
header('HTTP/1.1 404 Not Found');
header('Content-Type: application/json; charset=utf-8');
echo '{"message":"Tile does not exist"}';
die;
break;
case 'webp':
header('Access-Control-Allow-Origin: *');
header('Content-type: image/webp');
echo base64_decode('UklGRhIAAABXRUJQVlA4TAYAAAAvQWxvAGs=');
break;
case 'jpg':
header('Access-Control-Allow-Origin: *');
header('Content-type: image/jpg');
echo base64_decode('/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=');
break;
case 'png':
default:
$tileSize = 256 * $scale;
$png = imagecreatetruecolor($tileSize, $tileSize);
imagesavealpha($png, true);
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
imagefill($png, 0, 0, $trans_colour);
header('Access-Control-Allow-Origin: *');
header('Content-type: image/png');
imagepng($png);
die;
// 256x256 transparent optimised png tile
echo unpack('H', '89504e470d0a1a0a0000000d494844520000010000000100010300000066bc3a2500000003504c5445000000a77a3dda0000000174524e530040e6d8660000001f494441541819edc1010d000000c220fba77e0e37600000000000000000e70221000001f5a2bd040000000049454e44ae426082');
break;
}
die;
}
/**
@@ -463,29 +502,22 @@ class Server {
* Returns server info
*/
public function getInfo() {
// echo $this->config['baseUrls'][0];die;
$this->setDatasets();
$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></head><body>';
echo '<h1>' . $this->config['serverTitle'] . '</h1>';
echo 'TileJSON service: <a href="//' . $this->config['baseUrls'][0] . '/index.json">' . $this->config['baseUrls'][0] . '/index.json</a><br>';
echo 'WMTS service: <a href="//' . $this->config['baseUrls'][0] . '/wmts">' . $this->config['baseUrls'][0] . '/wmts</a><br>';
echo 'TMS service: <a href="//' . $this->config['baseUrls'][0] . '/tms">' . $this->config['baseUrls'][0] . '/tms</a>';
echo '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>' . $this->config['serverTitle'] . '</title></head><body>' .
'<h1>' . $this->config['serverTitle'] . '</h1>' .
'TileJSON service: <a href="//' . $this->config['baseUrls'][0] . '/index.json">' . $this->config['baseUrls'][0] . '/index.json</a><br>' .
'WMTS service: <a href="//' . $this->config['baseUrls'][0] . '/wmts">' . $this->config['baseUrls'][0] . '/wmts</a><br>' .
'TMS service: <a href="//' . $this->config['baseUrls'][0] . '/tms">' . $this->config['baseUrls'][0] . '/tms</a>';
foreach ($maps as $map) {
$extend = '[';
foreach ($map['bounds'] as $ext) {
$extend = $extend . ' ' . $ext;
}
$extend = $extend . ' ]';
if (strpos($map['basename'], 'mbtiles') !== false) {
echo '<p>Available MBtiles tileset: ' . $map['basename'] . '<br>';
} else {
echo '<p>Available file tileset: ' . $map['basename'] . '<br>';
}
echo 'Metadata: <a href="//' . $this->config['baseUrls'][0] . '/' . $map['basename'] . '.json">'
. $this->config['baseUrls'][0] . '/' . $map['basename'] . '.json</a><br>';
echo 'Bounds: ' . $extend . '</p>';
$extend = '[' . implode($map['bounds'], ', ') . ']';
echo '<p>Tileset: <b>' . $map['basename'] . '</b><br>' .
'Metadata: <a href="//' . $this->config['baseUrls'][0] . '/' . $map['basename'] . '.json">' .
$this->config['baseUrls'][0] . '/' . $map['basename'] . '.json</a><br>' .
'Bounds: ' . $extend ;
if(isset($map['crs'])){echo '<br>CRS: ' . $map['crs'];}
echo '</p>';
}
echo '<p>Copyright (C) 2016 - Klokan Technologies GmbH</p>';
echo '</body></html>';
@@ -497,6 +529,11 @@ class Server {
public function getHtml() {
$this->setDatasets();
$maps = array_merge($this->fileLayer, $this->dbLayer);
if (isset($this->config['template']) && file_exists($this->config['template'])) {
$baseUrls = $this->config['baseUrls'];
$serverTitle = $this->config['serverTitle'];
include_once $this->config['template'];
} else {
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="//cdn.klokantech.com/tileviewer/v1/index.css" />
@@ -520,6 +557,7 @@ class Server {
}
echo '</body></html>';
}
}
}
@@ -579,19 +617,9 @@ class Json extends Server {
public function metadataTileJson($metadata) {
$metadata['tilejson'] = '2.0.0';
$metadata['scheme'] = 'xyz';
$tiles = array();
foreach ($this->config['baseUrls'] as $url) {
$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 * FROM grids LIMIT 1;');
$res = $this->db->query('SELECT name FROM sqlite_master WHERE name="grids";');
if ($res) {
foreach ($this->config['baseUrls'] as $url) {
$grids[] = '' . $this->config['protocol'] . '://' . $url . '/' . $metadata['basename'] . '/{z}/{x}/{y}.grid.json';
@@ -730,7 +758,7 @@ class Wmts extends Server {
/**
* Validates tilematrixset, calculates missing params
* @param Obrject $tileMatrix
* @param Object $tileMatrix
* @return Object
*/
public function parseTileMatrix($layer, $tileMatrix){
@@ -810,14 +838,15 @@ class Wmts extends Server {
/**
* Default TileMetrixSet for Pseudo Mercator projection 3857
* @param ?number $maxZoom
* @return string TileMatrixSet xml
*/
public function getMercatorTileMatrixSet(){
public function getMercatorTileMatrixSet($maxZoom = 18){
$denominatorBase = 559082264.0287178;
$extent = array(-20037508.34,-20037508.34,20037508.34,20037508.34);
$tileMatrixSet = array();
for($i = 0; $i <= 18; $i++){
for($i = 0; $i <= $maxZoom; $i++){
$matrixSize = pow(2, $i);
$tileMatrixSet[] = array(
'extent' => $extent,
@@ -847,7 +876,7 @@ class Wmts extends Server {
2132.72958384978574031265);
$tileMatrixSet = array();
for($i = 0; $i <= count($scaleDenominators); $i++){
for($i = 0; $i <= 17; $i++){
$matrixSize = pow(2, $i);
$tileMatrixSet[] = array(
'extent' => $extent,
@@ -967,9 +996,9 @@ class Wmts extends Server {
<Contents>';
$customtileMatrixSets = '';
$maxMercatorZoom = 18;
//layers
$mercator = new GlobalMercator();
foreach ($layers as $m) {
$basename = $m['basename'];
@@ -991,16 +1020,16 @@ class Wmts extends Server {
);
} else {
$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);
$maxMercatorZoom = max($maxMercatorZoom, $m['maxzoom']);
}
$resourceUrlTemplate = $this->config['protocol'] . '://'
. $this->config['baseUrls'][0] . '/wmts/' . $basename . '/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}';
$wmtsHost = substr($m['tiles'][0], 0, strpos($m['tiles'][0], $m['basename']));
$resourceUrlTemplate = $wmtsHost . $basename
. '/{TileMatrix}/{TileCol}/{TileRow}';
if(strlen($format) <= 4){
$resourceUrlTemplate .= '.' . $format;
}
echo'
<Layer>
<ows:Title>' . $title . '</ows:Title>
@@ -1026,7 +1055,7 @@ class Wmts extends Server {
}
// Print PseudoMercator TileMatrixSet
echo $this->getMercatorTileMatrixSet();
echo $this->getMercatorTileMatrixSet($maxMercatorZoom);
// Print WGS84 TileMatrixSet
echo $this->getWGS84TileMatrixSet();
@@ -1117,10 +1146,12 @@ class Tms extends Server {
$srs = 'EPSG:4326';
} else {
$srs = 'EPSG:3857';
}
$url = $this->config['protocol'] . '://' . $this->config['baseUrls'][0]
. '/tms/' . $basename;
echo '<TileMap title="' . $title . '" srs="' . $srs
. '" type="InvertedTMS" ' . 'profile="global-' . $profile
. '" href="' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/tms/' . $basename . '" />';
}
. '" href="' . $url . '" />';
}
echo '</TileMaps></TileMapService>';
}
@@ -1142,31 +1173,35 @@ class Tms extends Server {
$bounds = $m['bounds'];
if ($m['profile'] == 'geodetic') {
$srs = 'EPSG:4326';
$originx = -180.0;
$originy = -90.0;
$initialResolution = 0.703125;
$initRes = 0.703125;
} elseif ($m['profile'] == 'custom') {
$srs = $m['crs'];
$bounds = $m['extent'];
if(isset($m['tile_matrix'][0]['pixel_size'][0])){
$initRes = $m['tile_matrix'][0]['pixel_size'][0];
}else{
$initRes = 1;
}
} else {
$srs = 'EPSG:3857';
$originx = -20037508.342789;
$originy = -20037508.342789;
$mercator = new GlobalMercator();
list( $minx, $miny ) = $mercator->LatLonToMeters($bounds[1], $bounds[0]);
list( $maxx, $maxy ) = $mercator->LatLonToMeters($bounds[3], $bounds[2]);
$bounds = array($minx, $miny, $maxx, $maxy);
$initialResolution = 156543.03392804062;
$bounds = array(-20037508.34,-20037508.34,20037508.34,20037508.34);
$initRes = 156543.03392804062;
}
$mime = ($m['format'] == 'jpg') ? 'image/jpeg' : 'image/png';
header("Content-type: application/xml");
echo '<TileMap version="1.0.0" tilemapservice="' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/' . $m['basename'] . '" type="InvertedTMS">
$serviceUrl = $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/' . $m['basename'];
echo '<TileMap version="1.0.0" tilemapservice="' . $serviceUrl . '" type="InvertedTMS">
<Title>' . htmlspecialchars($title) . '</Title>
<Abstract>' . htmlspecialchars($description) . '</Abstract>
<SRS>' . $srs . '</SRS>
<BoundingBox minx="' . $bounds[0] . '" miny="' . $bounds[1] . '" maxx="' . $bounds[2] . '" maxy="' . $bounds[3] . '" />
<Origin x="' . $originx . '" y="' . $originy . '"/>
<Origin x="' . $bounds[0] . '" y="' . $bounds[1] . '"/>
<TileFormat width="256" height="256" mime-type="' . $mime . '" extension="' . $m['format'] . '"/>
<TileSets profile="global-' . $m['profile'] . '">';
for ($zoom = $m['minzoom']; $zoom < $m['maxzoom'] + 1; $zoom++) {
echo '<TileSet href="' . $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/' . $m['basename'] . '/' . $zoom . '" units-per-pixel="' . $initialResolution / pow(2, $zoom) . '" order="' . $zoom . '" />';
$res = $initRes / pow(2, $zoom);
$url = $this->config['protocol'] . '://' . $this->config['baseUrls'][0] . '/' . $m['basename'] . '/' . $zoom;
echo '<TileSet href="' . $url . '" units-per-pixel="' . $res . '" order="' . $zoom . '" />';
}
echo'</TileSets></TileMap>';
}
@@ -1177,135 +1212,6 @@ class Tms extends Server {
public function getTile() {
parent::renderTile($this->layer, $this->z, $this->y, $this->x, $this->ext);
}
}
/*
GlobalMapTiles - part of Aggregate Map Tools
Version 1.0
Copyright (c) 2009 The Bivings Group
All rights reserved.
Author: John Bafford
http://www.bivings.com/
http://bafford.com/softare/aggregate-map-tools/
Based on GDAL2Tiles / globalmaptiles.py
Original python version Copyright (c) 2008 Klokan Petr Pridal. All rights reserved.
http://www.klokan.cz/projects/gdal2tiles/
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublic ense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The abov
e copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
class GlobalMercator {
var $tileSize;
var $initialResolution;
var $originShift;
//Initialize the TMS Global Mercator pyramid
function __construct($tileSize = 256) {
$this->tileSize = $tileSize;
$this->initialResolution = 2 * M_PI * 6378137 / $this->tileSize;
# 156543.03392804062 for tileSize 256 Pixels
$this->originShift = 2 * M_PI * 6378137 / 2.0;
# 20037508.342789244
}
//Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:900913
function LatLonToMeters($lat, $lon) {
$mx = $lon * $this->originShift / 180.0;
$my = log(tan((90 + $lat) * M_PI / 360.0)) / (M_PI / 180.0);
$my *= $this->originShift / 180.0;
return array($mx, $my);
}
//Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
function MetersToLatLon($mx, $my) {
$lon = ($mx / $this->originShift) * 180.0;
$lat = ($my / $this->originShift) * 180.0;
$lat = 180 / M_PI * (2 * atan(exp($lat * M_PI / 180.0)) - M_PI / 2.0);
return array($lat, $lon);
}
//Converts pixel coordinates in given zoom level of pyramid to EPSG:900913
function PixelsToMeters($px, $py, $zoom) {
$res = $this->Resolution($zoom);
$mx = $px * $res - $this->originShift;
$my = $py * $res - $this->originShift;
return array($mx, $my);
}
//Converts EPSG:900913 to pyramid pixel coordinates in given zoom level
function MetersToPixels($mx, $my, $zoom) {
$res = $this->Resolution($zoom);
$px = ($mx + $this->originShift) / $res;
$py = ($my + $this->originShift) / $res;
return array($px, $py);
}
//Returns a tile covering region in given pixel coordinates
function PixelsToTile($px, $py) {
$tx = ceil($px / $this->tileSize) - 1;
$ty = ceil($py / $this->tileSize) - 1;
return array($tx, $ty);
}
//Returns tile for given mercator coordinates
function MetersToTile($mx, $my, $zoom) {
list($px, $py) = $this->MetersToPixels($mx, $my, $zoom);
return $this->PixelsToTile($px, $py);
}
//Returns bounds of the given tile in EPSG:900913 coordinates
function TileBounds($tx, $ty, $zoom) {
list($minx, $miny) = $this->PixelsToMeters($tx * $this->tileSize, $ty * $this->tileSize, $zoom);
list($maxx, $maxy) = $this->PixelsToMeters(($tx + 1) * $this->tileSize, ($ty + 1) * $this->tileSize, $zoom);
return array($minx, $miny, $maxx, $maxy);
}
//Returns bounds of the given tile in latutude/longitude using WGS84 datum
function TileLatLonBounds($tx, $ty, $zoom) {
$bounds = $this->TileBounds($tx, $ty, $zoom);
list($minLat, $minLon) = $this->MetersToLatLon($bounds[0], $bounds[1]);
list($maxLat, $maxLon) = $this->MetersToLatLon($bounds[2], $bounds[3]);
return array($minLat, $minLon, $maxLat, $maxLon);
}
//Resolution (meters/pixel) for given zoom level (measured at Equator)
function Resolution($zoom) {
return $this->initialResolution / (1 < $zoom);
}
}
/**
@@ -1323,7 +1229,7 @@ class Router {
$config['protocol'] = ( isset($_SERVER["HTTPS"]) or $_SERVER['SERVER_PORT'] == '443') ? "https" : "http";
if (!empty($_SERVER['PATH_INFO'])) {
$path_info = $_SERVER['PATH_INFO'];
} else if (!empty($_SERVER['ORIG_PATH_INFO']) && $_SERVER['ORIG_PATH_INFO'] !== '/tileserver.php') {
} else if (!empty($_SERVER['ORIG_PATH_INFO']) && strpos($_SERVER['ORIG_PATH_INFO'], 'tileserver.php') === false) {
$path_info = $_SERVER['ORIG_PATH_INFO'];
} else if (!empty($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/tileserver.php') !== false) {
$path_info = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
@@ -1371,7 +1277,7 @@ class Router {
}
} else {
if (!isset($config['baseUrls'][0])) {
$config['baseUrls'][0] = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?';
$config['baseUrls'][0] = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
if (strpos($_SERVER['REQUEST_URI'], '=') != FALSE) {
$kvp = explode('=', $_SERVER['REQUEST_URI']);