|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectInfoToolHelper<T>
public abstract class InfoToolHelper<T>
Abstract base class for helper classes used by InfoTool
to query
MapLayers
.
The primary reason for having this class is to avoid loading grid coverage classes unless they are really needed, and thus avoid the need for users to have JAI in the classpath when working with vector data.
The type parameter <T>
defines the return type of the
getInfo(org.geotools.geometry.DirectPosition2D, java.lang.Object...) method.
InfoTool
Constructor Summary | |
---|---|
protected |
InfoToolHelper(MapContent content,
CoordinateReferenceSystem dataCRS)
Protected constructor. |
Method Summary | |
---|---|
abstract T |
getInfo(DirectPosition2D pos,
Object... params)
Get feature data at the given position. |
MapContent |
getMapContent()
Get the MapContent associated with this helper. |
MathTransform |
getTransform()
Get the MathTransform to reproject data from the coordinate system of
the MapContext's to that of the MapLayer . |
protected boolean |
isTransformRequired()
Check if queries with this helper involve transforming between coordinate systems. |
abstract boolean |
isValid()
Query if this helper has a reference to a MapContext and MapLayer . |
protected void |
setCRS(CoordinateReferenceSystem crs)
Set the coordinate reference system that pertains to the feature data that will be queried by this helper. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected InfoToolHelper(MapContent content, CoordinateReferenceSystem dataCRS)
content
- the map contextdataCRS
- the coordinate reference system of the feature data that will be queried
by this helperMethod Detail |
---|
public abstract T getInfo(DirectPosition2D pos, Object... params) throws Exception
pos
- the location to queryparams
- additional parameters as optionally defined by the sub-class
T
as defined by the sub-class
Exception
isValid()
public abstract boolean isValid()
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);
}
public MapContent getMapContent()
MapContent
associated with this helper. The helper maintains
only a WeakReference to the context.
protected boolean isTransformRequired()
public MathTransform getTransform()
MathTransform
to reproject data from the coordinate system of
the MapContext's
to that of the MapLayer
.
null
if either the layer's coordinate system is the same
as that of the map context, or either has a null
CRS.protected void setCRS(CoordinateReferenceSystem crs)
crs
- data coordinate reference system
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |