fix: don't unzip data, it is already done
the pmtiles getZxy function already decompresses the file Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
6ff506af99
commit
0c19728cc2
2 changed files with 2 additions and 23 deletions
|
|
@ -51,7 +51,6 @@ export const serve_data = {
|
|||
return res.status(404).send('Out of bounds');
|
||||
}
|
||||
if (tileJSONExtension === 'pmtiles') {
|
||||
let isGzipped;
|
||||
let tileinfo = await GetPMtilesTile(item.source, z, x, y);
|
||||
if (tileinfo == undefined || tileinfo.data == undefined) {
|
||||
return res.status(404).send('Not found');
|
||||
|
|
@ -59,13 +58,7 @@ export const serve_data = {
|
|||
let data = tileinfo.data;
|
||||
let headers = tileinfo.header;
|
||||
if (tileJSONFormat === 'pbf') {
|
||||
isGzipped =
|
||||
data.slice(0, 2).indexOf(Buffer.from([0x1f, 0x8b])) === 0;
|
||||
if (options.dataDecoratorFunc) {
|
||||
if (isGzipped) {
|
||||
data = zlib.unzipSync(data);
|
||||
isGzipped = false;
|
||||
}
|
||||
data = options.dataDecoratorFunc(id, 'data', data, z, x, y);
|
||||
}
|
||||
}
|
||||
|
|
@ -99,9 +92,7 @@ export const serve_data = {
|
|||
headers['Content-Encoding'] = 'gzip';
|
||||
res.set(headers);
|
||||
|
||||
if (!isGzipped) {
|
||||
data = zlib.gzipSync(data);
|
||||
}
|
||||
data = zlib.gzipSync(data);
|
||||
|
||||
return res.status(200).send(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1281,22 +1281,12 @@ export const serve_rendered = {
|
|||
return;
|
||||
} else {
|
||||
const response = {};
|
||||
response.data = data;
|
||||
if (headers['Last-Modified']) {
|
||||
response.modified = new Date(headers['Last-Modified']);
|
||||
}
|
||||
|
||||
if (format === 'pbf') {
|
||||
try {
|
||||
response.data = zlib.unzipSync(data);
|
||||
} catch (err) {
|
||||
console.log(
|
||||
'Skipping incorrect header for tile mbtiles://%s/%s/%s/%s.pbf',
|
||||
id,
|
||||
z,
|
||||
x,
|
||||
y,
|
||||
);
|
||||
}
|
||||
if (options.dataDecoratorFunc) {
|
||||
response.data = options.dataDecoratorFunc(
|
||||
sourceId,
|
||||
|
|
@ -1307,8 +1297,6 @@ export const serve_rendered = {
|
|||
y,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
response.data = data;
|
||||
}
|
||||
|
||||
callback(null, response);
|
||||
|
|
|
|||
Loading…
Reference in a new issue