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) => {
|
||||
const tileSize = undefined;
|
||||
const item = repo[req.params.id];
|
||||
if (!item) {
|
||||
return res.sendStatus(404);
|
||||
|
|
@ -178,6 +179,7 @@ export const serve_data = {
|
|||
req,
|
||||
info.tiles,
|
||||
`data/${req.params.id}`,
|
||||
tileSize,
|
||||
info.format,
|
||||
item.publicUrl,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -823,6 +823,7 @@ export const serve_rendered = {
|
|||
}
|
||||
|
||||
app.get('/:id.json', (req, res, next) => {
|
||||
const tileSize = 512;
|
||||
const item = repo[req.params.id];
|
||||
if (!item) {
|
||||
return res.sendStatus(404);
|
||||
|
|
@ -832,6 +833,7 @@ export const serve_rendered = {
|
|||
req,
|
||||
info.tiles,
|
||||
`styles/${req.params.id}`,
|
||||
tileSize,
|
||||
info.format,
|
||||
item.publicUrl,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -356,6 +356,7 @@ function start(opts) {
|
|||
|
||||
const addTileJSONs = (arr, req, type) => {
|
||||
for (const id of Object.keys(serving[type])) {
|
||||
const tileSize = 256;
|
||||
const info = clone(serving[type][id].tileJSON);
|
||||
let path = '';
|
||||
if (type === 'rendered') {
|
||||
|
|
@ -367,6 +368,7 @@ function start(opts) {
|
|||
req,
|
||||
info.tiles,
|
||||
path,
|
||||
tileSize,
|
||||
info.format,
|
||||
opts.publicUrl,
|
||||
{
|
||||
|
|
@ -452,6 +454,7 @@ function start(opts) {
|
|||
};
|
||||
|
||||
if (style.serving_rendered) {
|
||||
const tileSize = 256;
|
||||
const { center } = style.serving_rendered.tileJSON;
|
||||
if (center) {
|
||||
style.viewer_hash = `#${center[2]}/${center[1].toFixed(5)}/${center[0].toFixed(5)}`;
|
||||
|
|
@ -465,6 +468,7 @@ function start(opts) {
|
|||
req,
|
||||
style.serving_rendered.tileJSON.tiles,
|
||||
`styles/${id}`,
|
||||
tileSize,
|
||||
style.serving_rendered.tileJSON.format,
|
||||
opts.publicUrl,
|
||||
)[0];
|
||||
|
|
@ -488,17 +492,19 @@ function start(opts) {
|
|||
|
||||
data.is_vector = tileJSON.format === 'pbf';
|
||||
if (!data.is_vector) {
|
||||
const tileSize = 256;
|
||||
if (center) {
|
||||
const centerPx = mercator.px([center[0], center[1]], center[2]);
|
||||
data.thumbnail = `${center[2]}/${Math.floor(
|
||||
centerPx[0] / 256,
|
||||
)}/${Math.floor(centerPx[1] / 256)}.${tileJSON.format}`;
|
||||
)}/${Math.floor(centerPx[1] / tileSize)}.${tileJSON.format}`;
|
||||
}
|
||||
|
||||
data.xyz_link = getTileUrls(
|
||||
req,
|
||||
tileJSON.tiles,
|
||||
`data/${id}`,
|
||||
tileSize,
|
||||
tileJSON.format,
|
||||
opts.publicUrl,
|
||||
{
|
||||
|
|
|
|||
19
src/utils.js
19
src/utils.js
|
|
@ -26,7 +26,15 @@ export const getPublicUrl = (publicUrl, req) => {
|
|||
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);
|
||||
if (domains) {
|
||||
if (domains.constructor === String && domains.length > 0) {
|
||||
|
|
@ -67,15 +75,20 @@ export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
|
|||
format = aliases[format];
|
||||
}
|
||||
|
||||
let tileParams = '{z}/{x}/{y}';
|
||||
if (tileSize && ['png', 'jpg', 'jpeg', 'webp'].includes(format)) {
|
||||
tileParams = '{tileSize}/{z}/{x}/{y}';
|
||||
}
|
||||
|
||||
const uris = [];
|
||||
if (!publicUrl) {
|
||||
for (const domain of domains) {
|
||||
uris.push(
|
||||
`${req.protocol}://${domain}/${path}/{tileSize}/{z}/{x}/{y}.${format}${query}`,
|
||||
`${req.protocol}://${domain}/${path}/${tileParams}.${format}${query}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
uris.push(`${publicUrl}${path}/{tileSize}/{z}/{x}/{y}.${format}${query}`);
|
||||
uris.push(`${publicUrl}${path}/${tileParams}.${format}${query}`);
|
||||
}
|
||||
|
||||
return uris;
|
||||
|
|
|
|||
Loading…
Reference in a new issue