Browse Source

Removed dateutil dependency. Now only a subset of ISO formatted time strings are supported for parsing in the temporal GIS framework.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53435 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 12 years ago
parent
commit
2e7acd8624

+ 1 - 1
lib/python/temporal/abstract_map_dataset.py

@@ -540,7 +540,7 @@ class AbstractMapDataset(TemporalMapRelations):
         if self.get_type() == "raster3d":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Raster3d Dataset --------------------------------------+"
+            print " +-------------------- 3D Raster Dataset -------------------------------------+"
         if self.get_type() == "vector":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678

+ 1 - 1
lib/python/temporal/abstract_space_time_dataset.py

@@ -80,7 +80,7 @@ class AbstractSpaceTimeDataset(AbstractDataset):
         if self.get_type() == "str3ds":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678
-            print " +-------------------- Space Time Raster3d Dataset ---------------------------+"
+            print " +-------------------- Space Time 3D Raster Dataset --------------------------+"
         if self.get_type() == "stvds":
             #                1         2         3         4         5         6         7
             #      0123456789012345678901234567890123456789012345678901234567890123456789012345678

+ 25 - 5
lib/python/temporal/datetime_math.py

@@ -14,7 +14,6 @@ for details.
 from datetime import datetime, date, time, timedelta
 import grass.script.core as core
 import copy
-from dateutil import parser
 
 DAY_IN_SECONDS = 86400
 SECOND_AS_DAY = 1.1574074074074073e-05
@@ -551,8 +550,17 @@ def compute_datetime_delta(start, end):
 
 
 def string_to_datetime(time_string):
-    """!Convert a string into a datetime object using the dateutil parser. 
-       Return None in case of failure"""
+    """!Convert a string into a datetime object 
+    
+        Supported ISO string formats are: 
+        - YYYY-mm-dd
+        - YYYY-mm-dd HH:MM:SS
+        
+        Time zones are not supported
+        
+        @param time_string: The time string to convert
+        @return datetime object or None in case of an error
+    """
 
     # BC is not supported
     if time_string.find("bc") > 0:
@@ -560,12 +568,24 @@ def string_to_datetime(time_string):
                    "in the temporal database")
         return None
 
+    # BC is not supported
+    if time_string.find("+") > 0:
+        core.error("Time zones are not supported "
+                   "in the temporal database")
+        return None
+        
+    if time_string.find(":") > 0:
+        time_format = "%Y-%m-%d %H:%M:%S"
+    else:
+        time_format = "%Y-%m-%d"
+  
     try:
-        dt = parser.parse(time_string)
-        return dt
+        return  datetime.strptime(time_string, time_format)
     except:
+        core.error("Unable to parse time string: %s"%time_string)
         return None
 
+
 ###############################################################################
 
 

+ 1 - 1
lib/python/temporal/space_time_datasets.py

@@ -542,7 +542,7 @@ class Raster3DDataset(AbstractMapDataset):
         # Get the data from an existing 3D raster map
         global use_ctypes_map_access
 
-	if use_ctypes_map_access:
+        if use_ctypes_map_access:
             kvp = self.read_info()
         else:
             kvp = raster3d.raster3d_info(self.get_id())