@@ -3,14 +3,14 @@ import { fsa, LogType, Url, UrlArrayJsonFile } from '@basemaps/shared';
33import { CliId , CliInfo } from '@basemaps/shared/build/cli/info.js' ;
44import { getLogger , logArguments } from '@basemaps/shared/build/cli/log.js' ;
55import { command , option , string } from 'cmd-ts' ;
6+ import { mkdirSync } from 'fs' ;
67import { basename } from 'path' ;
78import { createGzip } from 'zlib' ;
89
910import { createStacFiles } from '../stac.js' ;
1011import { toTarIndex } from '../transform/covt.js' ;
1112import { toTarTiles } from '../transform/mbtiles.to.ttiles.js' ;
1213import { tileJoin } from '../transform/tippecanoe.js' ;
13- import { mkdirSync } from 'fs' ;
1414
1515async 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' ) ;
0 commit comments