Skip to content

Commit f1ed481

Browse files
authored
Revert "feat(lambda-tiler): return 204 no content instead of a empty images (#2829)" (#2836)
This reverts commit db3ff1b. Research documentation suggest to use 200 Transparent Image. https://github.com/linz/basemaps/blob/master/docs/api/empty-tiles.md
1 parent 571af3f commit f1ed481

File tree

4 files changed

+4
-26
lines changed

4 files changed

+4
-26
lines changed

packages/lambda-tiler/src/__tests__/config.data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const TileSetAerial: ConfigTileSetRaster = {
2020
description: 'aerial__description',
2121
title: 'Aerial Imagery',
2222
category: 'Basemap',
23-
background: { r: 0xff, g: 0x00, b: 0xff, alpha: 0.5 },
2423
layers: [
2524
{
2625
2193: 'im_01FYWKAJ86W9P7RWM1VB62KD0H',

packages/lambda-tiler/src/routes/__tests__/attribution.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@ o.spec('/v1/attribution', () => {
309309

310310
o('should 304 with etag match', async () => {
311311
const request = mockUrlRequest(`/v1/attribution/aerial/EPSG:3857/summary.json`, 'get', {
312-
[HttpHeader.IfNoneMatch]: '3un15yA8o1ZDiyYpHXwUQHYXPxd5uGtzHS3R8gug9Nn1',
312+
[HttpHeader.IfNoneMatch]: 'E5HGpTqF8AiJ7VgGVKLehYnVfLN9jaVw8Sy6UafJRh2f',
313313
});
314314

315315
const res = await handler.router.handle(request);
316316

317-
if (res.status === 200) o(res.header('etag')).equals('3un15yA8o1ZDiyYpHXwUQHYXPxd5uGtzHS3R8gug9Nn1');
317+
if (res.status === 200) o(res.header('etag')).equals('E5HGpTqF8AiJ7VgGVKLehYnVfLN9jaVw8Sy6UafJRh2f');
318318

319319
console.log(res.header('etag'));
320320
o(res.status).equals(304);

packages/lambda-tiler/src/routes/__tests__/xyz.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,6 @@ o.spec('/v1/tiles', () => {
100100
o(resB.status).equals(404);
101101
});
102102

103-
o('should 204 if a tile is outside of the bounds', async () => {
104-
const fakeTileSet = FakeData.tileSetRaster('🦄 🌈');
105-
fakeTileSet.background = undefined;
106-
config.put(fakeTileSet);
107-
const res = await handler.router.handle(
108-
mockRequest('/v1/tiles/🦄 🌈/global-mercator/0/0/0.png', 'get', Api.header),
109-
);
110-
o(res.status).equals(204);
111-
});
112-
113103
o('should support utf8 tilesets', async () => {
114104
const fakeTileSet = FakeData.tileSetRaster('🦄 🌈');
115105
config.put(fakeTileSet);

packages/lambda-tiler/src/routes/tile.xyz.raster.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import pLimit from 'p-limit';
1010
import { ConfigLoader } from '../util/config.loader.js';
1111
import { Etag } from '../util/etag.js';
1212
import { filterLayers } from '../util/filter.js';
13-
import { NoContent, NotFound, NotModified } from '../util/response.js';
13+
import { NotFound, NotModified } from '../util/response.js';
1414
import { CoSources } from '../util/source.cache.js';
1515
import { TileXyz } from '../util/validate.js';
1616

@@ -106,25 +106,14 @@ export const TileXyzRaster = {
106106
const tiler = new Tiler(xyz.tileMatrix);
107107
const layers = await tiler.tile(assets, xyz.tile.x, xyz.tile.y, xyz.tile.z);
108108

109-
const background = tileSet.background ?? DefaultBackground;
110-
111109
const res = await TileComposer.compose({
112110
layers,
113111
format: xyz.tileType,
114-
background,
112+
background: tileSet.background ?? DefaultBackground,
115113
resizeKernel: tileSet.resizeKernel ?? DefaultResizeKernel,
116114
metrics: req.timer,
117115
});
118116

119-
// If no layers are used and the tile is going to be transparent
120-
// return 204 no content instead of a empty image
121-
if (res.layers === 0 && background.alpha === 0) {
122-
const response = NoContent();
123-
response.header(HttpHeader.ETag, cacheKey);
124-
response.header(HttpHeader.CacheControl, 'public, max-age=604800, stale-while-revalidate=86400');
125-
return response;
126-
}
127-
128117
req.set('layersUsed', res.layers);
129118
req.set('bytes', res.buffer.byteLength);
130119

0 commit comments

Comments
 (0)