Skip to content

Commit

Permalink
Add imagery name as parameter of create-over.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentao-Kuang committed Dec 12, 2024
1 parent e3a0444 commit bd7bbd0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/cogify/src/cogify/cli/__test__/cli.cover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('cli.cover', () => {
extraVerbose: false,
requireStacCollection: false,
background: undefined,
name: undefined,
};

it('should generate a covering', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cogify/src/cogify/cli/cli.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const BasemapsCogifyConfigCommand = command({
const q = pLimit(args.concurrency);

metrics.start('imagery:load');
const im = await initImageryFromTiffUrl(args.path, q, undefined, logger);
const im = await initImageryFromTiffUrl(args.path, q, undefined, undefined, logger);
const ts = ConfigProviderMemory.imageryToTileSet(im) as ConfigTileSetRaster;
provider.put(im);
metrics.end('imagery:load');
Expand Down
7 changes: 6 additions & 1 deletion packages/cogify/src/cogify/cli/cli.cover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export const BasemapsCogifyCoverCommand = command({
defaultValue: () => false,
defaultValueIsSerializable: true,
}),
name: option({
type: optional(string),
long: 'name',
description: 'Define the name of the output imagery',
}),
background: option({
type: optional(string),
long: 'background',
Expand All @@ -86,7 +91,7 @@ export const BasemapsCogifyCoverCommand = command({
const mem = new ConfigProviderMemory();
metrics.start('imagery:load');
const background = args.background ? parseBackgroud(args.background) : undefined;
const cfg = await initConfigFromUrls(mem, args.paths);
const cfg = await initConfigFromUrls(mem, args.paths, args.name);
const imageryLoadTime = metrics.end('imagery:load');
if (cfg.imagery.length === 0) throw new Error('No imagery found');
const im = cfg.imagery[0];
Expand Down
2 changes: 1 addition & 1 deletion packages/config-loader/src/json/json.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class ConfigJson {
const id = ConfigId.prefix(ConfigPrefix.Imagery, imageId);
this.logger.trace({ url: url.href, imageId: id }, 'Imagery:Fetch');

const img = await initImageryFromTiffUrl(url, this.Q, this.imageryConfigCache, this.logger);
const img = await initImageryFromTiffUrl(url, this.Q, undefined, this.imageryConfigCache, this.logger);
img.id = id; // TODO could we use img.collection.id for this?

// TODO should we be overwriting the name and title when it is loaded from the STAC metadata?
Expand Down
6 changes: 4 additions & 2 deletions packages/config-loader/src/json/tiff.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export async function loadTiffsFromPaths(sourceFiles: URL[], Q: LimitFunction):
export async function initImageryFromTiffUrl(
target: URL,
Q: LimitFunction,
name?: string,
configCache?: URL,
log?: LogType,
): Promise<ConfigImageryTiff> {
Expand All @@ -364,7 +365,7 @@ export async function initImageryFromTiffUrl(
if (stac == null) log?.warn({ target: target }, 'Tiff:StacNotFound');
const params = await computeTiffSummary(target, tiffs);

const imageryName = getImageryName(target);
const imageryName = name ? name : getImageryName(target);
const title = stac?.title ?? imageryName;
const tileMatrix =
params.projection === EpsgCode.Nztm2000 ? Nztm2000QuadTms : TileMatrixSets.tryGet(params.projection);
Expand Down Expand Up @@ -436,14 +437,15 @@ export async function initImageryFromTiffUrl(
export async function initConfigFromUrls(
provider: ConfigProviderMemory,
targets: URL[],
name?: string,
concurrency = 25,
configCache?: URL,
log?: LogType,
): Promise<{ tileSet: ConfigTileSetRaster; tileSets: ConfigTileSetRaster[]; imagery: ConfigImageryTiff[] }> {
const q = pLimit(concurrency);

const imageryConfig: Promise<ConfigImageryTiff>[] = [];
for (const target of targets) imageryConfig.push(initImageryFromTiffUrl(target, q, configCache, log));
for (const target of targets) imageryConfig.push(initImageryFromTiffUrl(target, q, name, configCache, log));

const aerialTileSet: ConfigTileSetRaster = {
id: 'ts_aerial',
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function loadConfig(opts: ServerOptions, logger: LogType): Promise<
// Load the config directly from the source tiff files
if ('paths' in opts) {
const mem = new ConfigProviderMemory();
const ret = await initConfigFromUrls(mem, opts.paths, TiffLoadConcurrency, opts.configCache, logger);
const ret = await initConfigFromUrls(mem, opts.paths, undefined, TiffLoadConcurrency, opts.configCache, logger);
for (const ts of ret.tileSets) {
logger.info(
{ tileSet: ts.name, layers: ts.layers.length, outputs: ts.outputs?.map((f) => f.name) },
Expand Down

0 comments on commit bd7bbd0

Please sign in to comment.