Class GeoTiffIIOMetadataDecoder


  • public final class GeoTiffIIOMetadataDecoder
    extends Object
    This class provides an abstraction from the details of TIFF data access for the purpose of retrieving GeoTIFFWritingUtilities metadata from an image.

    All of the GeoKey values are included here as constants, and the portions of the GeoTIFFWritingUtilities specification pertaining to each have been copied for easy access.

    The majority of the possible GeoKey values and their meanings are NOT reproduced here. Only the most important GeoKey code values have been copied, for others see the specification.

    Convenience methods have been included to retrieve the various TIFFFields that are not part of the GeoKey directory, such as the Model Transformation and Model TiePoints. Retrieving a GeoKey from the GeoKey directory is a bit more specialized and requires knowledge of the correct key code.

    Making use of the geographic metadata still requires some basic understanding of the GeoKey values that is not provided here.

    For more information see the GeoTIFFWritingUtilities specification at http://www.remotesensing.org/geotiff/spec/geotiffhome.html

    Author:
    Mike Nidel, Simone Giannecchini, GeoSolutions
    • Constructor Detail

      • GeoTiffIIOMetadataDecoder

        public GeoTiffIIOMetadataDecoder​(IIOMetadata imageMetadata)
        The constructor builds a metadata adapter for the image metadata root IIOMetadataNode.
        Parameters:
        imageMetadata - The image metadata
    • Method Detail

      • getGeoKeyDirectoryVersion

        public int getGeoKeyDirectoryVersion()
        Gets the version of the GeoKey directory. This is typically a value of 1 and can be used to check that the data is of a valid format.
      • getGeoKeyRevision

        public int getGeoKeyRevision()
        Gets the revision number of the GeoKeys in this metadata.
      • getGeoKeyMinorRevision

        public int getGeoKeyMinorRevision()
        Gets the minor revision number of the GeoKeys in this metadata.
      • getNumGeoKeys

        public int getNumGeoKeys()
        Gets the number of GeoKeys in the geokeys directory.
      • getGeoKey

        public String getGeoKey​(int keyID)
        Gets a GeoKey value as a String. This implementation should be "quiet" in the sense that it should not throw any exceptions but only return null in the event that the data organization is not as expected.
        Parameters:
        keyID - The numeric ID of the GeoKey
        Returns:
        A string representing the value, or null if the key was not found.
      • getGeoKeyRecord

        public GeoKeyEntry getGeoKeyRecord​(int keyID)
        Gets a record containing the four TIFFShort values for a geokey entry. For more information see the GeoTIFFWritingUtilities specification.
        Returns:
        the record with the given keyID, or null if none is found
      • getModelPixelScales

        public PixelScale getModelPixelScales()
        Gets the model pixel scales from the correct TIFFField
      • getModelTiePoints

        public TiePoint[] getModelTiePoints()
        Gets the model tie points from the appropriate TIFFField
        Returns:
        the tie points, or null if not found
      • getNoData

        public double getNoData()
        Gets the noData from the related TIFFField. Check metadata has noData using hasNoData() method before calling this method.
        Returns:
        the noData value or Double.NaN in case of unable to get noData.
      • hasTiePoints

        public boolean hasTiePoints()
        Tells me if the underlying IIOMetadata contains ModelTiepointTag tag for TiePoint.
        Returns:
        true if ModelTiepointTag is present, false otherwise.
      • hasPixelScales

        public boolean hasPixelScales()
        Tells me if the underlying IIOMetadata contains ModelTiepointTag tag for TiePoint.
        Returns:
        true if ModelTiepointTag is present, false otherwise.
      • getModelTransformation

        public AffineTransform getModelTransformation()
        Gets the model tie points from the appropriate TIFFField

        Attention, for the moment we support only 2D baseline transformations.

        Returns:
        the transformation, or null if not found
      • hasModelTrasformation

        public boolean hasModelTrasformation()
        Tells me if the underlying IIOMetadata contains ModelTransformationTag tag for AffineTransform that map from Raster Space to World Space.
        Returns:
        true if ModelTransformationTag is present, false otherwise.
      • hasGeoKey

        public boolean hasGeoKey()
        Return true if the geokey directory is present, false otherwise. In case no geokey dir is present no CRS can be constructed from this set of metadata.

        A prj can be used otherwise.

        Returns:
        true if the geokey directory is present, false otherwise.
      • getAsciiTIFFTag

        public String getAsciiTIFFTag​(String tagID)
        Returns the value of an ASCII TIFFTag referred by tagID.
        Returns:
        the tag value as a String, null if not available.