@basemaps/cli 6.46.0 → 7.0.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 +23 -0
- package/README.md +10 -108
- package/build/cli/config/action.bundle.d.ts.map +1 -1
- package/build/cli/config/action.bundle.js +2 -4
- package/build/cli/config/action.bundle.js.map +1 -1
- package/build/cli/config/action.import.d.ts +3 -3
- package/build/cli/config/action.import.d.ts.map +1 -1
- package/build/cli/config/action.import.js.map +1 -1
- package/build/cli/index.d.ts.map +1 -1
- package/build/cli/index.js +4 -13
- package/build/cli/index.js.map +1 -1
- package/build/cli/overview/action.create.overview.d.ts +2 -0
- package/build/cli/overview/action.create.overview.d.ts.map +1 -1
- package/build/cli/overview/action.create.overview.js +5 -1
- package/build/cli/overview/action.create.overview.js.map +1 -1
- package/build/cli/util.d.ts +1 -6
- package/build/cli/util.d.ts.map +1 -1
- package/build/cli/util.js +19 -27
- package/build/cli/util.js.map +1 -1
- package/build/cog/builder.d.ts +1 -1
- package/build/cog/builder.d.ts.map +1 -1
- package/build/cog/builder.js +1 -1
- package/build/cog/builder.js.map +1 -1
- package/build/cog/cutline.d.ts +1 -1
- package/build/cog/cutline.d.ts.map +1 -1
- package/build/cog/cutline.js +1 -1
- package/build/cog/cutline.js.map +1 -1
- package/package.json +10 -15
- package/build/cli/base.cli.d.ts +0 -1
- package/build/cli/base.cli.d.ts.map +0 -1
- package/build/cli/base.cli.js +0 -2
- package/build/cli/base.cli.js.map +0 -1
- package/build/cli/cogify/__tests__/batch.job.test.d.ts +0 -2
- package/build/cli/cogify/__tests__/batch.job.test.d.ts.map +0 -1
- package/build/cli/cogify/__tests__/batch.job.test.js +0 -92
- package/build/cli/cogify/__tests__/batch.job.test.js.map +0 -1
- package/build/cli/cogify/__tests__/semver.test.d.ts +0 -2
- package/build/cli/cogify/__tests__/semver.test.d.ts.map +0 -1
- package/build/cli/cogify/__tests__/semver.test.js +0 -62
- package/build/cli/cogify/__tests__/semver.test.js.map +0 -1
- package/build/cli/cogify/action.cog.d.ts +0 -20
- package/build/cli/cogify/action.cog.d.ts.map +0 -1
- package/build/cli/cogify/action.cog.js +0 -198
- package/build/cli/cogify/action.cog.js.map +0 -1
- package/build/cli/cogify/action.job.d.ts +0 -28
- package/build/cli/cogify/action.job.d.ts.map +0 -1
- package/build/cli/cogify/action.job.js +0 -176
- package/build/cli/cogify/action.job.js.map +0 -1
- package/build/cli/cogify/action.make.cog.d.ts +0 -23
- package/build/cli/cogify/action.make.cog.d.ts.map +0 -1
- package/build/cli/cogify/action.make.cog.js +0 -218
- package/build/cli/cogify/action.make.cog.js.map +0 -1
- package/build/cli/cogify/action.make.cog.pr.d.ts +0 -25
- package/build/cli/cogify/action.make.cog.pr.d.ts.map +0 -1
- package/build/cli/cogify/action.make.cog.pr.js +0 -96
- package/build/cli/cogify/action.make.cog.pr.js.map +0 -1
- package/build/cli/cogify/batch.job.d.ts +0 -40
- package/build/cli/cogify/batch.job.d.ts.map +0 -1
- package/build/cli/cogify/batch.job.js +0 -205
- package/build/cli/cogify/batch.job.js.map +0 -1
- package/build/cli/cogify/cutline.d.ts +0 -5
- package/build/cli/cogify/cutline.d.ts.map +0 -1
- package/build/cli/cogify/cutline.js +0 -33
- package/build/cli/cogify/cutline.js.map +0 -1
- package/build/cli/cogify/semver.util.d.ts +0 -24
- package/build/cli/cogify/semver.util.d.ts.map +0 -1
- package/build/cli/cogify/semver.util.js +0 -56
- package/build/cli/cogify/semver.util.js.map +0 -1
- package/build/cli/config/action.cog.mapsheet.d.ts +0 -12
- package/build/cli/config/action.cog.mapsheet.d.ts.map +0 -1
- package/build/cli/config/action.cog.mapsheet.js +0 -107
- package/build/cli/config/action.cog.mapsheet.js.map +0 -1
- package/build/cli/github/github.d.ts +0 -49
- package/build/cli/github/github.d.ts.map +0 -1
- package/build/cli/github/github.js +0 -107
- package/build/cli/github/github.js.map +0 -1
- package/build/cli/github/make.cog.pr.d.ts +0 -42
- package/build/cli/github/make.cog.pr.d.ts.map +0 -1
- package/build/cli/github/make.cog.pr.js +0 -173
- package/build/cli/github/make.cog.pr.js.map +0 -1
- package/build/cli/sprites/action.sprites.d.ts +0 -11
- package/build/cli/sprites/action.sprites.d.ts.map +0 -1
- package/build/cli/sprites/action.sprites.js +0 -42
- package/build/cli/sprites/action.sprites.js.map +0 -1
- package/build/cog/__tests__/builder.test.d.ts +0 -2
- package/build/cog/__tests__/builder.test.d.ts.map +0 -1
- package/build/cog/__tests__/builder.test.js +0 -81
- package/build/cog/__tests__/builder.test.js.map +0 -1
- package/build/cog/__tests__/cog.stac.job.test.d.ts +0 -2
- package/build/cog/__tests__/cog.stac.job.test.d.ts.map +0 -1
- package/build/cog/__tests__/cog.stac.job.test.js +0 -319
- package/build/cog/__tests__/cog.stac.job.test.js.map +0 -1
- package/build/cog/__tests__/cog.test.d.ts +0 -2
- package/build/cog/__tests__/cog.test.d.ts.map +0 -1
- package/build/cog/__tests__/cog.test.js +0 -91
- package/build/cog/__tests__/cog.test.js.map +0 -1
- package/build/cog/__tests__/cog.vrt.test.d.ts +0 -2
- package/build/cog/__tests__/cog.vrt.test.d.ts.map +0 -1
- package/build/cog/__tests__/cog.vrt.test.js +0 -229
- package/build/cog/__tests__/cog.vrt.test.js.map +0 -1
- package/build/cog/__tests__/cutline.test.d.ts +0 -2
- package/build/cog/__tests__/cutline.test.d.ts.map +0 -1
- package/build/cog/__tests__/cutline.test.js +0 -300
- package/build/cog/__tests__/cutline.test.js.map +0 -1
- package/build/cog/__tests__/projection.loader.test.d.ts +0 -2
- package/build/cog/__tests__/projection.loader.test.d.ts.map +0 -1
- package/build/cog/__tests__/projection.loader.test.js +0 -27
- package/build/cog/__tests__/projection.loader.test.js.map +0 -1
- package/build/cog/__tests__/source.tiff.testhelper.d.ts +0 -8
- package/build/cog/__tests__/source.tiff.testhelper.d.ts.map +0 -1
- package/build/cog/__tests__/source.tiff.testhelper.js +0 -41
- package/build/cog/__tests__/source.tiff.testhelper.js.map +0 -1
- package/build/cog/cog.d.ts +0 -22
- package/build/cog/cog.d.ts.map +0 -1
- package/build/cog/cog.js +0 -72
- package/build/cog/cog.js.map +0 -1
- package/build/cog/cog.stac.job.d.ts +0 -106
- package/build/cog/cog.stac.job.d.ts.map +0 -1
- package/build/cog/cog.stac.job.js +0 -257
- package/build/cog/cog.stac.job.js.map +0 -1
- package/build/cog/cog.vrt.d.ts +0 -18
- package/build/cog/cog.vrt.d.ts.map +0 -1
- package/build/cog/cog.vrt.js +0 -102
- package/build/cog/cog.vrt.js.map +0 -1
- package/build/cog/constants.d.ts +0 -5
- package/build/cog/constants.d.ts.map +0 -1
- package/build/cog/constants.js +0 -5
- package/build/cog/constants.js.map +0 -1
- package/build/cog/job.factory.d.ts +0 -10
- package/build/cog/job.factory.d.ts.map +0 -1
- package/build/cog/job.factory.js +0 -92
- package/build/cog/job.factory.js.map +0 -1
- package/build/cog/projection.loader.d.ts +0 -13
- package/build/cog/projection.loader.d.ts.map +0 -1
- package/build/cog/projection.loader.js +0 -27
- package/build/cog/projection.loader.js.map +0 -1
- package/build/cog/stac.d.ts +0 -32
- package/build/cog/stac.d.ts.map +0 -1
- package/build/cog/stac.js +0 -3
- package/build/cog/stac.js.map +0 -1
- package/build/cog/types.d.ts +0 -83
- package/build/cog/types.d.ts.map +0 -1
- package/build/cog/types.js +0 -2
- package/build/cog/types.js.map +0 -1
- package/build/gdal/__tests__/gdal.progress.test.d.ts +0 -2
- package/build/gdal/__tests__/gdal.progress.test.d.ts.map +0 -1
- package/build/gdal/__tests__/gdal.progress.test.js +0 -22
- package/build/gdal/__tests__/gdal.progress.test.js.map +0 -1
- package/build/gdal/__tests__/gdal.test.d.ts +0 -2
- package/build/gdal/__tests__/gdal.test.d.ts.map +0 -1
- package/build/gdal/__tests__/gdal.test.js +0 -52
- package/build/gdal/__tests__/gdal.test.js.map +0 -1
- package/build/gdal/gdal.cog.d.ts +0 -42
- package/build/gdal/gdal.cog.d.ts.map +0 -1
- package/build/gdal/gdal.cog.js +0 -108
- package/build/gdal/gdal.cog.js.map +0 -1
- package/build/gdal/gdal.command.d.ts +0 -44
- package/build/gdal/gdal.command.d.ts.map +0 -1
- package/build/gdal/gdal.command.js +0 -87
- package/build/gdal/gdal.command.js.map +0 -1
- package/build/gdal/gdal.config.d.ts +0 -51
- package/build/gdal/gdal.config.d.ts.map +0 -1
- package/build/gdal/gdal.config.js +0 -23
- package/build/gdal/gdal.config.js.map +0 -1
- package/build/gdal/gdal.d.ts +0 -19
- package/build/gdal/gdal.d.ts.map +0 -1
- package/build/gdal/gdal.docker.d.ts +0 -18
- package/build/gdal/gdal.docker.d.ts.map +0 -1
- package/build/gdal/gdal.docker.js +0 -82
- package/build/gdal/gdal.docker.js.map +0 -1
- package/build/gdal/gdal.js +0 -28
- package/build/gdal/gdal.js.map +0 -1
- package/build/gdal/gdal.local.d.ts +0 -10
- package/build/gdal/gdal.local.d.ts.map +0 -1
- package/build/gdal/gdal.local.js +0 -22
- package/build/gdal/gdal.local.js.map +0 -1
- package/build/gdal/gdal.progress.d.ts +0 -16
- package/build/gdal/gdal.progress.d.ts.map +0 -1
- package/build/gdal/gdal.progress.js +0 -50
- package/build/gdal/gdal.progress.js.map +0 -1
- package/build/index.d.ts +0 -6
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -6
- package/build/index.js.map +0 -1
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { EpsgCode, GoogleTms } from '@basemaps/geo';
|
|
2
|
-
import { CogStacJob } from '../cog.stac.job.js';
|
|
3
|
-
export const SourceTiffTestHelper = {
|
|
4
|
-
makeCogJob() {
|
|
5
|
-
return new CogStacJob({
|
|
6
|
-
source: {
|
|
7
|
-
files: [],
|
|
8
|
-
epsg: EpsgCode.Nztm2000,
|
|
9
|
-
gsd: 0.8,
|
|
10
|
-
},
|
|
11
|
-
output: {
|
|
12
|
-
tileMatrix: GoogleTms.identifier,
|
|
13
|
-
gsd: 0.75,
|
|
14
|
-
addAlpha: true,
|
|
15
|
-
oneCogCovering: false,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
tiffNztmBounds(path = '/path/to') {
|
|
20
|
-
return [
|
|
21
|
-
{
|
|
22
|
-
name: path + '/tiff1.tiff',
|
|
23
|
-
x: 1732000,
|
|
24
|
-
y: 5442000,
|
|
25
|
-
width: 24000,
|
|
26
|
-
height: 36000,
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: path + '/tiff2.tiff',
|
|
30
|
-
x: 1756000,
|
|
31
|
-
y: 5442000,
|
|
32
|
-
width: 24000,
|
|
33
|
-
height: 36000,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
},
|
|
37
|
-
namedBoundsToPaths(bounds) {
|
|
38
|
-
return bounds.map(({ name }) => `/path/to/tiff${name}.tiff`);
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=source.tiff.testhelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source.tiff.testhelper.js","sourceRoot":"","sources":["../../../src/cog/__tests__/source.tiff.testhelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,SAAS,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU;QACR,OAAO,IAAI,UAAU,CAAC;YACpB,MAAM,EAAE;gBACN,KAAK,EAAE,EAAmB;gBAC1B,IAAI,EAAE,QAAQ,CAAC,QAAQ;gBACvB,GAAG,EAAE,GAAG;aACT;YACD,MAAM,EAAE;gBACN,UAAU,EAAE,SAAS,CAAC,UAAU;gBAChC,GAAG,EAAE,IAAI;gBACT,QAAQ,EAAE,IAAI;gBACd,cAAc,EAAE,KAAK;aACtB;SACY,CAAC,CAAC;IACnB,CAAC;IAED,cAAc,CAAC,IAAI,GAAG,UAAU;QAC9B,OAAO;YACL;gBACE,IAAI,EAAE,IAAI,GAAG,aAAa;gBAC1B,CAAC,EAAE,OAAO;gBACV,CAAC,EAAE,OAAO;gBACV,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,KAAK;aACd;YACD;gBACE,IAAI,EAAE,IAAI,GAAG,aAAa;gBAC1B,CAAC,EAAE,OAAO;gBACV,CAAC,EAAE,OAAO;gBACV,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,KAAK;aACd;SACF,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,MAAqB;QACtC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAU,EAAE,CAAC,gBAAgB,IAAI,OAAO,CAAC,CAAC;IACvE,CAAC;CACF,CAAC"}
|
package/build/cog/cog.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { LogType } from '@basemaps/shared';
|
|
2
|
-
import { GdalCommand } from '../gdal/gdal.command.js';
|
|
3
|
-
import { CogJob } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Create a onProgress logger
|
|
6
|
-
*
|
|
7
|
-
* @param keys additional keys to log
|
|
8
|
-
* @param logger base logger to use
|
|
9
|
-
*/
|
|
10
|
-
export declare function onProgress(gdal: GdalCommand, keys: Record<string, any>, logger: LogType): void;
|
|
11
|
-
/**
|
|
12
|
-
* Build a COG for a given collection of tiffs
|
|
13
|
-
*
|
|
14
|
-
* @param job the job to process
|
|
15
|
-
* @param name tile name of cog to generate
|
|
16
|
-
* @param vrtLocation Location of the source VRT file
|
|
17
|
-
* @param outputTiffPath Path to where the output tiff will be stored
|
|
18
|
-
* @param logger Logger to use
|
|
19
|
-
* @param execute Whether to actually execute the transformation,
|
|
20
|
-
*/
|
|
21
|
-
export declare function buildCogForName(job: CogJob, name: string, vrtLocation: string, outputTiffPath: string, logger: LogType, execute?: boolean): Promise<void>;
|
|
22
|
-
//# sourceMappingURL=cog.d.ts.map
|
package/build/cog/cog.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cog.d.ts","sourceRoot":"","sources":["../../src/cog/cog.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGpC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAQ9F;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,OAAO,EACf,OAAO,UAAQ,GACd,OAAO,CAAC,IAAI,CAAC,CA2Df"}
|
package/build/cog/cog.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Bounds, Projection, TileMatrixSet } from '@basemaps/geo';
|
|
2
|
-
import { Env, isConfigS3Role } from '@basemaps/shared';
|
|
3
|
-
import { GdalCogBuilder } from '../gdal/gdal.cog.js';
|
|
4
|
-
import { GdalProgressParser } from '../gdal/gdal.progress.js';
|
|
5
|
-
import { AwsCredentials } from '@chunkd/source-aws-v2';
|
|
6
|
-
/**
|
|
7
|
-
* Create a onProgress logger
|
|
8
|
-
*
|
|
9
|
-
* @param keys additional keys to log
|
|
10
|
-
* @param logger base logger to use
|
|
11
|
-
*/
|
|
12
|
-
export function onProgress(gdal, keys, logger) {
|
|
13
|
-
let lastTime = Date.now();
|
|
14
|
-
gdal.parser = new GdalProgressParser();
|
|
15
|
-
gdal.parser.on('progress', (p) => {
|
|
16
|
-
logger.trace({ ...keys, progress: parseFloat(p.toFixed(2)), progressTime: Date.now() - lastTime }, 'Progress');
|
|
17
|
-
lastTime = Date.now();
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Build a COG for a given collection of tiffs
|
|
22
|
-
*
|
|
23
|
-
* @param job the job to process
|
|
24
|
-
* @param name tile name of cog to generate
|
|
25
|
-
* @param vrtLocation Location of the source VRT file
|
|
26
|
-
* @param outputTiffPath Path to where the output tiff will be stored
|
|
27
|
-
* @param logger Logger to use
|
|
28
|
-
* @param execute Whether to actually execute the transformation,
|
|
29
|
-
*/
|
|
30
|
-
export async function buildCogForName(job, name, vrtLocation, outputTiffPath, logger, execute = false) {
|
|
31
|
-
const startTime = Date.now();
|
|
32
|
-
const { targetZoom, tileMatrix } = job;
|
|
33
|
-
const nb = job.output.files.find((nb) => nb.name === name);
|
|
34
|
-
if (nb == null) {
|
|
35
|
-
throw new Error("Can't find COG named " + name);
|
|
36
|
-
}
|
|
37
|
-
const bounds = Bounds.fromJson(nb);
|
|
38
|
-
const tile = TileMatrixSet.nameToTile(name);
|
|
39
|
-
const blockSize = tileMatrix.tileSize * 2; // FIXME is this blockFactor always 2
|
|
40
|
-
const alignmentLevels = Projection.findAlignmentLevels(tileMatrix, tile, job.source.gsd);
|
|
41
|
-
const cogBuild = new GdalCogBuilder(vrtLocation, outputTiffPath, {
|
|
42
|
-
bbox: [bounds.x, bounds.bottom, bounds.right, bounds.y],
|
|
43
|
-
tileMatrix,
|
|
44
|
-
blockSize,
|
|
45
|
-
targetRes: job.output.gsd,
|
|
46
|
-
alignmentLevels,
|
|
47
|
-
resampling: job.output.resampling,
|
|
48
|
-
quality: job.output.quality,
|
|
49
|
-
});
|
|
50
|
-
onProgress(cogBuild.gdal, { name, target: 'tiff' }, logger);
|
|
51
|
-
logger.info({
|
|
52
|
-
imageSize: Projection.getImagePixelWidth(tileMatrix, tile, targetZoom),
|
|
53
|
-
name,
|
|
54
|
-
tile,
|
|
55
|
-
alignmentLevels,
|
|
56
|
-
}, 'CreateCog');
|
|
57
|
-
const sourceLocation = job.source.location;
|
|
58
|
-
// If required assume role
|
|
59
|
-
if (isConfigS3Role(sourceLocation)) {
|
|
60
|
-
const credentials = AwsCredentials.role(sourceLocation.roleArn, sourceLocation.externalId, Env.getNumber(Env.AwsRoleDurationHours, 8) * 60 * 60);
|
|
61
|
-
cogBuild.gdal.setCredentials(credentials);
|
|
62
|
-
}
|
|
63
|
-
if (cogBuild.gdal.mount != null) {
|
|
64
|
-
for (const file of job.source.files)
|
|
65
|
-
cogBuild.gdal.mount(file.name);
|
|
66
|
-
}
|
|
67
|
-
if (execute) {
|
|
68
|
-
await cogBuild.convert(logger.child({ name }));
|
|
69
|
-
logger.info({ name, duration: Date.now() - startTime }, 'CogCreated');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=cog.js.map
|
package/build/cog/cog.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cog.js","sourceRoot":"","sources":["../../src/cog/cog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAW,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAiB,EAAE,IAAyB,EAAE,MAAe;IACtF,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE1B,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAS,EAAQ,EAAE;QAC7C,MAAM,CAAC,KAAK,CAAC,E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;QAC/C,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,EAAE,YAAY,CAAC,CAAC;KACvE;AACH,CAAC"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { Epsg, TileMatrixSet } from '@basemaps/geo';
|
|
2
|
-
import { FileConfig, FileConfigPath } from '@basemaps/shared';
|
|
3
|
-
import { MultiPolygon } from '@linzjs/geojson';
|
|
4
|
-
import { GdalCogBuilderResampling } from '../gdal/gdal.config.js';
|
|
5
|
-
import { CogBuilderMetadata, CogJob, CogJobJson, CogOutputProperties, CogSourceProperties, FeatureCollectionWithCrs } from './types.js';
|
|
6
|
-
export declare const MaxConcurrencyDefault = 50;
|
|
7
|
-
export interface JobCreationContext {
|
|
8
|
-
/** Custom Imagery Name if defined */
|
|
9
|
-
imageryName?: string;
|
|
10
|
-
/** Source config */
|
|
11
|
-
sourceLocation: FileConfig | FileConfigPath;
|
|
12
|
-
/** Output config */
|
|
13
|
-
outputLocation: FileConfig;
|
|
14
|
-
/** Should the imagery be cut to a cutline */
|
|
15
|
-
cutline?: {
|
|
16
|
-
href: string;
|
|
17
|
-
blend: number;
|
|
18
|
-
};
|
|
19
|
-
tileMatrix: TileMatrixSet;
|
|
20
|
-
override?: {
|
|
21
|
-
/** Override job id */
|
|
22
|
-
id?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Image quality
|
|
25
|
-
* @default GdalCogBuilderDefaults.quality
|
|
26
|
-
*/
|
|
27
|
-
quality?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Number of threads to use for fetches
|
|
30
|
-
* @default MaxConcurrencyDefault
|
|
31
|
-
*/
|
|
32
|
-
concurrency?: number;
|
|
33
|
-
/**
|
|
34
|
-
* Override the source projection
|
|
35
|
-
*/
|
|
36
|
-
projection?: Epsg;
|
|
37
|
-
/**
|
|
38
|
-
* Override Default aligned zoom level
|
|
39
|
-
*/
|
|
40
|
-
alignedLevel?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Resampling method
|
|
43
|
-
* @Default GdalCogBuilderDefaults.resampling
|
|
44
|
-
*/
|
|
45
|
-
resampling?: GdalCogBuilderResampling;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Should this job be submitted to batch now?
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
51
|
-
batch: boolean;
|
|
52
|
-
/** Should this job ignore source coverage and just produce one big COG for EPSG extent */
|
|
53
|
-
oneCogCovering: boolean;
|
|
54
|
-
}
|
|
55
|
-
export interface CogJobCreateParams {
|
|
56
|
-
/** unique id for imagery set */
|
|
57
|
-
id: string;
|
|
58
|
-
/** name of imagery set */
|
|
59
|
-
imageryName: string;
|
|
60
|
-
/** information about the source */
|
|
61
|
-
metadata: CogBuilderMetadata;
|
|
62
|
-
/** information about the output */
|
|
63
|
-
ctx: JobCreationContext;
|
|
64
|
-
/** the polygon to use to clip the source imagery */
|
|
65
|
-
cutlinePoly: MultiPolygon;
|
|
66
|
-
/** do we need an alpha band added */
|
|
67
|
-
addAlpha: boolean;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Information needed to create cogs
|
|
71
|
-
*/
|
|
72
|
-
export declare class CogStacJob implements CogJob {
|
|
73
|
-
json: CogJobJson;
|
|
74
|
-
private cacheTargetZoom?;
|
|
75
|
-
/**
|
|
76
|
-
* Load the job.json
|
|
77
|
-
|
|
78
|
-
* @param jobpath where to load the job.json from
|
|
79
|
-
*/
|
|
80
|
-
static load(jobpath: string): Promise<CogStacJob>;
|
|
81
|
-
/**
|
|
82
|
-
* Create job.json, collection.json, source.geojson, covering.geojson, cutlint.geojson.gz and
|
|
83
|
-
* stac descriptions of the target COGs
|
|
84
|
-
*/
|
|
85
|
-
static create({ id, imageryName, metadata, ctx, cutlinePoly, addAlpha, }: CogJobCreateParams): Promise<CogStacJob>;
|
|
86
|
-
/**
|
|
87
|
-
* build a FeatureCollection from MultiPolygon
|
|
88
|
-
*/
|
|
89
|
-
static toGeoJson(poly: MultiPolygon, epsg: Epsg): FeatureCollectionWithCrs;
|
|
90
|
-
constructor(json: CogJobJson);
|
|
91
|
-
get id(): string;
|
|
92
|
-
get name(): string;
|
|
93
|
-
get title(): string;
|
|
94
|
-
get description(): string | undefined;
|
|
95
|
-
get source(): CogSourceProperties;
|
|
96
|
-
get output(): CogOutputProperties;
|
|
97
|
-
get tileMatrix(): TileMatrixSet;
|
|
98
|
-
get targetZoom(): number;
|
|
99
|
-
/**
|
|
100
|
-
* Get a nicely formatted folder path based on the job
|
|
101
|
-
*
|
|
102
|
-
* @param key optional file key inside of the job folder
|
|
103
|
-
*/
|
|
104
|
-
getJobPath(key?: string): string;
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=cog.stac.job.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cog.stac.job.d.ts","sourceRoot":"","sources":["../../src/cog/cog.stac.job.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAMJ,aAAa,EAEd,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,UAAU,EACV,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAA8C,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAA0B,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAG1F,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,oBAAoB;IACpB,cAAc,EAAE,UAAU,GAAG,cAAc,CAAC;IAE5C,oBAAoB;IACpB,cAAc,EAAE,UAAU,CAAC;IAE3B,6CAA6C;IAC7C,OAAO,CAAC,EAAE;Q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AAE,YAAY,EAAE,IAAI,EAAE,IAAI,GAAG,wBAAwB;gBAS9D,IAAI,EAAE,UAAU;IAI5B,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,IAAI,MAAM,IAAI,mBAAmB,CAEhC;IAED,IAAI,MAAM,IAAI,mBAAmB,CAEhC;IAED,IAAI,UAAU,IAAI,aAAa,CAO9B;IAED,IAAI,UAAU,IAAI,MAAM,CAMvB;IAED;;;;OAIG;IACH,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM;CAOjC"}
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { Bounds, Projection, Stac, TileMatrixSets, } from '@basemaps/geo';
|
|
2
|
-
import { CompositeError, extractYearRangeFromName, fsa, titleizeImageryName, } from '@basemaps/shared';
|
|
3
|
-
import { CliInfo } from '@basemaps/shared/build/cli/info.js';
|
|
4
|
-
import { toFeatureCollection, toFeatureMultiPolygon } from '@linzjs/geojson';
|
|
5
|
-
import { GdalCogBuilderDefaults } from '../gdal/gdal.config.js';
|
|
6
|
-
import { ProjectionLoader } from './projection.loader.js';
|
|
7
|
-
import { CogStacItemExtensions, CogStacKeywords } from './stac.js';
|
|
8
|
-
export const MaxConcurrencyDefault = 50;
|
|
9
|
-
/**
|
|
10
|
-
* Information needed to create cogs
|
|
11
|
-
*/
|
|
12
|
-
export class CogStacJob {
|
|
13
|
-
/**
|
|
14
|
-
* Load the job.json
|
|
15
|
-
|
|
16
|
-
* @param jobpath where to load the job.json from
|
|
17
|
-
*/
|
|
18
|
-
static async load(jobpath) {
|
|
19
|
-
const job = new CogStacJob(await fsa.readJson(jobpath));
|
|
20
|
-
await ProjectionLoader.load(job.source.epsg);
|
|
21
|
-
return job;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Create job.json, collection.json, source.geojson, covering.geojson, cutlint.geojson.gz and
|
|
25
|
-
* stac descriptions of the target COGs
|
|
26
|
-
*/
|
|
27
|
-
static async create({ id, imageryName, metadata, ctx, cutlinePoly, addAlpha, }) {
|
|
28
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
29
|
-
let description;
|
|
30
|
-
const providers = [];
|
|
31
|
-
const links = [
|
|
32
|
-
{
|
|
33
|
-
href: fsa.join(ctx.outputLocation.path, 'collection.json'),
|
|
34
|
-
type: 'application/json',
|
|
35
|
-
rel: 'self',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
href: 'job.json',
|
|
39
|
-
type: 'application/json',
|
|
40
|
-
rel: 'linz.basemaps.job',
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
let sourceStac = {};
|
|
44
|
-
const interval = [];
|
|
45
|
-
try {
|
|
46
|
-
const sourceCollectionPath = fsa.join(ctx.sourceLocation.path, 'collection.json');
|
|
47
|
-
sourceStac = await fsa.readJson(sourceCollectionPath);
|
|
48
|
-
description = sourceStac.description;
|
|
49
|
-
interval.push(...((_c = (_b = (_a = sourceStac.extent) === null || _a === void 0 ? void 0 : _a.temporal) === null || _b === void 0 ? void 0 : _b.interval) !== null && _c !== void 0 ? _c : []));
|
|
50
|
-
links.push({ href: sourceCollectionPath, rel: 'sourceImagery', type: 'application/json' });
|
|
51
|
-
if (sourceStac.providers != null) {
|
|
52
|
-
for (const p of sourceStac.providers) {
|
|
53
|
-
if (p.roles.indexOf('host') === -1) {
|
|
54
|
-
if (p.url === 'unknown') {
|
|
55
|
-
// LINZ LDS has put unknown in some urls
|
|
56
|
-
p.url = undefined;
|
|
57
|
-
}
|
|
58
|
-
providers.push(p);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
if (!CompositeError.isCompositeError(err) || err.code !== 404) {
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const keywords = (_d = sourceStac.keywords) !== null && _d !== void 0 ? _d : CogStacKeywords.slice();
|
|
69
|
-
const license = (_e = sourceStac.license) !== null && _e !== void 0 ? _e : Stac.License;
|
|
70
|
-
const title = (_f = sourceStac.title) !== null && _f !== void 0 ? _f : titleizeImageryName(imageryName);
|
|
71
|
-
if (description == null) {
|
|
72
|
-
description = 'No description';
|
|
73
|
-
}
|
|
74
|
-
await ProjectionLoader.load(metadata.projection);
|
|
75
|
-
const job = new CogStacJob({
|
|
76
|
-
id,
|
|
77
|
-
name: imageryName,
|
|
78
|
-
title,
|
|
79
|
-
description,
|
|
80
|
-
source: {
|
|
81
|
-
gsd: metadata.pixelScale,
|
|
82
|
-
epsg: metadata.projection,
|
|
83
|
-
files: metadata.bounds,
|
|
84
|
-
location: ctx.sourceLocation,
|
|
85
|
-
},
|
|
86
|
-
output: {
|
|
87
|
-
gsd: ctx.tileMatrix.pixelScale(metadata.resZoom),
|
|
88
|
-
tileMatrix: ctx.tileMatrix.identifier,
|
|
89
|
-
epsg: ctx.tileMatrix.projection.code,
|
|
90
|
-
files: metadata.files,
|
|
91
|
-
location: ctx.outputLocation,
|
|
92
|
-
resampling: (_h = (_g = ctx.override) === null || _g === void 0 ? void 0 : _g.resampling) !== null && _h !== void 0 ? _h : GdalCogBuilderDefaults.resampling,
|
|
93
|
-
quality: (_k = (_j = ctx.override) === null || _j === void 0 ? void 0 : _j.quality) !== null && _k !== void 0 ? _k : GdalCogBuilderDefaults.quality,
|
|
94
|
-
cutline: ctx.cutline,
|
|
95
|
-
addAlpha,
|
|
96
|
-
nodata: metadata.nodata,
|
|
97
|
-
bounds: metadata.targetBounds,
|
|
98
|
-
oneCogCovering: ctx.oneCogCovering,
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
const nowStr = new Date().toISOString();
|
|
102
|
-
const sourceProj = Projection.get(job.source.epsg);
|
|
103
|
-
const bbox = [
|
|
104
|
-
sourceProj.boundsToWgs84BoundingBox(metadata.bounds.map((a) => Bounds.fromJson(a)).reduce((sum, a) => sum.union(a))),
|
|
105
|
-
];
|
|
106
|
-
if (interval.length === 0) {
|
|
107
|
-
const years = extractYearRangeFromName(imageryName);
|
|
108
|
-
if (years == null)
|
|
109
|
-
throw new Error('Missing date in imagery name: ' + imageryName);
|
|
110
|
-
interval.push(years.map((y) => `${y}-01-01T00:00:00Z`));
|
|
111
|
-
}
|
|
112
|
-
if (ctx.cutline) {
|
|
113
|
-
links.push({ href: 'cutline.geojson.gz', type: 'application/geo+json+gzip', rel: 'linz.basemaps.cutline' });
|
|
114
|
-
}
|
|
115
|
-
links.push({ href: 'covering.geojson', type: 'application/geo+json', rel: 'linz.basemaps.covering' });
|
|
116
|
-
links.push({ href: 'source.geojson', type: 'application/geo+json', rel: 'linz.basemaps.source' });
|
|
117
|
-
const temporal = { interval };
|
|
118
|
-
const jobFile = job.getJobPath(`job.json`);
|
|
119
|
-
const stac = {
|
|
120
|
-
id,
|
|
121
|
-
title,
|
|
122
|
-
description,
|
|
123
|
-
stac_version: Stac.Version,
|
|
124
|
-
stac_extensions: [Stac.BaseMapsExtension],
|
|
125
|
-
extent: {
|
|
126
|
-
spatial: { bbox },
|
|
127
|
-
temporal,
|
|
128
|
-
},
|
|
129
|
-
license,
|
|
130
|
-
keywords,
|
|
131
|
-
providers,
|
|
132
|
-
summaries: {
|
|
133
|
-
gsd: [metadata.pixelScale],
|
|
134
|
-
'proj:epsg': [ctx.tileMatrix.projection.code],
|
|
135
|
-
'linz:output': [
|
|
136
|
-
{
|
|
137
|
-
resampling: (_m = (_l = ctx.override) === null || _l === void 0 ? void 0 : _l.resampling) !== null && _m !== void 0 ? _m : GdalCogBuilderDefaults.resampling,
|
|
138
|
-
quality: (_p = (_o = ctx.override) === null || _o === void 0 ? void 0 : _o.quality) !== null && _p !== void 0 ? _p : GdalCogBuilderDefaults.quality,
|
|
139
|
-
cutlineBlend: (_q = ctx.cutline) === null || _q === void 0 ? void 0 : _q.blend,
|
|
140
|
-
addAlpha,
|
|
141
|
-
nodata: metadata.nodata,
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
'linz:generated': [
|
|
145
|
-
{
|
|
146
|
-
...CliInfo,
|
|
147
|
-
datetime: nowStr,
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
},
|
|
151
|
-
links,
|
|
152
|
-
};
|
|
153
|
-
await fsa.writeJson(jobFile, job.json);
|
|
154
|
-
const covering = Projection.get(job.tileMatrix).toGeoJson(metadata.files);
|
|
155
|
-
const roles = ['data'];
|
|
156
|
-
const collectionLink = { href: 'collection.json', rel: 'collection' };
|
|
157
|
-
for (const f of covering.features) {
|
|
158
|
-
const { name } = f.properties;
|
|
159
|
-
const href = name + '.json';
|
|
160
|
-
links.push({ href, type: 'application/geo+json', rel: 'item' });
|
|
161
|
-
const item = {
|
|
162
|
-
...f,
|
|
163
|
-
id: job.id + '/' + name,
|
|
164
|
-
collection: job.id,
|
|
165
|
-
stac_version: Stac.Version,
|
|
166
|
-
stac_extensions: CogStacItemExtensions,
|
|
167
|
-
properties: {
|
|
168
|
-
...f.properties,
|
|
169
|
-
datetime: nowStr,
|
|
170
|
-
gsd: job.output.gsd,
|
|
171
|
-
'proj:epsg': job.tileMatrix.projection.code,
|
|
172
|
-
},
|
|
173
|
-
links: [{ href: job.getJobPath(href), rel: 'self' }, collectionLink],
|
|
174
|
-
assets: {
|
|
175
|
-
cog: {
|
|
176
|
-
href: name + '.tiff',
|
|
177
|
-
type: 'image/tiff; application=geotiff; profile=cloud-optimized',
|
|
178
|
-
roles,
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
await fsa.writeJson(job.getJobPath(href), item);
|
|
183
|
-
}
|
|
184
|
-
if (ctx.cutline != null) {
|
|
185
|
-
const geoJsonCutlineOutput = job.getJobPath(`cutline.geojson.gz`);
|
|
186
|
-
await fsa.writeJson(geoJsonCutlineOutput, this.toGeoJson(cutlinePoly, ctx.tileMatrix.projection));
|
|
187
|
-
}
|
|
188
|
-
const geoJsonSourceOutput = job.getJobPath(`source.geojson`);
|
|
189
|
-
await fsa.writeJson(geoJsonSourceOutput, Projection.get(job.source.epsg).toGeoJson(metadata.bounds));
|
|
190
|
-
const geoJsonCoveringOutput = job.getJobPath(`covering.geojson`);
|
|
191
|
-
await fsa.writeJson(geoJsonCoveringOutput, covering);
|
|
192
|
-
await fsa.writeJson(job.getJobPath(`collection.json`), stac);
|
|
193
|
-
return job;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* build a FeatureCollection from MultiPolygon
|
|
197
|
-
*/
|
|
198
|
-
static toGeoJson(poly, epsg) {
|
|
199
|
-
const feature = toFeatureCollection([toFeatureMultiPolygon(poly)]);
|
|
200
|
-
feature.crs = {
|
|
201
|
-
type: 'name',
|
|
202
|
-
properties: { name: epsg.toUrn() },
|
|
203
|
-
};
|
|
204
|
-
return feature;
|
|
205
|
-
}
|
|
206
|
-
constructor(json) {
|
|
207
|
-
this.json = json;
|
|
208
|
-
}
|
|
209
|
-
get id() {
|
|
210
|
-
return this.json.id;
|
|
211
|
-
}
|
|
212
|
-
get name() {
|
|
213
|
-
return this.json.name;
|
|
214
|
-
}
|
|
215
|
-
get title() {
|
|
216
|
-
return this.json.title;
|
|
217
|
-
}
|
|
218
|
-
get description() {
|
|
219
|
-
return this.json.description;
|
|
220
|
-
}
|
|
221
|
-
get source() {
|
|
222
|
-
return this.json.source;
|
|
223
|
-
}
|
|
224
|
-
get output() {
|
|
225
|
-
return this.json.output;
|
|
226
|
-
}
|
|
227
|
-
get tileMatrix() {
|
|
228
|
-
if (this.json.output.tileMatrix) {
|
|
229
|
-
const tileMatrix = TileMatrixSets.find(this.json.output.tileMatrix);
|
|
230
|
-
if (tileMatrix == null)
|
|
231
|
-
throw new Error(`Failed to find TileMatrixSet "${this.json.output.tileMatrix}"`);
|
|
232
|
-
return tileMatrix;
|
|
233
|
-
}
|
|
234
|
-
return TileMatrixSets.get(this.json.output.epsg);
|
|
235
|
-
}
|
|
236
|
-
get targetZoom() {
|
|
237
|
-
var _a;
|
|
238
|
-
const { gsd } = this.source;
|
|
239
|
-
if (((_a = this.cacheTargetZoom) === null || _a === void 0 ? void 0 : _a.gsd) !== gsd) {
|
|
240
|
-
this.cacheTargetZoom = { gsd, zoom: Projection.getTiffResZoom(this.tileMatrix, gsd) };
|
|
241
|
-
}
|
|
242
|
-
return this.cacheTargetZoom.zoom;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Get a nicely formatted folder path based on the job
|
|
246
|
-
*
|
|
247
|
-
* @param key optional file key inside of the job folder
|
|
248
|
-
*/
|
|
249
|
-
getJobPath(key) {
|
|
250
|
-
const parts = [this.tileMatrix.projection.code, this.name, this.id];
|
|
251
|
-
if (key != null) {
|
|
252
|
-
parts.push(key);
|
|
253
|
-
}
|
|
254
|
-
return fsa.join(this.output.location.path, parts.join('/'));
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
//# sourceMappingURL=cog.stac.job.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cog.stac.job.js","sourceRoot":"","sources":["../../src/cog/cog.stac.job.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAEN,UAAU,EACV,IAAI,EAKJ,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,wBAAwB,EAGxB,GAAG,EACH,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAgB,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAA4B,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAwB,qBAAqB,EAAE,eAAe,EAAE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UAAU,CAAC,CAAC;YACpE,IAAI,UAAU,IAAI,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;YACzG,OAAO,UAAU,CAAC;SACnB;QACD,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,UAAU;;QACZ,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAA,MAAA,IAAI,CAAC,eAAe,0CAAE,GAAG,MAAK,GAAG,EAAE;YACrC,IAAI,CAAC,eAAe,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC;SACvF;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,GAAY;QACrB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACpE,IAAI,GAAG,IAAI,IAAI,EAAE;YACf,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACjB;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
package/build/cog/cog.vrt.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { LogType } from '@basemaps/shared';
|
|
2
|
-
import { Cutline } from './cutline.js';
|
|
3
|
-
import { CogJob } from './types.js';
|
|
4
|
-
export declare const CogVrt: {
|
|
5
|
-
/**
|
|
6
|
-
* Build a vrt file for a COG `name` that transforms the source imagery with a cutline
|
|
7
|
-
*
|
|
8
|
-
* @param tmpFolder temporary `vrt` and `cutline.geojson` will be written here
|
|
9
|
-
* @param job
|
|
10
|
-
* @param cutline Used to filter the source imagery
|
|
11
|
-
* @param name COG tile to reduce vrt and cutline
|
|
12
|
-
* @param logger
|
|
13
|
-
*
|
|
14
|
-
* @return the path to the vrt file
|
|
15
|
-
*/
|
|
16
|
-
buildVrt(tmpFolder: string, job: CogJob, cutline: Cutline, name: string, logger: LogType): Promise<string | null>;
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=cog.vrt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cog.vrt.d.ts","sourceRoot":"","sources":["../../src/cog/cog.vrt.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,OAAO,EAAa,MAAM,kBAAkB,CAAC;AAIhF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAgEpC,eAAO,MAAM,MAAM;IACjB;;;;;;;;;;OAUG;wBAEU,MAAM,OACZ,MAAM,WACF,OAAO,QACV,MAAM,UACJ,OAAO,GACd,QAAQ,MAAM,GAAG,IAAI,CAAC;CAuD1B,CAAC"}
|
package/build/cog/cog.vrt.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Epsg } from '@basemaps/geo';
|
|
2
|
-
import { Env, fsa, isConfigS3Role, s3ToVsis3 } from '@basemaps/shared';
|
|
3
|
-
import { Gdal } from '../gdal/gdal.js';
|
|
4
|
-
import { onProgress } from './cog.js';
|
|
5
|
-
import { AwsCredentials } from '@chunkd/source-aws-v2';
|
|
6
|
-
/**
|
|
7
|
-
* Build the VRT for the needed source imagery
|
|
8
|
-
*/
|
|
9
|
-
async function buildPlainVrt(job, sourceFiles, vrtPath, gdalCommand, logger) {
|
|
10
|
-
const buildOpts = ['-hidenodata', '-allow_projection_difference'];
|
|
11
|
-
if (job.output.addAlpha) {
|
|
12
|
-
buildOpts.push('-addalpha');
|
|
13
|
-
}
|
|
14
|
-
logger.debug({ buildOpts: buildOpts.join(' ') }, 'gdalbuildvrt');
|
|
15
|
-
await gdalCommand.run('gdalbuildvrt', [...buildOpts, vrtPath, ...sourceFiles], logger);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Warp the source vrt to target projection using an optional cutline
|
|
19
|
-
*/
|
|
20
|
-
async function buildWarpVrt(job, sourceVrtPath, gdalCommand, cogVrtPath, tr, logger, cutlineTarget) {
|
|
21
|
-
const warpOpts = [
|
|
22
|
-
'-of',
|
|
23
|
-
'VRT',
|
|
24
|
-
'-multi',
|
|
25
|
-
'-wo',
|
|
26
|
-
'NUM_THREADS=ALL_CPUS',
|
|
27
|
-
'-s_srs',
|
|
28
|
-
Epsg.get(job.source.epsg).toEpsgString(),
|
|
29
|
-
'-t_srs',
|
|
30
|
-
job.tileMatrix.projection.toEpsgString(),
|
|
31
|
-
'-tr',
|
|
32
|
-
tr,
|
|
33
|
-
tr,
|
|
34
|
-
'-tap',
|
|
35
|
-
];
|
|
36
|
-
if (job.output.cutline != null) {
|
|
37
|
-
warpOpts.push('-cutline', cutlineTarget);
|
|
38
|
-
if (job.output.cutline.blend !== 0)
|
|
39
|
-
warpOpts.push('-cblend', String(job.output.cutline.blend));
|
|
40
|
-
}
|
|
41
|
-
if (job.output.nodata != null) {
|
|
42
|
-
warpOpts.push('-srcnodata', String(job.output.nodata), '-dstnodata', String(job.output.nodata));
|
|
43
|
-
}
|
|
44
|
-
if (job.output.resampling) {
|
|
45
|
-
warpOpts.push('-r', job.output.resampling.warp);
|
|
46
|
-
}
|
|
47
|
-
logger.debug({ warpOpts: warpOpts.join(' ') }, 'gdalwarp');
|
|
48
|
-
await gdalCommand.run('gdalwarp', [...warpOpts, cogVrtPath, sourceVrtPath], logger);
|
|
49
|
-
}
|
|
50
|
-
export const CogVrt = {
|
|
51
|
-
/**
|
|
52
|
-
* Build a vrt file for a COG `name` that transforms the source imagery with a cutline
|
|
53
|
-
*
|
|
54
|
-
* @param tmpFolder temporary `vrt` and `cutline.geojson` will be written here
|
|
55
|
-
* @param job
|
|
56
|
-
* @param cutline Used to filter the source imagery
|
|
57
|
-
* @param name COG tile to reduce vrt and cutline
|
|
58
|
-
* @param logger
|
|
59
|
-
*
|
|
60
|
-
* @return the path to the vrt file
|
|
61
|
-
*/
|
|
62
|
-
async buildVrt(tmpFolder, job, cutline, name, logger) {
|
|
63
|
-
logger.info({ name }, 'buildCogVrt');
|
|
64
|
-
const sourceFiles = cutline.filterSourcesForName(name, job).map(s3ToVsis3);
|
|
65
|
-
if (sourceFiles.length === 0) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
const sourceVrtPath = fsa.join(tmpFolder, `source.vrt`);
|
|
69
|
-
const cogVrtPath = fsa.join(tmpFolder, `cog.vrt`);
|
|
70
|
-
let cutlineTarget = '';
|
|
71
|
-
if (cutline.clipPoly.length !== 0) {
|
|
72
|
-
cutlineTarget = fsa.join(tmpFolder, 'cutline.geojson');
|
|
73
|
-
await fsa.writeJson(cutlineTarget, cutline.toGeoJson());
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
job.output.cutline = undefined;
|
|
77
|
-
}
|
|
78
|
-
logger.info({
|
|
79
|
-
inputTotal: job.source.files.length,
|
|
80
|
-
outputTotal: sourceFiles.length,
|
|
81
|
-
cutlinePolygons: cutline.clipPoly.length,
|
|
82
|
-
}, 'Tiff count');
|
|
83
|
-
const gdalCommand = Gdal.create();
|
|
84
|
-
const sourceLocation = job.source.location;
|
|
85
|
-
// If required assume role
|
|
86
|
-
if (isConfigS3Role(sourceLocation)) {
|
|
87
|
-
const credentials = AwsCredentials.role(sourceLocation.roleArn, sourceLocation.externalId, Env.getNumber(Env.AwsRoleDurationHours, 8) * 60 * 60);
|
|
88
|
-
gdalCommand.setCredentials(credentials);
|
|
89
|
-
}
|
|
90
|
-
if (gdalCommand.mount != null) {
|
|
91
|
-
gdalCommand.mount(tmpFolder);
|
|
92
|
-
for (const file of job.source.files)
|
|
93
|
-
gdalCommand.mount(file.name);
|
|
94
|
-
}
|
|
95
|
-
const tr = job.output.gsd.toString();
|
|
96
|
-
onProgress(gdalCommand, { target: `vrt.${job.tileMatrix.projection.code}` }, logger);
|
|
97
|
-
await buildPlainVrt(job, sourceFiles, sourceVrtPath, gdalCommand, logger);
|
|
98
|
-
await buildWarpVrt(job, cogVrtPath, gdalCommand, sourceVrtPath, tr, logger, cutlineTarget);
|
|
99
|
-
return cogVrtPath;
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=cog.vrt.js.map
|