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 const qint64 time1 = datasetTimes.at( i - 1 );
41 const 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 const 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;
126 if ( !groupReference.isValid() )
127 groupReference = reference;
129 const QList<qint64> times = mDatasetTimeSinceGroupReference[it.key()];
130 qint64 durationSinceFirst = groupReference.msecsTo( reference );
131 qint64 durationSinceLast = groupReference.msecsTo( reference );
132 if ( !times.isEmpty() )
134 durationSinceFirst += times.first();
135 durationSinceLast += times.last();
138 if ( !end.isValid() || groupReference.addMSecs( durationSinceLast ) > end )
139 end = groupReference.addMSecs( durationSinceLast );
141 if ( !begin.isValid() || groupReference.addMSecs( durationSinceFirst ) > begin )
142 begin = groupReference.addMSecs( durationSinceFirst );
145 return QgsDateTimeRange( begin, end );
150 mTemporalUnit = timeUnit;
155 return mTemporalUnit;
163 const QList<qint64> ×List = mDatasetTimeSinceGroupReference[index.
group()];
164 if ( index.
dataset() < timesList.count() )
165 return timesList.at( index.
dataset() );
172 mGlobalReferenceDateTime = QDateTime();
173 mGroupsReferenceDateTime.clear();
174 mDatasetTimeSinceGroupReference.clear();
180 if ( mDatasetTimeSinceGroupReference.contains( group ) )
182 const QList<qint64> times = mDatasetTimeSinceGroupReference[group];
183 if ( times.count() > 1 )
184 ret = times.at( 1 ) - times.at( 0 );