Skip to content

Commit

Permalink
feat: lint resolution TDE-938 (#747)
Browse files Browse the repository at this point in the history
#### Motivation

ensure that the resolution of the dataset name in the target key doesn't
have a trailing 0.
For example:
0.3m not 0.30m 
(This is just for naming conventions and is written manually).

#### Modification

resolution check added to `lint-inputs` command

#### Checklist

_If not applicable, provide explanation of why._

- [x] Tests updated
- [x] Docs updated - not required
- [x] Issue linked in Title
  • Loading branch information
MDavidson17 authored Nov 14, 2023
1 parent f8b8f06 commit b4b8512
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/commands/lint/__test__/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,27 @@ describe('lintImageryPaths', () => {
describe('lintImageryPaths', () => {
it('Should Fail - Incorrect Region', () => {
assert.throws(() => {
lintImageryPath('/hawkesbay/hawkes-bay_2018_0-75m/rgb/2193/');
lintImageryPath('/hawkesbay/hawkes-bay_2018_0.75m/rgb/2193/');
}, Error('region not in region list: hawkesbay'));
});
it('Should Fail - Incorrect product', () => {
assert.throws(() => {
lintImageryPath('/hawkes-bay/hawkes-bay_2018_0-75m/rgbi/2193/');
lintImageryPath('/hawkes-bay/hawkes-bay_2018_0.75m/rgbi/2193/');
}, Error('product not in product list: rgbi'));
});
it('Should Fail - Incorrect Crs', () => {
assert.throws(() => {
lintImageryPath('/auckland/auckland_2020_0-2m/rgb/219/');
lintImageryPath('/auckland/auckland_2020_0.2m/rgb/219/');
}, Error('crs not in crs list: 219'));
});
it('Should Fail - Trailing 0', () => {
assert.throws(() => {
lintImageryPath('/auckland/auckland_2020_0.20m/rgb/2193/');
}, Error('Trailing 0 in resolution of dataset name: auckland_2020_0.20m'));
});
it('Should Pass', () => {
assert.ok(() => {
lintImageryPath('/auckland/auckland_2020_0-2m/rgb/2193/');
lintImageryPath('/auckland/auckland_2020_0.2m/rgb/2193/');
});
});
});
4 changes: 4 additions & 0 deletions src/commands/lint/lint.s3.paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ export function lintImageryPath(pathName: string): void {
if (!imageryCrs.includes(Number(crs))) {
throw new Error(`crs not in crs list: ${crs}`);
}
const resolution = dataset.split('_').pop()?.replace('m', '');
if (resolution?.endsWith('0')) {
throw new Error(`Trailing 0 in resolution of dataset name: ${dataset}`);
}
}

0 comments on commit b4b8512

Please sign in to comment.