27 const QList<qint64> &datasetTimes = mDatasetTimeSinceGroupReference[group];
28 if ( datasetTimes.isEmpty() )
30 const QDateTime groupReference = mGroupsReferenceDateTime[group];
31 const qint64 timeSinceGroupReference =
32 timeSinceGlobalReference - mGlobalReferenceDateTime.msecsTo( groupReference );
34 if ( timeSinceGroupReference > datasetTimes.last()
35 || timeSinceGroupReference < datasetTimes.first() )
38 for (
int i = 1 ; i < datasetTimes.count(); ++i )
40 qint64 time1 = datasetTimes.at( i - 1 );
41 qint64 time2 = datasetTimes.at( i );
42 if ( time1 <= timeSinceGroupReference && timeSinceGroupReference <= time2 )
44 if ( abs( timeSinceGroupReference - time2 ) < abs( timeSinceGroupReference - time1 ) )
57 const QList<qint64> &datasetTimes = mDatasetTimeSinceGroupReference[group];
58 if ( datasetTimes.isEmpty() )
60 const QDateTime groupReference = mGroupsReferenceDateTime[group];
61 const qint64 timeSinceGroupReference =
62 timeSinceGlobalReference - mGlobalReferenceDateTime.msecsTo( groupReference );
64 if ( timeSinceGroupReference > datasetTimes.last()
65 || timeSinceGroupReference < datasetTimes.first() )
68 for (
int i = 1; i < datasetTimes.count(); ++i )
70 qint64 time = datasetTimes.at( i );
71 if ( timeSinceGroupReference < time )
80 if ( ( !mGlobalReferenceDateTime.isValid() && reference.isValid() ) ||
81 ( reference.isValid() && mGlobalReferenceDateTime.isValid() && reference < mGlobalReferenceDateTime ) )
82 mGlobalReferenceDateTime = reference;
84 mGroupsReferenceDateTime[group] = reference;
89 QList<qint64> &datasetTimes = mDatasetTimeSinceGroupReference[group];
90 datasetTimes.append( time );
101 return mGlobalReferenceDateTime.isValid();
106 return mGlobalReferenceDateTime;
112 return timeExtent( mGlobalReferenceDateTime );
119 for ( QHash<int, QDateTime>::const_iterator it = mGroupsReferenceDateTime.constBegin() ;
120 it != mGroupsReferenceDateTime.constEnd(); ++it )
122 QDateTime groupReference = it.value();
123 if ( !groupReference.isValid() )
124 groupReference = mGlobalReferenceDateTime;
127 if ( !groupReference.isValid() )
128 groupReference = reference;
130 const QList<qint64> times = mDatasetTimeSinceGroupReference[it.key()];
131 qint64 durationSinceFirst = groupReference.msecsTo( reference );
132 qint64 durationSinceLast = groupReference.msecsTo( reference );
133 if ( !times.isEmpty() )
135 durationSinceFirst += times.first();
136 durationSinceLast += times.last();
139 if ( !end.isValid() || groupReference.addMSecs( durationSinceLast ) > end )
140 end = groupReference.addMSecs( durationSinceLast );
142 if ( !begin.isValid() || groupReference.addMSecs( durationSinceFirst ) > begin )
143 begin = groupReference.addMSecs( durationSinceFirst );
146 return QgsDateTimeRange( begin, end );
151 mTemporalUnit = timeUnit;
156 return mTemporalUnit;
164 const QList<qint64> ×List = mDatasetTimeSinceGroupReference[index.
group()];
165 if ( index.
dataset() < timesList.count() )
166 return timesList.at( index.
dataset() );
173 mGlobalReferenceDateTime = QDateTime();
174 mGroupsReferenceDateTime.clear();
175 mDatasetTimeSinceGroupReference.clear();
181 if ( mDatasetTimeSinceGroupReference.contains( group ) )
183 const QList<qint64> times = mDatasetTimeSinceGroupReference[group];
184 if ( times.count() > 1 )
185 ret = times.at( 1 ) - times.at( 0 );