@basemaps/cli-raster 8.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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/build/bin.d.ts +1 -0
  4. package/build/bin.js +16 -0
  5. package/build/bin.js.map +1 -0
  6. package/build/cogify/__test__/covering.test.d.ts +1 -0
  7. package/build/cogify/__test__/covering.test.js +64 -0
  8. package/build/cogify/__test__/covering.test.js.map +1 -0
  9. package/build/cogify/__test__/extract.test.d.ts +1 -0
  10. package/build/cogify/__test__/extract.test.js +34 -0
  11. package/build/cogify/__test__/extract.test.js.map +1 -0
  12. package/build/cogify/cli/__test__/cli.cover.test.d.ts +1 -0
  13. package/build/cogify/cli/__test__/cli.cover.test.js +48 -0
  14. package/build/cogify/cli/__test__/cli.cover.test.js.map +1 -0
  15. package/build/cogify/cli/__test__/cli.topo.test.d.ts +1 -0
  16. package/build/cogify/cli/__test__/cli.topo.test.js +53 -0
  17. package/build/cogify/cli/__test__/cli.topo.test.js.map +1 -0
  18. package/build/cogify/cli/cli.cog.d.ts +55 -0
  19. package/build/cogify/cli/cli.cog.js +353 -0
  20. package/build/cogify/cli/cli.cog.js.map +1 -0
  21. package/build/cogify/cli/cli.cover.d.ts +30 -0
  22. package/build/cogify/cli/cli.cover.js +157 -0
  23. package/build/cogify/cli/cli.cover.js.map +1 -0
  24. package/build/cogify/cli/cli.topo.d.ts +50 -0
  25. package/build/cogify/cli/cli.topo.js +169 -0
  26. package/build/cogify/cli/cli.topo.js.map +1 -0
  27. package/build/cogify/cli/cli.validate.d.ts +15 -0
  28. package/build/cogify/cli/cli.validate.js +30 -0
  29. package/build/cogify/cli/cli.validate.js.map +1 -0
  30. package/build/cogify/cli.d.ts +121 -0
  31. package/build/cogify/cli.js +15 -0
  32. package/build/cogify/cli.js.map +1 -0
  33. package/build/cogify/covering/covering.d.ts +28 -0
  34. package/build/cogify/covering/covering.js +126 -0
  35. package/build/cogify/covering/covering.js.map +1 -0
  36. package/build/cogify/covering/cutline.d.ts +29 -0
  37. package/build/cogify/covering/cutline.js +109 -0
  38. package/build/cogify/covering/cutline.js.map +1 -0
  39. package/build/cogify/covering/tile.cover.d.ts +38 -0
  40. package/build/cogify/covering/tile.cover.js +198 -0
  41. package/build/cogify/covering/tile.cover.js.map +1 -0
  42. package/build/cogify/gdal/gdal.command.d.ts +27 -0
  43. package/build/cogify/gdal/gdal.command.js +175 -0
  44. package/build/cogify/gdal/gdal.command.js.map +1 -0
  45. package/build/cogify/gdal/gdal.runner.d.ts +42 -0
  46. package/build/cogify/gdal/gdal.runner.js +194 -0
  47. package/build/cogify/gdal/gdal.runner.js.map +1 -0
  48. package/build/cogify/stac.d.ts +138 -0
  49. package/build/cogify/stac.js +25 -0
  50. package/build/cogify/stac.js.map +1 -0
  51. package/build/cogify/topo/extract.d.ts +82 -0
  52. package/build/cogify/topo/extract.js +195 -0
  53. package/build/cogify/topo/extract.js.map +1 -0
  54. package/build/cogify/topo/slug.d.ts +10 -0
  55. package/build/cogify/topo/slug.js +18 -0
  56. package/build/cogify/topo/slug.js.map +1 -0
  57. package/build/cogify/topo/stac.creation.d.ts +47 -0
  58. package/build/cogify/topo/stac.creation.js +171 -0
  59. package/build/cogify/topo/stac.creation.js.map +1 -0
  60. package/build/download.d.ts +57 -0
  61. package/build/download.js +144 -0
  62. package/build/download.js.map +1 -0
  63. package/build/hash.stream.d.ts +20 -0
  64. package/build/hash.stream.js +62 -0
  65. package/build/hash.stream.js.map +1 -0
  66. package/build/index.d.ts +1 -0
  67. package/build/index.js +2 -0
  68. package/build/index.js.map +1 -0
  69. package/build/preset.d.ts +15 -0
  70. package/build/preset.js +66 -0
  71. package/build/preset.js.map +1 -0
  72. package/dist/index.cjs +85880 -0
  73. package/package.json +61 -0
@@ -0,0 +1,194 @@
1
+ import { sha256base58 } from '@basemaps/config';
2
+ import { urlToString } from '@basemaps/shared';
3
+ import { spawn } from 'child_process';
4
+ import { EventEmitter } from 'events';
5
+ import { dirname } from 'path';
6
+ function getDockerContainer() {
7
+ const containerPath = process.env['GDAL_DOCKER_CONTAINER'] ?? 'ghcr.io/osgeo/gdal';
8
+ const tag = process.env['GDAL_DOCKER_CONTAINER_TAG'] ?? 'ubuntu-small-3.8.0';
9
+ return `${containerPath}:${tag}`;
10
+ }
11
+ /** Convert a GDAL command to run using docker */
12
+ function toDockerArgs(cmd) {
13
+ const dirName = dirname(urlToString(cmd.output));
14
+ const args = ['run'];
15
+ if (cmd.output)
16
+ args.push(...['-v', `${dirName}:${dirName}`]);
17
+ args.push(...[getDockerContainer(), cmd.command, ...cmd.args]);
18
+ return args;
19
+ }
20
+ export class GdalRunner {
21
+ constructor(cmd) {
22
+ Object.defineProperty(this, "parser", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: new GdalProgressParser()
27
+ });
28
+ Object.defineProperty(this, "startTime", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ Object.defineProperty(this, "cmd", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: void 0
39
+ });
40
+ this.cmd = cmd;
41
+ }
42
+ /**
43
+ * Run a GDAL command
44
+ *
45
+ * @param logger logger to use
46
+ */
47
+ async run(logger) {
48
+ const commandHash = sha256base58(JSON.stringify(this.cmd)); // Hash the arguments as the arguments can be way too big to log
49
+ logger?.debug({ command: this.cmd.command, gdalArgs: this.cmd.args, hash: commandHash }, 'Gdal:Command');
50
+ logger?.info({ command: this.cmd.command, commandHash }, 'Gdal:Start');
51
+ const cmd = this.cmd.command;
52
+ this.parser.reset();
53
+ let lastTime = performance.now();
54
+ this.parser.on('progress', (progress) => {
55
+ const duration = performance.now() - lastTime;
56
+ lastTime = performance.now();
57
+ logger?.debug({
58
+ cmd: this.cmd.command,
59
+ output: this.cmd.output,
60
+ commandHash,
61
+ duration: Number(duration.toFixed(3)),
62
+ progress: Number(progress.toFixed(3)),
63
+ }, 'Gdal:Progress');
64
+ });
65
+ this.startTime = performance.now();
66
+ const useDocker = !!process.env['GDAL_DOCKER'];
67
+ if (useDocker) {
68
+ logger?.info({ command: this.cmd.command, commandHash, container: getDockerContainer() }, 'Gdal:Docker');
69
+ }
70
+ const child = useDocker ? spawn('docker', toDockerArgs(this.cmd)) : spawn(this.cmd.command, this.cmd.args);
71
+ const outputBuff = [];
72
+ const errBuff = [];
73
+ child.stderr.on('data', (data) => {
74
+ const buf = data.toString();
75
+ /**
76
+ * Example error line
77
+ *
78
+ * `ERROR 1: TIFFReadEncodedTile:Read error at row 4294967295, col 4294967295; got 49005 bytes, expected 49152`
79
+ */
80
+ if (buf.includes('ERROR 1')) {
81
+ logger?.error({ cmd, data: buf.toString().trim() }, 'Gdal:Error');
82
+ }
83
+ else {
84
+ logger?.warn({ cmd, data: buf.toString().trim() }, 'Gdal:Warn');
85
+ }
86
+ errBuff.push(data);
87
+ });
88
+ child.stdout.on('data', (data) => {
89
+ outputBuff.push(data);
90
+ this.parser.data(data);
91
+ });
92
+ return new Promise((resolve, reject) => {
93
+ child.on('exit', (code) => {
94
+ const stdout = outputBuff.join('').trim();
95
+ const stderr = errBuff.join('').trim();
96
+ const duration = performance.now() - this.startTime;
97
+ if (code !== 0) {
98
+ logger?.error({ cmd, args: this.cmd.args, code, stdout, stderr, duration }, 'Gdal:Failed');
99
+ return reject(new Error('Failed to execute GDAL command: ' + cmd));
100
+ }
101
+ logger?.debug({ cmd, commandHash, duration }, 'Gdal:Done');
102
+ return resolve({ stdout, stderr, duration });
103
+ });
104
+ child.on('error', (error) => {
105
+ const stdout = outputBuff.join('').trim();
106
+ const stderr = errBuff.join('').trim();
107
+ const duration = Date.now() - this.startTime;
108
+ logger?.error({ stdout, stderr, duration }, 'Gdal:Failed');
109
+ reject(error);
110
+ });
111
+ });
112
+ }
113
+ }
114
+ /**
115
+ * Emit a "progress" event every time a "." is recorded in the output
116
+ */
117
+ export class GdalProgressParser extends EventEmitter {
118
+ constructor() {
119
+ super(...arguments);
120
+ // Progress starts with "Input file size is .., ..\n"
121
+ Object.defineProperty(this, "waitNewLine", {
122
+ enumerable: true,
123
+ configurable: true,
124
+ writable: true,
125
+ value: true
126
+ });
127
+ Object.defineProperty(this, "dotCount", {
128
+ enumerable: true,
129
+ configurable: true,
130
+ writable: true,
131
+ value: 0
132
+ });
133
+ Object.defineProperty(this, "byteCount", {
134
+ enumerable: true,
135
+ configurable: true,
136
+ writable: true,
137
+ value: 0
138
+ });
139
+ // Last time a progress event was emitted
140
+ Object.defineProperty(this, "lastEmit", {
141
+ enumerable: true,
142
+ configurable: true,
143
+ writable: true,
144
+ value: -1
145
+ });
146
+ // debounce emits to every 1 second
147
+ Object.defineProperty(this, "debounceMs", {
148
+ enumerable: true,
149
+ configurable: true,
150
+ writable: true,
151
+ value: 1000
152
+ });
153
+ }
154
+ /** Reset the progress counter */
155
+ reset() {
156
+ this.waitNewLine = true;
157
+ this.dotCount = 0;
158
+ this.byteCount = 0;
159
+ }
160
+ get progress() {
161
+ return this.dotCount * (100 / 31);
162
+ }
163
+ data(data) {
164
+ const str = data.toString('utf8');
165
+ this.byteCount += str.length;
166
+ // In theory only a small amount of output bytes should be recorded
167
+ if (this.byteCount > 4096)
168
+ throw new Error('Too much data: ' + str);
169
+ if (str === '0') {
170
+ this.waitNewLine = false;
171
+ return;
172
+ }
173
+ if (this.waitNewLine) {
174
+ const newLine = str.indexOf('\n');
175
+ if (newLine > -1) {
176
+ this.waitNewLine = false;
177
+ return this.data(Buffer.from(str.slice(newLine + 1)));
178
+ }
179
+ return;
180
+ }
181
+ for (const char of str) {
182
+ if (char !== '.')
183
+ continue;
184
+ this.dotCount++;
185
+ const currentTime = Date.now();
186
+ const timeDiff = currentTime - this.lastEmit;
187
+ if (timeDiff > this.debounceMs || this.progress === 100) {
188
+ this.lastEmit = currentTime;
189
+ this.emit('progress', this.progress);
190
+ }
191
+ }
192
+ }
193
+ }
194
+ //# sourceMappingURL=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G,KAAK,CAAC;YACzB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClC,IAAI,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC;gBACjB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;gBACzB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,CAAC;YACD,OAAO;QACT,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;YACvB,IAAI,IAAI,KAAK,GAAG;gBAAE,SAAS;YAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC7C,IAAI,QAAQ,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;gBACxD,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC;gBAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,138 @@
1
+ import { Rgba } from '@basemaps/config';
2
+ import { EpsgCode, Tile } from '@basemaps/geo';
3
+ import { StacCollection, StacItem, StacLink } from 'stac-ts';
4
+ export interface CogifyCreationOptions {
5
+ /** Preset GDAL config to use */
6
+ preset: string;
7
+ /** Tile to be created */
8
+ tile: Tile;
9
+ /** Tile matrix to create the tiles against */
10
+ tileMatrix: string;
11
+ /** Projection of source imagery */
12
+ sourceEpsg: number;
13
+ /**
14
+ * Compression to use for the cog
15
+ *
16
+ * @default 'webp'
17
+ */
18
+ compression?: 'webp' | 'jpeg' | 'lerc' | 'zstd' | 'lzw';
19
+ /**
20
+ * Output tile size
21
+ *
22
+ * @default 512
23
+ */
24
+ blockSize?: number;
25
+ /** Target base zoom level */
26
+ zoomLevel: number;
27
+ /**
28
+ * Compression quality
29
+ *
30
+ * @default 90
31
+ */
32
+ quality?: number;
33
+ /** Max Z Error only used when compression is `lerc` */
34
+ maxZError?: number;
35
+ /** Max Z Error only used when compression is `lerc` defaults to {maxZError} */
36
+ maxZErrorOverview?: number;
37
+ /**
38
+ * Resampling for warping
39
+ * @default 'bilinear'
40
+ */
41
+ warpResampling?: GdalResampling;
42
+ /**
43
+ * Resampling for overview
44
+ * @default 'lanczos'
45
+ */
46
+ overviewResampling?: GdalResampling;
47
+ /** Color with which to replace all transparent COG pixels */
48
+ background?: Rgba;
49
+ }
50
+ export interface GeneratedProperties {
51
+ /** Package name that generated the file */
52
+ package: string;
53
+ /** Version number that generated the file */
54
+ version: string;
55
+ /** Git commit hash that the file was generated with */
56
+ hash: string;
57
+ /** ISO date of the time this file was generated */
58
+ datetime: string;
59
+ /** version of GDAL used to create the COG */
60
+ gdal?: string;
61
+ /**
62
+ * is the tiff invalid
63
+ *
64
+ * If the tiff was generated but then determined to be invalid this property explains why the tiff was rejected.
65
+ *
66
+ * Reasons:
67
+ * - "empty" - No data was produced by GDAL when creating the tiff
68
+ */
69
+ invalid?: 'empty';
70
+ }
71
+ export type GdalResampling = 'nearest' | 'bilinear' | 'cubic' | 'cubicspline' | 'lanczos' | 'average' | 'mode';
72
+ export type CogifyStacCollection = StacCollection;
73
+ /**
74
+ * Is the the provided stac item a topographic map sheet creation request or a generic cog creation request
75
+ * @returns true if a linz:map_sheet is found false otherwise.
76
+ */
77
+ export declare function isTopoStacItem(x: CogifyStacItem | TopoStacItem): x is TopoStacItem;
78
+ export type CogifyStacItem = StacItem & {
79
+ properties: {
80
+ 'linz_basemaps:generated': GeneratedProperties;
81
+ 'linz_basemaps:options': CogifyCreationOptions;
82
+ };
83
+ };
84
+ export type TopoStacItem = StacItem & {
85
+ properties: {
86
+ /**
87
+ * A topo50 or topo250 raster map sheet's code.
88
+ *
89
+ * @example
90
+ * - topo50: "CJ10", "BQ31"
91
+ * - topo250: "00", "03", "05"
92
+ */
93
+ 'linz:map_sheet': string;
94
+ /**
95
+ * A map sheet's version.
96
+ *
97
+ * @example "v1.00"
98
+ *
99
+ * @see https://github.com/stac-extensions/version
100
+ */
101
+ version: string;
102
+ /**
103
+ * An EpsgCode Enum representing a map sheet's projection.
104
+ *
105
+ * @example EpsgCode.Nztm2000 = 2193
106
+ *
107
+ * @see https://github.com/stac-extensions/projection
108
+ */
109
+ 'proj:epsg': EpsgCode;
110
+ 'linz_basemaps:generated': GeneratedProperties;
111
+ 'linz_basemaps:options': {
112
+ /** Tile matrix to create the tiles against */
113
+ tileMatrix: string;
114
+ /** Projection of source imagery */
115
+ sourceEpsg: number;
116
+ };
117
+ };
118
+ };
119
+ /** The cutline that was used on the imagery */
120
+ export type CogifyLinkCutline = StacLink & {
121
+ rel: 'linz_basemaps:cutline';
122
+ blend: number;
123
+ };
124
+ /** Link back to the source imagery that was used to create the cog */
125
+ export type CogifyLinkSource = StacLink & {
126
+ rel: 'linz_basemaps:source';
127
+ 'linz_basemaps:source_width': number;
128
+ 'linz_basemaps:source_height': number;
129
+ };
130
+ /** Find all the linz_basemaps:source links */
131
+ export declare function getSources(links: StacLink[]): CogifyLinkSource[];
132
+ /** find the linz_basemaps:cutline link if it exists */
133
+ export declare function getCutline(links: StacLink[]): CogifyLinkCutline | null;
134
+ /** Generate the STAC file:size and file:checksum fields from a buffer */
135
+ export declare function createFileStats(data: string | Buffer): {
136
+ 'file:size': number;
137
+ 'file:checksum': string;
138
+ };
@@ -0,0 +1,25 @@
1
+ import { createHash } from 'node:crypto';
2
+ /**
3
+ * Is the the provided stac item a topographic map sheet creation request or a generic cog creation request
4
+ * @returns true if a linz:map_sheet is found false otherwise.
5
+ */
6
+ export function isTopoStacItem(x) {
7
+ return typeof x['properties']['linz:map_sheet'] === 'string';
8
+ }
9
+ /** Find all the linz_basemaps:source links */
10
+ export function getSources(links) {
11
+ return links.filter((f) => f.rel === 'linz_basemaps:source');
12
+ }
13
+ /** find the linz_basemaps:cutline link if it exists */
14
+ export function getCutline(links) {
15
+ return links.find((f) => f.rel === 'linz_basemaps:cutline');
16
+ }
17
+ /** Generate the STAC file:size and file:checksum fields from a buffer */
18
+ export function createFileStats(data) {
19
+ return {
20
+ 'file:size': Buffer.isBuffer(data) ? data.byteLength : data.length,
21
+ // Multihash header for sha256 is 0x12 0x20
22
+ 'file:checksum': '1220' + createHash('sha256').update(data).digest('hex'),
23
+ };
24
+ }
25
+ //# sourceMappingURL=stac.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stac.js","sourceRoot":"","sources":["../../src/cogify/stac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAgGzC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,CAAgC;IAC7D,OAAO,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,gBAAgB,CAAC,KAAK,QAAQ,CAAC;AAC/D,CAAC;AAyDD,8CAA8C;AAC9C,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,sBAAsB,CAAuB,CAAC;AACrF,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,uBAAuB,CAAsB,CAAC;AACnF,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,eAAe,CAAC,IAAqB;IACnD,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;QAClE,2CAA2C;QAC3C,eAAe,EAAE,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;KAC1E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { Bounds, Epsg, Size, TileMatrixSet } from '@basemaps/geo';
2
+ import { LogType } from '@basemaps/shared';
3
+ import { Tiff } from '@cogeotiff/core';
4
+ export declare const brokenTiffs: {
5
+ noBounds: string[];
6
+ noEpsg: string[];
7
+ noSize: string[];
8
+ noTileMatrix: string[];
9
+ };
10
+ /**
11
+ * Attempts to extract a bounds set from the given Tiff object.
12
+ *
13
+ * @param tiff: the Tiff object from which to extract a bounds set.
14
+ *
15
+ * @returns a Bounds object, on success. Otherwise, null.
16
+ */
17
+ export declare function extractBoundsFromTiff(tiff: Tiff, logger?: LogType): Bounds | null;
18
+ /**
19
+ * Attempts to extract an epsg value from the given Tiff object.
20
+ *
21
+ * @param tiff: The Tiff object from which to extract an epsg value.
22
+ *
23
+ * @returns an Epsg instance, on success. Otherwise, null.
24
+ */
25
+ export declare function extractEpsgFromTiff(tiff: Tiff, logger?: LogType): Epsg | null;
26
+ /**
27
+ * Attempts to extract a map code and version from the filename of the provided filepath.
28
+ * Throws an error if either detail cannot be parsed.
29
+ *
30
+ * @param file: the filepath from which to extract a map code and version.
31
+ *
32
+ * @example
33
+ * file: "s3://linz-topographic-upload/topographic/TopoReleaseArchive/NZTopo50_GeoTif_Gridless/CJ10_GRIDLESS_GeoTifv1-00.tif"
34
+ * returns: { mapCode: "CJ10", version: "v1-00" }
35
+ *
36
+ * @returns an object containing the map code and version.
37
+ */
38
+ export declare function extractMapCodeAndVersion(url: URL, logger?: LogType): {
39
+ mapCode: string;
40
+ version: string;
41
+ };
42
+ /**
43
+ * Attempts to extract a size from the given Tiff object.
44
+ *
45
+ * @param tiff: the Tiff object from which to extract the size.
46
+ *
47
+ * @returns a Size object, on success. Otherwise, null.
48
+ */
49
+ export declare function extractSizeFromTiff(tiff: Tiff, logger?: LogType): Size | null;
50
+ export interface TiffItem {
51
+ tiff: Tiff;
52
+ source: URL;
53
+ mapCode: string;
54
+ version: string;
55
+ bounds: Bounds;
56
+ epsg: Epsg;
57
+ size: Size;
58
+ tileMatrix: TileMatrixSet;
59
+ latest?: string;
60
+ }
61
+ /**
62
+ * Converts Tiffs to TiffItems, returning a Map of Epsgs to TiffItem arrays.
63
+ *
64
+ * For each Tiff, this function extracts its core data, converts it into a TiffItem, and
65
+ * stores it in a Map by its Epsg. A Tiff is skipped if it's missing any piece of core data.
66
+ *
67
+ * @param tiffs: the list of Tiffs to convert into TiffItems and group by Epsg.
68
+ *
69
+ * @returns a Map of TiffItem arrays by Epsg.
70
+ */
71
+ export declare function extractTiffItemsByEpsg(tiffs: Tiff[], logger: LogType): Map<Epsg, TiffItem[]>;
72
+ /**
73
+ * Identifies the latest TiffItems by map code and version, returning a Map of map codes to TiffItems.
74
+ *
75
+ * For each TiffItem, this function determines whether it's the latest version of those with the same map code.
76
+ * If so, this function stores it in a Map by its map code.
77
+ *
78
+ * @param tiffItems: the list of TiffItems to filter and group by map code.
79
+ *
80
+ * @returns a Map of TiffItems by map code.
81
+ */
82
+ export declare function extractLatestTiffItemsByMapCode(tiffItems: TiffItem[]): Map<string, TiffItem>;
@@ -0,0 +1,195 @@
1
+ import { Bounds, Epsg, TileMatrixSets } from '@basemaps/geo';
2
+ import { RasterTypeKey, TiffTagGeo } from '@cogeotiff/core';
3
+ import path from 'path';
4
+ export const brokenTiffs = {
5
+ noBounds: [],
6
+ noEpsg: [],
7
+ noSize: [],
8
+ noTileMatrix: [],
9
+ };
10
+ /**
11
+ * Attempts to extract a bounds set from the given Tiff object.
12
+ *
13
+ * @param tiff: the Tiff object from which to extract a bounds set.
14
+ *
15
+ * @returns a Bounds object, on success. Otherwise, null.
16
+ */
17
+ export function extractBoundsFromTiff(tiff, logger) {
18
+ const img = tiff.images[0];
19
+ if (img == null) {
20
+ logger?.error({ source: tiff.source.url.href }, 'extractBoundsFromTiff(): No images found in Tiff file');
21
+ return null;
22
+ }
23
+ if (img.valueGeo(TiffTagGeo.GTRasterTypeGeoKey) === RasterTypeKey.PixelIsPoint) {
24
+ logger?.error({ source: tiff.source.url.href }, 'extractBoundsFromTiff(): Pixel is Point raster grid spacing is not supported');
25
+ return null;
26
+ }
27
+ try {
28
+ return Bounds.fromBbox(img.bbox);
29
+ }
30
+ catch {
31
+ logger?.info({ found: false }, 'extractBoundsFromTiff()');
32
+ return null;
33
+ }
34
+ }
35
+ const projections = {
36
+ 'Universal Transverse Mercator Zone': Epsg.Wgs84,
37
+ 'Chatham Islands Transverse Mercator 2000': Epsg.Citm2000,
38
+ 'New Zealand Transverse Mercator 2000': Epsg.Nztm2000,
39
+ };
40
+ /**
41
+ * Attempts to extract an epsg value from the given Tiff object.
42
+ *
43
+ * @param tiff: The Tiff object from which to extract an epsg value.
44
+ *
45
+ * @returns an Epsg instance, on success. Otherwise, null.
46
+ */
47
+ export function extractEpsgFromTiff(tiff, logger) {
48
+ const img = tiff.images[0];
49
+ if (img == null) {
50
+ logger?.error({ source: tiff.source.url.href }, 'extractEpsgFromTiff(): No images found in Tiff file');
51
+ return null;
52
+ }
53
+ // try to extract the epsg directly from the tiff
54
+ const epsg = img.epsg;
55
+ if (epsg != null) {
56
+ const code = Epsg.tryGet(epsg);
57
+ if (code != null) {
58
+ logger?.info({ found: true, method: 'direct', source: tiff.source.url.href }, 'extractEpsgFromTiff()');
59
+ return code;
60
+ }
61
+ }
62
+ // try to extract the epsg from the tiff's projected citation geotag
63
+ const tag = img.valueGeo(TiffTagGeo.ProjectedCitationGeoKey);
64
+ if (typeof tag === 'string') {
65
+ for (const [citation, epsg] of Object.entries(projections)) {
66
+ if (tag.startsWith(citation)) {
67
+ logger?.info({ found: true, method: 'geotag', source: tiff.source.url.href }, 'extractEpsgFromTiff()');
68
+ return epsg;
69
+ }
70
+ }
71
+ }
72
+ logger?.info({ found: false }, 'extractEpsgFromTiff()');
73
+ return null;
74
+ }
75
+ /**
76
+ * Attempts to extract a map code and version from the filename of the provided filepath.
77
+ * Throws an error if either detail cannot be parsed.
78
+ *
79
+ * @param file: the filepath from which to extract a map code and version.
80
+ *
81
+ * @example
82
+ * file: "s3://linz-topographic-upload/topographic/TopoReleaseArchive/NZTopo50_GeoTif_Gridless/CJ10_GRIDLESS_GeoTifv1-00.tif"
83
+ * returns: { mapCode: "CJ10", version: "v1-00" }
84
+ *
85
+ * @returns an object containing the map code and version.
86
+ */
87
+ export function extractMapCodeAndVersion(url, logger) {
88
+ const filePath = path.parse(url.href);
89
+ const fileName = filePath.name;
90
+ // extract map code from head of the file name (e.g. CJ10)
91
+ const mapCode = fileName.split('_')[0];
92
+ if (mapCode == null)
93
+ throw new Error(`Map sheet not found in the file name: "${url.href}"`);
94
+ // extract version from tail of the file name (e.g. v1-00)
95
+ const version = fileName.match(/v(\d)-(\d\d)/)?.[0];
96
+ if (version == null)
97
+ throw new Error(`Version not found in the file name: "${url.href}"`);
98
+ logger?.info({ mapCode, version }, 'extractMapCodeAndVersion()');
99
+ return { mapCode, version };
100
+ }
101
+ /**
102
+ * Attempts to extract a size from the given Tiff object.
103
+ *
104
+ * @param tiff: the Tiff object from which to extract the size.
105
+ *
106
+ * @returns a Size object, on success. Otherwise, null.
107
+ */
108
+ export function extractSizeFromTiff(tiff, logger) {
109
+ try {
110
+ const size = tiff.images[0]?.size ?? null;
111
+ logger?.info({ source: tiff.source.url.href, found: true, size }, 'extractSizeFromTiff()');
112
+ return size;
113
+ }
114
+ catch (e) {
115
+ logger?.error({ source: tiff.source.url.href, found: false }, 'extractSizeFromTiff()');
116
+ return null;
117
+ }
118
+ }
119
+ /**
120
+ * Converts Tiffs to TiffItems, returning a Map of Epsgs to TiffItem arrays.
121
+ *
122
+ * For each Tiff, this function extracts its core data, converts it into a TiffItem, and
123
+ * stores it in a Map by its Epsg. A Tiff is skipped if it's missing any piece of core data.
124
+ *
125
+ * @param tiffs: the list of Tiffs to convert into TiffItems and group by Epsg.
126
+ *
127
+ * @returns a Map of TiffItem arrays by Epsg.
128
+ */
129
+ export function extractTiffItemsByEpsg(tiffs, logger) {
130
+ const tiffItemsByEpsg = new Map();
131
+ // create TiffItem objects for each tiff and store them by epsg
132
+ for (const tiff of tiffs) {
133
+ const source = tiff.source.url;
134
+ const { mapCode, version } = extractMapCodeAndVersion(source, logger);
135
+ const bounds = extractBoundsFromTiff(tiff, logger);
136
+ const epsg = extractEpsgFromTiff(tiff, logger);
137
+ const size = extractSizeFromTiff(tiff, logger);
138
+ const tileMatrix = TileMatrixSets.tryGet(epsg);
139
+ if (bounds == null) {
140
+ brokenTiffs.noBounds.push(`${mapCode}_${version}`);
141
+ logger.warn({ mapCode, version }, 'Could not extract bounds from tiff');
142
+ continue;
143
+ }
144
+ if (epsg == null) {
145
+ brokenTiffs.noEpsg.push(`${mapCode}_${version}`);
146
+ logger.warn({ mapCode, version }, 'Could not extract epsg from tiff');
147
+ continue;
148
+ }
149
+ if (size == null) {
150
+ brokenTiffs.noSize.push(`${mapCode}_${version}`);
151
+ logger.warn({ mapCode, version }, 'Could not extract width or height from tiff');
152
+ continue;
153
+ }
154
+ if (tileMatrix == null) {
155
+ brokenTiffs.noTileMatrix.push(`${mapCode}_${version}`);
156
+ if (epsg != null) {
157
+ logger.warn({ mapCode, version }, `Could not convert epsg code '${epsg.code}' to a tile matrix`);
158
+ }
159
+ continue;
160
+ }
161
+ const item = { tiff, source, mapCode, version, bounds, epsg, size, tileMatrix };
162
+ // store the created TiffItem Object by epsg
163
+ const items = tiffItemsByEpsg.get(epsg);
164
+ if (items == null) {
165
+ tiffItemsByEpsg.set(epsg, [item]);
166
+ }
167
+ else {
168
+ items.push(item);
169
+ }
170
+ }
171
+ return tiffItemsByEpsg;
172
+ }
173
+ /**
174
+ * Identifies the latest TiffItems by map code and version, returning a Map of map codes to TiffItems.
175
+ *
176
+ * For each TiffItem, this function determines whether it's the latest version of those with the same map code.
177
+ * If so, this function stores it in a Map by its map code.
178
+ *
179
+ * @param tiffItems: the list of TiffItems to filter and group by map code.
180
+ *
181
+ * @returns a Map of TiffItems by map code.
182
+ */
183
+ export function extractLatestTiffItemsByMapCode(tiffItems) {
184
+ const latest = new Map();
185
+ // identify the latest item by 'version' and copy it to 'latest'
186
+ for (const item of tiffItems) {
187
+ const mapCode = item.mapCode;
188
+ const latestItem = latest.get(mapCode);
189
+ if (latestItem == null || latestItem.version.localeCompare(item.version) < 0) {
190
+ latest.set(mapCode, item);
191
+ }
192
+ }
193
+ return latest;
194
+ }
195
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../src/cogify/topo/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAuB,cAAc,EAAE,MAAM,eAAe,CAAC;AAElF,OAAO,EAAE,aAAa,EAAQ,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,EAAc;IACxB,MAAM,EAAE,EAAc;IACtB,MAAM,EAAE,EAAc;IACtB,YAAY,EAAE,EAAc;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAU,EAAE,MAAgB;IAChE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,uDAAuD,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,GAAG,CAAC,QAAQ,CAAC,U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
5
+ *
6
+ * @param epsg: The EpsgCode enum to map to a slug
7
+ *
8
+ * @returns if succeeded, a slug string. Otherwise, null.
9
+ */
10
+ export declare function mapEpsgToSlug(epsg: EpsgCode, logger?: LogType): string | null;