fix: remove unneeded tileSize

Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
Andrew Calcutt 2024-01-22 00:21:54 -05:00
parent 0047cb0bbb
commit 222da24b03
4 changed files with 4 additions and 27 deletions

View file

@ -169,7 +169,6 @@ export const serve_data = {
); );
app.get('/:id.json', (req, res, next) => { app.get('/:id.json', (req, res, next) => {
const tileSize = undefined;
const item = repo[req.params.id]; const item = repo[req.params.id];
if (!item) { if (!item) {
return res.sendStatus(404); return res.sendStatus(404);
@ -179,7 +178,6 @@ export const serve_data = {
req, req,
info.tiles, info.tiles,
`data/${req.params.id}`, `data/${req.params.id}`,
tileSize,
info.format, info.format,
item.publicUrl, item.publicUrl,
{ {

View file

@ -823,7 +823,6 @@ export const serve_rendered = {
} }
app.get('/:id.json', (req, res, next) => { app.get('/:id.json', (req, res, next) => {
const tileSize = 512;
const item = repo[req.params.id]; const item = repo[req.params.id];
if (!item) { if (!item) {
return res.sendStatus(404); return res.sendStatus(404);
@ -833,7 +832,6 @@ export const serve_rendered = {
req, req,
info.tiles, info.tiles,
`styles/${req.params.id}`, `styles/${req.params.id}`,
tileSize,
info.format, info.format,
item.publicUrl, item.publicUrl,
); );

View file

@ -356,7 +356,6 @@ function start(opts) {
const addTileJSONs = (arr, req, type) => { const addTileJSONs = (arr, req, type) => {
for (const id of Object.keys(serving[type])) { for (const id of Object.keys(serving[type])) {
const tileSize = 256;
const info = clone(serving[type][id].tileJSON); const info = clone(serving[type][id].tileJSON);
let path = ''; let path = '';
if (type === 'rendered') { if (type === 'rendered') {
@ -368,7 +367,6 @@ function start(opts) {
req, req,
info.tiles, info.tiles,
path, path,
tileSize,
info.format, info.format,
opts.publicUrl, opts.publicUrl,
{ {
@ -454,7 +452,6 @@ function start(opts) {
}; };
if (style.serving_rendered) { if (style.serving_rendered) {
const tileSize = 256;
const { center } = style.serving_rendered.tileJSON; const { center } = style.serving_rendered.tileJSON;
if (center) { if (center) {
style.viewer_hash = `#${center[2]}/${center[1].toFixed( style.viewer_hash = `#${center[2]}/${center[1].toFixed(
@ -470,7 +467,6 @@ function start(opts) {
req, req,
style.serving_rendered.tileJSON.tiles, style.serving_rendered.tileJSON.tiles,
`styles/${id}`, `styles/${id}`,
tileSize,
style.serving_rendered.tileJSON.format, style.serving_rendered.tileJSON.format,
opts.publicUrl, opts.publicUrl,
)[0]; )[0];
@ -494,19 +490,17 @@ function start(opts) {
data.is_vector = tileJSON.format === 'pbf'; data.is_vector = tileJSON.format === 'pbf';
if (!data.is_vector) { if (!data.is_vector) {
const tileSize = 256;
if (center) { if (center) {
const centerPx = mercator.px([center[0], center[1]], center[2]); const centerPx = mercator.px([center[0], center[1]], center[2]);
data.thumbnail = `${center[2]}/${Math.floor( data.thumbnail = `${center[2]}/${Math.floor(
centerPx[0] / 256, centerPx[0] / 256,
)}/${Math.floor(centerPx[1] / tileSize)}.${tileJSON.format}`; )}/${Math.floor(centerPx[1] / 256)}.${tileJSON.format}`;
} }
data.xyz_link = getTileUrls( data.xyz_link = getTileUrls(
req, req,
tileJSON.tiles, tileJSON.tiles,
`data/${id}`, `data/${id}`,
tileSize,
tileJSON.format, tileJSON.format,
opts.publicUrl, opts.publicUrl,
{ {

View file

@ -26,15 +26,7 @@ export const getPublicUrl = (publicUrl, req) => {
return getUrlObject(req).toString(); return getUrlObject(req).toString();
}; };
export const getTileUrls = ( export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
req,
domains,
path,
tileSize,
format,
publicUrl,
aliases,
) => {
const urlObject = getUrlObject(req); const urlObject = getUrlObject(req);
if (domains) { if (domains) {
if (domains.constructor === String && domains.length > 0) { if (domains.constructor === String && domains.length > 0) {
@ -75,20 +67,15 @@ export const getTileUrls = (
format = aliases[format]; format = aliases[format];
} }
let tileParams = '{z}/{x}/{y}';
if (tileSize && ['png', 'jpg', 'jpeg', 'webp'].includes(format)) {
tileParams = '{tileSize}/{z}/{x}/{y}';
}
const uris = []; const uris = [];
if (!publicUrl) { if (!publicUrl) {
for (const domain of domains) { for (const domain of domains) {
uris.push( uris.push(
`${req.protocol}://${domain}/${path}/${tileParams}.${format}${query}`, `${req.protocol}://${domain}/${path}/{tileSize}/{z}/{x}/{y}.${format}${query}`,
); );
} }
} else { } else {
uris.push(`${publicUrl}${path}/${tileParams}.${format}${query}`); uris.push(`${publicUrl}${path}/{tileSize}/{z}/{x}/{y}.${format}${query}`);
} }
return uris; return uris;