[GRASS-SVN] r57467 - grass/trunk/lib/python/temporal

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 18 09:12:01 PDT 2013


Author: huhabla
Date: 2013-08-18 09:11:27 -0700 (Sun, 18 Aug 2013)
New Revision: 57467

Modified:
   grass/trunk/lib/python/temporal/temporal_extent.py
Log:
Fixed wrong object creation for temporal operators


Modified: grass/trunk/lib/python/temporal/temporal_extent.py
===================================================================
--- grass/trunk/lib/python/temporal/temporal_extent.py	2013-08-17 22:28:01 UTC (rev 57466)
+++ grass/trunk/lib/python/temporal/temporal_extent.py	2013-08-18 16:11:27 UTC (rev 57467)
@@ -194,7 +194,12 @@
         else:
             end = self.D["end_time"]
 
-        return AbstractTemporalExtent(start_time=start, end_time=end)
+        if issubclass(type(self), RelativeTemporalExtent):
+            return RelativeTemporalExtent(start_time=start, end_time=end, unit=self.get_unit())
+        elif issubclass(type(self), AbsoluteTemporalExtent):
+            return AbsoluteTemporalExtent(start_time=start, end_time=end, tz=self.get_timezone())
+        elif issubclass(type(self), AbstractTemporalExtent):
+            return AbstractTemporalExtent(start_time=start, end_time=end)
 
     def disjoint_union(self, extent):
         """!Creates a disjoint union with this temporal extent and the provided one.
@@ -309,6 +314,22 @@
             | Start time:................. 3
             | End time:................... 5
 
+           >>> A = RelativeTemporalExtent(start_time=5, end_time=None, unit="years" )
+           >>> B = RelativeTemporalExtent(start_time=3, end_time=None, unit="years" )
+           >>> inter = A.disjoint_union(B)
+           >>> inter.print_info()
+            +-------------------- Relative time -----------------------------------------+
+            | Start time:................. 3
+            | End time:................... 5
+            | Relative time unit:......... years
+
+           >>> inter = B.disjoint_union(A)
+           >>> inter.print_info()
+            +-------------------- Relative time -----------------------------------------+
+            | Start time:................. 3
+            | End time:................... 5
+            | Relative time unit:......... years
+
            @endcoe
         """
 
@@ -341,7 +362,12 @@
         else:
             end = self.D["end_time"]
 
-        return AbstractTemporalExtent(start_time=start, end_time=end)
+        if issubclass(type(self), RelativeTemporalExtent):
+            return RelativeTemporalExtent(start_time=start, end_time=end, unit=self.get_unit())
+        elif issubclass(type(self), AbsoluteTemporalExtent):
+            return AbsoluteTemporalExtent(start_time=start, end_time=end, tz=self.get_timezone())
+        elif issubclass(type(self), AbstractTemporalExtent):
+            return AbstractTemporalExtent(start_time=start, end_time=end)
 
     def union(self, extent):
         """!Creates a union with this temporal extent and the provided one.



More information about the grass-commit mailing list