Compare commits

...

21 Commits

Author SHA1 Message Date
Petr Sloup 21883f490f Update package version to 1.2.0 2016-12-05 16:45:27 +01:00
Petr Sloup 70515947ca Merge pull request #73 from LKajan/x-ray-points
X-Ray style: add circle symbols for point layers
2016-12-05 16:42:16 +01:00
Lauri Kajan 63090802ae fixing typo 2016-11-16 11:28:15 +02:00
Lauri Kajan 131b5e2f81 added circle symbols for point layers 2016-11-16 10:16:14 +02:00
Petr Sloup 6e085af7cc Update package version to 1.1.5 2016-10-25 12:16:07 +02:00
Petr Sloup 345d96d5e6 Fix static endpoints for (near-)whole-world queries (close #63) 2016-10-21 14:49:39 +02:00
Petr Sloup f1c835c21d Update package version to 1.1.4 2016-10-07 15:21:58 +02:00
Petr Sloup 15ed6d74bf Fix incorrect XYZ URLs (close #58) 2016-10-07 15:21:12 +02:00
Petr Sloup a3d8240aac Do not add scale prefix when viewing raster data tiles (close #57) 2016-10-07 11:16:22 +02:00
Petr Sloup 098f057e55 Update package version to 1.1.3 2016-09-30 09:51:20 +02:00
Petr Sloup 18ba6f5059 Ignore tiling scheme of the source for internal meta urls (#54) 2016-09-30 09:50:05 +02:00
Petr Sloup 820dbdd3dd Update package version to 1.1.2 2016-09-27 17:34:39 +02:00
Petr Sloup acd7683f18 Update dependencies 2016-09-27 17:30:24 +02:00
Petr Sloup 09859c10c1 Serve any vector/raster mbtiles, use styles only for osm2vt (close #51, #52) 2016-09-27 17:26:05 +02:00
Petr Sloup f201deecdc Merge pull request #48 from rastapasta/patch-1
adding info for OSX setup
2016-09-22 08:55:41 +02:00
Petr Pridal b49521d2ed Update README.md 2016-09-01 17:53:15 +02:00
Michael Straßburger 30c9bc8979 adding info for OSX setup 2016-08-29 12:31:33 +02:00
Petr Sloup 69340bbc83 Update package version to 1.1.1 2016-08-25 12:52:51 +02:00
Petr Sloup ff9d5a8e5d Update READMEs and descriptions 2016-08-25 12:52:32 +02:00
Petr Sloup 23c2aa54d0 Update tests 2016-08-25 11:09:01 +02:00
Petr Sloup a8fd1b38b7 Return 404 for negative zoom levels on static endpoint 2016-08-25 11:08:19 +02:00
11 changed files with 124 additions and 41 deletions
+34 -6
View File
@@ -1,18 +1,46 @@
![tileserver-gl](https://cloud.githubusercontent.com/assets/59284/18173467/fa3aa2ca-7069-11e6-86b1-0f1266befeb6.jpeg)
# TileServer GL # TileServer GL
[![Build Status](https://travis-ci.org/klokantech/tileserver-gl.svg?branch=master)](https://travis-ci.org/klokantech/tileserver-gl) [![Build Status](https://travis-ci.org/klokantech/tileserver-gl.svg?branch=master)](https://travis-ci.org/klokantech/tileserver-gl)
[![Docker Hub](https://img.shields.io/badge/docker-hub-blue.svg)](https://hub.docker.com/r/klokantech/tileserver-gl/) [![Docker Hub](https://img.shields.io/badge/docker-hub-blue.svg)](https://hub.docker.com/r/klokantech/tileserver-gl/)
Vector and raster maps with GL styles. Server side rendering by Mapbox GL Native. Map tile server for Mapbox GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
## Quickstart ## Get Started
Use `npm install -g tileserver-gl` to install the package from npm.
Then you can simply run `tileserver-gl zurich_switzerland.mbtiles` to start the server for the given mbtiles. Install `tileserver-gl` with server-side raster rendering of vector tiles with npm
Alternatively, you can use `tileserver-gl-light` package instead, which is pure javascript (does not have any native dependencies) and can run anywhere, but does not contain rasterization features. ```bash
npm install -g tileserver-gl
```
Or you can use `docker run -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl` to run the server inside a docker container. Now download vector tiles from [OSM2VectorTiles](http://osm2vectortiles.org/downloads/).
Prepared vector tiles can be downloaded from [OSM2VectorTiles](http://osm2vectortiles.org/). ```bash
curl -o zurich_switzerland.mbtiles https://osm2vectortiles-downloads.os.zhdk.cloud.switch.ch/v2.0/extracts/zurich_switzerland.mbtiles
```
Start `tileserver-gl` with the downloaded vector tiles.
```bash
tileserver-gl zurich_switzerland.mbtiles
```
Alternatively, you can use the `tileserver-gl-light` package instead, which is pure javascript (does not have any native dependencies) and can run anywhere, but does not contain rasterization on the server side made with MapBox GL Native.
## Using Docker
An alternative to npm to start the packed software easier is to install [Docker](http://www.docker.com/) on your computer and then run in the directory with the downloaded MBTiles the command:
```bash
docker run -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl
```
This will download and start a ready to use container on your computer and the maps are going to be available in webbrowser on localhost:8080.
On laptop you can use [Docker Kitematic](https://kitematic.com/) and search "tileserver-gl" and run it, then drop in the 'data' folder the MBTiles.
## Documentation ## Documentation
You can read full documentation of this project at http://tileserver.readthedocs.io/. You can read full documentation of this project at http://tileserver.readthedocs.io/.
+17
View File
@@ -0,0 +1,17 @@
# TileServer GL light
[![Build Status](https://travis-ci.org/klokantech/tileserver-gl.svg?branch=master)](https://travis-ci.org/klokantech/tileserver-gl)
[![Docker Hub](https://img.shields.io/badge/docker-hub-blue.svg)](https://hub.docker.com/r/klokantech/tileserver-gl/)
Vector maps with GL styles. Map tile server for Mapbox Android, iOS, GL JS, Leaflet, OpenLayers, etc. without server side rendering.
## Quickstart
Use `npm install -g tileserver-gl-light` to install the package from npm.
Then you can simply run `tileserver-gl-light zurich_switzerland.mbtiles` to start the server for the given mbtiles.
See also `tileserver-gl` which contains server side rendering.
Prepared vector tiles can be downloaded from [OSM2VectorTiles](http://osm2vectortiles.org/).
## Documentation
You can read full documentation of this project at http://tileserver.readthedocs.io/.
+8
View File
@@ -27,3 +27,11 @@ Make sure you have Node v4 or higher (nvm install 4) and run::
npm install npm install
node . node .
On OSX
======
Make sure to have ``pkg-config`` and ``cairo`` installed::
brew install pkg-config cairo
+6 -6
View File
@@ -1,7 +1,7 @@
{ {
"name": "tileserver-gl", "name": "tileserver-gl",
"version": "1.1.0", "version": "1.2.0",
"description": "Map tile server for JSON GL styles - serverside 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",
"authors": [ "authors": [
@@ -19,19 +19,19 @@
"async": "2.0.1", "async": "2.0.1",
"advanced-pool": "0.3.2", "advanced-pool": "0.3.2",
"base64url": "2.0.0", "base64url": "2.0.0",
"canvas": "1.4.0", "canvas": "1.5.0",
"clone": "1.0.2", "clone": "1.0.2",
"color": "0.11.3", "color": "0.11.3",
"cors": "2.8.0", "cors": "2.8.1",
"express": "4.14.0", "express": "4.14.0",
"glyph-pbf-composite": "0.0.2", "glyph-pbf-composite": "0.0.2",
"handlebars": "4.0.5", "handlebars": "4.0.5",
"mapbox-gl-native": "3.3.2", "mapbox-gl-native": "3.3.3",
"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",
"request": "2.74.0", "request": "2.75.0",
"sharp": "0.16.0", "sharp": "0.16.0",
"sphericalmercator": "1.0.5", "sphericalmercator": "1.0.5",
"tileserver-gl-styles": "0.3.0" "tileserver-gl-styles": "0.3.0"
+14
View File
@@ -69,6 +69,16 @@
type: 'line', type: 'line',
paint: {'line-color': colorText} paint: {'line-color': colorText}
}); });
layers_.push({
id: el['id'] + Math.random(),
source: 'vector_layer_',
'source-layer': el['id'],
interactive: true,
type: 'circle',
paint: {'circle-color': colorText,
'circle-radius': 3},
filter: ["==", "$type", "Point"]
});
var item = document.createElement('div'); var item = document.createElement('div');
item.innerHTML = '<div style="' + item.innerHTML = '<div style="' +
'background:rgba(' + color[0] + ',' + color[1] + ',' + color[2] + ',1);' + 'background:rgba(' + color[0] + ',' + color[1] + ',' + color[2] + ',1);' +
@@ -124,6 +134,10 @@
<div id='map'></div> <div id='map'></div>
<script> <script>
var map = L.mapbox.map('map', '/data/{{id}}.json{{&key_query}}', { zoomControl: false }); var map = L.mapbox.map('map', '/data/{{id}}.json{{&key_query}}', { zoomControl: false });
map.eachLayer(function(layer) {
// do not add scale prefix even if retina display is detected
layer.scalePrefix = '.';
});
new L.Control.Zoom({ position: 'topright' }).addTo(map); new L.Control.Zoom({ position: 'topright' }).addTo(map);
setTimeout(function() { setTimeout(function() {
new L.Hash(map); new L.Hash(map);
+2
View File
@@ -20,6 +20,7 @@ var fs = require('fs');
var packageJson = require('./package'); var packageJson = require('./package');
packageJson.name += '-light'; packageJson.name += '-light';
packageJson.description = 'Map tile server for JSON GL styles - serving vector tiles';
delete packageJson.dependencies['canvas']; delete packageJson.dependencies['canvas'];
delete packageJson.dependencies['mapbox-gl-native']; delete packageJson.dependencies['mapbox-gl-native'];
delete packageJson.dependencies['node-pngquant-native']; delete packageJson.dependencies['node-pngquant-native'];
@@ -29,6 +30,7 @@ delete packageJson.devDependencies;
var str = JSON.stringify(packageJson, undefined, 2); var str = JSON.stringify(packageJson, undefined, 2);
fs.writeFileSync('light/package.json', str); fs.writeFileSync('light/package.json', str);
fs.renameSync('light/README_light.md', 'light/README.md');
/* PUBLISH */ /* PUBLISH */
+14 -9
View File
@@ -70,10 +70,6 @@ var startWithMBTiles = function(mbtilesFile) {
} }
var instance = new mbtiles(mbtilesFile, function(err) { var instance = new mbtiles(mbtilesFile, function(err) {
instance.getInfo(function(err, info) { instance.getInfo(function(err, info) {
if (info.format != 'pbf') {
console.log('ERROR: MBTiles format is not "pbf".');
process.exit(1);
}
var bounds = info.bounds; var bounds = info.bounds;
var styleDir = path.resolve(__dirname, "../node_modules/tileserver-gl-styles/"); var styleDir = path.resolve(__dirname, "../node_modules/tileserver-gl-styles/");
@@ -89,15 +85,17 @@ var startWithMBTiles = function(mbtilesFile) {
} }
}, },
"styles": {}, "styles": {},
"data": { "data": {}
"osm2vectortiles": { };
if (info.format == 'pbf' &&
info.name.toLowerCase().indexOf('osm2vectortiles') > -1) {
config['data']['osm2vectortiles'] = {
"mbtiles": path.basename(mbtilesFile) "mbtiles": path.basename(mbtilesFile)
}
}
}; };
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++) {
var styleFilename = styles[i]; var styleFilename = styles[i];
if (styleFilename.endsWith('.json')) { if (styleFilename.endsWith('.json')) {
var styleObject = { var styleObject = {
@@ -110,6 +108,13 @@ var startWithMBTiles = function(mbtilesFile) {
styleObject; styleObject;
} }
} }
} else {
console.log('WARN: MBTiles not in "osm2vectortiles" format. ' +
'Serving raw data only...');
config['data'][info.id || 'mbtiles'] = {
"mbtiles": path.basename(mbtilesFile)
};
}
if (opts.verbose) { if (opts.verbose) {
console.log(JSON.stringify(config, undefined, 2)); console.log(JSON.stringify(config, undefined, 2));
+11 -4
View File
@@ -202,6 +202,7 @@ module.exports = function(options, repo, params, id, dataResolver) {
// meta url which will be detected when requested // meta url which will be detected when requested
'mbtiles://' + name + '/{z}/{x}/{y}.' + (info.format || 'pbf') 'mbtiles://' + name + '/{z}/{x}/{y}.' + (info.format || 'pbf')
]; ];
delete source.scheme;
if (source.format == 'pbf') { if (source.format == 'pbf') {
map.sources[name].emptyTile = new Buffer(0); map.sources[name].emptyTile = new Buffer(0);
} else { } else {
@@ -431,14 +432,16 @@ module.exports = function(options, repo, params, id, dataResolver) {
var minCorner = mercator.px([bbox[0], bbox[3]], z), var minCorner = mercator.px([bbox[0], bbox[3]], z),
maxCorner = mercator.px([bbox[2], bbox[1]], z); maxCorner = mercator.px([bbox[2], bbox[1]], z);
w /= (1 + 2 * padding); var w_ = w / (1 + 2 * padding);
h /= (1 + 2 * padding); var h_ = h / (1 + 2 * padding);
z -= Math.max( z -= Math.max(
Math.log((maxCorner[0] - minCorner[0]) / w), Math.log((maxCorner[0] - minCorner[0]) / w_),
Math.log((maxCorner[1] - minCorner[1]) / h) Math.log((maxCorner[1] - minCorner[1]) / h_)
) / Math.LN2; ) / Math.LN2;
z = Math.max(Math.log(Math.max(w, h) / 256) / Math.LN2, Math.min(25, z));
return z; return z;
}; };
@@ -462,6 +465,10 @@ module.exports = function(options, repo, params, id, dataResolver) {
scale = getScale(req.params.scale), scale = getScale(req.params.scale),
format = req.params.format; format = req.params.format;
if (z < 0) {
return res.status(404).send('Invalid zoom');
}
var path = extractPathFromQuery(req.query); var path = extractPathFromQuery(req.query);
var overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale, var overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale,
path, req.query); path, req.query);
+1 -1
View File
@@ -249,7 +249,7 @@ module.exports = function(opts, callback) {
var tiles = utils.getTileUrls( var tiles = utils.getTileUrls(
req, style.serving_rendered.tiles, req, style.serving_rendered.tiles,
'styles/' + id, style.serving_rendered.format); 'styles/' + id + '/rendered', style.serving_rendered.format);
style.xyz_link = tiles[0]; style.xyz_link = tiles[0];
} }
}); });
+2 -1
View File
@@ -28,6 +28,8 @@ describe('Static endpoints', function() {
testStatic(prefix, '0,0,0/300x300', 'png', 200, 2); testStatic(prefix, '0,0,0/300x300', 'png', 200, 2);
testStatic(prefix, '0,0,0/300x300', 'png', 200, 3); testStatic(prefix, '0,0,0/300x300', 'png', 200, 3);
testStatic(prefix, '0,0,1.5/256x256', 'png', 200);
testStatic(prefix, '80,40,20/600x300', 'png', 200, 3); testStatic(prefix, '80,40,20/600x300', 'png', 200, 3);
testStatic(prefix, '8.5,40.5,20/300x150', 'png', 200, 3); testStatic(prefix, '8.5,40.5,20/300x150', 'png', 200, 3);
testStatic(prefix, '-8.5,-40.5,20/300x150', 'png', 200, 3); testStatic(prefix, '-8.5,-40.5,20/300x150', 'png', 200, 3);
@@ -48,7 +50,6 @@ describe('Static endpoints', function() {
testStatic(prefix, '0,0,0/256x256', 'png', 404, 1); testStatic(prefix, '0,0,0/256x256', 'png', 404, 1);
testStatic(prefix, '0,0,-1/256x256', 'png', 404); testStatic(prefix, '0,0,-1/256x256', 'png', 404);
testStatic(prefix, '0,0,1.5/256x256', 'png', 404);
testStatic(prefix, '0,0,0/256.5x256.5', 'png', 404); testStatic(prefix, '0,0,0/256.5x256.5', 'png', 404);
testStatic(prefix, '0,0,0,/256x256', 'png', 404); testStatic(prefix, '0,0,0,/256x256', 'png', 404);
+2 -1
View File
@@ -26,6 +26,7 @@ describe('Raster tiles', function() {
testTile(prefix, 0, 0, 0, 'png', 200, 2); testTile(prefix, 0, 0, 0, 'png', 200, 2);
testTile(prefix, 0, 0, 0, 'png', 200, 3); testTile(prefix, 0, 0, 0, 'png', 200, 3);
testTile(prefix, 2, 1, 1, 'png', 200, 3); testTile(prefix, 2, 1, 1, 'png', 200, 3);
testTile(prefix, 0, 0, 0, 'png', 200, 4);
}); });
}); });
@@ -39,7 +40,7 @@ describe('Raster tiles', function() {
testTile(prefix, 0, 0, 0, 'pbf', 400); testTile(prefix, 0, 0, 0, 'pbf', 400);
testTile(prefix, 0, 0, 0, 'png', 404, 1); testTile(prefix, 0, 0, 0, 'png', 404, 1);
testTile(prefix, 0, 0, 0, 'png', 404, 4); testTile(prefix, 0, 0, 0, 'png', 404, 5);
//testTile('hybrid', 0, 0, 0, 'png', 404); //TODO: test this //testTile('hybrid', 0, 0, 0, 'png', 404); //TODO: test this
}); });