Change bearing and pitch format in static url

This commit is contained in:
Petr Sloup 2016-06-27 07:52:01 +02:00
parent 391c21a966
commit 4af6fb686f
2 changed files with 4 additions and 4 deletions

View file

@ -42,7 +42,7 @@ See https://github.com/klokantech/tileserver-gl-data/blob/master/config.json
- Available formats: `png`, `jpg` (`jpeg`), `webp` - Available formats: `png`, `jpg` (`jpeg`), `webp`
- TileJSON at `/styles/{id}/rendered.json` - TileJSON at `/styles/{id}/rendered.json`
- Static images are rendered at: - Static images are rendered at:
- `/styles/{id}/static/{lon},{lat},{zoom}[,{bearing},{pitch}]/{width}x{height}[@2x].{format}` (center-based) - `/styles/{id}/static/{lon},{lat},{zoom}[@{bearing}[,{pitch}]]/{width}x{height}[@2x].{format}` (center-based)
- `/styles/{id}/static/{minx},{miny},{maxx},{maxy}/{width}x{height}[@2x].{format}` (area-based) - `/styles/{id}/static/{minx},{miny},{maxx},{maxy}/{width}x{height}[@2x].{format}` (area-based)
- `/styles/{id}/static/auto/{width}x{height}[@2x].{format}` (autofit path -- see below) - `/styles/{id}/static/auto/{width}x{height}[@2x].{format}` (autofit path -- see below)
- The static image endpoints additionally support following query parameters: - The static image endpoints additionally support following query parameters:

View file

@ -408,15 +408,15 @@ module.exports = function(options, repo, params, id) {
':scale(' + SCALE_PATTERN + ')?\.:format([\\w]+)'; ':scale(' + SCALE_PATTERN + ')?\.:format([\\w]+)';
var centerPattern = var centerPattern =
util.format(':lon(%s),:lat(%s),:z(\\d+):bearing(,%s)?:pitch(,%s)?', util.format(':lon(%s),:lat(%s),:z(\\d+)(@:bearing(%s)(,:pitch(%s))?)?',
FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN); FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN);
app.get(util.format(staticPattern, centerPattern), function(req, res, next) { app.get(util.format(staticPattern, centerPattern), function(req, res, next) {
var z = req.params.z | 0, var z = req.params.z | 0,
x = +req.params.lon, x = +req.params.lon,
y = +req.params.lat, y = +req.params.lat,
bearing = +((req.params.bearing || ',0').substring(1)), bearing = +(req.params.bearing || '0'),
pitch = +((req.params.pitch || ',0').substring(1)), pitch = +(req.params.pitch || '0'),
w = req.params.width | 0, w = req.params.width | 0,
h = req.params.height | 0, h = req.params.height | 0,
scale = getScale(req.params.scale), scale = getScale(req.params.scale),