Merge branch 'master' into terrain-elevation-contour

This commit is contained in:
Miko 2025-01-11 20:54:18 +01:00
commit eb6a11b3b9
10 changed files with 140 additions and 54 deletions

View file

@ -14,9 +14,41 @@ on:
required: true required: true
jobs: jobs:
release-check:
name: Check if version is published
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
check-latest: true
cache: 'npm'
- name: Check if version is published
id: check
run: |
currentVersion="$( node -e "console.log(require('./package.json').version)" )"
isPublished="$( npm view tileserver-gl versions --json | jq -c --arg cv "$currentVersion" 'any(. == $cv)' )"
echo "version=$currentVersion" >> "$GITHUB_OUTPUT"
echo "published=$isPublished" >> "$GITHUB_OUTPUT"
echo "currentVersion: $currentVersion"
echo "isPublished: $isPublished"
outputs:
published: ${{ steps.check.outputs.published }}
version: ${{ steps.check.outputs.version }}
release: release:
needs: release-check
if: ${{ needs.release-check.outputs.published == 'false' }}
name: 'Build, Test, Publish' name: 'Build, Test, Publish'
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
env:
PACKAGE_VERSION: ${{ needs.release-check.outputs.version }}
steps: steps:
- name: Check out repository ✨ - name: Check out repository ✨
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -54,17 +86,23 @@ jobs:
- name: Remove Test Data - name: Remove Test Data
run: rm -R test_data* run: rm -R test_data*
- name: Publish to Full Version NPM - name: Get release type
id: prepare_release
run: |
RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('${{ needs.release-check.outputs.version }}') ? 'prerelease' : 'regular')")"
if [[ $RELEASE_TYPE == 'regular' ]]; then
echo "prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: Publish to NPM
run: | run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public npm publish --access public --tag ${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }}
env: env:
NPM_TOKEN: ${{ github.event.inputs.npm_token }} NPM_TOKEN: ${{ github.event.inputs.npm_token }}
- name: Get version
run: |
echo "PACKAGE_VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -n 1)" >> $GITHUB_ENV
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with: with:
@ -84,24 +122,42 @@ jobs:
with: with:
context: . context: .
push: true push: true
tags: maptiler/tileserver-gl:latest, maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }} tags: |
maptiler/tileserver-gl:${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }},
maptiler/tileserver-gl:v${{ env.PACKAGE_VERSION }}
platforms: linux/arm64,linux/amd64 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
- name: Extract changelog for version
run: |
awk '/^##/ { p = 0 }; p == 1 { print }; $0 == "## ${{ env.PACKAGE_VERSION }}" { p = 1 };' CHANGELOG.md > changelog_for_version.md
cat changelog_for_version.md
- name: Publish to Github
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ env.PACKAGE_VERSION }}
name: v${{ env.PACKAGE_VERSION }}
bodyFile: changelog_for_version.md
allowUpdates: true
draft: false
prerelease: ${{ steps.prepare_release.outputs.prerelease }}
- name: Create Tileserver Light Directory - name: Create Tileserver Light Directory
run: node publish.js --no-publish run: node publish.js --no-publish
- name: Install node dependencies - name: Install node dependencies
run: npm install run: npm ci --prefer-offline --no-audit
working-directory: ./light working-directory: ./light
- name: Publish to Light Version NPM - name: Publish to Light Version NPM
working-directory: ./light working-directory: ./light
run: | run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public npm publish --access public --tag ${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }}
env: env:
NPM_TOKEN: ${{ github.event.inputs.npm_token }} NPM_TOKEN: ${{ github.event.inputs.npm_token }}
@ -111,8 +167,9 @@ jobs:
context: ./light context: ./light
file: ./light/Dockerfile file: ./light/Dockerfile
push: true push: true
tags: maptiler/tileserver-gl-light:latest, maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }} tags: |
maptiler/tileserver-gl-light:${{ steps.prepare_release.outputs.prerelease == 'true' && 'next' || 'latest' }},
maptiler/tileserver-gl-light:v${{ env.PACKAGE_VERSION }}
platforms: linux/arm64,linux/amd64 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-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max

16
CHANGELOG.md Normal file
View file

@ -0,0 +1,16 @@
# tileserver-gl changelog
## 5.1.1
* Fix wrong node version in Docker image (https://github.com/maptiler/tileserver-gl/pull/1442) by @acalcutt
## 5.1.0
* Update recommended node to v22 + Update docker images to use node 22 (https://github.com/maptiler/tileserver-gl/pull/1438) by @acalcutt
* Upgrade Express to v5 + Canvas to v3 + code cleanup (https://github.com/maptiler/tileserver-gl/pull/1429) by @acalcutt
* Terrain Preview and simple Elevation Query (https://github.com/maptiler/tileserver-gl/pull/1425 and https://github.com/maptiler/tileserver-gl/pull/1432) by @okimiko
* add progressive rendering option for static jpeg images (#1397) by @samuel-git
## 5.0.0
* Update Maplibre-Native to [v6.0.0](https://github.com/maplibre/maplibre-native/releases/tag/node-v6.0.0) release by @acalcutt in https://github.com/maptiler/tileserver-gl/pull/1376 and @dependabot in https://github.com/maptiler/tileserver-gl/pull/1381
* This first release that use Metal for rendering instead of OpenGL (ES) for macOS.
* This the first release that uses OpenGL (ES) 3.0 on Windows and Linux
* Note: Windows users may need to update their [c++ redistributable ](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) for maplibre-native v6.0.0

View file

@ -35,7 +35,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mkdir -p /etc/apt/keyrings; \ RUN mkdir -p /etc/apt/keyrings; \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ 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_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ 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 -qq update; \
apt-get install -y nodejs; \ apt-get install -y nodejs; \
npm i -g npm@latest; \ npm i -g npm@latest; \
@ -94,7 +94,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mkdir -p /etc/apt/keyrings; \ RUN mkdir -p /etc/apt/keyrings; \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ 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_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ 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 -qq update; \
apt-get install -y nodejs; \ apt-get install -y nodejs; \
npm i -g npm@latest; \ npm i -g npm@latest; \

View file

@ -16,7 +16,7 @@ RUN set -ex; \
gnupg; \ gnupg; \
mkdir -p /etc/apt/keyrings; \ mkdir -p /etc/apt/keyrings; \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \ 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_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list; \ 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 -qq update; \
apt-get install -y nodejs; \ apt-get install -y nodejs; \
npm i -g npm@latest; \ npm i -g npm@latest; \

View file

@ -13,7 +13,8 @@ RUN set -ex; \
unzip \ unzip \
build-essential \ build-essential \
ca-certificates \ ca-certificates \
wget \ curl \
gnupg \
pkg-config \ pkg-config \
xvfb \ xvfb \
libglfw3-dev \ libglfw3-dev \
@ -25,16 +26,33 @@ RUN set -ex; \
libjpeg-dev \ libjpeg-dev \
libgif-dev \ libgif-dev \
librsvg2-dev \ librsvg2-dev \
gir1.2-rsvg-2.0 \
librsvg2-2 \
librsvg2-common \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
libpixman-1-dev; \ libpixman-1-dev \
wget -qO- https://deb.nodesource.com/setup_18.x | bash; \ libpixman-1-0; \
apt-get -y --purge autoremove; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*;
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN 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 nodejs; \ apt-get install -y nodejs; \
apt-get clean; npm i -g npm@latest; \
apt-get -y remove gnupg; \
apt-get -y --purge autoremove; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*;
RUN mkdir -p /usr/src/app RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app WORKDIR /usr/src/app
RUN wget -O test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip; \ RUN curl -L -o test_data.zip https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip; \
unzip -q test_data.zip -d test_data unzip -q test_data.zip -d test_data
COPY package.json . COPY package.json .

View file

@ -1,13 +1,19 @@
# Publishing new version # Publishing new version
- Update version in `package.json` 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):
- `git tag vx.x.x` npm version <update_type> --preid pre --no-git-tag-version
- `git push --tags`
- `docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl:latest -t maptiler/tileserver-gl:[version] .` --preid specifies which suffix to use in the release such as pre, next, beta, rc, etc.
- `docker push maptiler/tileserver-gl --all-tags`
- `npm publish --access public` or `node publish.js` 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)
- `node publish.js --no-publish`
- `cd light` 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.
- `docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl-light:latest -t maptiler/tileserver-gl-light:[version] .`
- `docker push maptiler/tileserver-gl-light --all-tags` For regular versions, you can use patch, minor, or major. E.g. npm version major --no-git-tag-version.
- `npm publish --access public`
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```
3.) Commit and push the changes.
4.) Run the 'Build, Test, Release' github workflow. The workflow will create a NPM, Docker, and Github release and Tag.

View file

@ -9,7 +9,7 @@ Vector and raster maps with GL styles. Server-side rendering by MapLibre GL Nati
Download vector tiles from [OpenMapTiles](https://data.maptiler.com/downloads/planet/). Download vector tiles from [OpenMapTiles](https://data.maptiler.com/downloads/planet/).
## Getting Started with Node ## Getting Started with Node
Make sure you have Node.js version **18.17.0** or above installed. Node 20 is recommended. (running `node -v` it should output something like `v20.x.x`). Running without docker requires [Native dependencies](https://maptiler-tileserver.readthedocs.io/en/latest/installation.html#npm) to be installed first. Make sure you have Node.js version **18.17.0** or above installed. Node 22 is recommended. (running `node -v` it should output something like `v22.x.x`). Running without docker requires [Native dependencies](https://maptiler-tileserver.readthedocs.io/en/latest/installation.html#npm) to be installed first.
Install `tileserver-gl` with server-side raster rendering of vector tiles with npm. Install `tileserver-gl` with server-side raster rendering of vector tiles with npm.
@ -43,7 +43,7 @@ An alternative to npm to start the packed software easier is to install [Docker]
Example using a mbtiles file Example using a mbtiles file
```bash ```bash
wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl --file zurich_switzerland.mbtiles docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl:latest --file zurich_switzerland.mbtiles
[in your browser, visit http://[server ip]:8080] [in your browser, visit http://[server ip]:8080]
``` ```
@ -51,18 +51,18 @@ Example using a config.json + style + mbtiles file
```bash ```bash
wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
unzip test_data.zip unzip test_data.zip
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl:latest
[in your browser, visit http://[server ip]:8080] [in your browser, visit http://[server ip]:8080]
``` ```
Example using a different path Example using a different path
```bash ```bash
docker run --rm -it -v /your/local/config/path:/data -p 8080:8080 maptiler/tileserver-gl docker run --rm -it -v /your/local/config/path:/data -p 8080:8080 maptiler/tileserver-gl:latest
``` ```
replace '/your/local/config/path' with the path to your config file replace '/your/local/config/path' with the path to your config file
Alternatively, you can use the `maptiler/tileserver-gl-light` docker image 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 Maplibre GL Native. Alternatively, you can use the `maptiler/tileserver-gl-light:latest` docker image 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 Maplibre GL Native.
## Getting Started with Linux cli ## Getting Started with Linux cli

7
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "tileserver-gl", "name": "tileserver-gl",
"version": "5.0.0", "version": "5.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "tileserver-gl", "name": "tileserver-gl",
"version": "5.0.0", "version": "5.1.1",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "dependencies": {
"@jsse/pbfont": "^0.2.2", "@jsse/pbfont": "^0.2.2",
@ -34,6 +34,7 @@
"pmtiles": "3.0.7", "pmtiles": "3.0.7",
"proj4": "2.12.1", "proj4": "2.12.1",
"sanitize-filename": "1.6.3", "sanitize-filename": "1.6.3",
"semver": "^7.6.3",
"sharp": "0.33.5", "sharp": "0.33.5",
"tileserver-gl-styles": "2.0.0" "tileserver-gl-styles": "2.0.0"
}, },
@ -60,7 +61,7 @@
"yaml-lint": "^1.7.0" "yaml-lint": "^1.7.0"
}, },
"engines": { "engines": {
"node": ">=18.17.0 <21" "node": ">=18.17.0 <23"
} }
}, },
"node_modules/@aashutoshrathi/word-wrap": { "node_modules/@aashutoshrathi/word-wrap": {

View file

@ -1,6 +1,6 @@
{ {
"name": "tileserver-gl", "name": "tileserver-gl",
"version": "5.0.0", "version": "5.1.1",
"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",
@ -43,6 +43,7 @@
"pmtiles": "3.0.7", "pmtiles": "3.0.7",
"proj4": "2.12.1", "proj4": "2.12.1",
"sanitize-filename": "1.6.3", "sanitize-filename": "1.6.3",
"semver": "^7.6.3",
"sharp": "0.33.5", "sharp": "0.33.5",
"tileserver-gl-styles": "2.0.0" "tileserver-gl-styles": "2.0.0"
}, },
@ -73,7 +74,7 @@
], ],
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"engines": { "engines": {
"node": ">=18.17.0 <21" "node": ">=18.17.0 <23"
}, },
"repository": { "repository": {
"url": "git+https://github.com/maptiler/tileserver-gl.git", "url": "git+https://github.com/maptiler/tileserver-gl.git",

View file

@ -308,15 +308,12 @@ export const serve_data = {
} else if (format !== 'webp' && format !== 'png') { } else if (format !== 'webp' && format !== 'png') {
return res.status(400).send('Invalid format. Must be webp or png.'); return res.status(400).send('Invalid format. Must be webp or png.');
} }
const z = parseInt(req.params.z, 10); const z = parseInt(req.params.z, 10);
const x = parseFloat(req.params.x); const x = parseFloat(req.params.x);
const y = parseFloat(req.params.y); const y = parseFloat(req.params.y);
if (tileJSON.minzoom == null || tileJSON.maxzoom == null) { if (tileJSON.minzoom == null || tileJSON.maxzoom == null) {
return res.status(404).send(JSON.stringify(tileJSON)); return res.status(404).send(JSON.stringify(tileJSON));
} }
const TILE_SIZE = tileJSON.tileSize || 512; const TILE_SIZE = tileJSON.tileSize || 512;
let bbox; let bbox;
let xy; let xy;
@ -325,7 +322,6 @@ export const serve_data = {
if (Number.isInteger(x) && Number.isInteger(y)) { if (Number.isInteger(x) && Number.isInteger(y)) {
const intX = parseInt(req.params.x, 10); const intX = parseInt(req.params.x, 10);
const intY = parseInt(req.params.y, 10); const intY = parseInt(req.params.y, 10);
if ( if (
zoom < tileJSON.minzoom || zoom < tileJSON.minzoom ||
zoom > tileJSON.maxzoom || zoom > tileJSON.maxzoom ||
@ -346,7 +342,6 @@ export const serve_data = {
if (zoom > tileJSON.maxzoom) { if (zoom > tileJSON.maxzoom) {
zoom = tileJSON.maxzoom; zoom = tileJSON.maxzoom;
} }
bbox = [x, y, x + 0.1, y + 0.1]; bbox = [x, y, x + 0.1, y + 0.1];
const { minX, minY } = new SphericalMercator().xyz(bbox, zoom); const { minX, minY } = new SphericalMercator().xyz(bbox, zoom);
xy = [minX, minY]; xy = [minX, minY];
@ -368,7 +363,6 @@ export const serve_data = {
const canvas = createCanvas(TILE_SIZE, TILE_SIZE); const canvas = createCanvas(TILE_SIZE, TILE_SIZE);
const context = canvas.getContext('2d'); const context = canvas.getContext('2d');
context.drawImage(image, 0, 0); context.drawImage(image, 0, 0);
const long = bbox[0]; const long = bbox[0];
const lat = bbox[1]; const lat = bbox[1];
@ -378,7 +372,6 @@ export const serve_data = {
// Truncating to 0.9999 effectively limits latitude to 89.189. This is // Truncating to 0.9999 effectively limits latitude to 89.189. This is
// about a third of a tile past the edge of the world tile. // about a third of a tile past the edge of the world tile.
siny = Math.min(Math.max(siny, -0.9999), 0.9999); siny = Math.min(Math.max(siny, -0.9999), 0.9999);
const xWorld = TILE_SIZE * (0.5 + long / 360); const xWorld = TILE_SIZE * (0.5 + long / 360);
const yWorld = const yWorld =
TILE_SIZE * TILE_SIZE *
@ -391,7 +384,6 @@ export const serve_data = {
const xPixel = Math.floor(xWorld * scale) - xTile * TILE_SIZE; const xPixel = Math.floor(xWorld * scale) - xTile * TILE_SIZE;
const yPixel = Math.floor(yWorld * scale) - yTile * TILE_SIZE; const yPixel = Math.floor(yWorld * scale) - yTile * TILE_SIZE;
if ( if (
xPixel < 0 || xPixel < 0 ||
yPixel < 0 || yPixel < 0 ||
@ -400,12 +392,10 @@ export const serve_data = {
) { ) {
return reject('Out of bounds Pixel'); return reject('Out of bounds Pixel');
} }
const imgdata = context.getImageData(xPixel, yPixel, 1, 1); const imgdata = context.getImageData(xPixel, yPixel, 1, 1);
const red = imgdata.data[0]; const red = imgdata.data[0];
const green = imgdata.data[1]; const green = imgdata.data[1];
const blue = imgdata.data[2]; const blue = imgdata.data[2];
let elevation; let elevation;
if (encoding === 'mapbox') { if (encoding === 'mapbox') {
elevation = -10000 + (red * 256 * 256 + green * 256 + blue) * 0.1; elevation = -10000 + (red * 256 * 256 + green * 256 + blue) * 0.1;
@ -414,7 +404,6 @@ export const serve_data = {
} else { } else {
elevation = 'invalid encoding'; elevation = 'invalid encoding';
} }
resolve( resolve(
res.status(200).send({ res.status(200).send({
z: zoom, z: zoom,
@ -429,9 +418,7 @@ export const serve_data = {
}), }),
); );
}; };
image.onerror = (err) => reject(err); image.onerror = (err) => reject(err);
if (format === 'webp') { if (format === 'webp') {
try { try {
const img = await sharp(data).toFormat('png').toBuffer(); const img = await sharp(data).toFormat('png').toBuffer();