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 ILcdPoints that are defined in this
reference. For example, if the reference is a TLcdGeodeticReference, the points passed to
ILcdHeightProvider.retrieveHeightAt(ILcdPoint) should be TLcdLonLatPoints.
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
FieldsModifier and TypeFieldDescriptionstatic final StringKey used to denote that only visible layers are used when creating anILcdHeightProvider. -
Constructor Summary
ConstructorsModifierConstructorDescriptionTLcdViewHeightProvider(S aView, ILcdLayerHeightProviderFactory aLayerHeightProviderFactory, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProviderusing a given view, anILcdLayerHeightProviderFactoryand a list of optional and required properties.TLcdViewHeightProvider(S aView, ILcdModelHeightProviderFactory aModelHeightProviderFactory, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProviderusing a given view, anILcdModelHeightProviderFactoryand a list of optional and required properties.protectedTLcdViewHeightProvider(S aView, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProviderusing a given view and a list of optional or required properties. -
Method Summary
Modifier and TypeMethodDescriptionReturns theILcdBoundsby which the geometry of thisILcdBoundedobject is bounded.Returns theILcdLayerHeightProviderFactoryto be used when creating anILcdHeightProvider.Returns theILcdModelHeightProviderFactoryto be used when creating anILcdHeightProvider.doubleretrieveHeightAt(ILcdPoint aPoint) Returns the height at the given point.
-
Field Details
-
KEY_ONLY_VISIBLE
Key used to denote that only visible layers are used when creating anILcdHeightProvider. The property should be a boolean. The default istrue- See Also:
-
-
Constructor Details
-
TLcdViewHeightProvider
protected TLcdViewHeightProvider(S aView, Map<String, Object> aRequiredProperties, Map<String, Object> aOptionalProperties) Constructs aTLcdViewHeightProviderusing a given view and a list of optional or required properties. TheTLcdViewHeightProviderdoesn't contain anILcdModelHeightProviderFactoryorILcdLayerHeightProviderFactory.- 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 aTLcdViewHeightProviderusing a given view, anILcdModelHeightProviderFactoryand 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 aTLcdViewHeightProviderusing a given view, anILcdLayerHeightProviderFactoryand 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 theILcdModelHeightProviderFactoryto be used when creating anILcdHeightProvider.- Returns:
- the
ILcdModelHeightProviderFactory.
-
getLayerHeightProviderFactory
Returns theILcdLayerHeightProviderFactoryto be used when creating anILcdHeightProvider.- Returns:
- the
ILcdLayerHeightProviderFactory
-
retrieveHeightAt
Description copied from interface:ILcdHeightProviderReturns the height at the given point.- Specified by:
retrieveHeightAtin 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:ILcdBoundedReturns theILcdBoundsby which the geometry of thisILcdBoundedobject 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
undefinedbounds. You can create undefined bounds using the default constructors ofTLcdLonLatBoundsorTLcdXYBounds.- Specified by:
getBoundsin interfaceILcdBounded- Returns:
- the
ILcdBoundsby which the geometry of thisILcdBoundedobject is bounded.
-