|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectInfoToolHelper<SimpleFeatureCollection>
VectorLayerHelper
public class VectorLayerHelper
Helper class used by InfoTool
to query MapLayers
with vector feature data.
Implementation note: this class keeps only a weak reference to
the MapLayer
it is working with to avoid memory leaks if
the layer is deleted.
InfoTool
,
GridLayerHelper
Constructor Summary | |
---|---|
VectorLayerHelper(MapContent context,
Layer layer)
Create a new helper to work with a MapLayer that has vector feature data. |
Method Summary | |
---|---|
SimpleFeatureCollection |
getInfo(DirectPosition2D pos,
Object... params)
Get feature data at the given position. |
Layer |
getMapLayer()
Get the MapLayer that this helper is working with. |
boolean |
isValid()
Query if this helper has a reference to a MapContext and MapLayer . |
Methods inherited from class InfoToolHelper |
---|
getMapContent, getTransform, isTransformRequired, setCRS |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VectorLayerHelper(MapContent context, Layer layer)
MapLayer
that has vector feature data.
layer
- the map layergeomAttributeName
- the name of the geometry attribute for Features
geomClass
- the geometry classMethod Detail |
---|
public 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);
}
isValid
in class InfoToolHelper<SimpleFeatureCollection>
public Layer getMapLayer()
MapLayer
that this helper is working with.
MapLayer
or null if the original layer is no longer validisValid()
public SimpleFeatureCollection getInfo(DirectPosition2D pos, Object... params) throws IOException
getInfo
in class InfoToolHelper<SimpleFeatureCollection>
params
- a Double
value for the search radius to use with
point or line featurespos
- the location to query
pos
; if
this helper is not valid an empty collection will be returned
IOException
- if the feature source for the layer cannot be accessedInfoToolHelper.isValid()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |