mirror of
https://github.com/klokantech/tileserver-php.git
synced 2025-08-01 20:20:21 +02:00
Added UTFgrid functionality on url {layer}.mbtiles/{z}/{x}/{y}.grid.json returns jsonp with grid and also callback is supported
This commit is contained in:
@@ -35,6 +35,7 @@ RewriteRule ^(.+).jpeg$ $1.jpg [L]
|
|||||||
# MBTiles support at /layer/z/x/y.ext - loads the tile from mbtiles with php
|
# MBTiles support at /layer/z/x/y.ext - loads the tile from mbtiles with php
|
||||||
# TODO: serve also 404 errors for tiles
|
# TODO: serve also 404 errors for tiles
|
||||||
RewriteRule ^([^\/]+\.mbtiles)\/.*?(\d+)\/(\d+)\/(\d+)\.(\w+)$ tileserver-mbtiles.php?tileset=$1&z=$2&x=$3&y=$4&ext=$5 [L]
|
RewriteRule ^([^\/]+\.mbtiles)\/.*?(\d+)\/(\d+)\/(\d+)\.(\w+)$ tileserver-mbtiles.php?tileset=$1&z=$2&x=$3&y=$4&ext=$5 [L]
|
||||||
|
RewriteRule ^([^\/]+\.mbtiles)\/.*?(\d+)\/(\d+)\/(\d+)\.grid.json?$ tileserver-mbtiles.php?tileset=$1&z=$2&x=$3&y=$4&ext=grid [QSA,L]
|
||||||
# TODO: use mod_sqlite if available to map the tiles to URL directly by apache
|
# TODO: use mod_sqlite if available to map the tiles to URL directly by apache
|
||||||
|
|
||||||
# WMTS KVP
|
# WMTS KVP
|
||||||
@@ -87,6 +88,7 @@ RewriteRule ^(.+)/tms$ tileserver-tms.php?layer=$1 [QSA,L]
|
|||||||
|
|
||||||
# TileJSON JSONP wrapper for MapBOX.js API
|
# TileJSON JSONP wrapper for MapBOX.js API
|
||||||
RewriteRule ^maps.jsonp?$ tileserver.php?service=json [QSA,L]
|
RewriteRule ^maps.jsonp?$ tileserver.php?service=json [QSA,L]
|
||||||
|
RewriteCond %{REQUEST_URI} !\.grid\.json [NC]
|
||||||
RewriteRule ^(.+).jsonp?$ tileserver.php?service=json&layer=$1 [QSA,L]
|
RewriteRule ^(.+).jsonp?$ tileserver.php?service=json&layer=$1 [QSA,L]
|
||||||
|
|
||||||
# If-Modified-Since (if php is not installed as cgi then comment lines below)
|
# If-Modified-Since (if php is not installed as cgi then comment lines below)
|
||||||
|
@@ -79,18 +79,16 @@ if (isset($_GET['tileset'])) {
|
|||||||
}
|
}
|
||||||
$grid = rtrim($grid, ',') . '}}';
|
$grid = rtrim($grid, ',') . '}}';
|
||||||
|
|
||||||
// CORS header
|
// CORS headers
|
||||||
header('Access-Control-Allow-Origin: *');
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
|
||||||
//TODO: Process callback and ext but first in htaccess or route
|
|
||||||
if (isset($_GET['callback'])) {
|
if (isset($_GET['callback'])) {
|
||||||
|
header("Content-Type:text/javascript charset=utf-8");
|
||||||
echo $_GET['callback'] . '(' . $grid . ');';
|
echo $_GET['callback'] . '(' . $grid . ');';
|
||||||
} elseif ($_GET['ext'] == 'jsonp') {
|
|
||||||
echo 'grid(' . $grid . ');';
|
|
||||||
} else {
|
} else {
|
||||||
echo $grid;
|
header("Content-Type:text/javascript; charset=utf-8");
|
||||||
|
echo 'grid(' . $grid . ');';
|
||||||
}
|
}
|
||||||
die;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
Reference in New Issue
Block a user