Package ucar.unidata.data.point
Class TextPointDataSource
java.lang.Object
ucar.unidata.collab.SharableImpl
ucar.unidata.data.DataSourceImpl
ucar.unidata.data.FilesDataSource
ucar.unidata.data.point.PointDataSource
ucar.unidata.data.point.TextPointDataSource
- All Implemented Interfaces:
Sharable
,DataSource
,DataSourceFactory
,XmlPersistable
- Direct Known Subclasses:
AMRCTextPointDataSource
,CDOGTextPointDataSource
,DiamondPointDataSource
,GNOMETextPointDataSource
A data source for point data from a Text file
- Author:
- IDV Development Team
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Class Metadata holds the skipRows and the list of metadata itemsNested classes/interfaces inherited from class ucar.unidata.data.point.PointDataSource
PointDataSource.PlotModelSelectionComponent
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Blank delimiterstatic final String
Comma delimiterboolean
_more_static final String
Where to write out the saved meta data listingstatic final String
Property identifier for the hashtable of propertiesstatic final String
property id for the whole header blob, map and paramsstatic final String
Property identifier for thestatic final String
property id for the header mapstatic final String
property id for the header paramsstatic final String
property id for how many rows to skipstatic final String
property id for how many rows to skipstatic final String
Semicolon delimiterstatic final String
Tab delimiterboolean
_more_Fields inherited from class ucar.unidata.data.point.PointDataSource
fieldsDescription, POINT_DATA, PROP_FIRSTGUESS, PROP_GRID_GAIN, PROP_GRID_NUMPASSES, PROP_GRID_PARAM, PROP_GRID_SEARCH_RADIUS, PROP_GRID_UNIT, PROP_GRID_X, PROP_GRID_Y, PROP_STATIONMODELNAME, PROP_STATIONMODELSCALE, STATION_DATA, STATION_PLOT
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_TIMESTRIDE, PROP_TITLE
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorTextPointDataSource
(String source) Create a TextPointDataSource from the path nameTextPointDataSource
(DataSourceDescriptor descriptor, String source, String name, Hashtable properties) Create a new TextPointDataSourceTextPointDataSource
(DataSourceDescriptor descriptor, String source, Hashtable properties) Create a new TextPointDataSourceTextPointDataSource
(DataSourceDescriptor descriptor, List sources, Hashtable properties) Create a new PointDataSource -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertiesTabs
(JTabbedPane tabbedPane) add to properties tabvoid
applyNames
(String line) update the guiboolean
apply propertiesvoid
Init the widgetsvoid
THis gets called from the Preferences menu and sets the metadata and also updates the skipRowsvoid
This gets called in a thread from the applySavedMetaDataFromUI methodboolean
Can this datasource do the geoselection subsetting and decimationprotected boolean
Used for the geo subsetting property gui as to whether to show the stride or notboolean
Can we save locallyvoid
Show the metadata guivoid
deleteMetaData
(String key) Remove the given key from the saved mapping.void
Make the data choicesboolean
Check to see if this TextPointDataSource is equal to the object in question.static int[]
Find the lat/lon/alt indicidesprotected final String
getContents
(String sourceFile) Get the contents of the file as a stringprotected String
getContents
(String sourceFile, boolean sampleIt) Read the given source file and return the text contents of it.protected Data
getDataInner
(DataChoice dataChoice, DataCategory category, DataSelection dataSelection, Hashtable requestProperties) Get the data represented by this class.Get the delimiter used in the text fileprotected String
getDelimiter
(String source) Get the delimiter to use for the given file.Get the GroupVarName property.getMap()
Get the Map property.Get the MetaDataFields property.Get the Params property.protected List
Get the default categories for data from PointDataSource-svoid
getPropertiesComponents
(List comps) Add to properties guiprotected FieldImpl
getSample
(DataChoice dataChoice) Read a sample of the data.int
Get the SkipRows property.protected String
getSource
(DataChoice dataChoice) the data choiceint
hashCode()
Get the hashcode for this objectstatic void
mainstatic void
testmakeObs
(String contents, String delimiter, DataSelection subset, ucar.unidata.geoloc.LatLonRect bbox, String trackParam, boolean sampleIt, boolean showAttributeGuiIfNeeded) make the observations from the given datachoicemakeObs
(DataChoice dataChoice, DataSelection subset, ucar.unidata.geoloc.LatLonRect bbox) Make PointObs from the raw VisAD datamakeObs
(DataChoice dataChoice, DataSelection subset, ucar.unidata.geoloc.LatLonRect bbox, String trackParam, boolean sampleIt, boolean showAttributeGuiIfNeeded) make the observations from the given datachoicevoid
popupMetaDataMenu
(JComponent near) Show the metadata preference menuvoid
Save the meta datavoid
setDelimiter
(String delim) Get the delimiter used in the text filevoid
setGroupVarName
(String value) Set the GroupVarName property.void
Set the Map property.void
setMetaDataFields
(List value) Set the MetaDataFields property.void
Set the Params property.void
setSkipRows
(int value) Set the SkipRows property.void
setStreamProcessor
(TextAdapter.StreamProcessor streamProcessor) Set the stream processor to usevoid
write the header text to a filevoid
write the pluginMethods inherited from class ucar.unidata.data.point.PointDataSource
canAddCurrentName, canCreateGrid, canDoAllLevels, doRemove, getBinRoundTo, getBinWidth, getDataName, getDefaultLevels, getDescriptionDataChoice, getFullDescription, getGridGain, getGridSearchRadius, getGridUnit, getGridX, getGridY, getMakeGridFields, getNumGridPasses, init, initDataSelectionComponents, initGridParameters, makeDerivedDataChoices, makeFieldDescription, reloadData, setBinRoundTo, setBinWidth, setGridGain, setGridSearchRadius, setGridUnit, setGridX, setGridY, setMakeGridFields, setNumGridPasses, setRoundToFromComboBox, setSource, setWidthFromComboBox, shouldCache
Methods inherited from class ucar.unidata.data.FilesDataSource
getDataFileExtension, getDataPaths, getFilePath, getInputStreams, getLocationsForPolling, getPartialDescription, getSource, getSources, haveSources, initAfterCreation, initAfterUnpersistence, initWithPollingInfo, isFileBased, newFilesFromPolling, processDataFilename, propertiesChanged, reloadData, saveDataToLocalDisk, setNewFiles, setSources, sourcesChanged, updateState
Methods inherited from class ucar.unidata.data.DataSourceImpl
addActions, addDataChangeListener, addDataChoice, addReloadTab, applyFieldMask, beginWritingDataToLocalDisk, canCacheDataToDisk, canChangeData, canDoFieldMask, canDoGeoSelectionMap, canPoll, canShowParameter, checkForInitAfterUnPersistence, clearCachedData, clearFileCache, clearTimes, convertSourceFile, convertToFilesIfDirectory, createAutoDisplay, createCacheKey, createElement, decrOutstandingGetDataCalls, doDirectory, doMakeDateTimes, doMakeGeoSelectionPanel, doMakeGeoSelectionPanel, doMakeGeoSelectionPanel, doMakeGeoSubsetPropertiesComponent, endWritingDataToLocalDisk, expandIfNeeded, findDataChoice, findDataChoices, flushCache, getAbsoluteDateTimes, getActions, getAlias, getAllDateTimes, getAllDateTimes, getAllLevels, getAllLevels, getAllTimesForTimeDriver, getCache, getCache, getCacheClearDelay, getCacheDataToDisk, getCompositeDataChoices, getData, getData, getDataCachePath, getDataChangeListeners, getDataChoices, getDataContext, getDataInner, getDataIsEditable, getDataPrefix, getDataSelection, getDataSelectionComponents, getDataSource, getDateTimes, getDateTimeSelection, getDefaultSave, getDescription, getDescriptor, getErrorMessage, getEverChangedName, getExtraGeoSelectionComponent, getExtraTimesComponent, getFileFilterForPolling, getid, getIdv, getInError, getLocalDirectory, getLocationForPolling, getMostRecentFiles, getName, getNameForDataSource, getNeedToShowErrorToUser, getNextId, getOutstandingGetDataCalls, getPassword, getPathsThatCanBeRelative, getPollingInfo, getProperties, getPropertiesHeader, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getRelativePaths, getSampleDataProjection, getSaveDataFileLabel, getSelectedDateTimes, getSelectedDateTimes, getTimesFromDataSelection, getTmpPaths, getTypeName, getUserName, handlePropertiesAction, hasPollingInfo, holdsDateTimes, holdsIndices, identifiedBy, identifiedByName, incrOutstandingGetDataCalls, initAfter, initDataChoice, initFromXml, isPolling, loadFieldMask, loadFieldMask, loadLatestFile, logException, logException, makeSaveLocalActions, newFileFromPolling, notifyDataChange, putCache, putCache, reloadProperties, removeCache, removeDataChangeListener, removeDataChoice, removeProperty, replaceDataChoice, resetTmpState, saveDataToLocalDisk, saveDataToLocalDisk, selectTimesFromList, setAlias, setAskToUpdate, setCacheClearDelay, setCacheDataToDisk, setDataEditableStrings, setDataIsEditable, setDataIsRelative, setDataRelativeStrings, setDataSelection, setDateTimeSelection, setDefaultSave, setDescription, setDescriptor, setDirectory, setEverChangedName, setInError, setInError, setInError, setName, setObjectProperties, setObjectProperty, setPassword, setPollingInfo, setPollLocation, setProperties, setProperty, setProperty, setRelativePaths, setTemplateName, setTmpPaths, setUserName, shouldCache, showPasswordDialog, showPropertiesDialog, showPropertiesDialog, showPropertiesDialog, showWaitDialog, tick, toString, toStringTruncated, updateDetailsText, writeFieldMaskFile, 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, notify, notifyAll, wait, wait, wait
Methods inherited from interface ucar.unidata.data.DataSource
getUniqueId
-
Field Details
-
PROP_HEADER_MAP
property id for the header map- See Also:
-
PROP_DATAPROPERTIES
Property identifier for the hashtable of properties- See Also:
-
PROP_HEADER_EXTRA
Property identifier for the- See Also:
-
PROP_HEADER_PARAMS
property id for the header params- See Also:
-
PROP_HEADER_SKIP
property id for how many rows to skip- See Also:
-
PROP_HEADER_SKIPPATTERN
property id for how many rows to skip- See Also:
-
PROP_HEADER_BLOB
property id for the whole header blob, map and params- See Also:
-
PREF_METADATAMAP
Where to write out the saved meta data listing- See Also:
-
COMMA_DELIM
Comma delimiter- See Also:
-
SEMICOLON_DELIM
Semicolon delimiter- See Also:
-
TAB_DELIM
Tab delimiter- See Also:
-
BLANK_DELIM
Blank delimiter- See Also:
-
useDriverTime
public boolean useDriverTime_more_ -
hasLatLon
public boolean hasLatLon_more_
-
-
Constructor Details
-
TextPointDataSource
Default constructor- Throws:
VisADException
- problem creating the object
-
TextPointDataSource
Create a TextPointDataSource from the path name- Parameters:
source
- path to source data- Throws:
VisADException
- problem creating the file
-
TextPointDataSource
public TextPointDataSource(DataSourceDescriptor descriptor, List sources, Hashtable properties) throws VisADException Create a new PointDataSource- Parameters:
descriptor
- data source descriptorsources
- List of sources of data (filename/URL)properties
- extra properties for initialization- Throws:
VisADException
- problem creating the data
-
TextPointDataSource
public TextPointDataSource(DataSourceDescriptor descriptor, String source, Hashtable properties) throws VisADException Create a new TextPointDataSource- Parameters:
descriptor
- data source descriptorsource
- source of data (filename/URL)properties
- extra properties for initialization- Throws:
VisADException
- problem creating the data
-
TextPointDataSource
public TextPointDataSource(DataSourceDescriptor descriptor, String source, String name, Hashtable properties) throws VisADException Create a new TextPointDataSource- Parameters:
descriptor
- data source descriptorsource
- source of data (filename/URL)name
- the name of the datasetproperties
- extra properties for initialization- Throws:
VisADException
- problem creating the data
-
-
Method Details
-
canSaveDataToLocalDisk
public boolean canSaveDataToLocalDisk()Can we save locally- Specified by:
canSaveDataToLocalDisk
in interfaceDataSource
- Overrides:
canSaveDataToLocalDisk
in classDataSourceImpl
- Returns:
- true if we can
-
setStreamProcessor
Set the stream processor to use- Parameters:
streamProcessor
- the StreamProcessor
-
canDoGeoSelection
public boolean canDoGeoSelection()Can this datasource do the geoselection subsetting and decimation- Specified by:
canDoGeoSelection
in interfaceDataSource
- Overrides:
canDoGeoSelection
in classDataSourceImpl
- Returns:
- treu if can do geo subsetting
-
canDoGeoSelectionStride
protected boolean canDoGeoSelectionStride()Used for the geo subsetting property gui as to whether to show the stride or not- Overrides:
canDoGeoSelectionStride
in classDataSourceImpl
- Returns:
- default is true
-
makeObs
public FieldImpl makeObs(DataChoice dataChoice, DataSelection subset, ucar.unidata.geoloc.LatLonRect bbox) throws Exception Make PointObs from the raw VisAD data- Specified by:
makeObs
in classPointDataSource
- Parameters:
dataChoice
- choice for data (source of data)subset
- subsetting parametersbbox
- The area subset. May be null.- Returns:
- data of the form index -> (EarthLocation, Time, value_tuple)
- Throws:
Exception
- problem creating data
-
getSource
the data choice- Overrides:
getSource
in classPointDataSource
- Parameters:
dataChoice
- the data choice- Returns:
- the file or url this data choice refers to
-
makeObs
public FieldImpl makeObs(DataChoice dataChoice, DataSelection subset, ucar.unidata.geoloc.LatLonRect bbox, String trackParam, boolean sampleIt, boolean showAttributeGuiIfNeeded) throws Exception make the observations from the given datachoice- Parameters:
dataChoice
- the data choicesubset
- data selection to subset withbbox
- bounding box to subsettrackParam
- the parameter to use for thetracksampleIt
- do we just sample or do we read the full set of obsshowAttributeGuiIfNeeded
- popup the gui if we have a problem- Returns:
- the field
- Throws:
Exception
- On badness
-
getDelimiter
Get the delimiter to use for the given file. If its xls then use ','- Parameters:
source
- source file- Returns:
- delimiter to use
-
getContents
Get the contents of the file as a string- Parameters:
sourceFile
- the contents- Returns:
- the contents as a string
- Throws:
Exception
- probably an IOException
-
getContents
Read the given source file and return the text contents of it. If the source file is a xls file then convert to csv text- Parameters:
sourceFile
- The source file (or url)sampleIt
- if true, then just read on ob- Returns:
- The contents
- Throws:
Exception
- On badness
-
makeObs
public FieldImpl makeObs(String contents, String delimiter, DataSelection subset, ucar.unidata.geoloc.LatLonRect bbox, String trackParam, boolean sampleIt, boolean showAttributeGuiIfNeeded) throws Exception make the observations from the given datachoice- Parameters:
contents
- The text contentsdelimiter
- The delimitersubset
- data selection to subset withbbox
- bounding box to subsettrackParam
- the parameter to use for thetracksampleIt
- do we just sample or do we read the full set of obsshowAttributeGuiIfNeeded
- popup the gui if we have a problem- Returns:
- the field
- Throws:
Exception
- On badness
-
changeMetadata
Show the metadata gui- Throws:
IOException
- On badness
-
getDelimiter
Get the delimiter used in the text file- Returns:
- delimiter
-
setDelimiter
Get the delimiter used in the text file- Parameters:
delim
- delimiter
-
applyNames
update the gui- Parameters:
line
- the sampled text line
-
deleteMetaData
Remove the given key from the saved mapping. Write out the file- Parameters:
key
- key
-
writePlugin
public void writePlugin()write the plugin -
writeHeader
public void writeHeader()write the header text to a file -
popupMetaDataMenu
Show the metadata preference menu- Parameters:
near
- The component to show the menu near
-
saveMetaDataMap
public void saveMetaDataMap()Save the meta data -
applyProperties
public boolean applyProperties()apply properties- Overrides:
applyProperties
in classPointDataSource
- Returns:
- ok
-
addPropertiesTabs
add to properties tab- Overrides:
addPropertiesTabs
in classPointDataSource
- Parameters:
tabbedPane
- tab
-
applySavedMetaDataFromUI
THis gets called from the Preferences menu and sets the metadata and also updates the skipRows- Parameters:
metadata
- The metadata
-
applySavedMetaDataFromUIInner
This gets called in a thread from the applySavedMetaDataFromUI method- Parameters:
metadata
- The metadata
-
applySavedMetaData
Init the widgets- Parameters:
metadata
- The metadata
-
equals
Check to see if this TextPointDataSource is equal to the object in question.- Overrides:
equals
in classFilesDataSource
- Parameters:
o
- object in question- Returns:
- true if they are the same or equivalent objects
-
hashCode
public int hashCode()Get the hashcode for this object -
getPointCategories
Get the default categories for data from PointDataSource-s- Overrides:
getPointCategories
in classPointDataSource
- Returns:
- list of categories
-
findLatLonAltIndices
Find the lat/lon/alt indicides- Parameters:
type
- the type to search- Returns:
- the indicies in the tuple
-
getSample
Read a sample of the data. e.g., just the first ob- Overrides:
getSample
in classPointDataSource
- Parameters:
dataChoice
- The data choice- Returns:
- The first ob
- Throws:
Exception
- On badness
-
doMakeDataChoices
public void doMakeDataChoices()Make the data choices- Overrides:
doMakeDataChoices
in classPointDataSource
-
getPropertiesComponents
Add to properties gui- Overrides:
getPropertiesComponents
in classPointDataSource
- Parameters:
comps
- properties comps
-
getDataInner
protected Data getDataInner(DataChoice dataChoice, DataCategory category, DataSelection dataSelection, Hashtable requestProperties) throws VisADException, RemoteException Get the data represented by this class. Calls makeObs, real work needs to be implemented there.- Overrides:
getDataInner
in classPointDataSource
- Parameters:
dataChoice
- choice for datacategory
- category of datadataSelection
- subselection propertiesrequestProperties
- additional selection properties (not used here)- Returns:
- Data object representative of the choice
- Throws:
RemoteException
- Java RMI errorVisADException
- VisAD Error
-
main2
test- Parameters:
args
- args- Throws:
Exception
- On badness
-
main
main- Parameters:
args
- args- Throws:
Exception
- on badness
-
setMap
Set the Map property.- Parameters:
value
- The new value for Map
-
getMap
Get the Map property.- Returns:
- The Map
-
setParams
Set the Params property.- Parameters:
value
- The new value for Params
-
getParams
Get the Params property.- Returns:
- The Params
-
setMetaDataFields
Set the MetaDataFields property.- Parameters:
value
- The new value for MetaDataFields
-
getMetaDataFields
Get the MetaDataFields property.- Returns:
- The MetaDataFields
-
setGroupVarName
Set the GroupVarName property.- Parameters:
value
- The new value for GroupVarName
-
getGroupVarName
Get the GroupVarName property.- Returns:
- The GroupVarName
-
setSkipRows
public void setSkipRows(int value) Set the SkipRows property.- Parameters:
value
- The new value for SkipRows
-
getSkipRows
public int getSkipRows()Get the SkipRows property.- Returns:
- The SkipRows
-