applied lint:js:fix

This commit is contained in:
Miko 2024-10-13 22:54:31 +02:00
parent 21a25592d2
commit c94bd22b8e
3 changed files with 41 additions and 19 deletions

View file

@ -174,8 +174,8 @@ export const serve_data = {
}
if (
item.source._info.encoding != "terrarium" &&
item.source._info.encoding != "mapbox"
item.source._info.encoding != 'terrarium' &&
item.source._info.encoding != 'mapbox'
) {
return res.status(404).send('Missing encoding');
}
@ -263,20 +263,36 @@ export const serve_data = {
var green = imgdata.data[index + 1];
var blue = imgdata.data[index + 2];
let elevation;
if (item.source._info.encoding == "mapbox") {
elevation = -10000 + ((red * 256 * 256 + green * 256 + blue) * 0.1);
} else if (item.source._info.encoding == "terrarium") {
elevation = (red * 256 + green + blue / 256) - 32768;
if (item.source._info.encoding == 'mapbox') {
elevation =
-10000 + (red * 256 * 256 + green * 256 + blue) * 0.1;
} else if (item.source._info.encoding == 'terrarium') {
elevation = red * 256 + green + blue / 256 - 32768;
} else {
elevation = "invalid encoding";
elevation = 'invalid encoding';
}
//"index": index, "length": imgdata.data.length,
return res.status(200).send({ "z": z, "x": xy[0], "y": xy[1], "red": red, "green": green, "blue": blue, "latitude": tileCenter[0], "longitude": tileCenter[1], "elevation": elevation });
return res.status(200).send({
z: z,
x: xy[0],
y: xy[1],
red: red,
green: green,
blue: blue,
latitude: tileCenter[0],
longitude: tileCenter[1],
elevation: elevation,
});
};
image.onerror = (err) => {
return res
.status(500)
.header('Content-Type', 'text/plain')
.send(err.message);
};
image.onerror = err => { return res.status(500).header('Content-Type', 'text/plain').send(err.message); }
//image.onerror = err => { return res.status(200).header('Content-Type', 'image/webp').send(data); }
if (item.source._info.format == "webp") {
if (item.source._info.format == 'webp') {
const img = await sharp(data).toFormat('png').toBuffer();
image.src = img;
} else {
@ -372,7 +388,7 @@ export const serve_data = {
const mbw = await openMbTilesWrapper(inputFile);
const info = await mbw.getInfo();
source = mbw.getMbTiles();
info["encoding"] = params["encoding"];
info['encoding'] = params['encoding'];
tileJSON['name'] = id;
tileJSON['format'] = 'pbf';

View file

@ -513,13 +513,16 @@ function start(opts) {
data.is_vector = tileJSON.format === 'pbf';
if (!data.is_vector) {
if ((tileJSON.encoding === 'terrarium' || tileJSON.encoding === 'mapbox')) {
if (
tileJSON.encoding === 'terrarium' ||
tileJSON.encoding === 'mapbox'
) {
data.elevation_link = getTileUrls(
req,
tileJSON.tiles,
`data/${id}/elevation`
`data/${id}/elevation`,
)[0];
};
}
if (center) {
const centerPx = mercator.px([center[0], center[1]], center[2]);
data.thumbnail = `${center[2]}/${Math.floor(centerPx[0] / 256)}/${Math.floor(centerPx[1] / 256)}.${tileJSON.format}`;
@ -610,13 +613,16 @@ function start(opts) {
if (!data) {
return null;
}
const is_terrain = ((data.tileJSON.encoding === 'terrarium' || data.tileJSON.encoding === 'mapbox') && (preview === "preview"));
const is_terrain =
(data.tileJSON.encoding === 'terrarium' ||
data.tileJSON.encoding === 'mapbox') &&
preview === 'preview';
return {
...data,
id,
use_maplibre: (data.tileJSON.format === 'pbf' || is_terrain),
use_maplibre: data.tileJSON.format === 'pbf' || is_terrain,
is_terrain: is_terrain,
is_terrainrgb: (data.tileJSON.encoding === "mapbox"),
is_terrainrgb: data.tileJSON.encoding === 'mapbox',
terrain_encoding: data.tileJSON.encoding,
};
});

View file

@ -119,10 +119,10 @@ export const getTileUrls = (
tileParams = `${tileSize}/{z}/{x}/{y}`;
}
if (format && format != "") {
if (format && format != '') {
format = `.${format}`;
} else {
format = "";
format = '';
}
const uris = [];