Package adams.data.io.input
Class ArcInfoASCIIGridReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractSpreadSheetReader
-
- adams.data.io.input.ArcInfoASCIIGridReader
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler,adams.core.Destroyable,adams.core.ErrorProvider,adams.core.GlobalInfoSupporter,adams.core.io.EncodingSupporter,adams.core.io.FileFormatHandler,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.SizeOfHandler,adams.core.Stoppable,adams.core.StoppableWithFeedback,adams.data.io.input.ChunkedSpreadSheetReader,adams.data.io.input.SpreadSheetReader,adams.data.spreadsheet.DataRowTypeHandler,adams.data.spreadsheet.SpreadSheetTypeHandler,Serializable
public class ArcInfoASCIIGridReader extends adams.data.io.input.AbstractSpreadSheetReader implements adams.data.io.input.ChunkedSpreadSheetReaderReads ASCII files in ESRI Grid format.
For more information see:
https://en.wikipedia.org/wiki/Esri_grid
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-data-row-type <adams.data.spreadsheet.DataRow> (property: dataRowType) The type of row to use for the data. default: adams.data.spreadsheet.DenseDataRow
-spreadsheet-type <adams.data.spreadsheet.SpreadSheet> (property: spreadSheetType) The type of spreadsheet to use for the data. default: adams.data.spreadsheet.DefaultSpreadSheet
-output-grid <boolean> (property: outputGrid) If enabled, a spreadsheet is generated that represents the data in the file rather than one value per row with GPS coordinates. default: false
-chunk-size <int> (property: chunkSize) The size of the chunks (= number of rows) of spreadsheets to output if not in grid mode. default: -1 minimum: -1
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_BOTTOMthe bottom corner key.static StringKEY_CELLSIZEthe number of columns key.static StringKEY_LEFTthe left corner key.static StringKEY_NODATAVALUEthe no data value key.static StringKEY_NUMCOLSthe number of columns key.static StringKEY_NUMROWSthe number of rows key.protected intm_ChunkSizethe chunk size.protected intm_Headerthe size of the header in rows.protected HashMap<String,String>m_MetaDatathe meta data.protected intm_Offsetthe current offset.protected booleanm_OutputGridwhether to output the grid instead the values alongside their GPS coordinates.protected List<String>m_Rawthe raw data.
-
Constructor Summary
Constructors Constructor Description ArcInfoASCIIGridReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringchunkSizeTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected adams.data.spreadsheet.SpreadSheetdoRead(File file)Performs the actual reading.intgetChunkSize()Returns the current chunk size (non-grid mode).adams.data.io.output.SpreadSheetWritergetCorrespondingWriter()Returns, if available, the corresponding writer.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.protected adams.data.io.input.AbstractSpreadSheetReader.InputTypegetInputType()Returns how to read the data, from a file, stream or reader.booleangetOutputGrid()Returns whether to output a grid of values (as stored in the file) instead of the values associated with their GPS coordinates.StringglobalInfo()Returns a string describing the object.booleanhasMoreChunks()Checks whether there is more data to read.static voidmain(String[] args)Runs the reader from the command-line.adams.data.spreadsheet.SpreadSheetnextChunk()Returns the next chunk.StringoutputGridTipText()Returns the tip text for this property.protected adams.data.spreadsheet.SpreadSheetreadData()Generates spreadsheets from the raw ASCII data.protected voidreset()Resets the scheme.voidsetChunkSize(int value)Sets the maximum chunk size (non-grid mode).voidsetOutputGrid(boolean value)Sets whether to output a grid of values (as stored in the file) instead of the values associated with their GPS coordinates.-
Methods inherited from class adams.data.io.input.AbstractSpreadSheetReader
canDecompress, check, dataRowTypeTipText, doRead, doRead, encodingTipText, getAdditionalInformation, getDataRowType, getDefaultDataRowType, getDefaultFormatExtension, getDefaultSpreadSheet, getEncoding, getLastError, getReaders, getSpreadSheetType, hasLastError, initialize, isStopped, read, read, read, read, runReader, setDataRowType, setEncoding, setLastError, setSpreadSheetType, spreadSheetTypeTipText, stopExecution, supportsCompressedInput
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
KEY_NUMCOLS
public static final String KEY_NUMCOLS
the number of columns key.- See Also:
- Constant Field Values
-
KEY_NUMROWS
public static final String KEY_NUMROWS
the number of rows key.- See Also:
- Constant Field Values
-
KEY_LEFT
public static final String KEY_LEFT
the left corner key.- See Also:
- Constant Field Values
-
KEY_BOTTOM
public static final String KEY_BOTTOM
the bottom corner key.- See Also:
- Constant Field Values
-
KEY_CELLSIZE
public static final String KEY_CELLSIZE
the number of columns key.- See Also:
- Constant Field Values
-
KEY_NODATAVALUE
public static final String KEY_NODATAVALUE
the no data value key.- See Also:
- Constant Field Values
-
m_OutputGrid
protected boolean m_OutputGrid
whether to output the grid instead the values alongside their GPS coordinates.
-
m_ChunkSize
protected int m_ChunkSize
the chunk size.
-
m_Header
protected int m_Header
the size of the header in rows.
-
m_Offset
protected int m_Offset
the current offset.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.core.option.AbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.data.io.input.AbstractSpreadSheetReader
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classadams.core.option.AbstractOptionHandler
-
setOutputGrid
public void setOutputGrid(boolean value)
Sets whether to output a grid of values (as stored in the file) instead of the values associated with their GPS coordinates.- Parameters:
value- true if to output grid
-
getOutputGrid
public boolean getOutputGrid()
Returns whether to output a grid of values (as stored in the file) instead of the values associated with their GPS coordinates.- Returns:
- true if to output grid
-
outputGridTipText
public String outputGridTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setChunkSize
public void setChunkSize(int value)
Sets the maximum chunk size (non-grid mode).- Specified by:
setChunkSizein interfaceadams.data.io.input.ChunkedSpreadSheetReader- Parameters:
value- the size of the chunks, < 1 denotes infinity
-
getChunkSize
public int getChunkSize()
Returns the current chunk size (non-grid mode).- Specified by:
getChunkSizein interfaceadams.data.io.input.ChunkedSpreadSheetReader- Returns:
- the size of the chunks, < 1 denotes infinity
-
chunkSizeTipText
public String chunkSizeTipText()
Returns the tip text for this property.- Specified by:
chunkSizeTipTextin interfaceadams.data.io.input.ChunkedSpreadSheetReader- Returns:
- tip text for this property suitable for displaying in the gui
-
getInputType
protected adams.data.io.input.AbstractSpreadSheetReader.InputType getInputType()
Returns how to read the data, from a file, stream or reader.- Specified by:
getInputTypein classadams.data.io.input.AbstractSpreadSheetReader- Returns:
- how to read the data
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatDescriptionin interfaceadams.data.io.input.SpreadSheetReader- Specified by:
getFormatDescriptionin classadams.data.io.input.AbstractSpreadSheetReader- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatExtensionsin interfaceadams.data.io.input.SpreadSheetReader- Specified by:
getFormatExtensionsin classadams.data.io.input.AbstractSpreadSheetReader- Returns:
- the extension (without the dot!)
-
getCorrespondingWriter
public adams.data.io.output.SpreadSheetWriter getCorrespondingWriter()
Returns, if available, the corresponding writer.- Specified by:
getCorrespondingWriterin interfaceadams.data.io.input.SpreadSheetReader- Returns:
- the writer, null if none available
-
readData
protected adams.data.spreadsheet.SpreadSheet readData()
Generates spreadsheets from the raw ASCII data.- Returns:
- the generated spreadsheet
-
doRead
protected adams.data.spreadsheet.SpreadSheet doRead(File file)
Performs the actual reading. Must handle compression itself, ifAbstractSpreadSheetReader.supportsCompressedInput()returns true.- Overrides:
doReadin classadams.data.io.input.AbstractSpreadSheetReader- Parameters:
file- the file to read from- Returns:
- the spreadsheet or null in case of an error
- See Also:
getInputType(),AbstractSpreadSheetReader.supportsCompressedInput()
-
hasMoreChunks
public boolean hasMoreChunks()
Checks whether there is more data to read.- Specified by:
hasMoreChunksin interfaceadams.data.io.input.ChunkedSpreadSheetReader- Returns:
- true if there is more data available
-
nextChunk
public adams.data.spreadsheet.SpreadSheet nextChunk()
Returns the next chunk.- Specified by:
nextChunkin interfaceadams.data.io.input.ChunkedSpreadSheetReader- Returns:
- the next chunk
-
main
public static void main(String[] args)
Runs the reader from the command-line. Use the optionAbstractSpreadSheetReader.OPTION_INPUTto specify the input file. If the optionAbstractSpreadSheetReader.OPTION_OUTPUTis specified then the read sheet gets output as .csv files in that directory.- Parameters:
args- the command-line options to use
-
-