ucar.unidata.data.grid
Class GeoGridDataSource

java.lang.Object
  extended by ucar.unidata.collab.SharableImpl
      extended by ucar.unidata.data.DataSourceImpl
          extended by ucar.unidata.data.FilesDataSource
              extended by ucar.unidata.data.grid.GridDataSource
                  extended by ucar.unidata.data.grid.GeoGridDataSource
All Implemented Interfaces:
Sharable, DataSource, DataSourceFactory, XmlPersistable
Direct Known Subclasses:
DodsGeoGridDataSource, ImageGridDataSource

public class GeoGridDataSource
extends GridDataSource

Handles gridded files

Author:
IDV Development Team

Field Summary
protected  Object DOMAIN_SET_MUTEX
          Used to synchronize the geogridadapter
static String PREF_VERTICALCS
          Preference
static String PROP_GRIDSIZE
          grid size
static String PROP_TIMESIZE
          property timesize
static String PROP_TIMEVAR
          property time variable
protected  Object readLock
          This is used to synchronize geogrid read access
static boolean testMode
          for test
 
Fields inherited from class ucar.unidata.data.grid.GridDataSource
ATTR_EAST, ATTR_NORTH, ATTR_SOUTH, ATTR_WEST, ATTR_X, ATTR_Y, ATTR_Z, PROP_ENSEMBLEMEMBERS
 
Fields inherited from class ucar.unidata.data.FilesDataSource
adapters, oldSourceFromBundles, sources
 
Fields inherited from class ucar.unidata.data.DataSourceImpl
changeDataPathsCbx, dataCacheKey, dataChoices, geoSelectionPanel, haveBeenUnPersisted, okToContinue, PARAM_SHOW_HIDE, PARAM_SHOW_NO, PARAM_SHOW_YES
 
Fields inherited from interface ucar.unidata.data.DataSource
DATAPATH_DATE_FORMAT, DATAPATH_DATE_PATTERN, MOST_RECENT, ordinalNames, PROP_AUTOCREATEDISPLAY, PROP_BASEDIRECTORY, PROP_CACHEABLE, PROP_DATACHOICENAME, PROP_DISPLAYPROPERTIES, PROP_DOCUMENTLINKS, PROP_FILEPATTERN, PROP_GEOLOCATION, PROP_ICON, PROP_NAME, PROP_POLLINFO, PROP_RESOLVERURL, PROP_SERVICE_HTTP, PROP_SUBPROPERTIES, PROP_TIMELABELS, PROP_TITLE
 
Constructor Summary
GeoGridDataSource()
          Default constructor
GeoGridDataSource(DataSourceDescriptor descriptor, File file, Hashtable properties)
          Create a GeoGridDataSource from a File.
GeoGridDataSource(DataSourceDescriptor descriptor, ucar.nc2.dt.grid.GridDataset gds, String name, String filename)
          Construct a GeoGridDataSource
GeoGridDataSource(DataSourceDescriptor descriptor, List files, Hashtable properties)
          Create a GeoGridDataSource from the filename.
GeoGridDataSource(DataSourceDescriptor descriptor, String filename, Hashtable properties)
          Create a GeoGridDataSource from the filename.
GeoGridDataSource(ucar.nc2.dt.grid.GridDataset gds)
          Create a GeoGridDataSource from the GridDataset
 
Method Summary
 void addPropertiesTabs(JTabbedPane tabbedPane)
          Add any extra tabs into the properties tab
protected  void applyFieldMask(Element root)
          Load any subset info in field mask xml
 boolean applyProperties()
          Apply the properties
protected  Object beginWritingDataToLocalDisk(String msg)
          Overwrite this method so we don't show the loading dialog
 boolean canCacheDataToDisk()
          Can this data source cache its
protected  boolean canDoFieldMask()
          Can we mask the data?
 boolean canDoGeoSelection()
          We can do geo selection in the properties gui
 boolean canSaveDataToLocalDisk()
          Can this DataSource save data to local disk?
protected  void doMakeDataChoices()
          This method is called at initialization time and creates a set of DirectDataChoice-s and adds them into the base class managed list of DataChoice-s with the method addDataChoice.
protected  ucar.nc2.dt.grid.GridDataset doMakeDataSet()
          Create the dataset from the name of this DataSource.
protected  List doMakeDateTimes()
          Return the list of DateTime-s associated with this DataSource.
protected  JComponent doMakeGeoSubsetPropertiesComponent()
          Add in the spatial dimensions label
 void doRemove()
          Called when Datasource is removed.
 List getAllDateTimes(DataChoice dataChoice)
          Override the base class method to return the times for the data choice
 List getAllLevels(DataChoice dataChoice, DataSelection dataSelection)
          Get the list of all levels available from this DataSource
 Data getData(String parameter)
          Get the data for a particular parameter
protected  Data getDataInner(DataChoice dataChoice, DataCategory category, DataSelection givenDataSelection, Hashtable requestProperties)
          Get the Data object specified by the particular selection criteria.
 List getDataPaths()
          What should be changed by the user when in data relative mode
 ucar.nc2.dt.grid.GridDataset getDataset()
          Return the GridDataset associated with this DataSource.
protected  JComponent getExtraGeoSelectionComponent()
          Get the extra label that is shown in the geo-subset panel
protected  JComponent getExtraTimesComponent()
          Add the reverse times checkbox
 String getFullDescription()
          Get the full description of the grid
protected  String getLocalDirectory(String label, String prefix)
          Get the local directory
 boolean getReverseTimes()
          Get the ReverseTimes property.
protected  ucar.unidata.geoloc.ProjectionImpl getSampleDataProjection()
          Return the sample projection
protected  String getSaveDataFileLabel()
          Get the label for the save data file option
 void initAfterCreation()
          Initialize after we have been created.
 void initAfterUnpersistence()
          Initialize if being unpersisted.
 boolean isLocalFile()
          Are we a local file
static boolean isNumeric(String str)
          check if a input is only numeric number
protected  boolean isZAxisOk(ucar.nc2.dataset.CoordinateAxis1D zaxis)
          Utility to check if we should ignore the given z axis
 List<String> listParameters()
          Get the list of parameters
static void main(String[] args)
          Test this class by running "java ucar.unidata.data.grid.GeoGridDataSource "
protected  void makeSaveLocalActions(List actions)
          Make savel local actions
 void reloadData()
          Clear out the data set
 void resetTmpState()
          Reset the tmp state
protected  void resolvePath()
          Resolve the url if we have to
protected  List saveDataToLocalDisk(String prefix, Object loadId, boolean changeLinks)
          Save the data to local disk.
 void setDefaultSelectionBounds(Rectangle2D.Float rect)
          Set the default selection bounds
 void setFileNameOrUrl(String value)
          Set the FileNameOrUrl property.
 void setNewFiles(List files)
          Overwrite setNewFiles so we clear out the resolverurl
 void setReverseTimes(boolean value)
          Set the ReverseTimes property.
 void setTmpPaths(List paths)
          Set what the user has changed
protected  void sourcesChanged()
          The source has changed
 void updateState(Object newObject, Hashtable newProperties)
          Update the state
protected  void writeFieldMaskFile(Document doc, Element root)
          Write out the field mask file
 
Methods inherited from class ucar.unidata.data.grid.GridDataSource
getEnsDCategory, getEnsembleSelection, getThreeDCategories, getThreeDEnsTimeSeriesCategories, getThreeDTimeSeriesCategories, getTwoDCategories, getTwoDEnsTimeSeriesCategories, getTwoDTimeSeriesCategories, initCategories, setEnsembleSelection
 
Methods inherited from class ucar.unidata.data.FilesDataSource
equals, getDataFileExtension, getFilePath, getInputStreams, getLocationsForPolling, getPartialDescription, getSource, getSources, haveSources, initWithPollingInfo, isFileBased, newFilesFromPolling, processDataFilename, propertiesChanged, reloadData, setSource, setSources
 
Methods inherited from class ucar.unidata.data.DataSourceImpl
addActions, addDataChangeListener, addDataChoice, addReloadTab, canAddCurrentName, canChangeData, canDoGeoSelectionMap, canDoGeoSelectionStride, canPoll, canShowParameter, checkForInitAfterUnPersistence, clearCachedData, clearFileCache, clearTimes, convertSourceFile, convertToFilesIfDirectory, createAutoDisplay, createCacheKey, createElement, decrOutstandingGetDataCalls, doDirectory, doMakeGeoSelectionPanel, doMakeGeoSelectionPanel, doMakeGeoSelectionPanel, endWritingDataToLocalDisk, expandIfNeeded, findDataChoice, findDataChoices, flushCache, getAbsoluteDateTimes, getActions, getAlias, getAllDateTimes, getAllLevels, getAllTimesForTimeDriver, getCache, getCache, getCacheClearDelay, getCacheDataToDisk, getCompositeDataChoices, getData, getData, getDataCachePath, getDataChangeListeners, getDataChoices, getDataContext, getDataInner, getDataIsEditable, getDataPrefix, getDataSelection, getDataSelectionComponents, getDataSource, getDateTimes, getDateTimeSelection, getDescription, getDescriptor, getErrorMessage, getEverChangedName, getFileFilterForPolling, getid, getIdv, getInError, getLocationForPolling, getMostRecentFiles, getName, getNameForDataSource, getNeedToShowErrorToUser, getNextId, getOutstandingGetDataCalls, getPassword, getPathsThatCanBeRelative, getPollingInfo, getProperties, getPropertiesComponents, getPropertiesHeader, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getRelativePaths, getSelectedDateTimes, getSelectedDateTimes, getTimesFromDataSelection, getTmpPaths, getTypeName, getUserName, handlePropertiesAction, hasPollingInfo, holdsDateTimes, holdsIndices, identifiedBy, identifiedByName, incrOutstandingGetDataCalls, initAfter, initDataChoice, initDataSelectionComponents, initFromXml, isPolling, loadFieldMask, loadFieldMask, loadLatestFile, logException, logException, makeDerivedDataChoices, newFileFromPolling, notifyDataChange, putCache, putCache, reloadProperties, removeCache, removeDataChangeListener, removeDataChoice, removeProperty, replaceDataChoice, saveDataToLocalDisk, saveDataToLocalDisk, selectTimesFromList, setAlias, setAskToUpdate, setCacheClearDelay, setCacheDataToDisk, setDataEditableStrings, setDataIsEditable, setDataIsRelative, setDataRelativeStrings, setDataSelection, setDateTimeSelection, setDescription, setDescriptor, setDirectory, setEverChangedName, setInError, setInError, setInError, setName, setObjectProperties, setObjectProperty, setPassword, setPollingInfo, setPollLocation, setProperties, setProperty, setProperty, setRelativePaths, setTemplateName, setUserName, shouldCache, shouldCache, showPasswordDialog, showPropertiesDialog, showPropertiesDialog, showPropertiesDialog, showWaitDialog, tick, toString, toStringTruncated, updateDetailsText, writeFieldMaskFile
 
Methods inherited from class ucar.unidata.collab.SharableImpl
applySharableProperties, doShare, doShare, doShareExternal, doShareInternal, getReceiveShareTime, getSharablePropertiesComponent, getShareGroup, getSharing, getUniqueId, initSharable, receiveShareData, removeSharable, setReceiveShareTime, setShareGroup, setSharing, setUniqueId, showSharableDialog
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ucar.unidata.data.DataSource
getUniqueId
 

Field Detail

DOMAIN_SET_MUTEX

protected final Object DOMAIN_SET_MUTEX
Used to synchronize the geogridadapter


PREF_VERTICALCS

public static final String PREF_VERTICALCS
Preference

See Also:
Constant Field Values

PROP_GRIDSIZE

public static final String PROP_GRIDSIZE
grid size

See Also:
Constant Field Values

PROP_TIMESIZE

public static final String PROP_TIMESIZE
property timesize

See Also:
Constant Field Values

PROP_TIMEVAR

public static final String PROP_TIMEVAR
property time variable

See Also:
Constant Field Values

readLock

protected final Object readLock
This is used to synchronize geogrid read access


testMode

public static boolean testMode
for test

Constructor Detail

GeoGridDataSource

public GeoGridDataSource()
Default constructor


GeoGridDataSource

public GeoGridDataSource(DataSourceDescriptor descriptor,
                         ucar.nc2.dt.grid.GridDataset gds,
                         String name,
                         String filename)
Construct a GeoGridDataSource

Parameters:
descriptor - the data source descriptor
gds - The GridDataset
name - A name
filename - the filename

GeoGridDataSource

public GeoGridDataSource(ucar.nc2.dt.grid.GridDataset gds)
Create a GeoGridDataSource from the GridDataset

Parameters:
gds - the GridDataset

GeoGridDataSource

public GeoGridDataSource(DataSourceDescriptor descriptor,
                         File file,
                         Hashtable properties)
                  throws IOException
Create a GeoGridDataSource from a File.

Parameters:
descriptor - Describes this data source, has a label etc.
file - This is the file that points to the actual data source.
properties - General properties used in the base class
Throws:
IOException - problem opening file

GeoGridDataSource

public GeoGridDataSource(DataSourceDescriptor descriptor,
                         String filename,
                         Hashtable properties)
                  throws IOException
Create a GeoGridDataSource from the filename.

Parameters:
descriptor - Describes this data source, has a label etc.
filename - This is the filename (or url) that points to the actual data source.
properties - General properties used in the base class
Throws:
IOException

GeoGridDataSource

public GeoGridDataSource(DataSourceDescriptor descriptor,
                         List files,
                         Hashtable properties)
                  throws IOException
Create a GeoGridDataSource from the filename.

Parameters:
descriptor - Describes this data source, has a label etc.
files - List of files or urls
properties - General properties used in the base class
Throws:
IOException
Method Detail

setDefaultSelectionBounds

public void setDefaultSelectionBounds(Rectangle2D.Float rect)
Set the default selection bounds

Parameters:
rect - rectangle

applyFieldMask

protected void applyFieldMask(Element root)
Load any subset info in field mask xml

Overrides:
applyFieldMask in class DataSourceImpl
Parameters:
root - xml root

canDoFieldMask

protected boolean canDoFieldMask()
Can we mask the data?

Overrides:
canDoFieldMask in class DataSourceImpl
Returns:
true if we can

writeFieldMaskFile

protected void writeFieldMaskFile(Document doc,
                                  Element root)
Write out the field mask file

Overrides:
writeFieldMaskFile in class DataSourceImpl
Parameters:
doc - doc to write to
root - root node

initAfterUnpersistence

public void initAfterUnpersistence()
Initialize if being unpersisted.

Specified by:
initAfterUnpersistence in interface DataSource
Overrides:
initAfterUnpersistence in class FilesDataSource

doMakeGeoSubsetPropertiesComponent

protected JComponent doMakeGeoSubsetPropertiesComponent()
Add in the spatial dimensions label

Overrides:
doMakeGeoSubsetPropertiesComponent in class DataSourceImpl
Returns:
The subset properties component

getExtraGeoSelectionComponent

protected JComponent getExtraGeoSelectionComponent()
Get the extra label that is shown in the geo-subset panel

Overrides:
getExtraGeoSelectionComponent in class DataSourceImpl
Returns:
Extra label for geosubset panel

addPropertiesTabs

public void addPropertiesTabs(JTabbedPane tabbedPane)
Add any extra tabs into the properties tab

Overrides:
addPropertiesTabs in class DataSourceImpl
Parameters:
tabbedPane - The properties tab

initAfterCreation

public void initAfterCreation()
Initialize after we have been created.

Specified by:
initAfterCreation in interface DataSource
Overrides:
initAfterCreation in class FilesDataSource

getDataPaths

public List getDataPaths()
What should be changed by the user when in data relative mode

Specified by:
getDataPaths in interface DataSource
Overrides:
getDataPaths in class FilesDataSource
Returns:
paths to changed

updateState

public void updateState(Object newObject,
                        Hashtable newProperties)
Update the state

Specified by:
updateState in interface DataSource
Overrides:
updateState in class FilesDataSource
Parameters:
newObject - new object
newProperties - properties

setTmpPaths

public void setTmpPaths(List paths)
Set what the user has changed

Specified by:
setTmpPaths in interface DataSource
Overrides:
setTmpPaths in class DataSourceImpl
Parameters:
paths - new paths

resolvePath

protected void resolvePath()
Resolve the url if we have to


sourcesChanged

protected void sourcesChanged()
The source has changed

Overrides:
sourcesChanged in class FilesDataSource

reloadData

public void reloadData()
Clear out the data set

Specified by:
reloadData in interface DataSource
Overrides:
reloadData in class FilesDataSource

doRemove

public void doRemove()
Called when Datasource is removed.

Specified by:
doRemove in interface DataSource
Overrides:
doRemove in class FilesDataSource

canSaveDataToLocalDisk

public boolean canSaveDataToLocalDisk()
Can this DataSource save data to local disk?

Specified by:
canSaveDataToLocalDisk in interface DataSource
Overrides:
canSaveDataToLocalDisk in class DataSourceImpl
Returns:
true if this DataSource can save data to local disk?

getSaveDataFileLabel

protected String getSaveDataFileLabel()
Get the label for the save data file option

Overrides:
getSaveDataFileLabel in class DataSourceImpl
Returns:
label

makeSaveLocalActions

protected void makeSaveLocalActions(List actions)
Make savel local actions

Overrides:
makeSaveLocalActions in class DataSourceImpl
Parameters:
actions - list of actions

beginWritingDataToLocalDisk

protected Object beginWritingDataToLocalDisk(String msg)
Overwrite this method so we don't show the loading dialog

Overrides:
beginWritingDataToLocalDisk in class DataSourceImpl
Parameters:
msg - The msg to show in the dialog
Returns:
The jobmanager loadid

saveDataToLocalDisk

protected List saveDataToLocalDisk(String prefix,
                                   Object loadId,
                                   boolean changeLinks)
                            throws Exception
Save the data to local disk.

Overrides:
saveDataToLocalDisk in class FilesDataSource
Parameters:
prefix - the prefix for the local file name
loadId - the load id (for cancelling)
changeLinks - true to change the links
Returns:
The list of files
Throws:
Exception - problem saving data.

isLocalFile

public boolean isLocalFile()
Are we a local file

Returns:
is a local file

setNewFiles

public void setNewFiles(List files)
Overwrite setNewFiles so we clear out the resolverurl

Specified by:
setNewFiles in interface DataSource
Overrides:
setNewFiles in class FilesDataSource
Parameters:
files - The list of new files to use

getLocalDirectory

protected String getLocalDirectory(String label,
                                   String prefix)
Get the local directory

Overrides:
getLocalDirectory in class DataSourceImpl
Parameters:
label - a label
prefix - the prefix
Returns:
the path

getFullDescription

public String getFullDescription()
Get the full description of the grid

Specified by:
getFullDescription in interface DataSource
Overrides:
getFullDescription in class FilesDataSource
Returns:
the description

resetTmpState

public void resetTmpState()
Reset the tmp state

Specified by:
resetTmpState in interface DataSource
Overrides:
resetTmpState in class DataSourceImpl

doMakeDataSet

protected ucar.nc2.dt.grid.GridDataset doMakeDataSet()
Create the dataset from the name of this DataSource.

Returns:
new GridDataset

getDataset

public ucar.nc2.dt.grid.GridDataset getDataset()
Return the GridDataset associated with this DataSource.

Returns:
dataset

getSampleDataProjection

protected ucar.unidata.geoloc.ProjectionImpl getSampleDataProjection()
Return the sample projection

Overrides:
getSampleDataProjection in class DataSourceImpl
Returns:
the sample projection

doMakeDataChoices

protected void doMakeDataChoices()
This method is called at initialization time and creates a set of DirectDataChoice-s and adds them into the base class managed list of DataChoice-s with the method addDataChoice.

Overrides:
doMakeDataChoices in class DataSourceImpl

getDataInner

protected Data getDataInner(DataChoice dataChoice,
                            DataCategory category,
                            DataSelection givenDataSelection,
                            Hashtable requestProperties)
                     throws VisADException,
                            RemoteException
Get the Data object specified by the particular selection criteria.

Overrides:
getDataInner in class DataSourceImpl
Parameters:
dataChoice - DataChoice to select.
category - DataCategory (unused at present)
givenDataSelection - DataSelection criteria for this request.
requestProperties - extra request selection properties (not used in this class)
Returns:
Data object corresponding to the data choice
Throws:
VisADException - couldn't create Data object
RemoteException - couldn't create remote Data object

listParameters

public List<String> listParameters()
Get the list of parameters

Returns:
the list

getData

public Data getData(String parameter)
             throws VisADException,
                    RemoteException
Get the data for a particular parameter

Parameters:
parameter - the parameter name
Returns:
the Data or null
Throws:
RemoteException - Java RMI Error
VisADException - VisAD Error

doMakeDateTimes

protected List doMakeDateTimes()
Return the list of DateTime-s associated with this DataSource.

Overrides:
doMakeDateTimes in class DataSourceImpl
Returns:
List of DateTime-s.

getAllLevels

public List getAllLevels(DataChoice dataChoice,
                         DataSelection dataSelection)
Get the list of all levels available from this DataSource

Specified by:
getAllLevels in interface DataSource
Overrides:
getAllLevels in class DataSourceImpl
Parameters:
dataChoice - The data choice we are getting levels for
dataSelection - the data selection
Returns:
List of all available levels

canDoGeoSelection

public boolean canDoGeoSelection()
We can do geo selection in the properties gui

Specified by:
canDoGeoSelection in interface DataSource
Overrides:
canDoGeoSelection in class DataSourceImpl
Returns:
can do geo selection

canCacheDataToDisk

public boolean canCacheDataToDisk()
Can this data source cache its

Overrides:
canCacheDataToDisk in class DataSourceImpl
Returns:
can cache data to disk

isZAxisOk

protected boolean isZAxisOk(ucar.nc2.dataset.CoordinateAxis1D zaxis)
Utility to check if we should ignore the given z axis

Parameters:
zaxis - given z axis
Returns:
Is ok

getAllDateTimes

public List getAllDateTimes(DataChoice dataChoice)
Override the base class method to return the times for the data choice

Specified by:
getAllDateTimes in interface DataSource
Overrides:
getAllDateTimes in class DataSourceImpl
Parameters:
dataChoice - DataChoice in question
Returns:
List of all times for that choice

isNumeric

public static boolean isNumeric(String str)
check if a input is only numeric number

Parameters:
str - is this numeric
Returns:
true if numeric

main

public static void main(String[] args)
                 throws Exception
Test this class by running "java ucar.unidata.data.grid.GeoGridDataSource "

Parameters:
args - filename
Throws:
Exception - some error occurred

setFileNameOrUrl

public void setFileNameOrUrl(String value)
Set the FileNameOrUrl property.

Parameters:
value - The new value for FileNameOrUrl

applyProperties

public boolean applyProperties()
Apply the properties

Overrides:
applyProperties in class DataSourceImpl
Returns:
everything ok

getExtraTimesComponent

protected JComponent getExtraTimesComponent()
Add the reverse times checkbox

Overrides:
getExtraTimesComponent in class DataSourceImpl
Returns:
extra comp

setReverseTimes

public void setReverseTimes(boolean value)
Set the ReverseTimes property.

Parameters:
value - The new value for ReverseTimes

getReverseTimes

public boolean getReverseTimes()
Get the ReverseTimes property.

Returns:
The ReverseTimes