Class FlatFileReader

java.lang.Object
edu.wisc.ssec.mcidasv.data.FlatFileReader

public class FlatFileReader extends Object
Class that can read file formats associated with FlatFileDataSource.
  • Field Details

  • Constructor Details

    • FlatFileReader

      public FlatFileReader()
      Ctor for xml encoding
    • FlatFileReader

      public FlatFileReader(String filename)
      CTOR
      Parameters:
      filename - Filename to read.
    • FlatFileReader

      public FlatFileReader(String filename, int lines, int elements)
      CTOR
      Parameters:
      filename - Filename to read.
      lines - Number of lines.
      elements - Number of elements.
  • Method Details

    • setBinaryInfo

      public void setBinaryInfo(int format, String interleave, boolean bigEndian, int offset, int band, int bandCount)
      Set metadata required to properly read from file.
      Parameters:
      format - New format.
      interleave - Interleaving type.
      bigEndian - Whether or not data is big endian.
      offset - Data offset within file being read.
      band - Band to read.
      bandCount - Total number of bands.
    • setAsciiInfo

      public void setAsciiInfo(String delimiter, int dataScale)
      Change format to ASCII.
      Parameters:
      delimiter - Data value delimiter.
      dataScale - Data scale factor.
    • setImageInfo

      public void setImageInfo()
      Change format to image.
    • setNavBounds

      public void setNavBounds(double ulLat, double ulLon, double lrLat, double lrLon)
      Set the geographic bounding box.
      Parameters:
      ulLat - Upper left latitude.
      ulLon - Upper left longitude.
      lrLat - Lower right latitude.
      lrLon - Lower right longitude.
    • setNavFiles

      public void setNavFiles(String latFile, String lonFile, int latlonScale)
      Specify the files to use for navigation.
      Parameters:
      latFile - Path to the latitude file.
      lonFile - Path to the longitude file.
      latlonScale - Navigation value scaling.
    • setEastPositive

      public void setEastPositive(boolean eastPositive)
      Specify whether or not East is positive.
      Parameters:
      eastPositive - Whether or not East is positive.
    • setStride

      public void setStride(int stride)
      Change the "stride" to the specified value.
      Parameters:
      stride - New stride value. Values less than one will result in the stride being set to one.
    • setUnit

      public void setUnit(String unit)
      Change the unit.
      Parameters:
      unit - New unit.
    • readFloatsFromBinary

      private void readFloatsFromBinary()
      Read floats from a binary file.
    • readFloatsFromAscii

      private void readFloatsFromAscii()
      Read floats from an ASCII file.
    • getDataFromImage

      Make a FlatField from an Image.
      Returns:
      VisAD data object built from contents of url.
    • getNavigationSetFromBounds

      Make a Gridded2DSet from bounds.
      Returns:
      VisAD bounding box.
    • getNavigationSetFromFiles

      Make a Gridded2DSet from files.
      Returns:
      VisAD bounding box.
    • makeCoordinateSystem

      private void makeCoordinateSystem()
      Create navigation info if it hasn't been built
    • getData

      public Data getData()
      Return a valid data object for a DataSource.
      Returns:
      VisAD data object representing what has been read.
    • getFloats

      public float[] getFloats()
      Return the array of floats making up the data.
      Returns:
      Floats found within the file.
    • getFlatField

      Convert floatData into a FlatField.
      Returns:
      floatData converted into a VisAD FlatField.
      Throws:
      IOException - if there was a general IO problem.
      VisADException - if there was a VisAD-related problem.
    • toString

      public String toString()
      String representation of the current FlatFileReader.
      Overrides:
      toString in class Object
      Returns:
      String containing things like the URL along with lines and elements.
    • bytesTo1ByteUInt

      private static int bytesTo1ByteUInt(byte[] bytes, int offset)
    • bytesTo2ByteUInt

      private static int bytesTo2ByteUInt(byte[] bytes, int offset)
    • bytesTo2ByteSInt

      private static int bytesTo2ByteSInt(byte[] bytes, int offset)
    • bytesTo4ByteSInt

      private static int bytesTo4ByteSInt(byte[] bytes, int offset)
    • bytesTo4ByteFloat

      private static float bytesTo4ByteFloat(byte[] bytes, int offset)
    • bytesToLong

      private static long bytesToLong(byte[] bytes)
    • bytesToDouble

      private static double bytesToDouble(byte[] bytes)