Skip to content

Commit 1f84436

Browse files
committed
Minior fix
1 parent 397317f commit 1f84436

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,26 @@ export const JoinCommand = command({
103103
args: JoinArgs,
104104
async handler(args) {
105105
const logger = getLogger(this, args, 'cli-vector');
106-
const outputPath = `tmp/join/`;
106+
const outputPath = `/tmp/join/`;
107107
const tileMatrix = TileMatrixSets.find(args.tileMatrix);
108108
if (tileMatrix == null) throw new Error(`Tile matrix ${args.tileMatrix} is not supported`);
109109
const bucketPath = new URL(`vector/${tileMatrix.projection.code}/`, args.target);
110110
const filePaths = await download(args.fromFile, outputPath, logger);
111111

112112
// Mbtiles output path to be string type path to avoid issues with tippecanoe and better-sqlite3
113-
const outputMbtiles = `${outputPath}/${args.filename}.mbtiles`;
113+
const outputMbtiles = fsa.toUrl(`${outputPath}${args.filename}.mbtiles`);
114114
logger.info({ files: filePaths.length, outputMbtiles }, 'JoinMbtiles: Start');
115-
await tileJoin(filePaths, outputMbtiles, logger);
115+
await tileJoin(filePaths, outputMbtiles.pathname, logger);
116116
logger.info({ files: filePaths.length, outputMbtiles }, 'JoinMbtiles: End');
117117

118118
const outputCotar = fsa.toUrl(`${outputPath}/${args.filename}.tar.co`);
119119
logger.info({ mbtiles: outputMbtiles, outputCotar }, 'ToTartTiles: Start');
120-
await toTarTiles(outputMbtiles, outputCotar, logger);
120+
await toTarTiles(outputMbtiles.pathname, outputCotar.pathname, logger);
121121
logger.info({ mbtiles: outputMbtiles, outputCotar }, 'ToTartTiles: End');
122122

123123
const outputIndex = fsa.toUrl(`${outputPath}/${args.filename}.tar.index`);
124124
logger.info({ cotar: outputCotar, outputIndex }, 'toTarIndex: Start');
125-
await toTarIndex(outputCotar, outputIndex, logger);
125+
await toTarIndex(outputCotar.pathname, outputIndex.pathname, logger);
126126
logger.info({ cotar: outputCotar, outputIndex }, 'toTarIndex: End');
127127

128128
logger.info({ target: bucketPath, tileMatrix: tileMatrix.identifier }, 'CreateStac: Start');
@@ -131,7 +131,7 @@ export const JoinCommand = command({
131131

132132
// Upload output to s3
133133
logger.info({ target: bucketPath, tileMatrix: tileMatrix.identifier }, 'Upload: Start');
134-
await upload(fsa.toUrl(outputMbtiles), bucketPath, logger);
134+
await upload(outputMbtiles, bucketPath, logger);
135135
await upload(outputCotar, bucketPath, logger);
136136
await upload(outputIndex, bucketPath, logger);
137137
// Upload stac Files

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { fsa, LogType, SourceMemory, urlToString } from '@basemaps/shared';
1+
import { fsa, LogType, SourceMemory } from '@basemaps/shared';
22
import { CotarIndexBuilder, CotarIndexOptions, TarReader } from '@cotar/builder';
33
import { CotarIndex } from '@cotar/core';
44
import { promises as fs } from 'fs';
55

66
/**
77
* Create index for the COVT tar file
88
*/
9-
export async function toTarIndex(input: URL, output: URL, logger: LogType): Promise<URL> {
10-
logger.info({ output: output.href }, 'Cotar.Index:Start');
9+
export async function toTarIndex(input: string, output: string, logger: LogType): Promise<string> {
10+
logger.info({ output: output }, 'Cotar.Index:Start');
1111

1212
const fd = await fs.open(input, 'r');
1313

@@ -16,11 +16,11 @@ export async function toTarIndex(input: URL, output: URL, logger: LogType): Prom
1616

1717
const index = await CotarIndex.create(new SourceMemory('index', buffer));
1818
await TarReader.validate(fd, index);
19-
await fs.writeFile(urlToString(output), buffer);
20-
await fs.appendFile(urlToString(input), buffer);
19+
await fs.writeFile(output, buffer);
20+
await fs.appendFile(input, buffer);
2121

2222
await fd.close();
23-
if (!(await fsa.exists(output))) throw new Error('Error - Cotar.Index creation Failure.');
23+
if (!(await fsa.exists(fsa.toUrl(output)))) throw new Error('Error - Cotar.Index creation Failure.');
2424

2525
logger.info({ index, count }, 'Cotar.Index:Done');
2626
return output;

packages/cli-vector/src/transform/mbtiles.to.ttiles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function* readMbTiles(
3333
return null;
3434
}
3535

36-
export async function toTarTiles(input: string, output: URL, logger: LogType, limit = -1): Promise<void> {
36+
export async function toTarTiles(input: string, output: string, logger: LogType, limit = -1): Promise<void> {
3737
const packer = tar.pack();
3838
const startTime = Date.now();
3939
let writeCount = 0;
@@ -43,7 +43,7 @@ export async function toTarTiles(input: string, output: URL, logger: LogType, li
4343

4444
let startTileTime = Date.now();
4545
for await (const { tile, index, total } of readMbTiles(input, limit, logger)) {
46-
if (index === 0) logger.info({ path: output.href, count: total }, 'Covt.Tar:Start');
46+
if (index === 0) logger.info({ path: output, count: total }, 'Covt.Tar:Start');
4747

4848
const z = tile.zoom_level;
4949
const x = tile.tile_column;
@@ -64,5 +64,5 @@ export async function toTarTiles(input: string, output: URL, logger: LogType, li
6464
logger.debug('Covt.Tar:Finalize');
6565
packer.finalize();
6666
await writeProm;
67-
logger.info({ path: output.href, count: writeCount, duration: Date.now() - startTime }, 'Covt.Tar:Done');
67+
logger.info({ path: output, count: writeCount, duration: Date.now() - startTime }, 'Covt.Tar:Done');
6868
}

0 commit comments

Comments
 (0)