@@ -17,6 +17,8 @@ import reprojectBoundingBox from "reproject-bbox";
1717// @ts -ignore
1818import tilebelt from "@mapbox/tilebelt" ;
1919// @ts -ignore
20+ import { transform } from "xdim" ;
21+ // @ts -ignore
2022import writeImage from "write-image" ;
2123
2224import geowarp from "./geowarp" ;
@@ -301,6 +303,8 @@ const runTileTests = async ({
301303
302304[
303305 {
306+ // note: the left edge of the tile is actually west of the left edge of the geotiff,
307+ // thus the resulting image should appear to have a black stripe on the left edge
304308 x : 40 ,
305309 y : 96 ,
306310 z : 8 ,
@@ -422,3 +426,34 @@ const runTileTests = async ({
422426 eq ( result . read_bands , [ 0 , 1 ] ) ;
423427 } ) ;
424428} ) ;
429+
430+ test ( "georaster-layer-for-leaflet v3 issues" , async ( { eq } ) => {
431+ const filename = "example_4326.tif" ;
432+ const filepath = resolve ( __dirname , "./test-data" , filename ) ;
433+ const geotiff = await fromFile ( filepath ) ;
434+ const image = await geotiff . getImage ( 0 ) ;
435+ const rasters = await image . readRasters ( ) ;
436+ const { inverse, forward } = proj4 ( "EPSG:4326" , "EPSG:3857" ) ;
437+ const in_height = image . getHeight ( ) ;
438+ const in_width = image . getWidth ( ) ;
439+ const in_data = transform ( { data : rasters , from : "[band][row,column]" , to : "[band][row][column]" , sizes : { band : rasters . length , row : in_height , column : in_width } } ) . data ;
440+ geowarp ( {
441+ debug_level : 0 ,
442+ forward,
443+ inverse,
444+ in_data,
445+ in_bbox : image . getBoundingBox ( ) ,
446+ in_layout : "[band][row][column]" ,
447+ in_srs : 4326 ,
448+ in_width,
449+ in_height,
450+ out_array_types : [ "Array" , "Array" , "Array" ] ,
451+ out_bbox : [ 149.99999998948465 , 49.99999988790859 , 309.99999995583534 , 159.99999987996836 ] ,
452+ out_layout : "[band][row][column]" ,
453+ out_srs : 3857 ,
454+ out_height : 256 ,
455+ out_width : 256 ,
456+ method : "near" ,
457+ round : false
458+ } ) ;
459+ } ) ;
0 commit comments