Compare commits

...

10 commits

Author SHA1 Message Date
4b1ffd489f Aggiorna README.md
Some checks failed
CodeQL / Analyze (push) Has been cancelled
The Pipeline / Fetch branch (push) Has been cancelled
The Pipeline / CI (push) Has been cancelled
The Pipeline / CT (push) Has been cancelled
The Pipeline / Automerge Dependabot PRs (push) Has been cancelled
2025-03-27 16:44:48 +08:00
Andrew Calcutt
cd613e2fb5
Update PUBLISHING.md (#1480) 2025-03-17 09:58:26 -04:00
Andrew Calcutt
3e521a7d92
v5.2.0 (#1479) 2025-03-17 09:18:40 -04:00
Andrew Calcutt
d88fbb7c55
Fix light version docker entrypoint permissions (#1478)
* put back entrypoint chmod

* bump to 5.2.0-pre.3

* move chown

* put back manual build steps

* Update PUBLISHING.md
2025-03-16 23:25:45 -04:00
Andrew Calcutt
6d4ab40b96
Test light version in ct workflow - fix sqlite build in light (#1477)
* Test light version in ct workflow
* make light builder two part
2025-03-16 19:12:09 -04:00
Andrew Calcutt
5441a10488
v5.2.0 pre.1 (#1476)
* 5.2.0-pre.1

* Update CHANGELOG.md
2025-03-16 15:04:12 -04:00
RJ Johnston
8a7d9957fb
fix: resolves Unimplemented type: 3 error for geojson format (#1465)
* fix: resolves Unimplemented type: 3 error for geojson format

* fix: removing duplicate zlib import

* fix: remove redundant change to headers

* revert fix decimal length

* lint fix

---------

Co-authored-by: Andrew Calcutt <acalcutt@techidiots.net>
2025-03-16 14:51:12 -04:00
dependabot[bot]
6d1c617752
fix(deps): bump axios from 1.7.9 to 1.8.2 (#1475)
Bumps [axios](https://github.com/axios/axios) from 1.7.9 to 1.8.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.7.9...v1.8.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-16 18:01:08 +00:00
Andrew Calcutt
3881219fee
fix ci - add canvas build dependencies to ci workflow (#1474)
* add canvas depends
2025-03-16 13:43:51 -04:00
Yoel Ridgway-Lopez
3110cab18f
feat: Fetch style from url (#1462)
* made the serve_style.add and addStyle functions async and return promises

* added fetching to addStyle() function and parsed it into serve_style and serve_rendered

* fixed linting issues

* removed async from synchronous functions

* added fetch example to docs
2025-02-28 23:45:51 -05:00
14 changed files with 264 additions and 90 deletions

View file

@ -21,6 +21,11 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies (Ubuntu) 🚀
run: >-
sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev
libgif-dev build-essential
- name: Setup node env 📦
uses: actions/setup-node@v4
with:

View file

@ -65,6 +65,22 @@ jobs:
context: .
push: false
platforms: linux/arm64,linux/amd64
# experimental: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#cache-backend-api
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create Tileserver Light Directory
run: node publish.js --no-publish
- name: Install node dependencies
run: npm ci --prefer-offline --no-audit
working-directory: ./light
- name: Test Light Version to Docker Hub
uses: docker/build-push-action@v6
with:
context: ./light
file: ./light/Dockerfile
push: false
platforms: linux/arm64,linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -1,10 +1,14 @@
# tileserver-gl changelog
## 5.2.0-pre.0
## 5.2.0
* Use npm packages for public/resources (https://github.com/maptiler/tileserver-gl/pull/1427) by @okimiko
* use ttf files of googlefonts/opensans (https://github.com/maptiler/tileserver-gl/pull/1447) by @okimiko
* fix memory leak on SIGHUP (https://github.com/maptiler/tileserver-gl/pull/1455) by @okimiko
* Limit Elevation Lat/Long Output Length (https://github.com/maptiler/tileserver-gl/pull/1457) by @okimiko
* Fetch style from url (https://github.com/maptiler/tileserver-gl/pull/1462) by @YoelRidgway
* fix: memory leak on SIGHUP (https://github.com/maptiler/tileserver-gl/pull/1455) by @okimiko
* fix: resolves Unimplemented type: 3 error for geojson format (https://github.com/maptiler/tileserver-gl/pull/1465) by @rjdjohnston
* fix: Test light version in ct workflow - fix sqlite build in light (https://github.com/maptiler/tileserver-gl/pull/1477) by @acalcutt
* fix: light version docker entrypoint permissions (https://github.com/maptiler/tileserver-gl/pull/1478) by @acalcutt
## 5.1.3
* Fix SIGHUP (broken since 5.1.x) (https://github.com/maptiler/tileserver-gl/pull/1452) by @okimiko

View file

@ -50,7 +50,6 @@ RUN npm config set maxsockets 1 && \
npm config set fetch-retries 5 && \
npm config set fetch-retry-mintimeout 100000 && \
npm config set fetch-retry-maxtimeout 600000 && \
npm install -g copyfiles@2.4.1 && \
npm ci --omit=dev && \
chown -R root:root /usr/src/app

View file

@ -1,4 +1,42 @@
FROM ubuntu:jammy
FROM ubuntu:jammy AS builder
ENV NODE_ENV="production"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests \
build-essential \
ca-certificates \
curl \
gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get -qq update && \
apt-get install -y --no-install-recommends --no-install-suggests nodejs && \
npm i -g npm@latest && \
apt-get -y remove curl gnupg && \
apt-get -y --purge autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
COPY package-lock.json /usr/src/app
RUN npm config set maxsockets 1 && \
npm config set fetch-retries 5 && \
npm config set fetch-retry-mintimeout 100000 && \
npm config set fetch-retry-maxtimeout 600000 && \
npm ci --omit=dev && \
chown -R root:root /usr/src/app
FROM ubuntu:jammy AS final
ENV \
NODE_ENV="production" \
@ -26,18 +64,14 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY . .
COPY --from=builder /usr/src/app /usr/src/app
RUN npm config set maxsockets 1 && \
npm config set fetch-retries 5 && \
npm config set fetch-retry-mintimeout 100000 && \
npm config set fetch-retry-maxtimeout 600000 && \
npm install --omit=dev && \
chown -R root:root . && \
chmod +x ./docker-entrypoint.sh
COPY . /usr/src/app
RUN mkdir -p /data && \
chown node:node /data && \
chmod +x /usr/src/app/docker-entrypoint.sh
RUN mkdir -p /data && chown node:node /data
VOLUME /data
WORKDIR /data

View file

@ -1,19 +1,112 @@
# Publishing new version
# Publishing a New Version
1.) Change the version number in package.json. Run the following command in the package root directory, replacing <update_type> with one of the semantic versioning release types (prerelease, prepatch, preminor, premajor, patch, minor, major):
npm version <update_type> --preid pre --no-git-tag-version
This document outlines the process for publishing new versions of this project. We use a GitHub workflow for automated releases, but also provide manual steps for specific situations.
--preid specifies which suffix to use in the release such as pre, next, beta, rc, etc.
## Automated Publishing via GitHub Workflow (Recommended)
prepatch, preminor, and premajor start a new series of pre-releases while bumping the patch, minor, or major version. E.g. premajor with --preid pre would do a prerelease for a new major using the -pre suffix (i.e. it would be a new major with -pre.0)
This is the preferred method for publishing new versions. It automates the entire process, including version bumping, tagging, building, and publishing.
You can use prerelease to bump the version for a new pre-release version. E.g. you could run npm version prerelease --preid pre --no-git-tag-version to go from -pre.0 to -pre.1.
1. **Prepare the Release:**
For regular versions, you can use patch, minor, or major. E.g. npm version major --no-git-tag-version.
* **Choose the Version Increment:** Determine the appropriate semantic versioning increment (prerelease, prepatch, preminor, premajor, patch, minor, major).
2.) Update the changelog, which can be found in CHANGELOG.md. The heading must match ## <VERSION> exactly, or it will not be picked up. For example, for version 5.0.0:
```## 5.0.0```
* **Update `package.json`:** Use the `npm version` command to bump the version number. This command also supports creating pre-release versions using the `--preid pre` flag.
3.) Commit and push the changes.
```bash
# Example: Increment to a new patch version
npm version patch --no-git-tag-version
4.) Run the 'Build, Test, Release' github workflow. The workflow will create a NPM, Docker, and Github release and Tag.
# Example: Increment to a new minor version
npm version minor --no-git-tag-version
# Example: Increment to a new major version
npm version major --no-git-tag-version
# Example: Create a pre-release (e.g., -pre.0) version
npm version prepatch --preid pre --no-git-tag-version
# OR
npm version preminor --preid pre --no-git-tag-version
# OR
npm version premajor --preid pre --no-git-tag-version
# Example: Increment an existing pre-release version (e.g., -pre.0 to -pre.1)
npm version prerelease --preid pre --no-git-tag-version
```
* `--no-git-tag-version`: This prevents `npm version` from automatically creating a git tag, as the GitHub workflow will handle this later.
* `--preid pre`: Specifies that "pre" is the pre-release identifier.
* **Update the Changelog (`CHANGELOG.md`):** Add a new section for the release. The heading *must* exactly match the format `## <VERSION>`, where `<VERSION>` is the full version number from `package.json`. Describe the changes included in the release.
```markdown
## 1.2.3
* Added new feature X.
```
2. **Commit and Push:** Commit the changes to `package.json`, `package-lock.json` and `CHANGELOG.md` to a the `master` branch. Create a pull request (PR) for review. If you are an administrator, you may push directly, but a PR is generally recommended for code review.
3. **Run the GitHub Workflow:** Once the PR is merged (or changes pushed directly), trigger the "Build, Test, Release" GitHub workflow. This workflow is responsible for:
* Building the project.
* Running tests.
* Creating an NPM package.
* Building and pushing Docker images.
* Creating a GitHub Release.
* Creating a Git tag for the release.
## Manual Publishing (For Special Cases)
Use the following steps *only* when the automated workflow is not suitable (e.g., for debugging, specific environment needs).
1. **Update Version in `package.json`:** Modify the `version` field in `package.json` to the desired version number.
2. **Create and Push Git Tag:**
```bash
git tag vX.X.X # Replace X.X.X with the version number
git push origin --tags
```
3. **NPM Publish Options (Choose ONE):**
* **Option A: Publish only the full `tileserver-gl` version:**
```bash
npm publish --access public
```
* **Option B: Build and Publish both `tileserver-gl` and `tileserver-gl-light` using `publish.js`:**
```bash
# This script builds the light version and publishes both tileserver-gl and tileserver-gl-light to NPM.
node publish.js
```
* **Option C: Build only the `tileserver-gl-light` version (no publish):**
```bash
# This script ONLY builds the light version (e.g., for local testing or Docker image creation) without publishing.
node publish.js --no-publish
```
4. **Build and Push Docker Images:**
```bash
# Build the main image
docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl:latest -t maptiler/tileserver-gl:X.X.X . # Replace X.X.X
docker push maptiler/tileserver-gl --all-tags
# Build the light image
cd light
docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl-light:latest -t maptiler/tileserver-gl-light:X.X.X . # Replace X.X.X
docker push maptiler/tileserver-gl-light --all-tags
cd .. # Return to the project root
```
* Make sure you are logged into the docker registry before pushing. `docker login`
**Important Considerations for Manual Publishing:**
* **Consistency:** Ensure the version number in `package.json`, the Git tag, and the Docker image tags are identical.
* **Credentials:** Verify that you have the necessary permissions to push Docker images and publish to NPM.
* **Cleanliness:** Before building Docker images, ensure your working directory is clean to avoid including unwanted files in the image.
* **Error Handling:** Manually publishing is more prone to errors. Double-check each step to avoid issues.

View file

@ -1,5 +1,32 @@
![tileserver-gl](https://cloud.githubusercontent.com/assets/59284/18173467/fa3aa2ca-7069-11e6-86b1-0f1266befeb6.jpeg)
# My TileServer GL
creare un folder dove mettere la mappa e i layers
Download vector tiles from [OpenMapTiles](https://data.maptiler.com/downloads/planet/).
scaricare i layers
wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
unzip test_data.zip
modificare nano config.json per inserire il nome del file .mbtiles (x es planetOSM.mbtiles )
far partire il docker
services:
tileserver-gl:
volumes:
- /home/nvme/dockerdata/tileserver:/data
ports:
- 8115:8080
image: maptiler/tileserver-gl:latest
oppure
sudo docker run -d -v /home/nvme/dockerdata/tileserver:/data -p 8115:8080 maptiler/tileserver-gl:latest
# TileServer GL
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/maptiler/tileserver-gl/pipeline.yml)](https://github.com/maptiler/tileserver-gl/actions/workflows/pipeline.yml)
[![Docker Hub](https://img.shields.io/badge/docker-hub-blue.svg)](https://hub.docker.com/r/maptiler/tileserver-gl/)

View file

@ -57,6 +57,9 @@ Example:
"tilejson": {
"format": "webp"
}
},
"remote": {
"style": "https://demotiles.maplibre.org/style.json"
}
},
"data": {
@ -209,7 +212,7 @@ Not used by default.
Each item in this object defines one style (map). It can have the following options:
* ``style`` -- name of the style json file [required]
* ``style`` -- name of the style json file or url of a remote hosted style [required]
* ``serve_rendered`` -- whether to render the raster tiles for this style or not
* ``serve_data`` -- whether to allow access to the original tiles, sprites and required glyphs
* ``tilejson`` -- properties to add to the TileJSON created for the raster data

41
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "tileserver-gl",
"version": "5.2.0-pre.0",
"version": "5.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tileserver-gl",
"version": "5.2.0-pre.0",
"version": "5.2.0",
"license": "BSD-2-Clause",
"dependencies": {
"@jsse/pbfont": "^0.2.2",
@ -20,12 +20,13 @@
"@maplibre/maplibre-gl-style-spec": "20.3.1",
"@sindresorhus/fnv1a": "3.1.0",
"advanced-pool": "0.3.3",
"axios": "^1.7.7",
"axios": "^1.8.2",
"canvas": "3.0.1",
"chokidar": "3.6.0",
"clone": "2.1.2",
"color": "4.2.3",
"commander": "12.1.0",
"copyfiles": "2.4.1",
"cors": "2.8.5",
"express": "5.0.1",
"handlebars": "4.7.8",
@ -51,7 +52,6 @@
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"chai": "5.1.1",
"copyfiles": "2.4.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^50.2.2",
@ -2052,9 +2052,9 @@
}
},
"node_modules/axios": {
"version": "1.7.9",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.2.tgz",
"integrity": "sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
@ -2902,7 +2902,6 @@
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.4.1.tgz",
"integrity": "sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==",
"dev": true,
"license": "MIT",
"dependencies": {
"glob": "^7.0.5",
@ -2922,7 +2921,6 @@
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
@ -2938,7 +2936,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
@ -2949,7 +2946,6 @@
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
@ -2961,14 +2957,12 @@
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/copyfiles/node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@ -2978,7 +2972,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^1.1.7"
@ -2991,7 +2984,6 @@
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
@ -3006,7 +2998,6 @@
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
@ -3024,7 +3015,6 @@
"version": "16.2.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
"integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^7.0.2",
@ -3043,7 +3033,6 @@
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
"dev": true,
"license": "MIT"
},
"node_modules/cors": {
@ -3672,7 +3661,6 @@
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@ -4728,7 +4716,6 @@
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
@ -5956,7 +5943,6 @@
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
"dev": true,
"license": "MIT"
},
"node_modules/isexe": {
@ -7652,7 +7638,6 @@
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz",
"integrity": "sha512-lNDU9VJaOPxUmXcLb+HQFeUgQQPtMI24Gt6hgfuMHRJgMRHMF/qZ4HJD3GDru4sSw9IQl2jPjAYnQrdIeLbwow==",
"dev": true,
"license": "ISC",
"dependencies": {
"inherits": "^2.0.1",
@ -8414,7 +8399,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"dev": true,
"license": "MIT"
},
"node_modules/proj4": {
@ -8821,7 +8805,6 @@
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==",
"dev": true,
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
@ -8911,7 +8894,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
@ -9944,7 +9926,6 @@
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==",
"dev": true,
"license": "MIT"
},
"node_modules/string-argv": {
@ -10340,7 +10321,6 @@
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"readable-stream": "~2.3.6",
@ -10351,14 +10331,12 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"dev": true,
"license": "MIT"
},
"node_modules/through2/node_modules/readable-stream": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
"dev": true,
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
@ -10374,14 +10352,12 @@
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true,
"license": "MIT"
},
"node_modules/through2/node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.1.0"
@ -10731,7 +10707,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz",
"integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@ -11095,7 +11070,6 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.4"
@ -11105,7 +11079,6 @@
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=10"

View file

@ -1,6 +1,6 @@
{
"name": "tileserver-gl",
"version": "5.2.0-pre.0",
"version": "5.2.0",
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
"main": "src/main.js",
"bin": "src/main.js",
@ -35,12 +35,13 @@
"@maplibre/maplibre-gl-style-spec": "20.3.1",
"@sindresorhus/fnv1a": "3.1.0",
"advanced-pool": "0.3.3",
"axios": "^1.7.7",
"axios": "^1.8.2",
"canvas": "3.0.1",
"chokidar": "3.6.0",
"clone": "2.1.2",
"color": "4.2.3",
"commander": "12.1.0",
"copyfiles": "2.4.1",
"cors": "2.8.5",
"express": "5.0.1",
"handlebars": "4.7.8",
@ -63,7 +64,6 @@
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"chai": "5.1.1",
"copyfiles": "2.4.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^50.2.2",

View file

@ -21,6 +21,7 @@ import { openMbTilesWrapper } from './mbtiles_wrapper.js';
import fs from 'node:fs';
import { fileURLToPath } from 'url';
const packageJson = JSON.parse(
fs.readFileSync(
path.dirname(fileURLToPath(import.meta.url)) + '/../package.json',
@ -113,12 +114,13 @@ export const serve_data = {
let headers = fetchTile.headers;
let isGzipped = data.slice(0, 2).indexOf(Buffer.from([0x1f, 0x8b])) === 0;
if (isGzipped) {
data = await gunzipP(data);
isGzipped = false;
}
if (tileJSONFormat === 'pbf') {
if (options.dataDecoratorFunc) {
if (isGzipped) {
data = await gunzipP(data);
isGzipped = false;
}
data = options.dataDecoratorFunc(
req.params.id,
'data',

View file

@ -1027,10 +1027,19 @@ export const serve_rendered = {
* @param {object} params Parameters object.
* @param {string} id ID of the item.
* @param {object} programOpts - An object containing the program options
* @param {object} style pre-fetched/read StyleJSON object.
* @param {Function} dataResolver Function to resolve data.
* @returns {Promise<void>}
*/
add: async function (options, repo, params, id, programOpts, dataResolver) {
add: async function (
options,
repo,
params,
id,
programOpts,
style,
dataResolver,
) {
const map = {
renderers: [],
renderersStatic: [],
@ -1040,7 +1049,7 @@ export const serve_rendered = {
const { publicUrl, verbose } = programOpts;
let styleJSON;
const styleJSON = clone(style);
/**
* Creates a pool of renderers.
* @param {number} ratio Pixel ratio
@ -1229,12 +1238,6 @@ export const serve_rendered = {
const styleFile = params.style;
const styleJSONPath = path.resolve(options.paths.styles, styleFile);
try {
styleJSON = JSON.parse(await fsp.readFile(styleJSONPath));
} catch (e) {
console.log('Error parsing style file');
return false;
}
if (styleJSON.sprite) {
if (!Array.isArray(styleJSON.sprite)) {

View file

@ -196,9 +196,10 @@ export const serve_style = {
* @param {object} params Parameters object containing style path
* @param {string} id ID of the style.
* @param {object} programOpts - An object containing the program options
* @param {object} style pre-fetched/read StyleJSON object.
* @param {Function} reportTiles Function for reporting tile sources.
* @param {Function} reportFont Function for reporting font usage
* @returns {boolean} true if add is succesful
* @returns {boolean} true if add is successful
*/
add: function (
options,
@ -206,21 +207,14 @@ export const serve_style = {
params,
id,
programOpts,
style,
reportTiles,
reportFont,
) {
const { publicUrl } = programOpts;
const styleFile = path.resolve(options.paths.styles, params.style);
const styleJSON = clone(style);
let styleFileData;
try {
styleFileData = fs.readFileSync(styleFile); // TODO: could be made async if this function was
} catch (e) {
console.log(`Error reading style file "${params.style}"`);
return false;
}
const styleJSON = JSON.parse(styleFileData);
const validationErrors = validateStyleMin(styleJSON);
if (validationErrors.length > 0) {
console.log(`The file "${params.style}" is not a valid style file:`);

View file

@ -178,10 +178,29 @@ async function start(opts) {
* @param {object} item - The style configuration object.
* @param {boolean} allowMoreData - Whether to allow adding more data sources.
* @param {boolean} reportFonts - Whether to report fonts.
* @returns {void}
* @returns {Promise<void>}
*/
function addStyle(id, item, allowMoreData, reportFonts) {
async function addStyle(id, item, allowMoreData, reportFonts) {
let success = true;
let styleJSON;
try {
if (isValidHttpUrl(item.style)) {
const res = await fetch(item.style);
if (!res.ok) {
throw new Error(`fetch error ${res.status}`);
}
styleJSON = await res.json();
} else {
const styleFile = path.resolve(options.paths.styles, item.style);
const styleFileData = await fs.promises.readFile(styleFile);
styleJSON = JSON.parse(styleFileData);
}
} catch (e) {
console.log(`Error getting style file "${item.style}"`);
return false;
}
if (item.serve_data !== false) {
success = serve_style.add(
options,
@ -189,6 +208,7 @@ async function start(opts) {
item,
id,
opts,
styleJSON,
(styleSourceId, protocol) => {
let dataItemId;
for (const id of Object.keys(data)) {
@ -246,6 +266,7 @@ async function start(opts) {
item,
id,
opts,
styleJSON,
function dataResolver(styleSourceId) {
let fileType;
let inputFile;
@ -271,6 +292,7 @@ async function start(opts) {
item.serve_rendered = false;
}
}
return success;
}
for (const id of Object.keys(config.styles || {})) {
@ -279,8 +301,7 @@ async function start(opts) {
console.log(`Missing "style" property for ${id}`);
continue;
}
addStyle(id, item, true, true);
startupPromises.push(addStyle(id, item, true, true));
}
startupPromises.push(
serve_font(options, serving.fonts, opts).then((sub) => {