Skip to content

Commit

Permalink
registerTypeAdapter for OME-ZARR also for file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanPreibisch committed Nov 8, 2024
1 parent 61bff48 commit 5b02d32
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/util/URITools.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ..." );
Expand All @@ -294,23 +294,23 @@ 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." );
}
else
{
N5Reader n5r;

final GsonBuilder builder = new GsonBuilder().registerTypeAdapter(
CoordinateTransformation.class,
new CoordinateTransformationAdapter() );

try
{
//System.out.println( "Trying reading with credentials ..." );
Expand Down

0 comments on commit 5b02d32

Please sign in to comment.