@basemaps/cli-vector 8.1.0 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/build/bin.js +2 -2
  2. package/build/cli/cli.analyse.d.ts +34 -0
  3. package/build/cli/cli.analyse.js +152 -0
  4. package/build/cli/cli.analyse.js.map +1 -0
  5. package/build/cli/cli.create.d.ts +39 -0
  6. package/build/cli/cli.create.js +211 -0
  7. package/build/cli/cli.create.js.map +1 -0
  8. package/build/cli/cli.extract.d.ts +8 -17
  9. package/build/cli/cli.extract.js +43 -33
  10. package/build/cli/cli.extract.js.map +1 -1
  11. package/build/cli/cli.join.d.ts +44 -0
  12. package/build/cli/cli.join.js +149 -0
  13. package/build/cli/cli.join.js.map +1 -0
  14. package/build/extract.js.map +1 -0
  15. package/build/generalization/generalization.d.ts +10 -0
  16. package/build/generalization/generalization.js +168 -0
  17. package/build/generalization/generalization.js.map +1 -0
  18. package/build/generalization/simplify.d.ts +2 -0
  19. package/build/generalization/simplify.js +80 -0
  20. package/build/generalization/simplify.js.map +1 -0
  21. package/build/index.d.ts +83 -5
  22. package/build/index.js +7 -1
  23. package/build/index.js.map +1 -1
  24. package/build/modify/consts.d.ts +1 -0
  25. package/build/modify/consts.js +23 -0
  26. package/build/modify/consts.js.map +1 -0
  27. package/build/modify/layers/__test__/contours.test.d.ts +1 -0
  28. package/build/modify/layers/__test__/contours.test.js +59 -0
  29. package/build/modify/layers/__test__/contours.test.js.map +1 -0
  30. package/build/modify/layers/contours.d.ts +28 -0
  31. package/build/modify/layers/contours.js +90 -0
  32. package/build/modify/layers/contours.js.map +1 -0
  33. package/build/modify/layers/place_labels.d.ts +18 -0
  34. package/build/modify/layers/place_labels.js +117 -0
  35. package/build/modify/layers/place_labels.js.map +1 -0
  36. package/build/modify/layers/pois.d.ts +11 -0
  37. package/build/modify/layers/pois.js +32 -0
  38. package/build/modify/layers/pois.js.map +1 -0
  39. package/build/modify/layers/public_transport.d.ts +12 -0
  40. package/build/modify/layers/public_transport.js +41 -0
  41. package/build/modify/layers/public_transport.js.map +1 -0
  42. package/build/modify/layers/street_labels.d.ts +12 -0
  43. package/build/modify/layers/street_labels.js +34 -0
  44. package/build/modify/layers/street_labels.js.map +1 -0
  45. package/build/modify/layers/streets.d.ts +12 -0
  46. package/build/modify/layers/streets.js +72 -0
  47. package/build/modify/layers/streets.js.map +1 -0
  48. package/build/modify/layers/water.d.ts +13 -0
  49. package/build/modify/layers/water.js +82 -0
  50. package/build/modify/layers/water.js.map +1 -0
  51. package/build/modify/modify.d.ts +11 -0
  52. package/build/modify/modify.js +49 -0
  53. package/build/modify/modify.js.map +1 -0
  54. package/build/modify/parser.d.ts +47 -0
  55. package/build/modify/parser.js +24 -0
  56. package/build/modify/parser.js.map +1 -0
  57. package/build/modify/schema.d.ts +17 -0
  58. package/build/modify/schema.js +2 -0
  59. package/build/modify/schema.js.map +1 -0
  60. package/build/modify/shared.d.ts +7 -0
  61. package/build/modify/shared.js +53 -0
  62. package/build/modify/shared.js.map +1 -0
  63. package/build/schema-loader/parser.d.ts +16 -0
  64. package/build/schema-loader/parser.js +2 -0
  65. package/build/schema-loader/parser.js.map +1 -1
  66. package/build/schema-loader/schema.d.ts +21 -5
  67. package/build/schema-loader/schema.loader.d.ts +3 -1
  68. package/build/schema-loader/schema.loader.js +18 -6
  69. package/build/schema-loader/schema.loader.js.map +1 -1
  70. package/build/stac.d.ts +41 -0
  71. package/build/stac.js +185 -0
  72. package/build/stac.js.map +1 -0
  73. package/build/transform/covt.d.ts +5 -0
  74. package/build/transform/covt.js +23 -0
  75. package/build/transform/covt.js.map +1 -0
  76. package/build/transform/mbtiles.to.ttiles.d.ts +14 -0
  77. package/build/transform/mbtiles.to.ttiles.js +60 -0
  78. package/build/transform/mbtiles.to.ttiles.js.map +1 -0
  79. package/build/transform/nztm.d.ts +4 -0
  80. package/build/transform/nztm.js +13 -0
  81. package/build/transform/nztm.js.map +1 -0
  82. package/build/transform/ogr2ogr.d.ts +9 -0
  83. package/build/transform/ogr2ogr.js +43 -0
  84. package/build/transform/ogr2ogr.js.map +1 -0
  85. package/build/transform/tippecanoe.d.ts +15 -0
  86. package/build/transform/tippecanoe.js +69 -0
  87. package/build/transform/tippecanoe.js.map +1 -0
  88. package/build/types/VectorGeoFeature.d.ts +9 -0
  89. package/build/types/VectorGeoFeature.js +2 -0
  90. package/build/types/VectorGeoFeature.js.map +1 -0
  91. package/build/util.d.ts +35 -0
  92. package/build/util.js +43 -0
  93. package/build/util.js.map +1 -0
  94. package/dist/index.cjs +20809 -9550
  95. package/package.json +23 -8
  96. package/build/extract/extract.js.map +0 -1
  97. /package/build/{extract/extract.d.ts → extract.d.ts} +0 -0
  98. /package/build/{extract/extract.js → extract.js} +0 -0
@@ -0,0 +1,69 @@
1
+ import { Epsg } from '@basemaps/geo';
2
+ import { urlToString } from '@basemaps/shared';
3
+ import { Command } from '@linzjs/docker-command';
4
+ import path, { dirname } from 'path';
5
+ import { transformZoom } from './nztm.js';
6
+ /**
7
+ * tippecanoe usage, return cmd for tippecanoe
8
+ *
9
+ * @returns { cmd: string; args: string[] } cmd and arguments for tippecanoe docker command
10
+ */
11
+ export async function tippecanoe(input, output, layer, tileMatrix, logger) {
12
+ const cmd = Command.create('tippecanoe');
13
+ // parallel processing for line-delimited geojson file.
14
+ cmd.args.push('--read-parallel');
15
+ // Config projection
16
+ cmd.args.push('-s', Epsg.Wgs84.toEpsgString());
17
+ // Config detail
18
+ if (layer.style != null) {
19
+ cmd.args.push(`-Z${transformZoom(layer.style.minZoom, tileMatrix)}`);
20
+ cmd.args.push(`-z${transformZoom(layer.style.maxZoom, tileMatrix)}`);
21
+ if (layer.style.detail != null)
22
+ cmd.args.push(`--full-detail=${layer.style.detail}`);
23
+ }
24
+ else {
25
+ // Default to 0-15 for WebMercator and 0-13 for NZTM2000Quad
26
+ cmd.args.push(`-z${transformZoom(15, tileMatrix)}`);
27
+ }
28
+ cmd.mount(dirname(input.pathname));
29
+ cmd.mount(dirname(output.pathname));
30
+ cmd.args.push('-o', output.pathname);
31
+ // Add tippecanoe options
32
+ if (layer.tippecanoe != null) {
33
+ for (const arg of layer.tippecanoe) {
34
+ cmd.args.push(arg);
35
+ }
36
+ }
37
+ cmd.args.push(input.pathname);
38
+ cmd.args.push('--force');
39
+ const res = await cmd.run();
40
+ logger.debug('tippecanoe ' + cmd.args.join(' '));
41
+ if (res.exitCode !== 0) {
42
+ logger.fatal({ Tippecanoe: res }, 'Failure');
43
+ throw new Error('Tippecanoe Docker failed to run');
44
+ }
45
+ }
46
+ /**
47
+ * tippecanoe tile-join usage, return cmd for tile-join
48
+ *
49
+ * @returns { cmd: string; args: string[] } cmd and arguments for tippecanoe tile-join docker command
50
+ */
51
+ export async function tileJoin(inputs, output, logger) {
52
+ const cmd = Command.create('tile-join');
53
+ cmd.mount(path.resolve(dirname(output)));
54
+ cmd.args.push('-pk');
55
+ cmd.args.push('-o', output);
56
+ for (const input of inputs) {
57
+ if (input.href.endsWith('mbtiles')) {
58
+ cmd.mount(dirname(urlToString(input)));
59
+ cmd.args.push(urlToString(input));
60
+ }
61
+ }
62
+ cmd.args.push('--force');
63
+ const res = await cmd.run();
64
+ if (res.exitCode !== 0) {
65
+ logger.fatal({ Tippecanoe: res }, 'Failure');
66
+ throw new Error('Tippecanoe Docker failed to run');
67
+ }
68
+ }
69
+ //# sourceMappingURL=tippecanoe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tippecanoe.js","sourceRoot":"","sources":["../../src/transform/tippecanoe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAW,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,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AC,SAAS,CAAC,EAAE,CAAC;YACnC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACvC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEzB,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC;IAC5B,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Feature } from 'geojson';
2
+ export interface VectorGeoFeature extends Feature {
3
+ properties: Record<string, boolean | null | number | string | undefined>;
4
+ tippecanoe: {
5
+ layer: string;
6
+ minzoom: number;
7
+ maxzoom: number;
8
+ };
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=VectorGeoFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VectorGeoFeature.js","sourceRoot":"","sources":["../../src/types/VectorGeoFeature.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { ReadStream } from 'fs';
2
+ export declare const projection: string;
3
+ export declare const ContentType: {
4
+ readonly gpkg: "application/x-ogc-gpkg";
5
+ readonly shp: "application/x-ogc-shp";
6
+ readonly geojson: "application/geo+json";
7
+ };
8
+ export declare function createReadStreamSafe(filename: string): Promise<ReadStream>;
9
+ export interface TmpPaths {
10
+ /**
11
+ * @example "local-cache/layerId/{layerId}_{version}_{hash}.json"
12
+ * @example "s3://linz-lds-cache/layerId/{layerId}_{version}_{hash}.json"
13
+ */
14
+ origin: URL;
15
+ source: {
16
+ /** @example "tmp/create/layers/50248/50248.gpkg" */
17
+ path: URL;
18
+ /** @example "gpkg" */
19
+ format: keyof typeof ContentType;
20
+ /** @example "application/x-ogc-gpkg" */
21
+ contentType: (typeof ContentType)[keyof typeof ContentType];
22
+ };
23
+ /** @example "tmp/create/layers/50248/50248.ndjson" */
24
+ ndjson: URL;
25
+ /** @example "tmp/create/transform/aerialways/50248/50248-gen.ndjson" */
26
+ genNdjson: URL;
27
+ /** @example "tmp/create/transform/aerialways/50248/50248.mbtiles" */
28
+ mbtiles: URL;
29
+ /**
30
+ * @example "local-cache/layerId/{layerId}_{version}_{hash}.mbtiles"
31
+ * @example "s3://linz-lds-cache/layerId/{layerId}_{version}_{hash}.mbtiles"
32
+ */
33
+ mbtilesCopy: URL;
34
+ }
35
+ export declare function prepareTmpPaths(tmpPath: URL, path: URL, layerId: string, format: keyof typeof ContentType, shortbreadLayer: string): TmpPaths;
package/build/util.js ADDED
@@ -0,0 +1,43 @@
1
+ import { existsSync, mkdirSync } from 'node:fs';
2
+ import { Epsg } from '@basemaps/geo';
3
+ import { createReadStream } from 'fs';
4
+ export const projection = Epsg.Wgs84.toEpsgString();
5
+ export const ContentType = {
6
+ gpkg: 'application/x-ogc-gpkg',
7
+ shp: 'application/x-ogc-shp',
8
+ geojson: 'application/geo+json',
9
+ };
10
+ export function createReadStreamSafe(filename) {
11
+ return new Promise((resolve, reject) => {
12
+ const fileStream = createReadStream(filename);
13
+ fileStream.on('error', reject).on('open', () => {
14
+ resolve(fileStream);
15
+ });
16
+ });
17
+ }
18
+ export function prepareTmpPaths(tmpPath, path, layerId, format, shortbreadLayer) {
19
+ /** @example "tmp/create/layers/50248/" */
20
+ const LayersDir = new URL(`layers/${layerId}/`, tmpPath);
21
+ if (!existsSync(LayersDir)) {
22
+ mkdirSync(LayersDir, { recursive: true });
23
+ }
24
+ /** @example "tmp/create/transform/aerialways/50248/" */
25
+ const TransformDir = new URL(`transform/${shortbreadLayer}/${layerId}/`, tmpPath);
26
+ if (!existsSync(TransformDir)) {
27
+ mkdirSync(TransformDir, { recursive: true });
28
+ }
29
+ const tmpPaths = {
30
+ origin: path,
31
+ source: {
32
+ path: new URL(`${layerId}.${format}`, LayersDir),
33
+ format,
34
+ contentType: ContentType[format],
35
+ },
36
+ ndjson: new URL(`${layerId}.ndjson`, LayersDir),
37
+ genNdjson: new URL(`${layerId}-gen.ndjson`, TransformDir),
38
+ mbtiles: new URL(`${layerId}.mbtiles`, TransformDir),
39
+ mbtilesCopy: new URL(path.href.replace(/\.json$/, '.mbtiles')),
40
+ };
41
+ return tmpPaths;
42
+ }
43
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAc,MAAM,IAAI,CAAC;AAElD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,wBAAwB;IAC9B,GAAG,EAAE,uBAAuB;IAC5B,OAAO,EAAE,sBAAsB;CACvB,CAAC;AAEX,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC9C,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YAC7C,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAoCD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