Remove obsolete old code
This commit is contained in:
parent
cdc7803ad8
commit
515c295898
3 changed files with 3 additions and 41 deletions
|
@ -10,12 +10,6 @@ const MBTiles = require('@mapbox/mbtiles');
|
|||
const Pbf = require('pbf');
|
||||
const VectorTile = require('@mapbox/vector-tile').VectorTile;
|
||||
|
||||
let tileshrinkGl;
|
||||
try {
|
||||
tileshrinkGl = require('tileshrink-gl');
|
||||
global.addStyleParam = true;
|
||||
} catch (e) {}
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = (options, repo, params, id, styles, publicUrl) => {
|
||||
|
@ -26,8 +20,6 @@ module.exports = (options, repo, params, id, styles, publicUrl) => {
|
|||
'tiles': params.domains || options.domains
|
||||
};
|
||||
|
||||
const shrinkers = {};
|
||||
|
||||
repo[id] = tileJSON;
|
||||
|
||||
const mbtilesFileStats = fs.statSync(mbtilesFile);
|
||||
|
@ -101,32 +93,6 @@ module.exports = (options, repo, params, id, styles, publicUrl) => {
|
|||
if (tileJSON['format'] === 'pbf') {
|
||||
isGzipped = data.slice(0, 2).indexOf(
|
||||
new Buffer([0x1f, 0x8b])) === 0;
|
||||
const style = req.query.style;
|
||||
if (style && tileshrinkGl) {
|
||||
if (!shrinkers[style]) {
|
||||
const styleJSON = styles[style];
|
||||
if (styleJSON) {
|
||||
let sourceName = null;
|
||||
for (let sourceName_ in styleJSON.sources) {
|
||||
const source = styleJSON.sources[sourceName_];
|
||||
if (source &&
|
||||
source.type === 'vector' &&
|
||||
source.url.endsWith(`/${id}.json`)) {
|
||||
sourceName = sourceName_;
|
||||
}
|
||||
}
|
||||
shrinkers[style] = tileshrinkGl.createPBFShrinker(styleJSON, sourceName);
|
||||
}
|
||||
}
|
||||
if (shrinkers[style]) {
|
||||
if (isGzipped) {
|
||||
data = zlib.unzipSync(data);
|
||||
isGzipped = false;
|
||||
}
|
||||
data = shrinkers[style](data, z, tileJSON.maxzoom);
|
||||
//console.log(shrinkers[style].getStats());
|
||||
}
|
||||
}
|
||||
if (options.dataDecoratorFunc) {
|
||||
if (isGzipped) {
|
||||
data = zlib.unzipSync(data);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const clone = require('clone');
|
||||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
|
|
@ -64,14 +64,11 @@ module.exports = (options, repo, params, id, publicUrl, reportTiles, reportFont)
|
|||
repo[id] = styleJSON;
|
||||
|
||||
app.get(`/${id}/style.json`, (req, res, next) => {
|
||||
const fixUrl = (url, opt_nokey, opt_nostyle) => {
|
||||
const fixUrl = (url, opt_nokey) => {
|
||||
if (!url || (typeof url !== 'string') || url.indexOf('local://') !== 0) {
|
||||
return url;
|
||||
}
|
||||
const queryParams = [];
|
||||
if (!opt_nostyle && global.addStyleParam) {
|
||||
queryParams.push(`style=${id}`);
|
||||
}
|
||||
if (!opt_nokey && req.query.key) {
|
||||
queryParams.unshift(`key=${req.query.key}`);
|
||||
}
|
||||
|
@ -90,10 +87,10 @@ module.exports = (options, repo, params, id, publicUrl, reportTiles, reportFont)
|
|||
}
|
||||
// mapbox-gl-js viewer cannot handle sprite urls with query
|
||||
if (styleJSON_.sprite) {
|
||||
styleJSON_.sprite = fixUrl(styleJSON_.sprite, true, true);
|
||||
styleJSON_.sprite = fixUrl(styleJSON_.sprite, true);
|
||||
}
|
||||
if (styleJSON_.glyphs) {
|
||||
styleJSON_.glyphs = fixUrl(styleJSON_.glyphs, false, true);
|
||||
styleJSON_.glyphs = fixUrl(styleJSON_.glyphs, false);
|
||||
}
|
||||
return res.send(styleJSON_);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue