@basemaps/cli 7.0.0 → 7.1.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/build/cli/__tests__/util.test.d.ts +0 -1
- package/build/cli/__tests__/util.test.js +11 -10
- package/build/cli/__tests__/util.test.js.map +1 -1
- package/build/cli/bin.d.ts +0 -1
- package/build/cli/config/action.bundle.assets.d.ts +5 -7
- package/build/cli/config/action.bundle.assets.js +34 -21
- package/build/cli/config/action.bundle.assets.js.map +1 -1
- package/build/cli/config/action.bundle.d.ts +1 -1
- package/build/cli/config/action.bundle.js +40 -10
- package/build/cli/config/action.bundle.js.map +1 -1
- package/build/cli/config/action.import.d.ts +4 -9
- package/build/cli/config/action.import.js +131 -110
- package/build/cli/config/action.import.js.map +1 -1
- package/build/cli/config/config.diff.d.ts +2 -2
- package/build/cli/config/config.diff.js +6 -4
- package/build/cli/config/config.diff.js.map +1 -1
- package/build/cli/config/config.update.d.ts +3 -5
- package/build/cli/config/config.update.js +42 -7
- package/build/cli/config/config.update.js.map +1 -1
- package/build/cli/folder.d.ts +0 -1
- package/build/cli/folder.js +1 -2
- package/build/cli/folder.js.map +1 -1
- package/build/cli/index.d.ts +0 -2
- package/build/cli/index.js +0 -6
- package/build/cli/index.js.map +1 -1
- package/build/cli/server/action.serve.d.ts +0 -1
- package/build/cli/server/action.serve.js +27 -4
- package/build/cli/server/action.serve.js.map +1 -1
- package/build/cli/util.d.ts +2 -2
- package/build/cli/util.js +38 -37
- package/build/cli/util.js.map +1 -1
- package/package.json +20 -19
- package/CHANGELOG.md +0 -1612
- package/build/cli/__tests__/util.test.d.ts.map +0 -1
- package/build/cli/bin.d.ts.map +0 -1
- package/build/cli/config/action.bundle.assets.d.ts.map +0 -1
- package/build/cli/config/action.bundle.d.ts.map +0 -1
- package/build/cli/config/action.imagery.config.d.ts +0 -11
- package/build/cli/config/action.imagery.config.d.ts.map +0 -1
- package/build/cli/config/action.imagery.config.js +0 -142
- package/build/cli/config/action.imagery.config.js.map +0 -1
- package/build/cli/config/action.import.d.ts.map +0 -1
- package/build/cli/config/config.diff.d.ts.map +0 -1
- package/build/cli/config/config.update.d.ts.map +0 -1
- package/build/cli/folder.d.ts.map +0 -1
- package/build/cli/index.d.ts.map +0 -1
- package/build/cli/overview/__test__/wmts.overview.test.d.ts +0 -2
- package/build/cli/overview/__test__/wmts.overview.test.d.ts.map +0 -1
- package/build/cli/overview/__test__/wmts.overview.test.js +0 -24
- package/build/cli/overview/__test__/wmts.overview.test.js.map +0 -1
- package/build/cli/overview/action.create.overview.d.ts +0 -19
- package/build/cli/overview/action.create.overview.d.ts.map +0 -1
- package/build/cli/overview/action.create.overview.js +0 -178
- package/build/cli/overview/action.create.overview.js.map +0 -1
- package/build/cli/overview/overview.wmts.d.ts +0 -3
- package/build/cli/overview/overview.wmts.d.ts.map +0 -1
- package/build/cli/overview/overview.wmts.js +0 -29
- package/build/cli/overview/overview.wmts.js.map +0 -1
- package/build/cli/overview/tile.generator.d.ts +0 -13
- package/build/cli/overview/tile.generator.d.ts.map +0 -1
- package/build/cli/overview/tile.generator.js +0 -86
- package/build/cli/overview/tile.generator.js.map +0 -1
- package/build/cli/overview/timer.d.ts +0 -14
- package/build/cli/overview/timer.d.ts.map +0 -1
- package/build/cli/overview/timer.js +0 -21
- package/build/cli/overview/timer.js.map +0 -1
- package/build/cli/server/action.serve.d.ts.map +0 -1
- package/build/cli/util.d.ts.map +0 -1
- package/build/cog/builder.d.ts +0 -49
- package/build/cog/builder.d.ts.map +0 -1
- package/build/cog/builder.js +0 -177
- package/build/cog/builder.js.map +0 -1
- package/build/cog/cutline.d.ts +0 -75
- package/build/cog/cutline.d.ts.map +0 -1
- package/build/cog/cutline.js +0 -250
- package/build/cog/cutline.js.map +0 -1
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class SimpleTimer {
|
|
2
|
-
/** time of last .tick() call */
|
|
3
|
-
lastTime: number;
|
|
4
|
-
/** time SimpleTimer was created */
|
|
5
|
-
startTime: number;
|
|
6
|
-
constructor();
|
|
7
|
-
/** Reset the timers */
|
|
8
|
-
reset(): void;
|
|
9
|
-
/** Get the duration since the last `.tick()` call rounded to 4 decimal places */
|
|
10
|
-
tick(): number;
|
|
11
|
-
/** Get the total time since the last `.reset()` */
|
|
12
|
-
total(): number;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=timer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../../src/cli/overview/timer.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACtB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;;IAMlB,uBAAuB;IACvB,KAAK,IAAI,IAAI;IAKb,iFAAiF;IACjF,IAAI,IAAI,MAAM;IAMd,mDAAmD;IACnD,KAAK,IAAI,MAAM;CAGhB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export class SimpleTimer {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.reset();
|
|
4
|
-
}
|
|
5
|
-
/** Reset the timers */
|
|
6
|
-
reset() {
|
|
7
|
-
this.lastTime = performance.now();
|
|
8
|
-
this.startTime = this.lastTime;
|
|
9
|
-
}
|
|
10
|
-
/** Get the duration since the last `.tick()` call rounded to 4 decimal places */
|
|
11
|
-
tick() {
|
|
12
|
-
const duration = Number((performance.now() - this.lastTime).toFixed(4));
|
|
13
|
-
this.lastTime = performance.now();
|
|
14
|
-
return duration;
|
|
15
|
-
}
|
|
16
|
-
/** Get the total time since the last `.reset()` */
|
|
17
|
-
total() {
|
|
18
|
-
return Number((performance.now() - this.startTime).toFixed(4));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=timer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer.js","sourceRoot":"","sources":["../../../src/cli/overview/timer.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;IAMtB;QACE,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,uBAAuB;IACvB,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;IACjC,CAAC;IAED,iFAAiF;IACjF,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,mDAAmD;IACnD,KAAK;QACH,OAAO,MAAM,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action.serve.d.ts","sourceRoot":"","sources":["../../../src/cli/server/action.serve.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,4BAA4B,CAAC;AAIpC,qBAAa,YAAa,SAAQ,iBAAiB;IACjD,MAAM,EAAE,0BAA0B,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;IACnC,IAAI,EAAE,2BAA2B,CAAC;IAClC,QAAQ,EAAE,wBAAwB,CAAC;;IAUnC,SAAS,CAAC,kBAAkB,IAAI,IAAI;cAmBpB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAe3C"}
|
package/build/cli/util.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/cli/util.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B5F;AAED,eAAO,MAAM,OAAO,cAAc,CAAC;AAEnC,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASjF;AAOD,wBAAgB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAajD;AAMD;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CA4BlB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtD"}
|
package/build/cog/builder.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Epsg, TileMatrixSet } from '@basemaps/geo';
|
|
2
|
-
import { LogType } from '@basemaps/shared';
|
|
3
|
-
import { ChunkSource } from '@chunkd/core';
|
|
4
|
-
import { CogTiff } from '@cogeotiff/core';
|
|
5
|
-
import { LimitFunction } from 'p-limit';
|
|
6
|
-
import { Cutline } from './cutline.js';
|
|
7
|
-
import { CogBuilderMetadata, SourceMetadata } from '@basemaps/shared';
|
|
8
|
-
export declare const InvalidProjectionCode = 32767;
|
|
9
|
-
/**
|
|
10
|
-
* Attempt to guess the projection based off the WKT
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
*
|
|
14
|
-
* "PCS Name = NZGD_2000_New_Zealand_Transverse_Mercator|GCS Name = GCS_NZGD_2000|Ellipsoid = GRS_1980|Primem = Greenwich||"
|
|
15
|
-
* "NZGD2000_New_Zealand_Transverse_Mercator_2000|GCS Name = GCS_NZGD_2000|Primem = Greenwich||"
|
|
16
|
-
*
|
|
17
|
-
* @param wkt
|
|
18
|
-
*/
|
|
19
|
-
export declare function guessProjection(wkt: string | null): Epsg | null;
|
|
20
|
-
export declare class CogBuilder {
|
|
21
|
-
q: LimitFunction;
|
|
22
|
-
logger: LogType;
|
|
23
|
-
targetTms: TileMatrixSet;
|
|
24
|
-
srcProj?: Epsg;
|
|
25
|
-
wktPreviousGuesses: Set<string>;
|
|
26
|
-
/**
|
|
27
|
-
* @param concurrency number of requests to run at a time
|
|
28
|
-
*/
|
|
29
|
-
constructor(targetTms: TileMatrixSet, concurrency: number, logger: LogType, srcProj?: Epsg);
|
|
30
|
-
/**
|
|
31
|
-
* Get the source bounds a collection of tiffs
|
|
32
|
-
* @param tiffs
|
|
33
|
-
*/
|
|
34
|
-
bounds(sources: ChunkSource[]): Promise<SourceMetadata>;
|
|
35
|
-
findProjection(tiff: CogTiff): Epsg;
|
|
36
|
-
/**
|
|
37
|
-
* Get the nodata value stored in the source tiff
|
|
38
|
-
* @param tiff
|
|
39
|
-
* @param logger
|
|
40
|
-
*/
|
|
41
|
-
findNoData(tiff: CogTiff): number | null;
|
|
42
|
-
/**
|
|
43
|
-
* Generate a list of tiles that need to be generated to cover the source tiffs
|
|
44
|
-
* @param tiffs list of source imagery to be converted
|
|
45
|
-
* @returns List of Tile bounds covering tiffs
|
|
46
|
-
*/
|
|
47
|
-
build(tiffs: ChunkSource[], cutline: Cutline, alignedLevel?: number): Promise<CogBuilderMetadata>;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/cog/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAc,aAAa,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAoC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAuB,MAAM,iBAAiB,CAAC;AAC/D,OAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEtE,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAO/D;AAED,qBAAa,UAAU;IACrB,CAAC,EAAE,aAAa,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,IAAI,CAAC;IAGf,kBAAkB,cAAqB;IAEvC;;OAEG;gBACS,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,IAAI;IAO1F;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAoF7D,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IA6BnC;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAaxC;;;;OAIG;IACG,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAaxG"}
|
package/build/cog/builder.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { Bounds, Epsg, Projection } from '@basemaps/geo';
|
|
2
|
-
import { CompositeError, LoggerFatalError } from '@basemaps/shared';
|
|
3
|
-
import { CogTiff, TiffTag, TiffTagGeo } from '@cogeotiff/core';
|
|
4
|
-
import pLimit from 'p-limit';
|
|
5
|
-
import { basename } from 'path';
|
|
6
|
-
import { ProjectionLoader } from '@basemaps/geo';
|
|
7
|
-
export const InvalidProjectionCode = 32767;
|
|
8
|
-
/**
|
|
9
|
-
* Attempt to guess the projection based off the WKT
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* "PCS Name = NZGD_2000_New_Zealand_Transverse_Mercator|GCS Name = GCS_NZGD_2000|Ellipsoid = GRS_1980|Primem = Greenwich||"
|
|
14
|
-
* "NZGD2000_New_Zealand_Transverse_Mercator_2000|GCS Name = GCS_NZGD_2000|Primem = Greenwich||"
|
|
15
|
-
*
|
|
16
|
-
* @param wkt
|
|
17
|
-
*/
|
|
18
|
-
export function guessProjection(wkt) {
|
|
19
|
-
if (wkt == null)
|
|
20
|
-
return null;
|
|
21
|
-
const searchWkt = wkt.replace(/_/g, ' ');
|
|
22
|
-
if (searchWkt.includes('New Zealand Transverse Mercator'))
|
|
23
|
-
return Epsg.Nztm2000;
|
|
24
|
-
if (searchWkt.includes('Chatham Islands Transverse Mercator 2000'))
|
|
25
|
-
return Epsg.Citm2000;
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
export class CogBuilder {
|
|
29
|
-
/**
|
|
30
|
-
* @param concurrency number of requests to run at a time
|
|
31
|
-
*/
|
|
32
|
-
constructor(targetTms, concurrency, logger, srcProj) {
|
|
33
|
-
// Prevent guessing spamming the logs
|
|
34
|
-
this.wktPreviousGuesses = new Set();
|
|
35
|
-
this.targetTms = targetTms;
|
|
36
|
-
this.logger = logger;
|
|
37
|
-
this.q = pLimit(concurrency);
|
|
38
|
-
this.srcProj = srcProj;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Get the source bounds a collection of tiffs
|
|
42
|
-
* @param tiffs
|
|
43
|
-
*/
|
|
44
|
-
async bounds(sources) {
|
|
45
|
-
let resX = -1;
|
|
46
|
-
let bands = -1;
|
|
47
|
-
let projection = this.srcProj;
|
|
48
|
-
let nodata;
|
|
49
|
-
let count = 0;
|
|
50
|
-
const queue = sources.map((source) => {
|
|
51
|
-
return this.q(async () => {
|
|
52
|
-
count++;
|
|
53
|
-
if (count % 50 === 0)
|
|
54
|
-
this.logger.info({ count, total: sources.length }, 'BoundsProgress');
|
|
55
|
-
this.logger.trace({ source: source.uri }, 'Tiff:Load');
|
|
56
|
-
const tiff = new CogTiff(source);
|
|
57
|
-
await tiff.init(true);
|
|
58
|
-
const image = tiff.getImage(0);
|
|
59
|
-
if (resX === -1 || image.resolution[0] < resX)
|
|
60
|
-
resX = image.resolution[0];
|
|
61
|
-
// Check number of bands to determine alpha layer
|
|
62
|
-
const tiffBandCount = image.value(TiffTag.BitsPerSample);
|
|
63
|
-
if (tiffBandCount != null && tiffBandCount.length > bands) {
|
|
64
|
-
if (bands > -1) {
|
|
65
|
-
this.logger.error({
|
|
66
|
-
firstImage: basename(sources[0].uri),
|
|
67
|
-
bands,
|
|
68
|
-
currentImage: basename(source.uri),
|
|
69
|
-
currentBands: tiffBandCount,
|
|
70
|
-
}, 'Multiple Bands');
|
|
71
|
-
}
|
|
72
|
-
bands = tiffBandCount.length;
|
|
73
|
-
}
|
|
74
|
-
const output = { ...Bounds.fromBbox(image.bbox).toJson(), name: source.uri };
|
|
75
|
-
if (source.close)
|
|
76
|
-
await source.close();
|
|
77
|
-
const imageProjection = this.findProjection(tiff);
|
|
78
|
-
if (imageProjection != null && (projection === null || projection === void 0 ? void 0 : projection.code) !== imageProjection.code) {
|
|
79
|
-
if (projection != null) {
|
|
80
|
-
this.logger.error({
|
|
81
|
-
firstImage: basename(sources[0].uri),
|
|
82
|
-
projection,
|
|
83
|
-
currentImage: basename(source.uri),
|
|
84
|
-
currentProjection: imageProjection,
|
|
85
|
-
}, 'Multiple projections');
|
|
86
|
-
throw new Error('Multiple projections');
|
|
87
|
-
}
|
|
88
|
-
projection = imageProjection;
|
|
89
|
-
}
|
|
90
|
-
const tiffNoData = this.findNoData(tiff);
|
|
91
|
-
if (tiffNoData != null && tiffNoData !== nodata) {
|
|
92
|
-
if (nodata != null)
|
|
93
|
-
throw new Error('Multiple No Data values');
|
|
94
|
-
nodata = tiffNoData;
|
|
95
|
-
}
|
|
96
|
-
return output;
|
|
97
|
-
}).catch((e) => {
|
|
98
|
-
throw new CompositeError('Failed to process image: ' + source.uri, 500, e);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
const bounds = await Promise.all(queue);
|
|
102
|
-
if (projection == null)
|
|
103
|
-
throw new Error('No projection detected');
|
|
104
|
-
if (resX === -1)
|
|
105
|
-
throw new Error('No resolution detected');
|
|
106
|
-
if (bands === -1)
|
|
107
|
-
throw new Error('No image bands detected');
|
|
108
|
-
return {
|
|
109
|
-
projection: projection.code,
|
|
110
|
-
nodata,
|
|
111
|
-
bands,
|
|
112
|
-
bounds,
|
|
113
|
-
pixelScale: resX,
|
|
114
|
-
resZoom: Projection.getTiffResZoom(this.targetTms, resX),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
findProjection(tiff) {
|
|
118
|
-
var _a;
|
|
119
|
-
const image = tiff.getImage(0);
|
|
120
|
-
const projection = image.valueGeo(TiffTagGeo.ProjectedCSTypeGeoKey);
|
|
121
|
-
if (projection != null && projection !== InvalidProjectionCode) {
|
|
122
|
-
return (_a = Epsg.tryGet(projection)) !== null && _a !== void 0 ? _a : new Epsg(projection);
|
|
123
|
-
}
|
|
124
|
-
const imgWkt = image.value(TiffTag.GeoAsciiParams);
|
|
125
|
-
const epsg = guessProjection(imgWkt);
|
|
126
|
-
if (imgWkt != null && epsg != null) {
|
|
127
|
-
if (!this.wktPreviousGuesses.has(imgWkt)) {
|
|
128
|
-
this.logger.trace({ tiff: tiff.source.uri, imgWkt, projection }, 'GuessingProjection from GeoAsciiParams');
|
|
129
|
-
}
|
|
130
|
-
this.wktPreviousGuesses.add(imgWkt);
|
|
131
|
-
return epsg;
|
|
132
|
-
}
|
|
133
|
-
if (this.srcProj != null) {
|
|
134
|
-
this.logger.warn({ tiff: tiff.source.uri, projection, imgWkt, defaultProjection: this.srcProj }, 'Default findProjection');
|
|
135
|
-
return this.srcProj;
|
|
136
|
-
}
|
|
137
|
-
this.logger.error({ tiff: tiff.source.uri, projection, imgWkt }, 'Failed findProjection');
|
|
138
|
-
throw new Error('Failed to find projection');
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Get the nodata value stored in the source tiff
|
|
142
|
-
* @param tiff
|
|
143
|
-
* @param logger
|
|
144
|
-
*/
|
|
145
|
-
findNoData(tiff) {
|
|
146
|
-
const noData = tiff.getImage(0).value(TiffTag.GDAL_NODATA);
|
|
147
|
-
if (noData == null)
|
|
148
|
-
return null;
|
|
149
|
-
const noDataNum = parseInt(noData);
|
|
150
|
-
if (isNaN(noDataNum) || noDataNum < 0 || noDataNum > 256) {
|
|
151
|
-
throw new LoggerFatalError({ tiff: tiff.source.uri, noData }, 'Failed converting GDAL_NODATA, defaulting to 255');
|
|
152
|
-
}
|
|
153
|
-
return noDataNum;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Generate a list of tiles that need to be generated to cover the source tiffs
|
|
157
|
-
* @param tiffs list of source imagery to be converted
|
|
158
|
-
* @returns List of Tile bounds covering tiffs
|
|
159
|
-
*/
|
|
160
|
-
async build(tiffs, cutline, alignedLevel) {
|
|
161
|
-
const metadata = await this.bounds(tiffs);
|
|
162
|
-
// Ensure that the projection definition is loaded
|
|
163
|
-
await ProjectionLoader.load(metadata.projection);
|
|
164
|
-
const files = cutline.optimizeCovering(metadata, alignedLevel);
|
|
165
|
-
let union = null;
|
|
166
|
-
for (const bounds of files) {
|
|
167
|
-
if (union == null)
|
|
168
|
-
union = Bounds.fromJson(bounds);
|
|
169
|
-
else
|
|
170
|
-
union = Bounds.fromJson(bounds).union(union);
|
|
171
|
-
}
|
|
172
|
-
if (union == null)
|
|
173
|
-
throw new Error('Bug! union can not be null');
|
|
174
|
-
return { ...metadata, files, targetBounds: union.toJson() };
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=builder.js.map
|
package/build/cog/builder.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/cog/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAW,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,MAAyB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAE3C;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,GAAkB;IAChD,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;IAChF,IAAI,SAAS,CAAC,QAAQ,CAAC,0CAA0C,CAAC;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;IAEzF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,OAAO,UAAU;IASrB;;OAEG;IACH,YAAY,SAAwB,EAAE,WAAmB,EAAE,MAAe,EAAE,OAAc;QAN1F,qCAAqC;QACrC,uBAAkB,GAAG,IAAI,GAAG,EAAU,CAAC;QAMrC,IAAI,CAAC,SAAS,G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build/cog/cutline.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Bounds, NamedBounds, TileMatrixSet } from '@basemaps/geo';
|
|
2
|
-
import { MultiPolygon } from '@linzjs/geojson';
|
|
3
|
-
import { FeatureCollection } from 'geojson';
|
|
4
|
-
import { CogJob, FeatureCollectionWithCrs, SourceMetadata } from '@basemaps/shared';
|
|
5
|
-
export declare function polyContainsBounds(poly: MultiPolygon, bounds: Bounds): boolean;
|
|
6
|
-
export declare class Cutline {
|
|
7
|
-
/** The polygon to clip source imagery to */
|
|
8
|
-
clipPoly: MultiPolygon;
|
|
9
|
-
tileMatrix: TileMatrixSet;
|
|
10
|
-
/** How much blending to apply at the clip line boundary */
|
|
11
|
-
blend: number;
|
|
12
|
-
/** the polygon outlining a area covered by the source imagery and clip polygon */
|
|
13
|
-
srcPoly: MultiPolygon;
|
|
14
|
-
/**
|
|
15
|
-
* Create a Cutline instance from a `GeoJSON FeatureCollection`.
|
|
16
|
-
|
|
17
|
-
* @param tileMatrix the tileMatrix the COGs will be created in.
|
|
18
|
-
|
|
19
|
-
* @param clipPoly the optional cutline. The source imagery outline used by default. This
|
|
20
|
-
* `FeatureCollection` is converted to one `MultiPolygon` with any holes removed and the
|
|
21
|
-
* coordinates transposed from `Wgs84` to the target projection (unless already in target projection).
|
|
22
|
-
|
|
23
|
-
* @param blend How much blending to consider when working out boundaries.
|
|
24
|
-
*/
|
|
25
|
-
constructor(tileMatrix: TileMatrixSet, clipPoly?: FeatureCollection, blend?: number);
|
|
26
|
-
/**
|
|
27
|
-
* Load a geojson cutline from the file-system.
|
|
28
|
-
*
|
|
29
|
-
* @param path the path of the cutline to load. Can be `s3://` or local file path.
|
|
30
|
-
*/
|
|
31
|
-
static loadCutline(path: string): Promise<FeatureCollection>;
|
|
32
|
-
/**
|
|
33
|
-
* For the given tile `name`, filter `job.source.files` and cutline polygons that are within bounds plus
|
|
34
|
-
* padding
|
|
35
|
-
*
|
|
36
|
-
* @param name
|
|
37
|
-
* @param job
|
|
38
|
-
* @returns names of source files required to render Cog
|
|
39
|
-
*/
|
|
40
|
-
filterSourcesForName(name: string, job: CogJob): string[];
|
|
41
|
-
/**
|
|
42
|
-
* Generate an optimized WebMercator tile cover for the supplied source images
|
|
43
|
-
* @param sourceMetadata contains images bounds and projection info
|
|
44
|
-
*/
|
|
45
|
-
optimizeCovering(sourceMetadata: SourceMetadata, alignedLevel?: number): NamedBounds[];
|
|
46
|
-
/**
|
|
47
|
-
* Convert JobCutline to geojson FeatureCollection
|
|
48
|
-
*/
|
|
49
|
-
toGeoJson(clipPoly?: MultiPolygon): FeatureCollectionWithCrs;
|
|
50
|
-
/**
|
|
51
|
-
* Merge child nodes that have at least a covering fraction
|
|
52
|
-
* @param tile the tile to descend
|
|
53
|
-
* @param srcArea the area of interest
|
|
54
|
-
* @param minZ Only produce tiles for zoom levels at least `minZ` and no sibling tiles
|
|
55
|
-
* greater than `minZ + 4`
|
|
56
|
-
* @param coveringFraction merge tiles that cover at least this fraction
|
|
57
|
-
* @return the tiles and fraction covered of the tile by this srcArea
|
|
58
|
-
*/
|
|
59
|
-
private makeTiles;
|
|
60
|
-
/**
|
|
61
|
-
* Find the polygon covering of source imagery and a (optional) clip cutline. Truncates the
|
|
62
|
-
* cutline to match.
|
|
63
|
-
*
|
|
64
|
-
* @param sourceMetadata
|
|
65
|
-
*/
|
|
66
|
-
private findCovering;
|
|
67
|
-
/**
|
|
68
|
-
* Pad the bounds to take in to consideration blending and 100 pixels of adjacent image data
|
|
69
|
-
*
|
|
70
|
-
* @param bounds
|
|
71
|
-
* @param resZoom the imagery resolution target zoom level
|
|
72
|
-
*/
|
|
73
|
-
private padBounds;
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=cutline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cutline.d.ts","sourceRoot":"","sources":["../../src/cog/cutline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ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'@basemaps/shared';
|
|
3
|
-
import { clipMultipolygon, featuresToMultiPolygon, intersection, toFeatureCollection, toFeatureMultiPolygon, union, } from '@linzjs/geojson';
|
|
4
|
-
import { AlignedLevel, CoveringFraction } from '@basemaps/shared';
|
|
5
|
-
/** Padding to always apply to image boundies */
|
|
6
|
-
const PixelPadding = 200;
|
|
7
|
-
/** fraction to scale source imagery to avoid degenerate edges */
|
|
8
|
-
const SourceSmoothScale = 1 + 1e-8;
|
|
9
|
-
function findGeoJsonProjection(geojson) {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
11
|
-
return (_d = Epsg.parse((_c = (_b = (_a = geojson === null || geojson === void 0 ? void 0 : geojson.crs) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '')) !== null && _d !== void 0 ? _d : Epsg.Wgs84;
|
|
12
|
-
}
|
|
13
|
-
function namedBounds(tms, tile) {
|
|
14
|
-
return { name: TileMatrixSet.tileToName(tile), ...tms.tileToSourceBounds(tile).toJson() };
|
|
15
|
-
}
|
|
16
|
-
export function polyContainsBounds(poly, bounds) {
|
|
17
|
-
const clipped = clipMultipolygon(poly, bounds.toBbox());
|
|
18
|
-
if (clipped.length !== 1 || clipped[0].length !== 1 || clipped[0][0].length !== 5)
|
|
19
|
-
return false;
|
|
20
|
-
return Bounds.fromMultiPolygon(clipped).containsBounds(bounds);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Filter out duplicate tiles
|
|
24
|
-
*/
|
|
25
|
-
function addNonDupes(list, addList) {
|
|
26
|
-
const len = list.length;
|
|
27
|
-
for (const add of addList) {
|
|
28
|
-
let i = 0;
|
|
29
|
-
for (; i < len; ++i) {
|
|
30
|
-
const curr = list[i];
|
|
31
|
-
if (curr.x === add.x && curr.y === add.y && curr.z === add.z) {
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (i === len) {
|
|
36
|
-
list.push(add);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export class Cutline {
|
|
41
|
-
/**
|
|
42
|
-
* Create a Cutline instance from a `GeoJSON FeatureCollection`.
|
|
43
|
-
|
|
44
|
-
* @param tileMatrix the tileMatrix the COGs will be created in.
|
|
45
|
-
|
|
46
|
-
* @param clipPoly the optional cutline. The source imagery outline used by default. This
|
|
47
|
-
* `FeatureCollection` is converted to one `MultiPolygon` with any holes removed and the
|
|
48
|
-
* coordinates transposed from `Wgs84` to the target projection (unless already in target projection).
|
|
49
|
-
|
|
50
|
-
* @param blend How much blending to consider when working out boundaries.
|
|
51
|
-
*/
|
|
52
|
-
constructor(tileMatrix, clipPoly, blend = 0) {
|
|
53
|
-
/** the polygon outlining a area covered by the source imagery and clip polygon */
|
|
54
|
-
this.srcPoly = [];
|
|
55
|
-
this.tileMatrix = tileMatrix;
|
|
56
|
-
this.blend = blend;
|
|
57
|
-
if (clipPoly == null) {
|
|
58
|
-
this.clipPoly = [];
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.tileMatrix = tileMatrix;
|
|
62
|
-
const proj = findGeoJsonProjection(clipPoly);
|
|
63
|
-
const tmsProj = Projection.get(tileMatrix);
|
|
64
|
-
const needProj = proj !== tmsProj.epsg;
|
|
65
|
-
if (needProj && proj !== Epsg.Wgs84)
|
|
66
|
-
throw new Error('Invalid geojson; CRS may not be set for cutline!');
|
|
67
|
-
const convert = needProj ? tmsProj.fromWgs84 : undefined;
|
|
68
|
-
this.clipPoly = featuresToMultiPolygon(clipPoly.features, true, convert).coordinates;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Load a geojson cutline from the file-system.
|
|
72
|
-
*
|
|
73
|
-
* @param path the path of the cutline to load. Can be `s3://` or local file path.
|
|
74
|
-
*/
|
|
75
|
-
static loadCutline(path) {
|
|
76
|
-
return fsa.readJson(path);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* For the given tile `name`, filter `job.source.files` and cutline polygons that are within bounds plus
|
|
80
|
-
* padding
|
|
81
|
-
*
|
|
82
|
-
* @param name
|
|
83
|
-
* @param job
|
|
84
|
-
* @returns names of source files required to render Cog
|
|
85
|
-
*/
|
|
86
|
-
filterSourcesForName(name, job) {
|
|
87
|
-
const tile = TileMatrixSet.nameToTile(name);
|
|
88
|
-
const sourceCode = Projection.get(job.source.epsg);
|
|
89
|
-
const targetCode = Projection.get(this.tileMatrix);
|
|
90
|
-
const tileBounds = this.tileMatrix.tileToSourceBounds(tile);
|
|
91
|
-
const tilePadded = this.padBounds(tileBounds, job.targetZoom);
|
|
92
|
-
let tileBoundsInSrcProj = tilePadded;
|
|
93
|
-
if (sourceCode !== targetCode) {
|
|
94
|
-
// convert the padded quadKey to source projection ensuring fully enclosed
|
|
95
|
-
const poly = targetCode.projectMultipolygon([tileBoundsInSrcProj.toPolygon()], sourceCode);
|
|
96
|
-
tileBoundsInSrcProj = Bounds.fromMultiPolygon(poly);
|
|
97
|
-
}
|
|
98
|
-
const paddedBbox = tilePadded.toBbox();
|
|
99
|
-
if (this.clipPoly.length > 0) {
|
|
100
|
-
const poly = clipMultipolygon(this.clipPoly, paddedBbox);
|
|
101
|
-
if (poly.length === 0) {
|
|
102
|
-
// this tile is not needed
|
|
103
|
-
this.clipPoly = [];
|
|
104
|
-
return [];
|
|
105
|
-
}
|
|
106
|
-
else if (polyContainsBounds(poly, tileBounds)) {
|
|
107
|
-
// tile is completely surrounded; no cutline polygons needed
|
|
108
|
-
this.clipPoly = [];
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// set the cutline polygons to just the area of interest (minus degenerate edges)
|
|
112
|
-
this.clipPoly = poly;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return job.source.files
|
|
116
|
-
.filter((image) => tileBoundsInSrcProj.intersects(Bounds.fromJson(image)))
|
|
117
|
-
.map(({ name }) => name);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Generate an optimized WebMercator tile cover for the supplied source images
|
|
121
|
-
* @param sourceMetadata contains images bounds and projection info
|
|
122
|
-
*/
|
|
123
|
-
optimizeCovering(sourceMetadata, alignedLevel = AlignedLevel) {
|
|
124
|
-
this.findCovering(sourceMetadata);
|
|
125
|
-
const { resZoom } = sourceMetadata;
|
|
126
|
-
// Fix the cog Minimum Zoom by the aligned level
|
|
127
|
-
const minZ = Math.max(0, resZoom - alignedLevel);
|
|
128
|
-
let tiles = [];
|
|
129
|
-
for (const tile of this.tileMatrix.topLevelTiles()) {
|
|
130
|
-
// Don't make COGs with a tile.z < minZ.
|
|
131
|
-
tiles = tiles.concat(this.makeTiles(tile, this.srcPoly, minZ, CoveringFraction).tiles);
|
|
132
|
-
}
|
|
133
|
-
if (tiles.length === 0) {
|
|
134
|
-
throw new Error('Source imagery does not overlap with project extent');
|
|
135
|
-
}
|
|
136
|
-
const covering = tiles.map((tile) => namedBounds(this.tileMatrix, tile));
|
|
137
|
-
// remove duplicate
|
|
138
|
-
return covering
|
|
139
|
-
.filter((curr) => {
|
|
140
|
-
for (const other of covering) {
|
|
141
|
-
if (other !== curr && Bounds.contains(other, curr))
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
return true;
|
|
145
|
-
})
|
|
146
|
-
.sort(compareName);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Convert JobCutline to geojson FeatureCollection
|
|
150
|
-
*/
|
|
151
|
-
toGeoJson(clipPoly = this.clipPoly) {
|
|
152
|
-
const feature = toFeatureCollection([toFeatureMultiPolygon(clipPoly)]);
|
|
153
|
-
feature.crs = {
|
|
154
|
-
type: 'name',
|
|
155
|
-
properties: { name: this.tileMatrix.projection.toUrn() },
|
|
156
|
-
};
|
|
157
|
-
return feature;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Merge child nodes that have at least a covering fraction
|
|
161
|
-
* @param tile the tile to descend
|
|
162
|
-
* @param srcArea the area of interest
|
|
163
|
-
* @param minZ Only produce tiles for zoom levels at least `minZ` and no sibling tiles
|
|
164
|
-
* greater than `minZ + 4`
|
|
165
|
-
* @param coveringFraction merge tiles that cover at least this fraction
|
|
166
|
-
* @return the tiles and fraction covered of the tile by this srcArea
|
|
167
|
-
*/
|
|
168
|
-
makeTiles(tile, srcArea, minZ, coveringFraction) {
|
|
169
|
-
const clipBounds = this.tileMatrix.tileToSourceBounds(tile).toBbox();
|
|
170
|
-
srcArea = clipMultipolygon(srcArea, clipBounds);
|
|
171
|
-
if (srcArea.length === 0) {
|
|
172
|
-
return { tiles: [], fractionCovered: 0 };
|
|
173
|
-
}
|
|
174
|
-
if (tile.z === minZ + 4) {
|
|
175
|
-
return { tiles: [tile], fractionCovered: 1 };
|
|
176
|
-
}
|
|
177
|
-
const ans = { tiles: [], fractionCovered: 0 };
|
|
178
|
-
for (const child of this.tileMatrix.coverTile(tile)) {
|
|
179
|
-
const { tiles, fractionCovered } = this.makeTiles(child, srcArea, minZ, coveringFraction);
|
|
180
|
-
if (fractionCovered !== 0) {
|
|
181
|
-
ans.fractionCovered += fractionCovered * 0.25;
|
|
182
|
-
addNonDupes(ans.tiles, tiles);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (
|
|
186
|
-
// tile too small OR children have enough coverage
|
|
187
|
-
(tile.z > minZ + 2 || ans.fractionCovered >= coveringFraction) &&
|
|
188
|
-
// AND more than one child tile
|
|
189
|
-
ans.tiles.length > 1 &&
|
|
190
|
-
// AND tile not too big
|
|
191
|
-
tile.z >= minZ) {
|
|
192
|
-
ans.tiles = [tile]; // replace children with parent
|
|
193
|
-
}
|
|
194
|
-
return ans;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Find the polygon covering of source imagery and a (optional) clip cutline. Truncates the
|
|
198
|
-
* cutline to match.
|
|
199
|
-
*
|
|
200
|
-
* @param sourceMetadata
|
|
201
|
-
*/
|
|
202
|
-
findCovering(sourceMetadata) {
|
|
203
|
-
var _a;
|
|
204
|
-
let srcPoly = [];
|
|
205
|
-
const { resZoom } = sourceMetadata;
|
|
206
|
-
// merge imagery bounds
|
|
207
|
-
for (const image of sourceMetadata.bounds) {
|
|
208
|
-
const poly = [Bounds.fromJson(image).scaleFromCenter(SourceSmoothScale).toPolygon()];
|
|
209
|
-
srcPoly = union(srcPoly, poly);
|
|
210
|
-
}
|
|
211
|
-
// Convert polygon to target projection
|
|
212
|
-
const sourceProj = Projection.get(sourceMetadata.projection);
|
|
213
|
-
const targetProj = Projection.get(this.tileMatrix);
|
|
214
|
-
if (sourceProj !== targetProj) {
|
|
215
|
-
srcPoly = sourceProj.projectMultipolygon(srcPoly, targetProj);
|
|
216
|
-
}
|
|
217
|
-
this.srcPoly = srcPoly;
|
|
218
|
-
if (this.clipPoly.length === 0)
|
|
219
|
-
return;
|
|
220
|
-
const srcBounds = Bounds.fromMultiPolygon(srcPoly);
|
|
221
|
-
const boundsPadded = this.padBounds(srcBounds, resZoom).toBbox();
|
|
222
|
-
const poly = clipMultipolygon(this.clipPoly, boundsPadded);
|
|
223
|
-
if (poly.length === 0) {
|
|
224
|
-
throw new Error('No intersection between source imagery and cutline');
|
|
225
|
-
}
|
|
226
|
-
if (polyContainsBounds(poly, srcBounds)) {
|
|
227
|
-
// tile is completely surrounded; no cutline polygons needed
|
|
228
|
-
this.clipPoly = [];
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
// set the cutline polygons to just the area of interest (minus degenerate edges)
|
|
232
|
-
this.clipPoly = poly;
|
|
233
|
-
this.srcPoly = (_a = intersection(srcPoly, this.clipPoly)) !== null && _a !== void 0 ? _a : [];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Pad the bounds to take in to consideration blending and 100 pixels of adjacent image data
|
|
238
|
-
*
|
|
239
|
-
* @param bounds
|
|
240
|
-
* @param resZoom the imagery resolution target zoom level
|
|
241
|
-
*/
|
|
242
|
-
padBounds(bounds, resZoom) {
|
|
243
|
-
const px = this.tileMatrix.pixelScale(resZoom);
|
|
244
|
-
// Ensure cutline blend does not interferre with non-costal edges
|
|
245
|
-
const widthScale = (bounds.width + px * (PixelPadding + this.blend) * 2) / bounds.width;
|
|
246
|
-
const heightScale = (bounds.height + px * (PixelPadding + this.blend) * 2) / bounds.height;
|
|
247
|
-
return bounds.scaleFromCenter(widthScale, heightScale);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
//# sourceMappingURL=cutline.js.map
|
package/build/cog/cutline.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cutline.js","sourceRoot":"","sources":["../../src/cog/cutline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAe,UAAU,EAAQ,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EAEZ,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,GACN,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGlE,gDAAgD;AAChD,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB,iEAAiE;AACjE,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,CAAC;AAEnC,SAAS,qBAAqB,CAAC,OAAmB;;IAChD,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,MAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,0CAAE,UAAU,0CAAE,IAAI,mCAAI,EAAE,CAAC,mCAAI,IAAI,CAAC,KAAK,CAAC;AACxE,CAAC;AAED,SAAS,WAAW,CAAC,GAAkB,EAAE,IAAU;IACjD,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,kBAAkB,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