com.bbn.openmap.dataAccess.image.geotiff
Class GeoTIFFFile

java.lang.Object
  extended by com.bbn.openmap.dataAccess.image.geotiff.GeoTIFFFile

public class GeoTIFFFile
extends java.lang.Object

GeoTIFFFile is the main object for loading a GeoTIFF image file. Relies on JAI being installed on the machine, because it needs the TIFF capabilities of that package. You can ask for the BufferedImage representing the image in the file, or ask for specific tag information. The GeoTIFFModelFactory can be used to create specific geo-referenced ImageTile objects for display in OpenMap.

Author:
dietrick

Field Summary
protected  java.net.URL fileURL
           
protected  org.libtiff.jai.codec.XTIFFField[] geoKeys
           
protected  org.geotiff.image.jai.GeoTIFFDirectory gtfDirectory
           
static java.util.logging.Logger logger
           
 
Constructor Summary
GeoTIFFFile(java.lang.String filePath)
           
GeoTIFFFile(java.net.URL fileURL)
           
 
Method Summary
 void dumpTags(org.libtiff.jai.codec.XTIFFField[] gtfFields)
          Prints out the values of the XTIFF Fields provided to it.
 java.awt.image.BufferedImage getBufferedImage()
          Uses the XTIFF Image Decoder to decode as rendered image, creating a new Buffered Image.
protected  int getFieldIntValue(int tiffCode)
          Helper function for taking a code from the TIFF spec, and getting the field value as a single int.
 org.libtiff.jai.codec.XTIFFField getFieldWithTag(int tagNumber)
          Helper function designed to make it easier to get the XTIFF field for a given tag number.
protected  org.libtiff.jai.codec.XTIFFField getGeoFieldForCode(int code)
          Searches for tag in geo keys.
 int getGeographicType()
           
protected  int getGeoKeyIntValue(int codeFromKeyRegistry)
          Helper function for taking a code from the Geo KeyRegistry, and getting the field value as a single int.
 org.libtiff.jai.codec.XTIFFField[] getGeoKeys()
          Ask specifically for the array of XTIFFFields pertaining to georeferencing.
 org.geotiff.image.jai.GeoTIFFDirectory getGtfDirectory()
          Very handy class from the file.
 ImageTile getImageTile()
          Uses a GeoTIFFModelFactory to create a georeferenced ImageTile image.
 ImageTile getImageTile(GeoTIFFImageReader id, ImageTile.Cache cache)
           
 int getModelType()
          Determine which class of model space coordinates are most natural for this dataset:Geographic, Geocentric, or Projected Coordinate System.
 int getProjectedCSType()
           Here is a summary of the index ranges for the various coding systems used by EPSG in their tables.
 int getRasterType()
          Pixels derived from scanners or other optical devices represent areas, and most commonly will use the RasterPixelIsArea coordinate system.
 java.lang.String getStringOfType(int type)
          Helper function that coverts type codes to string representation.
 void init(java.net.URL fileURL)
           
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static java.util.logging.Logger logger

gtfDirectory

protected org.geotiff.image.jai.GeoTIFFDirectory gtfDirectory

geoKeys

protected org.libtiff.jai.codec.XTIFFField[] geoKeys

fileURL

protected java.net.URL fileURL
Constructor Detail

GeoTIFFFile

public GeoTIFFFile(java.lang.String filePath)
            throws java.net.MalformedURLException,
                   java.io.IOException,
                   java.lang.IllegalArgumentException
Throws:
java.net.MalformedURLException
java.io.IOException
java.lang.IllegalArgumentException

GeoTIFFFile

public GeoTIFFFile(java.net.URL fileURL)
            throws java.net.MalformedURLException,
                   java.io.IOException,
                   java.lang.IllegalArgumentException
Throws:
java.net.MalformedURLException
java.io.IOException
java.lang.IllegalArgumentException
Method Detail

init

public void init(java.net.URL fileURL)
          throws java.io.IOException,
                 java.lang.IllegalArgumentException
Throws:
java.io.IOException
java.lang.IllegalArgumentException

getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
                                              throws java.io.IOException
Uses the XTIFF Image Decoder to decode as rendered image, creating a new Buffered Image. This is expensive, so if you need the image again, keep it around. Unless it's really huge, I guess.

Returns:
BufferedImage from GeoTIFF
Throws:
java.io.IOException - if the file URL is null, or if there's a problem reading the file.

getFieldWithTag

public org.libtiff.jai.codec.XTIFFField getFieldWithTag(int tagNumber)
Helper function designed to make it easier to get the XTIFF field for a given tag number. The easiest way to use this is to ask the KeyRegistry for the code of a tag from a specific map, i.e.
 int tagNumber = KeyRegistry.getCode(KeyRegistry.GEOKEY, "GTModelTypeGeoKey");
 
 
Once you have the XTIFFField, you can figure out what type it is, and then ask for its values as that type.

Parameters:
tagNumber -
Returns:
XTIFFField, or null if not found in file.

getGtfDirectory

public org.geotiff.image.jai.GeoTIFFDirectory getGtfDirectory()
Very handy class from the file. Contains all the XTIFFFields with the tag information.

Returns:
GeoTIFFDirectory that holds GeoTIFF fields.

getGeoKeys

public org.libtiff.jai.codec.XTIFFField[] getGeoKeys()
Ask specifically for the array of XTIFFFields pertaining to georeferencing.

Returns:
XTIFFField array for keys.

getGeoFieldForCode

protected org.libtiff.jai.codec.XTIFFField getGeoFieldForCode(int code)
Searches for tag in geo keys. Doesn't go through all of the tags in the file like the getFieldWithTag function, just the fields that have been pre-fetched as geotags.

Returns:
XTIFFField, or null if not found in file.

getRasterType

public int getRasterType()
Pixels derived from scanners or other optical devices represent areas, and most commonly will use the RasterPixelIsArea coordinate system. Pixel data such as digital elevation models represent points, and will probably use RasterPixelIsPoint coordinates.

Returns:
RasterPixelIsArea = 1, RasterPixelIsPoint = 2

getModelType

public int getModelType()
Determine which class of model space coordinates are most natural for this dataset:Geographic, Geocentric, or Projected Coordinate System. Usually this will be PCS.

Returns:
ModelTypeProjected = 1 (Projection Coordinate System) ModelTypeGeographic = 2 Geographic latitude-longitude System) ModelTypeGeocentric = 3 (Geocentric (X,Y,Z) Coordinate System)

getProjectedCSType

public int getProjectedCSType()
                     Here is a summary of the index ranges for the various coding systems used by EPSG in their tables. A copy of this index may be acquired at the FTP sites mentioned in the references in section 5. The "value" table entries below describe how values from one table are related to codes from another table.
                    
                         Summary
                         --------
                         Entity                        digit   Range
                         ----------------------------  ------- -------------- 
                         Prime Meridian                8       8000 thru 8999
                         Ellipsoid                     7       7000 thru 7999
                         Geodetic Datum                6       6000 thru 6999
                         Vertical datum                5       5000 thru 5999
                         Geographic Coordinate System  4       4000 thru 4999
                         Projected Coordinate Systems  2 or 3  20000 thru 32760
                         Map Projection                1       10000 - 19999
                         Geodetic Datum Codes
                         --------------------
                         Datum Type                 Value     Range            Currently Defined
                         -------------------------- --------- --------------   -----------------
                         Unspecified Geodetic Datum [EC-1000] 6000 thru 6099   6001 thru 6035
                         Geodetic Datum                       6100 thru 6321   6200 thru 6315
                         WGS 72; WGS 72BE and WGS84           6322 thru 6327   6322 thru 6327
                         Geodetic Datum (ancient)             6900 thru 6999   6901 thru 6902
                         Note for Values: EC = corresponding Ellipsoid Code.
                         Vertical Datum Codes
                         --------------------
                         Datum Type                 Value     Range            Currently Defined
                         -------------------------- --------- --------------   -----------------     
                         Ellipsoidal                [EC-1000] 5000 thru 5099   5001 thru 5035
                         Orthometric                          5100 thru 5899   5101 thru 5106
                         Note for Values: EC = corresponding Ellipsoid Code.
                         Geographic Coordinate System Codes    
                         ----------------------------------
                         GCS Type                    Value      Range           Currently Defined
                         -----------------------     ---------- --------------  -----------------        
                         Unknown geodetic datum      [GDC-2000] 4000 thru 4099  4001 thru 4045
                         Known datum (Greenwich)     [GDC-2000] 4100 thru 4321  4200 thru 4315
                         WGS 72; WGS 72BE and WGS84             4322 thru 4327  4322 thru 4327
                         Known datum (not Greenwich)            4800 thru 4899  4801 thru 4812
                         Known datum (ancient)       [GDC-2000] 4900 thru 4999  4901 thru 4902
                         Note for Values: GDC = corresponding Geodetic Datum Code
                         Map Projection System Codes
                         ---------------------------
                         US State Plane  ( 10000-15999 )
                         Format:     1sszz            
                         where ss is USC&GS State code  01 thru 59  
                         zz is (USC&GS zone code)      for NAD27 zones               
                         zz is (USC&GS zone code + 30) for NAD83 zones
                         
                         Larger zoned systems ( 16000-17999 ) 
                         System                            Format  zz Range
                         --------------------------------  ------- -------
                         UTM (North)                       160zz   01   60   
                         UTM (South)                       161zz   01   60   
                         zoned Universal Gauss-Kruger      162zz   04   32
                         Universal Gauss-Kruger (unzoned)  163zz   04   3                  
                         Australian Map Grid               174zz   48   58   
                         Southern African STM              175zz   13   35 
                         Smaller zoned systems  ( 18000-18999 ) 
                         Format:  18ssz           
                         where ss is sequential system number  01   18   
                         z is zone code               
                         
                         Single zone projections ( 19900-19999 )
                         Format:   199ss          
                         where ss is sequential system number  00   25
                         Projected Coordinate Systems
                         ----------------------------      
                         For PCS utilizing GeogCS with code in range 4201 through 4321 
                         (i.e. geodetic datum code 6201 through 6319):
                         As far as is possible the PCS code will be of the format 
                         gggzz where ggg is (geodetic datum code -6000) and zz is zone.               
                         
                         For PCS utilizing GeogCS with code out of range 4201 through 4321
                         (i.e.geodetic datum code 6201 through 6319):
                         PCS code 20xxx where xxx is a sequential number               
                         WGS72 / UTM North     322zz where zz is UTM zone number   32201   32260   
                         WGS72 / UTM South     323zz where zz is UTM zone number   32301   32360
                         WGS72BE / UTM North   324zz where zz is UTM zone number   32401   32460
                         WGS72BE / UTM South   325zz where zz is UTM zone number   32501   32560
                         WGS84 / UTM North     326zz where zz is UTM zone number   32601   32660
                         WGS84 / UTM South     327zz where zz is UTM zone number   32701   32760
                         US State Plane (NAD27)   267xx or 320xx where xx is a sequential number            
                         US State Plane (NAD83)   269xx or 321xx where xx is a sequential number
 
 

Returns:
type code for coordinate system

getGeographicType

public int getGeographicType()
Returns:
type code for geographic type

getGeoKeyIntValue

protected int getGeoKeyIntValue(int codeFromKeyRegistry)
Helper function for taking a code from the Geo KeyRegistry, and getting the field value as a single int. Should be called for codes that have only one int value, you should read the GeoTIFF spec to know what they are.

Parameters:
codeFromKeyRegistry -
Returns:
the code value, or -1 if not found.

getFieldIntValue

protected int getFieldIntValue(int tiffCode)
Helper function for taking a code from the TIFF spec, and getting the field value as a single int. Should be called for codes that have only one int value, you should read the TIFF spec to know what they are.

Parameters:
tiffCode -
Returns:
the code value, or -1 if not found.

dumpTags

public void dumpTags(org.libtiff.jai.codec.XTIFFField[] gtfFields)
Prints out the values of the XTIFF Fields provided to it.

Parameters:
gtfFields - You can get all of the XTIFFFields from the directory object, or ask this class for the geokeys.

getStringOfType

public java.lang.String getStringOfType(int type)
Helper function that coverts type codes to string representation.

Parameters:
type - code from XTIFFField.
Returns:
String interpretation of type code.

getImageTile

public ImageTile getImageTile()
                       throws java.io.IOException
Uses a GeoTIFFModelFactory to create a georeferenced ImageTile image. Only handles 4326 projection right now (WGS84).

Returns:
ImageTile from file
Throws:
java.io.IOException

getImageTile

public ImageTile getImageTile(GeoTIFFImageReader id,
                              ImageTile.Cache cache)
                       throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details