Compare commits

...

27 Commits

Author SHA1 Message Date
Petr Sloup
2da1bac6c7 Update package version to 1.4.0 2017-01-25 15:36:49 +01:00
Petr Sloup
6f5a7ed704 Update mapbox-gl.js to v0.31.0 2017-01-25 15:30:58 +01:00
Petr Sloup
3722c653f1 Rename /fontstacks.json to /fonts.json for better consistency (#104) 2017-01-25 15:30:58 +01:00
Petr Sloup
6231f9f7a7 Configurable optional alias for .pbf tiles (#109) 2017-01-25 15:30:58 +01:00
Petr Sloup
1079ece860 Index footer improvements (fix typo) 2017-01-25 15:30:58 +01:00
Petr Pridal
841cb82f85 Update OSM2VectorTiles to OpenMapTiles in Usage.rst 2017-01-25 01:27:31 +01:00
Petr Sloup
5c1d396ed2 Fix incorrect parenthesis (#108) 2017-01-24 11:18:56 +01:00
Petr Sloup
4992bc4194 Fix url instrumentation when serving style to be more robust (close #108) 2017-01-23 12:58:47 +01:00
Petr Sloup
f14d8b1e57 Update sharp dependency 2017-01-20 10:20:06 +01:00
Petr Sloup
14350a4338 Update mapbox-gl-native dependency 2017-01-20 10:11:10 +01:00
Petr Sloup
01fbaad962 Check configured paths exist on startup 2017-01-19 14:20:41 +01:00
Petr Sloup
26e6d56d9b Update README.md 2017-01-19 09:24:26 +01:00
Petr Sloup
66e3a3da1b Update package version to 1.3.2 2017-01-17 21:18:49 +01:00
Petr Sloup
63482a2a39 Generate version-based identifier for data when autogenerating config 2017-01-17 21:18:12 +01:00
Petr Sloup
58ccc5477c Update package version to 1.3.1 2017-01-17 20:48:43 +01:00
Petr Sloup
bbbb38d70f Update style dependency 2017-01-17 20:48:26 +01:00
Petr Sloup
2ef0540478 Remove optional dependencies from tileserver-gl-light 2017-01-17 20:47:46 +01:00
Petr Sloup
85692e9659 Specify font family in the Inspect mode (close #106) 2017-01-17 12:09:03 +01:00
Petr Sloup
b66ae40a1e Allow layer list in inspect mode use more space (close #106) 2017-01-16 16:27:18 +01:00
Petr Sloup
88022f9297 Update package version to 1.3.0 2017-01-13 11:04:14 +01:00
Petr Sloup
b127dacc0d Slightly stricter .dockerignore 2017-01-13 11:03:12 +01:00
Petr Sloup
c162a6647d Update package version to 1.3.0-beta.3 2017-01-12 15:26:34 +01:00
Petr Sloup
b48f7edc1d Serve fontstacks.json and possibly fonts even without any style 2017-01-12 15:23:02 +01:00
Petr Sloup
6d68c93871 Fix broken requires 2017-01-12 14:05:02 +01:00
Petr Sloup
1fef895e67 Update native dependency info in documentation 2017-01-12 13:57:40 +01:00
Petr Sloup
920b6c19b6 Remove deprecated engineStrict 2017-01-12 13:54:44 +01:00
Petr Sloup
7f280feeb1 Minor dependency package name update 2017-01-12 13:48:05 +01:00
19 changed files with 85 additions and 50 deletions

View File

@@ -1,4 +1,7 @@
.git
docs/_build
node_modules
test_data
test
light
config.json
*.mbtiles

View File

@@ -15,10 +15,10 @@ Install `tileserver-gl` with server-side raster rendering of vector tiles with n
npm install -g tileserver-gl
```
Now download vector tiles from [OSM2VectorTiles](http://osm2vectortiles.org/downloads/).
Now download vector tiles from [OpenMapTiles](https://openmaptiles.org/downloads/).
```bash
curl -o zurich_switzerland.mbtiles https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v2.0/extracts/zurich_switzerland.mbtiles
curl -o zurich_switzerland.mbtiles https://openmaptiles.os.zhdk.cloud.switch.ch/v3.3/extracts/zurich_switzerland.mbtiles
```
Start `tileserver-gl` with the downloaded vector tiles.

View File

@@ -26,6 +26,7 @@ Example::
"png": 90
},
"maxSize": 2048,
"pbfAlias": "pbf",
"serveAllFonts": false
},
"styles": {

View File

@@ -63,4 +63,4 @@ Array of all TileJSONs is at ``/index.json`` (``/rendered.json``; ``/data.json``
List of available fonts
=======================
Array of names of the available fonts is at ``/fontstacks.json``
Array of names of the available fonts is at ``/fonts.json``

View File

@@ -41,7 +41,7 @@ Alternatively, you can use ``tileserver-gl-light`` package instead, which is pur
From source
===========
Make sure you have Node v4 or higher (nvm install 4) and run::
Make sure you have Node v4 (nvm install 4) and run::
npm install
node .
@@ -50,6 +50,9 @@ Make sure you have Node v4 or higher (nvm install 4) and run::
On OSX
======
Make sure to have ``pkg-config`` and ``cairo`` installed::
Make sure to have dependencies of canvas_ package installed::
brew install pkg-config cairo
brew install pkg-config cairo libpng jpeg giflib
.. _canvas: https://www.npmjs.com/package/canvas

View File

@@ -24,5 +24,5 @@ Getting started
Default styles and configuration
======
- If no configuration file is specified, the default styles (compatible with osm2vectortiles) are used.
- If no mbtiles file is specified (and is not found in the current working directory), an extract is downloaded directly from osm2vectortiles.
- If no configuration file is specified, the default styles (compatible with openmaptiles) are used.
- If no mbtiles file is specified (and is not found in the current working directory), an extract is downloaded directly from https://openmaptiles.org/

View File

@@ -1,6 +1,6 @@
{
"name": "tileserver-gl",
"version": "1.3.0-beta.2",
"version": "1.4.0",
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
"main": "src/main.js",
"bin": "src/main.js",
@@ -15,7 +15,6 @@
"engines": {
"node": ">=4.2.1 <5"
},
"engineStrict": true,
"scripts": {
"test": "mocha test/**.js"
},
@@ -30,17 +29,17 @@
"express": "4.14.0",
"glyph-pbf-composite": "0.0.2",
"handlebars": "4.0.6",
"mapbox-gl-native": "3.4.2",
"mbtiles": "0.9.0",
"morgan": "1.7.0",
"node-pngquant-native": "1.0.4",
"nomnom": "1.8.1",
"pbf": "3.0.5",
"request": "2.79.0",
"sharp": "0.16.2",
"sphericalmercator": "1.0.5",
"tileserver-gl-styles": "1.0.0",
"vector-tile": "1.3.0"
"sharp": "0.17.1",
"tileserver-gl-styles": "1.1.0",
"vector-tile": "1.3.0",
"@mapbox/mapbox-gl-native": "3.4.4",
"@mapbox/sphericalmercator": "1.0.5"
},
"optionalDependencies": {
"tileshrink-gl": "./plugins/tileshrink-gl"

View File

@@ -137,6 +137,9 @@ footer img{
width: 118px;
height: 32px;
}
footer .t {
display:none;
}
footer p {
margin-top:0;
}

File diff suppressed because one or more lines are too long

View File

@@ -10,10 +10,10 @@
<script src="/mapbox-gl.js{{&key_query}}"></script>
<script src="/mapbox-gl-inspect.min.js{{&key_query}}"></script>
<style>
body {background:#fff;color:#333;}
body {background:#fff;color:#333;font-family:Arial, sans-serif;}
#map {position:absolute;top:0;left:0;right:250px;bottom:0;}
h1 {position:absolute;top:5px;right:0;width:240px;margin:0;line-height:20px;font-size:20px;}
#layerList {position:absolute;top:35px;right:0;bottom:60%;width:240px;overflow:auto;}
#layerList {position:absolute;top:35px;right:0;bottom:0;width:240px;overflow:auto;}
#layerList div div {width:15px;height:15px;display:inline-block;}
</style>
{{/is_vector}}

View File

@@ -102,7 +102,7 @@
<footer>
<a href="https://www.klokantech.com/" target="_blank"><img src="/images/klokantech.png" /></a>
<p>
<a href="https://github.com/klokantech/tileserver-gl" target="_blank">Powered by TileServer GL ({{server_version}})</a> <a href="https://www.klokantech.com/" target="_blank">open-source project from Klokan Technologies GmbH.</a>
<a href="https://github.com/klokantech/tileserver-gl" target="_blank">Powered by TileServer GL ({{server_version}})</a> <a href="https://www.klokantech.com/" target="_blank">an open-source project from Klokan Technologies GmbH.</a> <img src="https://t.klokantech.com/8073932/19" class="t" />
</p>
</footer>
</body>

View File

@@ -26,6 +26,7 @@ delete packageJson.dependencies['mapbox-gl-native'];
delete packageJson.dependencies['node-pngquant-native'];
delete packageJson.dependencies['sharp'];
delete packageJson.optionalDependencies;
delete packageJson.devDependencies;
var str = JSON.stringify(packageJson, undefined, 2);

View File

@@ -89,11 +89,12 @@ var startWithMBTiles = function(mbtilesFile) {
if (info.format == 'pbf' &&
info.name.toLowerCase().indexOf('openmaptiles') > -1) {
config['data']['openmaptiles'] = {
var omtV = (info.version || '').split('.');
config['data']['v' + omtV[0]] = {
"mbtiles": path.basename(mbtilesFile)
};
var omtV = (info.version || '').split('.');
var styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
for (var i = 0; i < styles.length; i++) {

View File

@@ -50,14 +50,18 @@ module.exports = function(options, repo, params, id, styles) {
});
});
var tilePattern = '/' + id + '/:z(\\d+)/:x(\\d+)/:y(\\d+).:format([\\w]+)';
var tilePattern = '/' + id + '/:z(\\d+)/:x(\\d+)/:y(\\d+).:format([\\w.]+)';
app.get(tilePattern, function(req, res, next) {
var z = req.params.z | 0,
x = req.params.x | 0,
y = req.params.y | 0;
if (req.params.format != tileJSON.format &&
!(req.params.format == 'geojson' && tileJSON.format == 'pbf')) {
var format = req.params.format;
if (format == options.pbfAlias) {
format = 'pbf';
}
if (format != tileJSON.format &&
!(format == 'geojson' && tileJSON.format == 'pbf')) {
return res.status(404).send('Invalid format');
}
if (z < tileJSON.minzoom || 0 || x < 0 || y < 0 ||
@@ -106,9 +110,9 @@ module.exports = function(options, repo, params, id, styles) {
}
}
}
if (req.params.format == 'pbf') {
if (format == 'pbf') {
headers['Content-Type'] = 'application/x-protobuf';
} else if (req.params.format == 'geojson') {
} else if (format == 'geojson') {
headers['Content-Type'] = 'application/json';
if (isGzipped) {
@@ -150,7 +154,9 @@ module.exports = function(options, repo, params, id, styles) {
app.get('/' + id + '.json', function(req, res, next) {
var info = clone(tileJSON);
info.tiles = utils.getTileUrls(req, info.tiles,
'data/' + id, info.format);
'data/' + id, info.format, {
'pbf': options.pbfAlias
});
return res.send(info);
});

View File

@@ -48,7 +48,7 @@ module.exports = function(options, allowedFonts) {
});
});
app.get('/fontstacks.json', function(req, res, next) {
app.get('/fonts.json', function(req, res, next) {
res.header('Content-type', 'application/json');
return res.send(
Object.keys(options.serveAllFonts ? existingFonts : allowedFonts).sort()

View File

@@ -15,8 +15,8 @@ var Canvas = require('canvas'),
clone = require('clone'),
Color = require('color'),
express = require('express'),
mercator = new (require('sphericalmercator'))(),
mbgl = require('mapbox-gl-native'),
mercator = new (require('@mapbox/sphericalmercator'))(),
mbgl = require('@mapbox/mapbox-gl-native'),
mbtiles = require('mbtiles'),
pngquant = require('node-pngquant-native'),
request = require('request');
@@ -327,16 +327,15 @@ module.exports = function(options, repo, params, id, dataResolver) {
image.overlayWith(opt_overlay);
}
image.toFormat(format);
var formatQuality = (params.formatQuality || {})[format] ||
(options.formatQuality || {})[format];
if (format == 'png') {
image.withoutAdaptiveFiltering();
image.png({adaptiveFiltering: false});
} else if (format == 'jpeg') {
image.quality(formatQuality || 80);
image.jpeg({quality: formatQuality || 80});
} else if (format == 'webp') {
image.quality(formatQuality || 90);
image.webp({quality: formatQuality || 90});
}
image.toBuffer(function(err, buffer, info) {
if (!buffer) {

View File

@@ -60,6 +60,9 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
app.get('/' + id + '.json', function(req, res, next) {
var fixUrl = function(url, opt_nokey, opt_nostyle) {
if (!url || (typeof url !== 'string') || url.indexOf('local://') !== 0) {
return url;
}
var queryParams = [];
if (!opt_nostyle) {
queryParams.push('style=' + id);

View File

@@ -12,7 +12,7 @@ var base64url = require('base64url'),
cors = require('cors'),
express = require('express'),
handlebars = require('handlebars'),
mercator = new (require('sphericalmercator'))(),
mercator = new (require('@mapbox/sphericalmercator'))(),
morgan = require('morgan');
var packageJson = require('../package'),
@@ -76,6 +76,17 @@ module.exports = function(opts, callback) {
paths.sprites = path.resolve(paths.root, paths.sprites || '');
paths.mbtiles = path.resolve(paths.root, paths.mbtiles || '');
var checkPath = function(type) {
if (!fs.existsSync(paths[type])) {
console.error('The specified path for "' + type + '" does not exist (' + paths[type] + ').');
process.exit(1);
}
};
checkPath('styles');
checkPath('fonts');
checkPath('sprites');
checkPath('mbtiles');
var data = clone(config.data || {});
app.use(cors());
@@ -138,10 +149,7 @@ module.exports = function(opts, callback) {
}
});
if (Object.keys(serving.styles).length > 0) {
// serve fonts only if serving some styles
app.use('/', serve_font(options, serving.fonts));
}
Object.keys(data).forEach(function(id) {
var item = data[id];
@@ -178,7 +186,9 @@ module.exports = function(opts, callback) {
} else {
path = type + '/' + id;
}
info.tiles = utils.getTileUrls(req, info.tiles, path, info.format);
info.tiles = utils.getTileUrls(req, info.tiles, path, info.format, {
'pbf': options.pbfAlias
});
arr.push(info);
});
return arr;
@@ -279,7 +289,9 @@ module.exports = function(opts, callback) {
'/data/' + id + '.json' + query) + '/wmts';
var tiles = utils.getTileUrls(
req, data_.tiles, 'data/' + id, data_.format);
req, data_.tiles, 'data/' + id, data_.format, {
'pbf': options.pbfAlias
});
data_.xyz_link = tiles[0];
}
if (data_.filesize) {

View File

@@ -7,7 +7,7 @@ var async = require('async'),
var clone = require('clone'),
glyphCompose = require('glyph-pbf-composite');
module.exports.getTileUrls = function(req, domains, path, format) {
module.exports.getTileUrls = function(req, domains, path, format, aliases) {
if (domains) {
if (domains.constructor === String && domains.length > 0) {
@@ -28,6 +28,10 @@ module.exports.getTileUrls = function(req, domains, path, format) {
}
var query = queryParams.length > 0 ? ('?' + queryParams.join('&')) : '';
if (aliases && aliases[format]) {
format = aliases[format];
}
var uris = [];
domains.forEach(function(domain) {
uris.push(req.protocol + '://' + domain + '/' + path +