This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 270416850b5bdc9b3bcd4dcddbe9bb9760bbfa91
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue May 24 18:46:58 2022 +0200

    More tolerant parsing of NaN value for GDAL_NODATA in TIFF file.
    It is sometime written as "nan" (all lower case).
---
 .../src/main/java/org/apache/sis/storage/geotiff/Type.java         | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java 
b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
index 893b0e51cc..dce49e9c21 100644
--- a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
+++ b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
@@ -388,8 +388,11 @@ enum Type {
         }
 
         @Override public double readDouble(final ChannelDataInput input, final 
long count) throws IOException {
-            final String text = readString(input, count, false);
-            return (text != null) ? Double.parseDouble(text) : Double.NaN;
+            String text = readString(input, count, false);
+            if (text == null || (text = text.trim()).isEmpty() || 
text.equalsIgnoreCase("NaN")) {
+                return Double.NaN;
+            }
+            return Double.parseDouble(text);
         }
 
         @Override public Object readArray(final ChannelDataInput input, final 
int count) throws IOException {

Reply via email to