New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle numerical metadata fields stored as strings in GeoTIFFS #311
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PR Alex. But it seems that the files which shall be read are not following the GeoTIFF specification. Who is the provider of the data? Can these files be read in other applications?
double[] tiePoints; | ||
try{ | ||
tiePoints = tiePointsField.getAsDoubles(); | ||
}catch (Exception e){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this should result in an IOException or IllegalFileFormatException. The specification requires Double values, not a String. The same for the other modifcation in this file and in TiffFileInfo.
If the changes are really necessary, these modifications can be extracted to a new method getAsDoubles(TIFFField).
try{ | ||
sb.append(tiffField.getValueAsString(i)); | ||
} catch (Exception e){ | ||
sb.append("99999"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theads provides wrong information to the user. Assuming that the value is 99999 when it could actually be anything.
Again, we have a format issue here and it might be better to throw an exception. If this is wrong, what else might be wrong with the file?
Instead, of "99999" something like "READERROR", OR "UNKNOWN" would be better.
Now, I have seen the issue in JIRA (https://senbox.atlassian.net/browse/SNAP-1500) and that it can be read by GDAL. But still, it doesn't follow the specs. Who is providing this data? |
I've checked the file you have provided. I can read it without the modifications. |
This change allows for GeoTIFFS that have numerical metadata stored as string (and numerical arrays stored as space delimited strings) to be read in properly by SNAP.