Skip to content

Commit 0ab464c

Browse files
committed
Fix the URL paths
1 parent 0039fa2 commit 0ab464c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/cli-vector/src/cli/cli.join.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { fsa, LogType, Url, UrlArrayJsonFile } from '@basemaps/shared';
33
import { CliId, CliInfo } from '@basemaps/shared/build/cli/info.js';
44
import { getLogger, logArguments } from '@basemaps/shared/build/cli/log.js';
55
import { command, option, string } from 'cmd-ts';
6+
import { mkdirSync } from 'fs';
67
import { basename } from 'path';
78
import { createGzip } from 'zlib';
89

910
import { createStacFiles } from '../stac.js';
1011
import { toTarIndex } from '../transform/covt.js';
1112
import { toTarTiles } from '../transform/mbtiles.to.ttiles.js';
1213
import { tileJoin } from '../transform/tippecanoe.js';
13-
import { mkdirSync } from 'fs';
1414

1515
async function download(filePaths: URL[], outputPath: string, logger: LogType): Promise<URL[]> {
1616
const paths: URL[] = [];
@@ -52,8 +52,9 @@ async function upload(file: URL, bucketPath: URL, logger: LogType): Promise<URL>
5252
}
5353

5454
// Upload to s3 or copy to local
55-
let path = new URL(`/topographic/${CliId}/`, bucketPath);
56-
if (path.protocol === 'file:') mkdirSync(path);
55+
let path = new URL(`topographic/${CliId}/`, bucketPath);
56+
logger.info({ file: file, path: path }, 'Load:Path');
57+
if (path.protocol === 'file:') mkdirSync(path, { recursive: true });
5758
if (filename.endsWith('catalog.json')) path = new URL(filename, bucketPath); // Upload catalog to root directory
5859
await fsa.write(path, stream);
5960
logger.info({ file: file, path: path }, 'Load:Finish');
@@ -103,6 +104,9 @@ export const JoinCommand = command({
103104
async handler(args) {
104105
const logger = getLogger(this, args, 'cli-vector');
105106
const outputPath = `tmp/join/`;
107+
const tileMatrix = TileMatrixSets.find(args.tileMatrix);
108+
if (tileMatrix == null) throw new Error(`Tile matrix ${args.tileMatrix} is not supported`);
109+
const bucketPath = new URL(`vector/${tileMatrix.projection.code}/`, args.target);
106110
const filePaths = await download(args.fromFile, outputPath, logger);
107111

108112
const outputMbtiles = fsa.toUrl(`${outputPath}/${args.filename}.mbtiles`);
@@ -120,9 +124,6 @@ export const JoinCommand = command({
120124
await toTarIndex(outputCotar, outputIndex, logger);
121125
logger.info({ cotar: outputCotar, outputIndex }, 'toTarIndex: End');
122126

123-
const tileMatrix = TileMatrixSets.find(args.tileMatrix);
124-
if (tileMatrix == null) throw new Error(`Tile matrix ${args.tileMatrix} is not supported`);
125-
const bucketPath = new URL(`/vector/${tileMatrix.projection.code}/`, args.target);
126127
logger.info({ target: bucketPath, tileMatrix: tileMatrix.identifier }, 'CreateStac: Start');
127128
const stacFiles = await createStacFiles(args.fromFile, bucketPath, args.filename, tileMatrix, args.title, logger);
128129
logger.info({ cotar: outputCotar, outputIndex }, 'CreateStac: End');

packages/cli-vector/src/transform/tippecanoe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function tileJoin(inputs: URL[], output: URL, logger: LogType): Pro
6363
cmd.mount(dirname(output.pathname));
6464

6565
cmd.args.push('-pk');
66-
cmd.args.push('-o', output.href);
66+
cmd.args.push('-o', output.pathname);
6767
for (const input of inputs) {
6868
if (input.href.endsWith('mbtiles')) {
6969
cmd.mount(dirname(input.pathname));

0 commit comments

Comments
 (0)