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

fix(cli): Update the chunkd verison for the fix, and allow trailing slash uri #3140

Merged
merged 2 commits into from
Feb 22, 2024
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
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions packages/config-loader/src/json/__tests__/config.loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ConfigProviderMemory } from '@basemaps/config';
import { fsa, FsMemory, SourceMemory, Tiff } from '@basemaps/shared';
import { getTiffTagSize, TiffTag } from '@cogeotiff/core';

import { matchUri } from '../json.config.js';
import { getImageryName, initConfigFromUrls } from '../tiff.config.js';

const simpleTiff = new URL('../../../../__tests__/static/rgba8_tiled.tiff', import.meta.url);
Expand Down Expand Up @@ -152,4 +153,19 @@ describe('config import', () => {
'05-ecan-banks-peninsula-original-9mjdj',
);
});

it('should match uris with trailing slashes or macros', () => {
assert(
matchUri(
's3://linz-basemaps/3857/ōtorohanga_urban_2021_0-1m_RGB/01FYWKATAEK2ZTJQ2PX44Y0XNT/',
's3://linz-basemaps/3857/%C5%8Dtorohanga_urban_2021_0-1m_RGB/01FYWKATAEK2ZTJQ2PX44Y0XNT/',
),
);
assert(
matchUri(
's3://linz-basemaps/3857/ōtorohanga_urban_2021_0-1m_RGB/01FYWKATAEK2ZTJQ2PX44Y0XNT/',
's3://linz-basemaps/3857/ōtorohanga_urban_2021_0-1m_RGB/01FYWKATAEK2ZTJQ2PX44Y0XNT',
),
);
});
});
9 changes: 8 additions & 1 deletion packages/config-loader/src/json/json.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ function isTiff(u: URL): boolean {
return filePath.endsWith('.tiff') || filePath.endsWith('.tif');
}

export function matchUri(a: string, b: string): boolean {
const UrlA = new URL(a.endsWith('/') ? a : a + '/');
const UrlB = new URL(b.endsWith('/') ? b : b + '/');
if (UrlA.href === UrlB.href) return true;
return false;
}

export function guessIdFromUri(uri: string): string | null {
const parts = uri.split('/');
const id = uri.endsWith('/') ? parts.at(-2) : parts.at(-1);
Expand Down Expand Up @@ -199,7 +206,7 @@ export class ConfigJson {
): string | undefined {
if (uri == null) return uri;
if (uri.startsWith(ConfigPrefix.Imagery)) return uri;
const record = imagery.find((f) => f.uri === uri); ///
const record = imagery.find((f) => matchUri(f.uri, uri)); ///
if (record == null) throw new Error('Unable to find imagery id for uri:' + uri);

if (record.title && record.title !== layer.title) {
Expand Down
2 changes: 1 addition & 1 deletion packages/lambda-tiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"bundle": "./bundle.sh"
},
"devDependencies": {
"@chunkd/fs": "^11.2.0",
"@basemaps/attribution": "^7.0.0",
"@chunkd/fs": "^11.2.0",
"@types/aws-lambda": "^8.10.75",
"@types/pixelmatch": "^5.0.0",
"pretty-json-log": "^1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"@basemaps/geo": "^7.0.0",
"@basemaps/tiler": "^7.0.0",
"@chunkd/fs": "^11.2.0",
"@chunkd/fs-aws": "^11.2.1",
"@chunkd/middleware": "^11.0.1",
"@chunkd/fs-aws": "^11.2.2",
"@chunkd/middleware": "^11.1.0",
"@cogeotiff/core": "^9.0.3",
"@cotar/core": "^6.0.1",
"@linzjs/geojson": "^7.0.0",
Expand Down
Loading