geosolutions-it / imageio-ext

Additional plugins and extension for the standard Java ImageIO library
Other
144 stars 83 forks source link

Add Python styled Float NoData Infinity support #279

Closed pomadchin closed 11 months ago

pomadchin commented 2 years ago

This PR adds support of the python styled -inf / inf nodata values support into the imagio-ext. Right, only the java styled NoData is supported.

The test file is generated via the following gdal command:

gdal_create -of GTiff -outsize 1 1 -bands 1 -ot Float32 -a_nodata -inf float32_neg_infinity_nodata.tif

The error output without this PR on the test file:

SEVERE: For input string: "-inf"
java.lang.NumberFormatException: For input string: "-inf"
  at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
  at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
  at java.base/java.lang.Double.parseDouble(Double.java:651)
  at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.initializeFromMetadata(TIFFImageReader.java:1298)
  at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.seekToImage(TIFFImageReader.java:835)
  at it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.getImageMetadata(TIFFImageReader.java:1450)

I noticed this one when tried to generate a file via for a similar geotools PR https://github.com/geotools/geotools/pull/3992