public class KMLRegion extends KMLAbstractObject
altitudeMode
attribute of a Region's geographic LatLonAltBox
as follows:
LatLonAltBox
.LatLonAltBox
, and who's upper and lower altitude are
specified by its minAltitude and maxAltitude, relative to ground level.LatLonAltBox
, and who's upper and lower altitude are specified by its minAltitude and maxAltitude,
relative to mean sea level.altitudeMode
attribute of a Region's geographic LatLonAltBox
as follows:
KMLTraversalContext's
detail hint, then
comparing that scaled distance to the Region's min and max pixel sizes in meters (the Region sector's area divided by
minLodPixels
and maxLodPixels
, respectively). The Region is active when the scaled distance
is less than or equal to the min pixel size in meters and greater than the max pixel size in meters. The detail hint
may be specified by calling setDetailHint
on the top level KMLRoot
(the KMLRoot loaded by
the application).minLodPixels
and maxLodPixels
. The Region is active when the pixel count is greater or
equal to minLodPixels
and less than maxLodPixels
.minLodPixels
and maxLodPixels
. The Region is active when the
pixel count is greater or equal to minLodPixels
and less than maxLodPixels
.isActive
method for determining if a Region is
active for a specified DrawContext
.
Regions do not apply directly to KML containers, because a descendant feature can override the container's Region
with its own Region. If a feature does not specify a Region it inherits the Region of its nearest ancestor. Since a
child feature's Region may be larger or have a less restrictive level of detail range than its ancestor's Region, the
visibility of an entire KML feature tree cannot be determined based on a container's Region. Instead, visibility must
be determined at each leaf feature.
Limitations Modifier and Type | Class and Description |
---|---|
protected static class |
KMLRegion.RegionData
RegionData holds a Region's computed data used during a single call to Region.isActive ,
and is unique to a particular Globe . |
Modifier and Type | Field and Description |
---|---|
protected KMLRegion.RegionData |
currentData
Identifies the active globe-dependent data for the current invocation of
isActive . |
protected static int |
DEFAULT_DATA_GENERATION_INTERVAL
The default time in milliseconds a
RegionData element may exist in this Region's
regionDataCache before it must be regenerated: 6 seconds. |
protected static double |
DEFAULT_DETAIL_HINT_ORIGIN
The default value that configures KML scene resolution to screen resolution as the viewing distance changes:
2.8.
|
protected static int |
DEFAULT_UNUSED_DATA_LIFETIME
The default time in milliseconds a
RegionData element may exist in this Region's
regionDataCache without being used before it is evicted: 1 minute. |
protected double |
detailHintOrigin
The default value that configures KML scene resolution to screen resolution as the viewing distance changes.
|
protected long |
maxExpiryTime
The maximum lifespan of this Region's computed data, in milliseconds.
|
protected long |
minExpiryTime
The minimum lifespan of this Region's computed data, in milliseconds.
|
protected ShapeDataCache |
regionDataCache
Holds globe-dependent computed Region data.
|
MSG_BOX_CHANGED, MSG_GEOMETRY_CHANGED, MSG_LINK_CHANGED, MSG_STYLE_CHANGED, MSG_TIME_CHANGED, MSG_VIEW_CHANGED
CHARACTERS_CONTENT, fields, namespaceURI, parent
Constructor and Description |
---|
KMLRegion(java.lang.String namespaceURI)
Creates a new
KMLRegion with the specified namespace URI, but otherwise does nothing. |
Modifier and Type | Method and Description |
---|---|
void |
applyChange(KMLAbstractObject sourceValues) |
protected KMLRegion.RegionData |
createCacheEntry(DrawContext dc)
Creates and returns a new
RegionData instance specific to this Region instance. |
protected void |
doMakeAbsoluteRegionData(DrawContext dc,
KMLLatLonAltBox box)
Produces the
Extent and the Sector for this Region. |
protected void |
doMakeClampToGroundRegionData(DrawContext dc,
KMLLatLonAltBox box)
Produces the
Extent and the Sector for this Region. |
protected void |
doMakeRegionData(DrawContext dc)
Produces the data used to determine whether this Region is active for the specified
DrawContext . |
protected void |
doMakeRelativeToGroundRegionData(DrawContext dc,
KMLLatLonAltBox box)
Produces the
Extent and the Sector for this Region. |
protected KMLRegion.RegionData |
getCurrentData()
Returns the data cache entry for the current invocation of
isActive . |
protected double |
getDetailFactor(KMLTraversalContext tc)
Indicates the detail factor that configures KML scene resolution to screen resolution as the viewing distance
changes.
|
KMLLatLonAltBox |
getLatLonAltBox()
Indicates the bounding box that must be in view for this this Region to be considered active.
|
KMLLod |
getLod()
Indicates the level of detail criteria that must be satisfied for this Region to be considered active.
|
protected boolean |
intersectsFrustum(DrawContext dc)
Indicates whether this Region intersects the viewing frustum for the specified
DrawContext . |
boolean |
isActive(KMLTraversalContext tc,
DrawContext dc)
Indicates whether this Region is active on the specified
DrawContext . |
protected boolean |
isRegionActive(KMLTraversalContext tc,
DrawContext dc)
Indicates whether this Region is active on the specified
DrawContext . |
protected boolean |
isRegionVisible(DrawContext dc)
Indicates whether this Region is visible for the specified
DrawContext . |
protected boolean |
isSectorSupported(Sector sector)
Determines if a Sector is supported by this Region implementation.
|
protected void |
makeRegionData(DrawContext dc)
Produces the data used to determine whether this Region is active for the specified
DrawContext . |
protected boolean |
meetsAbsoluteLodCriteria(KMLTraversalContext tc,
DrawContext dc,
KMLLod lod)
Indicates whether the specified
DrawContext meets this Region's level of detail criteria. |
protected boolean |
meetsClampToGroundLodCriteria(KMLTraversalContext tc,
DrawContext dc,
KMLLod lod)
Indicates whether the specified
DrawContext meets this Region's level of detail criteria. |
protected boolean |
meetsLodCriteria(KMLTraversalContext tc,
DrawContext dc)
Indicates whether the specified
DrawContext meets this Region's level of detail criteria. |
protected boolean |
meetsRelativeToGroundLodCriteria(KMLTraversalContext tc,
DrawContext dc,
KMLLod lod)
Indicates whether the specified
DrawContext meets this Region's level of detail criteria. |
protected boolean |
meetsScreenAreaCriteria(DrawContext dc,
KMLLod lod)
Indicates whether this Region's projected screen area on the specified
DrawContext is in the range
specified by lod . |
protected boolean |
mustRegenerateData(DrawContext dc)
Indicates whether this Region's data must be recomputed, either as a result of a change in the
Globe's state or the expiration of the geometry regeneration interval. |
void |
onChange(Message msg) |
protected void |
reset() |
getId, getRoot, getTargetId, onMessage
allocate, doAddCharacters, doAddEventAttribute, doAddEventContent, doParseEventAttributes, doParseEventContent, freeResources, getAConstructor, getCharacters, getField, getField, getFields, getNamespaceURI, getParent, hasField, hasField, hasFields, mergeFields, newInstance, overrideFields, parse, parseCharacterContent, removeField, setField, setField, setFields, setNamespaceURI, setParent
protected KMLRegion.RegionData currentData
isActive
. The active data
is drawn from the regionDataCache
at the beginning of the isActive
method.protected static final int DEFAULT_DATA_GENERATION_INTERVAL
RegionData
element may exist in this Region's
regionDataCache
before it must be regenerated: 6 seconds.protected static final double DEFAULT_DETAIL_HINT_ORIGIN
protected static final int DEFAULT_UNUSED_DATA_LIFETIME
RegionData
element may exist in this Region's
regionDataCache
without being used before it is evicted: 1 minute.protected double detailHintOrigin
KMLRoot's
detail hint specifies deviations from this default. Initially
DEFAULT_DETAIL_HINT_ORIGIN
.protected long maxExpiryTime
DEFAULT_DATA_GENERATION_INTERVAL
.protected long minExpiryTime
DEFAULT_DATA_GENERATION_INTERVAL - 1000
.protected ShapeDataCache regionDataCache
isActive
.
Initialized to a new ShapeDataCache
with maxTimeSinceLastUsed
set to
DEFAULT_UNUSED_DATA_LIFETIME
.public KMLRegion(java.lang.String namespaceURI)
KMLRegion
with the specified namespace URI, but otherwise does nothing. The new Region
has no bounding box and no level of detail range.namespaceURI
- the qualifying namespace URI. May be null
to indicate no namespace
qualification.public void applyChange(KMLAbstractObject sourceValues)
applyChange
in class KMLAbstractObject
protected KMLRegion.RegionData createCacheEntry(DrawContext dc)
RegionData
instance specific to this Region instance.dc
- the current draw context.protected void doMakeAbsoluteRegionData(DrawContext dc, KMLLatLonAltBox box)
Extent
and the Sector
for this Region. Assumes this region's altitude mode
is absolute
. A KMLRegion.RegionData
must be current
when this method is called.dc
- the current draw context.box
- the Region's geographic bounding box.protected void doMakeClampToGroundRegionData(DrawContext dc, KMLLatLonAltBox box)
Extent
and the Sector
for this Region. Assumes this region's altitude mode
is clampToGround
. A KMLRegion.RegionData
must be
current when this method is called.dc
- the current draw context.box
- the Region's geographic bounding box.protected void doMakeRegionData(DrawContext dc)
DrawContext
.
This method is called by makeRegionData
upon determining that the current RegionData must be
recomputed, either as a result of a change in the Globe's
state or the expiration of the geometry
regeneration interval. A KMLRegion.RegionData
must be current
when this method is called.dc
- the current draw context.makeRegionData(gov.nasa.worldwind.render.DrawContext)
protected void doMakeRelativeToGroundRegionData(DrawContext dc, KMLLatLonAltBox box)
Extent
and the Sector
for this Region. Assumes this region's altitude mode
is relativeToGround
. A KMLRegion.RegionData
must be
current when this method is called.dc
- the current draw context.box
- the Region's geographic bounding box.protected KMLRegion.RegionData getCurrentData()
isActive
.isActive
.protected double getDetailFactor(KMLTraversalContext tc)
detailHintOrigin
plus the KMLTraversalContext's
detail hint.tc
- the KML traversal context that specifies the detail hint.detailHintOrigin
plus the traversal context's detailHintOrigin
.public KMLLatLonAltBox getLatLonAltBox()
null
.null
indicating that this Region has no bounding
box restriction.public KMLLod getLod()
null
.null
indicating that this Region has no level of
detail restriction.protected boolean intersectsFrustum(DrawContext dc)
DrawContext
. A
KMLRegion.RegionData
must be current when this method is called.
This returns true
if this Region has no bounding box, or if its bounding box cannot be computed for
any reason.dc
- the DrawContext
who's frustum is tested against this Region's bounding box.true
if this Region's bounding box intersects the DrawContext's
frustum,
otherwise false
.public boolean isActive(KMLTraversalContext tc, DrawContext dc)
DrawContext
. A Region is active if its
bounding box intersects the viewing frustum, and its level of detail criteria are met for the specified traversal
context and draw context.
This always returns true
if this Region has no bounding box, or if its bounding box is in the
viewing frustum and this Region has no lod criteria.tc
- the current KML traversal context.dc
- the DrawContext
used to determine whether this Region is active.true
if this Region is active; otherwise false
.java.lang.IllegalArgumentException
- if either the KMLTraversalContext
or the DrawContext
is null
.protected boolean isRegionActive(KMLTraversalContext tc, DrawContext dc)
DrawContext
. A Region is active if its
bounding box intersects the viewing frustum, and its level of detail criteria are met for the specified traversal
context and draw context. This is called by isActive
and its return value may be cached during a
single frame.tc
- the current KML traversal context.dc
- the DrawContext
used to determine whether this Region is active.true
if this Region is active; otherwise false
.protected boolean isRegionVisible(DrawContext dc)
DrawContext
. If this Region's
altitudeMode
is clampToGround
, this Region is considered visible if its sector
intersects the DrawContext's
visible sector and its frustum intersects the
DrawContext's
viewing frustum. Otherwise, this Region is considered visible its frustum intersects
the DrawContext's
viewing frustum.dc
- the DrawContext
used to test this Region for visibility.true
if this Region is visible, otherwise false
.protected boolean isSectorSupported(Sector sector)
sector
- Sector to test.true
if sector
is with [-90, 90] latitude and [-180, 180] longitude.protected void makeRegionData(DrawContext dc)
DrawContext
.
This attempts to re-use RegionData
already been calculated this frame, or previously calculated
RegionData
that is still valid and has not expired. This method is called by isActive
prior to determining if this Region is actually active.dc
- the current draw context.isActive(gov.nasa.worldwind.ogc.kml.impl.KMLTraversalContext, gov.nasa.worldwind.render.DrawContext)
protected boolean meetsAbsoluteLodCriteria(KMLTraversalContext tc, DrawContext dc, KMLLod lod)
DrawContext
meets this Region's level of detail criteria. Assumes
this region's altitude mode is absolute
. A KMLRegion.RegionData
must be current when this method is called.tc
- the current KML traversal context.dc
- the DrawContext
to test.lod
- the level of detail criteria that must be met.true
if the DrawContext's
meets this Region's level of detail criteria,
otherwise false
.protected boolean meetsClampToGroundLodCriteria(KMLTraversalContext tc, DrawContext dc, KMLLod lod)
DrawContext
meets this Region's level of detail criteria. Assumes
this region's altitude mode is clampToGround
. A KMLRegion.RegionData
must be current when this method is called.tc
- the current KML traversal context.dc
- the DrawContext
to test.lod
- the level of detail criteria that must be met.true
if the DrawContext's
meets this Region's level of detail criteria,
otherwise false
.protected boolean meetsLodCriteria(KMLTraversalContext tc, DrawContext dc)
DrawContext
meets this Region's level of detail criteria. A
KMLRegion.RegionData
must be current when this method is called.
This returns true
if this Region has no level of criteria, or if its level of detail cannot be
compared against the bounding box for any reason.tc
- the current KML traversal context.dc
- the DrawContext
to test.true
if the DrawContext's
meets this Region's level of detail criteria,
otherwise false
.protected boolean meetsRelativeToGroundLodCriteria(KMLTraversalContext tc, DrawContext dc, KMLLod lod)
DrawContext
meets this Region's level of detail criteria. Assumes
this region's altitude mode is relativeToGround
. A KMLRegion.RegionData
must be current when this method is called.tc
- the current KML traversal context.dc
- the DrawContext
to test.lod
- the level of detail criteria that must be met.true
if the DrawContext's
meets this Region's level of detail criteria,
otherwise false
.protected boolean meetsScreenAreaCriteria(DrawContext dc, KMLLod lod)
DrawContext
is in the range
specified by lod
.dc
- the DrawContext
to test.lod
- the level of detail criteria that must be met.true
if this Region's screen area meets the level of detail criteria, otherwise
false
.protected boolean mustRegenerateData(DrawContext dc)
Globe's
state or the expiration of the geometry regeneration interval.
A KMLRegion.RegionData
must be current when this method is
called.dc
- the current draw context.true
if this Region's data must be regenerated, otherwise false
.public void onChange(Message msg)
onChange
in class KMLAbstractObject
protected void reset()