Class TLcdViewHeightProvider<S extends ILcdView & ILcdLayered>
- All Implemented Interfaces:
ILcdBounded
,ILcdHeightProvider
- Direct Known Subclasses:
TLcyViewHeightProvider
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.
Sample code
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.
- Since:
- 9.1
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Key used to denote that only visible layers are used when creating anILcdHeightProvider
. -
Constructor Summary
ModifierConstructorDescriptionTLcdViewHeightProvider
(S aView, ILcdLayerHeightProviderFactory aLayerHeightProviderFactory, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProvider
using a given view, anILcdLayerHeightProviderFactory
and a list of optional and required properties.TLcdViewHeightProvider
(S aView, ILcdModelHeightProviderFactory aModelHeightProviderFactory, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProvider
using a given view, anILcdModelHeightProviderFactory
and a list of optional and required properties.protected
TLcdViewHeightProvider
(S aView, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProvider
using a given view and a list of optional or required properties. -
Method Summary
Modifier and TypeMethodDescriptionReturns theILcdBounds
by which the geometry of thisILcdBounded
object is bounded.Returns theILcdLayerHeightProviderFactory
to be used when creating anILcdHeightProvider
.Returns theILcdModelHeightProviderFactory
to be used when creating anILcdHeightProvider
.double
retrieveHeightAt
(ILcdPoint aPoint) Returns the height at the given point.
-
Field Details
-
Constructor Details
-
TLcdViewHeightProvider
protected TLcdViewHeightProvider(S aView, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProvider
using a given view and a list of optional or required properties. TheTLcdViewHeightProvider
doesn't contain anILcdModelHeightProviderFactory
orILcdLayerHeightProviderFactory
.- Parameters:
aView
- a layered view.aRequiredProperties
- the required properties.aOptionalProperties
- the optional properties.
-
TLcdViewHeightProvider
public TLcdViewHeightProvider(S aView, ILcdModelHeightProviderFactory aModelHeightProviderFactory, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProvider
using a given view, anILcdModelHeightProviderFactory
and a list of optional and required properties.- Parameters:
aView
- a layered view.aModelHeightProviderFactory
- anILcdModelHeightProviderFactory
.aRequiredProperties
- the required properties.aOptionalProperties
- the optional properties.
-
TLcdViewHeightProvider
public TLcdViewHeightProvider(S aView, ILcdLayerHeightProviderFactory aLayerHeightProviderFactory, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProvider
using a given view, anILcdLayerHeightProviderFactory
and a list of optional and required properties.- Parameters:
aView
- a layered view.aLayerHeightProviderFactory
- anILcdLayerHeightProviderFactory
.aRequiredProperties
- the required properties.aOptionalProperties
- the optional properties.
-
-
Method Details
-
getModelHeightProviderFactory
Returns theILcdModelHeightProviderFactory
to be used when creating anILcdHeightProvider
.- Returns:
- the
ILcdModelHeightProviderFactory
.
-
getLayerHeightProviderFactory
Returns theILcdLayerHeightProviderFactory
to be used when creating anILcdHeightProvider
.- Returns:
- the
ILcdLayerHeightProviderFactory
-
retrieveHeightAt
Description copied from interface:ILcdHeightProvider
Returns the height at the given point.- Specified by:
retrieveHeightAt
in interfaceILcdHeightProvider
- Parameters:
aPoint
- a 2D point, in the horizontal reference that is determined by the implementation.- Returns:
- the elevation at the given point, in the vertical reference that
is determined by the implementation. The value may also be
Double.NaN
, if the elevation is not known.
-
getBounds
Description copied from interface:ILcdBounded
Returns theILcdBounds
by which the geometry of thisILcdBounded
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 ofTLcdLonLatBounds
orTLcdXYBounds
.- Specified by:
getBounds
in interfaceILcdBounded
- Returns:
- the
ILcdBounds
by which the geometry of thisILcdBounded
object is bounded.
-