@basemaps/cli 6.9.1 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/basemaps.js +2 -0
- package/build/cli/base.cli.d.ts +1 -1
- package/build/cli/base.cli.d.ts.map +1 -1
- package/build/cli/base.cli.js +25 -27
- package/build/cli/basemaps/action.invalidate.d.ts +1 -1
- package/build/cli/basemaps/action.invalidate.d.ts.map +1 -1
- package/build/cli/basemaps/action.invalidate.js +14 -18
- package/build/cli/basemaps/action.tileset.info.d.ts +1 -1
- package/build/cli/basemaps/action.tileset.info.d.ts.map +1 -1
- package/build/cli/basemaps/action.tileset.info.js +18 -23
- package/build/cli/basemaps/index.d.ts +2 -2
- package/build/cli/basemaps/index.d.ts.map +1 -1
- package/build/cli/basemaps/index.js +10 -14
- package/build/cli/basemaps/tileset.action.d.ts.map +1 -1
- package/build/cli/basemaps/tileset.action.js +4 -8
- package/build/cli/basemaps/tileset.util.d.ts +1 -1
- package/build/cli/basemaps/tileset.util.d.ts.map +1 -1
- package/build/cli/basemaps/tileset.util.js +20 -28
- package/build/cli/cli.table.d.ts.map +1 -1
- package/build/cli/cli.table.js +2 -7
- package/build/cli/cogify/__test__/action.batch.test.js +11 -14
- package/build/cli/cogify/__test__/semver.test.js +50 -53
- package/build/cli/cogify/action.batch.d.ts +2 -2
- package/build/cli/cogify/action.batch.d.ts.map +1 -1
- package/build/cli/cogify/action.batch.js +16 -22
- package/build/cli/cogify/action.cog.d.ts +1 -1
- package/build/cli/cogify/action.cog.d.ts.map +1 -1
- package/build/cli/cogify/action.cog.js +29 -33
- package/build/cli/cogify/action.job.d.ts.map +1 -1
- package/build/cli/cogify/action.job.js +21 -26
- package/build/cli/cogify/index.d.ts +2 -2
- package/build/cli/cogify/index.d.ts.map +1 -1
- package/build/cli/cogify/index.js +9 -13
- package/build/cli/cogify/semver.util.d.ts.map +1 -1
- package/build/cli/cogify/semver.util.js +2 -5
- package/build/cli/folder.js +6 -11
- package/build/cli/tag.action.js +1 -4
- package/build/cli/util.js +11 -16
- package/build/cog/__test__/builder.test.js +31 -35
- package/build/cog/__test__/cog.stac.job.test.js +59 -62
- package/build/cog/__test__/cog.test.js +26 -29
- package/build/cog/__test__/cog.vrt.test.js +90 -90
- package/build/cog/__test__/cutline.test.js +71 -71
- package/build/cog/__test__/source.tiff.testhelper.d.ts +1 -1
- package/build/cog/__test__/source.tiff.testhelper.d.ts.map +1 -1
- package/build/cog/__test__/source.tiff.testhelper.js +6 -9
- package/build/cog/builder.d.ts +3 -3
- package/build/cog/builder.d.ts.map +1 -1
- package/build/cog/builder.js +43 -48
- package/build/cog/cog.d.ts +2 -2
- package/build/cog/cog.d.ts.map +1 -1
- package/build/cog/cog.js +15 -19
- package/build/cog/cog.stac.job.d.ts +10 -10
- package/build/cog/cog.stac.job.d.ts.map +1 -1
- package/build/cog/cog.stac.job.js +48 -52
- package/build/cog/cog.vrt.d.ts +2 -2
- package/build/cog/cog.vrt.d.ts.map +1 -1
- package/build/cog/cog.vrt.js +16 -18
- package/build/cog/constants.js +2 -5
- package/build/cog/cutline.d.ts +21 -21
- package/build/cog/cutline.d.ts.map +1 -1
- package/build/cog/cutline.js +53 -58
- package/build/cog/job.factory.d.ts +2 -2
- package/build/cog/job.factory.d.ts.map +1 -1
- package/build/cog/job.factory.js +25 -41
- package/build/cog/stac.d.ts +1 -1
- package/build/cog/stac.d.ts.map +1 -1
- package/build/cog/stac.js +2 -5
- package/build/cog/types.d.ts +1 -1
- package/build/cog/types.d.ts.map +1 -1
- package/build/cog/types.js +1 -2
- package/build/gdal/__test__/gdal.progress.test.js +11 -14
- package/build/gdal/__test__/gdal.test.js +35 -38
- package/build/gdal/gdal.cog.d.ts +2 -2
- package/build/gdal/gdal.cog.d.ts.map +1 -1
- package/build/gdal/gdal.cog.js +14 -18
- package/build/gdal/gdal.command.d.ts +1 -1
- package/build/gdal/gdal.command.d.ts.map +1 -1
- package/build/gdal/gdal.command.js +4 -9
- package/build/gdal/gdal.config.d.ts.map +1 -1
- package/build/gdal/gdal.config.js +4 -7
- package/build/gdal/gdal.d.ts +1 -1
- package/build/gdal/gdal.d.ts.map +1 -1
- package/build/gdal/gdal.docker.d.ts +1 -1
- package/build/gdal/gdal.docker.d.ts.map +1 -1
- package/build/gdal/gdal.docker.js +8 -13
- package/build/gdal/gdal.js +7 -11
- package/build/gdal/gdal.local.d.ts +1 -1
- package/build/gdal/gdal.local.d.ts.map +1 -1
- package/build/gdal/gdal.local.js +2 -6
- package/build/gdal/gdal.progress.d.ts.map +1 -1
- package/build/gdal/gdal.progress.js +2 -6
- package/build/index.d.ts +5 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -11
- package/{cogify → cogify.js} +1 -1
- package/package.json +15 -13
- package/basemaps +0 -2
package/build/cli/util.js
CHANGED
|
@@ -1,44 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const shared_1 = require("@basemaps/shared");
|
|
6
|
-
const cloudformation_1 = tslib_1.__importDefault(require("aws-sdk/clients/cloudformation"));
|
|
7
|
-
const cloudfront_1 = tslib_1.__importDefault(require("aws-sdk/clients/cloudfront"));
|
|
8
|
-
const base_cli_1 = require("./base.cli");
|
|
1
|
+
import { LogConfig } from '@basemaps/shared';
|
|
2
|
+
import CloudFormation from 'aws-sdk/clients/cloudformation.js';
|
|
3
|
+
import CloudFront from 'aws-sdk/clients/cloudfront.js';
|
|
4
|
+
import { CliId } from './base.cli.js';
|
|
9
5
|
// Cloudfront has to be defined in us-east-1
|
|
10
|
-
const cloudFormation = new
|
|
11
|
-
const cloudFront = new
|
|
6
|
+
const cloudFormation = new CloudFormation({ region: 'us-east-1' });
|
|
7
|
+
const cloudFront = new CloudFront({ region: 'us-east-1' });
|
|
12
8
|
/** cloudfront invalidation references need to be unique */
|
|
13
9
|
let InvalidationId = 0;
|
|
14
10
|
/**
|
|
15
11
|
* Invalidate the cloudfront distribution cache when updating imagery sets
|
|
16
12
|
*/
|
|
17
|
-
async function invalidateCache(path, commit = false) {
|
|
13
|
+
export async function invalidateCache(path, commit = false) {
|
|
18
14
|
var _a, _b, _c;
|
|
19
15
|
const stackInfo = await cloudFormation.describeStacks({ StackName: 'Edge' }).promise();
|
|
20
16
|
if (((_a = stackInfo.Stacks) === null || _a === void 0 ? void 0 : _a[0].Outputs) == null) {
|
|
21
|
-
|
|
17
|
+
LogConfig.get().warn('Unable to find cloud front distribution');
|
|
22
18
|
return;
|
|
23
19
|
}
|
|
24
20
|
const cloudFrontDomain = stackInfo.Stacks[0].Outputs.find((f) => f.OutputKey === 'CloudFrontDomain');
|
|
25
21
|
const cloudFrontDistributions = await cloudFront.listDistributions().promise();
|
|
26
22
|
const cf = (_c = (_b = cloudFrontDistributions.DistributionList) === null || _b === void 0 ? void 0 : _b.Items) === null || _c === void 0 ? void 0 : _c.find((f) => f.DomainName === (cloudFrontDomain === null || cloudFrontDomain === void 0 ? void 0 : cloudFrontDomain.OutputValue));
|
|
27
23
|
if (cloudFrontDomain == null || cf == null) {
|
|
28
|
-
|
|
24
|
+
LogConfig.get().warn('Unable to find cloud front distribution');
|
|
29
25
|
return;
|
|
30
26
|
}
|
|
31
|
-
|
|
27
|
+
LogConfig.get().info({ path, cfId: cf.Id }, 'Invalidating');
|
|
32
28
|
if (commit) {
|
|
33
29
|
await cloudFront
|
|
34
30
|
.createInvalidation({
|
|
35
31
|
DistributionId: cf.Id,
|
|
36
32
|
InvalidationBatch: {
|
|
37
33
|
Paths: { Quantity: 1, Items: [path] },
|
|
38
|
-
CallerReference: `${
|
|
34
|
+
CallerReference: `${CliId}-${InvalidationId++}`,
|
|
39
35
|
},
|
|
40
36
|
})
|
|
41
37
|
.promise();
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
exports.invalidateCache = invalidateCache;
|
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ospec_1.default.spec('Builder', () => {
|
|
12
|
-
ospec_1.default('should guess WKT', () => {
|
|
13
|
-
ospec_1.default(builder_1.guessProjection('PCS Name = NZGD_2000_New_Zealand_Transverse_Mercator|GCS Name = GCS_NZGD_2000|Ellipsoid = GRS_1980|Primem = Greenwich||')).equals(geo_1.Epsg.Nztm2000);
|
|
14
|
-
ospec_1.default(builder_1.guessProjection('NZGD2000_New_Zealand_Transverse_Mercator_2000|GCS Name = GCS_NZGD_2000|Primem = Greenwich||')).equals(geo_1.Epsg.Nztm2000);
|
|
1
|
+
import { Bounds, Epsg, EpsgCode, GoogleTms } from '@basemaps/geo';
|
|
2
|
+
import { LogConfig } from '@basemaps/shared';
|
|
3
|
+
import { fsa } from '@chunkd/fs';
|
|
4
|
+
import { CogTiff } from '@cogeotiff/core';
|
|
5
|
+
import o from 'ospec';
|
|
6
|
+
import { CogBuilder, guessProjection } from '../builder.js';
|
|
7
|
+
o.spec('Builder', () => {
|
|
8
|
+
o('should guess WKT', () => {
|
|
9
|
+
o(guessProjection('PCS Name = NZGD_2000_New_Zealand_Transverse_Mercator|GCS Name = GCS_NZGD_2000|Ellipsoid = GRS_1980|Primem = Greenwich||')).equals(Epsg.Nztm2000);
|
|
10
|
+
o(guessProjection('NZGD2000_New_Zealand_Transverse_Mercator_2000|GCS Name = GCS_NZGD_2000|Primem = Greenwich||')).equals(Epsg.Nztm2000);
|
|
15
11
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
o('should not guess unknown wkt', () => {
|
|
13
|
+
o(guessProjection('')).equals(null);
|
|
14
|
+
o(guessProjection('NZTM')).equals(null);
|
|
15
|
+
o(guessProjection('NZGD2000')).equals(null);
|
|
20
16
|
});
|
|
21
|
-
|
|
22
|
-
const googleBuilder = new
|
|
23
|
-
const origInit =
|
|
24
|
-
const origGetImage =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
o.spec('tiff', () => {
|
|
18
|
+
const googleBuilder = new CogBuilder(GoogleTms, 1, LogConfig.get());
|
|
19
|
+
const origInit = CogTiff.prototype.init;
|
|
20
|
+
const origGetImage = CogTiff.prototype.getImage;
|
|
21
|
+
o.after(() => {
|
|
22
|
+
CogTiff.prototype.init = origInit;
|
|
23
|
+
CogTiff.prototype.getImage = origGetImage;
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
const localTiff =
|
|
31
|
-
const s3Tiff =
|
|
25
|
+
o('bounds', async () => {
|
|
26
|
+
const localTiff = fsa.source('/local/file.tiff');
|
|
27
|
+
const s3Tiff = fsa.source('s3://bucket/file.tiff');
|
|
32
28
|
const imageLocal = {
|
|
33
29
|
resolution: [0.1],
|
|
34
30
|
value: () => [1],
|
|
35
|
-
valueGeo: () =>
|
|
36
|
-
bbox:
|
|
31
|
+
valueGeo: () => EpsgCode.Nztm2000,
|
|
32
|
+
bbox: Bounds.fromJson({
|
|
37
33
|
x: 1492000,
|
|
38
34
|
y: 6198000,
|
|
39
35
|
width: 24000,
|
|
@@ -43,20 +39,20 @@ ospec_1.default.spec('Builder', () => {
|
|
|
43
39
|
const imageS3 = {
|
|
44
40
|
resolution: [0.1],
|
|
45
41
|
value: () => [1],
|
|
46
|
-
valueGeo: () =>
|
|
47
|
-
bbox:
|
|
42
|
+
valueGeo: () => EpsgCode.Nztm2000,
|
|
43
|
+
bbox: Bounds.fromJson({
|
|
48
44
|
x: 1492000 + 24000,
|
|
49
45
|
y: 6198000,
|
|
50
46
|
width: 24000,
|
|
51
47
|
height: 36000,
|
|
52
48
|
}).toBbox(),
|
|
53
49
|
};
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
CogTiff.prototype.init = o.spy();
|
|
51
|
+
CogTiff.prototype.getImage = function () {
|
|
56
52
|
return this.source === localTiff ? imageLocal : imageS3;
|
|
57
53
|
};
|
|
58
54
|
const ans = await googleBuilder.bounds([localTiff, s3Tiff]);
|
|
59
|
-
|
|
55
|
+
o(ans).deepEquals({
|
|
60
56
|
projection: 2193,
|
|
61
57
|
nodata: 1,
|
|
62
58
|
bands: 1,
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const cog_stac_job_1 = require("../cog.stac.job");
|
|
10
|
-
ospec_1.default.spec('CogJob', () => {
|
|
11
|
-
ospec_1.default.spec('build', () => {
|
|
1
|
+
import { Bounds, Epsg, EpsgCode, GoogleTms, Nztm2000Tms, Stac } from '@basemaps/geo';
|
|
2
|
+
import { Projection } from '@basemaps/shared';
|
|
3
|
+
import { mockFileOperator } from '@basemaps/shared/build/file/__test__/file.operator.test.helper.js';
|
|
4
|
+
import { round } from '@basemaps/test/build/rounding.js';
|
|
5
|
+
import o from 'ospec';
|
|
6
|
+
import { CogStacJob } from '../cog.stac.job.js';
|
|
7
|
+
o.spec('CogJob', () => {
|
|
8
|
+
o.spec('build', () => {
|
|
12
9
|
const id = 'jobid1';
|
|
13
10
|
const imageryName = 'auckland_rural_2010-2012_0-50m';
|
|
14
11
|
const jobPath = 's3://target-bucket/path/3857/auckland_rural_2010-2012_0-50m/jobid1';
|
|
@@ -18,19 +15,19 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
18
15
|
[-177, -42],
|
|
19
16
|
[175, -42],
|
|
20
17
|
[170, -41],
|
|
21
|
-
].map(
|
|
18
|
+
].map(Projection.get(Epsg.Nztm2000).fromWgs84);
|
|
22
19
|
const ring2 = [
|
|
23
20
|
[-150, -40],
|
|
24
21
|
[-140, -41],
|
|
25
22
|
[-150, -41],
|
|
26
23
|
[-150, -40],
|
|
27
|
-
].map(
|
|
24
|
+
].map(Projection.get(Epsg.Nztm2000).fromWgs84);
|
|
28
25
|
const srcPoly = [[ring1], [ring2]];
|
|
29
|
-
const bounds = srcPoly.map((poly, i) => ({ ...
|
|
26
|
+
const bounds = srcPoly.map((poly, i) => ({ ...Bounds.fromMultiPolygon([poly]), name: 'ring' + i }));
|
|
30
27
|
const metadata = {
|
|
31
28
|
bands: 3,
|
|
32
29
|
bounds,
|
|
33
|
-
projection:
|
|
30
|
+
projection: EpsgCode.Nztm2000,
|
|
34
31
|
pixelScale: 0.075,
|
|
35
32
|
resZoom: 22,
|
|
36
33
|
nodata: 0,
|
|
@@ -39,16 +36,16 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
39
36
|
};
|
|
40
37
|
const addAlpha = true;
|
|
41
38
|
const ctx = {
|
|
42
|
-
tileMatrix:
|
|
39
|
+
tileMatrix: GoogleTms,
|
|
43
40
|
sourceLocation: { type: 's3', path: 's3://source-bucket/path' },
|
|
44
41
|
outputLocation: { type: 's3', path: 's3://target-bucket/path' },
|
|
45
42
|
cutline: { blend: 20, href: 's3://curline-bucket/path' },
|
|
46
43
|
oneCogCovering: false,
|
|
47
44
|
};
|
|
48
|
-
const mockFs =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
const mockFs = mockFileOperator();
|
|
46
|
+
o.beforeEach(mockFs.setup);
|
|
47
|
+
o.afterEach(mockFs.teardown);
|
|
48
|
+
o('with job.json', async () => {
|
|
52
49
|
mockFs.jsStore['s3://source-bucket/path/collection.json'] = {
|
|
53
50
|
title: 'The Title',
|
|
54
51
|
description: 'The Description',
|
|
@@ -63,34 +60,34 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
63
60
|
{ name: 'unknown url', roles: ['processor'], url: 'unknown' },
|
|
64
61
|
],
|
|
65
62
|
};
|
|
66
|
-
const job = await
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const stac =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
const job = await CogStacJob.create({ id, imageryName, metadata, ctx, addAlpha, cutlinePoly: [] });
|
|
64
|
+
o(job.getJobPath('job.json')).equals(jobPath + '/job.json');
|
|
65
|
+
o(job.title).equals('The Title');
|
|
66
|
+
o(job.description).equals('The Description');
|
|
67
|
+
const stac = round(mockFs.jsStore[jobPath + '/collection.json'], 4);
|
|
68
|
+
o(stac.title).equals('The Title');
|
|
69
|
+
o(stac.description).equals('The Description');
|
|
70
|
+
o(stac.license).equals('The License');
|
|
71
|
+
o(stac.keywords).deepEquals(['keywords']);
|
|
72
|
+
o(stac.providers).deepEquals([
|
|
76
73
|
{ name: 'provider name', roles: ['licensor'], url: 'https://provider.com' },
|
|
77
74
|
{ name: 'unknown url', roles: ['processor'], url: undefined },
|
|
78
75
|
]);
|
|
79
|
-
|
|
76
|
+
o(stac.links[2]).deepEquals({
|
|
80
77
|
href: 's3://source-bucket/path/collection.json',
|
|
81
78
|
rel: 'sourceImagery',
|
|
82
79
|
type: 'application/json',
|
|
83
80
|
});
|
|
84
|
-
|
|
81
|
+
o(round(stac.extent, 4)).deepEquals({
|
|
85
82
|
spatial: { bbox: [[169.3341, -51.8754, -146.1432, -32.8952]] },
|
|
86
83
|
temporal: {
|
|
87
84
|
interval: [['2020-01-01T00:00:00.000', '2020-08-08T19:18:23.456Z']],
|
|
88
85
|
},
|
|
89
86
|
});
|
|
90
87
|
});
|
|
91
|
-
|
|
88
|
+
o('no source collection.json', async () => {
|
|
92
89
|
const startNow = Date.now();
|
|
93
|
-
const job = await
|
|
90
|
+
const job = await CogStacJob.create({
|
|
94
91
|
id,
|
|
95
92
|
imageryName,
|
|
96
93
|
metadata,
|
|
@@ -99,8 +96,8 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
99
96
|
cutlinePoly: [],
|
|
100
97
|
});
|
|
101
98
|
const afterNow = Date.now();
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
o(job.json).equals(mockFs.jsStore[jobPath + '/job.json']);
|
|
100
|
+
o(round(job.json, 4)).deepEquals({
|
|
104
101
|
id: 'jobid1',
|
|
105
102
|
name: 'auckland_rural_2010-2012_0-50m',
|
|
106
103
|
title: 'Auckland rural 2010-2012 0.50m',
|
|
@@ -141,28 +138,28 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
141
138
|
oneCogCovering: true,
|
|
142
139
|
},
|
|
143
140
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const stac =
|
|
141
|
+
o(job.id).equals(id);
|
|
142
|
+
o(job.source.gsd).equals(0.075);
|
|
143
|
+
o(round(job.output.gsd, 4)).equals(0.0373);
|
|
144
|
+
o(job.output.oneCogCovering).equals(true);
|
|
145
|
+
const stac = round(mockFs.jsStore[jobPath + '/collection.json'], 4);
|
|
149
146
|
const stacMeta = stac.summaries;
|
|
150
147
|
const generated = stacMeta['linz:generated'][0];
|
|
151
148
|
const jobNow = +Date.parse(generated.datetime);
|
|
152
|
-
|
|
149
|
+
o(startNow <= jobNow && jobNow <= afterNow).equals(true);
|
|
153
150
|
// split so that scripts/detect.unlinked.dep.js does not think it is an import
|
|
154
|
-
|
|
151
|
+
o(generated.package).equals('@' + 'basemaps/cli');
|
|
155
152
|
const exp = {
|
|
156
153
|
id: 'jobid1',
|
|
157
154
|
title: 'Auckland rural 2010-2012 0.50m',
|
|
158
155
|
description: 'No description',
|
|
159
|
-
stac_version:
|
|
160
|
-
stac_extensions: [
|
|
156
|
+
stac_version: Stac.Version,
|
|
157
|
+
stac_extensions: [Stac.BaseMapsExtension],
|
|
161
158
|
extent: {
|
|
162
159
|
spatial: { bbox: [[169.3341, -51.8754, -146.1432, -32.8952]] },
|
|
163
160
|
temporal: { interval: [['2010-01-01T00:00:00Z', '2011-01-01T00:00:00Z']] },
|
|
164
161
|
},
|
|
165
|
-
license:
|
|
162
|
+
license: Stac.License,
|
|
166
163
|
keywords: ['Imagery', 'New Zealand'],
|
|
167
164
|
providers: [],
|
|
168
165
|
summaries: {
|
|
@@ -208,8 +205,8 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
208
205
|
{ href: '0-0-0.json', type: 'application/geo+json', rel: 'item' },
|
|
209
206
|
],
|
|
210
207
|
};
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
o(stac).deepEquals(exp);
|
|
209
|
+
o(round(mockFs.jsStore[jobPath + '/cutline.geojson.gz'], 4)).deepEquals({
|
|
213
210
|
type: 'FeatureCollection',
|
|
214
211
|
features: [
|
|
215
212
|
{
|
|
@@ -223,7 +220,7 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
223
220
|
properties: { name: 'urn:ogc:def:crs:EPSG::3857' },
|
|
224
221
|
},
|
|
225
222
|
});
|
|
226
|
-
|
|
223
|
+
o(round(mockFs.jsStore[jobPath + '/0-0-0.json'], 4)).deepEquals({
|
|
227
224
|
type: 'Feature',
|
|
228
225
|
geometry: {
|
|
229
226
|
type: 'Polygon',
|
|
@@ -246,7 +243,7 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
246
243
|
bbox: [0, 0, 0, 0],
|
|
247
244
|
id: 'jobid1/0-0-0',
|
|
248
245
|
collection: 'jobid1',
|
|
249
|
-
stac_version:
|
|
246
|
+
stac_version: Stac.Version,
|
|
250
247
|
stac_extensions: ['projection'],
|
|
251
248
|
links: [
|
|
252
249
|
{ href: jobPath + '/0-0-0.json', rel: 'self' },
|
|
@@ -260,7 +257,7 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
260
257
|
},
|
|
261
258
|
},
|
|
262
259
|
});
|
|
263
|
-
|
|
260
|
+
o(round(mockFs.jsStore[jobPath + '/covering.geojson'], 4)).deepEquals({
|
|
264
261
|
type: 'FeatureCollection',
|
|
265
262
|
features: [
|
|
266
263
|
{
|
|
@@ -282,7 +279,7 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
282
279
|
},
|
|
283
280
|
],
|
|
284
281
|
});
|
|
285
|
-
|
|
282
|
+
o(round(mockFs.jsStore[jobPath + '/source.geojson'], 4)).deepEquals({
|
|
286
283
|
type: 'FeatureCollection',
|
|
287
284
|
features: [
|
|
288
285
|
{
|
|
@@ -333,19 +330,19 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
333
330
|
],
|
|
334
331
|
});
|
|
335
332
|
});
|
|
336
|
-
|
|
333
|
+
o('should create with no tileMatrix', () => {
|
|
337
334
|
const cfg = { output: { epsg: 2193 } };
|
|
338
|
-
const job = new
|
|
339
|
-
|
|
335
|
+
const job = new CogStacJob(cfg);
|
|
336
|
+
o(job.tileMatrix.identifier).equals(Nztm2000Tms.identifier);
|
|
340
337
|
});
|
|
341
|
-
|
|
338
|
+
o('should error with invalid tileMatrix', () => {
|
|
342
339
|
const cfg = { output: { tileMatrix: 'None' } };
|
|
343
|
-
const job = new
|
|
344
|
-
|
|
340
|
+
const job = new CogStacJob(cfg);
|
|
341
|
+
o(() => job.tileMatrix).throws('Failed to find TileMatrixSet "None"');
|
|
345
342
|
});
|
|
346
|
-
|
|
343
|
+
o('no source collection.json and not nice name', async () => {
|
|
347
344
|
try {
|
|
348
|
-
await
|
|
345
|
+
await CogStacJob.create({
|
|
349
346
|
id,
|
|
350
347
|
imageryName: 'yucky-name',
|
|
351
348
|
metadata,
|
|
@@ -353,10 +350,10 @@ ospec_1.default.spec('CogJob', () => {
|
|
|
353
350
|
addAlpha,
|
|
354
351
|
cutlinePoly: [],
|
|
355
352
|
});
|
|
356
|
-
|
|
353
|
+
o('').equals('create should not have exceeded');
|
|
357
354
|
}
|
|
358
355
|
catch (err) {
|
|
359
|
-
|
|
356
|
+
o(err.message).equals('Missing date in imagery name: yucky-name');
|
|
360
357
|
}
|
|
361
358
|
});
|
|
362
359
|
});
|
|
@@ -1,50 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const origConvert = gdal_cog_1.GdalCogBuilder.prototype.convert;
|
|
15
|
-
ospec_1.default.afterEach(() => {
|
|
16
|
-
gdal_cog_1.GdalCogBuilder.prototype.convert = origConvert;
|
|
1
|
+
import { GoogleTms } from '@basemaps/geo';
|
|
2
|
+
import { LogConfig } from '@basemaps/shared';
|
|
3
|
+
import { round } from '@basemaps/test/build/rounding.js';
|
|
4
|
+
import o from 'ospec';
|
|
5
|
+
import { GdalCogBuilder } from '../../gdal/gdal.cog.js';
|
|
6
|
+
import { buildCogForName } from '../cog.js';
|
|
7
|
+
import { SourceTiffTestHelper } from './source.tiff.testhelper.js';
|
|
8
|
+
LogConfig.disable();
|
|
9
|
+
o.spec('cog', () => {
|
|
10
|
+
o.spec('buildCogForName', () => {
|
|
11
|
+
const origConvert = GdalCogBuilder.prototype.convert;
|
|
12
|
+
o.afterEach(() => {
|
|
13
|
+
GdalCogBuilder.prototype.convert = origConvert;
|
|
17
14
|
});
|
|
18
|
-
|
|
15
|
+
o('gdal_translate args', async () => {
|
|
19
16
|
let gdalCogBuilder = null;
|
|
20
17
|
let convertArgs = null;
|
|
21
18
|
const convert = function (...args) {
|
|
22
19
|
gdalCogBuilder = this;
|
|
23
20
|
convertArgs = args;
|
|
24
21
|
};
|
|
25
|
-
|
|
26
|
-
const job =
|
|
27
|
-
const logger =
|
|
22
|
+
GdalCogBuilder.prototype.convert = convert;
|
|
23
|
+
const job = SourceTiffTestHelper.makeCogJob();
|
|
24
|
+
const logger = LogConfig.get();
|
|
28
25
|
const name = '4-15-10';
|
|
29
26
|
job.output.files = [{ name, ...job.tileMatrix.tileToSourceBounds({ x: 15, y: 10, z: 4 }) }];
|
|
30
|
-
await
|
|
31
|
-
|
|
27
|
+
await buildCogForName(job, name, '/tmp/test.vrt', '/tmp/out-tiff', logger, true);
|
|
28
|
+
o(convertArgs[0].info).equals(logger.info);
|
|
32
29
|
const { config } = gdalCogBuilder;
|
|
33
|
-
config.bbox =
|
|
34
|
-
config.targetRes =
|
|
35
|
-
|
|
30
|
+
config.bbox = round(config.bbox, 4);
|
|
31
|
+
config.targetRes = round(config.targetRes, 4);
|
|
32
|
+
o(config).deepEquals({
|
|
36
33
|
bbox: [17532819.7999, -5009377.0857, 20037508.3428, -7514065.6285],
|
|
37
34
|
alignmentLevels: 13,
|
|
38
35
|
compression: 'webp',
|
|
39
|
-
tileMatrix:
|
|
36
|
+
tileMatrix: GoogleTms,
|
|
40
37
|
resampling: { warp: 'bilinear', overview: 'lanczos' },
|
|
41
38
|
blockSize: 512,
|
|
42
39
|
targetRes: 0.75,
|
|
43
40
|
quality: 90,
|
|
44
41
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
o(gdalCogBuilder.source).equals('/tmp/test.vrt');
|
|
43
|
+
o(gdalCogBuilder.target).equals('/tmp/out-tiff');
|
|
44
|
+
o(round(gdalCogBuilder.args, 4)).deepEquals([
|
|
48
45
|
'-of',
|
|
49
46
|
'COG',
|
|
50
47
|
'-co',
|