[GRASS-SVN] r69586 - in grass/trunk/lib/python/temporal: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 27 11:53:19 PDT 2016
Author: huhabla
Date: 2016-09-27 11:53:19 -0700 (Tue, 27 Sep 2016)
New Revision: 69586
Modified:
grass/trunk/lib/python/temporal/register.py
grass/trunk/lib/python/temporal/testsuite/test_register_function.py
Log:
temporal framework: Register function fixed issue #3168
Modified: grass/trunk/lib/python/temporal/register.py
===================================================================
--- grass/trunk/lib/python/temporal/register.py 2016-09-27 18:20:29 UTC (rev 69585)
+++ grass/trunk/lib/python/temporal/register.py 2016-09-27 18:53:19 UTC (rev 69586)
@@ -283,7 +283,9 @@
# Try to read an existing time stamp from the grass spatial database
# in case this map wasn't already registered in the temporal database
- if not is_in_db:
+ # Read the spatial database time stamp only, if no time stamp was provided for this map
+ # as method argument or in the input file
+ if not is_in_db and not start:
map.read_timestamp_from_grass()
# Set the valid time
Modified: grass/trunk/lib/python/temporal/testsuite/test_register_function.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/test_register_function.py 2016-09-27 18:20:29 UTC (rev 69585)
+++ grass/trunk/lib/python/temporal/testsuite/test_register_function.py 2016-09-27 18:53:19 UTC (rev 69586)
@@ -44,7 +44,7 @@
expression="register_map_2 = 2")
self.strds_abs = tgis.open_new_stds(name="register_test_abs", type="strds", temporaltype="absolute",
- title="Test strds", descr="Test strds", semantic="field",
+ title="Test strds", descr="Test strds", semantic="field",
overwrite=True)
self.strds_rel = tgis.open_new_stds(name="register_test_rel", type="strds", temporaltype="relative",
title="Test strds", descr="Test strds", semantic="field",
@@ -114,6 +114,58 @@
self.assertEqual(start, datetime.datetime(2001, 1, 1))
self.assertEqual(end, datetime.datetime(2001, 1, 3))
+ def test_absolute_time_strds_3(self):
+ """Test the registration of maps with absolute time in a
+ space time raster dataset. The timestamps are set via method arguments and with the
+ c-interface. The timestamps of the method arguments should overwrite the
+ time stamps set via the C-interface.
+ """
+
+ ciface = tgis.get_tgis_c_library_interface()
+ ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001")
+
+ tgis.register_maps_in_space_time_dataset(type="raster", name=self.strds_abs.get_name(),
+ maps="register_map_1",
+ start="2001-02-01", increment="1 day",
+ interval=True)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 2, 1))
+ self.assertEqual(end, datetime.datetime(2001, 2, 2))
+
+ self.strds_abs.select()
+ start, end = self.strds_abs.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 2, 1))
+ self.assertEqual(end, datetime.datetime(2001, 2, 2))
+
+ def test_absolute_time_strds_4(self):
+ """Test the registration of maps with absolute time in a
+ space time raster dataset. The timestamps are set via method arguments and with the
+ c-interface. The timestamps of the method arguments should overwrite the
+ time stamps set via the C-interface. The C-interface sets relative time stamps.
+ """
+
+ ciface = tgis.get_tgis_c_library_interface()
+ ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 day")
+
+ tgis.register_maps_in_space_time_dataset(type="raster", name=self.strds_abs.get_name(),
+ maps="register_map_1",
+ start="2001-02-01", increment="1 day",
+ interval=True)
+
+ map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+ map.select()
+ start, end = map.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 2, 1))
+ self.assertEqual(end, datetime.datetime(2001, 2, 2))
+
+ self.strds_abs.select()
+ start, end = self.strds_abs.get_absolute_time()
+ self.assertEqual(start, datetime.datetime(2001, 2, 1))
+ self.assertEqual(end, datetime.datetime(2001, 2, 2))
+
def test_absolute_time_1(self):
"""Test the registration of maps with absolute time
"""
More information about the grass-commit
mailing list