@@ -65,7 +65,7 @@ export default async function createTile({
6565 >
6666 | undefined ;
6767 tile_array_types_strategy ?: "auto" | "geotiff" | "untyped" | undefined ;
68- tile_srs ?: number ;
68+ tile_srs ?: number | string ;
6969 tile_height : number ;
7070 tile_layout ?: string ;
7171 tile_resolution ?: number | number [ ] | [ number , number ] | Readonly < [ number , number ] > | undefined ;
@@ -87,11 +87,12 @@ export default async function createTile({
8787 const bbox_nums = [ Number ( bbox [ 0 ] ) , Number ( bbox [ 1 ] ) , Number ( bbox [ 2 ] ) , Number ( bbox [ 3 ] ) ] as const ;
8888 if ( debug_level >= 1 ) console . log ( "bbox_nums:" , bbox_nums ) ;
8989
90- // parse data from GeoTIFF
91- const start_get_geotiff_epsg_code = timed ? performance . now ( ) : 0 ;
92- if ( ! geotiff_srs ) geotiff_srs = await get_geotiff_epsg_code ( geotiff ) ;
93- if ( timed ) console . log ( "[geotiff-tile] getting epsg code took " + Math . round ( performance . now ( ) - start_get_geotiff_epsg_code ) + "ms" ) ;
94- if ( debug_level >= 1 ) console . log ( "geotiff_srs:" , geotiff_srs ) ;
90+ if ( ! geotiff_srs ) {
91+ const start_get_geotiff_epsg_code = timed ? performance . now ( ) : 0 ;
92+ geotiff_srs = await get_geotiff_epsg_code ( geotiff ) ;
93+ if ( timed ) console . log ( "[geotiff-tile] parsing epsg code took " + Math . round ( performance . now ( ) - start_get_geotiff_epsg_code ) + "ms" ) ;
94+ }
95+ if ( debug_level >= 1 ) console . log ( "[geotiff-tile] geotiff_srs:" , geotiff_srs ) ;
9596
9697 if ( ! geotiff_srs ) {
9798 throw new Error (
@@ -270,16 +271,21 @@ export default async function createTile({
270271 } ) ( ) ;
271272 if ( debug_level >= 2 ) console . log ( "[geotiff-tile] tile_array_types:\n" , tile_array_types ) ;
272273
273- const { data : out_data , ...extra } = await geowarp ( {
274+ const bbox_in_tile_srs_num = bbox_in_tile_srs . map ( ( it : number | string ) => Number ( it ) ) ;
275+
276+ const out_srs = tile_srs ;
277+
278+ const geowarp_options = {
274279 cutline,
275280 cutline_srs,
276281 cutline_forward : cutline ? proj4fullyloaded ( "EPSG:" + cutline_srs , "EPSG:" + tile_srs ) . forward : undefined ,
277282 debug_level : debug_level > 1 ? debug_level - 1 : 0 ,
278283 forward,
279284 inverse,
280285 in_data : readResult . data ,
281- in_bbox : readResult . bbox ,
282- in_geotransform : readResult . geotransform ,
286+ in_bbox : out_srs === "simple" ? readResult . simple_bbox : readResult . bbox ,
287+ // in_geotransform is only necessary if using skewed or rotated in_data
288+ in_geotransform : out_srs === "simple" ? null : readResult . geotransform ,
283289 in_layout : "[band][row,column]" ,
284290 in_no_data : get_geotiff_no_data_number ( image ) ,
285291 in_srs : geotiff_srs ,
@@ -288,19 +294,22 @@ export default async function createTile({
288294 method,
289295 // out_bands: should use if repeated bands in output
290296 out_array_types : tile_array_types ,
291- out_bbox : bbox_in_tile_srs . map ( ( it : number | string ) => Number ( it ) ) ,
297+ out_bbox : bbox_in_tile_srs_num ,
292298 out_height : tile_height ,
293299 out_layout : tile_layout ,
294300 out_pixel_depth : pixel_depth ,
295301 out_resolution : typeof tile_resolution === "number" ? [ tile_resolution , tile_resolution ] : tile_resolution ,
296- out_srs : tile_srs ,
302+ out_srs,
297303 out_width : tile_width ,
298304 round,
299305 theoretical_max,
300306 theoretical_min,
301307 expr : _expr ,
302308 turbo
303- } ) ;
309+ } ;
310+ if ( debug_level >= 2 ) console . log ( "[geotiff-tile] geowarp_options:\n" , geowarp_options ) ;
311+
312+ const { data : out_data , ...extra } = await geowarp ( geowarp_options ) ;
304313 if ( timed ) console . log ( "[geotiff-tile] geowarp took " + Math . round ( performance . now ( ) - start_geowarp ) + "ms" ) ;
305314
306315 if ( timed ) console . log ( "[geotiff-tile] took " + Math . round ( performance . now ( ) - start_time ) + "ms" ) ;
0 commit comments