fix: match docs source behavior
Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
c866de4691
commit
065b3742f0
2 changed files with 139 additions and 148 deletions
|
|
@ -6,8 +6,8 @@ import path from 'path';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
import zlib from 'zlib';
|
import zlib from 'zlib';
|
||||||
import { createCanvas, Image } from 'canvas';
|
|
||||||
import sharp from 'sharp'; // sharp has to be required before node-canvas on linux but after it on windows. see https://github.com/lovell/sharp/issues/371
|
import sharp from 'sharp'; // sharp has to be required before node-canvas on linux but after it on windows. see https://github.com/lovell/sharp/issues/371
|
||||||
|
import { createCanvas, Image } from 'canvas';
|
||||||
import clone from 'clone';
|
import clone from 'clone';
|
||||||
import Color from 'color';
|
import Color from 'color';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
|
@ -1470,11 +1470,10 @@ export const serve_rendered = {
|
||||||
let source_type;
|
let source_type;
|
||||||
let source = styleJSON.sources[name];
|
let source = styleJSON.sources[name];
|
||||||
let url = source.url;
|
let url = source.url;
|
||||||
if (url) {
|
if (
|
||||||
if (url.startsWith('{') && url.endsWith('}')) {
|
url &&
|
||||||
url = url.slice(1, -1);
|
(url.startsWith('pmtiles://') || url.startsWith('mbtiles://'))
|
||||||
}
|
) {
|
||||||
if (url.startsWith('pmtiles://') || url.startsWith('mbtiles://')) {
|
|
||||||
// found pmtiles or mbtiles source, replace with info from local file
|
// found pmtiles or mbtiles source, replace with info from local file
|
||||||
delete source.url;
|
delete source.url;
|
||||||
|
|
||||||
|
|
@ -1548,9 +1547,7 @@ export const serve_rendered = {
|
||||||
if (!inputFileStats.isFile() || inputFileStats.size === 0) {
|
if (!inputFileStats.isFile() || inputFileStats.size === 0) {
|
||||||
throw Error(`Not valid MBTiles file: "${inputFile}"`);
|
throw Error(`Not valid MBTiles file: "${inputFile}"`);
|
||||||
}
|
}
|
||||||
map.sources[name] = new MBTiles(
|
map.sources[name] = new MBTiles(inputFile + '?mode=ro', (err) => {
|
||||||
inputFile + '?mode=ro',
|
|
||||||
(err) => {
|
|
||||||
map.sources[name].getInfo((err, info) => {
|
map.sources[name].getInfo((err, info) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
@ -1589,9 +1586,7 @@ export const serve_rendered = {
|
||||||
source.attribution &&
|
source.attribution &&
|
||||||
source.attribution.length > 0
|
source.attribution.length > 0
|
||||||
) {
|
) {
|
||||||
if (
|
if (!tileJSON.attribution.includes(source.attribution)) {
|
||||||
!tileJSON.attribution.includes(source.attribution)
|
|
||||||
) {
|
|
||||||
if (tileJSON.attribution.length > 0) {
|
if (tileJSON.attribution.length > 0) {
|
||||||
tileJSON.attribution += ' | ';
|
tileJSON.attribution += ' | ';
|
||||||
}
|
}
|
||||||
|
|
@ -1600,14 +1595,12 @@ export const serve_rendered = {
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const renderersReadyPromise = Promise.all(queue).then(() => {
|
const renderersReadyPromise = Promise.all(queue).then(() => {
|
||||||
// standard and @2x tiles are much more usual -> default to larger pools
|
// standard and @2x tiles are much more usual -> default to larger pools
|
||||||
|
|
|
||||||
|
|
@ -111,11 +111,10 @@ export const serve_style = {
|
||||||
for (const name of Object.keys(styleJSON.sources)) {
|
for (const name of Object.keys(styleJSON.sources)) {
|
||||||
const source = styleJSON.sources[name];
|
const source = styleJSON.sources[name];
|
||||||
let url = source.url;
|
let url = source.url;
|
||||||
if (url) {
|
if (
|
||||||
if (url.startsWith('{') && url.endsWith('}')) {
|
url &&
|
||||||
url = url.slice(1, -1);
|
(url.startsWith('pmtiles://') || url.startsWith('mbtiles://'))
|
||||||
}
|
) {
|
||||||
if (url.startsWith('pmtiles://') || url.startsWith('mbtiles://')) {
|
|
||||||
const protocol = url.split(':')[0];
|
const protocol = url.split(':')[0];
|
||||||
|
|
||||||
let dataId = url.replace('pmtiles://', '').replace('mbtiles://', '');
|
let dataId = url.replace('pmtiles://', '').replace('mbtiles://', '');
|
||||||
|
|
@ -135,7 +134,6 @@ export const serve_style = {
|
||||||
source.url = `local://data/${identifier}.json`;
|
source.url = `local://data/${identifier}.json`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (const obj of styleJSON.layers) {
|
for (const obj of styleJSON.layers) {
|
||||||
if (obj['type'] === 'symbol') {
|
if (obj['type'] === 'symbol') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue