jpl.mipl.mars.viewer.util
Class MerImageFileFinder

java.lang.Object
  extended byjpl.mipl.mars.viewer.util.AbstractMarsImageFileFinder
      extended byjpl.mipl.mars.viewer.util.MerImageFileFinder
All Implemented Interfaces:
EventListener, MarsImageFileFinder, PropertyChangeListener
Direct Known Subclasses:
MerArchiveImageFileFinder, MerArchiveVolumeImageFileFinder, MerFeiImageFileFinder, MerFlatImageFileFinder, MerOssImageFileFinder, MerRemoteOssImageFileFinder

public abstract class MerImageFileFinder
extends AbstractMarsImageFileFinder

Purpose: Subclass of MarsImageFileFinder implementing some MER-specific methods and structure.

   Copyright 2003, California Institute of Technology.
   ALL RIGHTS RESERVED.
   U.S. Government Sponsorship acknowledge. 2003.
   
 ============================================================================
 Modification History :
 ----------------------

 Date              Who              What
 ----------------------------------------------------------------------------
 08/23/2003        Nick             Initial Release
 01/20/2004        Nick             Invrs LUT EDR (ILF, ISF, IDN, ITH) added
                                    Scaled Rad: RSD, RSL, RST, RSN added
 07/14/2004        Nick             Added Solar Energy type (SE{PLNT})
 11/11/2004        Nick             Added Slope Magnitude type (SM{PLNT})
 11/11/2004        Nick             Added Slope Heading type (SH{PLNT})
 ============================================================================
 

Version:
2004.01.20
Author:
Nicholas Toole (Nicholas.T.Toole@jpl.nasa.gov)

Field Summary
protected  Pattern edr_pattern
           
protected  Properties instrumentLookup
           
protected  DecimalFormat solFormatter
           
protected static String[] sourceTypes
          Known EDR source types
protected static String[] thumbnailTypes
          Known EDR/RDR thumbnail product types
 
Fields inherited from class jpl.mipl.mars.viewer.util.AbstractMarsImageFileFinder
_solRange, _treeRoot, _treeRootStr
 
Fields inherited from interface jpl.mipl.mars.viewer.util.MarsImageFileFinder
EDR_TYPE, RDR_TYPE
 
Constructor Summary
MerImageFileFinder(String root)
          Constructor.
 
Method Summary
protected  Pattern createRdrPattern(String filename)
          Given an EDR filename, returns a Pattern object to be used to match RDR products which were produced from the EDR.
 String extractEyeType(String imgPath, short type)
          Returns the camera eye type as denoted by the file organization and the imgPath parameter.
 String extractImageType(String imgPath, short type)
          Returns the image type as denoted by the file organization and the imgPath parameter.
 Vector extractImageTypes(Vector imgPaths, short type)
          Returns the image types as denoted by the file organization and the imgPath parameters.
 String extractInstrument(String imgPath, short type)
          Returns the instrument type as denoted by the instrument identifying position in the filename
 Vector filterProducts(Vector edrs, String instrument, String fileType, String eyeType, boolean allowThumbs)
          Returns a subset of entries from edrs vector which are of the same instrument as specified by instrumentName, and permitted by the allowThumbs flag.
 String formatSol(int sol)
          Formats the SOL as a string based on the directory structure
protected  Vector getBestRdrs(Vector paths)
          Removes previous versions of products, leaving only the greatest.
 String[] getCameraEyeTypes()
          Returns a String array of camera eye types.
 String getEdrThumbnail(String edrPath)
          Given a complete path to an EDR, returns the associated thumbnail path, if it exists.
 String[] getInstrumentTypes()
          Returns a String array of instrument names.
 String[] getRdrTypes()
          Returns a String array of RDR types.
protected  Vector grabMatchingRdr(String directory, Pattern pattern)
          Given a directory and a pattern, returns the best file matching that pattern.
protected  Vector grabMatchingRdrs(String directory, String filename)
          Convenience method that calls and returns value from grabMatchingRdr(String,Pattern), with Pattern object created from filename parameter.
 boolean isThumbnail(String imgFile)
          Determines if image represented by imgFile is a thumbnail.
 boolean isThumbnailType(String type)
          Determines if product type represented by type is a thumbnail.
 boolean isTypeNominal(String type)
          Returns true if the type parameter is raw, false otherwise (e.g.
 boolean isTypeSource(String type)
          Returns true if the type parameter is source, false otherwise.
 
Methods inherited from class jpl.mipl.mars.viewer.util.AbstractMarsImageFileFinder
equals, extractFilename, getEdrs, getInitialSol, getRdrs, getRoot, getRootFile, getSolRange, getSourceProductPath, getType, initSolRange, propertyChange, removeThumbnails, setRoot
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edr_pattern

protected Pattern edr_pattern

solFormatter

protected DecimalFormat solFormatter

instrumentLookup

protected Properties instrumentLookup

thumbnailTypes

protected static String[] thumbnailTypes
Known EDR/RDR thumbnail product types


sourceTypes

protected static String[] sourceTypes
Known EDR source types

Constructor Detail

MerImageFileFinder

public MerImageFileFinder(String root)
                   throws IOException
Constructor.

Throws:
FileNotFoundException - If directory specified by newRoot parameter does not exist or cannot be read.
IOException
Method Detail

createRdrPattern

protected Pattern createRdrPattern(String filename)
Given an EDR filename, returns a Pattern object to be used to match RDR products which were produced from the EDR. Wildcard entries are: product, who, version, and extension

Parameters:
filename - EDR filename or path
Returns:
Pattern of the RDR filenames to match

grabMatchingRdrs

protected Vector grabMatchingRdrs(String directory,
                                  String filename)
                           throws IOException
Convenience method that calls and returns value from grabMatchingRdr(String,Pattern), with Pattern object created from filename parameter.

Parameters:
directory - Directory to be scanned.
filename - EDR filename
Returns:
Vectors of paths of best matching RDR files, empty if none.
Throws:
IOException - if directory does not exist

grabMatchingRdr

protected Vector grabMatchingRdr(String directory,
                                 Pattern pattern)
                          throws IOException
Given a directory and a pattern, returns the best file matching that pattern. If no match is found, null is returned. If multiple matches are found, then the filename with highest compareTo() value is returned.

Parameters:
directory - Directory to be scanned.
pattern - Pattern object created from EDR
Returns:
Vectors of paths of best matching RDR files, empty if none.
Throws:
IOException - if directory does not exist

filterProducts

public Vector filterProducts(Vector edrs,
                             String instrument,
                             String fileType,
                             String eyeType,
                             boolean allowThumbs)
Returns a subset of entries from edrs vector which are of the same instrument as specified by instrumentName, and permitted by the allowThumbs flag.

Specified by:
filterProducts in interface MarsImageFileFinder
Specified by:
filterProducts in class AbstractMarsImageFileFinder
Parameters:
edrs - Sets of EDR pathnames, specific to organization type.
instrument - Name of instrument, "" and null for all instruments.
fileType - EDR file type , "" and null for all file types.
eyeType - Camera eye type , "" and null for all camera eye types.
allowThumbs - Flag for thumbnails, if true thumbnails are allowed, else they will be filtered out.
Returns:
Subset of entries matching instrument type. If instrument is null or the empty string, a cloned Vector is returned.

isThumbnail

public boolean isThumbnail(String imgFile)
Determines if image represented by imgFile is a thumbnail.

Specified by:
isThumbnail in interface MarsImageFileFinder
Specified by:
isThumbnail in class AbstractMarsImageFileFinder
Parameters:
imgFile - Filename of the image.
Returns:
True if file is a thumbnail, false otherwise.

isThumbnailType

public boolean isThumbnailType(String type)
Description copied from class: AbstractMarsImageFileFinder
Determines if product type represented by type is a thumbnail.

Specified by:
isThumbnailType in interface MarsImageFileFinder
Specified by:
isThumbnailType in class AbstractMarsImageFileFinder
Parameters:
type - Product type.
Returns:
True if file is a thumbnail, false otherwise.

getInstrumentTypes

public String[] getInstrumentTypes()
Returns a String array of instrument names.

Specified by:
getInstrumentTypes in interface MarsImageFileFinder
Overrides:
getInstrumentTypes in class AbstractMarsImageFileFinder
Returns:
String array of instrument types, first element an empty string.

getRdrTypes

public String[] getRdrTypes()
Returns a String array of RDR types.

Specified by:
getRdrTypes in interface MarsImageFileFinder
Overrides:
getRdrTypes in class AbstractMarsImageFileFinder
Returns:
String array of RDR types.

getCameraEyeTypes

public String[] getCameraEyeTypes()
Returns a String array of camera eye types.

Specified by:
getCameraEyeTypes in interface MarsImageFileFinder
Overrides:
getCameraEyeTypes in class AbstractMarsImageFileFinder
Returns:
String array of camera eye types.

extractInstrument

public String extractInstrument(String imgPath,
                                short type)
Returns the instrument type as denoted by the instrument identifying position in the filename

Specified by:
extractInstrument in interface MarsImageFileFinder
Specified by:
extractInstrument in class AbstractMarsImageFileFinder
Parameters:
imgPath - Filename or path of the edr/rdr file.
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Instrument as determined by organization. Null if cannot be determined.

extractImageType

public String extractImageType(String imgPath,
                               short type)
Returns the image type as denoted by the file organization and the imgPath parameter.

Specified by:
extractImageType in interface MarsImageFileFinder
Specified by:
extractImageType in class AbstractMarsImageFileFinder
Parameters:
imgPath - Complete path of the edr file.
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Image type as determined by filename and org. Null if cannot be determined.

extractImageTypes

public Vector extractImageTypes(Vector imgPaths,
                                short type)
Returns the image types as denoted by the file organization and the imgPath parameters.

Specified by:
extractImageTypes in interface MarsImageFileFinder
Specified by:
extractImageTypes in class AbstractMarsImageFileFinder
Parameters:
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Image types as determined by filename and org.

extractEyeType

public String extractEyeType(String imgPath,
                             short type)
Returns the camera eye type as denoted by the file organization and the imgPath parameter.

Specified by:
extractEyeType in interface MarsImageFileFinder
Specified by:
extractEyeType in class AbstractMarsImageFileFinder
Parameters:
imgPath - Complete path of the edr file.
type - Type of file (choose from MarsImageFileFinder.EDR_TYPE, MarsImageFileFinder.RDR_TYPE)
Returns:
Camera eye type as determined by organization.

formatSol

public String formatSol(int sol)
Formats the SOL as a string based on the directory structure

Specified by:
formatSol in interface MarsImageFileFinder
Overrides:
formatSol in class AbstractMarsImageFileFinder
Returns:
string representation of the sol parameter

getBestRdrs

protected Vector getBestRdrs(Vector paths)
Removes previous versions of products, leaving only the greatest. This method is destructive to the paths parameter.

Parameters:
paths - Vector of product paths
Returns:
Vector of only the highest versions of products

isTypeNominal

public boolean isTypeNominal(String type)
Returns true if the type parameter is raw, false otherwise (e.g. type is linearized).

Specified by:
isTypeNominal in interface MarsImageFileFinder
Specified by:
isTypeNominal in class AbstractMarsImageFileFinder
Returns:
True is type is raw, false otherwise.

isTypeSource

public boolean isTypeSource(String type)
Returns true if the type parameter is source, false otherwise.

Specified by:
isTypeSource in interface MarsImageFileFinder
Specified by:
isTypeSource in class AbstractMarsImageFileFinder
Returns:
True is type is source, false otherwise.

getEdrThumbnail

public String getEdrThumbnail(String edrPath)
Given a complete path to an EDR, returns the associated thumbnail path, if it exists. Essentially, it replaces the EDR product type with 'ETH', and checks that the file exists. If so, returns the path to the thumbnail. else returns null.

Specified by:
getEdrThumbnail in interface MarsImageFileFinder
Specified by:
getEdrThumbnail in class AbstractMarsImageFileFinder
Parameters:
edrPath - Absolute path of EDR file
Returns:
Associated thumbnail path, if it exists, else null