public class TLcdViewHeightProvider<S extends ILcdView & ILcdLayered> extends Object implements ILcdHeightProvider
ILcdHeightProvider
retrieves height based on a view. It uses its layers or
models to retrieve the height data. This height provider is able to update itself
when a new layer is added or removed from the given view, when the visibility of
a layer is changed in the given view, or when the model in one of the layers is changed.
A class that requires a height provider based on a all raster models in a view could construct one as follows:
// Create a height provider factory for raster models.
ILcdModelHeightProviderFactory factory = new TLcdRasterModelHeightProviderFactory();
// Specify the desired properties for the height provider.
Map<String, Object> requiredProperties = new HashMap<String, Object>();
requiredProperties.put(ILcdModelHeightProviderFactory.KEY_GEO_REFERENCE, aModelReference);
Map<String, Object> optionalProperties = new HashMap<String, Object>();
optionalProperties.put(ALcdRasterModelHeightProviderFactory.KEY_PIXEL_DENSITY, 2.5);
// Create a height provider for all raster models in the view.
ILcdHeightProvider heightProvider =
new TLcdViewHeightProvider<ILcdGXYView>(aView,
factory,
requiredProperties,
optionalProperties);
A similar approach can be used based on the layers instead of the model by creating and adding an
ILcdLayerHeightProviderFactory
instance
instead of an ILcdModelHeightProviderFactory
instance. A combination of layer and
model height provider factories is not possible.
For many cases it is sufficient to add the ILcdModelHeightProviderFactory.KEY_GEO_REFERENCE
property. Not setting this property will generate an exception in most cases. When using a
ILcdHeightProvider
constructed with a specific ILcdGeoReference
as
required property, one can retrieve height using ILcdPoint
s that are defined in this
reference. For example, if the reference is a TLcdGeodeticReference
, the points passed to
ILcdHeightProvider.retrieveHeightAt(ILcdPoint)
should be TLcdLonLatPoint
s.
If the reference is a TLcdGridReference
, the points passed to it should be
TLcdXYPoints
.
Other properties that can be passed are for example :
ALcdRasterModelHeightProviderFactory.KEY_PIXEL_DENSITY
: This property determines
which raster is chosen from a multi level raster, or which level is chosen from a tile set.
In most cases, this property should be passed as an optional property since not all height
providers factories can interpret it.KEY_ONLY_VISIBLE
: This property is used to denote that only visible layers should
be used when creating a view height provider.This class is thread safe, as long as the given model and layer height provider factories
are thread safe, and as long as they produce ILcdHeightProvider
instances that
are thread safe. Note that TLcdViewHeightProvider<ILcdGXYView>
instances should always be
created on the EDT thread.
Modifier and Type | Field and Description |
---|---|
static String |
KEY_ONLY_VISIBLE
Key used to denote that only visible layers are used when creating an
ILcdHeightProvider . |
Modifier | Constructor and Description |
---|---|
|
TLcdViewHeightProvider(S aView,
ILcdLayerHeightProviderFactory aLayerHeightProviderFactory,
Map<String,Object> aRequiredProperties,
Map<String,Object> aOptionalProperties)
Constructs a
TLcdViewHeightProvider using a given view, an
ILcdLayerHeightProviderFactory and a list of optional and required
properties. |
|
TLcdViewHeightProvider(S aView,
ILcdModelHeightProviderFactory aModelHeightProviderFactory,
Map<String,Object> aRequiredProperties,
Map<String,Object> aOptionalProperties)
Constructs a
TLcdViewHeightProvider using a given view, an
ILcdModelHeightProviderFactory and a list of optional and required
properties. |
protected |
TLcdViewHeightProvider(S aView,
Map<String,Object> aRequiredProperties,
Map<String,Object> aOptionalProperties)
Constructs a
TLcdViewHeightProvider using a given view and a list of optional
or required properties. |
Modifier and Type | Method and Description |
---|---|
ILcdBounds |
getBounds()
Returns the
ILcdBounds by which the geometry of this ILcdBounded object
is bounded. |
ILcdLayerHeightProviderFactory |
getLayerHeightProviderFactory()
Returns the
ILcdLayerHeightProviderFactory to be used when creating an
ILcdHeightProvider . |
ILcdModelHeightProviderFactory |
getModelHeightProviderFactory()
Returns the
ILcdModelHeightProviderFactory to be used
when creating an ILcdHeightProvider . |
double |
retrieveHeightAt(ILcdPoint aPoint)
Returns the height at the given point.
|
public static final String KEY_ONLY_VISIBLE
ILcdHeightProvider
. The property should be a boolean.
The default is true
protected TLcdViewHeightProvider(S aView, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
TLcdViewHeightProvider
using a given view and a list of optional
or required properties. The TLcdViewHeightProvider
doesn't contain an
ILcdModelHeightProviderFactory
or ILcdLayerHeightProviderFactory
.aView
- a layered view.aRequiredProperties
- the required properties.aOptionalProperties
- the optional properties.public TLcdViewHeightProvider(S aView, ILcdModelHeightProviderFactory aModelHeightProviderFactory, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
TLcdViewHeightProvider
using a given view, an
ILcdModelHeightProviderFactory
and a list of optional and required
properties.aView
- a layered view.aModelHeightProviderFactory
- an ILcdModelHeightProviderFactory
.aRequiredProperties
- the required properties.aOptionalProperties
- the optional properties.public TLcdViewHeightProvider(S aView, ILcdLayerHeightProviderFactory aLayerHeightProviderFactory, Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
TLcdViewHeightProvider
using a given view, an
ILcdLayerHeightProviderFactory
and a list of optional and required
properties.aView
- a layered view.aLayerHeightProviderFactory
- an ILcdLayerHeightProviderFactory
.aRequiredProperties
- the required properties.aOptionalProperties
- the optional properties.public ILcdModelHeightProviderFactory getModelHeightProviderFactory()
ILcdModelHeightProviderFactory
to be used
when creating an ILcdHeightProvider
.ILcdModelHeightProviderFactory
.public ILcdLayerHeightProviderFactory getLayerHeightProviderFactory()
ILcdLayerHeightProviderFactory
to be used when creating an
ILcdHeightProvider
.ILcdLayerHeightProviderFactory
public double retrieveHeightAt(ILcdPoint aPoint)
ILcdHeightProvider
retrieveHeightAt
in interface ILcdHeightProvider
aPoint
- a 2D point, in the horizontal reference that is determined by
the implementation.Double.NaN
, if the elevation is not known.public ILcdBounds getBounds()
ILcdBounded
ILcdBounds
by which the geometry of this ILcdBounded
object
is bounded.
If the geometry does not allow retrieving valid bounds (for example a polyline with 0 points)
the return value is unspecified.
It is highly recommended to return an undefined
bounds.
You can create undefined bounds using the default constructors
of TLcdLonLatBounds
or TLcdXYBounds
.
getBounds
in interface ILcdBounded
ILcdBounds
by which the geometry of this ILcdBounded
object
is bounded.