diff --git a/src/main/java/util/URITools.java b/src/main/java/util/URITools.java index a377f04b..fd2d8647 100644 --- a/src/main/java/util/URITools.java +++ b/src/main/java/util/URITools.java @@ -252,12 +252,16 @@ else if ( URITools.isS3( xmlURI ) || URITools.isGC( xmlURI ) ) public static N5Writer instantiateN5Writer( final StorageFormat format, final URI uri ) { + final GsonBuilder builder = new GsonBuilder().registerTypeAdapter( + CoordinateTransformation.class, + new CoordinateTransformationAdapter() ); + if ( URITools.isFile( uri ) ) { if ( format.equals( StorageFormat.N5 )) return new N5FSWriter( URITools.fromURI( uri ) ); else if ( format.equals( StorageFormat.ZARR )) - return new N5ZarrWriter( URITools.fromURI( uri ) ); + return new N5ZarrWriter( URITools.fromURI( uri ), builder ); else if ( format.equals( StorageFormat.HDF5 )) return new N5HDF5Writer( URITools.fromURI( uri ) ); else @@ -267,10 +271,6 @@ else if ( format.equals( StorageFormat.HDF5 )) { N5Writer n5w; - final GsonBuilder builder = new GsonBuilder().registerTypeAdapter( - CoordinateTransformation.class, - new CoordinateTransformationAdapter() ); - try { //System.out.println( "Trying writing with credentials ..." ); @@ -294,12 +294,16 @@ else if ( format.equals( StorageFormat.HDF5 )) public static N5Reader instantiateN5Reader( final StorageFormat format, final URI uri ) { + final GsonBuilder builder = new GsonBuilder().registerTypeAdapter( + CoordinateTransformation.class, + new CoordinateTransformationAdapter() ); + if ( URITools.isFile( uri ) ) { if ( format.equals( StorageFormat.N5 )) return new N5FSReader( URITools.fromURI( uri ) ); else if ( format.equals( StorageFormat.ZARR )) - return new N5ZarrReader( URITools.fromURI( uri ) ); + return new N5ZarrReader( URITools.fromURI( uri ), builder ); else throw new RuntimeException( "Format: " + format + " not supported." ); } @@ -307,10 +311,6 @@ else if ( format.equals( StorageFormat.ZARR )) { N5Reader n5r; - final GsonBuilder builder = new GsonBuilder().registerTypeAdapter( - CoordinateTransformation.class, - new CoordinateTransformationAdapter() ); - try { //System.out.println( "Trying reading with credentials ..." );