public class TLcdAIXM51SnapshotTimeSliceProvider extends Object implements ILcdAIXM51TimeSliceProvider
Date
. The
snapshot is derived from the time slices in the feature based on the algorithm that is defined in
the AIXM 5.1 specification.
The specification requires that for every feature one valid baseline time slice should be present. This method however still tries to generate a snapshot from the available data, but it can not be guaranteed that the result is correct, as specified by the AIXM 5.1 specification.
If one of the time slices of a feature is already a snapshot time slice valid at the given date, this snapshot time slice is used in the resulting message, regardless of any other time slices. This behavior is correct in case you have a feature which only contains snapshots, and no other type of time slices. The specification does not prescribe how to merge snapshot time slices with other types of time slices that possibly conflict with the snapshots.
PREREQUISITE: This class assumes that the time slices in the features are sorted.
Sorting is automatically done by the AIXM 5 decoder by default, or can also be done with the
TLcdAIXM51MessageUtil
.
TLcdAIXM51MessageUtil.sortMessage(com.luciad.format.aixm51.model.abstractfeature.TLcdAIXM51AbstractAIXMMessage)
,
TLcdAIXM51ModelDecoder.setAutoSortTimeSlices(boolean)
,
TLcdAIXM51MessageUtil.generateSnapshot(com.luciad.format.aixm51.model.abstractfeature.TLcdAIXM51AbstractAIXMMessage,
Date)
Constructor and Description |
---|
TLcdAIXM51SnapshotTimeSliceProvider() |
Modifier and Type | Method and Description |
---|---|
Date |
getTime()
Returns the
Date that is set on this provider. |
<T extends TLcdAIXM51AbstractAIXMTimeSlice> |
getTimeSlice(TLcdAIXM51Feature<T> aFeature)
Returns a time slice that is selected or computed by this provider from the time slices of the
given feature.
|
<T extends TLcdAIXM51AbstractAIXMTimeSlice> |
getTimeSliceSFCT(TLcdAIXM51Feature<T> aFeature,
ILcdEditableTimeBounds aTimeBoundsSFCT)
Returns a snapshot time slice that is valid for the time instant that is set on this provider.
|
void |
setTime(Date aDate)
Sets the time instant for which snapshots should be created by this provider.
|
public void setTime(Date aDate)
aDate
- A valid datepublic Date getTime()
Date
that is set on this provider. By default this returns null.setTime(Date)
public <T extends TLcdAIXM51AbstractAIXMTimeSlice> T getTimeSliceSFCT(TLcdAIXM51Feature<T> aFeature, ILcdEditableTimeBounds aTimeBoundsSFCT)
aTimeBoundsSFCT
is not null, it will be set to the interval for which the
returned time slice will remain valid, assuming that the feature does not change. This interval
can be used to check whether an application needs to update its views.
This method can be used by extensions of this time slice provider to construct the intersection
of time bounds for all features for which a time slice has been requested. This intersection
can than be used to check whether changing the time will affect previously computed time
slices.
The following sample shows how to combine the time bounds for each feature in an intersected
bounds:
ILcdEditableTimeBounds featureBounds = new TLcdTimeBounds();
T timeSlice = getTimeSlice( aFeature, featureBounds );
if ( ILcdTimeBounds.Boundedness.BOUNDED.equals( featureBounds.getBeginTimeBoundedness() ) && featureBounds.getBeginTime() > intersectedBounds.getBeginTime() ) {
intersectedBounds.setBeginTime( featureBounds.getBeginTime() );
intersectedBounds.setBeginTimeBoundedness( Boundedness.BOUNDED );
}
if ( ILcdTimeBounds.Boundedness.BOUNDED.equals( featureBounds.getEndTimeBoundedness() ) && featureBounds.getEndTime() < intersectedBounds.getEndTime() ) {
intersectedBounds.setEndTime( featureBounds.getEndTime() );
intersectedBounds.setEndTimeBoundedness( Boundedness.BOUNDED );
}
return timeSlice;
The following check can be used to compare the intersection with a new date:
if ( intersectedBounds.getBeginTime() > aDate.getTime()
|| intersectedBounds.getEndTime() < aDate.getTime() )
//the date is outside the intersection, new snapshots will need to be generated
aFeature
- the feature for which a time slice needs to be returnedaTimeBoundsSFCT
- A parameter that will be initialized with the bounds for which the
returned time slice will be valid, can be null.public <T extends TLcdAIXM51AbstractAIXMTimeSlice> T getTimeSlice(TLcdAIXM51Feature<T> aFeature)
ILcdAIXM51TimeSliceProvider
getTimeSlice
in interface ILcdAIXM51TimeSliceProvider
aFeature
- the feature for which a time slice needs to be returned