Compare commits
21 Commits
v1.3.0-bet
...
v1.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2da1bac6c7 | ||
|
|
6f5a7ed704 | ||
|
|
3722c653f1 | ||
|
|
6231f9f7a7 | ||
|
|
1079ece860 | ||
|
|
841cb82f85 | ||
|
|
5c1d396ed2 | ||
|
|
4992bc4194 | ||
|
|
f14d8b1e57 | ||
|
|
14350a4338 | ||
|
|
01fbaad962 | ||
|
|
26e6d56d9b | ||
|
|
66e3a3da1b | ||
|
|
63482a2a39 | ||
|
|
58ccc5477c | ||
|
|
bbbb38d70f | ||
|
|
2ef0540478 | ||
|
|
85692e9659 | ||
|
|
b66ae40a1e | ||
|
|
88022f9297 | ||
|
|
b127dacc0d |
@@ -1,4 +1,7 @@
|
|||||||
.git
|
.git
|
||||||
|
docs/_build
|
||||||
node_modules
|
node_modules
|
||||||
test_data
|
test_data
|
||||||
test
|
light
|
||||||
|
config.json
|
||||||
|
*.mbtiles
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ Install `tileserver-gl` with server-side raster rendering of vector tiles with n
|
|||||||
npm install -g tileserver-gl
|
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
|
```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.
|
Start `tileserver-gl` with the downloaded vector tiles.
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ Example::
|
|||||||
"png": 90
|
"png": 90
|
||||||
},
|
},
|
||||||
"maxSize": 2048,
|
"maxSize": 2048,
|
||||||
|
"pbfAlias": "pbf",
|
||||||
"serveAllFonts": false
|
"serveAllFonts": false
|
||||||
},
|
},
|
||||||
"styles": {
|
"styles": {
|
||||||
|
|||||||
@@ -63,4 +63,4 @@ Array of all TileJSONs is at ``/index.json`` (``/rendered.json``; ``/data.json``
|
|||||||
|
|
||||||
List of available fonts
|
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``
|
||||||
|
|||||||
@@ -24,5 +24,5 @@ Getting started
|
|||||||
Default styles and configuration
|
Default styles and configuration
|
||||||
======
|
======
|
||||||
|
|
||||||
- If no configuration file is specified, the default styles (compatible with osm2vectortiles) are used.
|
- 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 osm2vectortiles.
|
- If no mbtiles file is specified (and is not found in the current working directory), an extract is downloaded directly from https://openmaptiles.org/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tileserver-gl",
|
"name": "tileserver-gl",
|
||||||
"version": "1.3.0-beta.3",
|
"version": "1.4.0",
|
||||||
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
|
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"bin": "src/main.js",
|
"bin": "src/main.js",
|
||||||
@@ -29,16 +29,16 @@
|
|||||||
"express": "4.14.0",
|
"express": "4.14.0",
|
||||||
"glyph-pbf-composite": "0.0.2",
|
"glyph-pbf-composite": "0.0.2",
|
||||||
"handlebars": "4.0.6",
|
"handlebars": "4.0.6",
|
||||||
"mapbox-gl-native": "3.4.2",
|
|
||||||
"mbtiles": "0.9.0",
|
"mbtiles": "0.9.0",
|
||||||
"morgan": "1.7.0",
|
"morgan": "1.7.0",
|
||||||
"node-pngquant-native": "1.0.4",
|
"node-pngquant-native": "1.0.4",
|
||||||
"nomnom": "1.8.1",
|
"nomnom": "1.8.1",
|
||||||
"pbf": "3.0.5",
|
"pbf": "3.0.5",
|
||||||
"request": "2.79.0",
|
"request": "2.79.0",
|
||||||
"sharp": "0.16.2",
|
"sharp": "0.17.1",
|
||||||
"tileserver-gl-styles": "1.0.0",
|
"tileserver-gl-styles": "1.1.0",
|
||||||
"vector-tile": "1.3.0",
|
"vector-tile": "1.3.0",
|
||||||
|
"@mapbox/mapbox-gl-native": "3.4.4",
|
||||||
"@mapbox/sphericalmercator": "1.0.5"
|
"@mapbox/sphericalmercator": "1.0.5"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ footer img{
|
|||||||
width: 118px;
|
width: 118px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
footer .t {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
footer p {
|
footer p {
|
||||||
margin-top:0;
|
margin-top:0;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -10,10 +10,10 @@
|
|||||||
<script src="/mapbox-gl.js{{&key_query}}"></script>
|
<script src="/mapbox-gl.js{{&key_query}}"></script>
|
||||||
<script src="/mapbox-gl-inspect.min.js{{&key_query}}"></script>
|
<script src="/mapbox-gl-inspect.min.js{{&key_query}}"></script>
|
||||||
<style>
|
<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;}
|
#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;}
|
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;}
|
#layerList div div {width:15px;height:15px;display:inline-block;}
|
||||||
</style>
|
</style>
|
||||||
{{/is_vector}}
|
{{/is_vector}}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
<footer>
|
<footer>
|
||||||
<a href="https://www.klokantech.com/" target="_blank"><img src="/images/klokantech.png" /></a>
|
<a href="https://www.klokantech.com/" target="_blank"><img src="/images/klokantech.png" /></a>
|
||||||
<p>
|
<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>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ delete packageJson.dependencies['mapbox-gl-native'];
|
|||||||
delete packageJson.dependencies['node-pngquant-native'];
|
delete packageJson.dependencies['node-pngquant-native'];
|
||||||
delete packageJson.dependencies['sharp'];
|
delete packageJson.dependencies['sharp'];
|
||||||
|
|
||||||
|
delete packageJson.optionalDependencies;
|
||||||
delete packageJson.devDependencies;
|
delete packageJson.devDependencies;
|
||||||
|
|
||||||
var str = JSON.stringify(packageJson, undefined, 2);
|
var str = JSON.stringify(packageJson, undefined, 2);
|
||||||
|
|||||||
@@ -89,11 +89,12 @@ var startWithMBTiles = function(mbtilesFile) {
|
|||||||
|
|
||||||
if (info.format == 'pbf' &&
|
if (info.format == 'pbf' &&
|
||||||
info.name.toLowerCase().indexOf('openmaptiles') > -1) {
|
info.name.toLowerCase().indexOf('openmaptiles') > -1) {
|
||||||
config['data']['openmaptiles'] = {
|
var omtV = (info.version || '').split('.');
|
||||||
|
|
||||||
|
config['data']['v' + omtV[0]] = {
|
||||||
"mbtiles": path.basename(mbtilesFile)
|
"mbtiles": path.basename(mbtilesFile)
|
||||||
};
|
};
|
||||||
|
|
||||||
var omtV = (info.version || '').split('.');
|
|
||||||
|
|
||||||
var styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
var styles = fs.readdirSync(path.resolve(styleDir, 'styles'));
|
||||||
for (var i = 0; i < styles.length; i++) {
|
for (var i = 0; i < styles.length; i++) {
|
||||||
|
|||||||
@@ -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) {
|
app.get(tilePattern, function(req, res, next) {
|
||||||
var z = req.params.z | 0,
|
var z = req.params.z | 0,
|
||||||
x = req.params.x | 0,
|
x = req.params.x | 0,
|
||||||
y = req.params.y | 0;
|
y = req.params.y | 0;
|
||||||
if (req.params.format != tileJSON.format &&
|
var format = req.params.format;
|
||||||
!(req.params.format == 'geojson' && tileJSON.format == 'pbf')) {
|
if (format == options.pbfAlias) {
|
||||||
|
format = 'pbf';
|
||||||
|
}
|
||||||
|
if (format != tileJSON.format &&
|
||||||
|
!(format == 'geojson' && tileJSON.format == 'pbf')) {
|
||||||
return res.status(404).send('Invalid format');
|
return res.status(404).send('Invalid format');
|
||||||
}
|
}
|
||||||
if (z < tileJSON.minzoom || 0 || x < 0 || y < 0 ||
|
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';
|
headers['Content-Type'] = 'application/x-protobuf';
|
||||||
} else if (req.params.format == 'geojson') {
|
} else if (format == 'geojson') {
|
||||||
headers['Content-Type'] = 'application/json';
|
headers['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
if (isGzipped) {
|
if (isGzipped) {
|
||||||
@@ -150,7 +154,9 @@ module.exports = function(options, repo, params, id, styles) {
|
|||||||
app.get('/' + id + '.json', function(req, res, next) {
|
app.get('/' + id + '.json', function(req, res, next) {
|
||||||
var info = clone(tileJSON);
|
var info = clone(tileJSON);
|
||||||
info.tiles = utils.getTileUrls(req, info.tiles,
|
info.tiles = utils.getTileUrls(req, info.tiles,
|
||||||
'data/' + id, info.format);
|
'data/' + id, info.format, {
|
||||||
|
'pbf': options.pbfAlias
|
||||||
|
});
|
||||||
return res.send(info);
|
return res.send(info);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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');
|
res.header('Content-type', 'application/json');
|
||||||
return res.send(
|
return res.send(
|
||||||
Object.keys(options.serveAllFonts ? existingFonts : allowedFonts).sort()
|
Object.keys(options.serveAllFonts ? existingFonts : allowedFonts).sort()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var Canvas = require('canvas'),
|
|||||||
Color = require('color'),
|
Color = require('color'),
|
||||||
express = require('express'),
|
express = require('express'),
|
||||||
mercator = new (require('@mapbox/sphericalmercator'))(),
|
mercator = new (require('@mapbox/sphericalmercator'))(),
|
||||||
mbgl = require('mapbox-gl-native'),
|
mbgl = require('@mapbox/mapbox-gl-native'),
|
||||||
mbtiles = require('mbtiles'),
|
mbtiles = require('mbtiles'),
|
||||||
pngquant = require('node-pngquant-native'),
|
pngquant = require('node-pngquant-native'),
|
||||||
request = require('request');
|
request = require('request');
|
||||||
@@ -327,16 +327,15 @@ module.exports = function(options, repo, params, id, dataResolver) {
|
|||||||
image.overlayWith(opt_overlay);
|
image.overlayWith(opt_overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
image.toFormat(format);
|
|
||||||
|
|
||||||
var formatQuality = (params.formatQuality || {})[format] ||
|
var formatQuality = (params.formatQuality || {})[format] ||
|
||||||
(options.formatQuality || {})[format];
|
(options.formatQuality || {})[format];
|
||||||
|
|
||||||
if (format == 'png') {
|
if (format == 'png') {
|
||||||
image.withoutAdaptiveFiltering();
|
image.png({adaptiveFiltering: false});
|
||||||
} else if (format == 'jpeg') {
|
} else if (format == 'jpeg') {
|
||||||
image.quality(formatQuality || 80);
|
image.jpeg({quality: formatQuality || 80});
|
||||||
} else if (format == 'webp') {
|
} else if (format == 'webp') {
|
||||||
image.quality(formatQuality || 90);
|
image.webp({quality: formatQuality || 90});
|
||||||
}
|
}
|
||||||
image.toBuffer(function(err, buffer, info) {
|
image.toBuffer(function(err, buffer, info) {
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
|||||||
|
|
||||||
app.get('/' + id + '.json', function(req, res, next) {
|
app.get('/' + id + '.json', function(req, res, next) {
|
||||||
var fixUrl = function(url, opt_nokey, opt_nostyle) {
|
var fixUrl = function(url, opt_nokey, opt_nostyle) {
|
||||||
|
if (!url || (typeof url !== 'string') || url.indexOf('local://') !== 0) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
var queryParams = [];
|
var queryParams = [];
|
||||||
if (!opt_nostyle) {
|
if (!opt_nostyle) {
|
||||||
queryParams.push('style=' + id);
|
queryParams.push('style=' + id);
|
||||||
|
|||||||
@@ -76,6 +76,17 @@ module.exports = function(opts, callback) {
|
|||||||
paths.sprites = path.resolve(paths.root, paths.sprites || '');
|
paths.sprites = path.resolve(paths.root, paths.sprites || '');
|
||||||
paths.mbtiles = path.resolve(paths.root, paths.mbtiles || '');
|
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 || {});
|
var data = clone(config.data || {});
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
@@ -175,7 +186,9 @@ module.exports = function(opts, callback) {
|
|||||||
} else {
|
} else {
|
||||||
path = type + '/' + id;
|
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);
|
arr.push(info);
|
||||||
});
|
});
|
||||||
return arr;
|
return arr;
|
||||||
@@ -276,7 +289,9 @@ module.exports = function(opts, callback) {
|
|||||||
'/data/' + id + '.json' + query) + '/wmts';
|
'/data/' + id + '.json' + query) + '/wmts';
|
||||||
|
|
||||||
var tiles = utils.getTileUrls(
|
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];
|
data_.xyz_link = tiles[0];
|
||||||
}
|
}
|
||||||
if (data_.filesize) {
|
if (data_.filesize) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ var async = require('async'),
|
|||||||
var clone = require('clone'),
|
var clone = require('clone'),
|
||||||
glyphCompose = require('glyph-pbf-composite');
|
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) {
|
||||||
if (domains.constructor === String && domains.length > 0) {
|
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('&')) : '';
|
var query = queryParams.length > 0 ? ('?' + queryParams.join('&')) : '';
|
||||||
|
|
||||||
|
if (aliases && aliases[format]) {
|
||||||
|
format = aliases[format];
|
||||||
|
}
|
||||||
|
|
||||||
var uris = [];
|
var uris = [];
|
||||||
domains.forEach(function(domain) {
|
domains.forEach(function(domain) {
|
||||||
uris.push(req.protocol + '://' + domain + '/' + path +
|
uris.push(req.protocol + '://' + domain + '/' + path +
|
||||||
|
|||||||
Reference in New Issue
Block a user