tileserver-gl-light 4.1.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.dockerignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *
2
2
  !src
3
3
  !public
4
+ !test
4
5
  !package.json
5
6
  !package-lock.json
6
7
  !docker-entrypoint.sh
package/.eslintrc.cjs ADDED
@@ -0,0 +1,32 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: {
4
+ browser: true,
5
+ node: true,
6
+ es6: true,
7
+ },
8
+ parserOptions: {
9
+ parser: '@typescript-eslint/parser',
10
+ ecmaVersion: 2020,
11
+ sourceType: 'module',
12
+ lib: ['es2020'],
13
+ ecmaFeatures: {
14
+ jsx: true,
15
+ tsx: true,
16
+ },
17
+ },
18
+ plugins: ['prettier', 'jsdoc', 'security'],
19
+ extends: [
20
+ 'prettier',
21
+ 'plugin:@typescript-eslint/recommended',
22
+ 'plugin:@typescript-eslint/eslint-recommended',
23
+ 'plugin:prettier/recommended',
24
+ 'plugin:jsdoc/recommended',
25
+ 'plugin:security/recommended',
26
+ ],
27
+ // add your custom rules here
28
+ rules: {
29
+ 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
30
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
31
+ },
32
+ };
package/.gitattributes ADDED
@@ -0,0 +1,11 @@
1
+ ###############################################################################
2
+ # Set default behavior to automatically normalize line endings.
3
+ ###############################################################################
4
+ * text=auto
5
+
6
+ ###############################################################################
7
+ # behavior for Unix scripts
8
+ #
9
+ # Unix scripts are treated as binary by default.
10
+ ###############################################################################
11
+ *.sh eol=lf
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ NAME=$(git config user.name)
5
+ EMAIL=$(git config user.email)
6
+
7
+ if [ -z "$NAME" ]; then
8
+ echo "empty git config user.name"
9
+ exit 1
10
+ fi
11
+
12
+ if [ -z "$EMAIL" ]; then
13
+ echo "empty git config user.email"
14
+ exit 1
15
+ fi
16
+
17
+ git interpret-trailers --if-exists doNothing --trailer \
18
+ "Signed-off-by: $NAME <$EMAIL>" \
19
+ --in-place "$1"
20
+
21
+ npm exec --no -- commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm exec --no -- lint-staged --no-stash
package/Dockerfile CHANGED
@@ -1,14 +1,35 @@
1
- FROM node:16-bullseye
1
+ FROM ubuntu:focal
2
2
 
3
- ENV NODE_ENV="production"
4
- ENV CHOKIDAR_USEPOLLING=1
5
- ENV CHOKIDAR_INTERVAL=500
6
- EXPOSE 80
3
+ ENV \
4
+ NODE_ENV="production" \
5
+ CHOKIDAR_USEPOLLING=1 \
6
+ CHOKIDAR_INTERVAL=500
7
+
8
+ RUN set -ex; \
9
+ export DEBIAN_FRONTEND=noninteractive; \
10
+ groupadd -r node; \
11
+ useradd -r -g node node; \
12
+ apt-get -qq update; \
13
+ apt-get -y --no-install-recommends install \
14
+ ca-certificates \
15
+ wget; \
16
+ wget -qO- https://deb.nodesource.com/setup_16.x | bash; \
17
+ apt-get install -y nodejs; \
18
+ apt-get -y remove wget; \
19
+ apt-get -y --purge autoremove; \
20
+ apt-get clean; \
21
+ rm -rf /var/lib/apt/lists/*;
22
+
23
+ EXPOSE 8080
24
+
25
+ RUN mkdir -p /data && chown node:node /data
7
26
  VOLUME /data
8
27
  WORKDIR /data
9
28
  ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
10
29
 
11
30
  RUN mkdir -p /usr/src/app
12
31
  COPY / /usr/src/app
13
- RUN cd /usr/src/app && npm install --production
32
+ RUN cd /usr/src/app && npm install --omit=dev
14
33
  RUN ["chmod", "+x", "/usr/src/app/docker-entrypoint.sh"]
34
+ USER node:node
35
+ HEALTHCHECK CMD node /usr/src/app/src/healthcheck.js
package/Dockerfile_test CHANGED
@@ -2,34 +2,43 @@
2
2
  # Simply run "docker build -f Dockerfile_test ."
3
3
  # WARNING: sometimes it fails with a core dumped exception
4
4
 
5
- FROM node:16-bullseye
5
+ FROM ubuntu:focal
6
6
 
7
- RUN apt-get -qq update \
8
- && DEBIAN_FRONTEND=noninteractive apt-get -y install \
9
- apt-transport-https \
10
- curl \
11
- unzip \
12
- build-essential \
13
- python \
14
- libcairo2-dev \
15
- libgles2-mesa-dev \
16
- libgbm-dev \
17
- libllvm3.9 \
18
- libprotobuf-dev \
19
- libxxf86vm-dev \
20
- libopengl0 \
21
- xvfb \
22
- && apt-get clean
7
+ ENV NODE_ENV="development"
8
+
9
+ RUN set -ex; \
10
+ export DEBIAN_FRONTEND=noninteractive; \
11
+ apt-get -qq update; \
12
+ apt-get -y --no-install-recommends install \
13
+ unzip \
14
+ build-essential \
15
+ ca-certificates \
16
+ wget \
17
+ pkg-config \
18
+ xvfb \
19
+ libglfw3-dev \
20
+ libuv1-dev \
21
+ libjpeg-turbo8 \
22
+ libicu66 \
23
+ libcairo2-dev \
24
+ libpango1.0-dev \
25
+ libjpeg-dev \
26
+ libgif-dev \
27
+ librsvg2-dev \
28
+ libcurl4-openssl-dev \
29
+ libpixman-1-dev; \
30
+ wget -qO- https://deb.nodesource.com/setup_16.x | bash; \
31
+ apt-get install -y nodejs; \
32
+ apt-get clean;
23
33
 
24
34
  RUN mkdir -p /usr/src/app
25
35
  WORKDIR /usr/src/app
26
36
 
27
- RUN wget -O test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
28
- RUN unzip -q test_data.zip -d test_data
29
-
30
- ENV NODE_ENV="test"
37
+ RUN wget -O test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip; \
38
+ unzip -q test_data.zip -d test_data
31
39
 
32
40
  COPY package.json .
33
41
  RUN npm install
34
42
  COPY / .
43
+
35
44
  RUN xvfb-run --server-args="-screen 0 1024x768x24" npm test
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ };
@@ -20,7 +20,7 @@ trap refresh HUP
20
20
 
21
21
  if ! which -- "${1}"; then
22
22
  # first arg is not an executable
23
- node /usr/src/app/ -p 80 "$@" &
23
+ node /usr/src/app/ "$@" &
24
24
  # Wait exits immediately on signals which have traps set. Store return value and wait
25
25
  # again for all jobs to actually complete before continuing.
26
26
  wait $! || RETVAL=$?
package/docs/config.rst CHANGED
@@ -14,6 +14,7 @@ Example:
14
14
  "root": "",
15
15
  "fonts": "fonts",
16
16
  "sprites": "sprites",
17
+ "icons": "icons",
17
18
  "styles": "styles",
18
19
  "mbtiles": ""
19
20
  },
@@ -31,6 +32,7 @@ Example:
31
32
  "serveAllFonts": false,
32
33
  "serveAllStyles": false,
33
34
  "serveStaticMaps": true,
35
+ "allowRemoteMarkerIcons": true,
34
36
  "tileMargin": 0
35
37
  },
36
38
  "styles": {
@@ -141,6 +143,13 @@ Optional string to be rendered into the raster tiles (and static maps) as waterm
141
143
  Can be used for hard-coding attributions etc. (can also be specified per-style).
142
144
  Not used by default.
143
145
 
146
+ ``allowRemoteMarkerIcons``
147
+ --------------
148
+
149
+ Allows the rendering of marker icons fetched via http(s) hyperlinks.
150
+ For security reasons only allow this if you can control the origins from where the markers are fetched!
151
+ Default is to disallow fetching of icons from remote sources.
152
+
144
153
  ``styles``
145
154
  ==========
146
155
 
@@ -38,15 +38,41 @@ Static images
38
38
  * ``path`` - comma-separated ``lng,lat``, pipe-separated pairs
39
39
 
40
40
  * e.g. ``5.9,45.8|5.9,47.8|10.5,47.8|10.5,45.8|5.9,45.8``
41
+ * can be provided multiple times
41
42
 
42
- * ``latlng`` - indicates the ``path`` coordinates are in ``lat,lng`` order rather than the usual ``lng,lat``
43
+ * ``latlng`` - indicates coordinates are in ``lat,lng`` order rather than the usual ``lng,lat``
43
44
  * ``fill`` - color to use as the fill (e.g. ``red``, ``rgba(255,255,255,0.5)``, ``#0000ff``)
44
45
  * ``stroke`` - color of the path stroke
45
46
  * ``width`` - width of the stroke
47
+ * ``linecap`` - rendering style for the start and end points of the path
48
+ * ``linejoin`` - rendering style for overlapping segments of the path with differing directions
49
+ * ``border`` - color of the optional border path stroke
50
+ * ``borderwidth`` - width of the border stroke (default 10% of width)
51
+ * ``marker`` - Marker in format ``lng,lat|iconPath|option|option|...``
52
+
53
+ * Will be rendered with the bottom center at the provided location
54
+ * ``lng,lat`` and ``iconPath`` are mandatory and icons won't be rendered without them
55
+ * ``iconPath`` is either a link to an image served via http(s) or a path to a file relative to the configured icon path
56
+ * ``option`` must adhere to the format ``optionName:optionValue`` and supports the following names
57
+
58
+ * ``scale`` - Factor to scale image by
59
+
60
+ * e.g. ``0.5`` - Scales the image to half it's original size
61
+
62
+ * ``offset`` - Image offset as positive or negative pixel value in format ``[offsetX],[offsetY]``
63
+
64
+ * scales with ``scale`` parameter since image placement is relative to it's size
65
+ * e.g. ``2,-4`` - Image will be moved 2 pixel to the right and 4 pixel in the upwards direction from the provided location
66
+
67
+ * e.g. ``5.9,45.8|marker-start.svg|scale:0.5|offset:2,-4``
68
+ * can be provided multiple times
69
+
46
70
  * ``padding`` - "percentage" padding for fitted endpoints (area-based and path autofit)
47
71
 
48
72
  * value of ``0.1`` means "add 10% size to each side to make sure the area of interest is nicely visible"
49
73
 
74
+ * ``maxzoom`` - Maximum zoom level (only for auto endpoint where zoom level is calculated and not provided)
75
+
50
76
  * You can also use (experimental) ``/styles/{id}/static/raw/...`` endpoints with raw spherical mercator coordinates (EPSG:3857) instead of WGS84.
51
77
 
52
78
  * The static images are not available in the ``tileserver-gl-light`` version.
@@ -7,7 +7,7 @@ Docker
7
7
 
8
8
  When running docker image, no special installation is needed -- the docker will automatically download the image if not present.
9
9
 
10
- Just run ``docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl``.
10
+ Just run ``docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl``.
11
11
 
12
12
  Additional options (see :doc:`/usage`) can be passed to the TileServer GL by appending them to the end of this command. You can, for example, do the following:
13
13
 
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '*.{js,ts}': 'npm run lint:js',
3
+ '*.{yml}': 'npm run lint:yml',
4
+ };
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "tileserver-gl-light",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "Map tile server for JSON GL styles - serving vector tiles",
5
5
  "main": "src/main.js",
6
6
  "bin": "src/main.js",
7
7
  "type": "module",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/maptiler/tileserver-gl.git"
11
- },
12
- "license": "BSD-2-Clause",
13
- "engines": {
14
- "node": ">= 14.15.0"
15
- },
16
8
  "scripts": {
17
9
  "test": "mocha test/**.js --timeout 10000",
18
- "docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:80 $(docker build -q .)"
10
+ "lint:yml": "yamllint --schema=CORE_SCHEMA *.{yml,yaml}",
11
+ "lint:js": "npm run lint:eslint && npm run lint:prettier",
12
+ "lint:js:fix": "npm run lint:eslint:fix && npm run lint:prettier:fix",
13
+ "lint:eslint": "eslint \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-path .gitignore",
14
+ "lint:eslint:fix": "eslint --fix \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs}\" --ignore-path .gitignore",
15
+ "lint:prettier": "prettier --check \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
16
+ "lint:prettier:fix": "prettier --write \"{,!(node_modules|dist|static|public)/**/}*.{js,ts,cjs,mjs,json}\" --ignore-path .gitignore",
17
+ "docker": "docker build -f Dockerfile . && docker run --rm -i -p 8080:8080 $(docker build -q .)"
19
18
  },
20
19
  "dependencies": {
21
20
  "@mapbox/glyph-pbf-composite": "0.0.3",
@@ -36,6 +35,25 @@
36
35
  "pbf": "3.2.1",
37
36
  "proj4": "2.8.0",
38
37
  "request": "2.88.2",
39
- "tileserver-gl-styles": "2.0.0"
40
- }
38
+ "tileserver-gl-styles": "2.0.0",
39
+ "sanitize-filename": "1.6.3"
40
+ },
41
+ "keywords": [
42
+ "maptiler",
43
+ "tileserver-gl",
44
+ "maplibre-gl",
45
+ "tileserver"
46
+ ],
47
+ "license": "BSD-2-Clause",
48
+ "engines": {
49
+ "node": ">= 14.15.0"
50
+ },
51
+ "repository": {
52
+ "url": "git+https://github.com/maptiler/tileserver-gl.git",
53
+ "type": "git"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/maptiler/tileserver-gl/issues"
57
+ },
58
+ "homepage": "https://github.com/maptiler/tileserver-gl#readme"
41
59
  }
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ $schema: 'http://json.schemastore.org/prettierrc',
3
+ semi: true,
4
+ arrowParens: 'always',
5
+ singleQuote: true,
6
+ trailingComma: 'all',
7
+ bracketSpacing: true,
8
+ htmlWhitespaceSensitivity: 'css',
9
+ insertPragma: false,
10
+ tabWidth: 2,
11
+ useTabs: false,
12
+ endOfLine: 'lf',
13
+ };
@@ -11,7 +11,7 @@
11
11
  <ows:Operation name="GetCapabilities">
12
12
  <ows:DCP>
13
13
  <ows:HTTP>
14
- <ows:Get xlink:href="{{baseUrl}}/wmts/{{id}}/">
14
+ <ows:Get xlink:href="{{baseUrl}}wmts/{{id}}/">
15
15
  <ows:Constraint name="GetEncoding">
16
16
  <ows:AllowedValues>
17
17
  <ows:Value>RESTful</ows:Value>
@@ -24,7 +24,7 @@
24
24
  <ows:Operation name="GetTile">
25
25
  <ows:DCP>
26
26
  <ows:HTTP>
27
- <ows:Get xlink:href="{{baseUrl}}/styles/">
27
+ <ows:Get xlink:href="{{baseUrl}}styles/">
28
28
  <ows:Constraint name="GetEncoding">
29
29
  <ows:AllowedValues>
30
30
  <ows:Value>RESTful</ows:Value>
@@ -50,7 +50,7 @@
50
50
  <TileMatrixSetLink>
51
51
  <TileMatrixSet>GoogleMapsCompatible</TileMatrixSet>
52
52
  </TileMatrixSetLink>
53
- <ResourceURL format="image/png" resourceType="tile" template="{{baseUrl}}/styles/{{id}}/{TileMatrix}/{TileCol}/{TileRow}.png{{key_query}}"/>
53
+ <ResourceURL format="image/png" resourceType="tile" template="{{baseUrl}}styles/{{id}}/{TileMatrix}/{TileCol}/{TileRow}.png{{key_query}}"/>
54
54
  </Layer><TileMatrixSet>
55
55
  <ows:Title>GoogleMapsCompatible</ows:Title>
56
56
  <ows:Abstract>GoogleMapsCompatible EPSG:3857</ows:Abstract>
@@ -403,5 +403,5 @@
403
403
  <MatrixHeight>262144</MatrixHeight>
404
404
  </TileMatrix></TileMatrixSet>
405
405
  </Contents>
406
- <ServiceMetadataURL xlink:href="{{baseUrl}}/wmts/{{id}}/"/>
406
+ <ServiceMetadataURL xlink:href="{{baseUrl}}wmts/{{id}}/"/>
407
407
  </Capabilities>
package/publish.js CHANGED
@@ -12,25 +12,33 @@
12
12
 
13
13
  // SYNC THE `light` FOLDER
14
14
 
15
- import child_process from 'child_process'
16
- child_process.execSync('rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light', {
17
- stdio: 'inherit'
18
- });
15
+ import child_process from 'child_process';
16
+ child_process.execSync(
17
+ 'rsync -av --exclude="light" --exclude=".git" --exclude="node_modules" --delete . light',
18
+ {
19
+ stdio: 'inherit',
20
+ },
21
+ );
19
22
 
20
23
  // PATCH `package.json`
21
24
  import fs from 'fs';
22
25
  import path from 'path';
23
- import {fileURLToPath} from 'url';
26
+ import { fileURLToPath } from 'url';
24
27
  const __filename = fileURLToPath(import.meta.url);
25
28
  const __dirname = path.dirname(__filename);
26
- const packageJson = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8'))
29
+ const packageJson = JSON.parse(
30
+ fs.readFileSync(__dirname + '/package.json', 'utf8'),
31
+ );
27
32
 
28
33
  packageJson.name += '-light';
29
- packageJson.description = 'Map tile server for JSON GL styles - serving vector tiles';
34
+ packageJson.description =
35
+ 'Map tile server for JSON GL styles - serving vector tiles';
30
36
  delete packageJson.dependencies['canvas'];
31
37
  delete packageJson.dependencies['@maplibre/maplibre-gl-native'];
32
38
  delete packageJson.dependencies['sharp'];
33
39
 
40
+ delete packageJson.scripts['prepare'];
41
+
34
42
  delete packageJson.optionalDependencies;
35
43
  delete packageJson.devDependencies;
36
44
 
@@ -51,10 +59,10 @@ if (process.argv.length > 2 && process.argv[2] == '--no-publish') {
51
59
 
52
60
  // tileserver-gl
53
61
  child_process.execSync('npm publish . --access public', {
54
- stdio: 'inherit'
62
+ stdio: 'inherit',
55
63
  });
56
64
 
57
65
  // tileserver-gl-light
58
66
  child_process.execSync('npm publish ./light --access public', {
59
- stdio: 'inherit'
67
+ stdio: 'inherit',
60
68
  });
package/run.sh CHANGED
@@ -29,7 +29,7 @@ export DISPLAY=:${displayNumber}.${screenNumber}
29
29
 
30
30
  echo
31
31
  cd /data
32
- node /usr/src/app/ -p 80 "$@" &
32
+ node /usr/src/app/ "$@" &
33
33
  child=$!
34
34
  wait "$child"
35
35
 
@@ -0,0 +1,18 @@
1
+ import * as http from 'http';
2
+ var options = {
3
+ timeout: 2000,
4
+ };
5
+ var url = 'http://localhost:8080/health';
6
+ var request = http.request(url, options, (res) => {
7
+ console.log(`STATUS: ${res.statusCode}`);
8
+ if (res.statusCode == 200) {
9
+ process.exit(0);
10
+ } else {
11
+ process.exit(1);
12
+ }
13
+ });
14
+ request.on('error', function (err) {
15
+ console.log('ERROR');
16
+ process.exit(1);
17
+ });
18
+ request.end();