*
* @return A string representing the value, or null if the key was not found.
*/
public String getGeoKey(final int keyID) {
final GeoKeyEntry rec = getGeoKeyRecord(keyID);
if (rec == null) {
return null;
}
if (rec.getTiffTagLocation() == 0) {
// value is stored directly in the GeoKey record
return String.valueOf(rec.getValueOffset());
}
// value is stored externally
// get the TIFF field where the data is actually stored
final IIOMetadataNode field = GeoTiffMetadataUtilities.getTiffField(rootNode, rec.getTiffTagLocation());
if (field == null) {
return null;
}
final Node sequence = field.getFirstChild();
if (sequence == null) {
return null;
}
return sequence.getNodeName().equals(GeoTiffConstants.GEOTIFF_ASCIIS_TAG) ? GeoTiffMetadataUtilities.getTiffAscii(
(IIOMetadataNode) sequence, rec.getValueOffset(), rec.getCount())
: GeoTiffMetadataUtilities.getValueAttribute(sequence.getChildNodes().item(rec.getValueOffset()));
}