From 515c295898e5b30591dd5d02e9badc4f70a3c4e6 Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Mon, 30 Dec 2019 17:00:23 +0100 Subject: [PATCH] Remove obsolete old code --- src/serve_data.js | 34 ---------------------------------- src/serve_font.js | 1 - src/serve_style.js | 9 +++------ 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/src/serve_data.js b/src/serve_data.js index a7929d2..4cec5e5 100644 --- a/src/serve_data.js +++ b/src/serve_data.js @@ -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); diff --git a/src/serve_font.js b/src/serve_font.js index 9123fe6..c7212e9 100644 --- a/src/serve_font.js +++ b/src/serve_font.js @@ -1,6 +1,5 @@ 'use strict'; -const clone = require('clone'); const express = require('express'); const fs = require('fs'); const path = require('path'); diff --git a/src/serve_style.js b/src/serve_style.js index 71cd4ee..65b9669 100644 --- a/src/serve_style.js +++ b/src/serve_style.js @@ -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_); });