Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
654bdda629 | ||
|
|
537313840e | ||
|
|
d30f8464b2 | ||
|
|
698c527e94 | ||
|
|
8007f1386c | ||
|
|
4f2fdf602b | ||
|
|
6d7397647a | ||
|
|
8fd7a9b42b | ||
|
|
95470143b6 | ||
|
|
de83021c3d |
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4"
|
||||
- "6"
|
||||
env:
|
||||
- CXX=g++-4.8
|
||||
addons:
|
||||
@@ -12,7 +12,7 @@ addons:
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
|
||||
- sudo apt-get install -qq xvfb
|
||||
- sudo apt-get install -qq xvfb libgles2-mesa-dev libgbm-dev libxxf86vm-dev
|
||||
install:
|
||||
- npm install
|
||||
- wget -O test_data.zip https://github.com/klokantech/tileserver-gl/releases/download/v1.3.0/test_data.zip
|
||||
|
||||
@@ -9,10 +9,14 @@ RUN apt-get -qq update \
|
||||
build-essential \
|
||||
python \
|
||||
libcairo2-dev \
|
||||
libgles2-mesa-dev \
|
||||
libgbm-dev \
|
||||
libllvm3.9 \
|
||||
libprotobuf-dev \
|
||||
libxxf86vm-dev \
|
||||
xvfb \
|
||||
&& echo "deb https://deb.nodesource.com/node_4.x jessie main" >> /etc/apt/sources.list.d/nodejs.list \
|
||||
&& echo "deb-src https://deb.nodesource.com/node_4.x jessie main" >> /etc/apt/sources.list.d/nodejs.list \
|
||||
&& echo "deb https://deb.nodesource.com/node_6.x jessie main" >> /etc/apt/sources.list.d/nodejs.list \
|
||||
&& echo "deb-src https://deb.nodesource.com/node_6.x jessie main" >> /etc/apt/sources.list.d/nodejs.list \
|
||||
&& apt-get -qq update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated install \
|
||||
nodejs \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:4
|
||||
FROM node:6
|
||||
MAINTAINER Petr Sloup <petr.sloup@klokantech.com>
|
||||
|
||||
RUN mkdir -p /usr/src/app
|
||||
|
||||
@@ -6,18 +6,18 @@ If you visit the server on the configured port (default 8080) you can see your m
|
||||
|
||||
Styles
|
||||
======
|
||||
* Styles are served at ``/styles/{id}.json`` (+ array at ``/styles.json``)
|
||||
* Styles are served at ``/styles/{id}/style.json`` (+ array at ``/styles.json``)
|
||||
|
||||
* Sprites at ``/styles/{id}/sprite[@2x].{format}``
|
||||
* Fonts at ``/fonts/{fontstack}/{start}-{end}.pbf``
|
||||
|
||||
Rendered tiles
|
||||
==============
|
||||
* Rendered tiles are served at ``/styles/{id}/rendered/{z}/{x}/{y}[@2x].{format}``
|
||||
* Rendered tiles are served at ``/styles/{id}/{z}/{x}/{y}[@2x].{format}``
|
||||
|
||||
* The optional ``@2x`` (or ``@3x``, ``@4x``) part can be used to render HiDPI (retina) tiles
|
||||
* Available formats: ``png``, ``jpg`` (``jpeg``), ``webp``
|
||||
* TileJSON at ``/styles/{id}/rendered.json``
|
||||
* TileJSON at ``/styles/{id}.json``
|
||||
|
||||
* The rendered tiles are not available in the ``tileserver-gl-light`` version.
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ Alternatively, you can use ``tileserver-gl-light`` package instead, which is pur
|
||||
From source
|
||||
===========
|
||||
|
||||
Make sure you have Node v4 (nvm install 4) and run::
|
||||
Make sure you have Node v6 (nvm install 6) and run::
|
||||
|
||||
npm install
|
||||
node .
|
||||
|
||||
20
package.json
20
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tileserver-gl",
|
||||
"version": "1.7.0",
|
||||
"version": "2.0.0",
|
||||
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
|
||||
"main": "src/main.js",
|
||||
"bin": "src/main.js",
|
||||
@@ -13,34 +13,34 @@
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=4.2.1 <5"
|
||||
"node": ">=6 <7"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/**.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mapbox/mapbox-gl-native": "3.4.4",
|
||||
"@mapbox/mapbox-gl-native": "3.5.4",
|
||||
"@mapbox/mbtiles": "0.9.0",
|
||||
"@mapbox/sphericalmercator": "1.0.5",
|
||||
"@mapbox/vector-tile": "1.3.0",
|
||||
"advanced-pool": "0.3.2",
|
||||
"base64url": "2.0.0",
|
||||
"canvas": "1.6.5",
|
||||
"clone": "2.1.1",
|
||||
"color": "1.0.3",
|
||||
"cors": "2.8.3",
|
||||
"express": "4.15.2",
|
||||
"express": "4.15.3",
|
||||
"glyph-pbf-composite": "0.0.2",
|
||||
"handlebars": "4.0.8",
|
||||
"handlebars": "4.0.10",
|
||||
"http-shutdown": "^1.2.0",
|
||||
"mbtiles": "0.9.0",
|
||||
"morgan": "1.8.1",
|
||||
"morgan": "1.8.2",
|
||||
"node-pngquant-native": "1.0.4",
|
||||
"nomnom": "1.8.1",
|
||||
"pbf": "3.0.5",
|
||||
"proj4": "2.4.3",
|
||||
"request": "2.81.0",
|
||||
"sharp": "0.17.3",
|
||||
"tileserver-gl-styles": "1.1.1",
|
||||
"vector-tile": "1.3.0"
|
||||
"sharp": "0.18.1",
|
||||
"tileserver-gl-styles": "1.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"should": "^11.2.0",
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
{{#each styles}}
|
||||
<div class="item">
|
||||
{{#if thumbnail}}
|
||||
<img src="/styles/{{@key}}/rendered/{{thumbnail}}{{&../key_query}}" alt="{{name}} preview" />
|
||||
<img src="/styles/{{@key}}/{{thumbnail}}{{&../key_query}}" alt="{{name}} preview" />
|
||||
{{else}}
|
||||
<img src="/images/placeholder.png" alt="{{name}} preview" />
|
||||
{{/if}}
|
||||
@@ -35,10 +35,10 @@
|
||||
<p class="services">
|
||||
services:
|
||||
{{#if serving_data}}
|
||||
<a href="/styles/{{@key}}.json{{&../key_query}}">GL Style</a>
|
||||
<a href="/styles/{{@key}}/style.json{{&../key_query}}">GL Style</a>
|
||||
{{/if}}
|
||||
{{#if serving_rendered}}
|
||||
{{#if serving_data}}| {{/if}}<a href="/styles/{{@key}}/rendered.json{{&../key_query}}">TileJSON</a>
|
||||
{{#if serving_data}}| {{/if}}<a href="/styles/{{@key}}.json{{&../key_query}}">TileJSON</a>
|
||||
{{/if}}
|
||||
{{#if wmts_link}}
|
||||
| <a href="{{&wmts_link}}">WMTS</a>
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
mapboxgl.setRTLTextPlugin('/mapbox-gl-rtl-text.js{{&key_query}}');
|
||||
var map = new mapboxgl.Map({
|
||||
container: 'map',
|
||||
style: '/styles/{{id}}.json{{&key_query}}',
|
||||
style: '/styles/{{id}}/style.json{{&key_query}}',
|
||||
hash: true
|
||||
});
|
||||
map.addControl(new mapboxgl.NavigationControl());
|
||||
} else {
|
||||
var map = L.mapbox.map('map', '/styles/{{id}}/rendered.json{{&key_query}}', { zoomControl: false });
|
||||
var map = L.mapbox.map('map', '/styles/{{id}}.json{{&key_query}}', { zoomControl: false });
|
||||
new L.Control.Zoom({ position: 'topright' }).addTo(map);
|
||||
setTimeout(function() {
|
||||
new L.Hash(map);
|
||||
|
||||
@@ -6,7 +6,7 @@ var fs = require('fs'),
|
||||
path = require('path'),
|
||||
request = require('request');
|
||||
|
||||
var mbtiles = require('mbtiles');
|
||||
var mbtiles = require('@mapbox/mbtiles');
|
||||
|
||||
var packageJson = require('../package');
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ var fs = require('fs'),
|
||||
|
||||
var clone = require('clone'),
|
||||
express = require('express'),
|
||||
mbtiles = require('mbtiles'),
|
||||
mbtiles = require('@mapbox/mbtiles'),
|
||||
pbf = require('pbf'),
|
||||
VectorTile = require('vector-tile').VectorTile;
|
||||
VectorTile = require('@mapbox/vector-tile').VectorTile;
|
||||
|
||||
var tileshrinkGl;
|
||||
try {
|
||||
|
||||
@@ -16,7 +16,7 @@ var Canvas = require('canvas'),
|
||||
express = require('express'),
|
||||
mercator = new (require('@mapbox/sphericalmercator'))(),
|
||||
mbgl = require('@mapbox/mapbox-gl-native'),
|
||||
mbtiles = require('mbtiles'),
|
||||
mbtiles = require('@mapbox/mbtiles'),
|
||||
pngquant = require('node-pngquant-native'),
|
||||
proj4 = require('proj4'),
|
||||
request = require('request');
|
||||
@@ -223,7 +223,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
}
|
||||
mbtilesFile = dataResolver(mbtilesFile);
|
||||
if (!mbtilesFile) {
|
||||
console.log('ERROR: data "' + mbtilesFile + '" not found!');
|
||||
console.error('ERROR: data "' + mbtilesFile + '" not found!');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
@@ -238,6 +238,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
map.sources[name].getInfo(function(err, info) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dataProjWGStoInternalWGS && info.proj4) {
|
||||
@@ -309,7 +310,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
|
||||
repo[id] = tileJSON;
|
||||
|
||||
var tilePattern = '/rendered/:z(\\d+)/:x(\\d+)/:y(\\d+)' +
|
||||
var tilePattern = '/' + id + '/:z(\\d+)/:x(\\d+)/:y(\\d+)' +
|
||||
':scale(' + scalePattern + ')?\.:format([\\w]+)';
|
||||
|
||||
var respondImage = function(z, lon, lat, bearing, pitch,
|
||||
@@ -348,7 +349,10 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
}
|
||||
renderer.render(params, function(err, data) {
|
||||
pool.release(renderer);
|
||||
if (err) console.log(err);
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
var image = sharp(data, {
|
||||
raw: {
|
||||
@@ -540,7 +544,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
|
||||
if (options.serveStaticMaps !== false) {
|
||||
var staticPattern =
|
||||
'/static/:raw(raw)?/%s/:width(\\d+)x:height(\\d+)' +
|
||||
'/' + id + '/static/:raw(raw)?/%s/:width(\\d+)x:height(\\d+)' +
|
||||
':scale(' + scalePattern + ')?\.:format([\\w]+)';
|
||||
|
||||
var centerPattern =
|
||||
@@ -624,7 +628,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
|
||||
app.get(util.format(staticPattern, boundsPattern), serveBounds);
|
||||
|
||||
app.get('/static/', function(req, res, next) {
|
||||
app.get('/' + id + '/static/', function(req, res, next) {
|
||||
for (var key in req.query) {
|
||||
req.query[key.toLowerCase()] = req.query[key];
|
||||
}
|
||||
@@ -690,10 +694,10 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/rendered.json', function(req, res, next) {
|
||||
app.get('/' + id + '.json', function(req, res, next) {
|
||||
var info = clone(tileJSON);
|
||||
info.tiles = utils.getTileUrls(req, info.tiles,
|
||||
'styles/' + id + '/rendered', info.format);
|
||||
'styles/' + id, info.format);
|
||||
return res.send(info);
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||
|
||||
repo[id] = styleJSON;
|
||||
|
||||
app.get('/' + id + '.json', function(req, res, next) {
|
||||
app.get('/' + id + '/style.json', function(req, res, next) {
|
||||
var fixUrl = function(url, opt_nokey, opt_nostyle) {
|
||||
if (!url || (typeof url !== 'string') || url.indexOf('local://') !== 0) {
|
||||
return url;
|
||||
|
||||
@@ -150,7 +150,7 @@ function start(opts) {
|
||||
return mbtilesFile;
|
||||
}
|
||||
).then(function(sub) {
|
||||
app.use('/styles/' + id + '/', sub);
|
||||
app.use('/styles/', sub);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
@@ -189,7 +189,7 @@ function start(opts) {
|
||||
name: styleJSON.name,
|
||||
id: id,
|
||||
url: req.protocol + '://' + req.headers.host +
|
||||
'/styles/' + id + '.json' + query
|
||||
'/styles/' + id + '/style.json' + query
|
||||
});
|
||||
});
|
||||
res.send(result);
|
||||
@@ -200,7 +200,7 @@ function start(opts) {
|
||||
var info = clone(serving[type][id]);
|
||||
var path = '';
|
||||
if (type == 'rendered') {
|
||||
path = 'styles/' + id + '/rendered';
|
||||
path = 'styles/' + id;
|
||||
} else {
|
||||
path = type + '/' + id;
|
||||
}
|
||||
@@ -288,11 +288,11 @@ function start(opts) {
|
||||
var query = req.query.key ? ('?key=' + req.query.key) : '';
|
||||
style.wmts_link = 'http://wmts.maptiler.com/' +
|
||||
base64url('http://' + req.headers.host +
|
||||
'/styles/' + id + '/rendered.json' + query) + '/wmts';
|
||||
'/styles/' + id + '.json' + query) + '/wmts';
|
||||
|
||||
var tiles = utils.getTileUrls(
|
||||
req, style.serving_rendered.tiles,
|
||||
'styles/' + id + '/rendered', style.serving_rendered.format);
|
||||
'styles/' + id, style.serving_rendered.format);
|
||||
style.xyz_link = tiles[0];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -71,6 +71,6 @@ describe('Metadata', function() {
|
||||
});
|
||||
});
|
||||
|
||||
testTileJSON('/styles/test-style/rendered.json');
|
||||
testTileJSON('/styles/test-style.json');
|
||||
testTileJSON('/data/openmaptiles.json');
|
||||
});
|
||||
|
||||
@@ -11,12 +11,12 @@ var testIs = function(url, type, status) {
|
||||
var prefix = 'test-style';
|
||||
|
||||
describe('Styles', function() {
|
||||
describe('/styles/' + prefix + '.json is valid style', function() {
|
||||
testIs('/styles/' + prefix + '.json', /application\/json/);
|
||||
describe('/styles/' + prefix + '/style.json is valid style', function() {
|
||||
testIs('/styles/' + prefix + '/style.json', /application\/json/);
|
||||
|
||||
it('contains expected properties', function(done) {
|
||||
supertest(app)
|
||||
.get('/styles/' + prefix + '.json')
|
||||
.get('/styles/' + prefix + '/style.json')
|
||||
.expect(function(res) {
|
||||
res.body.version.should.equal(8);
|
||||
res.body.name.should.be.String();
|
||||
@@ -27,8 +27,8 @@ describe('Styles', function() {
|
||||
}).end(done);
|
||||
});
|
||||
});
|
||||
describe('/styles/streets.json is not served', function() {
|
||||
testIs('/styles/streets.json', /./, 404);
|
||||
describe('/styles/streets/style.json is not served', function() {
|
||||
testIs('/styles/streets/style.json', /./, 404);
|
||||
});
|
||||
|
||||
describe('/styles/' + prefix + '/sprite[@2x].{format}', function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var testTile = function(prefix, z, x, y, format, status, scale, type) {
|
||||
if (scale) y += '@' + scale + 'x';
|
||||
var path = '/styles/' + prefix + '/rendered/' + z + '/' + x + '/' + y + '.' + format;
|
||||
var path = '/styles/' + prefix + '/' + z + '/' + x + '/' + y + '.' + format;
|
||||
it(path + ' returns ' + status, function(done) {
|
||||
var test = supertest(app).get(path);
|
||||
test.expect(status);
|
||||
|
||||
Reference in New Issue
Block a user