org.geotools.image.io.metadata
Class GeographicMetadata

java.lang.Object
  extended by javax.imageio.metadata.IIOMetadata
      extended by org.geotools.image.io.metadata.GeographicMetadata
Direct Known Subclasses:
NetcdfMetadata

public class GeographicMetadata
extends javax.imageio.metadata.IIOMetadata

Geographic informations encoded in image as metadata. This class provides various methods for reading and writting attribute values in IIOMetadataNode according the geographic metadata format. If some inconsistency are found while reading (for example if the coordinate system dimension doesn't match the envelope dimension), then the default implementation logs a warning. We do not throw an exception because minor errors are not uncommon in geographic data, and we want to process the data on a "best effort" basis. However because every warnings are logged through the warningOccurred(java.util.logging.LogRecord) method, subclasses can override this method if they want treat some warnings as fatal errors.

Since:
2.4
Version:
$Id: GeographicMetadata.java 31445 2008-09-07 18:14:23Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
 
Fields inherited from class javax.imageio.metadata.IIOMetadata
controller, defaultController, extraMetadataFormatClassNames, extraMetadataFormatNames, nativeMetadataFormatClassName, nativeMetadataFormatName, standardFormatSupported
 
Constructor Summary
GeographicMetadata()
          Creates a default metadata instance.
GeographicMetadata(boolean standardMetadataFormatSupported, java.lang.String nativeMetadataFormatName, java.lang.String nativeMetadataFormatClassName, java.lang.String[] extraMetadataFormatNames, java.lang.String[] extraMetadataFormatClassNames)
          Constructs a geographic metadata instance with the given format names and format class names.
GeographicMetadata(javax.imageio.ImageReader reader)
          Creates a default metadata instance for the given reader.
GeographicMetadata(javax.imageio.ImageWriter writer)
          Creates a default metadata instance for the given writer.
 
Method Summary
 Band addBand(java.lang.String name)
          Creates a new band and returns it.
protected
<T> LoggedFormat<T>
createLoggedFormat(java.text.Format format, java.lang.Class<T> type)
          Wraps the specified format in order to either parse fully a string, or log a warning.
 org.w3c.dom.Node getAsTree(java.lang.String formatName)
          Returns the root of a tree of metadata contained within this object according to the conventions defined by a given metadata format.
 Band getBand(int bandIndex)
          Returns the band at the specified index.
 ImageGeometry getGeometry()
          Returns the grid geometry.
 java.util.Locale getLocale()
          Returns the language to use when logging a warning, or null if none has been set.
 int getNumBands()
          Returns the number of bands in the coverage.
 ImageReferencing getReferencing()
          Returns the grid referencing.
 java.lang.String getSampleType()
          Returns the sample type (typically or ), or null if none.
 boolean isReadOnly()
          Returns false since this node support some write operations.
 void mergeTree(javax.imageio.metadata.IIOMetadata metadata)
          Alters the internal state of this metadata from a tree defined by the specified metadata.
 void mergeTree(java.lang.String formatName, org.w3c.dom.Node root)
          Alters the internal state of this metadata from a tree whose syntax is defined by the given metadata format.
 void reset()
          Resets all the data stored in this object to default values.
 void setSampleType(java.lang.String type)
          Set the sample type for all bands.
 java.lang.String toString()
          Returns a string representation of this metadata, mostly for debugging purpose.
protected  void warningOccurred(java.util.logging.LogRecord record)
          Invoked when a warning occured.
 
Methods inherited from class javax.imageio.metadata.IIOMetadata
activateController, getController, getDefaultController, getExtraMetadataFormatNames, getMetadataFormat, getMetadataFormatNames, getNativeMetadataFormatName, getStandardChromaNode, getStandardCompressionNode, getStandardDataNode, getStandardDimensionNode, getStandardDocumentNode, getStandardTextNode, getStandardTileNode, getStandardTransparencyNode, getStandardTree, hasController, isStandardMetadataFormatSupported, setController, setFromTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeographicMetadata

public GeographicMetadata()
Creates a default metadata instance. This constructor defines no standard or native format. The only format defined is the geographic one.


GeographicMetadata

public GeographicMetadata(javax.imageio.ImageReader reader)
Creates a default metadata instance for the given reader.

Parameters:
reader - The source image reader, or null if none.

GeographicMetadata

public GeographicMetadata(javax.imageio.ImageWriter writer)
Creates a default metadata instance for the given writer.

Parameters:
writer - The target image writer, or null if none.

GeographicMetadata

public GeographicMetadata(boolean standardMetadataFormatSupported,
                          java.lang.String nativeMetadataFormatName,
                          java.lang.String nativeMetadataFormatClassName,
                          java.lang.String[] extraMetadataFormatNames,
                          java.lang.String[] extraMetadataFormatClassNames)
Constructs a geographic metadata instance with the given format names and format class names. This constructor passes the arguments to the super-class constructor unchanged.

Parameters:
standardMetadataFormatSupported - true if this object can return or accept a DOM tree using the standard metadata format.
nativeMetadataFormatName - The name of the native metadata, or null if none.
nativeMetadataFormatClassName - The name of the class of the native metadata format, or null if none.
extraMetadataFormatNames - Additional formats supported by this object, or null if none.
extraMetadataFormatClassNames - The class names of any additional formats supported by this object, or null if none.
Method Detail

isReadOnly

public boolean isReadOnly()
Returns false since this node support some write operations.

Specified by:
isReadOnly in class javax.imageio.metadata.IIOMetadata

getReferencing

public ImageReferencing getReferencing()
Returns the grid referencing.


getGeometry

public ImageGeometry getGeometry()
Returns the grid geometry.


getSampleType

public java.lang.String getSampleType()
Returns the sample type (typically or ), or null if none. This type applies to all bands.


setSampleType

public void setSampleType(java.lang.String type)
Set the sample type for all bands. Valid types include and .

Parameters:
type - The sample type, or null if none.

getNumBands

public int getNumBands()
Returns the number of bands in the coverage.


getBand

public Band getBand(int bandIndex)
             throws java.lang.IndexOutOfBoundsException
Returns the band at the specified index.

Parameters:
bandIndex - the band index, ranging from 0 inclusive to getNumBands() exclusive.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of bounds.

addBand

public Band addBand(java.lang.String name)
Creates a new band and returns it.

Parameters:
name - The name for the new band.

getAsTree

public org.w3c.dom.Node getAsTree(java.lang.String formatName)
                           throws java.lang.IllegalArgumentException
Returns the root of a tree of metadata contained within this object according to the conventions defined by a given metadata format.

Specified by:
getAsTree in class javax.imageio.metadata.IIOMetadata
Parameters:
formatName - the desired metadata format.
Returns:
The node forming the root of metadata tree.
Throws:
java.lang.IllegalArgumentException - if the format name is null or is not one of the names returned by IIOMetadata.getMetadataFormatNames().

mergeTree

public void mergeTree(java.lang.String formatName,
                      org.w3c.dom.Node root)
               throws javax.imageio.metadata.IIOInvalidTreeException
Alters the internal state of this metadata from a tree whose syntax is defined by the given metadata format. The default implementation simply replaces all existing state with the contents of the given tree.

Specified by:
mergeTree in class javax.imageio.metadata.IIOMetadata
Parameters:
formatName - The desired metadata format.
root - An XML DOM Node object forming the root of a tree.
Throws:
javax.imageio.metadata.IIOInvalidTreeException

mergeTree

public void mergeTree(javax.imageio.metadata.IIOMetadata metadata)
               throws javax.imageio.metadata.IIOInvalidTreeException
Alters the internal state of this metadata from a tree defined by the specified metadata. The default implementation expects the format.

Parameters:
metadata - The metadata to merge to this object.
Throws:
javax.imageio.metadata.IIOInvalidTreeException - If the metadata can not be merged.

reset

public void reset()
Resets all the data stored in this object to default values.

Specified by:
reset in class javax.imageio.metadata.IIOMetadata

getLocale

public java.util.Locale getLocale()
Returns the language to use when logging a warning, or null if none has been set. The default implementation delegates to ImageReader.getLocale() or ImageWriter.getLocale() if possible, or returns null otherwise.


warningOccurred

protected void warningOccurred(java.util.logging.LogRecord record)
Invoked when a warning occured. This method is invoked when some inconsistency has been detected in the geographic metadata. The default implementation delegates to GeographicImageReader.warningOccurred(java.util.logging.LogRecord) if possible, or send the record to the "org.geotools.image.io.metadata" logger otherwise.

Subclasses may override this method if more processing is wanted, or for throwing exception if some warnings should be considered as fatal errors.


createLoggedFormat

protected <T> LoggedFormat<T> createLoggedFormat(java.text.Format format,
                                                 java.lang.Class<T> type)
Wraps the specified format in order to either parse fully a string, or log a warning.

Parameters:
format - The format to use for parsing and formatting.
type - The expected type of parsed values.

toString

public java.lang.String toString()
Returns a string representation of this metadata, mostly for debugging purpose.

Overrides:
toString in class java.lang.Object


Copyright © 1996-2010 Geotools. All Rights Reserved.