Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(landing): support ?tileFormat as a alias to format BM-636 #2333

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/lambda-tiler/src/routes/__tests__/wmts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ o.spec('GetImageFormats', () => {
const formats = getImageFormats(req);
o(formats).deepEquals([ImageFormat.Png, ImageFormat.Jpeg]);
});

o('should support "tileFormat" Alias all formats', () => {
const req = newRequest('/v1/blank', 'tileFormat=png&format=jpeg');
const formats = getImageFormats(req);
o(formats).deepEquals([ImageFormat.Jpeg, ImageFormat.Png]);
});

o('should not duplicate "tileFormat" alias all formats', () => {
const req = newRequest('/v1/blank', 'tileFormat=jpeg&format=jpeg');
const formats = getImageFormats(req);
o(formats).deepEquals([ImageFormat.Jpeg]);
});
});

o.spec('WMTSRouting', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/lambda-tiler/src/routes/tile.wmts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import { NotFound, NotModified } from './response.js';
import { TileEtag } from './tile.etag.js';

export function getImageFormats(req: LambdaHttpRequest): ImageFormat[] | undefined {
const formats = req.query.getAll('format');
if (formats == null || formats.length === 0) return undefined;
const formats = [...req.query.getAll('format'), ...req.query.getAll('tileFormat')];
if (formats.length === 0) return;

const output: Set<ImageFormat> = new Set();
for (const fmt of formats) {
const parsed = getImageFormat(fmt);
if (parsed == null) continue;
output.add(parsed);
}
if (output.size === 0) return undefined;
if (output.size === 0) return;
return [...output.values()];
}

Expand Down