Class TextPointDataSource

All Implemented Interfaces:
Sharable, DataSource, DataSourceFactory, XmlPersistable
Direct Known Subclasses:
AMRCTextPointDataSource, CDOGTextPointDataSource, DiamondPointDataSource, GNOMETextPointDataSource

public class TextPointDataSource extends PointDataSource
A data source for point data from a Text file
Author:
IDV Development Team
  • Field Details

  • Constructor Details

    • TextPointDataSource

      public TextPointDataSource() throws VisADException
      Default constructor
      Throws:
      VisADException - problem creating the object
    • TextPointDataSource

      public TextPointDataSource(String source) throws VisADException
      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 descriptor
      sources - 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 descriptor
      source - 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 descriptor
      source - source of data (filename/URL)
      name - the name of the dataset
      properties - extra properties for initialization
      Throws:
      VisADException - problem creating the data
  • Method Details

    • canSaveDataToLocalDisk

      public boolean canSaveDataToLocalDisk()
      Can we save locally
      Specified by:
      canSaveDataToLocalDisk in interface DataSource
      Overrides:
      canSaveDataToLocalDisk in class DataSourceImpl
      Returns:
      true if we can
    • setStreamProcessor

      public void setStreamProcessor(TextAdapter.StreamProcessor streamProcessor)
      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 interface DataSource
      Overrides:
      canDoGeoSelection in class DataSourceImpl
      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 class DataSourceImpl
      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 class PointDataSource
      Parameters:
      dataChoice - choice for data (source of data)
      subset - subsetting parameters
      bbox - The area subset. May be null.
      Returns:
      data of the form index -> (EarthLocation, Time, value_tuple)
      Throws:
      Exception - problem creating data
    • getSource

      protected String getSource(DataChoice dataChoice)
      the data choice
      Overrides:
      getSource in class PointDataSource
      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 choice
      subset - data selection to subset with
      bbox - bounding box to subset
      trackParam - the parameter to use for thetrack
      sampleIt - do we just sample or do we read the full set of obs
      showAttributeGuiIfNeeded - popup the gui if we have a problem
      Returns:
      the field
      Throws:
      Exception - On badness
    • getDelimiter

      protected String getDelimiter(String source)
      Get the delimiter to use for the given file. If its xls then use ','
      Parameters:
      source - source file
      Returns:
      delimiter to use
    • getContents

      protected final String getContents(String sourceFile) throws Exception
      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

      protected String getContents(String sourceFile, boolean sampleIt) throws Exception
      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 contents
      delimiter - The delimiter
      subset - data selection to subset with
      bbox - bounding box to subset
      trackParam - the parameter to use for thetrack
      sampleIt - do we just sample or do we read the full set of obs
      showAttributeGuiIfNeeded - popup the gui if we have a problem
      Returns:
      the field
      Throws:
      Exception - On badness
    • changeMetadata

      public void changeMetadata() throws IOException
      Show the metadata gui
      Throws:
      IOException - On badness
    • getDelimiter

      public String getDelimiter()
      Get the delimiter used in the text file
      Returns:
      delimiter
    • setDelimiter

      public void setDelimiter(String delim)
      Get the delimiter used in the text file
      Parameters:
      delim - delimiter
    • applyNames

      public void applyNames(String line)
      update the gui
      Parameters:
      line - the sampled text line
    • deleteMetaData

      public void deleteMetaData(String key)
      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

      public void popupMetaDataMenu(JComponent near)
      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 class PointDataSource
      Returns:
      ok
    • addPropertiesTabs

      public void addPropertiesTabs(JTabbedPane tabbedPane)
      add to properties tab
      Overrides:
      addPropertiesTabs in class PointDataSource
      Parameters:
      tabbedPane - tab
    • applySavedMetaDataFromUI

      public void applySavedMetaDataFromUI(TextPointDataSource.Metadata metadata)
      THis gets called from the Preferences menu and sets the metadata and also updates the skipRows
      Parameters:
      metadata - The metadata
    • applySavedMetaDataFromUIInner

      public void applySavedMetaDataFromUIInner(TextPointDataSource.Metadata metadata)
      This gets called in a thread from the applySavedMetaDataFromUI method
      Parameters:
      metadata - The metadata
    • applySavedMetaData

      public void applySavedMetaData(TextPointDataSource.Metadata metadata)
      Init the widgets
      Parameters:
      metadata - The metadata
    • equals

      public boolean equals(Object o)
      Check to see if this TextPointDataSource is equal to the object in question.
      Overrides:
      equals in class FilesDataSource
      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
      Overrides:
      hashCode in class Object
      Returns:
      hash code
    • getPointCategories

      protected List getPointCategories()
      Get the default categories for data from PointDataSource-s
      Overrides:
      getPointCategories in class PointDataSource
      Returns:
      list of categories
    • findLatLonAltIndices

      public static int[] findLatLonAltIndices(TupleType type)
      Find the lat/lon/alt indicides
      Parameters:
      type - the type to search
      Returns:
      the indicies in the tuple
    • getSample

      protected FieldImpl getSample(DataChoice dataChoice) throws Exception
      Read a sample of the data. e.g., just the first ob
      Overrides:
      getSample in class PointDataSource
      Parameters:
      dataChoice - The data choice
      Returns:
      The first ob
      Throws:
      Exception - On badness
    • doMakeDataChoices

      public void doMakeDataChoices()
      Make the data choices
      Overrides:
      doMakeDataChoices in class PointDataSource
    • getPropertiesComponents

      public void getPropertiesComponents(List comps)
      Add to properties gui
      Overrides:
      getPropertiesComponents in class PointDataSource
      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 class PointDataSource
      Parameters:
      dataChoice - choice for data
      category - category of data
      dataSelection - subselection properties
      requestProperties - additional selection properties (not used here)
      Returns:
      Data object representative of the choice
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • main2

      public static void main2(String[] args) throws Exception
      test
      Parameters:
      args - args
      Throws:
      Exception - On badness
    • main

      public static void main(String[] args) throws Exception
      main
      Parameters:
      args - args
      Throws:
      Exception - on badness
    • setMap

      public void setMap(String value)
      Set the Map property.
      Parameters:
      value - The new value for Map
    • getMap

      public String getMap()
      Get the Map property.
      Returns:
      The Map
    • setParams

      public void setParams(String value)
      Set the Params property.
      Parameters:
      value - The new value for Params
    • getParams

      public String getParams()
      Get the Params property.
      Returns:
      The Params
    • setMetaDataFields

      public void setMetaDataFields(List value)
      Set the MetaDataFields property.
      Parameters:
      value - The new value for MetaDataFields
    • getMetaDataFields

      public List getMetaDataFields()
      Get the MetaDataFields property.
      Returns:
      The MetaDataFields
    • setGroupVarName

      public void setGroupVarName(String value)
      Set the GroupVarName property.
      Parameters:
      value - The new value for GroupVarName
    • getGroupVarName

      public String 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