Class MapReader
- java.lang.Object
-
- org.hortonmachine.gears.io.grasslegacy.io.MapReader
-
- Direct Known Subclasses:
GrassRasterReader
public abstract class MapReader extends Object
A map reader object
- Since:
- 1.1.0
- Author:
- Andrea Antonello - www.hydrologis.com, John Preston
-
-
Field Summary
Fields Modifier and Type Field Description static intCOLORprotected ColorTablecolorTablestatic intDATAprotected ObjectdataObjectprotected WindowdataWindowstatic StringFEATURECOLLECTIONprotected WindowfileWindowstatic intPOINT_READERstatic intRASTER_READERprotected intreaderTypestatic intVECTOR_READER
-
Constructor Summary
Constructors Constructor Description MapReader(int _readerType)Creates a new instance of MapReader
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclose()close the resource, deallocation whatever needed to be deallocatedColorTablegetColorTable()WindowgetDataWindow()abstract StringgetLegendString()WindowgetMapWindow()abstract ObjectgetNextData()abstract ColorMapBuffergetNextDataColor(int attIndex)ObjectgetOutputDataObject()ObjectgetParameter(String key, Object obj)abstract double[]getRange()intgetReaderType()abstract booleanhasMoreData(IHMProgressMonitor monitor)abstract booleanopen(String mapPath)Open the resourceabstract booleanopen(String fileName, String locationPath, String mapsetName)Open the resourcevoidsetDataWindow(Window window)Set the active reader window, i.e.voidsetOutputDataObject(Object outputDataObject)Define the output data object.voidsetParameter(String key, Object obj)utility to set particular parameters supported keys: "novalue" "matrixtype" "progressbar" "commandoptions"voidsetReaderType(int readerType)Define the reader type
-
-
-
Field Detail
-
RASTER_READER
public static final int RASTER_READER
- See Also:
- Constant Field Values
-
VECTOR_READER
public static final int VECTOR_READER
- See Also:
- Constant Field Values
-
POINT_READER
public static final int POINT_READER
- See Also:
- Constant Field Values
-
FEATURECOLLECTION
public static final String FEATURECOLLECTION
- See Also:
- Constant Field Values
-
COLOR
public static final int COLOR
- See Also:
- Constant Field Values
-
DATA
public static final int DATA
- See Also:
- Constant Field Values
-
fileWindow
protected Window fileWindow
-
dataWindow
protected Window dataWindow
-
colorTable
protected ColorTable colorTable
-
dataObject
protected Object dataObject
-
readerType
protected int readerType
-
-
Method Detail
-
setReaderType
public void setReaderType(int readerType)
Define the reader type- Parameters:
readerType- the type, can be one ofRASTER_READER,VECTOR_READER,POINT_READER
-
getReaderType
public int getReaderType()
- Returns:
- the reader type, can be one of
RASTER_READER,VECTOR_READER,POINT_READER
-
close
public abstract void close()
close the resource, deallocation whatever needed to be deallocated
-
setOutputDataObject
public void setOutputDataObject(Object outputDataObject)
Define the output data object. The output data object is the kind of result that the reader will give. This can be for example:- when you need to elaborate the data, a double matrix, so the odo would be new double[][]
- when you need to visualize the data, a floatbuffer, so the odo would be new
FloatBuffer
- Parameters:
outputDataObject- the output data object
-
getOutputDataObject
public Object getOutputDataObject()
- Returns:
- the output data object
-
getColorTable
public ColorTable getColorTable()
- Returns:
- the colortable object
-
getMapWindow
public Window getMapWindow()
- Returns:
- the window that corresponds to the map file that the reader has opened.
-
getDataWindow
public Window getDataWindow()
- Returns:
- the window that corresponds to the active window.
-
setDataWindow
public void setDataWindow(Window window)
Set the active reader window, i.e. the region out of which the reader will read- Parameters:
window- the region object
-
setParameter
public void setParameter(String key, Object obj)
utility to set particular parameters supported keys: "novalue" "matrixtype" "progressbar" "commandoptions"- Parameters:
key-obj-
-
getParameter
public Object getParameter(String key, Object obj)
- Parameters:
key- the parameter keyobj- a default return object- Returns:
- the parameter corrisponding to the passed key
-
open
public abstract boolean open(String fileName, String locationPath, String mapsetName)
Open the resource- Parameters:
fileName- the name of the resourcelocationPath- the path to the GRASS locationmapsetName- the name of the mapset holding the resource- Returns:
- true if the resource was successfully opened
-
open
public abstract boolean open(String mapPath)
Open the resource- Parameters:
mapPath- the full path to the resource that needs to be opened- Returns:
- true if the resource was successfully opened
-
hasMoreData
public abstract boolean hasMoreData(IHMProgressMonitor monitor) throws Exception
- Parameters:
monitor- progressmonitor- Returns:
- true, if the resource has more data to read
- Throws:
Exception
-
getNextData
public abstract Object getNextData()
- Returns:
- get the data object
-
getNextDataColor
public abstract ColorMapBuffer getNextDataColor(int attIndex)
- Parameters:
attIndex-- Returns:
- the data color
-
getLegendString
public abstract String getLegendString() throws IOException
- Returns:
- the string representing the legend
- Throws:
IOException
-
getRange
public abstract double[] getRange()
- Returns:
- an array containing the min and max value of the resource
-
-