Revert "fix: remove unneeded tileSize"
This reverts commit a4583161bf53653d65a4606c407ba9b5249d1061.
This commit is contained in:
parent
b2787b89ed
commit
24f6a833ec
4 changed files with 27 additions and 4 deletions
|
|
@ -169,6 +169,7 @@ 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);
|
||||||
|
|
@ -178,6 +179,7 @@ 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,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -823,6 +823,7 @@ 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);
|
||||||
|
|
@ -832,6 +833,7 @@ 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,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,7 @@ 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') {
|
||||||
|
|
@ -367,6 +368,7 @@ function start(opts) {
|
||||||
req,
|
req,
|
||||||
info.tiles,
|
info.tiles,
|
||||||
path,
|
path,
|
||||||
|
tileSize,
|
||||||
info.format,
|
info.format,
|
||||||
opts.publicUrl,
|
opts.publicUrl,
|
||||||
{
|
{
|
||||||
|
|
@ -452,6 +454,7 @@ 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(5)}/${center[0].toFixed(5)}`;
|
style.viewer_hash = `#${center[2]}/${center[1].toFixed(5)}/${center[0].toFixed(5)}`;
|
||||||
|
|
@ -465,6 +468,7 @@ 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];
|
||||||
|
|
@ -488,17 +492,19 @@ 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] / 256)}.${tileJSON.format}`;
|
)}/${Math.floor(centerPx[1] / tileSize)}.${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,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
19
src/utils.js
19
src/utils.js
|
|
@ -26,7 +26,15 @@ export const getPublicUrl = (publicUrl, req) => {
|
||||||
return getUrlObject(req).toString();
|
return getUrlObject(req).toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
|
export const getTileUrls = (
|
||||||
|
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) {
|
||||||
|
|
@ -67,15 +75,20 @@ export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
|
||||||
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}/{tileSize}/{z}/{x}/{y}.${format}${query}`,
|
`${req.protocol}://${domain}/${path}/${tileParams}.${format}${query}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uris.push(`${publicUrl}${path}/{tileSize}/{z}/{x}/{y}.${format}${query}`);
|
uris.push(`${publicUrl}${path}/${tileParams}.${format}${query}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return uris;
|
return uris;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue