@basemaps/bathymetry 6.6.0 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/build/__test__/hash.test.js +9 -10
- package/build/__test__/stac.test.js +45 -48
- package/build/bathy.maker.d.ts +1 -1
- package/build/bathy.maker.d.ts.map +1 -1
- package/build/bathy.maker.js +36 -41
- package/build/file.d.ts.map +1 -1
- package/build/file.js +3 -8
- package/build/hash.js +5 -9
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +26 -31
- package/build/mapnik.d.ts +1 -1
- package/build/mapnik.d.ts.map +1 -1
- package/build/mapnik.js +5 -10
- package/build/stac.d.ts +2 -2
- package/build/stac.d.ts.map +1 -1
- package/build/stac.js +26 -29
- package/package.json +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,55 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [6.10.0](https://github.com/linz/basemaps/compare/v6.9.1...v6.10.0) (2021-09-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* correctly bundle with esm modules ([#1858](https://github.com/linz/basemaps/issues/1858)) ([708a22e](https://github.com/linz/basemaps/commit/708a22ec1006c25cf2c057b75f61cc813e943aac))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* replace s3fs with chunkd/fs ([#1859](https://github.com/linz/basemaps/issues/1859)) ([9b6f2d3](https://github.com/linz/basemaps/commit/9b6f2d3609c336f96c2ae32246f241cb396e71c8))
|
|
17
|
+
* switch to esm modules ([#1857](https://github.com/linz/basemaps/issues/1857)) ([75bdff8](https://github.com/linz/basemaps/commit/75bdff8da35104f10f6b6ecf58a2c6006245af6e))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [6.9.1](https://github.com/linz/basemaps/compare/v6.9.0...v6.9.1) (2021-09-09)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package @basemaps/bathymetry
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# [6.9.0](https://github.com/linz/basemaps/compare/v6.8.0...v6.9.0) (2021-09-09)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package @basemaps/bathymetry
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# [6.8.0](https://github.com/linz/basemaps/compare/v6.7.0...v6.8.0) (2021-09-01)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @basemaps/bathymetry
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# [6.7.0](https://github.com/linz/basemaps/compare/v6.6.1...v6.7.0) (2021-08-15)
|
|
48
|
+
|
|
49
|
+
**Note:** Version bump only for package @basemaps/bathymetry
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
6
55
|
# [6.6.0](https://github.com/linz/basemaps/compare/v6.5.0...v6.6.0) (2021-07-29)
|
|
7
56
|
|
|
8
57
|
**Note:** Version bump only for package @basemaps/bathymetry
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ospec_1.default(ans).equals('122076427149ca45100f317f16821ef934885cc49352447ee64c9f5e9655c95c695e');
|
|
1
|
+
import o from 'ospec';
|
|
2
|
+
import path, { resolve } from 'path';
|
|
3
|
+
import url from 'url';
|
|
4
|
+
import { Hash } from '../hash.js';
|
|
5
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
6
|
+
o.spec('hash', () => {
|
|
7
|
+
o('hash', async () => {
|
|
8
|
+
const ans = await Hash.hash(resolve(__dirname.replace('/build/', '/src/'), 'test-file.txt'));
|
|
9
|
+
o(ans).equals('122076427149ca45100f317f16821ef934885cc49352447ee64c9f5e9655c95c695e');
|
|
11
10
|
});
|
|
12
11
|
});
|
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ospec_1.default.beforeEach(mockFs.setup);
|
|
17
|
-
ospec_1.default.afterEach(() => {
|
|
18
|
-
hash_1.Hash.hash = origHash;
|
|
1
|
+
import { GoogleTms } from '@basemaps/geo';
|
|
2
|
+
import { LogConfig } from '@basemaps/shared';
|
|
3
|
+
import { mockFileOperator } from '@basemaps/shared/build/file/__test__/file.operator.test.helper.js';
|
|
4
|
+
import { round } from '@basemaps/test/build/rounding.js';
|
|
5
|
+
import o from 'ospec';
|
|
6
|
+
import { dirname } from 'path';
|
|
7
|
+
import { FilePath } from '../file.js';
|
|
8
|
+
import { Hash } from '../hash.js';
|
|
9
|
+
import { Stac } from '../stac.js';
|
|
10
|
+
o.spec('stac', () => {
|
|
11
|
+
const origHash = Hash.hash;
|
|
12
|
+
const mockFs = mockFileOperator();
|
|
13
|
+
o.beforeEach(mockFs.setup);
|
|
14
|
+
o.afterEach(() => {
|
|
15
|
+
Hash.hash = origHash;
|
|
19
16
|
mockFs.teardown();
|
|
20
17
|
});
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
o('createItem', async () => {
|
|
19
|
+
Hash.hash = (v) => 'hash' + v;
|
|
23
20
|
const bm = {
|
|
24
21
|
id: 'id123',
|
|
25
|
-
tileMatrix:
|
|
22
|
+
tileMatrix: GoogleTms,
|
|
26
23
|
inputPath: 's3://test-source-bucket/gebco-2020',
|
|
27
24
|
outputPath: 's3://test-bucket/bathy-2020',
|
|
28
|
-
tmpFolder: new
|
|
25
|
+
tmpFolder: new FilePath('/tmp/path'),
|
|
29
26
|
};
|
|
30
27
|
bm.config = bm;
|
|
31
28
|
const now = Date.now();
|
|
32
|
-
const stac =
|
|
29
|
+
const stac = round((await Stac.createItem(bm, { x: 22, y: 33, z: 13 })));
|
|
33
30
|
const date = Date.parse(stac.properties.datetime);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
stac_version:
|
|
37
|
-
stac_extensions: ['projection',
|
|
31
|
+
o(date >= now && date < now + 2000).equals(true);
|
|
32
|
+
o(round(stac, 4)).deepEquals({
|
|
33
|
+
stac_version: Stac.Version,
|
|
34
|
+
stac_extensions: ['projection', Stac.BaseMapsExtension],
|
|
38
35
|
id: 'id123/13-22-33',
|
|
39
36
|
collection: 'id123',
|
|
40
37
|
type: 'Feature',
|
|
@@ -69,29 +66,29 @@ ospec_1.default.spec('stac', () => {
|
|
|
69
66
|
links: [{ rel: 'collection', href: 'collection.json' }],
|
|
70
67
|
});
|
|
71
68
|
});
|
|
72
|
-
|
|
73
|
-
const logger =
|
|
74
|
-
|
|
69
|
+
o.spec('createCollection', () => {
|
|
70
|
+
const logger = LogConfig.get();
|
|
71
|
+
LogConfig.disable();
|
|
75
72
|
const bm = {
|
|
76
73
|
id: 'id123',
|
|
77
|
-
tileMatrix:
|
|
74
|
+
tileMatrix: GoogleTms,
|
|
78
75
|
inputPath: 's3://test-source-bucket/gebco-2020/gebco_2020.nc',
|
|
79
76
|
outputPath: 's3://test-bucket/bathy-2020',
|
|
80
|
-
tmpFolder: new
|
|
77
|
+
tmpFolder: new FilePath('/tmp/path'),
|
|
81
78
|
createSourceHash(l) {
|
|
82
79
|
return 'multihashResult' + (l === logger);
|
|
83
80
|
},
|
|
84
81
|
get inputFolder() {
|
|
85
|
-
return
|
|
82
|
+
return dirname(this.inputPath);
|
|
86
83
|
},
|
|
87
84
|
};
|
|
88
85
|
bm.config = bm;
|
|
89
|
-
|
|
90
|
-
const bounds =
|
|
86
|
+
o('createCollection without source collection.json', async () => {
|
|
87
|
+
const bounds = GoogleTms.tileToSourceBounds({ x: 1, y: 2, z: 4 });
|
|
91
88
|
const items = ['1-1-2.json'];
|
|
92
|
-
const stac = await
|
|
93
|
-
|
|
94
|
-
stac_version:
|
|
89
|
+
const stac = await Stac.createCollection(bm, bounds, items, logger);
|
|
90
|
+
o(round(stac, 4)).deepEquals({
|
|
91
|
+
stac_version: Stac.Version,
|
|
95
92
|
stac_extensions: ['projection'],
|
|
96
93
|
id: 'id123',
|
|
97
94
|
title: 'Gebco 2020.nc',
|
|
@@ -102,7 +99,7 @@ ospec_1.default.spec('stac', () => {
|
|
|
102
99
|
interval: [['2020-01-01T00:00:00Z', '2021-01-01T00:00:00Z']],
|
|
103
100
|
},
|
|
104
101
|
},
|
|
105
|
-
license:
|
|
102
|
+
license: Stac.License,
|
|
106
103
|
links: stac.links,
|
|
107
104
|
providers: [
|
|
108
105
|
{
|
|
@@ -115,7 +112,7 @@ ospec_1.default.spec('stac', () => {
|
|
|
115
112
|
summaries: { 'proj:epsg': [3857] },
|
|
116
113
|
});
|
|
117
114
|
});
|
|
118
|
-
|
|
115
|
+
o('createCollection with source collection.json', async () => {
|
|
119
116
|
mockFs.jsStore['s3://test-source-bucket/gebco-2020/collection.json'] = {
|
|
120
117
|
title: 'fancy title',
|
|
121
118
|
description: 'collection description',
|
|
@@ -125,15 +122,15 @@ ospec_1.default.spec('stac', () => {
|
|
|
125
122
|
temporal: { interval: [['2020-01-01T00:00:00Z', '2020-10-12T01:02:03Z']] },
|
|
126
123
|
},
|
|
127
124
|
};
|
|
128
|
-
const bounds =
|
|
125
|
+
const bounds = GoogleTms.tileToSourceBounds({ x: 22, y: 33, z: 13 });
|
|
129
126
|
const items = ['13-22-33.json', '13-22-34.json'];
|
|
130
|
-
const stac = await
|
|
127
|
+
const stac = await Stac.createCollection(bm, bounds, items, logger);
|
|
131
128
|
const gitHubLink = stac.links[2];
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
stac_version:
|
|
129
|
+
o(gitHubLink.href.startsWith('https://github.com/linz/basemaps.git')).equals(true);
|
|
130
|
+
o(gitHubLink.rel).equals('derived_from');
|
|
131
|
+
o(/^\d+\.\d+\.\d+$/.test(gitHubLink.version)).equals(true);
|
|
132
|
+
o(round(stac, 4)).deepEquals({
|
|
133
|
+
stac_version: Stac.Version,
|
|
137
134
|
stac_extensions: ['projection'],
|
|
138
135
|
id: 'id123',
|
|
139
136
|
title: 'fancy title',
|
|
@@ -142,7 +139,7 @@ ospec_1.default.spec('stac', () => {
|
|
|
142
139
|
spatial: { bbox: [[-179.0332, 84.9205, -178.9893, 84.9244]] },
|
|
143
140
|
temporal: { interval: [['2020-01-01T00:00:00Z', '2020-10-12T01:02:03Z']] },
|
|
144
141
|
},
|
|
145
|
-
license:
|
|
142
|
+
license: Stac.License,
|
|
146
143
|
links: [
|
|
147
144
|
{
|
|
148
145
|
rel: 'self',
|
package/build/bathy.maker.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Bounds, Tile, TileMatrixSet } from '@basemaps/geo';
|
|
2
2
|
import { LogType } from '@basemaps/shared';
|
|
3
3
|
import type { Limit } from 'p-limit';
|
|
4
|
-
import { FilePath } from './file';
|
|
4
|
+
import { FilePath } from './file.js';
|
|
5
5
|
interface BathyMakerContext {
|
|
6
6
|
/** unique id for this build */
|
|
7
7
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bathy.maker.d.ts","sourceRoot":"","sources":["../src/bathy.maker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAQ,IAAI,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAO,OAAO,EAAa,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIrC,OAAO,EAAE,QAAQ,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"bathy.maker.d.ts","sourceRoot":"","sources":["../src/bathy.maker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAQ,IAAI,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAO,OAAO,EAAa,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIrC,OAAO,EAAE,QAAQ,EAAY,MAAM,WAAW,CAAC;AAK/C,UAAU,iBAAiB;IACzB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC;IACpB,mDAAmD;IACnD,UAAU,EAAE,aAAa,CAAC;IAC1B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAUD,eAAO,MAAM,wBAAwB;;IAEnC,0EAA0E;;CAE3E,CAAC;AAEF,qBAAa,UAAU;IACrB,MAAM,EAAE,iBAAiB,GAAG,OAAO,wBAAwB,CAAC;IAE5D,6CAA6C;IAC7C,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,0EAA0E;IAC1E,CAAC,EAAE,KAAK,CAAC;gBAEG,GAAG,EAAE,iBAAiB;IAKlC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,SAAS,IAAI,QAAQ,CAExB;IAED,WAAW,IAAI,OAAO;IAItB,uCAAuC;IACvC,IAAI,QAAQ,IAAI,MAAM,CAGrB;IAED,4BAA4B;IAC5B,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA4C5C,8CAA8C;IACxC,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAUxD,6BAA6B;IACvB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAY9D,yEAAyE;IACnE,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBzD,4CAA4C;IACtC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B5D,oCAAoC;IAC9B,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAatE,wEAAwE;IAClE,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCrE,8DAA8D;IACxD,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ/C,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAK1F"}
|
package/build/bathy.maker.js
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
const hash_1 = require("./hash");
|
|
13
|
-
const mapnik_1 = require("./mapnik");
|
|
14
|
-
const stac_1 = require("./stac");
|
|
1
|
+
import { Gdal } from '@basemaps/cli';
|
|
2
|
+
import { Epsg, TileMatrixSet } from '@basemaps/geo';
|
|
3
|
+
import { fsa, s3ToVsis3 } from '@basemaps/shared';
|
|
4
|
+
import * as os from 'os';
|
|
5
|
+
import PLimit from 'p-limit';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { basename } from 'path';
|
|
8
|
+
import { Hash } from './hash.js';
|
|
9
|
+
import { MapnikRender } from './mapnik.js';
|
|
10
|
+
import { Stac } from './stac.js';
|
|
15
11
|
function createMountedGdal(...paths) {
|
|
16
|
-
const gdal =
|
|
12
|
+
const gdal = Gdal.create();
|
|
17
13
|
if (gdal.mount != null) {
|
|
18
14
|
for (const path of paths)
|
|
19
15
|
gdal.mount(path);
|
|
20
16
|
}
|
|
21
17
|
return gdal;
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
export const BathyMakerContextDefault = {
|
|
24
20
|
threads: os.cpus().length,
|
|
25
21
|
/** Making this much larger than this takes quite a long time to render */
|
|
26
22
|
tileSize: 8192,
|
|
27
23
|
};
|
|
28
|
-
class BathyMaker {
|
|
24
|
+
export class BathyMaker {
|
|
29
25
|
constructor(ctx) {
|
|
30
|
-
this.config = { ...
|
|
31
|
-
this.q =
|
|
26
|
+
this.config = { ...BathyMakerContextDefault, ...ctx };
|
|
27
|
+
this.q = PLimit(this.config.threads);
|
|
32
28
|
}
|
|
33
29
|
get inputPath() {
|
|
34
30
|
return this.config.inputPath;
|
|
@@ -56,7 +52,7 @@ class BathyMaker {
|
|
|
56
52
|
return path.basename(this.inputPath);
|
|
57
53
|
}
|
|
58
54
|
async render(logger) {
|
|
59
|
-
this.gdalVersion =
|
|
55
|
+
this.gdalVersion = Gdal.version(logger);
|
|
60
56
|
const isNc = this.inputPath.endsWith('.nc');
|
|
61
57
|
// NetCdf files need to be converted to GeoTiff before processing
|
|
62
58
|
if (isNc)
|
|
@@ -75,7 +71,7 @@ class BathyMaker {
|
|
|
75
71
|
const tile = { x, y, z: zoom };
|
|
76
72
|
const bounds = tms.tileToSourceBounds(tile);
|
|
77
73
|
extent = extent == null ? bounds : extent.union(bounds);
|
|
78
|
-
const tileId =
|
|
74
|
+
const tileId = TileMatrixSet.tileToName(tile);
|
|
79
75
|
return this.renderTile(tile, logger.child({ index: tileId }));
|
|
80
76
|
});
|
|
81
77
|
promises.push(promise);
|
|
@@ -95,11 +91,11 @@ class BathyMaker {
|
|
|
95
91
|
/** Create a multi hash of the source file */
|
|
96
92
|
async createSourceHash(logger) {
|
|
97
93
|
const hashPath = this.tmpFolder.name("hash" /* Hash */);
|
|
98
|
-
if (await
|
|
99
|
-
return (await
|
|
94
|
+
if (await fsa.exists(hashPath))
|
|
95
|
+
return (await fsa.read(hashPath)).toString();
|
|
100
96
|
logger.info({ hashPath }, 'CreateHash');
|
|
101
|
-
const outputHash = await
|
|
102
|
-
await
|
|
97
|
+
const outputHash = await Hash.hash(this.inputPath);
|
|
98
|
+
await fsa.write(hashPath, Buffer.from(outputHash));
|
|
103
99
|
return outputHash;
|
|
104
100
|
}
|
|
105
101
|
/** Render a specific tile */
|
|
@@ -128,15 +124,15 @@ class BathyMaker {
|
|
|
128
124
|
// see https://github.com/linz/basemaps-team/issues/241
|
|
129
125
|
'-ot',
|
|
130
126
|
'Float32',
|
|
131
|
-
|
|
127
|
+
s3ToVsis3(this.inputPath),
|
|
132
128
|
this.tiffPath,
|
|
133
129
|
], logger);
|
|
134
130
|
}
|
|
135
131
|
/** Create a tile in the output TMS's CRS */
|
|
136
132
|
async createTile(tile, logger) {
|
|
137
|
-
const tileId =
|
|
133
|
+
const tileId = TileMatrixSet.tileToName(tile);
|
|
138
134
|
const warpedPath = this.tmpFolder.name("warped" /* Warped */, tileId);
|
|
139
|
-
if (await
|
|
135
|
+
if (await fsa.exists(warpedPath))
|
|
140
136
|
return;
|
|
141
137
|
const tms = this.config.tileMatrix;
|
|
142
138
|
const bounds = tms.tileToSourceBounds(tile);
|
|
@@ -146,7 +142,7 @@ class BathyMaker {
|
|
|
146
142
|
'-co',
|
|
147
143
|
'NUM_THREADS=ALL_CPUS',
|
|
148
144
|
'-s_srs',
|
|
149
|
-
|
|
145
|
+
Epsg.Wgs84.toEpsgString(),
|
|
150
146
|
'-t_srs',
|
|
151
147
|
tms.projection.toEpsgString(),
|
|
152
148
|
'-r',
|
|
@@ -162,10 +158,10 @@ class BathyMaker {
|
|
|
162
158
|
}
|
|
163
159
|
/** Create a hillshade for a tile */
|
|
164
160
|
async createHillShadedTile(tile, logger) {
|
|
165
|
-
const tileId =
|
|
161
|
+
const tileId = TileMatrixSet.tileToName(tile);
|
|
166
162
|
const warped = this.tmpFolder.name("warped" /* Warped */, tileId);
|
|
167
163
|
const target = this.tmpFolder.name("hillshade" /* HillShade */, tileId);
|
|
168
|
-
if (await
|
|
164
|
+
if (await fsa.exists(target))
|
|
169
165
|
return;
|
|
170
166
|
logger.trace({ file: target }, 'Shading');
|
|
171
167
|
const gdal = createMountedGdal(this.inputPath, this.tmpFolder.sourcePath);
|
|
@@ -173,10 +169,10 @@ class BathyMaker {
|
|
|
173
169
|
}
|
|
174
170
|
/** Use mapnik to composite the hillshaded tile and the rendered tile */
|
|
175
171
|
async createCompositeTile(tile, logger) {
|
|
176
|
-
const tileId =
|
|
177
|
-
const renderedPath = await
|
|
172
|
+
const tileId = TileMatrixSet.tileToName(tile);
|
|
173
|
+
const renderedPath = await MapnikRender.render(this, tile, logger);
|
|
178
174
|
const outputPath = this.tmpFolder.name("output" /* Output */, tileId);
|
|
179
|
-
if (await
|
|
175
|
+
if (await fsa.exists(outputPath))
|
|
180
176
|
return;
|
|
181
177
|
const gdal = createMountedGdal(this.tmpFolder.sourcePath);
|
|
182
178
|
const tileMatrix = this.config.tileMatrix;
|
|
@@ -202,17 +198,16 @@ class BathyMaker {
|
|
|
202
198
|
}
|
|
203
199
|
/** Create and write a stac metadata item for a single tile */
|
|
204
200
|
async createTileMetadata(tile) {
|
|
205
|
-
const output = await
|
|
206
|
-
const tileId =
|
|
201
|
+
const output = await Stac.createItem(this, tile);
|
|
202
|
+
const tileId = TileMatrixSet.tileToName(tile);
|
|
207
203
|
const stacOutputPath = this.tmpFolder.name("stac" /* Stac */, tileId);
|
|
208
|
-
await
|
|
209
|
-
return
|
|
204
|
+
await fsa.writeJson(stacOutputPath, output);
|
|
205
|
+
return basename(stacOutputPath);
|
|
210
206
|
}
|
|
211
207
|
async createMetadata(bounds, itemPaths, logger) {
|
|
212
|
-
const output = await
|
|
208
|
+
const output = await Stac.createCollection(this, bounds, itemPaths, logger);
|
|
213
209
|
const stacOutputPath = this.tmpFolder.name("stac" /* Stac */, 'collection');
|
|
214
|
-
await
|
|
210
|
+
await fsa.writeJson(stacOutputPath, output);
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
|
-
exports.BathyMaker = BathyMaker;
|
|
218
213
|
module.exports = { BathyMaker };
|
package/build/file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAOA,0BAAkB,QAAQ;
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAOA,0BAAkB,QAAQ;IACxB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,UAAU,eAAe;CAC1B;AAQD,qBAAa,QAAQ;IACnB,UAAU,EAAE,MAAM,CAAC;gBAEP,UAAU,EAAE,MAAM;IAG9B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,SAAmB,GAAG,MAAM;IAK3D;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,SAAmB,GAAG,MAAM;CAgBxD"}
|
package/build/file.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FilePath = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
-
const path = tslib_1.__importStar(require("path"));
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
7
3
|
const PrefixMade = {};
|
|
8
4
|
const BathyTempFolder = '.bathy';
|
|
9
5
|
const SuffixMap = {
|
|
@@ -11,7 +7,7 @@ const SuffixMap = {
|
|
|
11
7
|
["stac" /* Stac */]: 'json',
|
|
12
8
|
["rendered" /* Rendered */]: 'png',
|
|
13
9
|
};
|
|
14
|
-
class FilePath {
|
|
10
|
+
export class FilePath {
|
|
15
11
|
constructor(sourcePath) {
|
|
16
12
|
this.sourcePath = sourcePath;
|
|
17
13
|
}
|
|
@@ -45,4 +41,3 @@ class FilePath {
|
|
|
45
41
|
return `${tempPath}/${basename}`;
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
|
-
exports.FilePath = FilePath;
|
package/build/hash.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
-
const multihashes_1 = tslib_1.__importDefault(require("multihashes"));
|
|
1
|
+
import * as crypto from 'crypto';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import Multihash from 'multihashes';
|
|
8
4
|
/** Stream a file though */
|
|
9
5
|
function hashFile(filePath, hashName) {
|
|
10
6
|
return new Promise((resolve, reject) => {
|
|
@@ -18,6 +14,6 @@ function hashFile(filePath, hashName) {
|
|
|
18
14
|
/** Create a multihash of a file */
|
|
19
15
|
async function hash(filePath) {
|
|
20
16
|
const hashData = await hashFile(filePath, 'sha256');
|
|
21
|
-
return Buffer.from(
|
|
17
|
+
return Buffer.from(Multihash.encode(hashData, 'sha2-256')).toString('hex');
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
export const Hash = { hash };
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAmHtE,qBAAa,qBAAsB,SAAQ,eAAe;;CAQzD"}
|
package/build/index.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const os = tslib_1.__importStar(require("os"));
|
|
12
|
-
const ulid = tslib_1.__importStar(require("ulid"));
|
|
13
|
-
const bathy_maker_1 = require("./bathy.maker");
|
|
14
|
-
const file_1 = require("./file");
|
|
1
|
+
import { BaseCommandLine } from '@basemaps/cli/build/cli/base.cli.js';
|
|
2
|
+
import { makeTempFolder } from '@basemaps/cli/build/cli/folder.js';
|
|
3
|
+
import { GoogleTms, TileMatrixSets } from '@basemaps/geo';
|
|
4
|
+
import { Env, fsa, LogConfig } from '@basemaps/shared';
|
|
5
|
+
import { CommandLineAction } from '@rushstack/ts-command-line';
|
|
6
|
+
import { createReadStream, promises as fs } from 'fs';
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import * as ulid from 'ulid';
|
|
9
|
+
import { BathyMaker } from './bathy.maker.js';
|
|
10
|
+
import { FilePath } from './file.js';
|
|
15
11
|
/** This zoom level gives a good enough quality world while not making too many tiles */
|
|
16
|
-
const GoodZoom =
|
|
17
|
-
class CreateAction extends
|
|
12
|
+
const GoodZoom = GoogleTms.def.tileMatrix[4];
|
|
13
|
+
class CreateAction extends CommandLineAction {
|
|
18
14
|
constructor() {
|
|
19
15
|
super({
|
|
20
16
|
actionName: 'create',
|
|
@@ -52,22 +48,22 @@ class CreateAction extends ts_command_line_1.CommandLineAction {
|
|
|
52
48
|
const isDocker = !!this.docker.value;
|
|
53
49
|
const pathToFile = this.inputPath.value;
|
|
54
50
|
if (isDocker) {
|
|
55
|
-
process.env[
|
|
56
|
-
if (process.env[
|
|
57
|
-
process.env[
|
|
51
|
+
process.env[Env.Gdal.UseDocker] = 'true';
|
|
52
|
+
if (process.env[Env.Gdal.DockerContainerTag] == null) {
|
|
53
|
+
process.env[Env.Gdal.DockerContainerTag] = 'ubuntu-full-latest';
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
|
-
const tileMatrixInput = (_a = this.tileMatrix.value) !== null && _a !== void 0 ? _a :
|
|
61
|
-
const tileMatrix =
|
|
56
|
+
const tileMatrixInput = (_a = this.tileMatrix.value) !== null && _a !== void 0 ? _a : GoogleTms.identifier;
|
|
57
|
+
const tileMatrix = TileMatrixSets.find(tileMatrixInput);
|
|
62
58
|
if (tileMatrix == null) {
|
|
63
59
|
throw new Error('Unknown tile matrix set: ' +
|
|
64
60
|
tileMatrixInput +
|
|
65
61
|
' Aviaiable tile matrix sets: ' +
|
|
66
|
-
|
|
62
|
+
TileMatrixSets.All.map((c) => c.identifier).join(', '));
|
|
67
63
|
}
|
|
68
|
-
const logger =
|
|
64
|
+
const logger = LogConfig.get();
|
|
69
65
|
logger.info({ source: pathToFile }, 'MakeBathy');
|
|
70
|
-
const tmpFolder = new
|
|
66
|
+
const tmpFolder = new FilePath(await makeTempFolder(`bathymetry-${ulid.ulid()}`));
|
|
71
67
|
try {
|
|
72
68
|
const outputPath = this.outputPath.value;
|
|
73
69
|
/** Find a decent zoom level that is close to the good zoom at google's scale */
|
|
@@ -75,7 +71,7 @@ class CreateAction extends ts_command_line_1.CommandLineAction {
|
|
|
75
71
|
// Make at least a few tiles
|
|
76
72
|
if (bestZ === 0)
|
|
77
73
|
bestZ++;
|
|
78
|
-
const bathy = new
|
|
74
|
+
const bathy = new BathyMaker({
|
|
79
75
|
id: ulid.ulid(),
|
|
80
76
|
inputPath: this.inputPath.value,
|
|
81
77
|
outputPath,
|
|
@@ -85,17 +81,17 @@ class CreateAction extends ts_command_line_1.CommandLineAction {
|
|
|
85
81
|
threads: os.cpus().length / 2,
|
|
86
82
|
});
|
|
87
83
|
await bathy.render(logger);
|
|
88
|
-
const srcPath =
|
|
89
|
-
for (const file of await
|
|
90
|
-
await
|
|
84
|
+
const srcPath = fsa.join(tmpFolder.sourcePath, String("output" /* Output */));
|
|
85
|
+
for (const file of await fs.readdir(srcPath)) {
|
|
86
|
+
await fsa.write(fsa.join(outputPath, file), createReadStream(fsa.join(srcPath, file)));
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
finally {
|
|
94
|
-
await
|
|
90
|
+
await fs.rmdir(tmpFolder.sourcePath, { recursive: true });
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
}
|
|
98
|
-
class BathymetryCommandLine extends
|
|
94
|
+
export class BathymetryCommandLine extends BaseCommandLine {
|
|
99
95
|
constructor() {
|
|
100
96
|
super({
|
|
101
97
|
toolFilename: 'bathymetry',
|
|
@@ -104,5 +100,4 @@ class BathymetryCommandLine extends base_cli_1.BaseCommandLine {
|
|
|
104
100
|
this.addAction(new CreateAction());
|
|
105
101
|
}
|
|
106
102
|
}
|
|
107
|
-
exports.BathymetryCommandLine = BathymetryCommandLine;
|
|
108
103
|
new BathymetryCommandLine().run();
|
package/build/mapnik.d.ts
CHANGED
package/build/mapnik.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapnik.d.ts","sourceRoot":"","sources":["../src/mapnik.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mapnik.d.ts","sourceRoot":"","sources":["../src/mapnik.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA2D3C,6EAA6E;AAC7E,iBAAe,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBlF;AAED,eAAO,MAAM,YAAY;;CAAa,CAAC"}
|
package/build/mapnik.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MapnikRender = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
-
const geo_1 = require("@basemaps/geo");
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { TileMatrixSet } from '@basemaps/geo';
|
|
7
3
|
/** To prevent the long compile time of mapnik for development, only pull it in when needed */
|
|
8
|
-
|
|
9
|
-
const mapnik = require('mapnik');
|
|
4
|
+
import mapnik from 'mapnik';
|
|
10
5
|
mapnik.register_default_input_plugins();
|
|
11
6
|
/** Create the mapnik template */
|
|
12
7
|
function makeTemplate(sourceFile, hillShade) {
|
|
@@ -61,7 +56,7 @@ function makeTemplate(sourceFile, hillShade) {
|
|
|
61
56
|
}
|
|
62
57
|
/** composite a hillshade and base tile into a hillshaded file with mapnik */
|
|
63
58
|
async function render(bm, tile, logger) {
|
|
64
|
-
const tileId =
|
|
59
|
+
const tileId = TileMatrixSet.tileToName(tile);
|
|
65
60
|
const warpedPath = bm.tmpFolder.name("warped" /* Warped */, tileId);
|
|
66
61
|
const hillShadePath = bm.tmpFolder.name("hillshade" /* HillShade */, tileId);
|
|
67
62
|
const outputPath = bm.tmpFolder.name("rendered" /* Rendered */, tileId);
|
|
@@ -76,4 +71,4 @@ async function render(bm, tile, logger) {
|
|
|
76
71
|
logger.debug({ duration: Date.now() - startTime }, 'MapnikRender');
|
|
77
72
|
return outputPath;
|
|
78
73
|
}
|
|
79
|
-
|
|
74
|
+
export const MapnikRender = { render };
|
package/build/stac.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Bounds,
|
|
1
|
+
import { Bounds, StacCollection, StacItem, Tile } from '@basemaps/geo';
|
|
2
2
|
import { LogType } from '@basemaps/shared';
|
|
3
|
-
import { BathyMaker } from './bathy.maker';
|
|
3
|
+
import { BathyMaker } from './bathy.maker.js';
|
|
4
4
|
/** Write some basic metadata about how the file was created*/
|
|
5
5
|
declare function createItem(bm: BathyMaker, tile: Tile): Promise<StacItem>;
|
|
6
6
|
/**
|
package/build/stac.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stac.d.ts","sourceRoot":"","sources":["../src/stac.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"stac.d.ts","sourceRoot":"","sources":["../src/stac.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAEN,cAAc,EACd,QAAQ,EAGR,IAAI,EAEL,MAAM,eAAe,CAAC;AACvB,OAAO,EAIL,OAAO,EAGR,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAW9C,8DAA8D;AAC9D,iBAAe,UAAU,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkCvE;AAED;;;;;;GAMG;AACH,iBAAe,gBAAgB,CAC7B,EAAE,EAAE,UAAU,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EAAE,EACnB,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,cAAc,CAAC,CA6EzB;AAED,eAAO,MAAM,IAAI;;;;;;CAAkD,CAAC"}
|
package/build/stac.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const hash_1 = require("./hash");
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
12
|
-
const packageJson = require('../package.json');
|
|
1
|
+
import { Stac as StacStatic, TileMatrixSet, } from '@basemaps/geo';
|
|
2
|
+
import { CompositeError, extractYearRangeFromName, fsa, Projection, titleizeImageryName, } from '@basemaps/shared';
|
|
3
|
+
import * as cp from 'child_process';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import path, { basename } from 'path';
|
|
6
|
+
import url from 'url';
|
|
7
|
+
import { Hash } from './hash.js';
|
|
8
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
9
|
+
const packageJson = JSON.parse(readFileSync(path.join(__dirname, '../package.json')).toString());
|
|
13
10
|
function getCommitHash() {
|
|
14
11
|
var _a;
|
|
15
12
|
return (_a = packageJson.gitHead) !== null && _a !== void 0 ? _a : cp.execSync('git rev-parse HEAD').toString().trim();
|
|
@@ -17,14 +14,14 @@ function getCommitHash() {
|
|
|
17
14
|
/** Write some basic metadata about how the file was created*/
|
|
18
15
|
async function createItem(bm, tile) {
|
|
19
16
|
const { tileMatrix } = bm.config;
|
|
20
|
-
const tileId =
|
|
17
|
+
const tileId = TileMatrixSet.tileToName(tile);
|
|
21
18
|
const outputTiffPath = bm.tmpFolder.name("output" /* Output */, tileId);
|
|
22
|
-
const bbox =
|
|
23
|
-
const { geometry } =
|
|
19
|
+
const bbox = Projection.tileToWgs84Bbox(tileMatrix, tile);
|
|
20
|
+
const { geometry } = Projection.get(tileMatrix).boundsToGeoJsonFeature(tileMatrix.tileToSourceBounds(tile));
|
|
24
21
|
const created = new Date().toISOString();
|
|
25
22
|
return {
|
|
26
|
-
stac_version:
|
|
27
|
-
stac_extensions: ['projection',
|
|
23
|
+
stac_version: StacStatic.Version,
|
|
24
|
+
stac_extensions: ['projection', StacStatic.BaseMapsExtension],
|
|
28
25
|
id: bm.config.id + '/' + tileId,
|
|
29
26
|
collection: bm.config.id,
|
|
30
27
|
type: 'Feature',
|
|
@@ -32,7 +29,7 @@ async function createItem(bm, tile) {
|
|
|
32
29
|
geometry,
|
|
33
30
|
properties: {
|
|
34
31
|
datetime: created,
|
|
35
|
-
'checksum:multihash': await
|
|
32
|
+
'checksum:multihash': await Hash.hash(outputTiffPath),
|
|
36
33
|
'proj:epsg': tileMatrix.projection.code,
|
|
37
34
|
'linz:gdal:version': await bm.gdalVersion,
|
|
38
35
|
'linz:tile_matrix_set': tileMatrix.identifier,
|
|
@@ -58,13 +55,13 @@ async function createItem(bm, tile) {
|
|
|
58
55
|
async function createCollection(bm, bounds, itemNames, logger) {
|
|
59
56
|
var _a, _b, _c, _d, _e;
|
|
60
57
|
const { tileMatrix } = bm.config;
|
|
61
|
-
const bbox = [
|
|
62
|
-
const name =
|
|
58
|
+
const bbox = [Projection.get(tileMatrix).boundsToWgs84BoundingBox(bounds)];
|
|
59
|
+
const name = basename(bm.inputPath);
|
|
63
60
|
let description;
|
|
64
61
|
const links = [
|
|
65
62
|
{
|
|
66
63
|
rel: 'self',
|
|
67
|
-
href:
|
|
64
|
+
href: fsa.join(bm.outputPath, bm.tmpFolder.basename("stac" /* Stac */, 'collection')),
|
|
68
65
|
},
|
|
69
66
|
{
|
|
70
67
|
rel: 'derived_from',
|
|
@@ -86,8 +83,8 @@ async function createCollection(bm, bounds, itemNames, logger) {
|
|
|
86
83
|
];
|
|
87
84
|
const interval = [];
|
|
88
85
|
try {
|
|
89
|
-
const sourceCollectionPath =
|
|
90
|
-
sourceStac = await
|
|
86
|
+
const sourceCollectionPath = fsa.join(bm.inputFolder, 'collection.json');
|
|
87
|
+
sourceStac = await fsa.readJson(sourceCollectionPath);
|
|
91
88
|
description = sourceStac.description;
|
|
92
89
|
interval.push(...((_d = (_c = (_b = sourceStac.extent) === null || _b === void 0 ? void 0 : _b.temporal) === null || _c === void 0 ? void 0 : _c.interval) !== null && _d !== void 0 ? _d : []));
|
|
93
90
|
links.push({ href: sourceCollectionPath, rel: 'sourceImagery', type: 'application/json' });
|
|
@@ -95,23 +92,23 @@ async function createCollection(bm, bounds, itemNames, logger) {
|
|
|
95
92
|
providers.push(...sourceStac.providers);
|
|
96
93
|
}
|
|
97
94
|
catch (err) {
|
|
98
|
-
if (!
|
|
95
|
+
if (!CompositeError.isCompositeError(err) || err.code !== 404) {
|
|
99
96
|
throw err;
|
|
100
97
|
}
|
|
101
98
|
}
|
|
102
|
-
const title = (_e = sourceStac.title) !== null && _e !== void 0 ? _e :
|
|
99
|
+
const title = (_e = sourceStac.title) !== null && _e !== void 0 ? _e : titleizeImageryName(name);
|
|
103
100
|
if (description == null) {
|
|
104
101
|
description = 'No description';
|
|
105
102
|
}
|
|
106
103
|
if (interval.length === 0) {
|
|
107
|
-
const years =
|
|
104
|
+
const years = extractYearRangeFromName(name);
|
|
108
105
|
if (years[0] === -1) {
|
|
109
106
|
throw new Error('Missing date in imagery name: ' + name);
|
|
110
107
|
}
|
|
111
108
|
interval.push(years.map((y) => `${y}-01-01T00:00:00Z`));
|
|
112
109
|
}
|
|
113
110
|
return {
|
|
114
|
-
stac_version:
|
|
111
|
+
stac_version: StacStatic.Version,
|
|
115
112
|
stac_extensions: ['projection'],
|
|
116
113
|
id: bm.config.id,
|
|
117
114
|
title,
|
|
@@ -122,11 +119,11 @@ async function createCollection(bm, bounds, itemNames, logger) {
|
|
|
122
119
|
},
|
|
123
120
|
temporal: { interval },
|
|
124
121
|
},
|
|
125
|
-
license:
|
|
122
|
+
license: StacStatic.License,
|
|
126
123
|
links,
|
|
127
124
|
providers,
|
|
128
125
|
keywords: ['Bathymetry'],
|
|
129
126
|
summaries: { 'proj:epsg': [bm.config.tileMatrix.projection.code] },
|
|
130
127
|
};
|
|
131
128
|
}
|
|
132
|
-
|
|
129
|
+
export const Stac = { createItem, createCollection, ...StacStatic };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/bathymetry",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"url": "https://linz.govt.nz",
|
|
12
12
|
"organization": true
|
|
13
13
|
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
17
|
+
},
|
|
14
18
|
"license": "MIT",
|
|
15
19
|
"main": "./build/index.js",
|
|
16
20
|
"types": "./build/index.d.ts",
|
|
@@ -24,9 +28,9 @@
|
|
|
24
28
|
"build/"
|
|
25
29
|
],
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@basemaps/cli": "^6.
|
|
28
|
-
"@basemaps/geo": "^6.
|
|
29
|
-
"@basemaps/shared": "^6.
|
|
31
|
+
"@basemaps/cli": "^6.10.0",
|
|
32
|
+
"@basemaps/geo": "^6.10.0",
|
|
33
|
+
"@basemaps/shared": "^6.10.0",
|
|
30
34
|
"@rushstack/ts-command-line": "^4.3.13",
|
|
31
35
|
"multihashes": "^4.0.2",
|
|
32
36
|
"ulid": "^2.3.0"
|
|
@@ -37,5 +41,5 @@
|
|
|
37
41
|
"devDependencies": {
|
|
38
42
|
"@types/mapnik": "^3.0.1"
|
|
39
43
|
},
|
|
40
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "c88706ff58f4dfe83bf2b757d1483194accdb4c9"
|
|
41
45
|
}
|