1
0
mirror of https://github.com/klokantech/tileserver-php.git synced 2025-01-29 12:07:39 +01: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:
Dalibor Janák 2014-03-26 09:36:44 +01:00
parent bd8c6b286f
commit 59c2d03552
2 changed files with 6 additions and 6 deletions

View File

@ -35,6 +35,7 @@ RewriteRule ^(.+).jpeg$ $1.jpg [L]
# MBTiles support at /layer/z/x/y.ext - loads the tile from mbtiles with php
# 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+)\.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
# WMTS KVP
@ -87,6 +88,7 @@ RewriteRule ^(.+)/tms$ tileserver-tms.php?layer=$1 [QSA,L]
# TileJSON JSONP wrapper for MapBOX.js API
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]
# If-Modified-Since (if php is not installed as cgi then comment lines below)

View File

@ -79,18 +79,16 @@ if (isset($_GET['tileset'])) {
}
$grid = rtrim($grid, ',') . '}}';
// CORS header
// CORS headers
header('Access-Control-Allow-Origin: *');
//TODO: Process callback and ext but first in htaccess or route
if (isset($_GET['callback'])) {
header("Content-Type:text/javascript charset=utf-8");
echo $_GET['callback'] . '(' . $grid . ');';
} elseif ($_GET['ext'] == 'jsonp') {
echo 'grid(' . $grid . ');';
} else {
echo $grid;
header("Content-Type:text/javascript; charset=utf-8");
echo 'grid(' . $grid . ');';
}
die;
}
}
} catch (PDOException $e) {