org.geotools.swing.tool
Class GridLayerHelper
java.lang.Object
org.geotools.swing.tool.InfoToolHelper<java.util.List<java.lang.Number>>
org.geotools.swing.tool.GridLayerHelper
public class GridLayerHelper
- extends InfoToolHelper<java.util.List<java.lang.Number>>
Helper class used by InfoTool
to query MapLayers
with raster feature data (GridCoverage2D
or AbstractGridCoverage2DReader
).
- Since:
- 2.6
- Version:
- $URL: http://svn.osgeo.org/geotools/tags/2.6.5/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/GridLayerHelper.java $
- Author:
- Michael Bedward
- See Also:
InfoTool
,
VectorLayerHelper
Method Summary |
java.util.List<java.lang.Number> |
getInfo(DirectPosition2D pos,
java.lang.Object... params)
Get band values at the given position |
boolean |
isValid()
Query if this helper has a reference to a MapContext and MapLayer . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
covRef
protected final java.lang.ref.WeakReference<GridCoverage2D> covRef
GridLayerHelper
public GridLayerHelper(MapContext context,
MapLayer layer)
- Create a new helper to work with the given raster data source.
- Parameters:
context
- the MapContext
associated with this helperrasterSource
- an instance of either
GridCoverage2D
or {@code AbstractGridCoverage2DReader
getInfo
public java.util.List<java.lang.Number> getInfo(DirectPosition2D pos,
java.lang.Object... params)
throws java.lang.Exception
- Get band values at the given position
- Specified by:
getInfo
in class InfoToolHelper<java.util.List<java.lang.Number>>
- Parameters:
pos
- the location to queryparams
- not used at present
- Returns:
- a
List
of band values; will be empty if pos
was
outside the coverage bounds
- Throws:
java.lang.Exception
- if the grid coverage could not be queried- See Also:
InfoToolHelper.isValid()
isValid
public boolean isValid()
- Query if this helper has a reference to a
MapContext
and MapLayer
.
Helpers only hold a WeakReference to the map context and layer
with which they are working to avoid blocking garbage collection when layers are
discarded. If this method returns false
the helper should be re-created.
//
// Example using a VectorLayerHelper...
//
VectorLayerHelper helper = ...
if (helper != null && helper.isValid()) {
FeatureCollection coll = helper.getInfo(queryLocation, ...);
// do something useful with results
} else {
// (Re-)create the helper
// Note: example only; this obviously depends on your use case
helper = new VectorLayerHelper(context, layer);
}
- Specified by:
isValid
in class InfoToolHelper<java.util.List<java.lang.Number>>
- Returns:
Copyright © 1996-2010 Geotools. All Rights Reserved.