@basemaps/bathymetry 6.46.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/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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E,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;SACxD;IACH,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,eAAe;IACxD;QACE,KAAK,CAAC;YACJ,YAAY,EAAE,YAAY;YAC1B,eAAe,EAAE,4CAA4C;SAC9D,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,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;I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AE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,EAAE,cAAc,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,MAAM,EAAE,CAAC"}
package/build/stac.d.ts DELETED
@@ -1,22 +0,0 @@
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,C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