mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-16 06:14:19 +01:00
Update fontstacks URL according to https://github.com/klokantech/tileserver-gl/pull/104#issuecomment-274444087
This commit is contained in:
parent
fd291490d0
commit
bbf26a3f38
1 changed files with 10 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
import request from 'request'
|
import request from 'request'
|
||||||
|
import npmurl from 'url'
|
||||||
|
|
||||||
function loadJSON(url, defaultValue, cb) {
|
function loadJSON(url, defaultValue, cb) {
|
||||||
request({
|
request({
|
||||||
|
@ -23,9 +24,15 @@ export function downloadGlyphsMetadata(urlTemplate, cb) {
|
||||||
if(!urlTemplate) return cb([])
|
if(!urlTemplate) return cb([])
|
||||||
|
|
||||||
// Special handling because Tileserver GL serves the fontstacks metadata differently
|
// Special handling because Tileserver GL serves the fontstacks metadata differently
|
||||||
// https://github.com/klokantech/tileserver-gl/pull/104
|
// https://github.com/klokantech/tileserver-gl/pull/104#issuecomment-274444087
|
||||||
let url = urlTemplate.replace('/fonts/{fontstack}/{range}.pbf', '/fontstacks.json')
|
let urlObj = npmurl.parse(urlTemplate);
|
||||||
url = url.replace('{fontstack}/{range}.pbf', 'fontstacks.json')
|
const normPathPart = '/%7Bfontstack%7D/%7Brange%7D.pbf';
|
||||||
|
if(urlObj.pathname === normPathPart) {
|
||||||
|
urlObj.pathname = '/fontstacks.json';
|
||||||
|
} else {
|
||||||
|
urlObj.pathname = urlObj.pathname.replace(normPathPart, '.json');
|
||||||
|
}
|
||||||
|
let url = npmurl.format(urlObj);
|
||||||
|
|
||||||
loadJSON(url, [], cb)
|
loadJSON(url, [], cb)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue