Package noaa.coastwatch.io
Class TextWriter
java.lang.Object
noaa.coastwatch.io.EarthDataWriter
noaa.coastwatch.io.TextWriter
A text writer is an earth data writer that writes variable data
as a series of lines in an ASCII text file. An optional dimension
header may be prepended to each variable.
- Since:
- 3.1.0
- Author:
- Peter Hollemans, Mark Robinson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Output buffer size in kilobytes.Fields inherited from class noaa.coastwatch.io.EarthDataWriter
info, isCanceled, variables, writeProgress, writeVariableName, writeVariables
-
Constructor Summary
ConstructorDescriptionTextWriter
(EarthDataInfo info, String file) Creates a new text file from the specified earth data info and file name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the writer and frees any resources.void
flush()
Flushes all unwritten data to the destination.void
setCoords
(boolean coords) Sets coordinate printing.void
setDecimals
(int decimals) Sets the decimal places.void
setDelimiter
(String delimiter) Sets the field delimiter.void
setHeader
(boolean header) Sets the header flag.void
setMissing
(Number missing) Sets the missing value.void
setReverse
(boolean reverse) Sets the reverse flag.protected void
writeHeader
(DataVariable var) Writes a dimension header.protected void
Writes the variable data as a stream of text lines.Methods inherited from class noaa.coastwatch.io.EarthDataWriter
addVariable, cancel, finalize, getDestination, getProgress, getProgressLength, getProgressVariable
-
Field Details
-
DEFAULT_CHUNK_SIZE
public static final int DEFAULT_CHUNK_SIZEOutput buffer size in kilobytes.- See Also:
-
-
Constructor Details
-
TextWriter
Creates a new text file from the specified earth data info and file name. By default, each line contains the latitude, longitude, and data value to 6 decimal places, separated by a space with no header line. The double valueDouble.NaN
is used for the missing value.- Parameters:
info
- the earth data info object.file
- the new binary file name.- Throws:
IOException
- if an error occurred opening the file.
-
-
Method Details
-
setDecimals
public void setDecimals(int decimals) Sets the decimal places.- Parameters:
decimals
- the number of decimal places to use in coordinate value printing.
-
setCoords
public void setCoords(boolean coords) Sets coordinate printing.- Parameters:
coords
- the coordinate flag. If true, the earth location coordinates are printed along with each data value in the order latitude, longitude. Otherwise no coordinates are printed.
-
setReverse
public void setReverse(boolean reverse) Sets the reverse flag. If true, the order of latitude and longitude printing is reversed.- Parameters:
reverse
- the reverse flag.- See Also:
-
setDelimiter
Sets the field delimiter.- Parameters:
delimiter
- the field delimiter. The delimiter is used to separate multiple data fields on one line.
-
setHeader
public void setHeader(boolean header) Sets the header flag.- Parameters:
header
- the header flag. If true, a header line is printed prior to any data values. The header line consists of one integer specifying the number of dimensions followed by a series of integers specifying the dimension lengths. If false, no header line is printed.
-
setMissing
Sets the missing value.- Parameters:
missing
- the missing value. The missing value is used to represent missing or out of range data values. The missing value is printed when such data is encountered in the variable data. If the missing value is null, the valueDouble.NaN
is used.
-
writeHeader
Writes a dimension header. The header line consists of one integer specifying the number of dimensions followed by a series of integers specifying the dimension lengths.- Parameters:
var
- the data variable to write a header for.- Throws:
IOException
- if an error occurred writing the header data to the file.
-
flush
Description copied from class:EarthDataWriter
Flushes all unwritten data to the destination.- Specified by:
flush
in classEarthDataWriter
- Throws:
IOException
- if the data destination had I/O errors.
-
writeVariable
Writes the variable data as a stream of text lines.- Parameters:
var
- the data variable to write data for.- Throws:
IOException
- if an error occurred writing the data to the file.
-
close
Description copied from class:EarthDataWriter
Closes the writer and frees any resources. Theflush
method is called prior to closing.- Specified by:
close
in classEarthDataWriter
- Throws:
IOException
- if the data destination had I/O errors.
-