@basemaps/bathymetry 6.45.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,27 @@
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
+ # [7.0.0](https://github.com/linz/basemaps/compare/v6.46.0...v7.0.0) (2023-11-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * upgrade to gdal 3.8.0 and add max_z_overview setting ([#3014](https://github.com/linz/basemaps/issues/3014)) ([0d78a9a](https://github.com/linz/basemaps/commit/0d78a9acd8e260e3caba452e00b68a81a001a68f))
12
+ * **cli:** Relocate dgal and cog from cli package. BM-879 ([#2984](https://github.com/linz/basemaps/issues/2984)) ([6ebb106](https://github.com/linz/basemaps/commit/6ebb1061b8b044e8bb519a26ddd5912b57494d22))
13
+ * **doc:** Improve the individual package documentations. BM-776 ([#2981](https://github.com/linz/basemaps/issues/2981)) ([5a4adcb](https://github.com/linz/basemaps/commit/5a4adcbbff15857a6f4c315d54280d542f785fec))
14
+
15
+
16
+
17
+
18
+
19
+ # [6.46.0](https://github.com/linz/basemaps/compare/v6.45.0...v6.46.0) (2023-10-10)
20
+
21
+ **Note:** Version bump only for package @basemaps/bathymetry
22
+
23
+
24
+
25
+
26
+
6
27
  # [6.45.0](https://github.com/linz/basemaps/compare/v6.44.0...v6.45.0) (2023-09-18)
7
28
 
8
29
  **Note:** Version bump only for package @basemaps/bathymetry
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # Bathymetry creation
1
+ # @basemaps/bathymetry
2
2
 
3
+ ## Bathymetry creation
3
4
 
4
5
  This process takes batheymetric data from [GEBCO](https://www.gebco.net/) and converts it into a colorized hillshaded geotiff.
5
6
 
6
7
  ![](./images/bathyoutput.png)
7
8
 
8
-
9
9
  ## Usage
10
10
 
11
11
  You will need:
@@ -18,7 +18,7 @@ You will need:
18
18
  # Install dependencies
19
19
  yarn add @basemaps/bathymetry
20
20
 
21
- # To prevent very long CI/Dev build times, mapnik will need to be manually installed
21
+ # To prevent very long CI/Dev build times, mapnik will need to be manually installed
22
22
  yarn add mapnik
23
23
 
24
24
  # Ensure the javascript has been built
@@ -28,7 +28,6 @@ yarn build
28
28
  node build/index.js -v create --input gebco_2020.nc --docker --output gebco/
29
29
  ```
30
30
 
31
-
32
31
  ## Process
33
32
 
34
33
  ![](./images/bathyprocess.png)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/bathymetry",
3
- "version": "6.45.0",
3
+ "version": "7.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/linz/basemaps.git",
@@ -28,9 +28,9 @@
28
28
  "build/"
29
29
  ],
30
30
  "dependencies": {
31
- "@basemaps/cli": "^6.45.0",
32
- "@basemaps/geo": "^6.44.0",
33
- "@basemaps/shared": "^6.45.0",
31
+ "@basemaps/cli": "^7.0.0",
32
+ "@basemaps/geo": "^7.0.0",
33
+ "@basemaps/shared": "^7.0.0",
34
34
  "@rushstack/ts-command-line": "^4.3.13",
35
35
  "multihashes": "^4.0.2",
36
36
  "ulid": "^2.3.0"
@@ -41,5 +41,5 @@
41
41
  "devDependencies": {
42
42
  "@types/mapnik": "^3.0.1"
43
43
  },
44
- "gitHead": "a04e29efbf9169e9b6d63cd23b2f4e7b5390014c"
44
+ "gitHead": "82d9e6d431240133f4e4d783dd0b4138c2d1f66a"
45
45
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hash.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/hash.test.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
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');
10
- });
11
- });
12
- //# sourceMappingURL=hash.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.test.js","sourceRoot":"","sources":["../../src/__tests__/hash.test.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,OAAO,CAAC;AACtB,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;IAClB,CAAC,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;QACnB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,sEAAsE,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=stac.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stac.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/stac.test.ts"],"names":[],"mappings":""}
@@ -1,176 +0,0 @@
1
- import { GoogleTms } from '@basemaps/geo';
2
- import { LogConfig } from '@basemaps/shared';
3
- import { mockFileOperator } from '@basemaps/shared/build/file/__tests__/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;
16
- mockFs.teardown();
17
- });
18
- o('createItem', async () => {
19
- Hash.hash = (v) => 'hash' + v;
20
- const bm = {
21
- id: 'id123',
22
- tileMatrix: GoogleTms,
23
- inputPath: 's3://test-source-bucket/gebco-2020',
24
- outputPath: 's3://test-bucket/bathy-2020',
25
- tmpFolder: new FilePath('/tmp/path'),
26
- };
27
- bm.config = bm;
28
- const now = Date.now();
29
- const stac = round((await Stac.createItem(bm, { x: 22, y: 33, z: 13 })));
30
- const date = Date.parse(stac.properties.datetime);
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],
35
- id: 'id123/13-22-33',
36
- collection: 'id123',
37
- type: 'Feature',
38
- bbox: [-179.0332, 84.9205, -178.9893, 84.9244],
39
- geometry: {
40
- type: 'Polygon',
41
- coordinates: [
42
- [
43
- [-179.0332, 84.9205],
44
- [-179.0332, 84.9244],
45
- [-178.9893, 84.9244],
46
- [-178.9893, 84.9205],
47
- [-179.0332, 84.9205],
48
- ],
49
- ],
50
- },
51
- properties: {
52
- datetime: stac.properties.datetime,
53
- 'checksum:multihash': 'hash/tmp/path/output/13-22-33.tiff',
54
- 'proj:epsg': 3857,
55
- 'linz:gdal:version': undefined,
56
- 'linz:tile_matrix_set': 'WebMercatorQuad',
57
- },
58
- assets: {
59
- tiff: {
60
- href: '13-22-33.tiff',
61
- title: 'GeoTiff',
62
- roles: ['data'],
63
- type: 'image/tiff; application=geotiff',
64
- },
65
- },
66
- links: [{ rel: 'collection', href: 'collection.json' }],
67
- });
68
- });
69
- o.spec('createCollection', () => {
70
- const logger = LogConfig.get();
71
- LogConfig.disable();
72
- const bm = {
73
- id: 'id123',
74
- tileMatrix: GoogleTms,
75
- inputPath: 's3://test-source-bucket/gebco-2020/gebco_2020.nc',
76
- outputPath: 's3://test-bucket/bathy-2020',
77
- tmpFolder: new FilePath('/tmp/path'),
78
- createSourceHash(l) {
79
- return 'multihashResult' + (l === logger);
80
- },
81
- get inputFolder() {
82
- return dirname(this.inputPath);
83
- },
84
- };
85
- bm.config = bm;
86
- o('createCollection without source collection.json', async () => {
87
- const bounds = GoogleTms.tileToSourceBounds({ x: 1, y: 2, z: 4 });
88
- const items = ['1-1-2.json'];
89
- const stac = await Stac.createCollection(bm, bounds, items, logger);
90
- o(round(stac, 4)).deepEquals({
91
- stac_version: Stac.Version,
92
- stac_extensions: ['projection'],
93
- id: 'id123',
94
- title: 'Gebco 2020.nc',
95
- description: 'No description',
96
- extent: {
97
- spatial: { bbox: [[-157.5, 74.0195, -135, 79.1713]] },
98
- temporal: {
99
- interval: [['2020-01-01T00:00:00Z', '2021-01-01T00:00:00Z']],
100
- },
101
- },
102
- license: Stac.License,
103
- links: stac.links,
104
- providers: [
105
- {
106
- name: 'Land Information New Zealand',
107
- url: 'https://www.linz.govt.nz/',
108
- roles: ['processor'],
109
- },
110
- ],
111
- keywords: ['Bathymetry'],
112
- summaries: { 'proj:epsg': [3857] },
113
- });
114
- });
115
- o('createCollection with source collection.json', async () => {
116
- mockFs.jsStore['s3://test-source-bucket/gebco-2020/collection.json'] = {
117
- title: 'fancy title',
118
- description: 'collection description',
119
- providers: [{ name: 'source provider', roles: ['source'] }],
120
- extent: {
121
- spatial: { bbox: [[-180, 84, -178, 85]] },
122
- temporal: { interval: [['2020-01-01T00:00:00Z', '2020-10-12T01:02:03Z']] },
123
- },
124
- };
125
- const bounds = GoogleTms.tileToSourceBounds({ x: 22, y: 33, z: 13 });
126
- const items = ['13-22-33.json', '13-22-34.json'];
127
- const stac = await Stac.createCollection(bm, bounds, items, logger);
128
- const gitHubLink = stac.links[2];
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,
134
- stac_extensions: ['projection'],
135
- id: 'id123',
136
- title: 'fancy title',
137
- description: 'collection description',
138
- extent: {
139
- spatial: { bbox: [[-179.0332, 84.9205, -178.9893, 84.9244]] },
140
- temporal: { interval: [['2020-01-01T00:00:00Z', '2020-10-12T01:02:03Z']] },
141
- },
142
- license: Stac.License,
143
- links: [
144
- {
145
- rel: 'self',
146
- href: 's3://test-bucket/bathy-2020/collection.json',
147
- },
148
- {
149
- rel: 'derived_from',
150
- href: 's3://test-source-bucket/gebco-2020/gebco_2020.nc',
151
- 'checksum:multihash': 'multihashResulttrue',
152
- },
153
- gitHubLink,
154
- { rel: 'item', href: '13-22-33.json', type: 'application/geo+json' },
155
- { rel: 'item', href: '13-22-34.json', type: 'application/geo+json' },
156
- {
157
- href: 's3://test-source-bucket/gebco-2020/collection.json',
158
- rel: 'sourceImagery',
159
- type: 'application/json',
160
- },
161
- ],
162
- providers: [
163
- {
164
- name: 'Land Information New Zealand',
165
- url: 'https://www.linz.govt.nz/',
166
- roles: ['processor'],
167
- },
168
- { name: 'source provider', roles: ['source'] },
169
- ],
170
- keywords: ['Bathymetry'],
171
- summaries: { 'proj:epsg': [3857] },
172
- });
173
- });
174
- });
175
- });
176
- //# sourceMappingURL=stac.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stac.test.js","sourceRoot":"","sources":["../../src/__tests__/stac.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAW,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAA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EAAE,kDAAkD;wBACxD,oBAAoB,EAAE,qBAAqB;qBAC5C;oBACD,UAAU;oBAEV,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,EAAE;oBACpE,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,EAAE;oBACpE;wBACE,IAAI,EAAE,oDAAoD;wBAC1D,GAAG,EAAE,eAAe;wBACpB,IAAI,EAAE,kBAAkB;qBACzB;iBACF;gBACD,SAAS,EAAE;oBACT;wBACE,IAAI,EAAE,8BAA8B;wBACpC,GAAG,EAAE,2BAA2B;wBAChC,KAAK,EAAE,CAAC,WAAW,CAAC;qBACrB;oBACD,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE;iBAC/C;gBACD,QAAQ,EAAE,CAAC,YAAY,CAAC;gBACxB,SAAS,EAAE,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE;aACnC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,61 +0,0 @@
1
- import { Bounds, Tile, TileMatrixSet } from '@basemaps/geo';
2
- import { LogType } from '@basemaps/shared';
3
- import type { LimitFunction } from 'p-limit';
4
- import { FilePath } from './file.js';
5
- interface BathyMakerContext {
6
- /** unique id for this build */
7
- id: string;
8
- /** Source netcdf or tiff file path */
9
- inputPath: string;
10
- /** Output directory path */
11
- outputPath: string;
12
- tmpFolder: FilePath;
13
- /** TileMatrixSet to cut the bathy up into tiles */
14
- tileMatrix: TileMatrixSet;
15
- /** zoom level of the tms to cut the tiles too */
16
- zoom: number;
17
- /** Number of threads used to convert @default NUM_CPUS */
18
- threads?: number;
19
- /** Mapnik render tilesize @default 8192 */
20
- tileSize?: number;
21
- }
22
- export declare const BathyMakerContextDefault: {
23
- threads: number;
24
- /** Making this much larger than this takes quite a long time to render */
25
- tileSize: number;
26
- };
27
- export declare class BathyMaker {
28
- config: BathyMakerContext & typeof BathyMakerContextDefault;
29
- /** Current gdal version @see Gdal.version */
30
- gdalVersion: Promise<string>;
31
- /** Concurrent limiting queue, all work should be done inside the queue */
32
- q: LimitFunction;
33
- constructor(ctx: BathyMakerContext);
34
- get inputPath(): string;
35
- get inputFolder(): string;
36
- get outputPath(): string;
37
- get tmpFolder(): FilePath;
38
- isTiffInput(): boolean;
39
- /** Most operations need a tiff file */
40
- get tiffPath(): string;
41
- /** File name of the path */
42
- get fileName(): string;
43
- render(logger: LogType): Promise<void>;
44
- /** Create a multi hash of the source file */
45
- createSourceHash(logger: LogType): Promise<string>;
46
- /** Render a specific tile */
47
- renderTile(tile: Tile, logger: LogType): Promise<string>;
48
- /** convert a input file into one that can be processed by this script */
49
- createSourceGeoTiff(logger: LogType): Promise<void>;
50
- /** Create a tile in the output TMS's CRS */
51
- createTile(tile: Tile, logger: LogType): Promise<void>;
52
- /** Create a hillshade for a tile */
53
- createHillShadedTile(tile: Tile, logger: LogType): Promise<void>;
54
- /** Use mapnik to composite the hillshaded tile and the rendered tile */
55
- createCompositeTile(tile: Tile, logger: LogType): Promise<void>;
56
- /** Create and write a stac metadata item for a single tile */
57
- createTileMetadata(tile: Tile): Promise<string>;
58
- createMetadata(bounds: Bounds, itemPaths: string[], logger: LogType): Promise<void>;
59
- }
60
- export {};
61
- //# sourceMappingURL=bathy.maker.d.ts.map
@@ -1 +0,0 @@
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,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,OAAO,EAAE,QAAQ,EAAY,MAAM,WAAW,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AM,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"}
@@ -1,213 +0,0 @@
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';
11
- function createMountedGdal(...paths) {
12
- const gdal = Gdal.create();
13
- if (gdal.mount != null) {
14
- for (const path of paths)
15
- gdal.mount(path);
16
- }
17
- return gdal;
18
- }
19
- export const BathyMakerContextDefault = {
20
- threads: os.cpus().length,
21
- /** Making this much larger than this takes quite a long time to render */
22
- tileSize: 8192,
23
- };
24
- export class BathyMaker {
25
- constructor(ctx) {
26
- this.config = { ...BathyMakerContextDefault, ...ctx };
27
- this.q = PLimit(this.config.threads);
28
- }
29
- get inputPath() {
30
- return this.config.inputPath;
31
- }
32
- get inputFolder() {
33
- return path.dirname(this.inputPath);
34
- }
35
- get outputPath() {
36
- return this.config.outputPath;
37
- }
38
- get tmpFolder() {
39
- return this.config.tmpFolder;
40
- }
41
- isTiffInput() {
42
- return this.inputPath.endsWith('.tiff');
43
- }
44
- /** Most operations need a tiff file */
45
- get tiffPath() {
46
- if (this.isTiffInput())
47
- return this.inputPath;
48
- return this.tmpFolder.name("sourceTiff" /* FileType.SourceTiff */);
49
- }
50
- /** File name of the path */
51
- get fileName() {
52
- return path.basename(this.inputPath);
53
- }
54
- async render(logger) {
55
- this.gdalVersion = Gdal.version(logger);
56
- const isNc = this.inputPath.endsWith('.nc');
57
- // NetCdf files need to be converted to GeoTiff before processing
58
- if (isNc)
59
- await this.createSourceGeoTiff(logger);
60
- await this.createSourceHash(logger);
61
- const { tileMatrix: tms, zoom } = this.config;
62
- const tmsZoom = tms.zooms[zoom];
63
- logger.info({ file: this.fileName, zoom, tileCount: tmsZoom.matrixWidth * tmsZoom.matrixHeight }, 'Splitting Tiles');
64
- const gdalVersion = await this.gdalVersion;
65
- logger.info({ gdalVersion }, 'GdalVersion');
66
- const promises = [];
67
- let extent = null;
68
- for (let x = 0; x < tmsZoom.matrixWidth; x++) {
69
- for (let y = 0; y < tmsZoom.matrixHeight; y++) {
70
- const promise = this.q(() => {
71
- const tile = { x, y, z: zoom };
72
- const bounds = tms.tileToSourceBounds(tile);
73
- extent = extent == null ? bounds : extent.union(bounds);
74
- const tileId = TileMatrixSet.tileToName(tile);
75
- return this.renderTile(tile, logger.child({ index: tileId }));
76
- });
77
- promises.push(promise);
78
- }
79
- }
80
- try {
81
- const tileNames = await Promise.all(promises);
82
- if (extent == null)
83
- return;
84
- await this.createMetadata(extent, tileNames, logger);
85
- }
86
- catch (err) {
87
- logger.fatal(err, 'FailedToRun');
88
- throw err;
89
- }
90
- }
91
- /** Create a multi hash of the source file */
92
- async createSourceHash(logger) {
93
- const hashPath = this.tmpFolder.name("hash" /* FileType.Hash */);
94
- if (await fsa.exists(hashPath))
95
- return (await fsa.read(hashPath)).toString();
96
- logger.info({ hashPath }, 'CreateHash');
97
- const outputHash = await Hash.hash(this.inputPath);
98
- await fsa.write(hashPath, Buffer.from(outputHash));
99
- return outputHash;
100
- }
101
- /** Render a specific tile */
102
- async renderTile(tile, logger) {
103
- try {
104
- await this.createTile(tile, logger);
105
- await this.createHillShadedTile(tile, logger);
106
- await this.createCompositeTile(tile, logger);
107
- return await this.createTileMetadata(tile);
108
- }
109
- catch (err) {
110
- logger.error({ err }, 'Failed');
111
- throw err;
112
- }
113
- }
114
- /** convert a input file into one that can be processed by this script */
115
- async createSourceGeoTiff(logger) {
116
- if (this.isTiffInput())
117
- return;
118
- logger.info({ path: this.tiffPath }, 'Converting to GeoTiff');
119
- const gdal = createMountedGdal(this.tmpFolder.sourcePath, this.inputFolder);
120
- await gdal.run('gdal_translate', [
121
- '-of',
122
- 'GTiff',
123
- // Files need to be converted to Float32 to fix a weird outline bug with the resampling
124
- // see https://github.com/linz/basemaps-team/issues/241
125
- '-ot',
126
- 'Float32',
127
- s3ToVsis3(this.inputPath),
128
- this.tiffPath,
129
- ], logger);
130
- }
131
- /** Create a tile in the output TMS's CRS */
132
- async createTile(tile, logger) {
133
- const tileId = TileMatrixSet.tileToName(tile);
134
- const warpedPath = this.tmpFolder.name("warped" /* FileType.Warped */, tileId);
135
- if (await fsa.exists(warpedPath))
136
- return;
137
- const tms = this.config.tileMatrix;
138
- const bounds = tms.tileToSourceBounds(tile);
139
- const warpCommand = [
140
- '-of',
141
- 'GTIFF',
142
- '-co',
143
- 'NUM_THREADS=ALL_CPUS',
144
- '-s_srs',
145
- Epsg.Wgs84.toEpsgString(),
146
- '-t_srs',
147
- tms.projection.toEpsgString(),
148
- '-r',
149
- 'bilinear',
150
- '-te',
151
- ...bounds.toBbox(),
152
- this.tiffPath,
153
- warpedPath,
154
- ].map(String);
155
- logger.trace({ file: warpedPath }, 'Warping');
156
- const gdal = createMountedGdal(this.tmpFolder.sourcePath, this.tiffPath);
157
- await gdal.run('gdalwarp', warpCommand, logger);
158
- }
159
- /** Create a hillshade for a tile */
160
- async createHillShadedTile(tile, logger) {
161
- const tileId = TileMatrixSet.tileToName(tile);
162
- const warped = this.tmpFolder.name("warped" /* FileType.Warped */, tileId);
163
- const target = this.tmpFolder.name("hillshade" /* FileType.HillShade */, tileId);
164
- if (await fsa.exists(target))
165
- return;
166
- logger.trace({ file: target }, 'Shading');
167
- const gdal = createMountedGdal(this.inputPath, this.tmpFolder.sourcePath);
168
- await gdal.run('gdaldem', ['hillshade', '-compute_edges', '-multidirectional', warped, target], logger);
169
- }
170
- /** Use mapnik to composite the hillshaded tile and the rendered tile */
171
- async createCompositeTile(tile, logger) {
172
- const tileId = TileMatrixSet.tileToName(tile);
173
- const renderedPath = await MapnikRender.render(this, tile, logger);
174
- const outputPath = this.tmpFolder.name("output" /* FileType.Output */, tileId);
175
- if (await fsa.exists(outputPath))
176
- return;
177
- const gdal = createMountedGdal(this.tmpFolder.sourcePath);
178
- const tileMatrix = this.config.tileMatrix;
179
- const bounds = tileMatrix.tileToSourceBounds(tile);
180
- await gdal.run('gdal_translate', [
181
- '-of',
182
- 'GTiff',
183
- '-co',
184
- 'NUM_THREADS=ALL_CPUS',
185
- '-co',
186
- 'COMPRESS=webp',
187
- '-co',
188
- 'WEBP_LEVEL=100',
189
- '-r',
190
- 'bilinear',
191
- '-a_srs',
192
- tileMatrix.projection.toEpsgString(),
193
- '-a_ullr',
194
- ...[bounds.x, bounds.bottom, bounds.right, bounds.y],
195
- renderedPath,
196
- outputPath,
197
- ].map(String), logger);
198
- }
199
- /** Create and write a stac metadata item for a single tile */
200
- async createTileMetadata(tile) {
201
- const output = await Stac.createItem(this, tile);
202
- const tileId = TileMatrixSet.tileToName(tile);
203
- const stacOutputPath = this.tmpFolder.name("stac" /* FileType.Stac */, tileId);
204
- await fsa.writeJson(stacOutputPath, output);
205
- return basename(stacOutputPath);
206
- }
207
- async createMetadata(bounds, itemPaths, logger) {
208
- const output = await Stac.createCollection(this, bounds, itemPaths, logger);
209
- const stacOutputPath = this.tmpFolder.name("stac" /* FileType.Stac */, 'collection');
210
- await fsa.writeJson(stacOutputPath, output);
211
- }
212
- }
213
- //# sourceMappingURL=bathy.maker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bathy.maker.js","sourceRoot":"","sources":["../src/bathy.maker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,OAAO,EAAU,IAAI,EAAQ,aAAa,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,GAAG,EAAW,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAoBjC,SAAS,iBAAiB,CAAC,GAAG,KAAe;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE;QACtB,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KAC5C;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM;IACzB,0EAA0E;IAC1E,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,MAAM,OAAO,UAAU;IAQrB,YAAY,GAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,wBAAwB,EAAE,GAAG,GAAG,EAAE,CAA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S,CAAC,IAAI,6BAAgB,MAAM,CAAC,CAAC;QAClE,MAAM,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,SAAmB,EAAE,MAAe;QACvE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC5E,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,6BAAgB,YAAY,CAAC,CAAC;QACxE,MAAM,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;CACF"}
package/build/file.d.ts DELETED
@@ -1,25 +0,0 @@
1
- export declare const enum FileType {
2
- Output = "output",
3
- Hash = "hash",
4
- Warped = "warped",
5
- HillShade = "hillshade",
6
- Rendered = "rendered",
7
- Stac = "stac",
8
- SourceTiff = "sourceTiff"
9
- }
10
- export declare class FilePath {
11
- sourcePath: string;
12
- constructor(sourcePath: string);
13
- /**
14
- * Determine the basename for a file type
15
- */
16
- basename(fileType: FileType, id?: string): string;
17
- /**
18
- * Create some temp files and folders
19
- *
20
- * output into folder ./output
21
- * temp files into temp folder ./.bathy/
22
- */
23
- name(fileType: FileType, id?: string): string;
24
- }
25
- //# sourceMappingURL=file.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,44 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- const PrefixMade = {};
4
- const BathyTempFolder = '.bathy';
5
- const SuffixMap = {
6
- ["hash" /* FileType.Hash */]: 'multihash',
7
- ["stac" /* FileType.Stac */]: 'json',
8
- ["rendered" /* FileType.Rendered */]: 'png',
9
- };
10
- export class FilePath {
11
- constructor(sourcePath) {
12
- this.sourcePath = sourcePath;
13
- }
14
- /**
15
- * Determine the basename for a file type
16
- */
17
- basename(fileType, id = String(fileType)) {
18
- var _a;
19
- const suffix = (_a = SuffixMap[fileType]) !== null && _a !== void 0 ? _a : 'tiff';
20
- return `${id}.${suffix}`;
21
- }
22
- /**
23
- * Create some temp files and folders
24
- *
25
- * output into folder ./output
26
- * temp files into temp folder ./.bathy/
27
- */
28
- name(fileType, id = String(fileType)) {
29
- const basename = this.basename(fileType, id);
30
- let tempPath = this.sourcePath;
31
- if (fileType === "output" /* FileType.Output */ || fileType === "stac" /* FileType.Stac */) {
32
- tempPath = path.join(tempPath, "output" /* FileType.Output */);
33
- }
34
- else {
35
- tempPath = path.join(tempPath, BathyTempFolder, fileType);
36
- }
37
- if (PrefixMade[tempPath] == null) {
38
- fs.mkdirSync(tempPath, { recursive: true });
39
- PrefixMade[tempPath] = true;
40
- }
41
- return `${tempPath}/${basename}`;
42
- }
43
- }
44
- //# sourceMappingURL=file.js.map
package/build/file.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,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ts DELETED
@@ -1,7 +0,0 @@
1
- /** Create a multihash of a file */
2
- declare function hash(filePath: string): Promise<string>;
3
- export declare const Hash: {
4
- hash: typeof hash;
5
- };
6
- export {};
7
- //# sourceMappingURL=hash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAeA,mCAAmC;AACnC,iBAAe,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGrD;AAED,eAAO,MAAM,IAAI;;CAAW,CAAC"}
package/build/hash.js DELETED
@@ -1,20 +0,0 @@
1
- import * as crypto from 'crypto';
2
- import * as fs from 'fs';
3
- import Multihash from 'multihashes';
4
- /** Stream a file though */
5
- function hashFile(filePath, hashName) {
6
- return new Promise((resolve, reject) => {
7
- const hash = crypto.createHash(hashName);
8
- const stream = fs.createReadStream(filePath);
9
- stream.on('error', (err) => reject(err));
10
- stream.on('data', (chunk) => hash.update(chunk));
11
- stream.on('end', () => resolve(hash.digest()));
12
- });
13
- }
14
- /** Create a multihash of a file */
15
- async function hash(filePath) {
16
- const hashData = await hashFile(filePath, 'sha256');
17
- return Buffer.from(Multihash.encode(hashData, 'sha2-256')).toString('hex');
18
- }
19
- export const Hash = { hash };
20
- //# sourceMappingURL=hash.js.map
package/build/hash.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,2BAA2B;AAC3B,SAAS,QAAQ,CAAC,QAAgB,EAAE,QAAgB;IAClD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mCAAmC;AACnC,KAAK,UAAU,IAAI,CAAC,QAAgB;IAClC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC"}
package/build/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { BaseCommandLine } from '@basemaps/shared/build/cli/base.js';
2
- export declare class BathymetryCommandLine extends BaseCommandLine {
3
- constructor();
4
- }
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAmHrE,qBAAa,qBAAsB,SAAQ,eAAe;;CAQzD"}
package/build/index.js DELETED
@@ -1,104 +0,0 @@
1
- import { BaseCommandLine } from '@basemaps/shared/build/cli/base.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';
11
- /** This zoom level gives a good enough quality world while not making too many tiles */
12
- const GoodZoom = GoogleTms.def.tileMatrix[4];
13
- class CreateAction extends CommandLineAction {
14
- constructor() {
15
- super({
16
- actionName: 'create',
17
- summary: 'create bathymetry imagery',
18
- documentation: 'Take batheymetric data and convert it into a set of colorized hillshaded geotiffs.',
19
- });
20
- }
21
- onDefineParameters() {
22
- this.inputPath = this.defineStringParameter({
23
- argumentName: 'PATH',
24
- parameterLongName: '--input',
25
- description: 'Folder or S3 Bucket location of Gebco netcdf or tiff file',
26
- required: true,
27
- });
28
- this.outputPath = this.defineStringParameter({
29
- argumentName: 'PATH',
30
- parameterLongName: '--output',
31
- description: 'Folder or S3 Bucket location to store imagery in',
32
- required: true,
33
- });
34
- this.docker = this.defineFlagParameter({
35
- parameterLongName: '--docker',
36
- description: 'Run inside a docker container',
37
- required: false,
38
- });
39
- this.tileMatrix = this.defineStringParameter({
40
- argumentName: 'TILE_MATRIX_SET',
41
- parameterLongName: '--tile-matrix-set',
42
- description: 'Tile matrix set to use for the final cutting',
43
- required: false,
44
- });
45
- }
46
- async onExecute() {
47
- var _a;
48
- const isDocker = !!this.docker.value;
49
- const pathToFile = this.inputPath.value;
50
- if (isDocker) {
51
- process.env[Env.Gdal.UseDocker] = 'true';
52
- if (process.env[Env.Gdal.DockerContainerTag] == null) {
53
- process.env[Env.Gdal.DockerContainerTag] = 'ubuntu-full-latest';
54
- }
55
- }
56
- const tileMatrixInput = (_a = this.tileMatrix.value) !== null && _a !== void 0 ? _a : GoogleTms.identifier;
57
- const tileMatrix = TileMatrixSets.find(tileMatrixInput);
58
- if (tileMatrix == null) {
59
- throw new Error('Unknown tile matrix set: ' +
60
- tileMatrixInput +
61
- ' Aviaiable tile matrix sets: ' +
62
- TileMatrixSets.All.map((c) => c.identifier).join(', '));
63
- }
64
- const logger = LogConfig.get();
65
- logger.info({ source: pathToFile }, 'MakeBathy');
66
- const tmpFolder = new FilePath(await makeTempFolder(`bathymetry-${ulid.ulid()}`));
67
- try {
68
- const outputPath = this.outputPath.value;
69
- /** Find a decent zoom level that is close to the good zoom at google's scale */
70
- let bestZ = tileMatrix.findBestZoom(GoodZoom.scaleDenominator + 1);
71
- // Make at least a few tiles
72
- if (bestZ === 0)
73
- bestZ++;
74
- const bathy = new BathyMaker({
75
- id: ulid.ulid(),
76
- inputPath: this.inputPath.value,
77
- outputPath,
78
- tmpFolder,
79
- tileMatrix,
80
- zoom: bestZ,
81
- threads: os.cpus().length / 2,
82
- });
83
- await bathy.render(logger);
84
- const srcPath = fsa.join(tmpFolder.sourcePath, String("output" /* FileType.Output */));
85
- for (const file of await fs.readdir(srcPath)) {
86
- await fsa.write(fsa.join(outputPath, file), createReadStream(fsa.join(srcPath, file)));
87
- }
88
- }
89
- finally {
90
- await fs.rm(tmpFolder.sourcePath, { recursive: true });
91
- }
92
- }
93
- }
94
- export class BathymetryCommandLine extends BaseCommandLine {
95
- constructor() {
96
- super({
97
- toolFilename: 'bathymetry',
98
- toolDescription: 'Create source imagery from bathymetry data',
99
- });
100
- this.addAction(new CreateAction());
101
- }
102
- }
103
- new BathymetryCommandLine().run();
104
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,GAAG,E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C,IAAI,YAAY,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AAED,IAAI,qBAAqB,EAAE,CAAC,GAAG,EAAE,CAAC"}
package/build/mapnik.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { BathyMaker } from './bathy.maker.js';
2
- import { Tile } from '@basemaps/geo';
3
- import { LogType } from '@basemaps/shared';
4
- /** composite a hillshade and base tile into a hillshaded file with mapnik */
5
- declare function render(bm: BathyMaker, tile: Tile, logger: LogType): Promise<string>;
6
- export declare const MapnikRender: {
7
- render: typeof render;
8
- };
9
- export {};
10
- //# sourceMappingURL=mapnik.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,75 +0,0 @@
1
- import * as fs from 'fs';
2
- import { TileMatrixSet } from '@basemaps/geo';
3
- /** To prevent the long compile time of mapnik for development, only pull it in when needed */
4
- import mapnik from 'mapnik';
5
- mapnik.register_default_input_plugins();
6
- /** Create the mapnik template */
7
- function makeTemplate(sourceFile, hillShade) {
8
- return `<?xml version="1.0" encoding="utf-8"?>
9
- <!DOCTYPE Map[]>
10
- <Map background-color="#2a383e" srs="+init=epsg:4326">
11
-
12
- <Style comp-op="color-dodge" filter-mode="first" name="gebco2019webmercator2">
13
- <Rule>
14
- <RasterSymbolizer default-color="rgba(0, 0, 0, 0)" default-mode="linear" scaling="bilinear">
15
- <stop color="#222222" value="0" />
16
- <stop color="#ebebeb" value="255" />
17
- </RasterSymbolizer>
18
- </Rule>
19
- </Style>
20
- <Layer name="gebco2019webmercator2" srs="+init=epsg:4326">
21
- <StyleName><![CDATA[gebco2019webmercator2]]></StyleName>
22
- <Datasource>
23
- <Parameter name="file"><![CDATA[${hillShade}]]></Parameter>
24
- <Parameter name="band"><![CDATA[1]]></Parameter>
25
- <Parameter name="type"><![CDATA[gdal]]></Parameter>
26
- </Datasource>
27
- </Layer>
28
- <Style comp-op="color-dodge" filter-mode="first" name="gebco2019webmercator-deuce">
29
- <Rule>
30
- <RasterSymbolizer default-color="rgba(0, 0, 0, 0)" default-mode="linear" opacity="0.75" scaling="bilinear">
31
- <stop color="rgba(0, 0, 0, 0)" value="-350" />
32
- <stop color="#88b3ac" value="0" />
33
- <stop color="#e7f0ef" value="200" />
34
- </RasterSymbolizer>
35
- </Rule>
36
- </Style>
37
- <Style comp-op="multiply" filter-mode="first" name="gebco2019webmercator">
38
- <Rule>
39
- <RasterSymbolizer default-color="rgba(0, 0, 0, 0)" default-mode="linear" scaling="bilinear">
40
- <stop color="#000000" value="-10881" />
41
- <stop color="#ffffff" value="100" />
42
- <stop color="rgba(0, 0, 0, 0)" value="101" />
43
- </RasterSymbolizer>
44
- </Rule>
45
- </Style>
46
- <Layer name="gebco2019webmercator" srs="+init=epsg:4326">
47
- <StyleName><![CDATA[gebco2019webmercator]]></StyleName>
48
- <StyleName><![CDATA[gebco2019webmercator-deuce]]></StyleName>
49
- <Datasource>
50
- <Parameter name="file"><![CDATA[${sourceFile}]]></Parameter>
51
- <Parameter name="band"><![CDATA[1]]></Parameter>
52
- <Parameter name="type"><![CDATA[gdal]]></Parameter>
53
- </Datasource>
54
- </Layer>
55
- </Map>`;
56
- }
57
- /** composite a hillshade and base tile into a hillshaded file with mapnik */
58
- async function render(bm, tile, logger) {
59
- const tileId = TileMatrixSet.tileToName(tile);
60
- const warpedPath = bm.tmpFolder.name("warped" /* FileType.Warped */, tileId);
61
- const hillShadePath = bm.tmpFolder.name("hillshade" /* FileType.HillShade */, tileId);
62
- const outputPath = bm.tmpFolder.name("rendered" /* FileType.Rendered */, tileId);
63
- if (fs.existsSync(outputPath))
64
- return outputPath;
65
- const template = makeTemplate(warpedPath, hillShadePath);
66
- const map = new mapnik.Map(bm.config.tileSize, bm.config.tileSize);
67
- await new Promise((resolve, reject) => map.fromString(template, (err) => (err == null ? resolve() : reject(err))));
68
- map.zoomAll();
69
- const startTime = Date.now();
70
- await new Promise((resolve, reject) => map.renderFile(outputPath, (err) => (err == null ? resolve() : reject(err))));
71
- logger.debug({ duration: Date.now() - startTime }, 'MapnikRender');
72
- return outputPath;
73
- }
74
- export const MapnikRender = { render };
75
- //# sourceMappingURL=mapnik.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapnik.js","sourceRoot":"","sources":["../src/mapnik.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAQ,aAAa,EAAE,MAAM,eAAe,CAAC;AAIpD,8FAA8F;AAC9F,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,CAAC,8BAA8B,EAAE,CAAC;AAExC,iCAAiC;AACjC,SAAS,YAAY,CAAC,UAAkB,EAAE,SAAiB;IACzD,OAAO;;;;;;;;;;;;;;;wCAe+B,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;wCA2BT,UAAU;;;;;OAK3C,CAAC;AACR,CAAC;AAED,6EAA6E;AAC7E,KAAK,UAAU,MAAM,CAAC,EAAc,EAAE,IAAU,EAAE,MAAe;IAC/D,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,iCAAkB,MAAM,CAAC,CAAC;IAC9D,MAAM,aAAa,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,uCAAqB,MAAM,C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1
- import { Bounds, StacCollection, StacItem, Tile } from '@basemaps/geo';
2
- import { LogType } from '@basemaps/shared';
3
- import { BathyMaker } from './bathy.maker.js';
4
- /** Write some basic metadata about how the file was created*/
5
- declare function createItem(bm: BathyMaker, tile: Tile): Promise<StacItem>;
6
- /**
7
- * Build a collection.json for the created files
8
-
9
- * @param bm build config
10
- * @param bounds the extent of the output
11
- * @param itemNames the names of the stac item json files
12
- */
13
- declare function createCollection(bm: BathyMaker, bounds: Bounds, itemNames: string[], logger: LogType): Promise<StacCollection>;
14
- export declare const Stac: {
15
- Version: "1.0.0-beta.2";
16
- License: "CC BY 4.0";
17
- BaseMapsExtension: "https://basemaps.linz.govt.nz/json-schema/stac-basemaps-extension/1.0/schema.json";
18
- createItem: typeof createItem;
19
- createCollection: typeof createCollection;
20
- };
21
- export {};
22
- //# sourceMappingURL=stac.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stac.d.ts","sourceRoot":"","sources":["../src/stac.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAGN,cAAc,EACd,QAAQ,EAGR,IAAI,EAEL,MAAM,eAAe,CAAC;AACvB,OAAO,EAAiD,OAAO,EAAuB,MAAM,kBAAkB,CAAC;AAK/G,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,CA4EzB;AAED,eAAO,MAAM,IAAI;;;;;;CAAkD,CAAC"}
package/build/stac.js DELETED
@@ -1,129 +0,0 @@
1
- import { Projection, Stac as StacStatic, TileMatrixSet, } from '@basemaps/geo';
2
- import { CompositeError, extractYearRangeFromName, fsa, 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());
10
- function getCommitHash() {
11
- var _a;
12
- return (_a = packageJson.gitHead) !== null && _a !== void 0 ? _a : cp.execSync('git rev-parse HEAD').toString().trim();
13
- }
14
- /** Write some basic metadata about how the file was created*/
15
- async function createItem(bm, tile) {
16
- const { tileMatrix } = bm.config;
17
- const tileId = TileMatrixSet.tileToName(tile);
18
- const outputTiffPath = bm.tmpFolder.name("output" /* FileType.Output */, tileId);
19
- const bbox = Projection.tileToWgs84Bbox(tileMatrix, tile);
20
- const { geometry } = Projection.get(tileMatrix).boundsToGeoJsonFeature(tileMatrix.tileToSourceBounds(tile));
21
- const created = new Date().toISOString();
22
- return {
23
- stac_version: StacStatic.Version,
24
- stac_extensions: ['projection', StacStatic.BaseMapsExtension],
25
- id: bm.config.id + '/' + tileId,
26
- collection: bm.config.id,
27
- type: 'Feature',
28
- bbox,
29
- geometry,
30
- properties: {
31
- datetime: created,
32
- 'checksum:multihash': await Hash.hash(outputTiffPath),
33
- 'proj:epsg': tileMatrix.projection.code,
34
- 'linz:gdal:version': await bm.gdalVersion,
35
- 'linz:tile_matrix_set': tileMatrix.identifier,
36
- },
37
- assets: {
38
- tiff: {
39
- href: path.basename(outputTiffPath),
40
- title: 'GeoTiff',
41
- roles: ['data'],
42
- type: 'image/tiff; application=geotiff',
43
- },
44
- },
45
- links: [{ rel: 'collection', href: 'collection.json' }],
46
- };
47
- }
48
- /**
49
- * Build a collection.json for the created files
50
-
51
- * @param bm build config
52
- * @param bounds the extent of the output
53
- * @param itemNames the names of the stac item json files
54
- */
55
- async function createCollection(bm, bounds, itemNames, logger) {
56
- var _a, _b, _c, _d, _e;
57
- const { tileMatrix } = bm.config;
58
- const bbox = [Projection.get(tileMatrix).boundsToWgs84BoundingBox(bounds)];
59
- const name = basename(bm.inputPath);
60
- let description;
61
- const links = [
62
- {
63
- rel: 'self',
64
- href: fsa.join(bm.outputPath, bm.tmpFolder.basename("stac" /* FileType.Stac */, 'collection')),
65
- },
66
- {
67
- rel: 'derived_from',
68
- href: bm.inputPath,
69
- 'checksum:multihash': await bm.createSourceHash(logger),
70
- },
71
- {
72
- rel: 'derived_from',
73
- href: ((_a = packageJson.repository.url) !== null && _a !== void 0 ? _a : packageJson.repository) + '#' + getCommitHash(),
74
- version: packageJson.version,
75
- },
76
- ];
77
- for (const name of itemNames) {
78
- links.push({ rel: 'item', href: name, type: 'application/geo+json' });
79
- }
80
- let sourceStac = {};
81
- const providers = [
82
- { name: 'Land Information New Zealand', url: 'https://www.linz.govt.nz/', roles: ['processor'] },
83
- ];
84
- const interval = [];
85
- try {
86
- const sourceCollectionPath = fsa.join(bm.inputFolder, 'collection.json');
87
- sourceStac = await fsa.readJson(sourceCollectionPath);
88
- description = sourceStac.description;
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 : []));
90
- links.push({ href: sourceCollectionPath, rel: 'sourceImagery', type: 'application/json' });
91
- if (sourceStac.providers != null)
92
- providers.push(...sourceStac.providers);
93
- }
94
- catch (err) {
95
- if (!CompositeError.isCompositeError(err) || err.code !== 404) {
96
- throw err;
97
- }
98
- }
99
- const title = (_e = sourceStac.title) !== null && _e !== void 0 ? _e : titleizeImageryName(name);
100
- if (description == null) {
101
- description = 'No description';
102
- }
103
- if (interval.length === 0) {
104
- const years = extractYearRangeFromName(name);
105
- if (years == null)
106
- throw new Error('Missing date in imagery name: ' + name);
107
- interval.push(years.map((y) => `${y}-01-01T00:00:00Z`));
108
- }
109
- return {
110
- stac_version: StacStatic.Version,
111
- stac_extensions: ['projection'],
112
- id: bm.config.id,
113
- title,
114
- description,
115
- extent: {
116
- spatial: {
117
- bbox,
118
- },
119
- temporal: { interval },
120
- },
121
- license: StacStatic.License,
122
- links,
123
- providers,
124
- keywords: ['Bathymetry'],
125
- summaries: { 'proj:epsg': [bm.config.tileMatrix.projection.code] },
126
- };
127
- }
128
- export const Stac = { createItem, createCollection, ...StacStatic };
129
- //# sourceMappingURL=stac.js.map
package/build/stac.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"stac.js","sourceRoot":"","sources":["../src/stac.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,IAAI,IAAI,UAAU,EAMlB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,GAAG,EAAW,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,GAAG,MAAM,KAAK,CAAC;AAGtB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACnE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAEjG,SAAS,aAAa;;IACpB,OAAO,MAAA,WAAW,CAAC,OAAO,mCAAI,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;AACpF,CAAC;AAED,8DAA8D;AAC9D,KAA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