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
FieldsModifier and TypeFieldDescriptionstatic final intOutput buffer size in kilobytes.Fields inherited from class noaa.coastwatch.io.EarthDataWriter
info, isCanceled, variables, writeProgress, writeVariableName, writeVariables -
Constructor Summary
ConstructorsConstructorDescriptionTextWriter(EarthDataInfo info, String file) Creates a new text file from the specified earth data info and file name. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the writer and frees any resources.voidflush()Flushes all unwritten data to the destination.voidsetCoords(boolean coords) Sets coordinate printing.voidsetDecimals(int decimals) Sets the decimal places.voidsetDelimiter(String delimiter) Sets the field delimiter.voidsetHeader(boolean header) Sets the header flag.voidsetMissing(Number missing) Sets the missing value.voidsetReverse(boolean reverse) Sets the reverse flag.protected voidwriteHeader(DataVariable var) Writes a dimension header.protected voidWrites 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.NaNis 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.NaNis 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:EarthDataWriterFlushes all unwritten data to the destination.- Specified by:
flushin 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:EarthDataWriterCloses the writer and frees any resources. Theflushmethod is called prior to closing.- Specified by:
closein classEarthDataWriter- Throws:
IOException- if the data destination had I/O errors.
-