chore: apply camelCase to function and variable names
Signed-off-by: Martin d'Allens <martin.dallens@liberty-rider.com>
This commit is contained in:
parent
9a4ef3dedf
commit
36d3e9d356
6 changed files with 73 additions and 73 deletions
|
@ -79,7 +79,7 @@
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<h3>{{tileJSON.name}}</h3>
|
<h3>{{tileJSON.name}}</h3>
|
||||||
<div class="identifier">identifier: {{@key}}{{#if formatted_filesize}} | size: {{formatted_filesize}}{{/if}}</div>
|
<div class="identifier">identifier: {{@key}}{{#if formatted_filesize}} | size: {{formatted_filesize}}{{/if}}</div>
|
||||||
<div class="identifier">type: {{#is_vector}}vector{{/is_vector}}{{^is_vector}}raster{{/is_vector}} data {{#if source_type}} | ext: {{source_type}}{{/if}}</div>
|
<div class="identifier">type: {{#is_vector}}vector{{/is_vector}}{{^is_vector}}raster{{/is_vector}} data {{#if sourceType}} | ext: {{sourceType}}{{/if}}</div>
|
||||||
<p class="services">
|
<p class="services">
|
||||||
services: <a href="{{public_url}}data/{{@key}}.json{{&../key_query}}">TileJSON</a>
|
services: <a href="{{public_url}}data/{{@key}}.json{{&../key_query}}">TileJSON</a>
|
||||||
{{#if xyz_link}}
|
{{#if xyz_link}}
|
||||||
|
|
22
src/main.js
22
src/main.js
|
@ -9,7 +9,7 @@ import axios from 'axios';
|
||||||
import { server } from './server.js';
|
import { server } from './server.js';
|
||||||
import MBTiles from '@mapbox/mbtiles';
|
import MBTiles from '@mapbox/mbtiles';
|
||||||
import { isValidHttpUrl } from './utils.js';
|
import { isValidHttpUrl } from './utils.js';
|
||||||
import { PMtilesOpen, GetPMtilesInfo } from './pmtiles_adapter.js';
|
import { openPMtiles, getPMtilesInfo } from './pmtiles_adapter.js';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
@ -62,7 +62,7 @@ const opts = program.opts();
|
||||||
|
|
||||||
console.log(`Starting ${packageJson.name} v${packageJson.version}`);
|
console.log(`Starting ${packageJson.name} v${packageJson.version}`);
|
||||||
|
|
||||||
const StartServer = (configPath, config) => {
|
const startServer = (configPath, config) => {
|
||||||
let publicUrl = opts.public_url;
|
let publicUrl = opts.public_url;
|
||||||
if (publicUrl && publicUrl.lastIndexOf('/') !== publicUrl.length - 1) {
|
if (publicUrl && publicUrl.lastIndexOf('/') !== publicUrl.length - 1) {
|
||||||
publicUrl += '/';
|
publicUrl += '/';
|
||||||
|
@ -81,7 +81,7 @@ const StartServer = (configPath, config) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const StartWithInputFile = async (inputFile) => {
|
const startWithInputFile = async (inputFile) => {
|
||||||
console.log(`[INFO] Automatically creating config file for ${inputFile}`);
|
console.log(`[INFO] Automatically creating config file for ${inputFile}`);
|
||||||
console.log(`[INFO] Only a basic preview style will be used.`);
|
console.log(`[INFO] Only a basic preview style will be used.`);
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -123,8 +123,8 @@ const StartWithInputFile = async (inputFile) => {
|
||||||
|
|
||||||
const extension = inputFile.split('.').pop().toLowerCase();
|
const extension = inputFile.split('.').pop().toLowerCase();
|
||||||
if (extension === 'pmtiles') {
|
if (extension === 'pmtiles') {
|
||||||
let FileOpenInfo = PMtilesOpen(inputFile);
|
const fileOpenInfo = openPMtiles(inputFile);
|
||||||
const metadata = await GetPMtilesInfo(FileOpenInfo);
|
const metadata = await getPMtilesInfo(fileOpenInfo);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
metadata.format === 'pbf' &&
|
metadata.format === 'pbf' &&
|
||||||
|
@ -174,7 +174,7 @@ const StartWithInputFile = async (inputFile) => {
|
||||||
console.log('Run with --verbose to see the config file here.');
|
console.log('Run with --verbose to see the config file here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return StartServer(null, config);
|
return startServer(null, config);
|
||||||
} else {
|
} else {
|
||||||
if (isValidHttpUrl(inputFile)) {
|
if (isValidHttpUrl(inputFile)) {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -235,7 +235,7 @@ const StartWithInputFile = async (inputFile) => {
|
||||||
console.log('Run with --verbose to see the config file here.');
|
console.log('Run with --verbose to see the config file here.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return StartServer(null, config);
|
return startServer(null, config);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ fs.stat(path.resolve(opts.config), async (err, stats) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputFile) {
|
if (inputFile) {
|
||||||
return StartWithInputFile(inputFile);
|
return startWithInputFile(inputFile);
|
||||||
} else {
|
} else {
|
||||||
// try to find in the cwd
|
// try to find in the cwd
|
||||||
const files = fs.readdirSync(process.cwd());
|
const files = fs.readdirSync(process.cwd());
|
||||||
|
@ -266,7 +266,7 @@ fs.stat(path.resolve(opts.config), async (err, stats) => {
|
||||||
}
|
}
|
||||||
if (inputFile) {
|
if (inputFile) {
|
||||||
console.log(`No input file specified, using ${inputFile}`);
|
console.log(`No input file specified, using ${inputFile}`);
|
||||||
return StartWithInputFile(inputFile);
|
return startWithInputFile(inputFile);
|
||||||
} else {
|
} else {
|
||||||
const url =
|
const url =
|
||||||
'https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles';
|
'https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles';
|
||||||
|
@ -283,7 +283,7 @@ fs.stat(path.resolve(opts.config), async (err, stats) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
response.data.pipe(writer);
|
response.data.pipe(writer);
|
||||||
writer.on('finish', () => StartWithInputFile(filename));
|
writer.on('finish', () => startWithInputFile(filename));
|
||||||
writer.on('error', (err) =>
|
writer.on('error', (err) =>
|
||||||
console.error(`Error writing file: ${err}`),
|
console.error(`Error writing file: ${err}`),
|
||||||
);
|
);
|
||||||
|
@ -294,6 +294,6 @@ fs.stat(path.resolve(opts.config), async (err, stats) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`Using specified config file from ${opts.config}`);
|
console.log(`Using specified config file from ${opts.config}`);
|
||||||
return StartServer(opts.config, null);
|
return startServer(opts.config, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ class PMTilesFileSource {
|
||||||
}
|
}
|
||||||
async getBytes(offset, length) {
|
async getBytes(offset, length) {
|
||||||
const buffer = Buffer.alloc(length);
|
const buffer = Buffer.alloc(length);
|
||||||
await ReadFileBytes(this.fd, buffer, offset);
|
await readFileBytes(this.fd, buffer, offset);
|
||||||
const ab = buffer.buffer.slice(
|
const ab = buffer.buffer.slice(
|
||||||
buffer.byteOffset,
|
buffer.byteOffset,
|
||||||
buffer.byteOffset + buffer.byteLength,
|
buffer.byteOffset + buffer.byteLength,
|
||||||
|
@ -26,7 +26,7 @@ class PMTilesFileSource {
|
||||||
* @param buffer
|
* @param buffer
|
||||||
* @param offset
|
* @param offset
|
||||||
*/
|
*/
|
||||||
async function ReadFileBytes(fd, buffer, offset) {
|
async function readFileBytes(fd, buffer, offset) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fs.read(fd, buffer, 0, buffer.length, offset, (err) => {
|
fs.read(fd, buffer, 0, buffer.length, offset, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -41,7 +41,7 @@ async function ReadFileBytes(fd, buffer, offset) {
|
||||||
*
|
*
|
||||||
* @param FilePath
|
* @param FilePath
|
||||||
*/
|
*/
|
||||||
export function PMtilesOpen(FilePath) {
|
export function openPMtiles(FilePath) {
|
||||||
let pmtiles = undefined;
|
let pmtiles = undefined;
|
||||||
|
|
||||||
if (isValidHttpUrl(FilePath)) {
|
if (isValidHttpUrl(FilePath)) {
|
||||||
|
@ -59,12 +59,12 @@ export function PMtilesOpen(FilePath) {
|
||||||
*
|
*
|
||||||
* @param pmtiles
|
* @param pmtiles
|
||||||
*/
|
*/
|
||||||
export async function GetPMtilesInfo(pmtiles) {
|
export async function getPMtilesInfo(pmtiles) {
|
||||||
const header = await pmtiles.getHeader();
|
const header = await pmtiles.getHeader();
|
||||||
const metadata = await pmtiles.getMetadata();
|
const metadata = await pmtiles.getMetadata();
|
||||||
|
|
||||||
//Add missing metadata from header
|
//Add missing metadata from header
|
||||||
metadata['format'] = GetPmtilesTileType(header.tileType).type;
|
metadata['format'] = getPmtilesTileType(header.tileType).type;
|
||||||
metadata['minzoom'] = header.minZoom;
|
metadata['minzoom'] = header.minZoom;
|
||||||
metadata['maxzoom'] = header.maxZoom;
|
metadata['maxzoom'] = header.maxZoom;
|
||||||
|
|
||||||
|
@ -103,23 +103,23 @@ export async function GetPMtilesInfo(pmtiles) {
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
*/
|
*/
|
||||||
export async function GetPMtilesTile(pmtiles, z, x, y) {
|
export async function getPMtilesTile(pmtiles, z, x, y) {
|
||||||
const header = await pmtiles.getHeader();
|
const header = await pmtiles.getHeader();
|
||||||
const TileType = GetPmtilesTileType(header.tileType);
|
const tileType = getPmtilesTileType(header.tileType);
|
||||||
let zxyTile = await pmtiles.getZxy(z, x, y);
|
let zxyTile = await pmtiles.getZxy(z, x, y);
|
||||||
if (zxyTile && zxyTile.data) {
|
if (zxyTile && zxyTile.data) {
|
||||||
zxyTile = Buffer.from(zxyTile.data);
|
zxyTile = Buffer.from(zxyTile.data);
|
||||||
} else {
|
} else {
|
||||||
zxyTile = undefined;
|
zxyTile = undefined;
|
||||||
}
|
}
|
||||||
return { data: zxyTile, header: TileType.header };
|
return { data: zxyTile, header: tileType.header };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param typenum
|
* @param typenum
|
||||||
*/
|
*/
|
||||||
function GetPmtilesTileType(typenum) {
|
function getPmtilesTileType(typenum) {
|
||||||
let head = {};
|
let head = {};
|
||||||
let tileType;
|
let tileType;
|
||||||
switch (typenum) {
|
switch (typenum) {
|
||||||
|
|
|
@ -12,9 +12,9 @@ import { VectorTile } from '@mapbox/vector-tile';
|
||||||
|
|
||||||
import { getTileUrls, isValidHttpUrl, fixTileJSONCenter } from './utils.js';
|
import { getTileUrls, isValidHttpUrl, fixTileJSONCenter } from './utils.js';
|
||||||
import {
|
import {
|
||||||
PMtilesOpen,
|
openPMtiles,
|
||||||
GetPMtilesInfo,
|
getPMtilesInfo,
|
||||||
GetPMtilesTile,
|
getPMtilesTile,
|
||||||
} from './pmtiles_adapter.js';
|
} from './pmtiles_adapter.js';
|
||||||
|
|
||||||
export const serve_data = {
|
export const serve_data = {
|
||||||
|
@ -53,8 +53,8 @@ export const serve_data = {
|
||||||
) {
|
) {
|
||||||
return res.status(404).send('Out of bounds');
|
return res.status(404).send('Out of bounds');
|
||||||
}
|
}
|
||||||
if (item.source_type === 'pmtiles') {
|
if (item.sourceType === 'pmtiles') {
|
||||||
let tileinfo = await GetPMtilesTile(item.source, z, x, y);
|
let tileinfo = await getPMtilesTile(item.source, z, x, y);
|
||||||
if (tileinfo == undefined || tileinfo.data == undefined) {
|
if (tileinfo == undefined || tileinfo.data == undefined) {
|
||||||
return res.status(404).send('Not found');
|
return res.status(404).send('Not found');
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,7 +99,7 @@ export const serve_data = {
|
||||||
|
|
||||||
return res.status(200).send(data);
|
return res.status(200).send(data);
|
||||||
}
|
}
|
||||||
} else if (item.source_type === 'mbtiles') {
|
} else if (item.sourceType === 'mbtiles') {
|
||||||
item.source.getTile(z, x, y, (err, data, headers) => {
|
item.source.getTile(z, x, y, (err, data, headers) => {
|
||||||
let isGzipped;
|
let isGzipped;
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -223,11 +223,11 @@ export const serve_data = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let source;
|
let source;
|
||||||
let source_type;
|
let sourceType;
|
||||||
if (inputType === 'pmtiles') {
|
if (inputType === 'pmtiles') {
|
||||||
source = PMtilesOpen(inputFile);
|
source = openPMtiles(inputFile);
|
||||||
source_type = 'pmtiles';
|
sourceType = 'pmtiles';
|
||||||
const metadata = await GetPMtilesInfo(source);
|
const metadata = await getPMtilesInfo(source);
|
||||||
|
|
||||||
tileJSON['name'] = id;
|
tileJSON['name'] = id;
|
||||||
tileJSON['format'] = 'pbf';
|
tileJSON['format'] = 'pbf';
|
||||||
|
@ -245,7 +245,7 @@ export const serve_data = {
|
||||||
tileJSON = options.dataDecoratorFunc(id, 'tilejson', tileJSON);
|
tileJSON = options.dataDecoratorFunc(id, 'tilejson', tileJSON);
|
||||||
}
|
}
|
||||||
} else if (inputType === 'mbtiles') {
|
} else if (inputType === 'mbtiles') {
|
||||||
source_type = 'mbtiles';
|
sourceType = 'mbtiles';
|
||||||
const sourceInfoPromise = new Promise((resolve, reject) => {
|
const sourceInfoPromise = new Promise((resolve, reject) => {
|
||||||
source = new MBTiles(inputFile + '?mode=ro', (err) => {
|
source = new MBTiles(inputFile + '?mode=ro', (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -285,7 +285,7 @@ export const serve_data = {
|
||||||
tileJSON,
|
tileJSON,
|
||||||
publicUrl,
|
publicUrl,
|
||||||
source,
|
source,
|
||||||
source_type,
|
sourceType,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,9 +25,9 @@ import {
|
||||||
fixTileJSONCenter,
|
fixTileJSONCenter,
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
import {
|
import {
|
||||||
PMtilesOpen,
|
openPMtiles,
|
||||||
GetPMtilesInfo,
|
getPMtilesInfo,
|
||||||
GetPMtilesTile,
|
getPMtilesTile,
|
||||||
} from './pmtiles_adapter.js';
|
} from './pmtiles_adapter.js';
|
||||||
import { renderOverlay, renderWatermark, renderAttribution } from './render.js';
|
import { renderOverlay, renderWatermark, renderAttribution } from './render.js';
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ const respondImage = (
|
||||||
if (mode === 'tile' && tileMargin === 0) {
|
if (mode === 'tile' && tileMargin === 0) {
|
||||||
pool = item.map.renderers[scale];
|
pool = item.map.renderers[scale];
|
||||||
} else {
|
} else {
|
||||||
pool = item.map.renderers_static[scale];
|
pool = item.map.renderersStatic[scale];
|
||||||
}
|
}
|
||||||
pool.acquire((err, renderer) => {
|
pool.acquire((err, renderer) => {
|
||||||
const mlglZ = Math.max(0, z - 1);
|
const mlglZ = Math.max(0, z - 1);
|
||||||
|
@ -471,14 +471,14 @@ const respondImage = (
|
||||||
image.resize(width * scale, height * scale);
|
image.resize(width * scale, height * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
const composite_array = [];
|
const composites = [];
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
composite_array.push({ input: overlay });
|
composites.push({ input: overlay });
|
||||||
}
|
}
|
||||||
if (item.watermark) {
|
if (item.watermark) {
|
||||||
const canvas = renderWatermark(width, height, scale, item.watermark);
|
const canvas = renderWatermark(width, height, scale, item.watermark);
|
||||||
|
|
||||||
composite_array.push({ input: canvas.toBuffer() });
|
composites.push({ input: canvas.toBuffer() });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === 'static' && item.staticAttributionText) {
|
if (mode === 'static' && item.staticAttributionText) {
|
||||||
|
@ -489,11 +489,11 @@ const respondImage = (
|
||||||
item.staticAttributionText,
|
item.staticAttributionText,
|
||||||
);
|
);
|
||||||
|
|
||||||
composite_array.push({ input: canvas.toBuffer() });
|
composites.push({ input: canvas.toBuffer() });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (composite_array.length > 0) {
|
if (composites.length > 0) {
|
||||||
image.composite(composite_array);
|
image.composite(composites);
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatQuality = (options.formatQuality || {})[format];
|
const formatQuality = (options.formatQuality || {})[format];
|
||||||
|
@ -847,9 +847,9 @@ export const serve_rendered = {
|
||||||
add: async (options, repo, params, id, publicUrl, dataResolver) => {
|
add: async (options, repo, params, id, publicUrl, dataResolver) => {
|
||||||
const map = {
|
const map = {
|
||||||
renderers: [],
|
renderers: [],
|
||||||
renderers_static: [],
|
renderersStatic: [],
|
||||||
sources: {},
|
sources: {},
|
||||||
source_types: {},
|
sourceTypes: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
let styleJSON;
|
let styleJSON;
|
||||||
|
@ -888,7 +888,7 @@ export const serve_rendered = {
|
||||||
const parts = req.url.split('/');
|
const parts = req.url.split('/');
|
||||||
const sourceId = parts[2];
|
const sourceId = parts[2];
|
||||||
const source = map.sources[sourceId];
|
const source = map.sources[sourceId];
|
||||||
const source_type = map.source_types[sourceId];
|
const sourceType = map.sourceTypes[sourceId];
|
||||||
const sourceInfo = styleJSON.sources[sourceId];
|
const sourceInfo = styleJSON.sources[sourceId];
|
||||||
|
|
||||||
const z = parts[3] | 0;
|
const z = parts[3] | 0;
|
||||||
|
@ -896,8 +896,8 @@ export const serve_rendered = {
|
||||||
const y = parts[5].split('.')[0] | 0;
|
const y = parts[5].split('.')[0] | 0;
|
||||||
const format = parts[5].split('.')[1];
|
const format = parts[5].split('.')[1];
|
||||||
|
|
||||||
if (source_type === 'pmtiles') {
|
if (sourceType === 'pmtiles') {
|
||||||
let tileinfo = await GetPMtilesTile(source, z, x, y);
|
let tileinfo = await getPMtilesTile(source, z, x, y);
|
||||||
let data = tileinfo.data;
|
let data = tileinfo.data;
|
||||||
let headers = tileinfo.header;
|
let headers = tileinfo.header;
|
||||||
if (data == undefined) {
|
if (data == undefined) {
|
||||||
|
@ -931,7 +931,7 @@ export const serve_rendered = {
|
||||||
|
|
||||||
callback(null, response);
|
callback(null, response);
|
||||||
}
|
}
|
||||||
} else if (source_type === 'mbtiles') {
|
} else if (sourceType === 'mbtiles') {
|
||||||
source.getTile(z, x, y, (err, data, headers) => {
|
source.getTile(z, x, y, (err, data, headers) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (options.verbose)
|
if (options.verbose)
|
||||||
|
@ -1092,7 +1092,7 @@ export const serve_rendered = {
|
||||||
|
|
||||||
const queue = [];
|
const queue = [];
|
||||||
for (const name of Object.keys(styleJSON.sources)) {
|
for (const name of Object.keys(styleJSON.sources)) {
|
||||||
let source_type;
|
let sourceType;
|
||||||
let source = styleJSON.sources[name];
|
let source = styleJSON.sources[name];
|
||||||
let url = source.url;
|
let url = source.url;
|
||||||
if (
|
if (
|
||||||
|
@ -1113,10 +1113,10 @@ export const serve_rendered = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let inputFile;
|
let inputFile;
|
||||||
const DataInfo = dataResolver(dataId);
|
const dataInfo = dataResolver(dataId);
|
||||||
if (DataInfo.inputFile) {
|
if (dataInfo.inputFile) {
|
||||||
inputFile = DataInfo.inputFile;
|
inputFile = dataInfo.inputFile;
|
||||||
source_type = DataInfo.fileType;
|
sourceType = dataInfo.fileType;
|
||||||
} else {
|
} else {
|
||||||
console.error(`ERROR: data "${inputFile}" not found!`);
|
console.error(`ERROR: data "${inputFile}" not found!`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -1129,10 +1129,10 @@ export const serve_rendered = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source_type === 'pmtiles') {
|
if (sourceType === 'pmtiles') {
|
||||||
map.sources[name] = PMtilesOpen(inputFile);
|
map.sources[name] = openPMtiles(inputFile);
|
||||||
map.source_types[name] = 'pmtiles';
|
map.sourceTypes[name] = 'pmtiles';
|
||||||
const metadata = await GetPMtilesInfo(map.sources[name]);
|
const metadata = await getPMtilesInfo(map.sources[name]);
|
||||||
|
|
||||||
if (!repoobj.dataProjWGStoInternalWGS && metadata.proj4) {
|
if (!repoobj.dataProjWGStoInternalWGS && metadata.proj4) {
|
||||||
// how to do this for multiple sources with different proj4 defs?
|
// how to do this for multiple sources with different proj4 defs?
|
||||||
|
@ -1177,7 +1177,7 @@ export const serve_rendered = {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
map.source_types[name] = 'mbtiles';
|
map.sourceTypes[name] = 'mbtiles';
|
||||||
|
|
||||||
if (!repoobj.dataProjWGStoInternalWGS && info.proj4) {
|
if (!repoobj.dataProjWGStoInternalWGS && info.proj4) {
|
||||||
// how to do this for multiple sources with different proj4 defs?
|
// how to do this for multiple sources with different proj4 defs?
|
||||||
|
@ -1236,7 +1236,7 @@ export const serve_rendered = {
|
||||||
const minPoolSize = minPoolSizes[i];
|
const minPoolSize = minPoolSizes[i];
|
||||||
const maxPoolSize = Math.max(minPoolSize, maxPoolSizes[j]);
|
const maxPoolSize = Math.max(minPoolSize, maxPoolSizes[j]);
|
||||||
map.renderers[s] = createPool(s, 'tile', minPoolSize, maxPoolSize);
|
map.renderers[s] = createPool(s, 'tile', minPoolSize, maxPoolSize);
|
||||||
map.renderers_static[s] = createPool(
|
map.renderersStatic[s] = createPool(
|
||||||
s,
|
s,
|
||||||
'static',
|
'static',
|
||||||
minPoolSize,
|
minPoolSize,
|
||||||
|
@ -1250,7 +1250,7 @@ export const serve_rendered = {
|
||||||
item.map.renderers.forEach((pool) => {
|
item.map.renderers.forEach((pool) => {
|
||||||
pool.close();
|
pool.close();
|
||||||
});
|
});
|
||||||
item.map.renderers_static.forEach((pool) => {
|
item.map.renderersStatic.forEach((pool) => {
|
||||||
pool.close();
|
pool.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,15 +179,15 @@ function start(opts) {
|
||||||
item,
|
item,
|
||||||
id,
|
id,
|
||||||
opts.publicUrl,
|
opts.publicUrl,
|
||||||
(StyleSourceId, protocol) => {
|
(styleSourceId, protocol) => {
|
||||||
let dataItemId;
|
let dataItemId;
|
||||||
for (const id of Object.keys(data)) {
|
for (const id of Object.keys(data)) {
|
||||||
if (id === StyleSourceId) {
|
if (id === styleSourceId) {
|
||||||
// Style id was found in data ids, return that id
|
// Style id was found in data ids, return that id
|
||||||
dataItemId = id;
|
dataItemId = id;
|
||||||
} else {
|
} else {
|
||||||
const fileType = Object.keys(data[id])[0];
|
const fileType = Object.keys(data[id])[0];
|
||||||
if (data[id][fileType] === StyleSourceId) {
|
if (data[id][fileType] === styleSourceId) {
|
||||||
// Style id was found in data filename, return the id that filename belong to
|
// Style id was found in data filename, return the id that filename belong to
|
||||||
dataItemId = id;
|
dataItemId = id;
|
||||||
}
|
}
|
||||||
|
@ -199,21 +199,21 @@ function start(opts) {
|
||||||
} else {
|
} else {
|
||||||
if (!allowMoreData) {
|
if (!allowMoreData) {
|
||||||
console.log(
|
console.log(
|
||||||
`ERROR: style "${item.style}" using unknown file "${StyleSourceId}"! Skipping...`,
|
`ERROR: style "${item.style}" using unknown file "${styleSourceId}"! Skipping...`,
|
||||||
);
|
);
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
let id =
|
let id =
|
||||||
StyleSourceId.substr(0, StyleSourceId.lastIndexOf('.')) ||
|
styleSourceId.substr(0, styleSourceId.lastIndexOf('.')) ||
|
||||||
StyleSourceId;
|
styleSourceId;
|
||||||
if (isValidHttpUrl(StyleSourceId)) {
|
if (isValidHttpUrl(styleSourceId)) {
|
||||||
id =
|
id =
|
||||||
fnv1a(StyleSourceId) + '_' + id.replace(/^.*\/(.*)$/, '$1');
|
fnv1a(styleSourceId) + '_' + id.replace(/^.*\/(.*)$/, '$1');
|
||||||
}
|
}
|
||||||
while (data[id]) id += '_'; //if the data source id already exists, add a "_" untill it doesn't
|
while (data[id]) id += '_'; //if the data source id already exists, add a "_" untill it doesn't
|
||||||
//Add the new data source to the data array.
|
//Add the new data source to the data array.
|
||||||
data[id] = {
|
data[id] = {
|
||||||
[protocol]: StyleSourceId,
|
[protocol]: styleSourceId,
|
||||||
};
|
};
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
@ -236,15 +236,15 @@ function start(opts) {
|
||||||
item,
|
item,
|
||||||
id,
|
id,
|
||||||
opts.publicUrl,
|
opts.publicUrl,
|
||||||
(StyleSourceId) => {
|
function dataResolver(styleSourceId) {
|
||||||
let fileType;
|
let fileType;
|
||||||
let inputFile;
|
let inputFile;
|
||||||
for (const id of Object.keys(data)) {
|
for (const id of Object.keys(data)) {
|
||||||
fileType = Object.keys(data[id])[0];
|
fileType = Object.keys(data[id])[0];
|
||||||
if (StyleSourceId == id) {
|
if (styleSourceId == id) {
|
||||||
inputFile = data[id][fileType];
|
inputFile = data[id][fileType];
|
||||||
break;
|
break;
|
||||||
} else if (data[id][fileType] == StyleSourceId) {
|
} else if (data[id][fileType] == styleSourceId) {
|
||||||
inputFile = data[id][fileType];
|
inputFile = data[id][fileType];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue