Skip to content

Commit

Permalink
fix: Handle resolution multiple of 10 TDE-968
Browse files Browse the repository at this point in the history
  • Loading branch information
l0b0 committed Nov 29, 2023
1 parent cd7d938 commit 84b41e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/commands/lint/__test__/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ describe('lintImageryPaths', () => {
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'));
}, Error('Trailing 0 in resolution fraction of dataset name: auckland_2020_0.20m'));
});
it('Should Pass', () => {
assert.ok(() => {
lintImageryPath('/auckland/auckland_2020_0.2m/rgb/2193/');
});
it('Should pass with fractional resolution', () => {
lintImageryPath('/auckland/auckland_2020_0.2m/rgb/2193/');
});
it('should pass with resolution multiple of 10', () => {
lintImageryPath('/auckland/auckland_2020_20m/rgb/2193/');
});
});
5 changes: 3 additions & 2 deletions src/commands/lint/lint.s3.paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export function lintImageryPath(pathName: string): void {
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}`);
const resolutionFraction = resolution?.split('.', 2)[1];
if (resolutionFraction?.endsWith('0')) {
throw new Error(`Trailing 0 in resolution fraction of dataset name: ${dataset}`);
}
}

0 comments on commit 84b41e7

Please sign in to comment.