Skip to content

Commit

Permalink
Fix temporal range slices (exclude end)
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Apr 6, 2020
1 parent 6cfa144 commit 3f8c28b
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/core/qgstemporalnavigationobject.cpp
Expand Up @@ -82,9 +82,9 @@ QgsDateTimeRange QgsTemporalNavigationObject::dateTimeRangeForFrameNumber( long
const QDateTime end = start.addSecs( nextFrame * mFrameDuration.seconds() );

if ( end <= mTemporalExtents.end() )
return QgsDateTimeRange( begin, end );
return QgsDateTimeRange( begin, end, true, false );

return QgsDateTimeRange( begin, mTemporalExtents.end() );
return QgsDateTimeRange( begin, mTemporalExtents.end(), true, false );
}

void QgsTemporalNavigationObject::setTemporalExtents( const QgsDateTimeRange &temporalExtents )
Expand Down
28 changes: 14 additions & 14 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Expand Up @@ -301,7 +301,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-61</y>
<y>0</y>
<width>629</width>
<height>824</height>
</rect>
Expand Down Expand Up @@ -457,7 +457,7 @@ border-radius: 2px;</string>
<widget class="QgsDateTimeEdit" name="mStartStaticDateTimeEdit">
<property name="dateTime">
<datetime>
<hour>6</hour>
<hour>4</hour>
<minute>3</minute>
<second>57</second>
<year>2020</year>
Expand Down Expand Up @@ -501,7 +501,7 @@ border-radius: 2px;</string>
<widget class="QgsDateTimeEdit" name="mReferenceDateTimeEdit">
<property name="dateTime">
<datetime>
<hour>18</hour>
<hour>17</hour>
<minute>20</minute>
<second>36</second>
<year>2020</year>
Expand Down Expand Up @@ -612,7 +612,7 @@ border-radius: 2px;</string>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="mPostgresRasterTemporalLabel">
<property name="text">
<string>If the dataset contains multiple rasters belonging to a time series, specifiy the field that contains the time information, the type of the field can be any type that can be converted to a timestamp. A default value can be specified and it will be used when the temporal controller is not requesting any particular time.</string>
<string>If the dataset contains multiple rasters belonging to a time series, specify the field that contains the time information, the type of the field can be any type that can be converted to a timestamp. A default value can be specified and it will be used when the temporal controller is not requesting any particular time.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down Expand Up @@ -678,8 +678,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>680</height>
<width>470</width>
<height>514</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
Expand Down Expand Up @@ -1278,8 +1278,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>680</height>
<width>332</width>
<height>477</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
Expand Down Expand Up @@ -1631,8 +1631,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>680</height>
<width>98</width>
<height>45</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
Expand Down Expand Up @@ -1849,8 +1849,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>680</height>
<width>531</width>
<height>205</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
Expand Down Expand Up @@ -2079,8 +2079,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>680</height>
<width>325</width>
<height>667</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_12">
Expand Down
16 changes: 8 additions & 8 deletions tests/src/python/test_provider_postgresraster.py
Expand Up @@ -58,7 +58,7 @@ def _load_test_table(cls, schemaname, tablename, basename=None):
with open(os.path.join(TEST_DATA_DIR, 'provider', 'postgresraster', basename + '.sql'), 'r') as f:
sql = f.read()
conn.executeSql(sql)
assert (tablename in [n.tableName() for n in conn.tables(schemaname)], tablename + ' not found!')
assert (tablename in [n.tableName() for n in conn.tables(schemaname)]), tablename + ' not found!'

@classmethod
def setUpClass(cls):
Expand All @@ -74,7 +74,7 @@ def setUpClass(cls):
cls._load_test_table('public', 'raster_3035_tiled_composite_pk')
cls._load_test_table('public', 'raster_3035_untiled_multiple_rows')
cls._load_test_table('idro', 'cosmo_i5_snow', 'bug_34823_pg_raster')
cls._load_test_table('public', 'raster_4326_time_series')
cls._load_test_table('public', 'raster_4326_time')

# Fix timing issues in backend
#time.sleep(1)
Expand Down Expand Up @@ -334,29 +334,29 @@ def _test_block(rl, expected_block, expected_single):
self.assertEqual(block.value(0, 0), expected_single)

# First check that setting different temporal default values we get different results
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-01T00:00:00' temporalFieldIndex='2'".format(table='raster_4326_time_serie', schema='public'), 'pg_layer', 'postgresraster')
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-01T00:00:00' temporalFieldIndex='2'".format(table='raster_4326_time', schema='public'), 'pg_layer', 'postgresraster')

_test_block(rl, [161, 218, 113, 142], 226)

rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-05T00:00:00' temporalFieldIndex='2'".format(table='raster_4326_time_serie', schema='public'), 'pg_layer', 'postgresraster')
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-05T00:00:00' temporalFieldIndex='2'".format(table='raster_4326_time', schema='public'), 'pg_layer', 'postgresraster')

_test_block(rl, [227, 254, 179, 206], 254)

# Check that manually setting a subsetString we get the same results
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"data\" = '2020-04-01'".format(table='raster_4326_time_serie', schema='public'), 'pg_layer', 'postgresraster')
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"data\" = '2020-04-01'".format(table='raster_4326_time', schema='public'), 'pg_layer', 'postgresraster')

_test_block(rl, [161, 218, 113, 142], 226)

rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"data\" = '2020-04-05'".format(table='raster_4326_time_serie', schema='public'), 'pg_layer', 'postgresraster')
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} sql=\"data\" = '2020-04-05'".format(table='raster_4326_time', schema='public'), 'pg_layer', 'postgresraster')

_test_block(rl, [227, 254, 179, 206], 254)

# Now check if the varchar temporal field works the same
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-01T00:00:00' temporalFieldIndex='3'".format(table='raster_4326_time_serie', schema='public'), 'pg_layer', 'postgresraster')
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-01T00:00:00' temporalFieldIndex='3'".format(table='raster_4326_time', schema='public'), 'pg_layer', 'postgresraster')

_test_block(rl, [161, 218, 113, 142], 226)

rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-05T00:00:00' temporalFieldIndex='3'".format(table='raster_4326_time_serie', schema='public'), 'pg_layer', 'postgresraster')
rl = QgsRasterLayer(self.dbconn + " sslmode=disable table={table} schema={schema} temporalDefaultTime='2020-04-05T00:00:00' temporalFieldIndex='3'".format(table='raster_4326_time', schema='public'), 'pg_layer', 'postgresraster')

_test_block(rl, [227, 254, 179, 206], 254)

Expand Down
53 changes: 53 additions & 0 deletions tests/testdata/provider/postgresraster/raster_4326_time.sql

Large diffs are not rendered by default.

0 comments on commit 3f8c28b

Please sign in to comment.