public class FlatFileReader extends Object
FlatFileDataSource
.Modifier and Type | Field and Description |
---|---|
private int |
band |
private int |
bandCount |
private boolean |
bigEndian |
private int |
dataScale |
private String |
delimiter |
private boolean |
eastPositive |
private int |
elements |
private float[] |
floatData
Float values read from the file.
|
private String |
interleave
Data parameters
|
private String |
latFile |
private int |
latlonScale |
private int |
lines
Dimensions
|
private static org.slf4j.Logger |
logger
Logging object.
|
private String |
lonFile |
private double |
lrLat |
private double |
lrLon |
private int |
myFormat
Format this object is representing.
|
private int |
myNavigation |
private int |
navElements |
(package private) CoordinateSystem |
navigationCoords |
(package private) Gridded2DSet |
navigationSet |
private int |
navLines
Nav dimensions
|
private int |
offset |
private int |
stride |
private int |
strideElements |
private int |
strideLines |
private double |
ulLat
Nav parameters
|
private double |
ulLon |
private String |
unit |
private String |
url
The url
|
Constructor and Description |
---|
FlatFileReader()
Ctor for xml encoding
|
FlatFileReader(String filename)
CTOR
|
FlatFileReader(String filename,
int lines,
int elements)
CTOR
|
Modifier and Type | Method and Description |
---|---|
private static int |
bytesTo1ByteUInt(byte[] bytes,
int offset) |
private static int |
bytesTo2ByteSInt(byte[] bytes,
int offset) |
private static int |
bytesTo2ByteUInt(byte[] bytes,
int offset) |
private static float |
bytesTo4ByteFloat(byte[] bytes,
int offset) |
private static int |
bytesTo4ByteSInt(byte[] bytes,
int offset) |
private static double |
bytesToDouble(byte[] bytes) |
private static long |
bytesToLong(byte[] bytes) |
Data |
getData()
Return a valid data object for a DataSource.
|
private Data |
getDataFromImage()
Make a
FlatField from an Image. |
private FlatField |
getFlatField()
|
float[] |
getFloats()
Return the array of floats making up the data.
|
private Gridded2DSet |
getNavigationSetFromBounds()
Make a Gridded2DSet from bounds.
|
private Gridded2DSet |
getNavigationSetFromFiles()
Make a Gridded2DSet from files.
|
private void |
makeCoordinateSystem()
Create navigation info if it hasn't been built
|
private void |
readFloatsFromAscii()
Read floats from an ASCII file.
|
private void |
readFloatsFromBinary()
Read floats from a binary file.
|
void |
setAsciiInfo(String delimiter,
int dataScale)
Change format to ASCII.
|
void |
setBinaryInfo(int format,
String interleave,
boolean bigEndian,
int offset,
int band,
int bandCount)
Set metadata required to properly read from file.
|
void |
setEastPositive(boolean eastPositive)
Specify whether or not East is positive.
|
void |
setImageInfo()
Change format to image.
|
void |
setNavBounds(double ulLat,
double ulLon,
double lrLat,
double lrLon)
Set the geographic bounding box.
|
void |
setNavFiles(String latFile,
String lonFile,
int latlonScale)
Specify the files to use for navigation.
|
void |
setStride(int stride)
Change the "stride" to the specified value.
|
void |
setUnit(String unit)
Change the unit.
|
String |
toString()
String representation of the current
FlatFileReader . |
private static final org.slf4j.Logger logger
private int lines
private int elements
private int strideLines
private int strideElements
private int band
private int bandCount
private int stride
private int navLines
private int navElements
private String interleave
private boolean bigEndian
private int offset
private int dataScale
private double ulLat
private double ulLon
private double lrLat
private double lrLon
private int latlonScale
private boolean eastPositive
private int myFormat
HeaderInfo.kFormatUnknown
.private int myNavigation
private float[] floatData
Gridded2DSet navigationSet
CoordinateSystem navigationCoords
public FlatFileReader()
public FlatFileReader(String filename)
filename
- Filename to read.public FlatFileReader(String filename, int lines, int elements)
filename
- Filename to read.lines
- Number of lines.elements
- Number of elements.public void setBinaryInfo(int format, String interleave, boolean bigEndian, int offset, int band, int bandCount)
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.public void setAsciiInfo(String delimiter, int dataScale)
delimiter
- Data value delimiter.dataScale
- Data scale factor.public void setImageInfo()
public void setNavBounds(double ulLat, double ulLon, double lrLat, double lrLon)
ulLat
- Upper left latitude.ulLon
- Upper left longitude.lrLat
- Lower right latitude.lrLon
- Lower right longitude.public void setNavFiles(String latFile, String lonFile, int latlonScale)
latFile
- Path to the latitude file.lonFile
- Path to the longitude file.latlonScale
- Navigation value scaling.public void setEastPositive(boolean eastPositive)
eastPositive
- Whether or not East is positive.public void setStride(int stride)
stride
- New stride value. Values less than one will result in the
stride being set to one.private void readFloatsFromBinary()
private void readFloatsFromAscii()
private Data getDataFromImage()
FlatField
from an Image.url
.private Gridded2DSet getNavigationSetFromBounds()
private Gridded2DSet getNavigationSetFromFiles()
private void makeCoordinateSystem()
public Data getData()
public float[] getFloats()
private FlatField getFlatField() throws IOException, VisADException
floatData
converted into a VisAD FlatField
.IOException
- if there was a general IO problem.VisADException
- if there was a VisAD-related problem.private static int bytesTo1ByteUInt(byte[] bytes, int offset)
private static int bytesTo2ByteUInt(byte[] bytes, int offset)
private static int bytesTo2ByteSInt(byte[] bytes, int offset)
private static int bytesTo4ByteSInt(byte[] bytes, int offset)
private static float bytesTo4ByteFloat(byte[] bytes, int offset)
private static long bytesToLong(byte[] bytes)
private static double bytesToDouble(byte[] bytes)