diff --git a/packages/cli/package.json b/packages/cli/package.json index ad17105be..8d5b3f922 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -54,7 +54,6 @@ "@rushstack/ts-command-line": "^4.3.13", "ansi-colors": "^4.1.1", "deep-diff": "^1.0.2", - "flatgeobuf": "^3.23.1", "node-fetch": "^3.2.3", "p-limit": "^4.0.0", "pretty-json-log": "^1.0.0", diff --git a/packages/cli/src/cli/config/action.cog.mapsheet.ts b/packages/cli/src/cli/config/action.cog.mapsheet.ts deleted file mode 100644 index 9b1ef828b..000000000 --- a/packages/cli/src/cli/config/action.cog.mapsheet.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { ConfigBundled, ConfigProviderMemory } from '@basemaps/config'; -import { Bounds } from '@basemaps/geo'; -import { fsa, LogConfig } from '@basemaps/shared'; -import { CommandLineAction, CommandLineStringParameter } from '@rushstack/ts-command-line'; -import * as fgb from 'flatgeobuf/lib/mjs/geojson.js'; -import { FeatureCollection, MultiPolygon } from 'geojson'; - -interface Output { - sheetCode: string; - files: string[]; -} - -export class CommandCogMapSheet extends CommandLineAction { - private path: CommandLineStringParameter; - private config: CommandLineStringParameter; - private output: CommandLineStringParameter; - private include: CommandLineStringParameter; - private exclude: CommandLineStringParameter; - - public constructor() { - super({ - actionName: 'create-mapsheet', - summary: 'Create a cog mapsheet from provided flatgeobuf', - documentation: 'Given a valid path of raw imagery and create a config bundle file', - }); - } - - protected onDefineParameters(): void { - this.path = this.defineStringParameter({ - argumentName: 'PATH', - parameterLongName: '--path', - description: 'Path of flatgeobuf, this can be both a local path or s3 location', - required: true, - }); - this.config = this.defineStringParameter({ - argumentName: 'CONFIG', - parameterLongName: '--config', - description: 'Path of basemaps config json, this can be both a local path or s3 location', - required: true, - }); - this.output = this.defineStringParameter({ - argumentName: 'OUTPUT', - parameterLongName: '--output', - description: 'Output of the mapsheet file', - required: true, - }); - this.include = this.defineStringParameter({ - argumentName: 'INCLUDE', - parameterLongName: '--include', - description: 'Include the layers with the pattern in the layer name.', - required: false, - }); - this.exclude = this.defineStringParameter({ - argumentName: 'EXCLUDE', - parameterLongName: '--exclude', - description: 'Exclude the layers with the pattern in the layer name.', - required: false, - }); - } - - async onExecute(): Promise { - const logger = LogConfig.get(); - const path = this.path.value; - if (path == null) throw new Error('Please provide valid a fgb path.'); - const config = this.config.value; - if (config == null) throw new Error('Please provide valid a config path.'); - - const include = this.include.value ? new RegExp(this.include.value.toLowerCase(), 'i') : undefined; - const exclude = this.exclude.value ? new RegExp(this.exclude.value.toLowerCase(), 'i') : undefined; - - const outputPath = this.output.value; - if (outputPath == null) throw new Error('Please provide valid a output path.'); - - logger.info({ path }, 'MapSheet:LoadFgb'); - const buf = await fsa.read(path); - logger.info({ config }, 'MapSheet:LoadConfig'); - const configJson = await fsa.readJson(config); - const men = ConfigProviderMemory.fromJson(configJson); - - const rest = fgb.deserialize(buf) as FeatureCollection; - - const aerial = await men.TileSet.get('ts_aerial'); - if (aerial == null) throw new Error('Invalid config file.'); - const layers = aerial.layers.filter( - (c) => c[2193] != null && (c.maxZoom == null || c.maxZoom > 19) && (c.minZoom == null || c.minZoom < 32), - ); - const imageryIds = new Set(); - for (const layer of layers) { - if (exclude && exclude.test(layer.name)) continue; - if (include && !include.test(layer.name)) continue; - if (layer[2193] != null) imageryIds.add(layer[2193]); - } - const imagery = await men.Imagery.getAll(imageryIds); - - const output: Output[] = []; - logger.info({ path, config }, 'MapSheet:CreateMapSheet'); - for (const feature of rest.features) { - if (feature.properties == null) continue; - const sheetCode = feature.properties.sheet_code_id; - const current: Output = { sheetCode, files: [] }; - output.push(current); - const bounds = Bounds.fromMultiPolygon((feature.geometry as MultiPolygon).coordinates); - - for (const layer of layers) { - if (layer[2193] == null) continue; - const img = imagery.get(layer[2193]); - if (img == null) continue; - if (img.bounds == null || Bounds.fromJson(img.bounds).intersects(bounds)) { - for (const file of img.files) { - if (bounds.intersects(Bounds.fromJson(file))) { - current.files.push(`${img.uri}/${file.name}.tiff`); - } - } - } - } - } - logger.info({ outputPath }, 'MapSheet:WriteOutput'); - fsa.write(outputPath, JSON.stringify(output, null, 2)); - } -} diff --git a/packages/cli/src/cli/index.ts b/packages/cli/src/cli/index.ts index 72def670f..e9b77db41 100644 --- a/packages/cli/src/cli/index.ts +++ b/packages/cli/src/cli/index.ts @@ -4,7 +4,6 @@ import 'source-map-support/register.js'; import { CommandCreateOverview } from './overview/action.create.overview.js'; import { CommandBundleAssets } from './config/action.bundle.assets.js'; import { CommandBundle } from './config/action.bundle.js'; -import { CommandCogMapSheet } from './config/action.cog.mapsheet.js'; import { CommandImageryConfig } from './config/action.imagery.config.js'; import { CommandImport } from './config/action.import.js'; import { CommandServe } from './server/action.serve.js'; @@ -23,9 +22,9 @@ export class BasemapsConfigCommandLine extends BaseCommandLine { this.addAction(new CommandImageryConfig()); // Argo - this.addAction(new CommandCogMapSheet()); this.addAction(new CommandCreateOverview()); + // CICD - Screenshot tests this.addAction(new CommandServe()); } } diff --git a/yarn.lock b/yarn.lock index de084745c..62e027ba1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1700,11 +1700,6 @@ resolved "https://registry.yarnpkg.com/@react-types/shared/-/shared-3.15.0.tgz#a4a78f36bc8daaefe6e9a9df1f453271639c2233" integrity sha512-hwuE4BmgswqP+HRDSLMj7DcnYOCCK+ZRuKnc9AVhXS4LBrwRSkdUkNvXhgvqF5tav7IqTpG9pBYMR9wedehuhA== -"@repeaterjs/repeater@3.0.4": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@repeaterjs/repeater/-/repeater-3.0.4.tgz#a04d63f4d1bf5540a41b01a921c9a7fddc3bd1ca" - integrity sha512-AW8PKd6iX3vAZ0vA43nOUOnbq/X5ihgU+mSXXqunMkeQADGiqw/PY0JNeYtD5sr0PAy51YPgAPbDoeapv9r8WA== - "@rushstack/ts-command-line@^4.3.13": version "4.11.1" resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.11.1.tgz#10b80960ddaed685445289807c75743e4ef0b5e9" @@ -4144,20 +4139,6 @@ flat-cache@^3.0.4: flatted "^3.1.0" rimraf "^3.0.2" -flatbuffers@2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/flatbuffers/-/flatbuffers-2.0.6.tgz#3aa3a39d282af9a660b4a0cdd1bb7ad91874abfc" - integrity sha512-QTTZTXTbVfuOVQu2X6eLOw4vefUxnFJZxAKeN3rEPhjEzBtIbehimJLfVGHPM8iX0Na+9i76SBEg0skf0c0sCA== - -flatgeobuf@^3.23.1: - version "3.23.1" - resolved "https://registry.yarnpkg.com/flatgeobuf/-/flatgeobuf-3.23.1.tgz#c2aab304be8209269894ea4c8e1833ede6da3b0e" - integrity sha512-u3MQnbMzL28Eiq7TbyzT6V/Ai70TI+zr1E8tu/m0g9bcxmuO2lT1iaocRX/7wYRLIijiZz2V4SVxCVenFG3JOg== - dependencies: - "@repeaterjs/repeater" "3.0.4" - flatbuffers "2.0.6" - slice-source "0.4.1" - flatted@^3.1.0: version "3.2.7" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" @@ -7496,11 +7477,6 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" -slice-source@0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/slice-source/-/slice-source-0.4.1.tgz#40a57ac03c6668b5da200e05378e000bf2a61d79" - integrity sha512-YiuPbxpCj4hD9Qs06hGAz/OZhQ0eDuALN0lRWJez0eD/RevzKqGdUx1IOMUnXgpr+sXZLq3g8ERwbAH0bCb8vg== - slugify@^1.6.5: version "1.6.5" resolved "https://registry.yarnpkg.com/slugify/-/slugify-1.6.5.tgz#c8f5c072bf2135b80703589b39a3d41451fbe8c8"