public interface ILspTerrainSupport
ILspView
.
Each view automatically creates a terrain layer onto which terrain can be applied. This layer
automatically incorporates elevation data from other layers to provide a consolidated terrain
elevation model on which various other 2D data can be draped. If the terrain elevation is
disabled, draping is performed on the surface of the ellipsoid of the view's world reference
system.
The getDrapingContext
and convertFromDrapingContext
methods should
be used by a painter that drapes certain objects to correctly implement methods such as the
query
method:
public boolean query( ListaPaintGroups, ALspPaintQuery aQuery, TLspPaintRepresentationState aPaintRepresentationState, TLspContext aContext ) { if ( aQuery instanceof TLspIsTouchedQuery ) { // The terrain support can be retrieved from the view. ILspTerrainSupport drapingSupport = aContext.getView().getServices().getTerrainSupport(); // Your painter should know which objects to drape. // This is typically known by querying the style for the given object. boolean terrain = isDraping(aObject); // In case the object is draped on terrain, convert the context to a proper context for terrain. if (terrain) { aContext = drapingSupport.getDrapingContext(aContext); } // Implement the isTouched query, now using the proper aContext. TLspWorldTouchInfo touchInfo = ... // If the object is draped on terrain, convert the resulting world point in the terrain // context to a world point in the regular context by including the elevation. // The terrain support provides a method for this. if (touchInfo != null && terrain) { TLcdXYZPoint convertedWorldPoint = new TLcdXYZPoint(); drapingSupport.convertFromDrapingContextSFCT(touchInfo.getTouchedWorldPoint(), aContext, convertedWorldPoint); touchInfo = new TLspWorldTouchInfo(touchInfo.getDomainObject(), convertedWorldPoint, touchInfo.getElevationMode()); } // Return the result return true; } else { // Handle other queries similarly ... } }
ILspView.getServices()
,
TLspViewServices.getTerrainSupport()
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aListener)
Adds the given listener to receive property change events.
|
void |
addTerrainChangeListener(ILspTerrainChangeListener aListener)
Adds the given listener to receive change events when the terrain that is painted in the
view changes.
|
void |
convertFromDrapingContextSFCT(ILcdPoint aDrapingWorldPoint,
TLspContext aContext,
ILcd3DEditablePoint aWorldPointSFCT)
Converts the given world point in the draping context back to the regular context.
|
ILspStyler |
getBackgroundStyler()
Returns the styler for the background layers.
|
TLspContext |
getDrapingContext(TLspContext aContext)
Converts the given context to a context that should be used
for objects to be draped.
|
ILspView |
getDrapingView()
Returns the draping view used for objects that are draped.
|
ILcdEarthTileSet |
getElevationTileSet()
Returns a tileset with exactly one coverage containing the elevation data of the terrain.
|
ILcdHeightProvider |
getModelHeightProvider(ILcdGeoReference aGeoReference,
double aPixelDensity)
Returns a height provider based on the terrain contained in the terrain layer.
|
ILcdPoint |
getPointOnTerrain(ILcdPoint aViewPoint,
TLspContext aContext)
Gets the front-most point in world coordinates on the terrain.
|
ILcdBounds |
getViewBoundsForDraping(ILcdBounds aViewBounds,
TLspContext aContext)
Converts the given view space bounds to a bounds that should be used
to check for interaction with objects in the draping view.
|
ILcdHeightProvider |
getViewDependentHeightProvider(ILcdGeoReference aGeoReference,
boolean aValidHeightsOnly)
Returns a height provider that computes heights based on the tiles that are currently loaded by
the terrain painter associated with the terrain layer.
|
ILcdPoint |
getViewPointForDraping(ILcdPoint aViewPoint,
TLspContext aContext)
Converts the given view space point to a point that should be used
to check for interaction with objects in the draping view.
|
default ILcdPoint |
intersectTerrain(ILcdPoint aWorldOrigin,
ILcdPoint aWorldDestination,
boolean aForceUseTerrain,
TLspContext aContext)
Equivalent to
intersectTerrain(ILcdPoint, ILcdPoint, TLspContext) , but can
also return intersections when the view is set to 2D. |
ILcdPoint |
intersectTerrain(ILcdPoint aWorldOrigin,
ILcdPoint aWorldDestination,
TLspContext aContext)
Finds a point on the terrain that is the first intersection of the ray
originating from the given origin and cast in the direction of the given destination
(both defined in the view's world reference system).
|
boolean |
isDrapingOnTerrain()
Returns
true only if the terrain is visible and contains data
and if the view is configured as a 3D view. |
boolean |
isElevationEnabled()
Returns whether the elevation of the terrain is enabled.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
Removes the given listener so that it stops receiving property change events.
|
void |
removeTerrainChangeListener(ILspTerrainChangeListener aListener)
Removes the given listener so that it stops receiving terrain change events.
|
void |
setBackgroundStyler(ILspStyler aStyler)
Sets the styler for the background layers.
|
void |
setElevationEnabled(boolean aEnabled)
Sets whether the elevation of the terrain is enabled.
|
ILspStyler getBackgroundStyler()
setBackgroundStyler(com.luciad.view.lightspeed.style.styler.ILspStyler)
void setBackgroundStyler(ILspStyler aStyler)
ILspLayer.LayerType.BACKGROUND
that are at the bottom of
the view (that is there is no non non-background or non-raster layers below these layers).
Changing the background styler is typically more efficient then changing the styles of the
individual background raster layers.
The specified styler can submit:
TLspRasterStyle
instance:
mandatory, this controls the style of the raster valuesTLspImageProcessingStyle
instance: a image processing
operator chain applied to the rasteraStyler
- a stylerboolean isElevationEnabled()
true
if the elevation of the terrain is enabledsetElevationEnabled(boolean)
void setElevationEnabled(boolean aEnabled)
aEnabled
- true
if the elevation of the terrain should be enabledsetElevationEnabled(boolean)
ILcdHeightProvider getViewDependentHeightProvider(ILcdGeoReference aGeoReference, boolean aValidHeightsOnly)
aGeoReference
- the geographic reference of the height provideraValidHeightsOnly
- true
if only valid heights may be returnedIllegalArgumentException
- when aGeoReference is a 3D reference.ILcdHeightProvider
ILcdHeightProvider getModelHeightProvider(ILcdGeoReference aGeoReference, double aPixelDensity)
aPixelDensity
parameter can be used to select a proper level of detail. This
density is expressed in the specified geographic reference. When sampling the height at
multiple points the pixel density should typically to match the distance between two samples:
1 / d^2
, where d
is the distance between two samples in the specified
geographic reference.aGeoReference
- the geographic reference of the height provideraPixelDensity
- the pixel density of the height data that should be usedIllegalArgumentException
- when aGeoReference is a 3D reference.ILcdHeightProvider
ILcdEarthTileSet getElevationTileSet()
ILcdPoint getPointOnTerrain(ILcdPoint aViewPoint, TLspContext aContext)
isDrapingOnTerrain()
returns false
), the intersection at zero elevation
(i.e., with the ellipsoid or z=0 plane) is returned.
If no intersection is found, null
is returned.
The implementation can use the level of detail of the terrain as currently shown in the view.
The layer dependent attributes of the aContext
argument are not relevant for this
method.
When used in 2D, the result will have a z-coordinate always equal to 0.
aViewPoint
- a point in view coordinatesaContext
- the context for the pointnull
if no
intersection is found.ILcdPoint intersectTerrain(ILcdPoint aWorldOrigin, ILcdPoint aWorldDestination, TLspContext aContext)
isDrapingOnTerrain()
returns false
), the intersection at zero elevation (i.e. with the
ellipsoid or z=0 plane) is returned. If no intersection is found, null
is returned.
Note that the ray doesn't end at the passed destination.
The layer dependent attributes of theaContext
argument are not relevant for this
method.aWorldOrigin
- the ray originaWorldDestination
- a point somewhere along the rayaContext
- the context of the pointsnull
if no intersection is founddefault ILcdPoint intersectTerrain(ILcdPoint aWorldOrigin, ILcdPoint aWorldDestination, boolean aForceUseTerrain, TLspContext aContext)
intersectTerrain(ILcdPoint, ILcdPoint, TLspContext)
, but can
also return intersections when the view is set to 2D. The aForceUseTerrain
controls this behavior. When the value is false
, this method behaves exactly
like the one that does not have the extra boolean parameter. When it is true
,
this method will perform intersection tests with the 3D terrain regardless of the
current state of the view.aWorldOrigin
- the ray originaWorldDestination
- a point somewhere along the rayaForceUseTerrain
- set to true to produce 3D intersections even in a 2D viewaContext
- the context of the pointsnull
if
no intersection is foundTLspContext getDrapingContext(TLspContext aContext)
aContext
- the original contextILcdPoint getViewPointForDraping(ILcdPoint aViewPoint, TLspContext aContext)
aViewPoint
- the view point to convertaContext
- the original contextILcdBounds getViewBoundsForDraping(ILcdBounds aViewBounds, TLspContext aContext)
aViewBounds
- the view bounds to convertaContext
- the original contextILspView getDrapingView()
void convertFromDrapingContextSFCT(ILcdPoint aDrapingWorldPoint, TLspContext aContext, ILcd3DEditablePoint aWorldPointSFCT)
isTouched
implementations for objects that are draped.
The layer dependent attributes of the aContext
argument are not relevant for this
method.
Note that the returned point does not take into account the altitude exaggeration of the view. If needed this has to be applied separately.
aDrapingWorldPoint
- the point in world coordinates in the draping contextaContext
- the contextaWorldPointSFCT
- the world point in the regular contextvoid addPropertyChangeListener(PropertyChangeListener aListener)
aListener
- the listener to be addedvoid removePropertyChangeListener(PropertyChangeListener aListener)
aListener
- the listener to removevoid addTerrainChangeListener(ILspTerrainChangeListener aListener)
aListener
- the listener to be addedvoid removeTerrainChangeListener(ILspTerrainChangeListener aListener)
aListener
- the listener to removeboolean isDrapingOnTerrain()
true
only if the terrain is visible and contains data
and if the view is configured as a 3D view.