[GRASS-SVN] r62864 - in grass/branches/releasebranch_7_0/lib/python/temporal: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 22 15:17:39 PST 2014


Author: huhabla
Date: 2014-11-22 15:17:39 -0800 (Sat, 22 Nov 2014)
New Revision: 62864

Added:
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_operator.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_doctests.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_register_function.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra_grs.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_conditionals.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_algebra_grs.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_conditionals.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py
Removed:
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_operator.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_operator.py
   grass/branches/releasebranch_7_0/lib/python/temporal/unittests_register.py
   grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster3d_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py
Modified:
   grass/branches/releasebranch_7_0/lib/python/temporal/Makefile
   grass/branches/releasebranch_7_0/lib/python/temporal/__init__.py
   grass/branches/releasebranch_7_0/lib/python/temporal/abstract_dataset.py
   grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py
   grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py
   grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py
   grass/branches/releasebranch_7_0/lib/python/temporal/base.py
   grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py
   grass/branches/releasebranch_7_0/lib/python/temporal/core.py
   grass/branches/releasebranch_7_0/lib/python/temporal/datetime_math.py
   grass/branches/releasebranch_7_0/lib/python/temporal/extract.py
   grass/branches/releasebranch_7_0/lib/python/temporal/factory.py
   grass/branches/releasebranch_7_0/lib/python/temporal/gui_support.py
   grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py
   grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py
   grass/branches/releasebranch_7_0/lib/python/temporal/metadata.py
   grass/branches/releasebranch_7_0/lib/python/temporal/open_stds.py
   grass/branches/releasebranch_7_0/lib/python/temporal/register.py
   grass/branches/releasebranch_7_0/lib/python/temporal/sampling.py
   grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py
   grass/branches/releasebranch_7_0/lib/python/temporal/spatial_extent.py
   grass/branches/releasebranch_7_0/lib/python/temporal/spatial_topology_dataset_connector.py
   grass/branches/releasebranch_7_0/lib/python/temporal/spatio_temporal_relationships.py
   grass/branches/releasebranch_7_0/lib/python/temporal/stds_export.py
   grass/branches/releasebranch_7_0/lib/python/temporal/stds_import.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_granularity.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster3d_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_topology_dataset_connector.py
   grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py
   grass/branches/releasebranch_7_0/lib/python/temporal/unit_tests.py
   grass/branches/releasebranch_7_0/lib/python/temporal/univar_statistics.py
Log:
temporal framework: Backport of all modifications of the temporal framework from trunk to enable mapset specific temporal databases. This backport includes the new temporal algebra.


Modified: grass/branches/releasebranch_7_0/lib/python/temporal/Makefile
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/Makefile	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/Makefile	2014-11-22 23:17:39 UTC (rev 62864)
@@ -8,7 +8,7 @@
 GDIR = $(PYDIR)/grass
 DSTDIR = $(GDIR)/temporal
 
-MODULES = base core abstract_dataset abstract_map_dataset abstract_space_time_dataset space_time_datasets open_stds factory gui_support list_stds register sampling metadata spatial_extent temporal_extent datetime_math temporal_granularity spatio_temporal_relationships unit_tests aggregation stds_export stds_import extract mapcalc univar_statistics temporal_topology_dataset_connector spatial_topology_dataset_connector c_libraries_interface temporal_algebra temporal_vector_algebra temporal_vector_operator temporal_raster_operator temporal_raster_base_algebra temporal_raster_algebra temporal_raster3d_algebra
+MODULES = base core abstract_dataset abstract_map_dataset abstract_space_time_dataset space_time_datasets open_stds factory gui_support list_stds register sampling metadata spatial_extent temporal_extent datetime_math temporal_granularity spatio_temporal_relationships unit_tests aggregation stds_export stds_import extract mapcalc univar_statistics temporal_topology_dataset_connector spatial_topology_dataset_connector c_libraries_interface temporal_algebra temporal_vector_algebra temporal_raster_base_algebra temporal_raster_algebra temporal_raster3d_algebra temporal_operator
 
 PYFILES := $(patsubst %,$(DSTDIR)/%.py,$(MODULES) __init__)
 PYCFILES := $(patsubst %,$(DSTDIR)/%.pyc,$(MODULES) __init__)

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/__init__.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/__init__.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/__init__.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,17 +1,12 @@
 from core import *
 from base import *
-from temporal_extent import *
 from spatial_extent import *
 from metadata import *
-from temporal_topology_dataset_connector import *
-from spatial_topology_dataset_connector import *
 from abstract_dataset import *
 from abstract_map_dataset import *
 from abstract_space_time_dataset import *
 from space_time_datasets import *
 from datetime_math import *
-from temporal_granularity import *
-from spatio_temporal_relationships import *
 from open_stds import *
 from factory import *
 from gui_support import *
@@ -25,10 +20,14 @@
 from mapcalc import *
 from univar_statistics import *
 from c_libraries_interface import *
+from spatio_temporal_relationships import *
+from spatial_topology_dataset_connector import *
+from temporal_extent import *
+from temporal_topology_dataset_connector import *
+from temporal_granularity import *
 from temporal_algebra import *
 from temporal_vector_algebra import *
-from temporal_vector_operator import *
-from temporal_raster_operator import *
 from temporal_raster_base_algebra import *
 from temporal_raster_algebra import *
 from temporal_raster3d_algebra import *
+from temporal_operator import *

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/abstract_dataset.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/abstract_dataset.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/abstract_dataset.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,20 +1,15 @@
 # -*- coding: utf-8 -*-
-"""!@package grass.temporal
+"""
+The abstract_dataset module provides the AbstractDataset class
+that is the base class for all map layer and Space Time Datasets.
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in temporal GIS Python library package.
-
-
 (C) 2011-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
-import uuid
-import copy
 from abc import ABCMeta, abstractmethod
 from temporal_extent import *
 from spatial_extent import *
@@ -22,12 +17,12 @@
 from temporal_topology_dataset_connector import *
 from spatial_topology_dataset_connector import *
 
-from grass.exceptions import ImplementationError
-
 ###############################################################################
 
-class AbstractDataset(SpatialTopologyDatasetConnector, TemporalTopologyDatasetConnector):
-    """!This is the base class for all datasets
+
+class AbstractDataset(SpatialTopologyDatasetConnector,
+                      TemporalTopologyDatasetConnector):
+    """This is the base class for all datasets
        (raster, vector, raster3d, strds, stvds, str3ds)"""
 
     __metaclass__ = ABCMeta
@@ -38,68 +33,72 @@
         self.msgr = get_tgis_message_interface()
 
     def reset_topology(self):
-        """!Reset any information about temporal topology"""
+        """Reset any information about temporal topology"""
+
         self.reset_spatial_topology()
         self.reset_temporal_topology()
 
     def get_number_of_relations(self):
-        """! Return a dictionary in which the keys are the relation names and the value
-        are the number of relations.
+        """Return a dictionary in which the keys are the relation names and the
+        value are the number of relations.
 
         The following relations are available:
 
-        Spatial relations
-        - equivalent
-        - overlap
-        - in
-        - contain
-        - meet
-        - cover
-        - covered
+        Spatial relations:
 
-        Temporal relations
-        - equal
-        - follows
-        - precedes
-        - overlaps
-        - overlapped
-        - during (including starts, finishes)
-        - contains (including started, finished)
-        - starts
-        - started
-        - finishes
-        - finished
+            - equivalent
+            - overlap
+            - in
+            - contain
+            - meet
+            - cover
+            - covered
 
-        To access topological information the spatial, temporal or booth topologies must be build first
-        using the SpatioTemporalTopologyBuilder.
+        Temporal relations:
 
-        @return the dictionary with relations as keys and number as values or None in case the topology  wasn't build
+            - equal
+            - follows
+            - precedes
+            - overlaps
+            - overlapped
+            - during (including starts, finishes)
+            - contains (including started, finished)
+            - starts
+            - started
+            - finishes
+            - finished
+
+        To access topological information the spatial, temporal or booth
+        topologies must be build first using the SpatioTemporalTopologyBuilder.
+
+        :return: The dictionary with relations as keys and number as values or
+                 None in case the topology  wasn't build
         """
         if self.is_temporal_topology_build() and not self.is_spatial_topology_build():
             return self.get_number_of_temporal_relations()
         elif self.is_spatial_topology_build() and not self.is_temporal_topology_build():
             self.get_number_of_spatial_relations()
         else:
-            return  self.get_number_of_temporal_relations() + \
-                    self.get_number_of_spatial_relations()
+            return self.get_number_of_temporal_relations() + \
+                   self.get_number_of_spatial_relations()
 
         return None
 
     def set_topology_build_true(self):
-        """!Use this method when the spatio-temporal topology was build"""
+        """Use this method when the spatio-temporal topology was build"""
         self.set_spatial_topology_build_true()
         self.set_temporal_topology_build_true()
 
-
     def set_topology_build_false(self):
-        """!Use this method when the spatio-temporal topology was not build"""
+        """Use this method when the spatio-temporal topology was not build"""
         self.set_spatial_topology_build_false()
         self.set_temporal_topology_build_false()
 
     def is_topology_build(self):
-        """!Check if the spatial and temporal topology was build
+        """Check if the spatial and temporal topology was build
 
-           @return A dictionary with "spatial" and "temporal" as keys that have boolen values
+           :return: A dictionary with "spatial" and "temporal" as keys that
+                    have boolen values
         """
         d = {}
         d["spatial"] = self.is_spatial_topology_build()
@@ -107,7 +106,6 @@
 
         return d
 
-
     def print_topology_info(self):
         if self.is_temporal_topology_build():
             self.print_temporal_topology_info()
@@ -122,7 +120,7 @@
 
     @abstractmethod
     def reset(self, ident):
-        """!Reset the internal structure and set the identifier
+        """Reset the internal structure and set the identifier
 
             This method creates the dataset specific internal objects
             that store the base information, the spatial and temporal extent
@@ -130,95 +128,99 @@
             specific subclasses. This is the code for the
             vector dataset:
 
-            self.base = VectorBase(ident=ident)
-            self.absolute_time = VectorAbsoluteTime(ident=ident)
-            self.relative_time = VectorRelativeTime(ident=ident)
-            self.spatial_extent = VectorSpatialExtent(ident=ident)
-            self.metadata = VectorMetadata(ident=ident)
+            .. code-block:: python
 
-           @param ident The identifier of the dataset that  "name at mapset" or in case of vector maps "name:layer at mapset"
+                self.base = VectorBase(ident=ident)
+                self.absolute_time = VectorAbsoluteTime(ident=ident)
+                self.relative_time = VectorRelativeTime(ident=ident)
+                self.spatial_extent = VectorSpatialExtent(ident=ident)
+                self.metadata = VectorMetadata(ident=ident)
+
+           :param ident: The identifier of the dataset that  "name at mapset" or
+                         in case of vector maps "name:layer at mapset"
         """
 
     @abstractmethod
     def is_stds(self):
-        """!Return True if this class is a space time dataset
+        """Return True if this class is a space time dataset
 
-           @return True if this class is a space time dataset, False otherwise
+           :return: True if this class is a space time dataset, False otherwise
         """
 
     @abstractmethod
     def get_type(self):
-        """!Return the type of this class as string
+        """Return the type of this class as string
 
-           The type can be "vect", "rast", "rast3d", "stvds", "strds" or "str3ds"
+           The type can be "vector", "raster", "raster3d", "stvds", "strds" or "str3ds"
 
-           @return "vect", "rast", "rast3d", "stvds", "strds" or "str3ds"
+           :return: "vector", "raster", "raster3d", "stvds", "strds" or "str3ds"
         """
 
     @abstractmethod
     def get_new_instance(self, ident):
-        """!Return a new instance with the type of this class
+        """Return a new instance with the type of this class
 
-           @param ident The identifier of the new dataset instance
-           @return A new instance with the type of this object
+           :param ident: The identifier of the new dataset instance
+           :return: A new instance with the type of this object
         """
 
     @abstractmethod
     def spatial_overlapping(self, dataset):
-        """!Return True if the spatial extents overlap
+        """Return True if the spatial extents overlap
 
-           @param dataset The abstract dataset to check spatial overlapping
-           @return True if self and the provided dataset spatial overlap
+           :param dataset: The abstract dataset to check spatial overlapping
+           :return: True if self and the provided dataset spatial overlap
         """
 
     @abstractmethod
     def spatial_intersection(self, dataset):
-        """!Return the spatial intersection as spatial_extent
+        """Return the spatial intersection as spatial_extent
            object or None in case no intersection was found.
 
-           @param dataset The abstract dataset to intersect with
-           @return The intersection spatial extent
+           :param dataset: The abstract dataset to intersect with
+           :return: The intersection spatial extent
         """
 
     @abstractmethod
     def spatial_union(self, dataset):
-        """!Return the spatial union as spatial_extent
+        """Return the spatial union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
 
     @abstractmethod
     def spatial_disjoint_union(self, dataset):
-        """!Return the spatial union as spatial_extent object.
+        """Return the spatial union as spatial_extent object.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
 
     @abstractmethod
     def spatial_relation(self, dataset):
-        """!Return the spatial relationship between self and dataset
+        """Return the spatial relationship between self and dataset
 
-           @param dataset The abstract dataset to compute the spatial relation with self
-           @return The spatial relationship as string
+           :param dataset: The abstract dataset to compute the spatial
+                           relation with self
+           :return: The spatial relationship as string
         """
 
     @abstractmethod
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
 
     @abstractmethod
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
 
     @abstractmethod
     def print_self(self):
-        """!Print the content of the internal structure to stdout"""
+        """Print the content of the internal structure to stdout"""
 
     def set_id(self, ident):
-        """!Set the identifier of the dataset"""
+        """Set the identifier of the dataset"""
         self.base.set_id(ident)
         self.temporal_extent.set_id(ident)
         self.spatial_extent.set_id(ident)
@@ -227,37 +229,37 @@
             self.stds_register.set_id(ident)
 
     def get_id(self):
-        """!Return the unique identifier of the dataset
-           @return The id of the dataset "name(:layer)@mapset" as string
+        """Return the unique identifier of the dataset
+           :return: The id of the dataset "name(:layer)@mapset" as string
         """
         return self.base.get_id()
 
     def get_name(self):
-        """!Return the name
-           @return The name of the dataset as string
+        """Return the name
+           :return: The name of the dataset as string
         """
         return self.base.get_name()
 
     def get_mapset(self):
-        """!Return the mapset
-           @return The mapset in which the dataset was created as string
+        """Return the mapset
+           :return: The mapset in which the dataset was created as string
         """
         return self.base.get_mapset()
 
     def get_temporal_extent_as_tuple(self):
-        """!Returns a tuple of the valid start and end time
+        """Returns a tuple of the valid start and end time
 
-           Start and end time can be either of type datetime or of type integer,
-           depending on the temporal type.
+           Start and end time can be either of type datetime or of type
+           integer, depending on the temporal type.
 
-           @return A tuple of (start_time, end_time)
+           :return: A tuple of (start_time, end_time)
         """
         start = self.temporal_extent.get_start_time()
         end = self.temporal_extent.get_end_time()
         return (start, end)
 
     def get_absolute_time(self):
-        """!Returns the start time, the end
+        """Returns the start time, the end
            time of the map as tuple
 
            The start time is of type datetime.
@@ -265,7 +267,7 @@
            The end time is of type datetime in case of interval time,
            or None on case of a time instance.
 
-           @return A tuple of (start_time, end_time)
+           :return: A tuple of (start_time, end_time)
         """
 
         start = self.absolute_time.get_start_time()
@@ -274,7 +276,7 @@
         return (start, end)
 
     def get_relative_time(self):
-        """!Returns the start time, the end
+        """Returns the start time, the end
            time and the temporal unit of the dataset as tuple
 
            The start time is of type integer.
@@ -282,7 +284,7 @@
            The end time is of type integer in case of interval time,
            or None on case of a time instance.
 
-           @return A tuple of (start_time, end_time, unit)
+           :return: A tuple of (start_time, end_time, unit)
         """
 
         start = self.relative_time.get_start_time()
@@ -292,17 +294,17 @@
         return (start, end, unit)
 
     def get_relative_time_unit(self):
-        """!Returns the relative time unit
-           @return The relative time unit as string, None if not present
+        """Returns the relative time unit
+           :return: The relative time unit as string, None if not present
         """
         return self.relative_time.get_unit()
 
     def check_relative_time_unit(self, unit):
-        """!Check if unit is of type  year(s), month(s), day(s), hour(s),
+        """Check if unit is of type  year(s), month(s), day(s), hour(s),
            minute(s) or second(s)
 
-           @param unit The unit string
-           @return True if success, False otherwise
+           :param unit: The unit string
+           :return: True if success, False otherwise
         """
         # Check unit
         units = ["year", "years", "month", "months", "day", "days", "hour",
@@ -312,37 +314,39 @@
         return True
 
     def get_temporal_type(self):
-        """!Return the temporal type of this dataset
+        """Return the temporal type of this dataset
 
            The temporal type can be absolute or relative
 
-           @return The temporal type of the dataset as string
+           :return: The temporal type of the dataset as string
         """
         return self.base.get_ttype()
 
     def get_spatial_extent_as_tuple(self):
-        """!Return the spatial extent as tuple
+        """Return the spatial extent as tuple
 
-           Top and bottom are set to 0 in case of a two dimensional spatial extent.
+           Top and bottom are set to 0 in case of a two dimensional spatial
+           extent.
 
-           @return A the spatial extent as tuple (north, south, east, west, top, bottom)
+           :return: A the spatial extent as tuple (north, south, east, west,
+                    top, bottom)
         """
         return self.spatial_extent.get_spatial_extent_as_tuple()
 
     def get_spatial_extent(self):
-        """!Return the spatial extent
+        """Return the spatial extent
         """
         return self.spatial_extent
 
     def select(self, dbif=None):
-        """!Select temporal dataset entry from database and fill
+        """Select temporal dataset entry from database and fill
            the internal structure
 
            The content of every dataset is stored in the temporal database.
            This method must be used to fill this object with the content
            from the temporal database.
 
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
         """
 
         dbif, connected = init_dbif(dbif)
@@ -358,31 +362,34 @@
             dbif.close()
 
     def is_in_db(self, dbif=None):
-        """!Check if the dataset is registered in the database
+        """Check if the dataset is registered in the database
 
-           @param dbif The database interface to be used
-           @return True if the dataset is registered in the database
+           :param dbif: The database interface to be used
+           :return: True if the dataset is registered in the database
         """
         return self.base.is_in_db(dbif)
 
     @abstractmethod
     def delete(self):
-        """!Delete dataset from database if it exists"""
+        """Delete dataset from database if it exists"""
 
     def insert(self, dbif=None, execute=True):
-        """!Insert dataset into database
+        """Insert dataset into database
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL statements will be executed.
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL statements will be executed.
                            If False the prepared SQL statements are returned
                            and must be executed by the caller.
-            @return The SQL insert statement in case execute=False, or an empty string otherwise
+           :return: The SQL insert statement in case execute=False, or an
+                    empty string otherwise
         """
 
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to insert dataset <%(ds)s> of type %(type)s in the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+            self.msgr.fatal(_("Unable to insert dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset "
+                              "of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
         dbif, connected = init_dbif(dbif)
 
@@ -405,23 +412,25 @@
         return statement
 
     def update(self, dbif=None, execute=True, ident=None):
-        """!Update the dataset entry in the database from the internal structure
+        """Update the dataset entry in the database from the internal structure
            excluding None variables
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL statements will be executed.
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL statements will be executed.
                            If False the prepared SQL statements are returned
                            and must be executed by the caller.
-           @param ident The identifier to be updated, useful for renaming
-           @return The SQL update statement in case execute=False, or an empty string otherwise
+           :param ident: The identifier to be updated, useful for renaming
+           :return: The SQL update statement in case execute=False, or an
+                    empty string otherwise
         """
 
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type %(type)s in the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                                 {"ds":self.get_id(), "type":self.get_type()})
+            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset "
+                              "of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
-
         dbif, connected = init_dbif(dbif)
 
         # Build the UPDATE SQL statement
@@ -446,21 +455,24 @@
         return statement
 
     def update_all(self, dbif=None, execute=True, ident=None):
-        """!Update the dataset entry in the database from the internal structure
+        """Update the dataset entry in the database from the internal structure
            and include None variables.
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL statements will be executed.
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL statements will be executed.
                            If False the prepared SQL statements are returned
                            and must be executed by the caller.
-           @param ident The identifier to be updated, useful for renaming
-           @return The SQL update statement in case execute=False, or an empty string otherwise
+           :param ident: The identifier to be updated, useful for renaming
+           :return: The SQL update statement in case execute=False, or an
+                    empty string otherwise
         """
 
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type %(type)s in the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset"
+                              " of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
         dbif, connected = init_dbif(dbif)
 
@@ -468,9 +480,10 @@
         statement = self.base.get_update_all_statement_mogrified(dbif, ident)
         statement += self.temporal_extent.get_update_all_statement_mogrified(dbif,
                                                                              ident)
-        statement += self.spatial_extent.get_update_all_statement_mogrified(
-            dbif, ident)
-        statement += self.metadata.get_update_all_statement_mogrified(dbif, ident)
+        statement += self.spatial_extent.get_update_all_statement_mogrified(dbif,
+                                                                            ident)
+        statement += self.metadata.get_update_all_statement_mogrified(dbif,
+                                                                      ident)
 
         if self.is_stds() is False:
             statement += self.stds_register.get_update_all_statement_mogrified(dbif, ident)
@@ -486,9 +499,9 @@
         return statement
 
     def is_time_absolute(self):
-        """!Return True in case the temporal type is absolute
+        """Return True in case the temporal type is absolute
 
-            @return True if temporal type is absolute, False otherwise
+           :return: True if temporal type is absolute, False otherwise
         """
         if "temporal_type" in self.base.D:
             return self.base.get_ttype() == "absolute"
@@ -496,9 +509,9 @@
             return None
 
     def is_time_relative(self):
-        """!Return True in case the temporal type is relative
+        """Return True in case the temporal type is relative
 
-            @return True if temporal type is relative, False otherwise
+           :return: True if temporal type is relative, False otherwise
         """
         if "temporal_type" in self.base.D:
             return self.base.get_ttype() == "relative"
@@ -506,7 +519,7 @@
             return None
 
     def get_temporal_extent(self):
-        """!Return the temporal extent of the correct internal type
+        """Return the temporal extent of the correct internal type
         """
         if self.is_time_absolute():
             return self.absolute_time
@@ -517,55 +530,57 @@
     temporal_extent = property(fget=get_temporal_extent)
 
     def temporal_relation(self, dataset):
-        """!Return the temporal relation of self and the provided dataset
+        """Return the temporal relation of self and the provided dataset
 
-            @return The temporal relation as string
+           :return: The temporal relation as string
         """
         return self.temporal_extent.temporal_relation(dataset.temporal_extent)
 
     def temporal_intersection(self, dataset):
-        """!Intersect self with the provided dataset and
+        """Intersect self with the provided dataset and
            return a new temporal extent with the new start and end time
 
-           @param dataset The abstract dataset to temporal intersect with
-           @return The new temporal extent with start and end time,
-                   or None in case of no intersection
+           :param dataset: The abstract dataset to temporal intersect with
+           :return: The new temporal extent with start and end time,
+                    or None in case of no intersection
         """
         return self.temporal_extent.intersect(dataset.temporal_extent)
 
     def temporal_union(self, dataset):
-        """!Creates a union with the provided dataset and
+        """Creates a union with the provided dataset and
            return a new temporal extent with the new start and end time.
 
-           @param dataset The abstract dataset to create temporal union with
-           @return The new temporal extent with start and end time,
-                   or None in case of no intersection
+           :param dataset: The abstract dataset to create temporal union with
+           :return: The new temporal extent with start and end time,
+                    or None in case of no intersection
         """
         return self.temporal_extent.union(dataset.temporal_extent)
 
     def temporal_disjoint_union(self, dataset):
-        """!Creates a union with the provided dataset and
+        """Creates a union with the provided dataset and
            return a new temporal extent with the new start and end time.
 
-           @param dataset The abstract dataset to create temporal union with
-           @return The new temporal extent with start and end time
+           :param dataset: The abstract dataset to create temporal union with
+           :return: The new temporal extent with start and end time
         """
         return self.temporal_extent.disjoint_union(dataset.temporal_extent)
 
 ###############################################################################
 
+
 class AbstractDatasetComparisonKeyStartTime(object):
-    """!This comparison key can be used to sort lists of abstract datasets
+    """This comparison key can be used to sort lists of abstract datasets
        by start time
 
         Example:
 
-        # Return all maps in a space time raster dataset as map objects
-        map_list = strds.get_registered_maps_as_objects()
+        .. code-block:: python
 
-        # Sort the maps in the list by start time
-        sorted_map_list = sorted(
-            map_list, key=AbstractDatasetComparisonKeyStartTime)
+            # Return all maps in a space time raster dataset as map objects
+            map_list = strds.get_registered_maps_as_objects()
+
+            # Sort the maps in the list by start time
+            sorted_map_list = sorted(map_list, key=AbstractDatasetComparisonKeyStartTime)
     """
     def __init__(self, obj, *args):
         self.obj = obj
@@ -602,18 +617,20 @@
 
 ###############################################################################
 
+
 class AbstractDatasetComparisonKeyEndTime(object):
-    """!This comparison key can be used to sort lists of abstract datasets
+    """This comparison key can be used to sort lists of abstract datasets
        by end time
 
         Example:
 
-        # Return all maps in a space time raster dataset as map objects
-        map_list = strds.get_registered_maps_as_objects()
+        .. code-block:: python
 
-        # Sort the maps in the list by end time
-        sorted_map_list = sorted(
-            map_list, key=AbstractDatasetComparisonKeyEndTime)
+            # Return all maps in a space time raster dataset as map objects
+            map_list = strds.get_registered_maps_as_objects()
+
+            # Sort the maps in the list by end time
+            sorted_map_list = sorted(map_list, key=AbstractDatasetComparisonKeyEndTime)
     """
     def __init__(self, obj, *args):
         self.obj = obj

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/abstract_map_dataset.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,22 +1,21 @@
 # -*- coding: utf-8 -*-
-"""!@package grass.temporal
+"""
+The abstract_map_dataset module provides the AbstractMapDataset class
+that is the base class for all map layer.
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in temporal GIS Python library package.
-
 (C) 2011-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 from abstract_dataset import *
 from datetime_math import *
 
+
 class AbstractMapDataset(AbstractDataset):
-    """!This is the base class for all maps (raster, vector, raster3d).
+    """This is the base class for all maps (raster, vector, raster3d).
 
         The temporal extent, the spatial extent and the metadata of maps
         are stored in the temporal database. Maps can be registered in the
@@ -24,16 +23,18 @@
 
         This class provides all functionalities that are needed to manage maps
         in the temporal database. That are:
+
         - insert() to register the map and therefore its spatio-temporal extent
-                   and metadata in the temporal database
+          and metadata in the temporal database
         - update() to update the map spatio-temporal extent and metadata in the
-                   temporal database
+          temporal database
         - unregister() to unregister the map from each space time dataset in
-                       which this map is registered
+          which this map is registered
         - delete() to remove the map from the temporal database
         - Methods to set relative and absolute time stamps
         - Abstract methods that must be implemented in the map specific
           subclasses
+
     """
 
     __metaclass__ = ABCMeta
@@ -44,15 +45,15 @@
 
     @abstractmethod
     def get_new_stds_instance(self, ident):
-        """!Return a new space time dataset instance that store maps with the
+        """Return a new space time dataset instance that store maps with the
            type of this map object (rast, rast3d or vect)
 
-           @param ident The identifier of the space time dataset
-           @return The new space time dataset instance
+           :param ident The identifier of the space time dataset
+           :return: The new space time dataset instance
         """
 
     def check_resolution_with_current_region(self):
-        """!Check if the raster or voxel resolution is
+        """Check if the raster or voxel resolution is
            finer than the current resolution
 
            - Return "finer" in case the raster/voxel resolution is finer
@@ -63,28 +64,28 @@
            Vector maps have no resolution, since they store the coordinates
            directly.
 
-           @return "finer" or "coarser"
+           :return: "finer" or "coarser"
         """
         raise ImplementationError(
             "This method must be implemented in the subclasses")
 
-
     @abstractmethod
     def has_grass_timestamp(self):
-        """!Check if a grass file based time stamp exists for this map.
-            @return True is the grass file based time stamped exists for this
-                    map
+        """Check if a grass file based time stamp exists for this map.
+
+        :return: True is the grass file based time stamped exists for this map
+
         """
 
     @abstractmethod
     def write_timestamp_to_grass(self):
-        """!Write the timestamp of this map into the map metadata
+        """Write the timestamp of this map into the map metadata
            in the grass file system based spatial database.
         """
 
     @abstractmethod
     def read_timestamp_from_grass(self):
-        """!Read the timestamp of this map from the map metadata
+        """Read the timestamp of this map from the map metadata
            in the grass file system based spatial database and
            set the internal time stamp that should be insert/updated
            in the temporal database.
@@ -92,29 +93,29 @@
 
     @abstractmethod
     def remove_timestamp_from_grass(self):
-        """!Remove the timestamp from the grass file
+        """Remove the timestamp from the grass file
            system based spatial database
         """
 
     @abstractmethod
     def map_exists(self):
-        """!Return True in case the map exists in the grass spatial database
+        """Return True in case the map exists in the grass spatial database
 
-           @return True if map exists, False otherwise
+           :return: True if map exists, False otherwise
         """
 
     @abstractmethod
     def load(self):
-        """!Load the content of this object from the grass
+        """Load the content of this object from the grass
            file system based database"""
 
     def _convert_timestamp(self):
-        """!Convert the valid time into a grass datetime library
+        """Convert the valid time into a grass datetime library
            compatible timestamp string
 
-            This methods works for relative and absolute time
+           This methods works for relative and absolute time
 
-            @return the grass timestamp string
+           :return: the grass timestamp string
         """
         start = ""
 
@@ -134,7 +135,7 @@
         return start
 
     def get_map_id(self):
-        """!Return the map id. The map id is the unique identifier
+        """Return the map id. The map id is the unique identifier
            in grass and must not be equal to the
            primary key identifier (id) of the map in the database.
            Since vector maps may have layer information,
@@ -144,24 +145,24 @@
            in the file system but not to identify
            map information in the temporal database.
 
-           @return The map id "name at mapset"
+           :return: The map id "name at mapset"
         """
         return self.base.get_map_id()
 
     @staticmethod
     def build_id(name, mapset, layer=None):
-        """!Convenient method to build the unique identifier
+        """Convenient method to build the unique identifier
 
-            Existing layer and mapset definitions in the name
-            string will be reused
+           Existing layer and mapset definitions in the name
+           string will be reused
 
-           @param name The name of the map
-           @param mapset The mapset in which the map is located
-           @param layer The layer of the vector map, use None in case no
-                        layer exists
+           :param name: The name of the map
+           :param mapset: The mapset in which the map is located
+           :param layer: The layer of the vector map, use None in case no
+                         layer exists
 
-           @return the id of the map as "name(:layer)@mapset"
-                   while layer is optional
+           :return: the id of the map as "name(:layer)@mapset" while layer is
+                    optional
         """
 
         # Check if the name includes any mapset
@@ -178,14 +179,14 @@
             return "%s@%s" % (name, mapset)
 
     def get_layer(self):
-        """!Return the layer of the map
-            @return the layer of the map or None in case no layer is defined
+        """Return the layer of the map
+
+            :return: the layer of the map or None in case no layer is defined
         """
         return self.base.get_layer()
 
-
     def print_self(self):
-        """!Print the content of the internal structure to stdout"""
+        """Print the content of the internal structure to stdout"""
         self.base.print_self()
         self.temporal_extent.print_self()
         self.spatial_extent.print_self()
@@ -193,7 +194,7 @@
         self.stds_register.print_self()
 
     def print_info(self):
-        """!Print information about this object in human readable style"""
+        """Print information about this object in human readable style"""
 
         if self.get_type() == "raster":
             #                1         2         3         4         5         6         7
@@ -231,7 +232,7 @@
         print " +----------------------------------------------------------------------------+"
 
     def print_shell_info(self):
-        """!Print information about this object in shell style"""
+        """Print information about this object in shell style"""
         self.base.print_shell_info()
         self.temporal_extent.print_shell_info()
         self.spatial_extent.print_shell_info()
@@ -252,7 +253,7 @@
             self.print_topology_shell_info()
 
     def insert(self, dbif=None, execute=True):
-        """!Insert the map content into the database from the internal
+        """Insert the map content into the database from the internal
            structure
 
            This functions assures that the timestamp is written to the
@@ -261,65 +262,66 @@
            Hence maps can only be registered in a space time dataset, when
            they were inserted in the temporal database beforehand.
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL statements will be executed.
-                          If False the prepared SQL statements are
-                          returned and must be executed by the caller.
-           @return The SQL insert statement in case execute=False, or an
-                   empty string otherwise
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL statements will be executed.
+                           If False the prepared SQL statements are
+                           returned and must be executed by the caller.
+           :return: The SQL insert statement in case execute=False, or an
+                    empty string otherwise
         """
         if get_enable_timestamp_write():
             self.write_timestamp_to_grass()
         return AbstractDataset.insert(self, dbif=dbif, execute=execute)
 
     def update(self, dbif=None, execute=True):
-        """!Update the map content in the database from the internal structure
+        """Update the map content in the database from the internal structure
            excluding None variables
 
            This functions assures that the timestamp is written to the
            grass file system based database in addition to the temporal
            database entry.
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL statements will be executed.
-                          If False the prepared SQL statements are
-                          returned and must be executed by the caller.
-           @return The SQL insert statement in case execute=False, or an
-                   empty string otherwise
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL statements will be executed.
+                           If False the prepared SQL statements are
+                           returned and must be executed by the caller.
+           :return: The SQL insert statement in case execute=False, or an
+                    empty string otherwise
         """
         if get_enable_timestamp_write():
             self.write_timestamp_to_grass()
         return AbstractDataset.update(self, dbif, execute)
 
     def update_all(self, dbif=None, execute=True):
-        """!Update the map content in the database from the internal structure
+        """Update the map content in the database from the internal structure
            including None variables
 
            This functions assures that the timestamp is written to the
            grass file system based database in addition to the temporal
            database entry.
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL statements will be executed.
-                          If False the prepared SQL statements are
-                          returned and must be executed by the caller.
-            @return The SQL insert statement in case execute=False, or an
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL statements will be executed.
+                           If False the prepared SQL statements are
+                           returned and must be executed by the caller.
+           :return: The SQL insert statement in case execute=False, or an
                     empty string otherwise
+
         """
         if get_enable_timestamp_write():
             self.write_timestamp_to_grass()
         return AbstractDataset.update_all(self, dbif, execute)
 
     def set_time_to_absolute(self):
-        """!Set the temporal type to absolute"""
+        """Set the temporal type to absolute"""
         self.base.set_ttype("absolute")
 
     def set_time_to_relative(self):
-        """!Set the temporal type to relative"""
+        """Set the temporal type to relative"""
         self.base.set_ttype("relative")
 
     def set_absolute_time(self, start_time, end_time=None):
-        """!Set the absolute time with start time and end time
+        """Set the absolute time with start time and end time
 
             The end time is optional and must be set to None in case of time
             instance.
@@ -327,53 +329,58 @@
             This method only modifies this object and does not commit
             the modifications to the temporal database.
 
-           @param start_time a datetime object specifying the start time of the
-                             map
-           @param end_time a datetime object specifying the end time of the
-                           map, None in case or time instance
+           :param start_time: A datetime object specifying the start time of
+                              the map
+           :param end_time: A datetime object specifying the end time of the
+                            map, None in case or time instance
 
-           @return True for success and False otherwise
+           :return: True for success and False otherwise
         """
         if start_time and not isinstance(start_time, datetime):
             if self.get_layer() is not None:
-                self.msgr.error(_("Start time must be of type datetime for %(type)s"
-                             " map <%(id)s> with layer: %(l)s") % {
-                             'type': self.get_type(), 'id': self.get_map_id(),
-                             'l': self.get_layer()})
+                self.msgr.error(_("Start time must be of type datetime for "
+                                  "%(type)s map <%(id)s> with layer: %(l)s") %
+                                {'type': self.get_type(),
+                                 'id': self.get_map_id(),
+                                 'l': self.get_layer()})
                 return False
             else:
-                core.error(_("Start time must be of type datetime for "
-                             "%(type)s map <%(id)s>") % {
-                             'type': self.get_type(), 'id': self.get_map_id()})
+                self.msgr.error(_("Start time must be of type datetime for "
+                                  "%(type)s map <%(id)s>") %
+                                {'type': self.get_type(),
+                                 'id': self.get_map_id()})
                 return False
 
         if end_time and not isinstance(end_time, datetime):
             if self.get_layer():
-                self.msgr.error(_("End time must be of type datetime for %(type)s "
-                             "map <%(id)s> with layer: %(l)s") % {
-                             'type': self.get_type(), 'id': self.get_map_id(),
-                             'l': self.get_layer()})
+                self.msgr.error(_("End time must be of type datetime for "
+                                  "%(type)s map <%(id)s> with layer: %(l)s") %
+                                {'type': self.get_type(),
+                                 'id': self.get_map_id(),
+                                 'l': self.get_layer()})
                 return False
             else:
                 self.msgr.error(_("End time must be of type datetime for "
-                             "%(type)s map <%(id)s>") % {
-                             'type': self.get_type(), 'id': self.get_map_id()})
+                                  "%(type)s map <%(id)s>") %
+                                {'type': self.get_type(),
+                                 'id': self.get_map_id()})
                 return False
 
         if start_time is not None and end_time is not None:
             if start_time > end_time:
                 if self.get_layer():
-                    self.msgr.error(_("End time must be greater than start time for"
-                                 " %(type)s map <%(id)s> with layer: %(l)s") % {
-                                 'type': self.get_type(),
-                                 'id': self.get_map_id(),
-                                 'l': self.get_layer()})
+                    self.msgr.error(_("End time must be greater than start "
+                                      "time for %(type)s map <%(id)s> with "
+                                      "layer: %(l)s") %
+                                    {'type': self.get_type(),
+                                     'id': self.get_map_id(),
+                                     'l': self.get_layer()})
                     return False
                 else:
-                    self.msgr.error(_("End time must be greater than start time "
-                                 "for %(type)s map <%(id)s>") % {
-                                 'type': self.get_type(),
-                                 'id': self.get_map_id()})
+                    self.msgr.error(_("End time must be greater than start "
+                                      "time for %(type)s map <%(id)s>") %
+                                    {'type': self.get_type(),
+                                     'id': self.get_map_id()})
                     return False
             else:
                 # Do not create an interval in case start and end time are
@@ -388,7 +395,7 @@
         return True
 
     def update_absolute_time(self, start_time, end_time=None, dbif=None):
-        """!Update the absolute time
+        """Update the absolute time
 
            The end time is optional and must be set to None in case of time
            instance.
@@ -397,19 +404,20 @@
            grass file system based database in addition to the temporal
            database entry.
 
-           @param start_time a datetime object specifying the start time of
-                  the map
-           @param end_time a datetime object specifying the end time of the
-                  map, None in case or time instance
-           @param dbif The database interface to be used
+           :param start_time: A datetime object specifying the start time of
+                                         the map
+           :param end_time: A datetime object specifying the end time of the
+                                        map, None in case or time instance
+           :param dbif: The database interface to be used
            """
 
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type %(type)s in the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset "
+                              "of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
-
         if self.set_absolute_time(start_time, end_time):
             dbif, connected = init_dbif(dbif)
             self.absolute_time.update_all(dbif)
@@ -422,7 +430,7 @@
                 self.write_timestamp_to_grass()
 
     def set_relative_time(self, start_time, end_time, unit):
-        """!Set the relative time interval
+        """Set the relative time interval
 
             The end time is optional and must be set to None in case of time
             instance.
@@ -430,38 +438,42 @@
             This method only modifies this object and does not commit
             the modifications to the temporal database.
 
-           @param start_time An integer value
-           @param end_time An integer value, None in case or time instance
-           @param unit The unit of the relative time. Supported units:
-                       year(s), month(s), day(s), hour(s), minute(s), second(s)
+           :param start_time: An integer value
+           :param end_time: An integer value, None in case or time instance
+           :param unit: The unit of the relative time. Supported units:
+                        year(s), month(s), day(s), hour(s), minute(s), second(s)
 
-           @return True for success and False otherwise
+           :return: True for success and False otherwise
 
         """
         if not self.check_relative_time_unit(unit):
             if self.get_layer() is not None:
-                self.msgr.error(_("Unsupported relative time unit type for %(type)s"
-                             " map <%(id)s> with layer %(l)s: %(u)s") % {
-                             'type': self.get_type(), 'id': self.get_id(),
-                             'l': self.get_layer(), 'u': unit})
+                self.msgr.error(_("Unsupported relative time unit type for "
+                                  "%(type)s map <%(id)s> with layer %(l)s: "
+                                  "%(u)s") % {'type': self.get_type(),
+                                              'id': self.get_id(),
+                                              'l': self.get_layer(),
+                                              'u': unit})
             else:
-                self.msgr.error(_("Unsupported relative time unit type for %(type)s"
-                             " map <%(id)s>: %(u)s") % {
-                             'type': self.get_type(), 'id': self.get_id(),
-                             'u': unit})
+                self.msgr.error(_("Unsupported relative time unit type for "
+                                  "%(type)s map <%(id)s>: %(u)s") %
+                                {'type': self.get_type(), 'id': self.get_id(),
+                                 'u': unit})
             return False
 
         if start_time is not None and end_time is not None:
             if int(start_time) > int(end_time):
                 if self.get_layer() is not None:
-                    self.msgr.error(_("End time must be greater than start time for"
-                                 " %(type)s map <%(id)s> with layer %(l)s") % \
-                                 {'type': self.get_type(), 'id': self.get_id(),
-                                  'l': self.get_layer()})
+                    self.msgr.error(_("End time must be greater than start "
+                                      "time for %(typ)s map <%(id)s> with "
+                                      "layer %(l)s") % {'typ': self.get_type(),
+                                                        'id': self.get_id(),
+                                                        'l': self.get_layer()})
                 else:
-                    self.msgr.error(_("End time must be greater than start time for"
-                                 " %(type)s map <%(id)s>") % {
-                                 'type': self.get_type(), 'id': self.get_id()})
+                    self.msgr.error(_("End time must be greater than start "
+                                      "time for %(type)s map <%(id)s>") %
+                                    {'type': self.get_type(),
+                                     'id': self.get_id()})
                 return False
             else:
                 # Do not create an interval in case start and end time are
@@ -481,7 +493,7 @@
         return True
 
     def update_relative_time(self, start_time, end_time, unit, dbif=None):
-        """!Update the relative time interval
+        """Update the relative time interval
 
            The end time is optional and must be set to None in case of time
            instance.
@@ -490,15 +502,17 @@
            grass file system based database in addition to the temporal
            database entry.
 
-           @param start_time An integer value
-           @param end_time An integer value, None in case or time instance
-           @param unit The relative time unit
-           @param dbif The database interface to be used
+           :param start_time: An integer value
+           :param end_time: An integer value, None in case or time instance
+           :param unit: The relative time unit
+           :param dbif: The database interface to be used
         """
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type %(type)s in the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset "
+                              "of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
         if self.set_relative_time(start_time, end_time, unit):
             dbif, connected = init_dbif(dbif)
@@ -512,38 +526,40 @@
                 self.write_timestamp_to_grass()
 
     def set_temporal_extent(self, extent):
-        """!Convenient method to set the temporal extent from a temporal extent object
+        """Convenient method to set the temporal extent from a temporal extent
+           object
 
-           @param temporal_extent The temporal extent that should be set for this object
+           :param temporal_extent: The temporal extent that should be set for
+                                   this object
 
-           @code
-           >>> import datetime
-           >>> import grass.temporal as tgis
-           >>> map      = tgis.RasterDataset(None)
-           >>> temp_ext = tgis.RasterRelativeTime(start_time=1, end_time=2, unit="years")
-           >>> map.set_temporal_extent(temp_ext)
-           >>> print map.get_temporal_extent_as_tuple()
-           (1, 2)
-           >>> map      = tgis.VectorDataset(None)
-           >>> temp_ext = tgis.VectorAbsoluteTime(start_time=datetime.datetime(2000, 1, 1),
-           ...                                        end_time=datetime.datetime(2001, 1, 1))
-           >>> map.set_temporal_extent(temp_ext)
-           >>> print map.get_temporal_extent_as_tuple()
-           (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
+           .. code-block: : python
 
-           >>> map1 = tgis.VectorDataset("A at P")
-           >>> check = map1.set_absolute_time(datetime.datetime(2000,5,5), datetime.datetime(2005,6,6))
-           >>> print map1.get_temporal_extent_as_tuple()
-           (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
-           >>> map2 = tgis.RasterDataset("B at P")
-           >>> check = map2.set_absolute_time(datetime.datetime(1990,1,1), datetime.datetime(1999,8,1))
-           >>> print map2.get_temporal_extent_as_tuple()
-           (datetime.datetime(1990, 1, 1, 0, 0), datetime.datetime(1999, 8, 1, 0, 0))
-           >>> map2.set_temporal_extent(map1.get_temporal_extent())
-           >>> print map2.get_temporal_extent_as_tuple()
-           (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
+               >>> import datetime
+               >>> import grass.temporal as tgis
+               >>> map      = tgis.RasterDataset(None)
+               >>> temp_ext = tgis.RasterRelativeTime(start_time=1, end_time=2, unit="years")
+               >>> map.set_temporal_extent(temp_ext)
+               >>> print map.get_temporal_extent_as_tuple()
+               (1, 2)
+               >>> map      = tgis.VectorDataset(None)
+               >>> temp_ext = tgis.VectorAbsoluteTime(start_time=datetime.datetime(2000, 1, 1),
+               ...                                        end_time=datetime.datetime(2001, 1, 1))
+               >>> map.set_temporal_extent(temp_ext)
+               >>> print map.get_temporal_extent_as_tuple()
+               (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
 
-           @endcode
+               >>> map1 = tgis.VectorDataset("A at P")
+               >>> check = map1.set_absolute_time(datetime.datetime(2000,5,5), datetime.datetime(2005,6,6))
+               >>> print map1.get_temporal_extent_as_tuple()
+               (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
+               >>> map2 = tgis.RasterDataset("B at P")
+               >>> check = map2.set_absolute_time(datetime.datetime(1990,1,1), datetime.datetime(1999,8,1))
+               >>> print map2.get_temporal_extent_as_tuple()
+               (datetime.datetime(1990, 1, 1, 0, 0), datetime.datetime(1999, 8, 1, 0, 0))
+               >>> map2.set_temporal_extent(map1.get_temporal_extent())
+               >>> print map2.get_temporal_extent_as_tuple()
+               (datetime.datetime(2000, 5, 5, 0, 0), datetime.datetime(2005, 6, 6, 0, 0))
+
         """
         if issubclass(type(extent), RelativeTemporalExtent):
             start = extent.get_start_time()
@@ -559,87 +575,87 @@
             self.set_absolute_time(start, end)
 
     def temporal_buffer(self, increment, update=False, dbif=None):
-        """!Create a temporal buffer based on an increment
+        """Create a temporal buffer based on an increment
 
            For absolute time the increment must be a string of type "integer
            unit"
            Unit can be year, years, month, months, day, days, hour, hours,
            minute, minutes, day or days.
 
-           @param increment This is the increment, a string in case of absolute
-                            time or an integer in case of relative time
-           @param update Perform an immediate database update to store the
-                         modified temporal extent, otherwise only this object
-                         will be modified
+           :param increment: This is the increment, a string in case of
+                             absolute time or an integer in case of relative
+                             time
+           :param update: Perform an immediate database update to store the
+                          modified temporal extent, otherwise only this object
+                          will be modified
 
            Usage:
 
-           @code
+           .. code-block: : python
 
-           >>> import grass.temporal as tgis
-           >>> maps = []
-           >>> for i in range(5):
-           ...   map = tgis.RasterDataset(None)
-           ...   if i%2 == 0:
-           ...       check = map.set_relative_time(i, i + 1, 'years')
-           ...   else:
-           ...       check = map.set_relative_time(i, None, 'years')
-           ...   map.temporal_buffer(3)
-           ...   maps.append(map)
-           >>> for map in maps:
-           ...   map.temporal_extent.print_info()
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. -3
-            | End time:................... 4
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. -2
-            | End time:................... 4
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. -1
-            | End time:................... 6
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 0
-            | End time:................... 6
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 1
-            | End time:................... 8
-            | Relative time unit:......... years
-           >>> maps = []
-           >>> for i in range(1,5):
-           ...   map = tgis.RasterDataset(None)
-           ...   if i%2 == 0:
-           ...       check = map.set_absolute_time(datetime(2001,i,1), datetime(2001, i + 1, 1))
-           ...   else:
-           ...       check = map.set_absolute_time(datetime(2001,i,1),  None)
-           ...   map.temporal_buffer("7 days")
-           ...   maps.append(map)
-           >>> for map in maps:
-           ...   map.temporal_extent.print_info()
-            +-------------------- Absolute time -----------------------------------------+
-            | Start time:................. 2000-12-25 00:00:00
-            | End time:................... 2001-01-08 00:00:00
-            +-------------------- Absolute time -----------------------------------------+
-            | Start time:................. 2001-01-25 00:00:00
-            | End time:................... 2001-03-08 00:00:00
-            +-------------------- Absolute time -----------------------------------------+
-            | Start time:................. 2001-02-22 00:00:00
-            | End time:................... 2001-03-08 00:00:00
-            +-------------------- Absolute time -----------------------------------------+
-            | Start time:................. 2001-03-25 00:00:00
-            | End time:................... 2001-05-08 00:00:00
+               >>> import grass.temporal as tgis
+               >>> maps = []
+               >>> for i in range(5):
+               ...   map = tgis.RasterDataset(None)
+               ...   if i%2 == 0:
+               ...       check = map.set_relative_time(i, i + 1, 'years')
+               ...   else:
+               ...       check = map.set_relative_time(i, None, 'years')
+               ...   map.temporal_buffer(3)
+               ...   maps.append(map)
+               >>> for map in maps:
+               ...   map.temporal_extent.print_info()
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. -3
+                | End time:................... 4
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. -2
+                | End time:................... 4
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. -1
+                | End time:................... 6
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 0
+                | End time:................... 6
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 1
+                | End time:................... 8
+                | Relative time unit:......... years
+               >>> maps = []
+               >>> for i in range(1,5):
+               ...   map = tgis.RasterDataset(None)
+               ...   if i%2 == 0:
+               ...       check = map.set_absolute_time(datetime(2001,i,1), datetime(2001, i + 1, 1))
+               ...   else:
+               ...       check = map.set_absolute_time(datetime(2001,i,1),  None)
+               ...   map.temporal_buffer("7 days")
+               ...   maps.append(map)
+               >>> for map in maps:
+               ...   map.temporal_extent.print_info()
+                +-------------------- Absolute time -----------------------------------------+
+                | Start time:................. 2000-12-25 00:00:00
+                | End time:................... 2001-01-08 00:00:00
+                +-------------------- Absolute time -----------------------------------------+
+                | Start time:................. 2001-01-25 00:00:00
+                | End time:................... 2001-03-08 00:00:00
+                +-------------------- Absolute time -----------------------------------------+
+                | Start time:................. 2001-02-22 00:00:00
+                | End time:................... 2001-03-08 00:00:00
+                +-------------------- Absolute time -----------------------------------------+
+                | Start time:................. 2001-03-25 00:00:00
+                | End time:................... 2001-05-08 00:00:00
 
-           @endcode
         """
 
         if self.is_time_absolute():
             start, end = self.get_absolute_time()
 
             new_start = decrement_datetime_by_string(start, increment)
-            if end == None:
+            if end is None:
                 new_end = increment_datetime_by_string(start, increment)
             else:
                 new_end = increment_datetime_by_string(end, increment)
@@ -651,7 +667,7 @@
         else:
             start, end, unit = self.get_relative_time()
             new_start = start - increment
-            if end == None:
+            if end is None:
                 new_end = start + increment
             else:
                 new_end = end + increment
@@ -661,101 +677,101 @@
             else:
                 self.set_relative_time(new_start, new_end, unit)
 
-    def set_spatial_extent_from_values(self, north, south, east, west, top=0, bottom=0):
-        """!Set the spatial extent of the map from values
+    def set_spatial_extent_from_values(self, north, south, east, west, top=0,
+                                       bottom=0):
+        """Set the spatial extent of the map from values
 
             This method only modifies this object and does not commit
             the modifications to the temporal database.
 
-           @param north The northern edge
-           @param south The southern edge
-           @param east The eastern edge
-           @param west The western edge
-           @param top The top edge
-           @param bottom The bottom edge
+           :param north: The northern edge
+           :param south: The southern edge
+           :param east: The eastern edge
+           :param west: The western edge
+           :param top: The top edge
+           :param bottom: The bottom edge
         """
         self.spatial_extent.set_spatial_extent_from_values(
             north, south, east, west, top, bottom)
 
     def set_spatial_extent(self, spatial_extent):
-        """!Set the spatial extent of the map
+        """Set the spatial extent of the map
 
             This method only modifies this object and does not commit
             the modifications to the temporal database.
 
-            @param spatial_extent An object of type SpatialExtent or its subclasses
+            :param spatial_extent: An object of type SpatialExtent or its
+                                   subclasses
 
-           @code
-           >>> import datetime
-           >>> import grass.temporal as tgis
-           >>> map      = tgis.RasterDataset(None)
-           >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
-           >>> map.set_spatial_extent(spat_ext)
-           >>> print map.get_spatial_extent_as_tuple()
-           (10.0, -10.0, 20.0, -20.0, 5.0, -5.0)
+           .. code-block: : python
 
-           @endcode
+               >>> import datetime
+               >>> import grass.temporal as tgis
+               >>> map      = tgis.RasterDataset(None)
+               >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
+               >>> map.set_spatial_extent(spat_ext)
+               >>> print map.get_spatial_extent_as_tuple()
+               (10.0, -10.0, 20.0, -20.0, 5.0, -5.0)
+
         """
         self.spatial_extent.set_spatial_extent(spatial_extent)
 
     def spatial_buffer(self, size, update=False, dbif=None):
-        """!Buffer the spatial extent by a given size in all
+        """Buffer the spatial extent by a given size in all
            spatial directions.
 
-           @param size The buffer size, using the unit of the grass region
+           :param size: The buffer size, using the unit of the grass region
 
-           @code
+           .. code-block: : python
 
-           >>> import grass.temporal as tgis
-           >>> map = tgis.RasterDataset(None)
-           >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
-           >>> map.set_spatial_extent(spat_ext)
-           >>> map.spatial_buffer(10)
-           >>> print map.get_spatial_extent_as_tuple()
-           (20.0, -20.0, 30.0, -30.0, 15.0, -15.0)
+               >>> import grass.temporal as tgis
+               >>> map = tgis.RasterDataset(None)
+               >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
+               >>> map.set_spatial_extent(spat_ext)
+               >>> map.spatial_buffer(10)
+               >>> print map.get_spatial_extent_as_tuple()
+               (20.0, -20.0, 30.0, -30.0, 15.0, -15.0)
 
-           @endcode
         """
-        self.spatial_extent.north   += size
-        self.spatial_extent.south   -= size
-        self.spatial_extent.east    += size
-        self.spatial_extent.west    -= size
-        self.spatial_extent.top     += size
-        self.spatial_extent.bottom  -= size
+        self.spatial_extent.north += size
+        self.spatial_extent.south -= size
+        self.spatial_extent.east += size
+        self.spatial_extent.west -= size
+        self.spatial_extent.top += size
+        self.spatial_extent.bottom -= size
 
         if update:
             self.spatial_extent.update(dbif)
 
     def spatial_buffer_2d(self, size, update=False, dbif=None):
-        """!Buffer the spatial extent by a given size in 2d
+        """Buffer the spatial extent by a given size in 2d
            spatial directions.
 
-           @param size The buffer size, using the unit of the grass region
+           :param size: The buffer size, using the unit of the grass region
 
-           @code
+           .. code-block: : python
 
-           >>> import grass.temporal as tgis
-           >>> map = tgis.RasterDataset(None)
-           >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
-           >>> map.set_spatial_extent(spat_ext)
-           >>> map.spatial_buffer_2d(10)
-           >>> print map.get_spatial_extent_as_tuple()
-           (20.0, -20.0, 30.0, -30.0, 5.0, -5.0)
+               >>> import grass.temporal as tgis
+               >>> map = tgis.RasterDataset(None)
+               >>> spat_ext = tgis.SpatialExtent(north=10, south=-10, east=20, west=-20, top=5, bottom=-5)
+               >>> map.set_spatial_extent(spat_ext)
+               >>> map.spatial_buffer_2d(10)
+               >>> print map.get_spatial_extent_as_tuple()
+               (20.0, -20.0, 30.0, -30.0, 5.0, -5.0)
 
-           @endcode
         """
-        self.spatial_extent.north   += size
-        self.spatial_extent.south   -= size
-        self.spatial_extent.east    += size
-        self.spatial_extent.west    -= size
+        self.spatial_extent.north += size
+        self.spatial_extent.south -= size
+        self.spatial_extent.east += size
+        self.spatial_extent.west -= size
 
         if update:
             self.spatial_extent.update(dbif)
 
     def check_for_correct_time(self):
-        """!Check for correct time"""
+        """Check for correct time"""
         if self.is_time_absolute():
-            start, end= self.get_absolute_time()
+            start, end = self.get_absolute_time()
         else:
             start, end, unit = self.get_relative_time()
 
@@ -763,48 +779,52 @@
             if end is not None:
                 if start >= end:
                     if self.get_layer() is not None:
-                        self.msgr.error(_("Map <%(id)s> with layer %(layer)s has "
-                                     "incorrect time interval, start time is "
-                                     "greater than end time") % {
-                                     'id': self.get_map_id(),
-                                     'layer': self.get_layer()})
+                        self.msgr.error(_("Map <%(id)s> with layer %(layer)s "
+                                          "has incorrect time interval, start "
+                                          "time is greater than end time") %
+                                        {'id': self.get_map_id(),
+                                         'layer': self.get_layer()})
                     else:
-                        self.msgr.error(_("Map <%s> has incorrect time interval, "
-                                     "start time is greater than end time") % \
-                                   (self.get_map_id()))
+                        self.msgr.error(_("Map <%s> has incorrect time "
+                                          "interval, start time is greater "
+                                          "than end time") %
+                                         (self.get_map_id()))
                     return False
         else:
             self.msgr.error(_("Map <%s> has incorrect start time") %
-                       (self.get_map_id()))
+                             (self.get_map_id()))
             return False
 
         return True
 
     def delete(self, dbif=None, update=True, execute=True):
-        """!Delete a map entry from database if it exists
+        """Delete a map entry from database if it exists
 
             Remove dependent entries:
-            * Remove the map entry in each space time dataset in which this map
+
+            - Remove the map entry in each space time dataset in which this map
               is registered
-            * Remove the space time dataset register table
+            - Remove the space time dataset register table
 
-           @param dbif The database interface to be used
-           @param update Call for each unregister statement the update from
+           :param dbif: The database interface to be used
+           :param update: Call for each unregister statement the update from
                           registered maps of the space time dataset.
                           This can slow down the un-registration process
                           significantly.
-           @param execute If True the SQL DELETE and DROP table statements will
-                           be executed.
+           :param execute: If True the SQL DELETE and DROP table statements
+                           will be executed.
                            If False the prepared SQL statements are
                            returned and must be executed by the caller.
 
-           @return The SQL statements if execute=False, else an empty string,
-                   None in case of a failure
+           :return: The SQL statements if execute=False, else an empty string,
+                    None in case of a failure
         """
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to delete dataset <%(ds)s> of type %(type)s from the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+            self.msgr.fatal(_("Unable to delete dataset <%(ds)s> of type "
+                              "%(type)s from the temporal database. The mapset"
+                              " of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
         dbif, connected = init_dbif(dbif)
         statement = ""
@@ -818,8 +838,8 @@
             statement += self.unregister(
                 dbif=dbif, update=update, execute=False)
 
-            self.msgr.verbose(_("Delete %s dataset <%s> from temporal database")
-                         % (self.get_type(), self.get_id()))
+            self.msgr.verbose(_("Delete %s dataset <%s> from temporal "
+                                "database") % (self.get_type(), self.get_id()))
 
             # Delete yourself from the database, trigger functions will
             # take care of dependencies
@@ -840,36 +860,39 @@
         return statement
 
     def unregister(self, dbif=None, update=True, execute=True):
-        """! Remove the map entry in each space time dataset in which this map
+        """ Remove the map entry in each space time dataset in which this map
            is registered
 
-           @param dbif The database interface to be used
-           @param update Call for each unregister statement the update from
-                         registered maps of the space time dataset. This can
-                         slow down the un-registration process significantly.
-           @param execute If True the SQL DELETE and DROP table statements
-                          will be executed.
-                          If False the prepared SQL statements are
-                          returned and must be executed by the caller.
+           :param dbif: The database interface to be used
+           :param update: Call for each unregister statement the update from
+                          registered maps of the space time dataset. This can
+                          slow down the un-registration process significantly.
+           :param execute: If True the SQL DELETE and DROP table statements
+                           will be executed.
+                           If False the prepared SQL statements are
+                           returned and must be executed by the caller.
 
-           @return The SQL statements if execute=False, else an empty string
+           :return: The SQL statements if execute=False, else an empty string
         """
 
-
         if self.get_layer() is not None:
             self.msgr.debug(1, "Unregister %(type)s map <%(map)s> with "
-                           "layer %(layer)s from space time datasets" % \
-                         {'type':self.get_type(), 'map':self.get_map_id(),
-                          'layer':self.get_layer()})
+                               "layer %(layer)s from space time datasets" %
+                               {'type': self.get_type(),
+                                'map': self.get_map_id(),
+                                'layer': self.get_layer()})
         else:
             self.msgr.debug(1, "Unregister %(type)s map <%(map)s> "
-                           "from space time datasets"
-                         % {'type':self.get_type(), 'map':self.get_map_id()})
+                               "from space time datasets" % {
+                               'type': self.get_type(),
+                               'map': self.get_map_id()})
 
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to unregister dataset <%(ds)s> of type %(type)s from the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+            self.msgr.fatal(_("Unable to unregister dataset <%(ds)s> of type "
+                              "%(type)s from the temporal database. The mapset"
+                              " of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
         statement = ""
         dbif, connected = init_dbif(dbif)
@@ -887,7 +910,7 @@
                     statement += stds.unregister_map(self, dbif, False)
                     # Take care to update the space time dataset after
                     # the map has been unregistered
-                    if update == True and execute == True:
+                    if update is True and execute is True:
                         stds.update_from_registered_maps(dbif)
 
         if execute:
@@ -900,13 +923,13 @@
         return statement
 
     def get_registered_stds(self, dbif=None):
-        """!Return all space time dataset ids in which this map is registered
+        """Return all space time dataset ids in which this map is registered
            as as a list of strings, or None if this map is not
            registered in any space time dataset.
 
-           @param dbif The database interface to be used
-           @return A list of ids of all space time datasets in
-                   which this map is registered
+           :param dbif: The database interface to be used
+           :return: A list of ids of all space time datasets in
+                        which this map is registered
         """
         dbif, connected = init_dbif(dbif)
 
@@ -924,16 +947,16 @@
         return datasets
 
     def add_stds_to_register(self, stds_id, dbif=None, execute=True):
-        """!Add a new space time dataset to the register
+        """Add a new space time dataset to the register
 
-           @param stds_id The id of the space time dataset to be registered
-           @param dbif The database interface to be used
-           @param execute If True the SQL INSERT table statements
-                          will be executed.
-                          If False the prepared SQL statements are
-                          returned and must be executed by the caller.
+           :param stds_id: The id of the space time dataset to be registered
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL INSERT table statements
+                           will be executed.
+                           If False the prepared SQL statements are
+                           returned and must be executed by the caller.
 
-           @return The SQL statements if execute=False, else an empty string
+           :return: The SQL statements if execute=False, else an empty string
         """
         dbif, connected = init_dbif(dbif=dbif)
 
@@ -968,18 +991,18 @@
 
         return statement
 
-
     def remove_stds_from_register(self, stds_id, dbif=None, execute=True):
-        """!Remove a space time dataset from the register
+        """Remove a space time dataset from the register
 
-           @param stds_id The id of the space time dataset to removed from the registered
-           @param dbif The database interface to be used
-           @param execute If True the SQL INSERT table statements
-                          will be executed.
-                          If False the prepared SQL statements are
-                          returned and must be executed by the caller.
+           :param stds_id: The id of the space time dataset to removed from
+                           the registered
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL INSERT table statements
+                           will be executed.
+                           If False the prepared SQL statements are
+                           returned and must be executed by the caller.
 
-           @return The SQL statements if execute=False, else an empty string
+           :return: The SQL statements if execute=False, else an empty string
         """
         dbif, connected = init_dbif(dbif)
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/abstract_space_time_dataset.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,17 +1,14 @@
 # -*- coding: utf-8 -*-
-"""!@package grass.temporal
+"""
+The abstract_space_time_dataset module provides the AbstractSpaceTimeDataset
+class that is the base class for all space time datasets.
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in temporal GIS Python
-library package.
-
 (C) 2011-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 import sys
 import uuid
@@ -21,10 +18,13 @@
 
 ###############################################################################
 
+
 class AbstractSpaceTimeDataset(AbstractDataset):
-    """!Abstract space time dataset class
+    """Abstract space time dataset class
 
-       This class represents a space time dataset. Convenient functions
+       Base class for all space time datasets.
+
+       This class represents an abstract space time dataset. Convenient functions
        to select, update, insert or delete objects of this type in the SQL
        temporal database exists as well as functions to register or unregister
        raster maps.
@@ -42,7 +42,7 @@
         self.map_counter = 0
 
     def create_map_register_name(self):
-        """!Create the name of the map register table of this space time
+        """Create the name of the map register table of this space time
             dataset
 
             A uuid and the map type are used to create the table name
@@ -50,31 +50,31 @@
             ATTENTION: It must be assured that the base object has selected its
             content from the database.
 
-            @return The name of the map register table
+            :return: The name of the map register table
         """
-        
+
         uuid_rand = str(uuid.uuid4()).replace("-",  "")
-        
+
         table_name = self.get_new_map_instance(None).get_type() + "_map_register_" + uuid_rand
         return table_name
 
     @abstractmethod
     def get_new_map_instance(self, ident=None):
-        """!Return a new instance of a map which is associated
+        """Return a new instance of a map which is associated
            with the type of this object
 
-           @param ident The unique identifier of the new object
+           :param ident: The unique identifier of the new object
         """
 
     @abstractmethod
     def get_map_register(self):
-        """!Return the name of the map register table
-           @return The map register table name
+        """Return the name of the map register table
+           :return: The map register table name
         """
 
     @abstractmethod
     def set_map_register(self, name):
-        """!Set the name of the map register table
+        """Set the name of the map register table
 
            This table stores all map names which are registered
            in this space time dataset.
@@ -82,18 +82,18 @@
            This method only modifies this object and does not commit
            the modifications to the temporal database.
 
-           @param name The name of the register table
+           :param name: The name of the register table
         """
 
     def print_self(self):
-        """!Print the content of the internal structure to stdout"""
+        """Print the content of the internal structure to stdout"""
         self.base.print_self()
         self.temporal_extent.print_self()
         self.spatial_extent.print_self()
         self.metadata.print_self()
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
 
         if self.get_type() == "strds":
             #                1         2         3         4         5         6         7
@@ -115,21 +115,21 @@
         print " +----------------------------------------------------------------------------+"
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         self.base.print_shell_info()
         self.temporal_extent.print_shell_info()
         self.spatial_extent.print_shell_info()
         self.metadata.print_shell_info()
 
     def print_history(self):
-        """!Print history information about this class in human readable
+        """Print history information about this class in human readable
             shell style
         """
         self.metadata.print_history()
 
     def set_initial_values(self, temporal_type, semantic_type=None,
                            title=None, description=None):
-        """!Set the initial values of the space time dataset
+        """Set the initial values of the space time dataset
 
             In addition the command creation string is generated
             an inserted into the metadata object.
@@ -140,11 +140,11 @@
             The insert() function must be called to commit
             this content into the temporal database.
 
-           @param temporal_type The temporal type of this space
+           :param temporal_type: The temporal type of this space
                                 time dataset (absolute or relative)
-           @param semantic_type The semantic type of this dataset
-           @param title The title
-           @param description The description of this dataset
+           :param semantic_type: The semantic type of this dataset
+           :param title: The title
+           :param description: The description of this dataset
         """
 
         if temporal_type == "absolute":
@@ -160,16 +160,18 @@
         self.metadata.set_command(self.create_command_string())
 
     def set_aggregation_type(self, aggregation_type):
-        """!Set the aggregation type of the space time dataset
+        """Set the aggregation type of the space time dataset
 
-           @param aggregation_type The aggregation type of the space time dataset
+           :param aggregation_type: The aggregation type of the space time
+                                    dataset
         """
         self.metadata.set_aggregation_type(aggregation_type)
 
     def update_command_string(self, dbif=None):
-        """!Append the current command string to any existing command string
+        """Append the current command string to any existing command string
            in the metadata class and calls metadata update
-           @param dbif The database interface to be used
+
+           :param dbif: The database interface to be used
         """
 
         self.metadata.select(dbif=dbif)
@@ -181,12 +183,12 @@
         self.metadata.update(dbif=dbif)
 
     def create_command_string(self):
-        """!Create the command string that was used to create this
+        """Create the command string that was used to create this
            space time dataset.
 
            The command string should be set with self.metadata.set_command()
 
-           @return The command string
+           :return: The command string
            """
         # The grass module
 
@@ -224,16 +226,16 @@
                 length += len(token) + 1
 
         command += "\n"
-        return command
+        return str(command)
 
     def get_semantic_type(self):
-        """!Return the semantic type of this dataset
-           @return The semantic type
+        """Return the semantic type of this dataset
+           :return: The semantic type
         """
         return self.base.get_semantic_type()
 
     def get_initial_values(self):
-        """!Return the initial values: temporal_type,
+        """Return the initial values: temporal_type,
            semantic_type, title, description"""
 
         temporal_type = self.get_temporal_type()
@@ -244,21 +246,20 @@
         return temporal_type, semantic_type, title, description
 
     def get_granularity(self):
-        """!Return the granularity of the space time dataset
+        """Return the granularity of the space time dataset
 
            Granularity can be of absolute time or relative time.
            In case of absolute time a string containing an integer
            value and the time unit (years, months, days, hours, minuts,
-                                    seconds).
-           In case of relative time an integer value is expected.
+           seconds). In case of relative time an integer value is expected.
 
-           @return The granularity
+           :return: The granularity
         """
 
         return self.temporal_extent.get_granularity()
 
     def set_granularity(self, granularity):
-        """!Set the granularity
+        """Set the granularity
 
            The granularity is usually computed by the space time dataset at
            runtime.
@@ -266,13 +267,12 @@
            Granularity can be of absolute time or relative time.
            In case of absolute time a string containing an integer
            value and the time unit (years, months, days, hours, minuts,
-                                    seconds).
-           In case of relative time an integer value is expected.
+           seconds). In case of relative time an integer value is expected.
 
            This method only modifies this object and does not commit
            the modifications to the temporal database.
 
-           @param granularity The granularity of the dataset
+           :param granularity: The granularity of the dataset
         """
 
         temporal_type = self.get_temporal_type()
@@ -291,7 +291,7 @@
         self.temporal_extent.set_granularity(granularity)
 
     def set_relative_time_unit(self, unit):
-        """!Set the relative time unit which may be of type:
+        """Set the relative time unit which may be of type:
            years, months, days, hours, minutes or seconds
 
            All maps registered in a (relative time)
@@ -300,7 +300,7 @@
            This method only modifies this object and does not commit
            the modifications to the temporal database.
 
-           @param unit The relative time unit
+           :param unit: The relative time unit
         """
 
         temporal_type = self.get_temporal_type()
@@ -311,18 +311,18 @@
             self.relative_time.set_unit(unit)
 
     def insert(self, dbif=None, execute=True):
-        """!Insert the space time dataset content into the database from the internal
+        """Insert the space time dataset content into the database from the internal
            structure
 
            The map register table will be created, so that maps
            can be registered.
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL statements will be executed.
-                          If False the prepared SQL statements are
-                          returned and must be executed by the caller.
-           @return The SQL insert statement in case execute=False, or an
-                   empty string otherwise
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL statements will be executed.
+                           If False the prepared SQL statements are
+                           returned and must be executed by the caller.
+           :return: The SQL insert statement in case execute=False, or an
+                    empty string otherwise
         """
 
         dbif, connected = init_dbif(dbif)
@@ -344,21 +344,24 @@
             # Read the SQL template
             sql = open(os.path.join(sql_path,
                                     "stds_map_register_table_template.sql"),
-                                    'r').read()
+                       'r').read()
 
             # Create a raster, raster3d or vector tables
             sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table)
             statement += sql
 
-            if dbif.dbmi.__name__ == "sqlite3":
-                statement += "CREATE INDEX %s_index ON %s (id);"%(stds_register_table, stds_register_table)
+            if dbif.get_dbmi().__name__ == "sqlite3":
+                statement += "CREATE INDEX %s_index ON %s (id);" % \
+                             (stds_register_table, stds_register_table)
 
             # Set the map register table name
             self.set_map_register(stds_register_table)
 
             self.msgr.debug(1, _("Created register table <%s> for space "
-                           "time %s  dataset <%s>") %
-                          (stds_register_table, self.get_new_map_instance(None).get_type(), self.get_id()))
+                                 "time %s  dataset <%s>") %
+                                (stds_register_table,
+                                 self.get_new_map_instance(None).get_type(),
+                                 self.get_id()))
 
         statement += AbstractDataset.insert(self, dbif=dbif, execute=False)
 
@@ -372,13 +375,13 @@
         return statement
 
     def get_map_time(self):
-        """!Return the type of the map time, interval, point, mixed or invalid
+        """Return the type of the map time, interval, point, mixed or invalid
         """
 
         return self.temporal_extent.get_map_time()
 
     def count_temporal_types(self, maps=None, dbif=None):
-        """!Return the temporal type of the registered maps as dictionary
+        """Return the temporal type of the registered maps as dictionary
 
            The map list must be ordered by start time
 
@@ -388,8 +391,8 @@
            - interval -> start and end time
            - invalid  -> No valid time point or interval found
 
-           @param maps A sorted (start_time) list of AbstractDataset objects
-           @param dbif The database interface to be used
+           :param maps: A sorted (start_time) list of AbstractDataset objects
+           :param dbif: The database interface to be used
         """
 
         if maps is None:
@@ -422,11 +425,11 @@
         return tcount
 
     def count_gaps(self, maps=None, dbif=None):
-        """!Count the number of gaps between temporal neighbors
+        """Count the number of gaps between temporal neighbors
 
-           @param maps A sorted (start_time) list of AbstractDataset objects
-           @param dbif The database interface to be used
-           @return The numbers of gaps between temporal neighbors
+           :param maps: A sorted (start_time) list of AbstractDataset objects
+           :param dbif: The database interface to be used
+           :return: The numbers of gaps between temporal neighbors
         """
 
         if maps is None:
@@ -446,16 +449,16 @@
 
     def print_spatio_temporal_relationships(self, maps=None, spatial=None,
                                             dbif=None):
-        """!Print the spatio-temporal relationships for each map of the space
+        """Print the spatio-temporal relationships for each map of the space
            time dataset or for each map of the optional list of maps
 
-           @param maps a ordered by start_time list of map objects, if None the
-                       registred maps of the space time dataset are used
-           @param spatial This indicates if the spatial topology is created as
-                          well: spatial can be None (no spatial topology), "2D"
-                          using west, east, south, north or "3D" using west,
-                          east, south, north, bottom, top
-           @param dbif The database interface to be used
+           :param maps: a ordered by start_time list of map objects, if None
+                        the registred maps of the space time dataset are used
+           :param spatial: This indicates if the spatial topology is created as
+                           well: spatial can be None (no spatial topology),
+                           "2D" using west, east, south, north or "3D" using
+                           west, east, south, north, bottom, top
+           :param dbif: The database interface to be used
         """
 
         if maps is None:
@@ -463,18 +466,19 @@
                 where=None, order="start_time", dbif=dbif)
 
         print_spatio_temporal_topology_relationships(maps1=maps, maps2=maps,
-                                              spatial=spatial, dbif=dbif)
+                                                     spatial=spatial,
+                                                     dbif=dbif)
 
     def count_temporal_relations(self, maps=None, dbif=None):
-        """!Count the temporal relations between the registered maps.
+        """Count the temporal relations between the registered maps.
 
            The map list must be ordered by start time.
            Temporal relations are counted by analysing the sparse upper right
            side temporal relationships matrix.
 
-           @param maps A sorted (start_time) list of AbstractDataset objects
-           @param dbif The database interface to be used
-           @return A dictionary with counted temporal relationships
+           :param maps: A sorted (start_time) list of AbstractDataset objects
+           :param dbif: The database interface to be used
+           :return: A dictionary with counted temporal relationships
         """
 
         if maps is None:
@@ -484,7 +488,7 @@
         return count_temporal_topology_relationships(maps1=maps, dbif=dbif)
 
     def check_temporal_topology(self, maps=None, dbif=None):
-        """!Check the temporal topology of all maps of the current space time
+        """Check the temporal topology of all maps of the current space time
            dataset or of an optional list of maps
 
            Correct topology means, that time intervals are not overlap or
@@ -494,7 +498,7 @@
            The optional map list must be ordered by start time
 
            Allowed and not allowed temporal relationships for correct topology:
-           @verbatim
+
            - after      -> allowed
            - precedes   -> allowed
            - follows    -> allowed
@@ -509,20 +513,21 @@
            - finishes   -> not allowed
            - started    -> not allowed
            - finished   -> not allowed
-           @endverbatim
 
-           @param maps An optional list of AbstractDataset objects, in case of
+
+           :param maps: An optional list of AbstractDataset objects, in case of
                        None all maps of the space time dataset are checked
-           @param dbif The database interface to be used
-           @return True if topology is correct
+           :param dbif: The database interface to be used
+           :return: True if topology is correct
         """
         if maps is None:
             maps = self.get_registered_maps_as_objects(
                 where=None, order="start_time", dbif=dbif)
 
-        relations = count_temporal_topology_relationships(maps1=maps, dbif=dbif)
+        relations = count_temporal_topology_relationships(maps1=maps,
+                                                          dbif=dbif)
 
-        if relations == None:
+        if relations is None:
             return False
 
         map_time = self.get_map_time()
@@ -555,7 +560,7 @@
         return True
 
     def sample_by_dataset(self, stds, method=None, spatial=False, dbif=None):
-        """!Sample this space time dataset with the temporal topology
+        """Sample this space time dataset with the temporal topology
            of a second space time dataset
 
            In case spatial is True, the spatial overlap between
@@ -571,17 +576,18 @@
            map and its temporal extent (the actual granule) and
            the list of samples are stored:
 
-           @code
-           list = self.sample_by_dataset(stds=sampler, method=[
-               "during","overlap","contains","equal"])
-           for entry in list:
-               granule = entry["granule"]
-               maplist = entry["samples"]
-               for map in maplist:
-                   map.select()
-                   map.print_info()
-           @endcode
+           .. code-block:: python
 
+               list = self.sample_by_dataset(stds=sampler, method=[
+                   "during","overlap","contains","equal"])
+               for entry in list:
+                   granule = entry["granule"]
+                   maplist = entry["samples"]
+                   for map in maplist:
+                       map.select()
+                       map.print_info()
+
+
            A valid temporal topology (no overlapping or inclusion allowed)
            is needed to get correct results in case of gaps in the sample
            dataset.
@@ -594,94 +600,88 @@
            In case more map information are needed, use the select()
            method for each listed object.
 
-           @param stds The space time dataset to be used for temporal sampling
-           @param method This option specifies what sample method should be
+           :param stds: The space time dataset to be used for temporal sampling
+           :param method: This option specifies what sample method should be
                          used. In case the registered maps are of temporal
                          point type, only the start time is used for sampling.
                          In case of mixed of interval data the user can chose
                          between:
 
-                  - Example @code ["start", "during", "equals"] @endcode
+                  - Example ["start", "during", "equals"]
 
                   - start: Select maps of which the start time is
-                    located in the selection granule
-                    @verbatim
-                    map    :        s
-                    granule:  s-----------------e
+                    located in the selection granule::
 
-                    map    :        s--------------------e
-                    granule:  s-----------------e
+                        map    :        s
+                        granule:  s-----------------e
 
-                    map    :        s--------e
-                    granule:  s-----------------e
-                    @endverbatim
+                        map    :        s--------------------e
+                        granule:  s-----------------e
 
+                        map    :        s--------e
+                        granule:  s-----------------e
+
                   - contains: Select maps which are temporal
-                              during the selection granule
-                    @verbatim
-                    map    :     s-----------e
-                    granule:  s-----------------e
-                    @endverbatim
+                     during the selection granule::
 
+                        map    :     s-----------e
+                        granule:  s-----------------e
+
                   - overlap: Select maps which temporal overlap
-                    the selection granule, this includes overlaps and overlapped
-                    @verbatim
-                    map    :     s-----------e
-                    granule:        s-----------------e
+                    the selection granule, this includes overlaps and
+                    overlapped::
 
-                    map    :     s-----------e
-                    granule:  s----------e
-                    @endverbatim
+                        map    :     s-----------e
+                        granule:        s-----------------e
 
+                        map    :     s-----------e
+                        granule:  s----------e
+
                   - during: Select maps which temporally contains
-                            the selection granule
-                    @verbatim
-                    map    :  s-----------------e
-                    granule:     s-----------e
-                    @endverbatim
+                    the selection granule::
 
+                        map    :  s-----------------e
+                        granule:     s-----------e
+
                   - equals: Select maps which temporally equal
-                    to the selection granule
-                    @verbatim
-                    map    :  s-----------e
-                    granule:  s-----------e
-                    @endverbatim
+                    to the selection granule::
 
+                        map    :  s-----------e
+                        granule:  s-----------e
+
                   - follows: Select maps which temporally follow
-                    the selection granule
-                    @verbatim
-                    map    :              s-----------e
-                    granule:  s-----------e
-                    @endverbatim
+                    the selection granule::
 
+                        map    :              s-----------e
+                        granule:  s-----------e
+
                   - precedes: Select maps which temporally precedes
-                    the selection granule
-                    @verbatim
-                    map    :  s-----------e
-                    granule:              s-----------e
-                    @endverbatim
+                    the selection granule::
 
+                        map    :  s-----------e
+                        granule:              s-----------e
+
                   All these methods can be combined. Method must be of
                   type tuple including the identification strings.
 
-           @param spatial If set True additional the 2d spatial overlapping
+           :param spatial: If set True additional the 2d spatial overlapping
                           is used for selection -> spatio-temporal relation.
                           The returned map objects will have temporal and
                           spatial extents
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
 
-           @return A list of lists of map objects or None in case nothing was
+           :return: A list of lists of map objects or None in case nothing was
                    found None
         """
 
         if self.get_temporal_type() != stds.get_temporal_type():
             self.msgr.error(_("The space time datasets must be of "
-                         "the same temporal type"))
+                              "the same temporal type"))
             return None
 
         if stds.get_map_time() != "interval":
             self.msgr.error(_("The temporal map type of the sample "
-                         "dataset must be interval"))
+                              "dataset must be interval"))
             return None
 
         dbif, connected = init_dbif(dbif)
@@ -713,10 +713,10 @@
                 relations.append("contains")
 
         # Remove start, equal, contain and overlap
-        relations = [relation.upper().strip() for relation in relations if relation \
-                    not in ["start", "overlap", "contain"]]
+        relations = [relation.upper().strip() for relation in relations
+                     if relation not in ["start", "overlap", "contain"]]
 
-        #print(relations)
+        #  print(relations)
 
         tb = SpatioTemporalTopologyBuilder()
         if spatial:
@@ -763,9 +763,9 @@
 
         return obj_list
 
-
-    def sample_by_dataset_sql(self, stds, method=None, spatial=False, dbif=None):
-        """!Sample this space time dataset with the temporal topology
+    def sample_by_dataset_sql(self, stds, method=None, spatial=False,
+                              dbif=None):
+        """Sample this space time dataset with the temporal topology
            of a second space time dataset using SQL queries.
 
            This function is very slow for huge large space time datasets
@@ -787,17 +787,18 @@
            map and its temporal extent (the actual granule) and
            the list of samples are stored:
 
-           @code
-           list = self.sample_by_dataset(stds=sampler, method=[
-               "during","overlap","contain","equal"])
-           for entry in list:
-               granule = entry["granule"]
-               maplist = entry["samples"]
-               for map in maplist:
-                   map.select()
-                   map.print_info()
-           @endcode
+           .. code-block:: python
 
+               list = self.sample_by_dataset(stds=sampler, method=[
+                   "during","overlap","contain","equal"])
+               for entry in list:
+                   granule = entry["granule"]
+                   maplist = entry["samples"]
+                   for map in maplist:
+                       map.select()
+                       map.print_info()
+
+
            A valid temporal topology (no overlapping or inclusion allowed)
            is needed to get correct results in case of gaps in the sample
            dataset.
@@ -810,82 +811,77 @@
            In case more map information are needed, use the select()
            method for each listed object.
 
-           @param stds The space time dataset to be used for temporal sampling
-           @param method This option specifies what sample method should be
+           :param stds: The space time dataset to be used for temporal sampling
+           :param method: This option specifies what sample method should be
                          used. In case the registered maps are of temporal
                          point type, only the start time is used for sampling.
                          In case of mixed of interval data the user can chose
                          between:
-                  - ["start", "during", "equals"]
 
+                  - Example ["start", "during", "equals"]
+
                   - start: Select maps of which the start time is
-                    located in the selection granule
-                    @verbatim
-                    map    :        s
-                    granule:  s-----------------e
+                    located in the selection granule::
 
-                    map    :        s--------------------e
-                    granule:  s-----------------e
+                        map    :        s
+                        granule:  s-----------------e
 
-                    map    :        s--------e
-                    granule:  s-----------------e
-                    @endverbatim
+                        map    :        s--------------------e
+                        granule:  s-----------------e
 
+                        map    :        s--------e
+                        granule:  s-----------------e
+
                   - contains: Select maps which are temporal
-                              during the selection granule
-                    @verbatim
-                    map    :     s-----------e
-                    granule:  s-----------------e
-                    @endverbatim
+                    during the selection granule::
 
+                        map    :     s-----------e
+                        granule:  s-----------------e
+
                   - overlap: Select maps which temporal overlap
-                    the selection granule, this includes overlaps and overlapped
-                    @verbatim
-                    map    :     s-----------e
-                    granule:        s-----------------e
+                    the selection granule, this includes overlaps and
+                    overlapped::
 
-                    map    :     s-----------e
-                    granule:  s----------e
-                    @endverbatim
+                        map    :     s-----------e
+                        granule:        s-----------------e
 
+                        map    :     s-----------e
+                        granule:  s----------e
+
                   - during: Select maps which temporally contains
-                            the selection granule
-                    @verbatim
-                    map    :  s-----------------e
-                    granule:     s-----------e
-                    @endverbatim
+                    the selection granule::
 
+                        map    :  s-----------------e
+                        granule:     s-----------e
+
                   - equals: Select maps which temporally equal
-                    to the selection granule
-                    @verbatim
-                    map    :  s-----------e
-                    granule:  s-----------e
-                    @endverbatim
+                    to the selection granule::
 
+                        map    :  s-----------e
+                        granule:  s-----------e
+
                   - follows: Select maps which temporally follow
-                    the selection granule
-                    @verbatim
-                    map    :              s-----------e
-                    granule:  s-----------e
-                    @endverbatim
+                    the selection granule::
 
+                        map    :              s-----------e
+                        granule:  s-----------e
+
                   - precedes: Select maps which temporally precedes
-                    the selection granule
-                    @verbatim
-                    map    :  s-----------e
-                    granule:              s-----------e
-                    @endverbatim
+                    the selection granule::
 
+                        map    :  s-----------e
+                        granule:              s-----------e
+
                   All these methods can be combined. Method must be of
                   type tuple including the identification strings.
 
-           @param spatial If set True additional the 2d spatial overlapping
+           :param spatial: If set True additional the 2d spatial overlapping
                           is used for selection -> spatio-temporal relation.
                           The returned map objects will have temporal and
                           spatial extents
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
 
-           @return A list of lists of map objects or None in case nothing was
+           :return: A list of lists of map objects or None in case nothing was
                    found None
         """
 
@@ -922,12 +918,12 @@
 
         if self.get_temporal_type() != stds.get_temporal_type():
             self.msgr.error(_("The space time datasets must be of "
-                         "the same temporal type"))
+                              "the same temporal type"))
             return None
 
         if stds.get_map_time() != "interval":
             self.msgr.error(_("The temporal map type of the sample "
-                         "dataset must be interval"))
+                              "dataset must be interval"))
             return None
 
         # In case points of time are available, disable the interval specific
@@ -1000,7 +996,7 @@
 
     def get_registered_maps_as_objects_by_granularity(self, gran=None,
                                                       dbif=None):
-        """!Return all registered maps as ordered (by start_time) object list
+        """Return all registered maps as ordered (by start_time) object list
            with "gap" map objects (id==None) for spatio-temporal topological
            operations that require the temporal extent only.
 
@@ -1029,7 +1025,7 @@
            In case more map information are needed, use the select()
            method for each listed object.
 
-           @param gran The granularity string to be used, if None the
+           :param gran: The granularity string to be used, if None the
                        granularity of the space time dataset is used.
                        Absolute time has the format "number unit", relative
                        time has the format "number".
@@ -1038,9 +1034,9 @@
                        weeks, month, months, year, years". The unit of the
                        relative time granule is always the space time dataset
                        unit and can not be changed.
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
 
-           @return ordered list of map lists. Each list represents a single
+           :return: ordered list of map lists. Each list represents a single
                    granule, or None in case nothing found
         """
 
@@ -1083,7 +1079,7 @@
 
     @staticmethod
     def resample_maplist_by_granularity(maps, start, end, gran):
-        """!Resample a list of AbstractMapDatasets by a given granularity
+        """Resample a list of AbstractMapDatasets by a given granularity
 
            The provided map list must be sorted by start time.
            A valid temporal topology (no overlapping or inclusion allowed)
@@ -1093,6 +1089,7 @@
            time are supported.
 
            The temporal topology search order is as follows:
+
            1. Maps that are equal to the actual granule are used
            2. If no euqal found then maps that contain the actual granule
               are used
@@ -1102,6 +1099,7 @@
            5. If no overlapped maps are found then maps are used that are
               durin the actual granule
 
+
            Each entry in the resulting list is a list of
            AbstractMapDatasets objects.
            Hence for each granule a list of AbstractMapDatasets can be
@@ -1109,12 +1107,12 @@
 
            Gaps between maps are identified as unregistered maps with id==None.
 
-           @param maps An ordered list (by start time) of AbstractMapDatasets
+           :param maps: An ordered list (by start time) of AbstractMapDatasets
                    objects. All maps must have the same temporal type
                    and the same unit in case of relative time.
-           @param start The start time of the provided map list
-           @param end   The end time of the provided map list
-           @param gran The granularity string to be used, if None the
+           :param start: The start time of the provided map list
+           :param end:   The end time of the provided map list
+           :param gran: The granularity string to be used, if None the
                    granularity of the space time dataset is used.
                    Absolute time has the format "number unit", relative
                    time has the format "number".
@@ -1124,70 +1122,69 @@
                    relative time granule is always the space time dataset
                    unit and can not be changed.
 
-           @return ordered list of map lists. Each list represents a single
+           :return: ordered list of map lists. Each list represents a single
                granule, or None in case nothing found
 
            Usage:
 
-        @code
+            .. code-block:: python
 
-        >>> import grass.temporal as tgis
-        >>> maps = []
-        >>> for i in xrange(3):
-        ...     map = tgis.RasterDataset("map%i at PERMANENT"%i)
-        ...     check = map.set_relative_time(i + 2, i + 3, "days")
-        ...     maps.append(map)
-        >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,8,1)
-        >>> for map_list in grans:
-        ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
-        None (0, 1)
-        None (1, 2)
-        map0 at PERMANENT (2, 3)
-        map1 at PERMANENT (3, 4)
-        map2 at PERMANENT (4, 5)
-        None (5, 6)
-        None (6, 7)
-        None (7, 8)
+                >>> import grass.temporal as tgis
+                >>> maps = []
+                >>> for i in xrange(3):
+                ...     map = tgis.RasterDataset("map%i at PERMANENT"%i)
+                ...     check = map.set_relative_time(i + 2, i + 3, "days")
+                ...     maps.append(map)
+                >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,8,1)
+                >>> for map_list in grans:
+                ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
+                None (0, 1)
+                None (1, 2)
+                map0 at PERMANENT (2, 3)
+                map1 at PERMANENT (3, 4)
+                map2 at PERMANENT (4, 5)
+                None (5, 6)
+                None (6, 7)
+                None (7, 8)
 
-        >>> maps = []
-        >>> map1 = tgis.RasterDataset("map1 at PERMANENT")
-        >>> check = map1.set_relative_time(2, 6, "days")
-        >>> maps.append(map1)
-        >>> map2 = tgis.RasterDataset("map2 at PERMANENT")
-        >>> check = map2.set_relative_time(7, 13, "days")
-        >>> maps.append(map2)
-        >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
-        >>> for map_list in grans:
-        ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
-        None (0, 2)
-        map1 at PERMANENT (2, 4)
-        map1 at PERMANENT (4, 6)
-        map2 at PERMANENT (6, 8)
-        map2 at PERMANENT (8, 10)
-        map2 at PERMANENT (10, 12)
-        map2 at PERMANENT (12, 14)
-        None (14, 16)
+                >>> maps = []
+                >>> map1 = tgis.RasterDataset("map1 at PERMANENT")
+                >>> check = map1.set_relative_time(2, 6, "days")
+                >>> maps.append(map1)
+                >>> map2 = tgis.RasterDataset("map2 at PERMANENT")
+                >>> check = map2.set_relative_time(7, 13, "days")
+                >>> maps.append(map2)
+                >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
+                >>> for map_list in grans:
+                ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
+                None (0, 2)
+                map1 at PERMANENT (2, 4)
+                map1 at PERMANENT (4, 6)
+                map2 at PERMANENT (6, 8)
+                map2 at PERMANENT (8, 10)
+                map2 at PERMANENT (10, 12)
+                map2 at PERMANENT (12, 14)
+                None (14, 16)
 
-        >>> maps = []
-        >>> map1 = tgis.RasterDataset("map1 at PERMANENT")
-        >>> check = map1.set_relative_time(2, None, "days")
-        >>> maps.append(map1)
-        >>> map2 = tgis.RasterDataset("map2 at PERMANENT")
-        >>> check = map2.set_relative_time(7, None, "days")
-        >>> maps.append(map2)
-        >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
-        >>> for map_list in grans:
-        ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
-        None (0, 2)
-        map1 at PERMANENT (2, 4)
-        None (4, 6)
-        map2 at PERMANENT (6, 8)
-        None (8, 10)
-        None (10, 12)
-        None (12, 14)
-        None (14, 16)
+                >>> maps = []
+                >>> map1 = tgis.RasterDataset("map1 at PERMANENT")
+                >>> check = map1.set_relative_time(2, None, "days")
+                >>> maps.append(map1)
+                >>> map2 = tgis.RasterDataset("map2 at PERMANENT")
+                >>> check = map2.set_relative_time(7, None, "days")
+                >>> maps.append(map2)
+                >>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
+                >>> for map_list in grans:
+                ...    print map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple()
+                None (0, 2)
+                map1 at PERMANENT (2, 4)
+                None (4, 6)
+                map2 at PERMANENT (6, 8)
+                None (8, 10)
+                None (10, 12)
+                None (12, 14)
+                None (14, 16)
 
-        @endcode
         """
 
         if not maps:
@@ -1204,11 +1201,12 @@
                 next = start + gran
 
             map = first.get_new_instance(None)
-            map.set_spatial_extent_from_values(0,0,0,0,0,0)
+            map.set_spatial_extent_from_values(0, 0, 0, 0, 0, 0)
             if first.is_time_absolute():
                 map.set_absolute_time(start, next)
             else:
-                map.set_relative_time(start, next, first.get_relative_time_unit())
+                map.set_relative_time(start, next,
+                                      first.get_relative_time_unit())
 
             gap_list.append(copy.copy(map))
             start = next
@@ -1216,13 +1214,14 @@
         tb = SpatioTemporalTopologyBuilder()
         tb.build(gap_list, maps)
 
-        relations_order = ["EQUAL", "DURING", "OVERLAPS", "OVERLAPPED", "CONTAINS"]
+        relations_order = ["EQUAL", "DURING", "OVERLAPS", "OVERLAPPED",
+                           "CONTAINS"]
 
         gran_list = []
         for gap in gap_list:
             # If not temporal relations then gap
             if not gap.get_temporal_relations():
-                gran_list.append([gap,])
+                gran_list.append([gap, ])
             else:
                 relations = gap.get_temporal_relations()
 
@@ -1242,7 +1241,7 @@
                         new_maps.append(new_map)
                     gran_list.append(new_maps)
                 else:
-                    gran_list.append([gap,])
+                    gran_list.append([gap, ])
 
         if gran_list:
             return gran_list
@@ -1250,7 +1249,7 @@
         return None
 
     def get_registered_maps_as_objects_with_gaps(self, where=None, dbif=None):
-        """!Return all or a subset of the registered maps as
+        """Return all or a subset of the registered maps as
            ordered (by start_time) object list with
            "gap" map objects (id==None) for spatio-temporal topological
            operations that require the spatio-temporal extent only.
@@ -1263,11 +1262,11 @@
            In case more map information are needed, use the select()
            method for each listed object.
 
-           @param where The SQL where statement to select a
+           :param where: The SQL where statement to select a
                         subset of the registered maps without "WHERE"
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
 
-           @return ordered object list, in case nothing found None is returned
+           :return: ordered object list, in case nothing found None is returned
         """
 
         dbif, connected = init_dbif(dbif)
@@ -1276,7 +1275,7 @@
 
         maps = self.get_registered_maps_as_objects(where, "start_time", dbif)
 
-        if maps  is not None and len(maps) > 0:
+        if maps is not None and len(maps) > 0:
             for i in range(len(maps)):
                 obj_list.append(maps[i])
                 # Detect and insert gaps
@@ -1298,7 +1297,7 @@
                         elif self.is_time_relative():
                             map.set_relative_time(start, end,
                                                  self.get_relative_time_unit())
-                        map.set_spatial_extent_from_values(0,0,0,0,0,0)
+                        map.set_spatial_extent_from_values(0, 0, 0, 0, 0, 0)
                         obj_list.append(copy.copy(map))
 
         if connected:
@@ -1309,7 +1308,7 @@
     def get_registered_maps_as_objects_with_temporal_topology(self, where=None,
                                                             order="start_time",
                                                             dbif=None):
-        """!Return all or a subset of the registered maps as ordered object
+        """Return all or a subset of the registered maps as ordered object
            list with spatio-temporal topological relationship informations.
 
            The objects are initialized with their id's' and the spatio-temporal
@@ -1318,12 +1317,12 @@
            In case more map information are needed, use the select()
            method for each listed object.
 
-           @param where The SQL where statement to select a subset of
+           :param where: The SQL where statement to select a subset of
                         the registered maps without "WHERE"
-           @param order The SQL order statement to be used to order the
+           :param order: The SQL order statement to be used to order the
                         objects in the list without "ORDER BY"
-           @param dbif The database interface to be used
-           @return The ordered map object list,
+           :param dbif: The database interface to be used
+           :return: The ordered map object list,
                    In case nothing found None is returned
         """
 
@@ -1340,7 +1339,7 @@
 
     def get_registered_maps_as_objects(self, where=None, order="start_time",
                                        dbif=None):
-        """!Return all or a subset of the registered maps as ordered object
+        """Return all or a subset of the registered maps as ordered object
            list for spatio-temporal topological operations that require the
            spatio-temporal extent only
 
@@ -1350,12 +1349,12 @@
            In case more map information are needed, use the select()
            method for each listed object.
 
-           @param where The SQL where statement to select a subset of
+           :param where: The SQL where statement to select a subset of
                          the registered maps without "WHERE"
-           @param order The SQL order statement to be used to order the
+           :param order: The SQL order statement to be used to order the
                          objects in the list without "ORDER BY"
-           @param dbif The database interface to be used
-           @return The ordered map object list,
+           :param dbif: The database interface to be used
+           :return: The ordered map object list,
                    In case nothing found None is returned
         """
 
@@ -1384,7 +1383,6 @@
 
         rows = self.get_registered_maps(columns, where, order, dbif)
 
-
         if rows is not None:
             for row in rows:
                 map = self.get_new_map_instance(row["id"])
@@ -1414,19 +1412,19 @@
 
     def get_registered_maps(self, columns=None, where=None, order=None,
                             dbif=None):
-        """!Return SQL rows of all registered maps.
+        """Return SQL rows of all registered maps.
 
            In case columns are not specified, each row includes all columns
            specified in the datatype specific view.
 
-           @param columns Columns to be selected as SQL compliant string
-           @param where The SQL where statement to select a subset
+           :param columns: Columns to be selected as SQL compliant string
+           :param where: The SQL where statement to select a subset
                         of the registered maps without "WHERE"
-           @param order The SQL order statement to be used to order the
+           :param order: The SQL order statement to be used to order the
                         objects in the list without "ORDER BY"
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
 
-           @return SQL rows of all registered maps,
+           :return: SQL rows of all registered maps,
                    In case nothing found None is returned
         """
 
@@ -1454,15 +1452,14 @@
                 sql += " AND (%s)" % (where.split(";")[0])
             if order is not None and order != "":
                 sql += " ORDER BY %s" % (order.split(";")[0])
-
             try:
-                dbif.cursor.execute(sql)
-                rows = dbif.cursor.fetchall()
+                dbif.execute(sql,  mapset=self.base.mapset)
+                rows = dbif.fetchall(mapset=self.base.mapset)
             except:
                 if connected:
                     dbif.close()
-                self.msgr.error(_("Unable to get map ids from register table <%s>")
-                           % (self.get_map_register()))
+                self.msgr.error(_("Unable to get map ids from register table "
+                                  "<%s>") % (self.get_map_register()))
                 raise
 
         if connected:
@@ -1472,72 +1469,72 @@
 
     @staticmethod
     def shift_map_list(maps, gran):
-        """!Temporally shift each map in the list with the provided granularity
+        """Temporally shift each map in the list with the provided granularity
 
            This method does not perform any temporal database operations.
 
-           @param maps A list of maps  with initialized temporal extent
-           @param gran The granularity to be used for shifting
-           @return The modified map list, None if nothing to shift or wrong
+           :param maps: A list of maps  with initialized temporal extent
+           :param gran: The granularity to be used for shifting
+           :return: The modified map list, None if nothing to shift or wrong
                    granularity
-           @code
 
-           >>> import grass.temporal as tgis
-           >>> maps = []
-           >>> for i in range(5):
-           ...   map = tgis.RasterDataset(None)
-           ...   if i%2 == 0:
-           ...       check = map.set_relative_time(i, i + 1, 'years')
-           ...   else:
-           ...       check = map.set_relative_time(i, None, 'years')
-           ...   maps.append(map)
-           >>> for map in maps:
-           ...   map.temporal_extent.print_info()
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 0
-            | End time:................... 1
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 1
-            | End time:................... None
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 2
-            | End time:................... 3
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 3
-            | End time:................... None
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 4
-            | End time:................... 5
-            | Relative time unit:......... years
-           >>> maps = tgis.AbstractSpaceTimeDataset.shift_map_list(maps, 5)
-           >>> for map in maps:
-           ...   map.temporal_extent.print_info()
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 5
-            | End time:................... 6
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 6
-            | End time:................... None
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 7
-            | End time:................... 8
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 8
-            | End time:................... None
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 9
-            | End time:................... 10
-            | Relative time unit:......... years
+           .. code-block:: python
 
-           @endcode
+               >>> import grass.temporal as tgis
+               >>> maps = []
+               >>> for i in range(5):
+               ...   map = tgis.RasterDataset(None)
+               ...   if i%2 == 0:
+               ...       check = map.set_relative_time(i, i + 1, 'years')
+               ...   else:
+               ...       check = map.set_relative_time(i, None, 'years')
+               ...   maps.append(map)
+               >>> for map in maps:
+               ...   map.temporal_extent.print_info()
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 0
+                | End time:................... 1
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 1
+                | End time:................... None
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 2
+                | End time:................... 3
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 3
+                | End time:................... None
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 4
+                | End time:................... 5
+                | Relative time unit:......... years
+               >>> maps = tgis.AbstractSpaceTimeDataset.shift_map_list(maps, 5)
+               >>> for map in maps:
+               ...   map.temporal_extent.print_info()
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 5
+                | End time:................... 6
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 6
+                | End time:................... None
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 7
+                | End time:................... 8
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 8
+                | End time:................... None
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 9
+                | End time:................... 10
+                | Relative time unit:......... years
+
         """
         if maps is None:
             return None
@@ -1562,18 +1559,21 @@
         return maps
 
     def shift(self, gran, dbif=None):
-        """!Temporally shift each registered map with the provided granularity
+        """Temporally shift each registered map with the provided granularity
 
-           @param gran The granularity to be used for shifting
-           @param dbif The database interface to be used
-           @return True something to shift, False if nothing to shift or wrong
+           :param gran: The granularity to be used for shifting
+           :param dbif: The database interface to be used
+           :return: True something to shift, False if nothing to shift or wrong
                    granularity
 
         """
-        if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to shift dataset <%(ds)s> of type %(type)s in the temporal database."
-            " The mapset of the dataset does not match the current mapset")%\
-            ({"ds":self.get_id()}, {"type":self.get_type()}))
+        if get_enable_mapset_check() is True and \
+           self.get_mapset() != get_current_mapset():
+            self.msgr.fatal(_("Unable to shift dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset "
+                              "of the dataset does not match the current "
+                              "mapset") % ({"ds": self.get_id()},
+                                           {"type": self.get_type()}))
 
         if not check_granularity_string(gran, self.get_temporal_type()):
             self.msgr.error(_("Wrong granularity format: %s" % (gran)))
@@ -1612,7 +1612,7 @@
 
     @staticmethod
     def snap_map_list(maps):
-        """!For each map in the list snap the end time to the start time of its
+        """For each map in the list snap the end time to the start time of its
            temporal nearest neighbor in the future.
 
            Maps with equal time stamps are not snapped.
@@ -1622,70 +1622,69 @@
 
            This method does not perform any temporal database operations.
 
-           @param maps A list of maps with initialized temporal extent
-           @return The modified map list, None nothing to shift or wrong
+           :param maps: A list of maps with initialized temporal extent
+           :return: The modified map list, None nothing to shift or wrong
                    granularity
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> import grass.temporal as tgis
-           >>> maps = []
-           >>> for i in range(5):
-           ...   map = tgis.RasterDataset(None)
-           ...   if i%2 == 0:
-           ...       check = map.set_relative_time(i, i + 1, 'years')
-           ...   else:
-           ...       check = map.set_relative_time(i, None, 'years')
-           ...   maps.append(map)
-           >>> for map in maps:
-           ...   map.temporal_extent.print_info()
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 0
-            | End time:................... 1
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 1
-            | End time:................... None
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 2
-            | End time:................... 3
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 3
-            | End time:................... None
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 4
-            | End time:................... 5
-            | Relative time unit:......... years
-           >>> maps = tgis.AbstractSpaceTimeDataset.snap_map_list(maps)
-           >>> for map in maps:
-           ...   map.temporal_extent.print_info()
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 0
-            | End time:................... 1
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 1
-            | End time:................... 2
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 2
-            | End time:................... 3
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 3
-            | End time:................... 4
-            | Relative time unit:......... years
-            +-------------------- Relative time -----------------------------------------+
-            | Start time:................. 4
-            | End time:................... 5
-            | Relative time unit:......... years
+               >>> import grass.temporal as tgis
+               >>> maps = []
+               >>> for i in range(5):
+               ...   map = tgis.RasterDataset(None)
+               ...   if i%2 == 0:
+               ...       check = map.set_relative_time(i, i + 1, 'years')
+               ...   else:
+               ...       check = map.set_relative_time(i, None, 'years')
+               ...   maps.append(map)
+               >>> for map in maps:
+               ...   map.temporal_extent.print_info()
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 0
+                | End time:................... 1
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 1
+                | End time:................... None
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 2
+                | End time:................... 3
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 3
+                | End time:................... None
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 4
+                | End time:................... 5
+                | Relative time unit:......... years
+               >>> maps = tgis.AbstractSpaceTimeDataset.snap_map_list(maps)
+               >>> for map in maps:
+               ...   map.temporal_extent.print_info()
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 0
+                | End time:................... 1
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 1
+                | End time:................... 2
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 2
+                | End time:................... 3
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 3
+                | End time:................... 4
+                | Relative time unit:......... years
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 4
+                | End time:................... 5
+                | Relative time unit:......... years
 
-           @endcode
         """
         if maps is None or len(maps) == 0:
             return None
@@ -1728,19 +1727,22 @@
         return maps
 
     def snap(self, dbif=None):
-        """!For each registered map snap the end time to the start time of
+        """For each registered map snap the end time to the start time of
            its temporal nearest neighbor in the future
 
            Maps with equal time stamps are not snapped
 
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
 
         """
 
-        if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to snap dataset <%(ds)s> of type %(type)s in the temporal database."
-            " The mapset of the dataset does not match the current mapset")%\
-            ({"ds":self.get_id()}, {"type":self.get_type()}))
+        if get_enable_mapset_check() is True and \
+           self.get_mapset() != get_current_mapset():
+            self.msgr.fatal(_("Unable to snap dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset "
+                              "of the dataset does not match the current "
+                              "mapset") % ({"ds": self.get_id()},
+                                           {"type": self.get_type()}))
 
         dbif, connected = init_dbif(dbif)
 
@@ -1768,8 +1770,8 @@
         # granularity if the end time is None
         if end is None:
             if self.is_time_absolute():
-                end =  increment_datetime_by_string(start,
-                                                    self.get_granularity())
+                end = increment_datetime_by_string(start,
+                                                   self.get_granularity())
             elif self.is_time_relative():
                 end = start + self.get_granularity()
 
@@ -1781,15 +1783,15 @@
             dbif.close()
 
     def _update_map_timestamps(self, maps, date_list, dbif):
-        """!Update the timestamps of maps with the start and end time
+        """Update the timestamps of maps with the start and end time
            stored in the date_list.
 
            The number of dates in the list must be equal to the number
            of maps.
 
-           @param maps A list of map objects
-           @param date_list A list with date tuples (start_time, end_time)
-           @param dbif The database interface to be used
+           :param maps: A list of map objects
+           :param date_list: A list with date tuples (start_time, end_time)
+           :param dbif: The database interface to be used
         """
 
         datatsets_to_modify = {}
@@ -1826,26 +1828,29 @@
                     ds.update_from_registered_maps(dbif)
 
     def rename(self, ident, dbif=None):
-        """!Rename the space time dataset
+        """Rename the space time dataset
 
            This method renames the space time dataset, the map register table
            and updates the entries in registered maps stds register.
 
            Renaming does not work with Postgresql yet.
 
-           @param ident The new identifier "name at mapset"
-           @param dbif The database interface to be used
+           :param ident: The new identifier "name at mapset"
+           :param dbif: The database interface to be used
         """
 
         if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to rename dataset <%(ds)s> of type %(type)s in the temporal database."
-            " The mapset of the dataset does not match the current mapset")%\
-            ({"ds":self.get_id()}, {"type":self.get_type()}))
+            self.msgr.fatal(_("Unable to rename dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset "
+                              "of the dataset does not match the current "
+                              "mapset") % ({"ds": self.get_id()},
+                                           {"type": self.get_type()}))
 
         dbif, connected = init_dbif(dbif)
 
-        if dbif.dbmi.__name__ != "sqlite3":
-            self.msgr.fatal(_("Renaming of space time datasets is not supported for PostgreSQL."))
+        if dbif.get_dbmi().__name__ != "sqlite3":
+            self.msgr.fatal(_("Renaming of space time datasets is not "
+                              "supported for PostgreSQL."))
 
         # SELECT all needed information from the database
         self.select(dbif)
@@ -1870,14 +1875,14 @@
         statement = self.update(dbif, execute=False, ident=old_ident)
 
         # We need to rename the raster register table
-        statement += "ALTER TABLE %s RENAME TO \"%s\";\n" % (old_map_register_table,
-                                                             new_map_register_table)
+        statement += "ALTER TABLE %s RENAME TO \"%s\";\n" % \
+                     (old_map_register_table, new_map_register_table)
 
         # We need to take care of the stds index in the sqlite3 database
-        if dbif.dbmi.__name__ == "sqlite3":
+        if dbif.get_dbmi().__name__ == "sqlite3":
             statement += "DROP INDEX %s_index;\n" % (old_map_register_table)
-            statement += "CREATE INDEX %s_index ON %s (id);"%(new_map_register_table,
-                                                              new_map_register_table)
+            statement += "CREATE INDEX %s_index ON %s (id);" % \
+                         (new_map_register_table, new_map_register_table)
 
         # We need to rename the space time dataset in the maps register table
         if maps:
@@ -1892,31 +1897,34 @@
             dbif.close()
 
     def delete(self, dbif=None, execute=True):
-        """!Delete a space time dataset from the temporal database
+        """Delete a space time dataset from the temporal database
 
            This method removes the space time dataset from the temporal
            database and drops its map register table
 
-           @param dbif The database interface to be used
-           @param execute If True the SQL DELETE and DROP table
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL DELETE and DROP table
                           statements will be executed.
                           If False the prepared SQL statements are returned
                           and must be executed by the caller.
 
-           @return The SQL statements if execute == False, else an empty string
+           :return: The SQL statements if execute == False, else an empty
+                    string
         """
         # First we need to check if maps are registered in this dataset and
         # unregister them
 
         self.msgr.verbose(_("Delete space time %s  dataset <%s> from temporal "
-                      "database") % \
-                    (self.get_new_map_instance(ident=None).get_type(),
-                     self.get_id()))
+                            "database") % (self.get_new_map_instance(ident=None).get_type(),
+                                           self.get_id()))
 
-        if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to delete dataset <%(ds)s> of type %(type)s from the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+        if get_enable_mapset_check() is True and \
+           self.get_mapset() != get_current_mapset():
+            self.msgr.fatal(_("Unable to delete dataset <%(ds)s> of type "
+                              "%(type)s from the temporal database. The mapset"
+                              " of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
         statement = ""
         dbif, connected = init_dbif(dbif)
@@ -1956,11 +1964,11 @@
         return statement
 
     def is_map_registered(self, map_id, dbif=None):
-        """!Check if a map is registered in the space time dataset
+        """Check if a map is registered in the space time dataset
 
-           @param map_id The map id
-           @param dbif The database interface to be used
-           @return True if success, False otherwise
+           :param map_id: The map id
+           :param dbif: The database interface to be used
+           :return: True if success, False otherwise
         """
         stds_register_table = self.get_map_register()
 
@@ -1970,15 +1978,15 @@
 
         # Check if map is already registered
         if stds_register_table is not None:
-            if dbif.dbmi.paramstyle == "qmark":
+            if dbif.get_dbmi().paramstyle == "qmark":
                 sql = "SELECT id FROM " + \
                     stds_register_table + " WHERE id = (?)"
             else:
                 sql = "SELECT id FROM " + \
                     stds_register_table + " WHERE id = (%s)"
             try:
-                dbif.cursor.execute(sql, (map_id,))
-                row = dbif.cursor.fetchone()
+                dbif.execute(sql, (map_id,),  mapset=self.base.mapset)
+                row = dbif.fetchone(mapset=self.base.mapset)
             except:
                 self.msgr.warning(_("Error in register table request"))
                 raise
@@ -1986,13 +1994,13 @@
             if row is not None and row[0] == map_id:
                 is_registered = True
 
-        if connected == True:
+        if connected is True:
             dbif.close()
 
         return is_registered
 
     def register_map(self, map, dbif=None):
-        """!Register a map in the space time dataset.
+        """Register a map in the space time dataset.
 
             This method takes care of the registration of a map
             in a space time dataset.
@@ -2002,42 +2010,48 @@
 
             This method raises a FatalError exception in case of a fatal error
 
-           @param map The AbstractMapDataset object that should be registered
-           @param dbif The database interface to be used
-           @return True if success, False otherwise
+           :param map: The AbstractMapDataset object that should be registered
+           :param dbif: The database interface to be used
+           :return: True if success, False otherwise
         """
 
-        if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to register map in dataset <%(ds)s> of type %(type)s."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+        if get_enable_mapset_check() is True and \
+           self.get_mapset() != get_current_mapset():
+            self.msgr.fatal(_("Unable to register map in dataset <%(ds)s> of "
+                              "type %(type)s. The mapset of the dataset does "
+                              "not match the current mapset") %
+                            {"ds": self.get_id(), "type": self.get_type()})
 
         dbif, connected = init_dbif(dbif)
 
-        if map.is_in_db(dbif) == False:
+        if map.is_in_db(dbif) is False:
             dbif.close()
-            self.msgr.fatal(_("Only a map that was inserted in the temporal database"
-                              " can be registered in a space time dataset"))
+            self.msgr.fatal(_("Only a map that was inserted in the temporal "
+                              "database can be registered in a space time "
+                              "dataset"))
 
         if map.get_layer():
             self.msgr.debug(1, "Register %s map <%s> with layer %s in space "
-                           "time %s dataset <%s>" % (map.get_type(),
-                                                     map.get_map_id(),
-                                                     map.get_layer(),
-                                                     map.get_type(),
-                                                     self.get_id()))
+                               "time %s dataset <%s>" % (map.get_type(),
+                                                         map.get_map_id(),
+                                                         map.get_layer(),
+                                                         map.get_type(),
+                                                         self.get_id()))
         else:
             self.msgr.debug(1, "Register %s map <%s> in space time %s "
-                           "dataset <%s>" % (map.get_type(), map.get_map_id(),
-                                              map.get_type(), self.get_id()))
+                               "dataset <%s>" % (map.get_type(),
+                                                 map.get_map_id(),
+                                                 map.get_type(),
+                                                 self.get_id()))
 
         # First select all data from the database
         map.select(dbif)
 
         if not map.check_for_correct_time():
             if map.get_layer():
-                self.msgr.fatal(_("Map <%(id)s> with layer %(l)s has invalid time")
-                           % {'id': map.get_map_id(), 'l': map.get_layer()})
+                self.msgr.fatal(_("Map <%(id)s> with layer %(l)s has invalid "
+                                  "time") % {'id': map.get_map_id(),
+                                             'l': map.get_layer()})
             else:
                 self.msgr.fatal(_("Map <%s> has invalid time") % (map.get_map_id()))
 
@@ -2057,28 +2071,31 @@
         # Check temporal types
         if stds_ttype != map_ttype:
             if map.get_layer():
-                self.msgr.fatal(_("Temporal type of space time dataset <%(id)s> and"
-                             " map <%(map)s> with layer %(l)s are different") \
-                             % {'id': self.get_id(), 'map': map.get_map_id(),
-                                'l': map.get_layer()})
+                self.msgr.fatal(_("Temporal type of space time dataset "
+                                  "<%(id)s> and map <%(map)s> with layer %(l)s"
+                                  " are different") % {'id': self.get_id(),
+                                                       'map': map.get_map_id(),
+                                                       'l': map.get_layer()})
             else:
-                self.msgr.fatal(_("Temporal type of space time dataset <%(id)s> and"
-                             " map <%(map)s> are different") % {
-                             'id': self.get_id(), 'map': map.get_map_id()})
+                self.msgr.fatal(_("Temporal type of space time dataset "
+                                  "<%(id)s> and map <%(map)s> are different")
+                                % {'id': self.get_id(),
+                                   'map': map.get_map_id()})
 
         # In case no map has been registered yet, set the
         # relative time unit from the first map
-        if (self.metadata.get_number_of_maps() is None or \
+        if (self.metadata.get_number_of_maps() is None or
             self.metadata.get_number_of_maps() == 0) and \
-            self.map_counter == 0 and self.is_time_relative():
+           self.map_counter == 0 and self.is_time_relative():
 
             self.set_relative_time_unit(map_rel_time_unit)
             statement += self.relative_time.get_update_all_statement_mogrified(
                 dbif)
 
             self.msgr.debug(1, _("Set temporal unit for space time %s dataset "
-                           "<%s> to %s") % (map.get_type(), self.get_id(),
-                                            map_rel_time_unit))
+                                 "<%s> to %s") % (map.get_type(),
+                                                  self.get_id(),
+                                                  map_rel_time_unit))
 
         stds_rel_time_unit = self.get_relative_time_unit()
 
@@ -2086,14 +2103,14 @@
         if self.is_time_relative() and (stds_rel_time_unit != map_rel_time_unit):
             if map.get_layer():
                 self.msgr.fatal(_("Relative time units of space time dataset "
-                             "<%(id)s> and map <%(map)s> with layer %(l)s are"
-                             " different") % {'id': self.get_id(),
-                                              'map': map.get_map_id(),
-                                              'l': map.get_layer()})
+                                  "<%(id)s> and map <%(map)s> with layer %(l)s"
+                                  " are different") % {'id': self.get_id(),
+                                                       'map': map.get_map_id(),
+                                                       'l': map.get_layer()})
             else:
                 self.msgr.fatal(_("Relative time units of space time dataset "
-                             "<%(id)s> and map <%(map)s> are different") % \
-                             {'id': self.get_id(), 'map': map.get_map_id()})
+                                  "<%(id)s> and map <%(map)s> are different") %
+                                {'id': self.get_id(), 'map': map.get_map_id()})
 
         if get_enable_mapset_check() is True and stds_mapset != map_mapset:
             dbif.close()
@@ -2102,20 +2119,20 @@
         # Check if map is already registered
         if self.is_map_registered(map_id, dbif=dbif):
             if map.get_layer() is not None:
-                self.msgr.warning(_("Map <%(map)s> with layer %(l)s is already "
-                                "registered.") % {'map': map.get_map_id(),
-                                                    'l': map.get_layer()})
+                self.msgr.warning(_("Map <%(map)s> with layer %(l)s is already"
+                                    " registered.") % {'map': map.get_map_id(),
+                                                       'l': map.get_layer()})
             else:
-                self.msgr.warning(_("Map <%s> is already registered.") % (
-                                map.get_map_id()))
+                self.msgr.warning(_("Map <%s> is already registered.") %
+                                   (map.get_map_id()))
             return False
 
         # Register the stds in the map stds register table column
         statement += map.add_stds_to_register(stds_id=self.base.get_id(),
-                                                 dbif=dbif, execute=False)
+                                              dbif=dbif, execute=False)
 
         # Now put the raster name in the stds map register table
-        if dbif.dbmi.paramstyle == "qmark":
+        if dbif.get_dbmi().paramstyle == "qmark":
             sql = "INSERT INTO " + stds_register_table + \
                 " (id) " + "VALUES (?);\n"
         else:
@@ -2136,26 +2153,29 @@
         return True
 
     def unregister_map(self, map, dbif=None, execute=True):
-        """!Unregister a map from the space time dataset.
+        """Unregister a map from the space time dataset.
 
            This method takes care of the un-registration of a map
            from a space time dataset.
 
-           @param map The map object to unregister
-           @param dbif The database interface to be used
-           @param execute If True the SQL DELETE and DROP table
+           :param map: The map object to unregister
+           :param dbif: The database interface to be used
+           :param execute: If True the SQL DELETE and DROP table
                            statements will be executed.
                            If False the prepared SQL statements are
                            returned and must be executed by the caller.
 
-           @return The SQL statements if execute == False, else an empty
+           :return: The SQL statements if execute == False, else an empty
                    string, None in case of a failure
         """
 
-        if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to unregister map from dataset <%(ds)s> of type %(type)s in the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+        if get_enable_mapset_check() is True and \
+           self.get_mapset() != get_current_mapset():
+            self.msgr.fatal(_("Unable to unregister map from dataset <%(ds)s>"
+                              " of type %(type)s in the temporal database."
+                              " The mapset of the dataset does not match the"
+                              " current mapset") % {"ds": self.get_id(),
+                                                    "type": self.get_type()})
 
         statement = ""
 
@@ -2165,33 +2185,35 @@
         if self.is_map_registered(map.get_id(), dbif) is False:
             if map.get_layer() is not None:
                 self.msgr.warning(_("Map <%(map)s> with layer %(l)s is not "
-                                "registered in space time dataset "
-                                "<%(base)s>") % {'map': map.get_map_id(),
-                                'l': map.get_layer(), 'base': self.base.get_id()})
+                                    "registered in space time dataset "
+                                    "<%(base)s>") % {'map': map.get_map_id(),
+                                                     'l': map.get_layer(),
+                                                     'base': self.base.get_id()})
             else:
                 self.msgr.warning(_("Map <%(map)s> is not registered in space "
-                                "time dataset <%(base)s>") % {'map': map.get_map_id(),
-                                'base': self.base.get_id()})
-            if connected == True:
+                                    "time dataset <%(base)s>") %
+                                  {'map': map.get_map_id(),
+                                   'base': self.base.get_id()})
+            if connected is True:
                 dbif.close()
             return ""
 
         # Remove the space time dataset from the dataset register
-        # We need to execute the statement here, otherwise the space time dataset will not be
-        # removed correctly
+        # We need to execute the statement here, otherwise the space time
+        # dataset will not be removed correctly
         map.remove_stds_from_register(self.base.get_id(),
-                                                      dbif=dbif, execute=True)
+                                      dbif=dbif, execute=True)
 
         # Remove the map from the space time dataset register
         stds_register_table = self.get_map_register()
         if stds_register_table is not None:
-            if dbif.dbmi.paramstyle == "qmark":
+            if dbif.get_dbmi().paramstyle == "qmark":
                 sql = "DELETE FROM " + stds_register_table + " WHERE id = ?;\n"
             else:
                 sql = "DELETE FROM " + \
                     stds_register_table + " WHERE id = %s;\n"
 
-            statement += dbif.mogrify_sql_statement((sql, ( map.get_id(),)))
+            statement += dbif.mogrify_sql_statement((sql, (map.get_id(), )))
 
         if execute:
             dbif.execute_transaction(statement)
@@ -2206,9 +2228,10 @@
         return statement
 
     def update_from_registered_maps(self, dbif=None):
-        """!This methods updates the modification time, the spatial and temporal extent as well as
-           type specific metadata. It should always been called after maps
-           are registered or unregistered/deleted from the space time dataset.
+        """This methods updates the modification time, the spatial and
+           temporal extent as well as type specific metadata. It should always
+           been called after maps are registered or unregistered/deleted from
+           the space time dataset.
 
            The update of the temporal extent checks if the end time is set
            correctly.
@@ -2217,16 +2240,19 @@
            will be used. If the end time is earlier than the maximum start
            time, it will be replaced by the maximum start time.
 
-           @param dbif The database interface to be used
+           :param dbif: The database interface to be used
         """
 
-        if get_enable_mapset_check() is True and self.get_mapset() != get_current_mapset():
-            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type %(type)s in the temporal database."
-                         " The mapset of the dataset does not match the current mapset")%\
-                         {"ds":self.get_id(), "type":self.get_type()})
+        if get_enable_mapset_check() is True and \
+           self.get_mapset() != get_current_mapset():
+            self.msgr.fatal(_("Unable to update dataset <%(ds)s> of type "
+                              "%(type)s in the temporal database. The mapset"
+                              " of the dataset does not match the current "
+                              "mapset") % {"ds": self.get_id(),
+                                           "type": self.get_type()})
 
-        self.msgr.verbose(_("Update metadata, spatial and temporal extent from "
-                       "all registered maps of <%s>") % (self.get_id()))
+        self.msgr.verbose(_("Update metadata, spatial and temporal extent from"
+                            " all registered maps of <%s>") % (self.get_id()))
 
         # Nothing to do if the map register is not present
         if not self.get_map_register():
@@ -2244,7 +2270,7 @@
         sql_path = get_sql_template_path()
         stds_register_table = self.get_map_register()
 
-        #We create a transaction
+        # We create a transaction
         sql_script = ""
 
         # Update the spatial and temporal extent from registered maps
@@ -2263,7 +2289,9 @@
 
         # Update type specific metadata
         sql = open(os.path.join(sql_path, "update_" +
-            self.get_type() + "_metadata_template.sql"), 'r').read()
+                                          self.get_type() +
+                                          "_metadata_template.sql"),
+                   'r').read()
         sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table)
         sql = sql.replace("SPACETIME_ID", self.base.get_id())
 
@@ -2292,21 +2320,23 @@
                         (SELECT id FROM SPACETIME_REGISTER_TABLE);"""
                 sql = sql.replace("GRASS_MAP", self.get_new_map_instance(
                     None).get_type())
-                sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table)
+                sql = sql.replace("SPACETIME_REGISTER_TABLE",
+                                  stds_register_table)
             else:
                 sql = """SELECT max(start_time) FROM GRASS_MAP_relative_time
                          WHERE GRASS_MAP_relative_time.id IN
                         (SELECT id FROM SPACETIME_REGISTER_TABLE);"""
                 sql = sql.replace("GRASS_MAP", self.get_new_map_instance(
                     None).get_type())
-                sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table)
+                sql = sql.replace("SPACETIME_REGISTER_TABLE",
+                                  stds_register_table)
 
-            dbif.cursor.execute(sql)
-            row = dbif.cursor.fetchone()
+            dbif.execute(sql,  mapset=self.base.mapset)
+            row = dbif.fetchone(mapset=self.base.mapset)
 
             if row is not None:
                 # This seems to be a bug in sqlite3 Python driver
-                if dbif.dbmi.__name__ == "sqlite3":
+                if dbif.get_dbmi().__name__ == "sqlite3":
                     tstring = row[0]
                     # Convert the unicode string into the datetime format
                     if self.is_time_absolute():
@@ -2335,7 +2365,8 @@
                ) WHERE id = 'SPACETIME_ID';"""
                 sql = sql.replace("GRASS_MAP", self.get_new_map_instance(
                     None).get_type())
-                sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table)
+                sql = sql.replace("SPACETIME_REGISTER_TABLE",
+                                  stds_register_table)
                 sql = sql.replace("SPACETIME_ID", self.base.get_id())
                 sql = sql.replace("STDS", self.get_type())
             elif self.is_time_relative():
@@ -2346,7 +2377,8 @@
                ) WHERE id = 'SPACETIME_ID';"""
                 sql = sql.replace("GRASS_MAP", self.get_new_map_instance(
                     None).get_type())
-                sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table)
+                sql = sql.replace("SPACETIME_REGISTER_TABLE",
+                                  stds_register_table)
                 sql = sql.replace("SPACETIME_ID", self.base.get_id())
                 sql = sql.replace("STDS", self.get_type())
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/aggregation.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,44 +1,39 @@
-"""!@package grass.temporal
+"""
+Aggregation methods for space time raster datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in Python scripts.
-
 Usage:
 
- at code
-import grass.temporal as tgis
+.. code-block:: python
 
-tgis.aggregate_raster_maps(dataset, mapset, inputs, base, start, end,
-    count, method, register_null, dbif)
+    import grass.temporal as tgis
 
-...
- at endcode
+    tgis.aggregate_raster_maps(dataset, mapset, inputs, base, start, end, count, method, register_null, dbif)
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:author: Soeren Gebbert
 """
 
 from space_time_datasets import *
+import grass.script as gscript
 from grass.exceptions import CalledModuleError
 
 ###############################################################################
 
 
 def collect_map_names(sp, dbif, start, end, sampling):
-    """!Gather all maps from dataset using a specific sample method
+    """Gather all maps from dataset using a specific sample method
 
-       @param sp The space time raster dataset to select aps from
-       @param dbif The temporal database interface to use
-       @param start The start time of the sample interval, may be relative or
+       :param sp: The space time raster dataset to select aps from
+       :param dbif: The temporal database interface to use
+       :param start: The start time of the sample interval, may be relative or
               absolute
-       @param end The end time of the sample interval, may be relative or
+       :param end: The end time of the sample interval, may be relative or
               absolute
-       @param sampling The sampling methods to use
+       :param sampling: The sampling methods to use
     """
 
     use_start = False
@@ -104,21 +99,21 @@
 
 def aggregate_raster_maps(inputs, base, start, end, count, method,
                           register_null, dbif,  offset=0):
-    """!Aggregate a list of raster input maps with r.series
+    """Aggregate a list of raster input maps with r.series
 
-       @param inputs The names of the raster maps to be aggregated
-       @param base The basename of the new created raster maps
-       @param start The start time of the sample interval, may be relative or
+       :param inputs: The names of the raster maps to be aggregated
+       :param base: The basename of the new created raster maps
+       :param start: The start time of the sample interval, may be relative or
                     absolute
-       @param end The end time of the sample interval, may be relative or
+       :param end: The end time of the sample interval, may be relative or
                   absolute
-       @param count The number to be attached to the basename of the new
+       :param count: The number to be attached to the basename of the new
                     created raster map
-       @param method The aggreation method to be used by r.series
-       @param register_null If true null maps will be registered in the space
+       :param method: The aggreation method to be used by r.series
+       :param register_null: If true null maps will be registered in the space
                             time raster dataset, if false not
-       @param dbif The temporal database interface to use
-       @param offset Offset to be added to the map counter to create the map ids
+       :param dbif: The temporal database interface to use
+       :param offset: Offset to be added to the map counter to create the map ids
     """
 
     msgr = get_tgis_message_interface()
@@ -132,20 +127,21 @@
 
     # Check if new map is in the temporal database
     if new_map.is_in_db(dbif):
-        if core.overwrite() == True:
+        if gscript.overwrite() is True:
             # Remove the existing temporal database entry
             new_map.delete(dbif)
             new_map = RasterDataset(map_id)
         else:
-            msgr.error(_("Raster map <%s> is already in temporal database, " \
-                         "use overwrite flag to overwrite"))
+            msgr.error(_("Raster map <%(name)s> is already in temporal "
+                         "database, use overwrite flag to overwrite" %
+                       ({"name": new_map.get_name()})))
             return
 
     msgr.verbose(_("Computing aggregation of maps between %(st)s - %(end)s" % {
                    'st': str(start), 'end': str(end)}))
 
     # Create the r.series input file
-    filename = core.tempfile(True)
+    filename = gscript.tempfile(True)
     file = open(filename, 'w')
 
     for name in inputs:
@@ -153,7 +149,6 @@
         file.write(string)
 
     file.close()
-    
     # Run r.series
     try:
         if len(inputs) > 1000:
@@ -173,9 +168,152 @@
     new_map.load()
 
     # In case of a null map continue, do not register null maps
-    if new_map.metadata.get_min() is None and new_map.metadata.get_max() is None:
+    if new_map.metadata.get_min() is None and \
+       new_map.metadata.get_max() is None:
         if not register_null:
-            core.run_command("g.remove", type="rast", name=output, flags="f")
+            gscript.run_command("g.remove", flags='f', type='rast',
+                                name=output)
             return None
 
     return new_map
+
+##############################################################################
+
+
+def aggregate_by_topology(granularity_list, granularity, map_list, topo_list,
+                          basename, time_suffix, offset=0, method="average",
+                          nprocs=1, spatial=None, dbif=None, overwrite=False):
+    """Aggregate a list of raster input maps with r.series
+
+       :param granularity_list: A list of AbstractMapDataset objects.
+                                The temporal extents of the objects are used
+                                to build the spatio-temporal topology with the
+                                map list objects
+       :param granularity: The granularity of the granularity list
+       :param map_list: A list of RasterDataset objects that contain the raster
+                        maps that should be aggregated
+       :param topo_list: A list of strings of topological relations that are
+                         used to select the raster maps for aggregation
+       :param basename: The basename of the new generated raster maps
+       :param time_suffix: Use the granularity truncated start time of the
+                           actual granule to create the suffix for the basename
+       :param offset: Use a numerical offset for suffix generation
+                      (overwritten by time_suffix)
+       :param method: The aggregation method of r.series (average,min,max, ...)
+       :param nprocs: The number of processes used for parallel computation
+       :param spatial: This indicates if the spatial topology is created as
+                       well: spatial can be None (no spatial topology), "2D"
+                       using west, east, south, north or "3D" using west,
+                       east, south, north, bottom, top
+       :param dbif: The database interface to be used
+       :param overwrite: Overwrite existing raster maps
+       :return: A list of RasterDataset objects that contain the new map names
+                and the temporal extent for map registration
+    """
+    import grass.pygrass.modules as pymod
+    import copy
+
+    msgr = get_tgis_message_interface()
+
+    dbif, connected = init_dbif(dbif)
+
+    topo_builder = SpatioTemporalTopologyBuilder()
+    topo_builder.build(mapsA=granularity_list, mapsB=map_list, spatial=spatial)
+
+    # The module queue for parallel execution
+    process_queue = pymod.ParallelModuleQueue(int(nprocs))
+
+    # Dummy process object that will be deep copied
+    # and be put into the process queue
+    r_series = pymod.Module("r.series", output="spam", method=[method],
+                            overwrite=overwrite, quiet=True, run_=False,
+                            finish_=False)
+    g_copy = pymod.Module("g.copy", rast=['spam', 'spamspam'],
+                          quiet=True, run_=False, finish_=False)
+    output_list = []
+    count = 0
+
+    for granule in granularity_list:
+        msgr.percent(count, len(granularity_list), 1)
+        count += 1
+
+        aggregation_list = []
+
+        if "equal" in topo_list and granule.equal:
+            for map_layer in granule.equal:
+                aggregation_list.append(map_layer.get_name())
+        if "contains" in topo_list and granule.contains:
+            for map_layer in granule.contains:
+                aggregation_list.append(map_layer.get_name())
+        if "during" in topo_list and granule.during:
+            for map_layer in granule.during:
+                aggregation_list.append(map_layer.get_name())
+        if "starts" in topo_list and granule.starts:
+            for map_layer in granule.starts:
+                aggregation_list.append(map_layer.get_name())
+        if "started" in topo_list and granule.started:
+            for map_layer in granule.started:
+                aggregation_list.append(map_layer.get_name())
+        if "finishes" in topo_list and granule.finishes:
+            for map_layer in granule.finishes:
+                aggregation_list.append(map_layer.get_name())
+        if "finished" in topo_list and granule.finished:
+            for map_layer in granule.finished:
+                aggregation_list.append(map_layer.get_name())
+        if "overlaps" in topo_list and granule.overlaps:
+            for map_layer in granule.overlaps:
+                aggregation_list.append(map_layer.get_name())
+        if "overlapped" in topo_list and granule.overlapped:
+            for map_layer in granule.overlapped:
+                aggregation_list.append(map_layer.get_name())
+
+        if aggregation_list:
+            msgr.verbose(_("Aggregating %(len)i raster maps from %(start)s to"
+                           " %(end)s")  %({"len": len(aggregation_list),
+                           "start": str(granule.temporal_extent.get_start_time()),
+                           "end": str(granule.temporal_extent.get_end_time())}))
+
+            if granule.is_time_absolute() is True and time_suffix is True:
+                suffix = create_suffix_from_datetime(granule.temporal_extent.get_start_time(),
+                                                     granularity)
+            else:
+                suffix = gscript.get_num_suffix(count + int(offset),
+                                                len(granularity_list) + int(offset))
+            output_name = "%s_%s" % (basename, suffix)
+
+            map_layer = RasterDataset("%s@%s" % (output_name,
+                                                 get_current_mapset()))
+            map_layer.set_temporal_extent(granule.get_temporal_extent())
+
+            if map_layer.map_exists() is True and overwrite is False:
+                msgr.fatal(_("Unable to perform aggregation. Output raster "
+                             "map <%(name)s> exists and overwrite flag was "
+                             "not set" % ({"name": output_name})))
+
+            output_list.append(map_layer)
+
+            if len(aggregation_list) > 1:
+                # Create the r.series input file
+                filename = gscript.tempfile(True)
+                file = open(filename, 'w')
+                for name in aggregation_list:
+                    string = "%s\n" % (name)
+                    file.write(string)
+                file.close()
+
+                mod = copy.deepcopy(r_series)
+                mod(file=filename, output=output_name)
+                if len(aggregation_list) > 1000:
+                    mod(flags="z")
+                process_queue.put(mod)
+            else:
+                mod = copy.deepcopy(g_copy)
+                mod(rast=[aggregation_list[0],  output_name])
+                process_queue.put(mod)
+
+    if connected:
+        dbif.close()
+
+    msgr.percent(1, 1, 1)
+
+    return output_list

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/base.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/base.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/base.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,81 +1,74 @@
-"""!@package grass.temporal
-
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS base classes to be used in other
-Python temporal gis packages.
-
+"""
 This packages includes all base classes to store basic information
 like id, name, mapset creation and modification time as well as sql
 serialization and de-serialization and the sql database interface.
 
 Usage:
 
- at code
+.. code-block:: python
 
->>> import grass.temporal as tgis
->>> tgis.init()
->>> rbase = tgis.RasterBase(ident="soil at PERMANENT")
->>> vbase = tgis.VectorBase(ident="soil:1 at PERMANENT")
->>> r3base = tgis.Raster3DBase(ident="soil at PERMANENT")
->>> strdsbase = tgis.STRDSBase(ident="soil at PERMANENT")
->>> stvdsbase = tgis.STVDSBase(ident="soil at PERMANENT")
->>> str3dsbase = tgis.STR3DSBase(ident="soil at PERMANENT")
+    >>> import grass.temporal as tgis
+    >>> tgis.init()
+    >>> rbase = tgis.RasterBase(ident="soil at PERMANENT")
+    >>> vbase = tgis.VectorBase(ident="soil:1 at PERMANENT")
+    >>> r3base = tgis.Raster3DBase(ident="soil at PERMANENT")
+    >>> strdsbase = tgis.STRDSBase(ident="soil at PERMANENT")
+    >>> stvdsbase = tgis.STVDSBase(ident="soil at PERMANENT")
+    >>> str3dsbase = tgis.STR3DSBase(ident="soil at PERMANENT")
 
- at endcode
 
 (C) 2011-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:author: Soeren Gebbert
 """
 
-from datetime import datetime, date, time, timedelta
+from datetime import datetime
 from core import *
 
 ###############################################################################
 
+
 class DictSQLSerializer(object):
     def __init__(self):
         self.D = {}
         self.dbmi_paramstyle = get_tgis_dbmi_paramstyle()
 
     def serialize(self, type, table, where=None):
-        """!Convert the internal dictionary into a string of semicolon
+        """Convert the internal dictionary into a string of semicolon
             separated SQL statements The keys are the column names and
             the values are the row entries
 
             Usage:
 
-            \code
-            >>> init()
-            >>> t = DictSQLSerializer()
-            >>> t.D["id"] = "soil at PERMANENT"
-            >>> t.D["name"] = "soil"
-            >>> t.D["mapset"] = "PERMANENT"
-            >>> t.D["creator"] = "soeren"
-            >>> t.D["creation_time"] = datetime(2001,1,1)
-            >>> t.D["modification_time"] = datetime(2001,1,1)
-            >>> t.serialize(type="SELECT", table="raster_base")
-            ('SELECT  name  , creator  , creation_time  , modification_time  , mapset  , id  FROM raster_base ;\\n', ())
-            >>> t.serialize(type="INSERT", table="raster_base")
-            ('INSERT INTO raster_base ( name  ,creator  ,creation_time  ,modification_time  ,mapset  ,id ) VALUES (? ,? ,? ,? ,? ,?) ;\\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil at PERMANENT'))
-            >>> t.serialize(type="UPDATE", table="raster_base")
-            ('UPDATE raster_base SET  name = ?  ,creator = ?  ,creation_time = ?  ,modification_time = ?  ,mapset = ?  ,id = ? ;\\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil at PERMANENT'))
-            >>> t.serialize(type="UPDATE ALL", table="raster_base")
-            ('UPDATE raster_base SET  name = ?  ,creator = ?  ,creation_time = ?  ,modification_time = ?  ,mapset = ?  ,id = ? ;\\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil at PERMANENT'))
+            .. code-block:: python
 
-            @param type must be SELECT. INSERT, UPDATE
-            @param table The name of the table to select, insert or update
-            @param where The optional where statement
-            @return a tuple containing the SQL string and the arguments
+                >>> init()
+                >>> t = DictSQLSerializer()
+                >>> t.D["id"] = "soil at PERMANENT"
+                >>> t.D["name"] = "soil"
+                >>> t.D["mapset"] = "PERMANENT"
+                >>> t.D["creator"] = "soeren"
+                >>> t.D["creation_time"] = datetime(2001,1,1)
+                >>> t.D["modification_time"] = datetime(2001,1,1)
+                >>> t.serialize(type="SELECT", table="raster_base")
+                ('SELECT  name  , creator  , creation_time  , modification_time  , mapset  , id  FROM raster_base ;\\n', ())
+                >>> t.serialize(type="INSERT", table="raster_base")
+                ('INSERT INTO raster_base ( name  ,creator  ,creation_time  ,modification_time  ,mapset  ,id ) VALUES (? ,? ,? ,? ,? ,?) ;\\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil at PERMANENT'))
+                >>> t.serialize(type="UPDATE", table="raster_base")
+                ('UPDATE raster_base SET  name = ?  ,creator = ?  ,creation_time = ?  ,modification_time = ?  ,mapset = ?  ,id = ? ;\\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil at PERMANENT'))
+                >>> t.serialize(type="UPDATE ALL", table="raster_base")
+                ('UPDATE raster_base SET  name = ?  ,creator = ?  ,creation_time = ?  ,modification_time = ?  ,mapset = ?  ,id = ? ;\\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil at PERMANENT'))
 
-            \endcode
+                :param type: must be SELECT. INSERT, UPDATE
+                :param table: The name of the table to select, insert or update
+                :param where: The optional where statement
+                :return: a tuple containing the SQL string and the arguments
+
         """
 
-
         sql = ""
         args = []
 
@@ -177,33 +170,35 @@
         return sql, tuple(args)
 
     def deserialize(self, row):
-        """!Convert the content of the dbmi dictionary like row into the
+        """Convert the content of the dbmi dictionary like row into the
            internal dictionary
 
-           @param row The dictionary like row to store in the internal dict
+           :param row: The dictionary like row to store in the internal dict
         """
         self.D = {}
         for key in row.keys():
             self.D[key] = row[key]
 
     def clear(self):
-        """!Initialize the internal storage"""
+        """Initialize the internal storage"""
         self.D = {}
 
     def print_self(self):
-        """!Print the content of the internal dictionary to stdout
+        """Print the content of the internal dictionary to stdout
         """
         print self.D
 
 ###############################################################################
 
+
 class SQLDatabaseInterface(DictSQLSerializer):
-    """!This class represents the SQL database interface
+    """This class represents the SQL database interface
 
        Functions to insert, select and update the internal
        structure of this class in the temporal database are implemented.
        This is the base class for raster, raster3d, vector and
        space time datasets data management classes:
+
        - Identification information (base)
        - Spatial extent
        - Temporal extent
@@ -211,42 +206,42 @@
 
        Usage:
 
-       \code
+       .. code-block:: python
 
-        >>> init()
-        >>> t = SQLDatabaseInterface("raster", "soil at PERMANENT")
-        >>> t.D["name"] = "soil"
-        >>> t.D["mapset"] = "PERMANENT"
-        >>> t.D["creator"] = "soeren"
-        >>> t.D["creation_time"] = datetime(2001,1,1)
-        >>> t.get_delete_statement()
-        "DELETE FROM raster WHERE id = 'soil at PERMANENT';\\n"
-        >>> t.get_is_in_db_statement()
-        "SELECT id FROM raster WHERE id = 'soil at PERMANENT';\\n"
-        >>> t.get_select_statement()
-        ("SELECT  creation_time  , mapset  , name  , creator  FROM raster WHERE id = 'soil at PERMANENT';\\n", ())
-        >>> t.get_select_statement_mogrified()
-        "SELECT  creation_time  , mapset  , name  , creator  FROM raster WHERE id = 'soil at PERMANENT';\\n"
-        >>> t.get_insert_statement()
-        ('INSERT INTO raster ( creation_time  ,mapset  ,name  ,creator ) VALUES (? ,? ,? ,?) ;\\n', (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
-        >>> t.get_insert_statement_mogrified()
-        "INSERT INTO raster ( creation_time  ,mapset  ,name  ,creator ) VALUES ('2001-01-01 00:00:00' ,'PERMANENT' ,'soil' ,'soeren') ;\\n"
-        >>> t.get_update_statement()
-        ("UPDATE raster SET  creation_time = ?  ,mapset = ?  ,name = ?  ,creator = ? WHERE id = 'soil at PERMANENT';\\n", (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
-        >>> t.get_update_statement_mogrified()
-        "UPDATE raster SET  creation_time = '2001-01-01 00:00:00'  ,mapset = 'PERMANENT'  ,name = 'soil'  ,creator = 'soeren' WHERE id = 'soil at PERMANENT';\\n"
-        >>> t.get_update_all_statement()
-        ("UPDATE raster SET  creation_time = ?  ,mapset = ?  ,name = ?  ,creator = ? WHERE id = 'soil at PERMANENT';\\n", (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
-        >>> t.get_update_all_statement_mogrified()
-        "UPDATE raster SET  creation_time = '2001-01-01 00:00:00'  ,mapset = 'PERMANENT'  ,name = 'soil'  ,creator = 'soeren' WHERE id = 'soil at PERMANENT';\\n"
+            >>> init()
+            >>> t = SQLDatabaseInterface("raster", "soil at PERMANENT")
+            >>> t.mapset = get_current_mapset()
+            >>> t.D["name"] = "soil"
+            >>> t.D["mapset"] = "PERMANENT"
+            >>> t.D["creator"] = "soeren"
+            >>> t.D["creation_time"] = datetime(2001,1,1)
+            >>> t.get_delete_statement()
+            "DELETE FROM raster WHERE id = 'soil at PERMANENT';\\n"
+            >>> t.get_is_in_db_statement()
+            "SELECT id FROM raster WHERE id = 'soil at PERMANENT';\\n"
+            >>> t.get_select_statement()
+            ("SELECT  creation_time  , mapset  , name  , creator  FROM raster WHERE id = 'soil at PERMANENT';\\n", ())
+            >>> t.get_select_statement_mogrified()
+            "SELECT  creation_time  , mapset  , name  , creator  FROM raster WHERE id = 'soil at PERMANENT';\\n"
+            >>> t.get_insert_statement()
+            ('INSERT INTO raster ( creation_time  ,mapset  ,name  ,creator ) VALUES (? ,? ,? ,?) ;\\n', (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
+            >>> t.get_insert_statement_mogrified()
+            "INSERT INTO raster ( creation_time  ,mapset  ,name  ,creator ) VALUES ('2001-01-01 00:00:00' ,'PERMANENT' ,'soil' ,'soeren') ;\\n"
+            >>> t.get_update_statement()
+            ("UPDATE raster SET  creation_time = ?  ,mapset = ?  ,name = ?  ,creator = ? WHERE id = 'soil at PERMANENT';\\n", (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
+            >>> t.get_update_statement_mogrified()
+            "UPDATE raster SET  creation_time = '2001-01-01 00:00:00'  ,mapset = 'PERMANENT'  ,name = 'soil'  ,creator = 'soeren' WHERE id = 'soil at PERMANENT';\\n"
+            >>> t.get_update_all_statement()
+            ("UPDATE raster SET  creation_time = ?  ,mapset = ?  ,name = ?  ,creator = ? WHERE id = 'soil at PERMANENT';\\n", (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
+            >>> t.get_update_all_statement_mogrified()
+            "UPDATE raster SET  creation_time = '2001-01-01 00:00:00'  ,mapset = 'PERMANENT'  ,name = 'soil'  ,creator = 'soeren' WHERE id = 'soil at PERMANENT';\\n"
 
-        \endcode
     """
     def __init__(self, table=None, ident=None):
-        """!Constructor of this class
+        """Constructor of this class
 
-           @param table The name of the table
-           @param ident The identifier (primary key) of this
+           :param table: The name of the table
+           :param ident: The identifier (primary key) of this
                          object in the database table
         """
         DictSQLSerializer.__init__(self)
@@ -255,64 +250,69 @@
         self.ident = ident
         self.msgr = get_tgis_message_interface()
 
+        if self.ident and self.ident.find("@") >= 0:
+            self.mapset = self.ident.split("@""")[1]
+        else:
+            self.mapset = None
+
     def get_table_name(self):
-        """!Return the name of the table in which the internal
+        """Return the name of the table in which the internal
            data are inserted, updated or selected
-           @return The name of the table
+           :return: The name of the table
            """
         return self.table
 
     def get_delete_statement(self):
-        """!Return the delete string
-           @return The DELETE string
+        """Return the delete string
+           :return: The DELETE string
         """
         return "DELETE FROM " + self.get_table_name() + \
                " WHERE id = \'" + str(self.ident) + "\';\n"
 
     def delete(self, dbif=None):
-        """!Delete the entry of this object from the temporal database
+        """Delete the entry of this object from the temporal database
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
         """
         sql = self.get_delete_statement()
         #print sql
 
         if dbif:
-            dbif.cursor.execute(sql)
+            dbif.execute(sql,   mapset=self.mapset)
         else:
             dbif = SQLDatabaseInterfaceConnection()
             dbif.connect()
-            dbif.cursor.execute(sql)
+            dbif.execute(sql,   mapset=self.mapset)
             dbif.close()
 
     def get_is_in_db_statement(self):
-        """!Return the selection string that checks if this object is registered in the
+        """Return the selection string that checks if this object is registered in the
            temporal database
-           @return The SELECT string
+           :return: The SELECT string
         """
         return "SELECT id FROM " + self.get_table_name() + \
                " WHERE id = \'" + str(self.ident) + "\';\n"
 
     def is_in_db(self, dbif=None):
-        """!Check if this object is present in the temporal database
+        """Check if this object is present in the temporal database
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
-           @return True if this object is present in the temporal database, False otherwise
+           :return: True if this object is present in the temporal database,
+                    False otherwise
         """
 
         sql = self.get_is_in_db_statement()
-        #print sql
 
         if dbif:
-            dbif.cursor.execute(sql)
-            row = dbif.cursor.fetchone()
+            dbif.execute(sql, mapset=self.mapset)
+            row = dbif.fetchone(mapset=self.mapset)
         else:
             dbif = SQLDatabaseInterfaceConnection()
             dbif.connect()
-            dbif.cursor.execute(sql)
-            row = dbif.cursor.fetchone()
+            dbif.execute(sql, mapset=self.mapset)
+            row = dbif.fetchone(mapset=self.mapset)
             dbif.close()
 
         # Nothing found
@@ -322,30 +322,31 @@
         return True
 
     def get_select_statement(self):
-        """!Return the sql statement and the argument list in
+        """Return the sql statement and the argument list in
            database specific style
-           @return The SELECT string
+           :return: The SELECT string
         """
         return self.serialize("SELECT", self.get_table_name(),
                               "WHERE id = \'" + str(self.ident) + "\'")
 
     def get_select_statement_mogrified(self, dbif=None):
-        """!Return the select statement as mogrified string
+        """Return the select statement as mogrified string
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
-           @return The SELECT string
+           :return: The SELECT string
         """
         if not dbif:
             dbif = SQLDatabaseInterfaceConnection()
 
-        return dbif.mogrify_sql_statement(self.get_select_statement())
+        return dbif.mogrify_sql_statement(self.get_select_statement(),
+                                          mapset=self.mapset)
 
     def select(self, dbif=None):
-        """!Select the content from the temporal database and store it
+        """Select the content from the temporal database and store it
            in the internal dictionary structure
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
         """
         sql, args = self.get_select_statement()
@@ -354,18 +355,18 @@
 
         if dbif:
             if len(args) == 0:
-                dbif.cursor.execute(sql)
+                dbif.execute(sql,  mapset=self.mapset)
             else:
-                dbif.cursor.execute(sql, args)
-            row = dbif.cursor.fetchone()
+                dbif.execute(sql, args,  mapset=self.mapset)
+            row = dbif.fetchone(mapset=self.mapset)
         else:
             dbif = SQLDatabaseInterfaceConnection()
             dbif.connect()
             if len(args) == 0:
-                dbif.cursor.execute(sql)
+                dbif.execute(sql, mapset=self.mapset)
             else:
-                dbif.cursor.execute(sql, args)
-            row = dbif.cursor.fetchone()
+                dbif.execute(sql, args, mapset=self.mapset)
+            row = dbif.fetchone(mapset=self.mapset)
             dbif.close()
 
         # Nothing found
@@ -376,33 +377,34 @@
             self.deserialize(row)
         else:
             self.msgr.fatal(_("Object <%s> not found in the temporal database")
-                       % self.get_id())
+                            % self.get_id())
 
         return True
 
     def get_insert_statement(self):
-        """!Return the sql statement and the argument
+        """Return the sql statement and the argument
            list in database specific style
-           @return The INSERT string"""
+           :return: The INSERT string"""
         return self.serialize("INSERT", self.get_table_name())
 
     def get_insert_statement_mogrified(self, dbif=None):
-        """!Return the insert statement as mogrified string
+        """Return the insert statement as mogrified string
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
-           @return The INSERT string
+           :return: The INSERT string
         """
         if not dbif:
             dbif = SQLDatabaseInterfaceConnection()
 
-        return dbif.mogrify_sql_statement(self.get_insert_statement())
+        return dbif.mogrify_sql_statement(self.get_insert_statement(),
+                                          mapset=self.mapset)
 
     def insert(self, dbif=None):
-        """!Serialize the content of this object and store it in the temporal
+        """Serialize the content of this object and store it in the temporal
            database using the internal identifier
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
         """
         sql, args = self.get_insert_statement()
@@ -410,50 +412,51 @@
         #print args
 
         if dbif:
-            dbif.cursor.execute(sql, args)
+            dbif.execute(sql, args, mapset=self.mapset)
         else:
             dbif = SQLDatabaseInterfaceConnection()
             dbif.connect()
-            dbif.cursor.execute(sql, args)
+            dbif.execute(sql, args, mapset=self.mapset)
             dbif.close()
 
     def get_update_statement(self, ident=None):
-        """!Return the sql statement and the argument list
+        """Return the sql statement and the argument list
            in database specific style
 
-           @param ident The identifier to be updated, useful for renaming
-           @return The UPDATE string
+           :param ident: The identifier to be updated, useful for renaming
+           :return: The UPDATE string
 
            """
         if ident:
             return self.serialize("UPDATE", self.get_table_name(),
-                              "WHERE id = \'" + str(ident) + "\'")
+                                  "WHERE id = \'" + str(ident) + "\'")
         else:
             return self.serialize("UPDATE", self.get_table_name(),
-                              "WHERE id = \'" + str(self.ident) + "\'")
+                                  "WHERE id = \'" + str(self.ident) + "\'")
 
     def get_update_statement_mogrified(self, dbif=None, ident=None):
-        """!Return the update statement as mogrified string
+        """Return the update statement as mogrified string
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
-           @param ident The identifier to be updated, useful for renaming
-           @return The UPDATE string
+           :param ident: The identifier to be updated, useful for renaming
+           :return: The UPDATE string
         """
         if not dbif:
             dbif = SQLDatabaseInterfaceConnection()
 
-        return dbif.mogrify_sql_statement(self.get_update_statement(ident))
+        return dbif.mogrify_sql_statement(self.get_update_statement(ident),
+                                          mapset=self.mapset)
 
     def update(self, dbif=None, ident=None):
-        """!Serialize the content of this object and update it in the temporal
+        """Serialize the content of this object and update it in the temporal
            database using the internal identifier
 
            Only object entries which are exists (not None) are updated
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
-           @param ident The identifier to be updated, useful for renaming
+           :param ident: The identifier to be updated, useful for renaming
         """
         if self.ident is None:
             self.msgr.fatal(_("Missing identifer"))
@@ -463,47 +466,48 @@
         #print args
 
         if dbif:
-            dbif.cursor.execute(sql, args)
+            dbif.execute(sql, args, mapset=self.mapset)
         else:
             dbif = SQLDatabaseInterfaceConnection()
             dbif.connect()
-            dbif.cursor.execute(sql, args)
+            dbif.execute(sql, args, mapset=self.mapset)
             dbif.close()
 
     def get_update_all_statement(self, ident=None):
-        """!Return the sql statement and the argument
+        """Return the sql statement and the argument
            list in database specific style
 
-           @param ident The identifier to be updated, useful for renaming
-           @return The UPDATE string
+           :param ident: The identifier to be updated, useful for renaming
+           :return: The UPDATE string
            """
         if ident:
             return self.serialize("UPDATE ALL", self.get_table_name(),
-                              "WHERE id = \'" + str(ident) + "\'")
+                                  "WHERE id = \'" + str(ident) + "\'")
         else:
             return self.serialize("UPDATE ALL", self.get_table_name(),
-                              "WHERE id = \'" + str(self.ident) + "\'")
+                                  "WHERE id = \'" + str(self.ident) + "\'")
 
     def get_update_all_statement_mogrified(self, dbif=None, ident=None):
-        """!Return the update all statement as mogrified string
+        """Return the update all statement as mogrified string
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
-           @param ident The identifier to be updated, useful for renaming
-           @return The UPDATE string
+           :param ident: The identifier to be updated, useful for renaming
+           :return: The UPDATE string
         """
         if not dbif:
             dbif = SQLDatabaseInterfaceConnection()
 
-        return dbif.mogrify_sql_statement(self.get_update_all_statement(ident))
+        return dbif.mogrify_sql_statement(self.get_update_all_statement(ident),
+                                          mapset=self.mapset)
 
     def update_all(self, dbif=None, ident=None):
-        """!Serialize the content of this object, including None objects,
+        """Serialize the content of this object, including None objects,
         and update it in the temporal database using the internal identifier
 
-           @param dbif The database interface to be used,
+           :param dbif: The database interface to be used,
                         if None a temporary connection will be established
-           @param ident The identifier to be updated, useful for renaming
+           :param ident: The identifier to be updated, useful for renaming
         """
         if self.ident is None:
             self.msgr.fatal(_("Missing identifer"))
@@ -513,73 +517,74 @@
         #print args
 
         if dbif:
-            dbif.cursor.execute(sql, args)
+            dbif.execute(sql, args, mapset=self.mapset)
         else:
             dbif = SQLDatabaseInterfaceConnection()
             dbif.connect()
-            dbif.cursor.execute(sql, args)
+            dbif.execute(sql, args, mapset=self.mapset)
             dbif.close()
 
 ###############################################################################
 
+
 class DatasetBase(SQLDatabaseInterface):
-    """!This is the base class for all maps and spacetime datasets storing
+    """This is the base class for all maps and spacetime datasets storing
         basic identification information
 
         Usage:
 
-        \code
+        .. code-block:: python
 
-        >>> init()
-        >>> t = DatasetBase("raster", "soil at PERMANENT", creator="soeren", ctime=datetime(2001,1,1), ttype="absolute")
-        >>> t.id
-        'soil at PERMANENT'
-        >>> t.name
-        'soil'
-        >>> t.mapset
-        'PERMANENT'
-        >>> t.creator
-        'soeren'
-        >>> t.ctime
-        datetime.datetime(2001, 1, 1, 0, 0)
-        >>> t.ttype
-        'absolute'
-        >>> t.print_info()
-         +-------------------- Basic information -------------------------------------+
-         | Id: ........................ soil at PERMANENT
-         | Name: ...................... soil
-         | Mapset: .................... PERMANENT
-         | Creator: ................... soeren
-         | Temporal type: ............. absolute
-         | Creation time: ............. 2001-01-01 00:00:00
-        >>> t.print_shell_info()
-        id=soil at PERMANENT
-        name=soil
-        mapset=PERMANENT
-        creator=soeren
-        temporal_type=absolute
-        creation_time=2001-01-01 00:00:00
+            >>> init()
+            >>> t = DatasetBase("raster", "soil at PERMANENT", creator="soeren", ctime=datetime(2001,1,1), ttype="absolute")
+            >>> t.id
+            'soil at PERMANENT'
+            >>> t.name
+            'soil'
+            >>> t.mapset
+            'PERMANENT'
+            >>> t.creator
+            'soeren'
+            >>> t.ctime
+            datetime.datetime(2001, 1, 1, 0, 0)
+            >>> t.ttype
+            'absolute'
+            >>> t.print_info()
+             +-------------------- Basic information -------------------------------------+
+             | Id: ........................ soil at PERMANENT
+             | Name: ...................... soil
+             | Mapset: .................... PERMANENT
+             | Creator: ................... soeren
+             | Temporal type: ............. absolute
+             | Creation time: ............. 2001-01-01 00:00:00
+            >>> t.print_shell_info()
+            id=soil at PERMANENT
+            name=soil
+            mapset=PERMANENT
+            creator=soeren
+            temporal_type=absolute
+            creation_time=2001-01-01 00:00:00
 
-        \endcode
     """
 
     def __init__(self, table=None, ident=None, name=None, mapset=None,
-                 creator=None, ctime=None,ttype=None):
-        """!Constructor
+                 creator=None, ctime=None, ttype=None):
+        """Constructor
 
-            @param table The name of the temporal database table
+            :param table: The name of the temporal database table
                           that should be used to store the values
-            @param ident The unique identifier must be a combination of
+            :param ident: The unique identifier must be a combination of
                           the dataset name, layer name and the mapset
                           "name at mapset" or "name:layer at mapset"
                           used as as primary key in the temporal database
-            @param name The name of the map or dataset
-            @param mapset The name of the mapset
-            @param creator The name of the creator
-            @param ctime The creation datetime object
-            @param ttype The temporal type
-                - "absolute" Identifier for absolute time
-                - "relative" Identifier for relative time
+            :param name: The name of the map or dataset
+            :param mapset: The name of the mapset
+            :param creator: The name of the creator
+            :param ctime: The creation datetime object
+            :param ttype: The temporal type
+
+                              - "absolute" Identifier for absolute time
+                              - "relative" Identifier for relative time
         """
 
         SQLDatabaseInterface.__init__(self, table, ident)
@@ -597,9 +602,9 @@
         self.set_ttype(ttype)
 
     def set_id(self, ident):
-        """!Convenient method to set the unique identifier (primary key)
+        """Convenient method to set the unique identifier (primary key)
 
-           @param ident The unique identifier must be a combination
+           :param ident: The unique identifier must be a combination
                          of the dataset name, layer name and the mapset
                          "name at mapset" or "name:layer at mapset"
         """
@@ -618,42 +623,41 @@
                 self.set_layer(layer)
             self.set_name(name)
 
-
     def set_name(self, name):
-        """!Set the name of the dataset
+        """Set the name of the dataset
 
-           @param name The name of the dataset
+           :param name: The name of the dataset
         """
         self.D["name"] = name
 
     def set_mapset(self, mapset):
-        """!Set the mapset of the dataset
+        """Set the mapset of the dataset
 
-           @param mapset The name of the mapset in which this dataset is stored
+           :param mapset: The name of the mapset in which this dataset is stored
         """
         self.D["mapset"] = mapset
 
     def set_layer(self, layer):
-        """!Convenient method to set the layer of the map (part of primary key)
+        """Convenient method to set the layer of the map (part of primary key)
 
            Layer are supported for vector maps
 
-           @param layer The layer of the map
+           :param layer: The layer of the map
         """
         self.D["layer"] = layer
 
     def set_creator(self, creator):
-        """!Set the creator of the dataset
+        """Set the creator of the dataset
 
-           @param creator The name of the creator
+           :param creator: The name of the creator
         """
         self.D["creator"] = creator
 
     def set_ctime(self, ctime=None):
-        """!Set the creation time of the dataset,
+        """Set the creation time of the dataset,
            if nothing set the current time is used
 
-           @param ctime The current time of type datetime
+           :param ctime: The current time of type datetime
         """
         if ctime is None:
             self.D["creation_time"] = datetime.today()
@@ -661,10 +665,10 @@
             self.D["creation_time"] = ctime
 
     def set_ttype(self, ttype):
-        """!Set the temporal type of the dataset: absolute or relative,
+        """Set the temporal type of the dataset: absolute or relative,
            if nothing set absolute time will assumed
 
-           @param ttype The temporal type of the dataset "absolute or relative"
+           :param ttype: The temporal type of the dataset "absolute or relative"
         """
         if ttype is None or (ttype != "absolute" and ttype != "relative"):
             self.D["temporal_type"] = "absolute"
@@ -672,9 +676,9 @@
             self.D["temporal_type"] = ttype
 
     def get_id(self):
-        """!Convenient method to get the unique identifier (primary key)
+        """Convenient method to get the unique identifier (primary key)
 
-           @return None if not found
+           :return: None if not found
         """
         if "id" in self.D:
             return self.D["id"]
@@ -682,10 +686,10 @@
             return None
 
     def get_map_id(self):
-        """!Convenient method to get the unique map identifier
+        """Convenient method to get the unique map identifier
            without layer information
 
-           @return the name of the vector map as "name at mapset"
+           :return: the name of the vector map as "name at mapset"
                   or None in case the id was not set
         """
         if self.id:
@@ -699,11 +703,11 @@
             return None
 
     def get_layer(self):
-        """!Convenient method to get the layer of the map (part of primary key)
+        """Convenient method to get the layer of the map (part of primary key)
 
            Layer are currently supported for vector maps
 
-           @return None if not found
+           :return: None if not found
         """
         if "layer" in self.D:
             return self.D["layer"]
@@ -711,40 +715,40 @@
             return None
 
     def get_name(self):
-        """!Get the name of the dataset
-           @return None if not found"""
+        """Get the name of the dataset
+           :return: None if not found"""
         if "name" in self.D:
             return self.D["name"]
         else:
             return None
 
     def get_mapset(self):
-        """!Get the name of mapset of this dataset
-           @return None if not found"""
+        """Get the name of mapset of this dataset
+           :return: None if not found"""
         if "mapset" in self.D:
             return self.D["mapset"]
         else:
             return None
 
     def get_creator(self):
-        """!Get the creator of the dataset
-           @return None if not found"""
+        """Get the creator of the dataset
+           :return: None if not found"""
         if "creator" in self.D:
             return self.D["creator"]
         else:
             return None
 
     def get_ctime(self):
-        """!Get the creation time of the dataset, datatype is datetime
-           @return None if not found"""
+        """Get the creation time of the dataset, datatype is datetime
+           :return: None if not found"""
         if "creation_time" in self.D:
             return self.D["creation_time"]
         else:
             return None
 
     def get_ttype(self):
-        """!Get the temporal type of the map
-           @return None if not found"""
+        """Get the temporal type of the map
+           :return: None if not found"""
         if "temporal_type" in self.D:
             return self.D["temporal_type"]
         else:
@@ -760,7 +764,7 @@
     creator = property(fget=get_creator, fset=set_creator)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " +-------------------- Basic information -------------------------------------+"
         print " | Id: ........................ " + str(self.get_id())
@@ -773,7 +777,7 @@
         print " | Creation time: ............. " + str(self.get_ctime())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         print "id=" + str(self.get_id())
         print "name=" + str(self.get_name())
         print "mapset=" + str(self.get_mapset())
@@ -787,28 +791,28 @@
 
 
 class RasterBase(DatasetBase):
-    """!Time stamped raster map base information class"""
+    """Time stamped raster map base information class"""
     def __init__(self, ident=None, name=None, mapset=None, creator=None,
                  creation_time=None, temporal_type=None):
         DatasetBase.__init__(self, "raster_base", ident, name, mapset,
-                              creator, creation_time, temporal_type)
+                             creator, creation_time, temporal_type)
 
 
 class Raster3DBase(DatasetBase):
-    """!Time stamped 3D raster map base information class"""
+    """Time stamped 3D raster map base information class"""
     def __init__(self, ident=None, name=None, mapset=None, creator=None,
                  creation_time=None, temporal_type=None,):
         DatasetBase.__init__(self, "raster3d_base", ident, name,
-                              mapset, creator, creation_time,
-                              temporal_type)
+                             mapset, creator, creation_time,
+                             temporal_type)
 
 
 class VectorBase(DatasetBase):
-    """!Time stamped vector map base information class"""
+    """Time stamped vector map base information class"""
     def __init__(self, ident=None, name=None, mapset=None, layer=None,
                  creator=None, creation_time=None, temporal_type=None):
         DatasetBase.__init__(self, "vector_base", ident, name, mapset,
-                              creator, creation_time, temporal_type)
+                             creator, creation_time, temporal_type)
 
         self.set_id(ident)
         if ident is not None and name is None and mapset is None:
@@ -826,81 +830,86 @@
 
 
 class STDSBase(DatasetBase):
-    """!Base class for space time datasets
+    """Base class for space time datasets
 
        This class adds the semantic type member variable to the dataset
        base class.
 
     Usage:
 
-    \code
+    .. code-block:: python
 
-    >>> init()
-    >>> t = STDSBase("stds", "soil at PERMANENT", semantic_type="average", creator="soeren", ctime=datetime(2001,1,1), ttype="absolute", mtime=datetime(2001,1,1))
-    >>> t.semantic_type
-    'average'
-    >>> t.print_info()
-     +-------------------- Basic information -------------------------------------+
-     | Id: ........................ soil at PERMANENT
-     | Name: ...................... soil
-     | Mapset: .................... PERMANENT
-     | Creator: ................... soeren
-     | Temporal type: ............. absolute
-     | Creation time: ............. 2001-01-01 00:00:00
-     | Modification time:.......... 2001-01-01 00:00:00
-     | Semantic type:.............. average
-    >>> t.print_shell_info()
-    id=soil at PERMANENT
-    name=soil
-    mapset=PERMANENT
-    creator=soeren
-    temporal_type=absolute
-    creation_time=2001-01-01 00:00:00
-    modification_time=2001-01-01 00:00:00
-    semantic_type=average
+        >>> init()
+        >>> t = STDSBase("stds", "soil at PERMANENT", semantic_type="average", creator="soeren", ctime=datetime(2001,1,1), ttype="absolute", mtime=datetime(2001,1,1))
+        >>> t.semantic_type
+        'average'
+        >>> t.print_info()
+         +-------------------- Basic information -------------------------------------+
+         | Id: ........................ soil at PERMANENT
+         | Name: ...................... soil
+         | Mapset: .................... PERMANENT
+         | Creator: ................... soeren
+         | Temporal type: ............. absolute
+         | Creation time: ............. 2001-01-01 00:00:00
+         | Modification time:.......... 2001-01-01 00:00:00
+         | Semantic type:.............. average
+        >>> t.print_shell_info()
+        id=soil at PERMANENT
+        name=soil
+        mapset=PERMANENT
+        creator=soeren
+        temporal_type=absolute
+        creation_time=2001-01-01 00:00:00
+        modification_time=2001-01-01 00:00:00
+        semantic_type=average
 
-    \endcode
     """
     def __init__(self, table=None, ident=None, name=None, mapset=None,
                  semantic_type=None, creator=None, ctime=None,
                  ttype=None, mtime=None):
         DatasetBase.__init__(self, table, ident, name, mapset, creator,
-                              ctime, ttype)
+                             ctime, ttype)
 
         self.set_semantic_type(semantic_type)
         self.set_mtime(mtime)
 
     def set_semantic_type(self, semantic_type):
-        """!Set the semantic type of the space time dataset"""
+        """Set the semantic type of the space time dataset"""
         self.D["semantic_type"] = semantic_type
-        
+
     def set_mtime(self, mtime=None):
-       """!Set the modification time of the space time dataset, if nothing set the current time is used"""
-       if mtime == None:
+        """Set the modification time of the space time dataset, if nothing set
+           the current time is used
+        """
+        if mtime is None:
             self.D["modification_time"] = datetime.now()
-       else:
+        else:
             self.D["modification_time"] = mtime
 
     def get_semantic_type(self):
-        """!Get the semantic type of the space time dataset
-           @return None if not found"""
+        """Get the semantic type of the space time dataset
+           :return: None if not found
+        """
         if "semantic_type" in self.D:
             return self.D["semantic_type"]
         else:
             return None
-            
+
     def get_mtime(self):
-       """!Get the modification time of the space time dataset, datatype is datetime
-          @return None if not found"""
-       if self.D.has_key("modification_time"):
-           return self.D["modification_time"]
-       else:
-           return None
+        """Get the modification time of the space time dataset, datatype is
+           datetime
 
+           :return: None if not found
+        """
+        if self.D.has_key("modification_time"):
+            return self.D["modification_time"]
+        else:
+            return None
+
     semantic_type = property(fget=get_semantic_type, fset=set_semantic_type)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         DatasetBase.print_info(self)
         #      0123456789012345678901234567890
         print " | Modification time:.......... " + str(self.get_mtime())
@@ -908,7 +917,7 @@
             self.get_semantic_type())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         DatasetBase.print_shell_info(self)
         print "modification_time=" + str(self.get_mtime())
         print "semantic_type=" + str(self.get_semantic_type())
@@ -917,64 +926,64 @@
 
 
 class STRDSBase(STDSBase):
-    """!Space time raster dataset base information class"""
+    """Space time raster dataset base information class"""
     def __init__(self, ident=None, name=None, mapset=None,
                  semantic_type=None, creator=None, ctime=None,
                  ttype=None):
         STDSBase.__init__(self, "strds_base", ident, name, mapset,
-                           semantic_type, creator, ctime,
-                           ttype)
+                          semantic_type, creator, ctime,
+                          ttype)
 
 
 class STR3DSBase(STDSBase):
-    """!Space time 3D raster dataset base information class"""
+    """Space time 3D raster dataset base information class"""
     def __init__(self, ident=None, name=None, mapset=None,
                  semantic_type=None, creator=None, ctime=None,
                  ttype=None):
         STDSBase.__init__(self, "str3ds_base", ident, name, mapset,
-                           semantic_type, creator, ctime,
-                           ttype)
+                          semantic_type, creator, ctime,
+                          ttype)
 
 
 class STVDSBase(STDSBase):
-    """!Space time vector dataset base information class"""
+    """Space time vector dataset base information class"""
     def __init__(self, ident=None, name=None, mapset=None,
                  semantic_type=None, creator=None, ctime=None,
                  ttype=None):
         STDSBase.__init__(self, "stvds_base", ident, name, mapset,
-                           semantic_type, creator, ctime,
-                           ttype)
+                          semantic_type, creator, ctime,
+                          ttype)
 
 ###############################################################################
 
+
 class AbstractSTDSRegister(SQLDatabaseInterface):
-    """!This is the base class for all maps to store the space time datasets
+    """This is the base class for all maps to store the space time datasets
        as comma separated string in which they are registered
 
         Usage:
 
-        \code
+        .. code-block:: python
 
-        >>> init()
-        >>> t = AbstractSTDSRegister("raster", "soil at PERMANENT", "A at P,B at P,C at P")
-        >>> t.id
-        'soil at PERMANENT'
-        >>> t.registered_stds
-        'A at P,B at P,C at P'
+            >>> init()
+            >>> t = AbstractSTDSRegister("raster", "soil at PERMANENT", "A at P,B at P,C at P")
+            >>> t.id
+            'soil at PERMANENT'
+            >>> t.registered_stds
+            'A at P,B at P,C at P'
 
-        \endcode
     """
 
     def __init__(self, table=None, ident=None, registered_stds=None):
-        """!Constructor
+        """Constructor
 
-            @param table The name of the temporal database table
+            :param table: The name of the temporal database table
                           that should be used to store the values
-            @param ident The unique identifier must be a combination of
+            :param ident: The unique identifier must be a combination of
                           the dataset name, layer name and the mapset
                           "name at mapset" or "name:layer at mapset"
                           used as as primary key in the temporal database
-            @param stds A comma separted list of space time dataset ids
+            :param stds: A comma separted list of space time dataset ids
         """
 
         SQLDatabaseInterface.__init__(self, table, ident)
@@ -983,9 +992,9 @@
         self.set_registered_stds(registered_stds)
 
     def set_id(self, ident):
-        """!Convenient method to set the unique identifier (primary key)
+        """Convenient method to set the unique identifier (primary key)
 
-           @param ident The unique identifier must be a combination
+           :param ident: The unique identifier must be a combination
                          of the dataset name, layer name and the mapset
                          "name at mapset" or "name:layer at mapset"
         """
@@ -993,17 +1002,18 @@
         self.D["id"] = ident
 
     def set_registered_stds(self, registered_stds):
-        """!Get the comma separated list of space time datasets ids
+        """Get the comma separated list of space time datasets ids
            in which this map is registered
-           @param registered_stds A comma separated list of space time dataset ids
-                                  in which this map is registered
+
+           :param registered_stds: A comma separated list of space time
+                                   dataset ids in which this map is registered
         """
         self.D["registered_stds"] = registered_stds
 
     def get_id(self):
-        """!Convenient method to get the unique identifier (primary key)
+        """Convenient method to get the unique identifier (primary key)
 
-           @return None if not found
+           :return: None if not found
         """
         if "id" in self.D:
             return self.D["id"]
@@ -1011,9 +1021,11 @@
             return None
 
     def get_registered_stds(self):
-        """!Get the comma separated list of space time datasets ids
+        """Get the comma separated list of space time datasets ids
            in which this map is registered
-           @return None if not found"""
+
+           :return: None if not found
+        """
         if "registered_stds" in self.D:
             return self.D["registered_stds"]
         else:
@@ -1021,24 +1033,31 @@
 
     # Properties of this class
     id = property(fget=get_id, fset=set_id)
-    registered_stds = property(fget=get_registered_stds, fset=set_registered_stds)
+    registered_stds = property(fget=get_registered_stds,
+                               fset=set_registered_stds)
 
 ###############################################################################
 
+
 class RasterSTDSRegister(AbstractSTDSRegister):
-    """!Time stamped raster map base information class"""
+    """Time stamped raster map base information class"""
     def __init__(self, ident=None, registered_stds=None):
-        AbstractSTDSRegister.__init__(self, "raster_stds_register", ident, registered_stds)
+        AbstractSTDSRegister.__init__(self, "raster_stds_register", ident,
+                                      registered_stds)
 
+
 class Raster3DSTDSRegister(AbstractSTDSRegister):
-    """!Time stamped 3D raster map base information class"""
+    """Time stamped 3D raster map base information class"""
     def __init__(self, ident=None, registered_stds=None):
-        AbstractSTDSRegister.__init__(self, "raster3d_stds_register", ident, registered_stds)
+        AbstractSTDSRegister.__init__(self, "raster3d_stds_register", ident,
+                                      registered_stds)
 
+
 class VectorSTDSRegister(AbstractSTDSRegister):
-    """!Time stamped vector map base information class"""
+    """Time stamped vector map base information class"""
     def __init__(self, ident=None, registered_stds=None):
-        AbstractSTDSRegister.__init__(self, "vector_stds_register", ident, registered_stds)
+        AbstractSTDSRegister.__init__(self, "vector_stds_register", ident,
+                                      registered_stds)
 
 ###############################################################################
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/c_libraries_interface.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,18 +1,14 @@
 # -*- coding: utf-8 -*-
-"""!@package grass.pygrass.massages
-
- at brief Temporal Framework GRASS C-library interface
-
+"""
 Fast and exit-safe interface to GRASS C-library functions
 using ctypes and multiprocessing
 
-
 (C) 2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 import sys
@@ -25,36 +21,134 @@
 import grass.lib.vector as libvector
 import grass.lib.date as libdate
 import grass.lib.raster3d as libraster3d
+import grass.lib.temporal as libtgis
 
 ###############################################################################
 
+
 class RPCDefs(object):
     # Function identifier and index
-    STOP=0
-    HAS_TIMESTAMP=1
-    WRITE_TIMESTAMP=2
-    READ_TIMESTAMP=3
-    REMOVE_TIMESTAMP=4
-    READ_MAP_INFO=5
-    MAP_EXISTS=6
-    READ_MAP_INFO=7
+    STOP = 0
+    HAS_TIMESTAMP = 1
+    WRITE_TIMESTAMP = 2
+    READ_TIMESTAMP = 3
+    REMOVE_TIMESTAMP = 4
+    READ_MAP_INFO = 5
+    MAP_EXISTS = 6
+    READ_MAP_INFO = 7
     AVAILABLE_MAPSETS = 8
+    GET_DRIVER_NAME = 9
+    GET_DATABASE_NAME = 10
+    G_MAPSET = 11
+    G_LOCATION = 12
+    G_GISDBASE = 13
+    G_FATAL_ERROR = 14
 
-    TYPE_RASTER=0
-    TYPE_RASTER3D=1
-    TYPE_VECTOR=2
+    TYPE_RASTER = 0
+    TYPE_RASTER3D = 1
+    TYPE_VECTOR = 2
 
 ###############################################################################
-def available_mapsets(lock, conn, data):
-    """!Return all available mapsets the user can access as a list of strings
-    
-       @param lock A multiprocessing.Lock instance
-       @param conn A multiprocessing.Pipe instance used to send True or False
-       @param data The list of data entries [function_id]
-       
-       @return Names of available mapsets as list of strings
+
+
+def _fatal_error(lock, conn, data):
+    """Calls G_fatal_error()"""
+    libgis.G_fatal_error("Fatal Error in C library server")
+
+
+def _get_mapset(lock, conn, data):
+    """Return the current mapset
+
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The mapset as list entry 1 [function_id]
+
+       :returns: Name of the current mapset
     """
-    
+    mapset = libgis.G_mapset()
+    conn.send(mapset)
+
+
+def _get_location(lock, conn, data):
+    """Return the current location
+
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The mapset as list entry 1 [function_id]
+
+       :returns: Name of the location
+    """
+    location = libgis.G_location()
+    conn.send(location)
+
+
+def _get_gisdbase(lock, conn, data):
+    """Return the current gisdatabase
+
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The mapset as list entry 1 [function_id]
+
+       :returns: Name of the gisdatabase
+    """
+    gisdbase = libgis.G_gisdbase()
+    conn.send(gisdbase)
+
+
+def _get_driver_name(lock, conn, data):
+    """Return the temporal database driver of a specific mapset
+
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The mapset as list entry 1 [function_id, mapset]
+
+       :returns: Name of the driver or None if no temporal database present
+    """
+    mapset = data[1]
+    if not mapset:
+        mapset = libgis.G_mapset()
+
+    drstring = libtgis.tgis_get_mapset_driver_name(mapset)
+    conn.send(drstring)
+
+###############################################################################
+
+
+def _get_database_name(lock, conn, data):
+    """Return the temporal database name of a specific mapset
+
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The mapset as list entry 1 [function_id, mapset]
+
+       :returns: Name of the database or None if no temporal database present
+    """
+    mapset = data[1]
+    if not mapset:
+        mapset = libgis.G_mapset()
+    dbstring = libtgis.tgis_get_mapset_database_name(mapset)
+
+    if dbstring:
+        # We substitute GRASS variables if they are located in the database string
+        # This behavior is in conjunction with db.connect
+        dbstring = dbstring.replace("$GISDBASE", libgis.G_gisdbase())
+        dbstring = dbstring.replace("$LOCATION_NAME", libgis.G_location())
+        dbstring = dbstring.replace("$MAPSET", libgis.G_mapset())
+    conn.send(dbstring)
+
+###############################################################################
+
+
+def _available_mapsets(lock, conn, data):
+    """Return all available mapsets the user can access as a list of strings
+
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The list of data entries [function_id]
+
+       :returns: Names of available mapsets as list of strings
+    """
+
     mapsets = libgis.G_get_available_mapsets()
 
     count = 0
@@ -68,10 +162,10 @@
             while mapset[c] != "\x00":
                 char_list += mapset[c]
                 c += 1
-                
-        mapset_list.append(char_list) 
-        
-    # We need to sort the mapset list, but the first one should be 
+
+        mapset_list.append(char_list)
+
+    # We need to sort the mapset list, but the first one should be
     # the current mapset
     current_mapset = libgis.G_mapset()
     mapset_list.remove(current_mapset)
@@ -80,21 +174,23 @@
     mapset_list.append(current_mapset)
     mapset_list.reverse()
 
-    conn.send(mapset_list) 
+    conn.send(mapset_list)
 
+
 def _has_timestamp(lock, conn, data):
-    """!Check if the file based GRASS timestamp is present and send
+    """Check if the file based GRASS timestamp is present and send
        True or False using the provided pipe.
 
-       @param lock A multiprocessing.Lock instance
-       @param conn A multiprocessing.Pipe instance used to send True or False
-       @param data The list of data entries [function_id, maptype, name, mapset, layer]
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The list of data entries [function_id, maptype, name,
+                    mapset, layer]
 
     """
     maptype = data[1]
     name = data[2]
     mapset = data[3]
-    layer= data[4]
+    layer = data[4]
     check = False
     if maptype == RPCDefs.TYPE_RASTER:
         if libgis.G_has_raster_timestamp(name, mapset) == 1:
@@ -109,32 +205,36 @@
 
 ###############################################################################
 
+
 def _read_timestamp(lock, conn, data):
-    """!Read the file based GRASS timestamp and send
+    """Read the file based GRASS timestamp and send
        the result using the provided pipe.
 
-       The tuple to be send via pipe: (return value of G_read_*_timestamp, timestamps).
+       The tuple to be send via pipe: (return value of G_read_*_timestamp,
+       timestamps).
 
        Please have a look at the documentation of G_read_raster_timestamp,
        G_read_vector_timestamp and G_read_raster3d_timestamp for the return
        values description.
 
        The timestamps to be send are tuples of values:
+
            - relative time (start, end, unit), start and end are of type
              integer, unit is of type string.
            - absolute time (start, end), start and end are of type datetime
 
        The end time may be None in case of a time instance.
 
-       @param lock A multiprocessing.Lock instance
-       @param conn A multiprocessing.Pipe instance used to send the result
-       @param data The list of data entries [function_id, maptype, name, mapset, layer]
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send the result
+       :param data: The list of data entries [function_id, maptype, name,
+                    mapset, layer]
 
     """
     maptype = data[1]
     name = data[2]
     mapset = data[3]
-    layer= data[4]
+    layer = data[4]
     check = False
     ts = libgis.TimeStamp()
     if maptype == RPCDefs.TYPE_RASTER:
@@ -149,8 +249,9 @@
 
 ###############################################################################
 
+
 def _write_timestamp(lock, conn, data):
-    """!Write the file based GRASS timestamp
+    """Write the file based GRASS timestamp
        the return values of the called C-functions using the provided pipe.
 
        The value to be send via pipe is the return value of G_write_*_timestamp.
@@ -159,21 +260,22 @@
        G_write_vector_timestamp and G_write_raster3d_timestamp for the return
        values description.
 
-       @param lock A multiprocessing.Lock instance
-       @param conn A multiprocessing.Pipe instance used to send True or False
-       @param data The list of data entries [function_id, maptype, name, mapset, layer, timestring]
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The list of data entries [function_id, maptype, name,
+                    mapset, layer, timestring]
     """
     maptype = data[1]
     name = data[2]
     mapset = data[3]
-    layer= data[4]
+    layer = data[4]
     timestring = data[5]
     check = -3
     ts = libgis.TimeStamp()
     check = libgis.G_scan_timestamp(byref(ts), timestring)
 
     if check != 1:
-        logging.error("Unable to convert the timestamp: "+ timestring)
+        logging.error("Unable to convert the timestamp: " + timestring)
         return -2
 
     if maptype == RPCDefs.TYPE_RASTER:
@@ -187,8 +289,9 @@
 
 ###############################################################################
 
+
 def _remove_timestamp(lock, conn, data):
-    """!Remove the file based GRASS timestamp
+    """Remove the file based GRASS timestamp
        the return values of the called C-functions using the provided pipe.
 
        The value to be send via pipe is the return value of G_remove_*_timestamp.
@@ -197,15 +300,16 @@
        G_remove_vector_timestamp and G_remove_raster3d_timestamp for the return
        values description.
 
-       @param lock A multiprocessing.Lock instance
-       @param conn A multiprocessing.Pipe instance used to send True or False
-       @param data The list of data entries [function_id, maptype, name, mapset, layer]
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The list of data entries [function_id, maptype, name,
+                    mapset, layer]
 
     """
     maptype = data[1]
     name = data[2]
     mapset = data[3]
-    layer= data[4]
+    layer = data[4]
     check = False
     if maptype == RPCDefs.TYPE_RASTER:
         check = libgis.G_remove_raster_timestamp(name, mapset)
@@ -218,15 +322,16 @@
 
 ###############################################################################
 
+
 def _map_exists(lock, conn, data):
-    """!Check if a map exists in the spatial database
+    """Check if a map exists in the spatial database
 
        The value to be send via pipe is True in case the map exists and False
        if not.
 
-       @param lock A multiprocessing.Lock instance
-       @param conn A multiprocessing.Pipe instance used to send True or False
-       @param data The list of data entries [function_id, maptype, name, mapset]
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The list of data entries [function_id, maptype, name, mapset]
 
     """
     maptype = data[1]
@@ -234,11 +339,11 @@
     mapset = data[3]
     check = False
     if maptype == RPCDefs.TYPE_RASTER:
-         mapset = libgis.G_find_raster(name, mapset)
+        mapset = libgis.G_find_raster(name, mapset)
     elif maptype == RPCDefs.TYPE_VECTOR:
-         mapset = libgis.G_find_vector(name, mapset)
+        mapset = libgis.G_find_vector(name, mapset)
     elif maptype == RPCDefs.TYPE_RASTER3D:
-         mapset = libgis.G_find_raster3d(name, mapset)
+        mapset = libgis.G_find_raster3d(name, mapset)
 
     if mapset:
         check = True
@@ -247,38 +352,41 @@
 
 ###############################################################################
 
+
 def _read_map_info(lock, conn, data):
-    """!Read map specific metadata from the spatial database using C-library
+    """Read map specific metadata from the spatial database using C-library
        functions
 
-       @param lock A multiprocessing.Lock instance
-       @param conn A multiprocessing.Pipe instance used to send True or False
-       @param data The list of data entries [function_id, maptype, name, mapset]
+       :param lock: A multiprocessing.Lock instance
+       :param conn: A multiprocessing.Pipe instance used to send True or False
+       :param data: The list of data entries [function_id, maptype, name, mapset]
     """
     maptype = data[1]
     name = data[2]
     mapset = data[3]
     if maptype == RPCDefs.TYPE_RASTER:
-         kvp = _read_raster_info(name, mapset)
+        kvp = _read_raster_info(name, mapset)
     elif maptype == RPCDefs.TYPE_VECTOR:
-         kvp = _read_vector_info(name, mapset)
+        kvp = _read_vector_info(name, mapset)
     elif maptype == RPCDefs.TYPE_RASTER3D:
-         kvp = _read_raster3d_info(name, mapset)
+        kvp = _read_raster3d_info(name, mapset)
 
     conn.send(kvp)
 
 ###############################################################################
 
+
 def _read_raster_info(name, mapset):
-    """!Read the raster map info from the file system and store the content
+    """Read the raster map info from the file system and store the content
        into a dictionary
 
        This method uses the ctypes interface to the gis and raster libraries
        to read the map metadata information
 
-       @param name The name of the map
-       @param mapset The mapset of the map
-       @return The key value pairs of the map specific metadata, or None in case of an error
+       :param name: The name of the map
+       :param mapset: The mapset of the map
+       :returns: The key value pairs of the map specific metadata, or None in
+                 case of an error
     """
 
     kvp = {}
@@ -348,16 +456,18 @@
 
 ###############################################################################
 
+
 def _read_raster3d_info(name, mapset):
-    """!Read the 3D raster map info from the file system and store the content
+    """Read the 3D raster map info from the file system and store the content
        into a dictionary
 
        This method uses the ctypes interface to the gis and raster3d libraries
        to read the map metadata information
 
-       @param name The name of the map
-       @param mapset The mapset of the map
-       @return The key value pairs of the map specific metadata, or None in case of an error
+       :param name: The name of the map
+       :param mapset: The mapset of the map
+       :returns: The key value pairs of the map specific metadata, or None in
+                 case of an error
     """
 
     kvp = {}
@@ -408,7 +518,7 @@
     ret = libraster3d.Rast3d_range_load(g3map)
     if not ret:
         logging.error(_("Unable to load range of 3D raster map <%s>" %
-                     (name)))
+                      (name)))
         return None
     libraster3d.Rast3d_range_min_max(g3map, byref(min), byref(max))
 
@@ -429,16 +539,18 @@
 
 ###############################################################################
 
+
 def _read_vector_info(name, mapset):
-    """!Read the vector map info from the file system and store the content
+    """Read the vector map info from the file system and store the content
        into a dictionary
 
        This method uses the ctypes interface to the vector libraries
        to read the map metadata information
 
-       @param name The name of the map
-       @param mapset The mapset of the map
-       @return The key value pairs of the map specific metadata, or None in case of an error
+       :param name: The name of the map
+       :param mapset: The mapset of the map
+       :returns: The key value pairs of the map specific metadata, or None in
+                 case of an error
     """
 
     kvp = {}
@@ -462,7 +574,7 @@
         with_topo = False
         if libvector.Vect_open_old2(byref(Map), name, mapset, "1") < 1:
             logging.error(_("Unable to open vector map <%s>" %
-                         (libvector.Vect_get_full_name(byref(Map)))))
+                          (libvector.Vect_get_full_name(byref(Map)))))
             return None
 
     # Release the vector spatial index memory when closed
@@ -529,18 +641,20 @@
 
 ###############################################################################
 
+
 def _convert_timestamp_from_grass(ts):
-    """!Convert a GRASS file based timestamp into the temporal framework
+    """Convert a GRASS file based timestamp into the temporal framework
        format datetime or integer.
 
-       A tuple of two datetime objects (start, end) is returned in case of absolute time.
+       A tuple of two datetime objects (start, end) is returned in case of
+       absolute time.
        In case of relative time a tuple with start time, end time and the
        relative unit (start, end, unit) will be returned.
 
        Note:
        The end time will be set to None in case of a time instance.
 
-       @param ts grass.lib.gis.TimeStamp object created by G_read_*_timestamp
+       :param ts grass.lib.gis.TimeStamp object created by G_read_*_timestamp
     """
 
     dt1 = libgis.DateTime()
@@ -551,7 +665,7 @@
                             byref(dt1),
                             byref(dt2),
                             byref(count))
-    
+
     if dt1.mode == libdate.DATETIME_ABSOLUTE:
         pdt1 = None
         pdt2 = None
@@ -607,23 +721,28 @@
 
 ###############################################################################
 
+
 def _stop(lock, conn, data):
+    libgis.G_debug(1, "Stop C-interface server")
     conn.close()
     lock.release()
-    libgis.G_debug(1, "Stop C-interface server")
     sys.exit()
 
 ###############################################################################
+# Global server connection
+server_connection = None
+server_lock = None
 
+
 def c_library_server(lock, conn):
-    """!The GRASS C-libraries server function designed to be a target for
+    """The GRASS C-libraries server function designed to be a target for
        multiprocessing.Process
 
-       @param lock A multiprocessing.Lock
-       @param conn A multiprocessing.Pipe
+       :param lock: A multiprocessing.Lock
+       :param conn: A multiprocessing.Pipe
     """
     # Crerate the function array
-    functions = [0]*9
+    functions = [0]*15
     functions[RPCDefs.STOP] = _stop
     functions[RPCDefs.HAS_TIMESTAMP] = _has_timestamp
     functions[RPCDefs.WRITE_TIMESTAMP] = _write_timestamp
@@ -631,7 +750,13 @@
     functions[RPCDefs.REMOVE_TIMESTAMP] = _remove_timestamp
     functions[RPCDefs.READ_MAP_INFO] = _read_map_info
     functions[RPCDefs.MAP_EXISTS] = _map_exists
-    functions[RPCDefs.AVAILABLE_MAPSETS] = available_mapsets
+    functions[RPCDefs.AVAILABLE_MAPSETS] = _available_mapsets
+    functions[RPCDefs.GET_DRIVER_NAME] = _get_driver_name
+    functions[RPCDefs.GET_DATABASE_NAME] = _get_database_name
+    functions[RPCDefs.G_MAPSET] = _get_mapset
+    functions[RPCDefs.G_LOCATION] = _get_location
+    functions[RPCDefs.G_GISDBASE] = _get_gisdbase
+    functions[RPCDefs.G_FATAL_ERROR] = _fatal_error
 
     libgis.G_gisinit("c_library_server")
     libgis.G_debug(1, "Start C-interface server")
@@ -644,8 +769,9 @@
         functions[data[0]](lock, conn, data)
         lock.release()
 
+
 class CLibrariesInterface(object):
-    """!Fast and exit-safe interface to GRASS C-libraries functions
+    """Fast and exit-safe interface to GRASS C-libraries functions
 
        This class implements a fast and exit-safe interface to the GRASS
        gis, raster, 3D raster and vector  C-libraries functions.
@@ -660,129 +786,136 @@
 
        Usage:
 
-       @code
-       >>> import grass.script as grass
-       >>> import grass.temporal as tgis
-       >>> grass.use_temp_region()
-       >>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
-       ... t=1.0, b=0.0, res=10.0, res3=10.0)
-       0
-       >>> tgis.init()
-       >>> grass.run_command("r.mapcalc", expression="test = 1", overwrite=True, quiet=True)
-       0
-       >>> grass.run_command("r3.mapcalc", expression="test = 1", overwrite=True, quiet=True)
-       0
-       >>> grass.run_command("v.random", output="test", n=10, overwrite=True, quiet=True)
-       0
-       >>> grass.run_command("r.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
-       0
-       >>> grass.run_command("r3.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
-       0
-       >>> grass.run_command("v.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
-       0
+       .. code-block:: python
 
-       # Check mapsets
-       >>> ciface = tgis.CLibrariesInterface()
-       >>> mapsets = ciface.available_mapsets()
-       >>> mapsets[0] == tgis.get_current_mapset()
-       True
-       
-       # Raster map
-       >>> ciface = tgis.CLibrariesInterface()
-       >>> check = ciface.raster_map_exists("test", tgis.get_current_mapset())
-       >>> print check
-       True
-       >>> ciface.read_raster_info("test", tgis.get_current_mapset())
-       {'rows': 12, 'north': 80.0, 'min': 1, 'datatype': 'CELL', 'max': 1, 'ewres': 10.0, 'cols': 8, 'west': 0.0, 'east': 120.0, 'nsres': 10.0, 'south': 0.0}
-       >>> check = ciface.has_raster_timestamp("test", tgis.get_current_mapset())
-       >>> print check
-       True
-       >>> if check:
-       ...     res = ciface.read_raster_timestamp("test", tgis.get_current_mapset())
-       ...     if res[0]:
-       ...         print str(res[1][0]), str(res[1][0])
-       ...         ciface.remove_raster_timestamp("test", tgis.get_current_mapset())
-       1995-03-12 10:34:40 1995-03-12 10:34:40
-       1
-       >>> ciface.has_raster_timestamp("test", tgis.get_current_mapset())
-       False
-       >>> ciface.write_raster_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
-       1
-       >>> ciface.has_raster_timestamp("test", tgis.get_current_mapset())
-       True
+           >>> import grass.script as gscript
+           >>> import grass.temporal as tgis
+           >>> gscript.use_temp_region()
+           >>> gscript.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
+           ... t=1.0, b=0.0, res=10.0, res3=10.0)
+           0
+           >>> tgis.init()
+           >>> gscript.run_command("r.mapcalc", expression="test = 1", overwrite=True, quiet=True)
+           0
+           >>> gscript.run_command("r3.mapcalc", expression="test = 1", overwrite=True, quiet=True)
+           0
+           >>> gscript.run_command("v.random", output="test", n=10, overwrite=True, quiet=True)
+           0
+           >>> gscript.run_command("r.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
+           0
+           >>> gscript.run_command("r3.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
+           0
+           >>> gscript.run_command("v.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
+           0
 
+           # Check mapsets
+           >>> ciface = tgis.CLibrariesInterface()
+           >>> mapsets = ciface.available_mapsets()
+           >>> mapsets[0] == tgis.get_current_mapset()
+           True
 
-       # 3D raster map
-       >>> check = ciface.raster3d_map_exists("test", tgis.get_current_mapset())
-       >>> print check
-       True
-       >>> ciface.read_raster3d_info("test", tgis.get_current_mapset())
-       {'tbres': 1.0, 'rows': 12, 'north': 80.0, 'bottom': 0.0, 'datatype': 'DCELL', 'max': 1.0, 'top': 1.0, 'min': 1.0, 'cols': 8, 'depths': 1, 'west': 0.0, 'ewres': 10.0, 'east': 120.0, 'nsres': 10.0, 'south': 0.0}
-       >>> check = ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
-       >>> print check
-       True
-       >>> if check:
-       ...     res = ciface.read_raster3d_timestamp("test", tgis.get_current_mapset())
-       ...     if res[0]:
-       ...         print str(res[1][0]), str(res[1][0])
-       ...         ciface.remove_raster3d_timestamp("test", tgis.get_current_mapset())
-       1995-03-12 10:34:40 1995-03-12 10:34:40
-       1
-       >>> ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
-       False
-       >>> ciface.write_raster3d_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
-       1
-       >>> ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
-       True
+           # Raster map
+           >>> ciface = tgis.CLibrariesInterface()
+           >>> check = ciface.raster_map_exists("test", tgis.get_current_mapset())
+           >>> print check
+           True
+           >>> ciface.read_raster_info("test", tgis.get_current_mapset())
+           {'rows': 12, 'north': 80.0, 'min': 1, 'datatype': 'CELL', 'max': 1, 'ewres': 10.0, 'cols': 8, 'west': 0.0, 'east': 120.0, 'nsres': 10.0, 'south': 0.0}
+           >>> check = ciface.has_raster_timestamp("test", tgis.get_current_mapset())
+           >>> print check
+           True
+           >>> if check:
+           ...     res = ciface.read_raster_timestamp("test", tgis.get_current_mapset())
+           ...     if res[0]:
+           ...         print str(res[1][0]), str(res[1][0])
+           ...         ciface.remove_raster_timestamp("test", tgis.get_current_mapset())
+           1995-03-12 10:34:40 1995-03-12 10:34:40
+           1
+           >>> ciface.has_raster_timestamp("test", tgis.get_current_mapset())
+           False
+           >>> ciface.write_raster_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
+           1
+           >>> ciface.has_raster_timestamp("test", tgis.get_current_mapset())
+           True
 
 
-       # Vector map
-       >>> check = ciface.vector_map_exists("test", tgis.get_current_mapset())
-       >>> print check
-       True
-       >>> kvp = ciface.read_vector_info("test", tgis.get_current_mapset())
-       >>> print kvp['points']
-       10
-       >>> check = ciface.has_vector_timestamp("test", tgis.get_current_mapset(), None)
-       >>> print check
-       True
-       >>> if check:
-       ...     res = ciface.read_vector_timestamp("test", tgis.get_current_mapset())
-       ...     if res[0]:
-       ...         print str(res[1][0]), str(res[1][0])
-       ...         ciface.remove_vector_timestamp("test", tgis.get_current_mapset())
-       1995-03-12 10:34:40 1995-03-12 10:34:40
-       1
-       >>> ciface.has_vector_timestamp("test", tgis.get_current_mapset())
-       False
-       >>> ciface.write_vector_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
-       1
-       >>> ciface.has_vector_timestamp("test", tgis.get_current_mapset())
-       True
+           # 3D raster map
+           >>> check = ciface.raster3d_map_exists("test", tgis.get_current_mapset())
+           >>> print check
+           True
+           >>> ciface.read_raster3d_info("test", tgis.get_current_mapset())
+           {'tbres': 1.0, 'rows': 12, 'north': 80.0, 'bottom': 0.0, 'datatype': 'DCELL', 'max': 1.0, 'top': 1.0, 'min': 1.0, 'cols': 8, 'depths': 1, 'west': 0.0, 'ewres': 10.0, 'east': 120.0, 'nsres': 10.0, 'south': 0.0}
+           >>> check = ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
+           >>> print check
+           True
+           >>> if check:
+           ...     res = ciface.read_raster3d_timestamp("test", tgis.get_current_mapset())
+           ...     if res[0]:
+           ...         print str(res[1][0]), str(res[1][0])
+           ...         ciface.remove_raster3d_timestamp("test", tgis.get_current_mapset())
+           1995-03-12 10:34:40 1995-03-12 10:34:40
+           1
+           >>> ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
+           False
+           >>> ciface.write_raster3d_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
+           1
+           >>> ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
+           True
 
-       >>> grass.del_temp_region()
 
-       @endcode
+           # Vector map
+           >>> check = ciface.vector_map_exists("test", tgis.get_current_mapset())
+           >>> print check
+           True
+           >>> kvp = ciface.read_vector_info("test", tgis.get_current_mapset())
+           >>> print kvp['points']
+           10
+           >>> check = ciface.has_vector_timestamp("test", tgis.get_current_mapset(), None)
+           >>> print check
+           True
+           >>> if check:
+           ...     res = ciface.read_vector_timestamp("test", tgis.get_current_mapset())
+           ...     if res[0]:
+           ...         print str(res[1][0]), str(res[1][0])
+           ...         ciface.remove_vector_timestamp("test", tgis.get_current_mapset())
+           1995-03-12 10:34:40 1995-03-12 10:34:40
+           1
+           >>> ciface.has_vector_timestamp("test", tgis.get_current_mapset())
+           False
+           >>> ciface.write_vector_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
+           1
+           >>> ciface.has_vector_timestamp("test", tgis.get_current_mapset())
+           True
+
+           >>> ciface.get_driver_name()
+           'sqlite'
+           >>> ciface.get_database_name().split("/")[-1]
+           'sqlite.db'
+
+           >>> mapset = ciface.get_mapset()
+           >>> location = ciface.get_location()
+           >>> gisdbase = ciface.get_gisdbase()
+
+           >>> gscript.del_temp_region()
+
     """
     def __init__(self):
         self.client_conn = None
         self.server_conn = None
+        self.queue = None
         self.server = None
         self.start_server()
 
-    def __del__(self):
-        self.stop()
-
     def start_server(self):
-        self.client_conn, self.server_conn = Pipe()
+        self.client_conn, self.server_conn = Pipe(True)
         self.lock = Lock()
         self.server = Process(target=c_library_server, args=(self.lock,
-                                                          self.server_conn))
+                                                             self.server_conn))
         self.server.daemon = True
         self.server.start()
 
     def _check_restart_server(self):
-        """!Restart the server if it was terminated
+        """Restart the server if it was terminated
         """
         if self.server.is_alive() is True:
             return
@@ -792,11 +925,11 @@
         logging.warning("Needed to restart the libgis server")
 
     def raster_map_exists(self, name, mapset):
-        """!Check if a raster map exists in the spatial database
+        """Check if a raster map exists in the spatial database
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return True if exists, False if not
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: True if exists, False if not
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.MAP_EXISTS, RPCDefs.TYPE_RASTER,
@@ -804,12 +937,13 @@
         return self.client_conn.recv()
 
     def read_raster_info(self, name, mapset):
-        """!Read the raster map info from the file system and store the content
+        """Read the raster map info from the file system and store the content
            into a dictionary
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return The key value pairs of the map specific metadata, or None in case of an error
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: The key value pairs of the map specific metadata,
+                     or None in case of an error
         """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.READ_MAP_INFO, RPCDefs.TYPE_RASTER,
@@ -817,11 +951,11 @@
         return self.client_conn.recv()
 
     def has_raster_timestamp(self, name, mapset):
-        """!Check if a file based raster timetamp exists
+        """Check if a file based raster timetamp exists
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return True if exists, False if not
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: True if exists, False if not
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.HAS_TIMESTAMP, RPCDefs.TYPE_RASTER,
@@ -829,14 +963,14 @@
         return self.client_conn.recv()
 
     def remove_raster_timestamp(self, name, mapset):
-        """!Remove a file based raster timetamp
+        """Remove a file based raster timetamp
 
            Please have a look at the documentation G_remove_raster_timestamp
            for the return values description.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return The return value of G_remove_raster_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: The return value of G_remove_raster_timestamp
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.REMOVE_TIMESTAMP, RPCDefs.TYPE_RASTER,
@@ -844,7 +978,7 @@
         return self.client_conn.recv()
 
     def read_raster_timestamp(self, name, mapset):
-        """!Read a file based raster timetamp
+        """Read a file based raster timetamp
 
            Please have a look at the documentation G_read_raster_timestamp
            for the return values description.
@@ -856,9 +990,9 @@
 
            The end time may be None in case of a time instance.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return The return value of G_read_raster_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: The return value of G_read_raster_timestamp
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.READ_TIMESTAMP, RPCDefs.TYPE_RASTER,
@@ -866,7 +1000,7 @@
         return self.client_conn.recv()
 
     def write_raster_timestamp(self, name, mapset, timestring):
-        """!Write a file based raster timetamp
+        """Write a file based raster timetamp
 
            Please have a look at the documentation G_write_raster_timestamp
            for the return values description.
@@ -874,10 +1008,10 @@
            Note:
                Only timestamps of maps from the current mapset can written.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @param timestring A GRASS datetime C-library compatible string
-           @return The return value of G_write_raster_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :param timestring: A GRASS datetime C-library compatible string
+           :returns: The return value of G_write_raster_timestamp
         """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.WRITE_TIMESTAMP, RPCDefs.TYPE_RASTER,
@@ -885,11 +1019,11 @@
         return self.client_conn.recv()
 
     def raster3d_map_exists(self, name, mapset):
-        """!Check if a 3D raster map exists in the spatial database
+        """Check if a 3D raster map exists in the spatial database
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return True if exists, False if not
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: True if exists, False if not
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.MAP_EXISTS, RPCDefs.TYPE_RASTER3D,
@@ -897,12 +1031,13 @@
         return self.client_conn.recv()
 
     def read_raster3d_info(self, name, mapset):
-        """!Read the 3D raster map info from the file system and store the content
+        """Read the 3D raster map info from the file system and store the content
            into a dictionary
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return The key value pairs of the map specific metadata, or None in case of an error
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: The key value pairs of the map specific metadata,
+                     or None in case of an error
         """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.READ_MAP_INFO, RPCDefs.TYPE_RASTER3D,
@@ -910,11 +1045,11 @@
         return self.client_conn.recv()
 
     def has_raster3d_timestamp(self, name, mapset):
-        """!Check if a file based 3D raster timetamp exists
+        """Check if a file based 3D raster timetamp exists
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return True if exists, False if not
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: True if exists, False if not
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.HAS_TIMESTAMP, RPCDefs.TYPE_RASTER3D,
@@ -922,14 +1057,14 @@
         return self.client_conn.recv()
 
     def remove_raster3d_timestamp(self, name, mapset):
-        """!Remove a file based 3D raster timetamp
+        """Remove a file based 3D raster timetamp
 
            Please have a look at the documentation G_remove_raster3d_timestamp
            for the return values description.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return The return value of G_remove_raster3d_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: The return value of G_remove_raster3d_timestamp
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.REMOVE_TIMESTAMP, RPCDefs.TYPE_RASTER3D,
@@ -937,7 +1072,7 @@
         return self.client_conn.recv()
 
     def read_raster3d_timestamp(self, name, mapset):
-        """!Read a file based 3D raster timetamp
+        """Read a file based 3D raster timetamp
 
            Please have a look at the documentation G_read_raster3d_timestamp
            for the return values description.
@@ -949,9 +1084,9 @@
 
            The end time may be None in case of a time instance.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return The return value of G_read_raster3d_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: The return value of G_read_raster3d_timestamp
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.READ_TIMESTAMP, RPCDefs.TYPE_RASTER3D,
@@ -959,7 +1094,7 @@
         return self.client_conn.recv()
 
     def write_raster3d_timestamp(self, name, mapset, timestring):
-        """!Write a file based 3D raster timetamp
+        """Write a file based 3D raster timetamp
 
            Please have a look at the documentation G_write_raster3d_timestamp
            for the return values description.
@@ -967,10 +1102,10 @@
            Note:
                Only timestamps of maps from the current mapset can written.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @param timestring A GRASS datetime C-library compatible string
-           @return The return value of G_write_raster3d_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :param timestring: A GRASS datetime C-library compatible string
+           :returns: The return value of G_write_raster3d_timestamp
         """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.WRITE_TIMESTAMP, RPCDefs.TYPE_RASTER3D,
@@ -978,11 +1113,11 @@
         return self.client_conn.recv()
 
     def vector_map_exists(self, name, mapset):
-        """!Check if a vector map exists in the spatial database
+        """Check if a vector map exists in the spatial database
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return True if exists, False if not
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: True if exists, False if not
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.MAP_EXISTS, RPCDefs.TYPE_VECTOR,
@@ -990,12 +1125,13 @@
         return self.client_conn.recv()
 
     def read_vector_info(self, name, mapset):
-        """!Read the vector map info from the file system and store the content
+        """Read the vector map info from the file system and store the content
            into a dictionary
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @return The key value pairs of the map specific metadata, or None in case of an error
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :returns: The key value pairs of the map specific metadata,
+                     or None in case of an error
         """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.READ_MAP_INFO, RPCDefs.TYPE_VECTOR,
@@ -1003,12 +1139,12 @@
         return self.client_conn.recv()
 
     def has_vector_timestamp(self, name, mapset, layer=None):
-        """!Check if a file based vector timetamp exists
+        """Check if a file based vector timetamp exists
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @param layer The layer of the vector map
-           @return True if exists, False if not
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :param layer: The layer of the vector map
+           :returns: True if exists, False if not
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.HAS_TIMESTAMP, RPCDefs.TYPE_VECTOR,
@@ -1016,15 +1152,15 @@
         return self.client_conn.recv()
 
     def remove_vector_timestamp(self, name, mapset, layer=None):
-        """!Remove a file based vector timetamp
+        """Remove a file based vector timetamp
 
            Please have a look at the documentation G_remove_vector_timestamp
            for the return values description.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @param layer The layer of the vector map
-           @return The return value of G_remove_vector_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :param layer: The layer of the vector map
+           :returns: The return value of G_remove_vector_timestamp
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.REMOVE_TIMESTAMP, RPCDefs.TYPE_VECTOR,
@@ -1032,7 +1168,7 @@
         return self.client_conn.recv()
 
     def read_vector_timestamp(self, name, mapset, layer=None):
-        """!Read a file based vector timetamp
+        """Read a file based vector timetamp
 
            Please have a look at the documentation G_read_vector_timestamp
            for the return values description.
@@ -1044,10 +1180,10 @@
 
            The end time may be None in case of a time instance.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @param layer The layer of the vector map
-           @return The return value ofG_read_vector_timestamp and the timestamps
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :param layer: The layer of the vector map
+           :returns: The return value ofG_read_vector_timestamp and the timestamps
        """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.READ_TIMESTAMP, RPCDefs.TYPE_VECTOR,
@@ -1055,7 +1191,7 @@
         return self.client_conn.recv()
 
     def write_vector_timestamp(self, name, mapset, timestring, layer=None):
-        """!Write a file based vector timetamp
+        """Write a file based vector timestamp
 
            Please have a look at the documentation G_write_vector_timestamp
            for the return values description.
@@ -1063,11 +1199,11 @@
            Note:
                Only timestamps pf maps from the current mapset can written.
 
-           @param name The name of the map
-           @param mapset The mapset of the map
-           @param timestring A GRASS datetime C-library compatible string
-           @param layer The layer of the vector map
-           @return The return value of G_write_vector_timestamp
+           :param name: The name of the map
+           :param mapset: The mapset of the map
+           :param timestring: A GRASS datetime C-library compatible string
+           :param layer: The layer of the vector map
+           :returns: The return value of G_write_vector_timestamp
         """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.WRITE_TIMESTAMP, RPCDefs.TYPE_VECTOR,
@@ -1075,23 +1211,80 @@
         return self.client_conn.recv()
 
     def available_mapsets(self):
-        """!Return all available mapsets the user can access as a list of strings
-        
-           @param lock A multiprocessing.Lock instance
-           @param conn A multiprocessing.Pipe instance used to send True or False
-           @param data Can be None
-           
-           @return Names of available mapsets as list of strings
+        """Return all available mapsets the user can access as a list of strings
+
+           :returns: Names of available mapsets as list of strings
         """
         self._check_restart_server()
         self.client_conn.send([RPCDefs.AVAILABLE_MAPSETS, ])
         return self.client_conn.recv()
 
+    def get_driver_name(self, mapset=None):
+        """Return the temporal database driver of a specific mapset
+
+           :param mapset: Name of the mapset
+
+           :returns: Name of the driver or None if no temporal database present
+        """
+        self._check_restart_server()
+        self.client_conn.send([RPCDefs.GET_DRIVER_NAME, mapset])
+        return self.client_conn.recv()
+
+    def get_database_name(self, mapset=None):
+        """Return the temporal database name of a specific mapset
+
+           :param mapset: Name of the mapset
+
+           :returns: Name of the database or None if no temporal database present
+        """
+        self._check_restart_server()
+        self.client_conn.send([RPCDefs.GET_DATABASE_NAME, mapset])
+        return self.client_conn.recv()
+
+    def get_mapset(self):
+        """Return the current mapset
+
+           :returns: Name of the current mapset
+        """
+        self._check_restart_server()
+        self.client_conn.send([RPCDefs.G_MAPSET, ])
+        return self.client_conn.recv()
+
+    def get_location(self):
+        """Return the location
+
+           :returns: Name of the location
+        """
+        self._check_restart_server()
+        self.client_conn.send([RPCDefs.G_LOCATION, ])
+        return self.client_conn.recv()
+
+    def get_gisdbase(self):
+        """Return the gisdatabase
+
+           :returns: Name of the gisdatabase
+        """
+        self._check_restart_server()
+        self.client_conn.send([RPCDefs.G_GISDBASE, ])
+        return self.client_conn.recv()
+
+    def fatal_error(self, mapset=None):
+        """Return the temporal database name of a specific mapset
+
+           :param mapset: Name of the mapset
+
+           :returns: Name of the database or None if no temporal database present
+        """
+        self._check_restart_server()
+        self.client_conn.send([RPCDefs.G_FATAL_ERROR])
+
     def stop(self):
-        """!Stop the messenger server and close the pipe
+        """Stop the messenger server and close the pipe
+
+           This method should be called at exit using the package atexit
         """
         if self.server is not None and self.server.is_alive():
-            self.client_conn.send([0,])
+            self.client_conn.send([0, ])
             self.server.join(5)
             self.server.terminate()
         if self.client_conn is not None:

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/core.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/core.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/core.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,47 +1,39 @@
-"""!@package grass.temporal
-
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS core functions to be used in library modules and scripts.
-
+"""
 This module provides the functionality to create the temporal
 SQL database and to establish a connection to the database.
 
 Usage:
 
- at code
+.. code-block:: python
 
->>> import grass.temporal as tgis
->>> # Create the temporal database
->>> tgis.init()
->>> # Establish a database connection
->>> dbif, connected = tgis.init_dbif(None)
->>> dbif.connect()
->>> # Execute a SQL statement
->>> dbif.execute_transaction("SELECT datetime(0, 'unixepoch', 'localtime');")
->>> # Mogrify an SQL statement
->>> dbif.mogrify_sql_statement(["SELECT name from raster_base where name = ?",
-... ("precipitation",)])
-"SELECT name from raster_base where name = 'precipitation'"
->>> dbif.close()
+    >>> import grass.temporal as tgis
+    >>> # Create the temporal database
+    >>> tgis.init()
+    >>> # Establish a database connection
+    >>> dbif, connected = tgis.init_dbif(None)
+    >>> dbif.connect()
+    >>> # Execute a SQL statement
+    >>> dbif.execute_transaction("SELECT datetime(0, 'unixepoch', 'localtime');")
+    >>> # Mogrify an SQL statement
+    >>> dbif.mogrify_sql_statement(["SELECT name from raster_base where name = ?",
+    ... ("precipitation",)])
+    "SELECT name from raster_base where name = 'precipitation'"
+    >>> dbif.close()
 
- at endcode
 
 (C) 2011-2014 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:author: Soeren Gebbert
 """
-import sys, traceback
 import os
-import locale
 # i18N
 import gettext
 gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
 
-import grass.script.core as core
+import grass.script as gscript
 from datetime import datetime
 from c_libraries_interface import *
 # Import all supported database backends
@@ -61,8 +53,9 @@
 
 ###############################################################################
 
-# Profiling function provided by the temporal framework
+
 def profile_function(func):
+    """Profiling function provided by the temporal framework"""
     do_profiling = os.getenv("GRASS_TGIS_PROFILE")
 
     if do_profiling is "True" or do_profiling is "1":
@@ -83,10 +76,12 @@
 # of the temporal GIS
 # It can either be "sqlite" or "pg"
 tgis_backend = None
+
+
 def get_tgis_backend():
-    """!Return the temporal GIS backend as string
+    """Return the temporal GIS backend as string
 
-       return either "sqlite" or "pg"
+       :returns: either "sqlite" or "pg"
     """
     global tgis_backend
     return tgis_backend
@@ -94,8 +89,10 @@
 # Global variable that defines the database string
 # of the temporal GIS
 tgis_database = None
+
+
 def get_tgis_database():
-    """!Return the temporal database string specified with t.connect
+    """Return the temporal database string specified with t.connect
     """
     global tgis_database
     return tgis_database
@@ -103,20 +100,21 @@
 # The version of the temporal framework
 # this value must be an integer larger than 0
 # Increase this value in case of backward incompatible changes in the TGIS API
-tgis_version=2
-# The version of the temporal database since framework and database version can differ
-# this value must be an integer larger than 0
+tgis_version = 2
+# The version of the temporal database since framework and database version
+# can differ this value must be an integer larger than 0
 # Increase this value in case of backward incompatible changes
 # temporal database SQL layout
-tgis_db_version=2
+tgis_db_version = 2
 
 # We need to know the parameter style of the database backend
 tgis_dbmi_paramstyle = None
 
+
 def get_tgis_dbmi_paramstyle():
-    """!Return the temporal database backend parameter style
+    """Return the temporal database backend parameter style
 
-       @return "qmark" or ""
+       :returns: "qmark" or ""
     """
     global tgis_dbmi_paramstyle
     return tgis_dbmi_paramstyle
@@ -129,8 +127,9 @@
 
 ###############################################################################
 
+
 def get_current_mapset():
-    """!Return the current mapset
+    """Return the current mapset
 
        This is the fastest way to receive the current mapset.
        The current mapset is set by init() and stored in a global variable.
@@ -141,8 +140,9 @@
 
 ###############################################################################
 
+
 def get_current_location():
-    """!Return the current location
+    """Return the current location
 
        This is the fastest way to receive the current location.
        The current location is set by init() and stored in a global variable.
@@ -153,8 +153,9 @@
 
 ###############################################################################
 
+
 def get_current_gisdbase():
-    """!Return the current gis database (gisdbase)
+    """Return the current gis database (gisdbase)
 
        This is the fastest way to receive the current gisdbase.
        The current gisdbase is set by init() and stored in a global variable.
@@ -165,48 +166,60 @@
 
 ###############################################################################
 
-# If this global variable is set True, then maps can only be registered in space time datasets
-# with the same mapset. In addition, only maps in the current mapset can be inserted, updated or deleted from
-# the temporal database.
+# If this global variable is set True, then maps can only be registered in
+# space time datasets with the same mapset. In addition, only maps in the
+# current mapset can be inserted, updated or deleted from the temporal database.
 # Overwrite this global variable by: g.gisenv set="TGIS_DISABLE_MAPSET_CHECK=True"
-# ATTENTION: Be aware to face corrupted temporal database in case this global variable is set to False.
-#            This feature is highly experimental and violates the grass permission guidance.
+# ATTENTION: Be aware to face corrupted temporal database in case this global
+#            variable is set to False. This feature is highly
+#            experimental and violates the grass permission guidance.
 enable_mapset_check = True
-# If this global variable is set True, the timestamps of maps will be written as textfiles
-# for each map that will be inserted or updated in the temporal database using the C-library
-# timestamp interface.
+# If this global variable is set True, the timestamps of maps will be written
+# as textfiles for each map that will be inserted or updated in the temporal
+# database using the C-library timestamp interface.
 # Overwrite this global variable by: g.gisenv set="TGIS_DISABLE_TIMESTAMP_WRITE=True"
-# ATTENTION: Be aware to face corrupted temporal database in case this global variable is set to False.
-#            This feature is highly experimental and violates the grass permission guidance.
+# ATTENTION: Be aware to face corrupted temporal database in case this global
+#            variable is set to False. This feature is highly
+#            experimental and violates the grass permission guidance.
 enable_timestamp_write = True
 
+
 def get_enable_mapset_check():
-    """!Return True if the mapsets should be checked while insert, updatem delete requests
-       and space time dataset registration.
+    """Return True if the mapsets should be checked while insert, update,
+       delete requests and space time dataset registration.
 
-       If this global variable is set True, then maps can only be registered in space time datasets
-       with the same mapset. In addition, only maps in the current mapset can be inserted, updated or deleted from
-       the temporal database.
+       If this global variable is set True, then maps can only be registered
+       in space time datasets with the same mapset. In addition, only maps in
+       the current mapset can be inserted, updated or deleted from the temporal
+       database.
        Overwrite this global variable by: g.gisenv set="TGIS_DISABLE_MAPSET_CHECK=True"
 
-       ATTENTION: Be aware to face corrupted temporal database in case this global variable is set to False.
-                  This feature is highly experimental and violates the grass permission guidance.
+       ..warning::
+
+           Be aware to face corrupted temporal database in case this
+           global variable is set to False. This feature is highly
+           experimental and violates the grass permission guidance.
+
     """
     global enable_mapset_check
     return enable_mapset_check
 
+
 def get_enable_timestamp_write():
-    """!Return True if the map timestamps should be written to the spatial database metadata as well.
+    """Return True if the map timestamps should be written to the spatial
+       database metadata as well.
 
-       If this global variable is set True, the timestamps of maps will be written as textfiles
-       for each map that will be inserted or updated in the temporal database using the C-library
-       timestamp interface.
+       If this global variable is set True, the timestamps of maps will be
+       written as textfiles for each map that will be inserted or updated in
+       the temporal database using the C-library timestamp interface.
        Overwrite this global variable by: g.gisenv set="TGIS_DISABLE_TIMESTAMP_WRITE=True"
 
-       ATTENTION: Be aware that C-libraries can not access timestamp informations if they are not
-                  written as spatial database metadata, hence modules that make use of timestamps
-                  using the C-library interface will not work with maps that were created without
-                  writing the timestamps.
+       ..warning::
+
+           Be aware that C-libraries can not access timestamp informations if
+           they are not written as spatial database metadata, hence modules
+           that make use of timestamps using the C-library interface will not
+           work with maps that were created without writing the timestamps.
     """
     global enable_timestamp_write
     return enable_timestamp_write
@@ -215,20 +228,22 @@
 
 # The global variable that stores the PyGRASS Messenger object that
 # provides a fast and exit safe interface to the C-library message functions
-message_interface=None
+message_interface = None
 
+
 def _init_tgis_message_interface(raise_on_error=False):
-    """!Initiate the global mesage interface
+    """Initiate the global mesage interface
 
-       @param raise_on_error If True raise a FatalError exception in case of a fatal error,
-                             call sys.exit(1) otherwise
+       :param raise_on_error: If True raise a FatalError exception in case of
+                              a fatal error, call sys.exit(1) otherwise
     """
     global message_interface
     from grass.pygrass import messages
     message_interface = messages.get_msgr(raise_on_error=raise_on_error)
 
+
 def get_tgis_message_interface():
-    """!Return the temporal GIS message interface which is of type
+    """Return the temporal GIS message interface which is of type
        grass.pygrass.message.Messenger()
 
        Use this message interface to print messages to stdout using the
@@ -242,18 +257,20 @@
 # The global variable that stores the C-library interface object that
 # provides a fast and exit safe interface to the C-library libgis,
 # libraster, libraster3d and libvector functions
-c_library_interface=None
+c_library_interface = None
 
+
 def _init_tgis_c_library_interface():
-    """!Set the global C-library interface variable that
+    """Set the global C-library interface variable that
        provides a fast and exit safe interface to the C-library libgis,
        libraster, libraster3d and libvector functions
     """
     global c_library_interface
     c_library_interface = CLibrariesInterface()
 
+
 def get_tgis_c_library_interface():
-    """!Return the C-library interface that
+    """Return the C-library interface that
        provides a fast and exit safe interface to the C-library libgis,
        libraster, libraster3d and libvector functions
     """
@@ -266,40 +283,39 @@
 # in case a fatal error occurs using the messenger interface
 raise_on_error = False
 
+
 def set_raise_on_error(raise_exp=True):
-    """!Define behavior on fatal error, invoked using the tgis messenger
+    """Define behavior on fatal error, invoked using the tgis messenger
     interface (msgr.fatal())
 
     The messenger interface will be restarted using the new error policy
 
-    @param raise_exp True to raise a FatalError exception instead of calling
-    sys.exit(1) when using the tgis messenger interface
+    :param raise_exp: True to raise a FatalError exception instead of calling
+                      sys.exit(1) when using the tgis messenger interface
 
-    @code
+    .. code-block:: python
 
-    >>> import grass.temporal as tgis
-    >>> tgis.init()
-    >>> ignore = tgis.set_raise_on_error(False)
-    >>> msgr = tgis.get_tgis_message_interface()
-    >>> tgis.get_raise_on_error()
-    False
-    >>> msgr.fatal("Ohh no no no!")
-    Traceback (most recent call last):
-      File "__init__.py", line 239, in fatal
-        sys.exit(1)
-    SystemExit: 1
+        >>> import grass.temporal as tgis
+        >>> tgis.init()
+        >>> ignore = tgis.set_raise_on_error(False)
+        >>> msgr = tgis.get_tgis_message_interface()
+        >>> tgis.get_raise_on_error()
+        False
+        >>> msgr.fatal("Ohh no no no!")
+        Traceback (most recent call last):
+          File "__init__.py", line 239, in fatal
+            sys.exit(1)
+        SystemExit: 1
 
-    >>> tgis.set_raise_on_error(True)
-    False
-    >>> msgr.fatal("Ohh no no no!")
-    Traceback (most recent call last):
-      File "__init__.py", line 241, in fatal
-        raise FatalError(message)
-    FatalError: Ohh no no no!
+        >>> tgis.set_raise_on_error(True)
+        False
+        >>> msgr.fatal("Ohh no no no!")
+        Traceback (most recent call last):
+          File "__init__.py", line 241, in fatal
+            raise FatalError(message)
+        FatalError: Ohh no no no!
 
-    @endcode
-
-    @return current status
+    :returns: current status
     """
     global raise_on_error
     tmp_raise = raise_on_error
@@ -315,7 +331,7 @@
 
 
 def get_raise_on_error():
-    """!Return True if a FatalError exception is raised instead of calling
+    """Return True if a FatalError exception is raised instead of calling
        sys.exit(1) in case a fatal error was invoked with msgr.fatal()
     """
     global raise_on_error
@@ -324,30 +340,33 @@
 
 ###############################################################################
 
+
 def get_tgis_version():
-    """!Get the verion number of the temporal framework
-       @return The version number of the temporal framework as string
+    """Get the version number of the temporal framework
+       :returns: The version number of the temporal framework as string
     """
     global tgis_version
     return tgis_version
 
 ###############################################################################
 
+
 def get_tgis_db_version():
-    """!Get the verion number of the temporal framework
-       @return The version number of the temporal framework as string
+    """Get the version number of the temporal framework
+       :returns: The version number of the temporal framework as string
     """
     global tgis_db_version
     return tgis_db_version
 
 ###############################################################################
 
+
 def get_tgis_metadata(dbif=None):
-    """!Return the tgis metadata table as a list of rows (dicts)
-               or None if not present
+    """Return the tgis metadata table as a list of rows (dicts) or None if not
+       present
 
-       @param dbif The database interface to be used
-       @return The selected rows with key/value comumns or None
+       :param dbif: The database interface to be used
+       :returns: The selected rows with key/value columns or None
     """
 
     dbif, connected = init_dbif(dbif)
@@ -355,8 +374,8 @@
     # Select metadata if the table is present
     try:
         statement = "SELECT * FROM tgis_metadata;\n"
-        dbif.cursor.execute(statement)
-        rows = dbif.cursor.fetchall()
+        dbif.execute(statement)
+        rows = dbif.fetchall()
     except:
         rows = None
 
@@ -371,8 +390,9 @@
 # with substituted GRASS variables gisdbase, location and mapset
 tgis_database_string = None
 
+
 def get_tgis_database_string():
-    """!Return the preprocessed temporal database string
+    """Return the preprocessed temporal database string
 
        This string is the temporal database string set with t.connect
        that was processed to substitue location, gisdbase and mapset
@@ -383,6 +403,7 @@
 
 ###############################################################################
 
+
 def get_sql_template_path():
     base = os.getenv("GISBASE")
     base_etc = os.path.join(base, "etc")
@@ -390,8 +411,9 @@
 
 ###############################################################################
 
+
 def stop_subprocesses():
-    """!Stop the messenger and C-interface subprocesses
+    """Stop the messenger and C-interface subprocesses
        that are started by tgis.init()
     """
     global message_interface
@@ -404,41 +426,73 @@
 # We register this function to be called at exit
 atexit.register(stop_subprocesses)
 
+
+def get_available_temporal_mapsets():
+    """Return a list of of mapset names with temporal database driver and names
+        that are accessable from the current mapset.
+
+        :returns: A dictionary, mapset names are keys, the tuple (driver,
+                  database) are the values
+    """
+    global c_library_interface
+
+    mapsets = c_library_interface.available_mapsets()
+
+    tgis_mapsets = {}
+
+    for mapset in mapsets:
+        driver = c_library_interface.get_driver_name(mapset)
+        database = c_library_interface.get_database_name(mapset)
+
+        if driver and database:
+            tgis_mapsets[mapset] = (driver,  database)
+
+    return tgis_mapsets
+
 ###############################################################################
 
+
 def init(raise_fatal_error=False):
-    """!This function set the correct database backend from GRASS environmental variables
-       and creates the grass temporal database structure for raster,
+    """This function set the correct database backend from GRASS environmental
+       variables and creates the grass temporal database structure for raster,
        vector and raster3d maps as well as for the space-time datasets strds,
        str3ds and stvds in case it does not exists.
 
-       Several global variables are initiated and the messenger and C-library interface
-       subprocesses are spawned.
+       Several global variables are initiated and the messenger and C-library
+       interface subprocesses are spawned.
 
-       Re-run this function in case the following GRASS variables change while the process runs:
+       Re-run this function in case the following GRASS variables change while
+       the process runs:
+
        - MAPSET
        - LOCATION_NAME
        - GISDBASE
        - TGIS_DISABLE_MAPSET_CHECK
        - TGIS_DISABLE_TIMESTAMP_WRITE
 
-       Re-run the script if the following t.connect variables change while the process runs:
+       Re-run this function if the following t.connect variables change while
+       the process runs:
+
        - temporal GIS driver (set by t.connect driver=)
        - temporal GIS database (set by t.connect database=)
 
        The following environmental variables are checked:
+
         - GRASS_TGIS_PROFILE (True, False, 1, 0)
         - GRASS_TGIS_RAISE_ON_ERROR (True, False, 1, 0)
 
-        ATTENTION: This functions must be called before any spatio-temporal processing
-                   can be started
+        ..warning::
 
-        @param raise_fatal_error Set this True to assure that the init() function
-                                 does not kill a persistent process like the GUI.
+            This functions must be called before any spatio-temporal processing
+            can be started
 
-                                 If set True a grass.pygrass.messages.FatalError
-                                 exception will be raised in case a fatal error occurs
-                                 in the init process, otherwise sys.exit(1) will be called.
+        :param raise_fatal_error: Set this True to assure that the init()
+                                  function does not kill a persistent process
+                                  like the GUI. If set True a
+                                  grass.pygrass.messages.FatalError
+                                  exception will be raised in case a fatal
+                                  error occurs in the init process, otherwise
+                                  sys.exit(1) will be called.
     """
     # We need to set the correct database backend and several global variables
     # from the GRASS mapset specific environment variables of g.gisenv and t.connect
@@ -457,9 +511,8 @@
 
     # We must run t.connect at first to create the temporal database and to
     # get the environmental variables
-    core.run_command("t.connect", flags="c")
-    kv = core.parse_command("t.connect", flags="pg")
-    grassenv = core.gisenv()
+    gscript.run_command("t.connect", flags="c")
+    grassenv = gscript.gisenv()
 
     # Set the global variable for faster access
     current_mapset = grassenv["MAPSET"]
@@ -467,12 +520,13 @@
     current_gisdbase = grassenv["GISDBASE"]
 
     # Check environment variable GRASS_TGIS_RAISE_ON_ERROR
-    if os.getenv("GRASS_TGIS_RAISE_ON_ERROR") == "True" or os.getenv("GRASS_TGIS_RAISE_ON_ERROR") == "1":
+    if os.getenv("GRASS_TGIS_RAISE_ON_ERROR") == "True" or \
+       os.getenv("GRASS_TGIS_RAISE_ON_ERROR") == "1":
         raise_on_error = True
 
     # Check if the script library raises on error,
     # if so we do the same
-    if core.get_raise_on_error() is True:
+    if gscript.get_raise_on_error() is True:
         raise_on_error = True
 
     # Start the GRASS message interface server
@@ -482,60 +536,58 @@
     msgr = get_tgis_message_interface()
     msgr.debug(1, "Initiate the temporal database")
 
+    ciface = get_tgis_c_library_interface()
+    driver_string = ciface.get_driver_name()
+    database_string = ciface.get_database_name()
+
     # Set the mapset check and the timestamp write
     if grassenv.has_key("TGIS_DISABLE_MAPSET_CHECK"):
-        if grassenv["TGIS_DISABLE_MAPSET_CHECK"] == "True" or grassenv["TGIS_DISABLE_MAPSET_CHECK"] == "1":
+        if grassenv["TGIS_DISABLE_MAPSET_CHECK"] == "True" or \
+           grassenv["TGIS_DISABLE_MAPSET_CHECK"] == "1":
             enable_mapset_check = False
             msgr.warning("TGIS_DISABLE_MAPSET_CHECK is True")
 
     if grassenv.has_key("TGIS_DISABLE_TIMESTAMP_WRITE"):
-        if grassenv["TGIS_DISABLE_TIMESTAMP_WRITE"] == "True" or grassenv["TGIS_DISABLE_TIMESTAMP_WRITE"] == "1":
+        if grassenv["TGIS_DISABLE_TIMESTAMP_WRITE"] == "True" or \
+           grassenv["TGIS_DISABLE_TIMESTAMP_WRITE"] == "1":
             enable_timestamp_write = False
             msgr.warning("TGIS_DISABLE_TIMESTAMP_WRITE is True")
 
-    if "driver" in kv:
-        if kv["driver"] == "sqlite":
-            tgis_backend = kv["driver"]
+    if driver_string is not None and driver_string is not "":
+        if driver_string == "sqlite":
+            tgis_backend = driver_string
             try:
                 import sqlite3
             except ImportError:
-                msgr.error("Unable to locate the sqlite SQL Python interface module sqlite3.")
+                msgr.error("Unable to locate the sqlite SQL Python interface"
+                           " module sqlite3.")
                 raise
             dbmi = sqlite3
-        elif kv["driver"] == "pg":
-            tgis_backend = kv["driver"]
+        elif driver_string == "pg":
+            tgis_backend = driver_string
             try:
                 import psycopg2
             except ImportError:
-                msgr.error("Unable to locate the Postgresql SQL Python interface module psycopg2.")
+                msgr.error("Unable to locate the Postgresql SQL Python "
+                           "interface module psycopg2.")
                 raise
             dbmi = psycopg2
         else:
-            msgr.fatal(_("Unable to initialize the temporal DBMI interface. Please use "
-                         "t.connect to specify the driver and the database string"))
-            dbmi = sqlite3
+            msgr.fatal(_("Unable to initialize the temporal DBMI interface. "
+                         "Please use t.connect to specify the driver and the"
+                         " database string"))
     else:
         # Set the default sqlite3 connection in case nothing was defined
-        core.run_command("t.connect", flags="d")
-        kv = core.parse_command("t.connect", flags="pg")
-        tgis_backend = kv["driver"]
+        gscript.run_command("t.connect", flags="d")
+        driver_string = ciface.get_driver_name()
+        database_string = ciface.get_database_name()
+        tgis_backend = driver_string
+        dbmi = sqlite3
 
-    # Database string from t.connect -pg
-    tgis_database = kv["database"]
+    tgis_database_string = database_string
     # Set the parameter style
     tgis_dbmi_paramstyle = dbmi.paramstyle
 
-    # Create the temporal database string
-    if tgis_backend == "sqlite":
-        # We substitute GRASS variables if they are located in the database string
-        # This behavior is in conjunction with db.connect
-        tgis_database_string = tgis_database
-        tgis_database_string = tgis_database_string.replace("$GISDBASE", current_gisdbase)
-        tgis_database_string = tgis_database_string.replace("$LOCATION_NAME", current_location)
-        tgis_database_string = tgis_database_string.replace("$MAPSET", current_mapset)
-    elif tgis_backend == "pg":
-        tgis_database_string = tgis_database
-
     # We do not know if the database already exists
     db_exists = False
     dbif = SQLDatabaseInterfaceConnection()
@@ -546,8 +598,9 @@
         if os.path.exists(tgis_database_string):
             dbif.connect()
             # Check for raster_base table
-            dbif.cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='raster_base';")
-            name = dbif.cursor.fetchone()
+            dbif.execute("SELECT name FROM sqlite_master WHERE type='table' "
+                         "AND name='raster_base';")
+            name = dbif.fetchone()
             if name and name[0] == "raster_base":
                 db_exists = True
             dbif.close()
@@ -555,23 +608,28 @@
         # Connect to database
         dbif.connect()
         # Check for raster_base table
-        dbif.cursor.execute("SELECT EXISTS(SELECT * FROM information_schema.tables "
-                   "WHERE table_name=%s)", ('raster_base',))
-        if dbif.cursor.fetchone()[0]:
+        dbif.execute("SELECT EXISTS(SELECT * FROM information_schema.tables "
+                     "WHERE table_name=%s)", ('raster_base',))
+        if dbif.fetchone()[0]:
             db_exists = True
 
-    backup_howto = "The format of your actual temporal database is not supported any more.\n"\
-                   "Solution: You need to export it by restoring the GRASS GIS version used for creating this DB. "\
-                   "   From there, create a backup of your temporal database to avoid the loss of your temporal data.\n"\
-                   "Notes: Use t.rast.export and t.vect.export to make a backup of your existing space time datasets."\
-                   "To safe the timestamps of your existing maps and space time datasets, use t.rast.list, "\
-                   "t.vect.list and t.rast3d.list. "\
-                   "You can register the existing time stamped maps easily if you export columns=id,start_time,end_time "\
-                   "into text files and use t.register to register them again in new created space time datasets (t.create). "\
-                   "After the backup remove the existing temporal database, a new one will be created automatically.\n"
+    backup_howto = "The format of your actual temporal database is not " \
+                   "supported any more.\nSolution: You need to export it by " \
+                   "restoring the GRASS GIS version used for creating this DB"\
+                   ". From there, create a backup of your temporal database "\
+                   "to avoid the loss of your temporal data.\nNotes: Use " \
+                   "t.rast.export and t.vect.export to make a backup of your" \
+                   " existing space time datasets.To safe the timestamps of" \
+                   " your existing maps and space time datasets, use " \
+                   "t.rast.list, t.vect.list and t.rast3d.list. "\
+                   "You can register the existing time stamped maps easily if"\
+                   " you export columns=id,start_time,end_time into text "\
+                   "files and use t.register to register them again in new" \
+                   " created space time datasets (t.create). After the backup"\
+                   " remove the existing temporal database, a new one will be"\
+                   " created automatically.\n"
 
-
-    if db_exists == True:
+    if db_exists is True:
         # Check the version of the temporal database
         dbif.close()
         dbif.connect()
@@ -579,41 +637,48 @@
         dbif.close()
         if metadata is None:
             msgr.fatal(_("Unable to receive temporal database metadata.\n"
-                         "Current temporal database info:%(info)s")%({"info":get_database_info_string()}))
+                         "Current temporal database info:%(info)s") % (
+                       {"info": get_database_info_string()}))
         for entry in metadata:
             if "tgis_version" in entry and entry[1] != str(get_tgis_version()):
-                msgr.fatal(_("Unsupported temporal database: version mismatch.\n %(backup)s"
-                             "Supported temporal API version is: %(api)i.\n"
-                             "Please update your GRASS GIS installation.\n"
-                             "Current temporal database info:%(info)s")%({"backup":backup_howto, "api":get_tgis_version(),
-                                                                          "info":get_database_info_string()}))
+                msgr.fatal(_("Unsupported temporal database: version mismatch."
+                             "\n %(backup)s Supported temporal API version is:"
+                             " %(api)i.\nPlease update your GRASS GIS "
+                             "installation.\nCurrent temporal database info:"
+                             "%(info)s") % ({"backup": backup_howto,
+                                             "api": get_tgis_version(),
+                                             "info": get_database_info_string()}))
             if "tgis_db_version" in entry and entry[1] != str(get_tgis_db_version()):
-                msgr.fatal(_("Unsupported temporal database: version mismatch.\n %(backup)s"
-                             "Supported temporal database version is: %(tdb)i\n"
-                             "Current temporal database info:%(info)s")%({"backup":backup_howto,"tdb":get_tgis_version(),
-                                                                          "info":get_database_info_string()}))
+                msgr.fatal(_("Unsupported temporal database: version mismatch."
+                             "\n %(backup)sSupported temporal database version"
+                             " is: %(tdb)i\nCurrent temporal database info:"
+                             "%(info)s") % ({"backup": backup_howto,
+                                             "tdb": get_tgis_version(),
+                                             "info": get_database_info_string()}))
         return
 
     create_temporal_database(dbif)
 
 ###############################################################################
 
+
 def get_database_info_string():
     dbif = SQLDatabaseInterfaceConnection()
 
-    info  = "\nDBMI interface:..... " + str(dbif.dbmi.__name__)
-    info += "\nTemporal database:.. " + str( get_tgis_database_string())
+    info = "\nDBMI interface:..... " + str(dbif.get_dbmi().__name__)
+    info += "\nTemporal database:.. " + str(get_tgis_database_string())
     return info
 
 ###############################################################################
 
+
 def create_temporal_database(dbif):
-    """!This function will create the temporal database
+    """This function will create the temporal database
 
        It will create all tables and triggers that are needed to run
        the temporal GIS
 
-       @param dbif The database interface to be used
+       :param dbif: The database interface to be used
     """
     global tgis_backend
     global tgis_version
@@ -630,10 +695,10 @@
         get_sql_template_path(), "raster_metadata_table.sql"), 'r').read()
     raster3d_metadata_sql = open(os.path.join(template_path,
                                               "raster3d_metadata_table.sql"),
-                                              'r').read()
+                                 'r').read()
     vector_metadata_sql = open(os.path.join(template_path,
                                             "vector_metadata_table.sql"),
-                                            'r').read()
+                               'r').read()
     raster_views_sql = open(os.path.join(template_path, "raster_views.sql"),
                             'r').read()
     raster3d_views_sql = open(os.path.join(template_path,
@@ -643,16 +708,16 @@
 
     stds_tables_template_sql = open(os.path.join(template_path,
                                                  "stds_tables_template.sql"),
-                                                 'r').read()
+                                    'r').read()
     strds_metadata_sql = open(os.path.join(template_path,
                                            "strds_metadata_table.sql"),
-                                           'r').read()
+                              'r').read()
     str3ds_metadata_sql = open(os.path.join(template_path,
                                             "str3ds_metadata_table.sql"),
-                                            'r').read()
+                               'r').read()
     stvds_metadata_sql = open(os.path.join(template_path,
                                            "stvds_metadata_table.sql"),
-                                           'r').read()
+                              'r').read()
     strds_views_sql = open(os.path.join(template_path, "strds_views.sql"),
                            'r').read()
     str3ds_views_sql = open(os.path.join(template_path, "str3ds_views.sql"),
@@ -682,22 +747,24 @@
                 os.makedirs(tgis_dir)
             except Exception as e:
                 msgr.fatal(_("Unable to create SQLite temporal database\n"
-                                     "Exception: %s\nPlease use t.connect to set a "
-                                     "read- and writable temporal database path"%(e)))
-                
+                             "Exception: %s\nPlease use t.connect to set a "
+                             "read- and writable temporal database path" % (e)))
+
         # Set up the trigger that takes care of
         # the correct deletion of entries across the different tables
         delete_trigger_sql = open(os.path.join(template_path,
                                                "sqlite3_delete_trigger.sql"),
-                                               'r').read()
-        indexes_sql = open(os.path.join(template_path, "sqlite3_indexes.sql"), 'r').read()
+                                  'r').read()
+        indexes_sql = open(os.path.join(template_path, "sqlite3_indexes.sql"),
+                           'r').read()
     else:
         # Set up the trigger that takes care of
         # the correct deletion of entries across the different tables
         delete_trigger_sql = open(os.path.join(template_path,
-                                            "postgresql_delete_trigger.sql"),
-                                            'r').read()
-        indexes_sql = open(os.path.join(template_path, "postgresql_indexes.sql"), 'r').read()
+                                               "postgresql_delete_trigger.sql"),
+                                  'r').read()
+        indexes_sql = open(os.path.join(template_path,
+                                        "postgresql_indexes.sql"), 'r').read()
 
     # Connect now to the database
     if not dbif.connected:
@@ -743,13 +810,14 @@
 
 ###############################################################################
 
+
 def _create_tgis_metadata_table(content, dbif=None):
     """!Create the temporal gis metadata table which stores all metadata
        information about the temporal database.
 
-       @param content The dictionary that stores the key:value metadata
+       :param content: The dictionary that stores the key:value metadata
                       that should be stored in the metadata table
-       @param dbif The database interface to be used
+       :param dbif: The database interface to be used
     """
     dbif, connected = init_dbif(dbif)
     statement = "CREATE TABLE tgis_metadata (key VARCHAR NOT NULL, value VARCHAR);\n";
@@ -757,7 +825,7 @@
 
     for key in content.keys():
         statement = "INSERT INTO tgis_metadata (key, value) VALUES " + \
-                     "(\'%s\' , \'%s\');\n"%(str(key), str(content[key]))
+                    "(\'%s\' , \'%s\');\n" % (str(key), str(content[key]))
         dbif.execute_transaction(statement)
 
     if connected:
@@ -765,22 +833,196 @@
 
 ###############################################################################
 
-class SQLDatabaseInterfaceConnection():
-    """!This class represents the database interface connection
+
+class SQLDatabaseInterfaceConnection(object):
+    def __init__(self):
+        self.tgis_mapsets = get_available_temporal_mapsets()
+        self.current_mapset = get_current_mapset()
+        self.connections = {}
+        self.connected = False
+
+        self.unique_connections = {}
+
+        for mapset in self.tgis_mapsets.keys():
+            driver,  dbstring = self.tgis_mapsets[mapset]
+
+            if dbstring not in self.unique_connections.keys():
+                self.unique_connections[dbstring] = DBConnection(driver)
+
+            self.connections[mapset] = self.unique_connections[dbstring]
+
+        self.msgr = get_tgis_message_interface()
+
+    def get_dbmi(self,  mapset=None):
+        if mapset is None:
+            mapset = self.current_mapset
+        return self.connections[mapset].dbmi
+
+    def rollback(self,  mapset=None):
+        """
+            Roll back the last transaction. This must be called
+            in case a new query should be performed after a db error.
+
+            This is only relevant for postgresql database.
+        """
+        if mapset is None:
+            mapset = self.current_mapset
+
+    def connect(self):
+        """Connect to the DBMI to execute SQL statements
+
+           Supported backends are sqlite3 and postgresql
+        """
+        for mapset in self.tgis_mapsets.keys():
+            driver,  dbstring = self.tgis_mapsets[mapset]
+            conn = self.connections[mapset]
+            if conn.is_connected() is False:
+                conn .connect(dbstring)
+
+        self.connected = True
+
+    def is_connected(self):
+        return self.connected
+
+    def close(self):
+        """Close the DBMI connection
+
+           There may be several temporal databases in a location, hence
+           close all temporal databases that have been opened.
+        """
+        for key in self.unique_connections.keys():
+            self.unique_connections[key] .close()
+
+        self.connected = False
+
+    def mogrify_sql_statement(self, content, mapset=None):
+        """Return the SQL statement and arguments as executable SQL string
+
+           :param content: The content as tuple with two entries, the first
+                           entry is the SQL statement with DBMI specific
+                           place holder (?), the second entry is the argument
+                           list that should substitute the place holder.
+           :param mapset: The mapset of the abstract dataset or temporal
+                          database location, if None the current mapset
+                          will be used
+        """
+        if mapset is None:
+            mapset = self.current_mapset
+
+        if mapset not in self.tgis_mapsets.keys():
+            self.msgr.fatal(_("Unable to mogrify sql statement. There is no "
+                              "temporal database connection defined for "
+                              "mapset <%(mapset)s>" % {"mapset": mapset}))
+
+        return self.connections[mapset].mogrify_sql_statement(content)
+
+    def check_table(self, table_name, mapset=None):
+        """Check if a table exists in the temporal database
+
+           :param table_name: The name of the table to be checked for existence
+           :param mapset: The mapset of the abstract dataset or temporal
+                          database location, if None the current mapset
+                          will be used
+           :returns: True if the table exists, False otherwise
+
+           TODO:
+           There may be several temporal databases in a location, hence
+           the mapset is used to query the correct temporal database.
+        """
+        if mapset is None:
+            mapset = self.current_mapset
+
+        if mapset not in self.tgis_mapsets.keys():
+            self.msgr.fatal(_("Unable to check table. There is no temporal "
+                              "database connection defined for mapset "
+                              "<%(mapset)s>" % {"mapset": mapset}))
+
+        return self.connections[mapset].check_table(table_name)
+
+    def execute(self,  statement,  args=None,  mapset=None):
+        """
+
+        :param mapset: The mapset of the abstract dataset or temporal
+                       database location, if None the current mapset
+                       will be used
+        """
+        if mapset is None:
+            mapset = self.current_mapset
+
+        if mapset not in self.tgis_mapsets.keys():
+            self.msgr.fatal(_("Unable to execute sql statement. There is no "
+                              "temporal database connection defined for "
+                              "mapset <%(mapset)s>" % {"mapset": mapset}))
+
+        return self.connections[mapset].execute(statement,  args)
+
+    def fetchone(self,  mapset=None):
+        if mapset is None:
+            mapset = self.current_mapset
+
+        if mapset not in self.tgis_mapsets.keys():
+            self.msgr.fatal(_("Unable to fetch one. There is no temporal "
+                              "database connection defined for mapset "
+                              "<%(mapset)s>" % {"mapset": mapset}))
+
+        return self.connections[mapset].fetchone()
+
+    def fetchall(self,  mapset=None):
+        if mapset is None:
+            mapset = self.current_mapset
+
+        if mapset not in self.tgis_mapsets.keys():
+            self.msgr.fatal(_("Unable to fetch all. There is no temporal "
+                              "database connection defined for mapset "
+                              "<%(mapset)s>" % {"mapset": mapset}))
+
+        return self.connections[mapset].fetchall()
+
+    def execute_transaction(self, statement, mapset=None):
+        """Execute a transactional SQL statement
+
+           The BEGIN and END TRANSACTION statements will be added automatically
+           to the sql statement
+
+           :param statement: The executable SQL statement or SQL script
+        """
+        if mapset is None:
+            mapset = self.current_mapset
+
+        if mapset not in self.tgis_mapsets.keys():
+            self.msgr.fatal(_("Unable to execute transaction. There is no "
+                              "temporal database connection defined for "
+                              "mapset <%(mapset)s>" % {"mapset": mapset}))
+
+        return self.connections[mapset].execute_transaction(statement)
+
+###############################################################################
+
+
+class DBConnection(object):
+    """This class represents the database interface connection
        and provides access to the chisen backend modules.
 
        The following DBMS are supported:
+
          - sqlite via the sqlite3 standard library
          - postgresql via psycopg2
 
     """
-    def __init__(self):
+
+    def __init__(self, backend=None):
         self.connected = False
-        global tgis_backend
-        if tgis_backend == "sqlite":
-            self.dbmi = sqlite3
+        if backend is None:
+            global tgis_backend
+            if tgis_backend == "sqlite":
+                self.dbmi = sqlite3
+            else:
+                self.dbmi = psycopg2
         else:
-            self.dbmi = psycopg2
+            if backend == "sqlite":
+                self.dbmi = sqlite3
+            else:
+                self.dbmi = psycopg2
 
         self.msgr = get_tgis_message_interface()
         self.msgr.debug(1, "SQLDatabaseInterfaceConnection constructor")
@@ -789,6 +1031,9 @@
         if self.connected is True:
             self.close()
 
+    def is_connected(self):
+        return self.connected
+
     def rollback(self):
         """
             Roll back the last transaction. This must be called
@@ -800,60 +1045,74 @@
             if self.connected:
                 self.connection.rollback()
 
-    def connect(self):
-        """!Connect to the DBMI to execute SQL statements
+    def connect(self,  dbstring=None):
+        """Connect to the DBMI to execute SQL statements
 
            Supported backends are sqlite3 and postgresql
         """
-        global tgis_database_string
+        # Connection in the current mapset
+        if dbstring is None:
+            global tgis_database_string
+            dbstring = tgis_database_string
 
         try:
             if self.dbmi.__name__ == "sqlite3":
-                self.connection = self.dbmi.connect(tgis_database_string,
-                        detect_types = self.dbmi.PARSE_DECLTYPES | self.dbmi.PARSE_COLNAMES)
+                self.connection = self.dbmi.connect(dbstring,
+                        detect_types=self.dbmi.PARSE_DECLTYPES | self.dbmi.PARSE_COLNAMES)
                 self.connection.row_factory = self.dbmi.Row
                 self.connection.isolation_level = None
                 self.cursor = self.connection.cursor()
                 self.cursor.execute("PRAGMA synchronous = OFF")
                 self.cursor.execute("PRAGMA journal_mode = MEMORY")
             elif self.dbmi.__name__ == "psycopg2":
-                self.connection = self.dbmi.connect(tgis_database_string)
+                self.connection = self.dbmi.connect(dbstring)
                 #self.connection.set_isolation_level(dbmi.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
                 self.cursor = self.connection.cursor(
-                    cursor_factory = self.dbmi.extras.DictCursor)
+                    cursor_factory=self.dbmi.extras.DictCursor)
             self.connected = True
         except Exception as e:
             self.msgr.fatal(_("Unable to connect to %(db)s database: "
-                                       "%(string)s\nException: \"%(ex)s\"\nPlease use t.connect to set a "
-                                       "read- and writable temporal database backend")%({"db":self.dbmi.__name__, 
-                                                                                                                      "string":tgis_database_string, 
-                                                                                                                      "ex":e,  }))
+                              "%(string)s\nException: \"%(ex)s\"\nPlease use"
+                              " t.connect to set a read- and writable "
+                              "temporal database backend") % (
+                            {"db": self.dbmi.__name__,
+                             "string": tgis_database_string, "ex": e, }))
 
     def close(self):
-        """!Close the DBMI connection"""
+        """Close the DBMI connection
+           TODO:
+           There may be several temporal databases in a location, hence
+           close all temporal databases that have been opened. Use a dictionary
+           to manage different connections.
+        """
         self.connection.commit()
         self.cursor.close()
         self.connected = False
 
     def mogrify_sql_statement(self, content):
-        """!Return the SQL statement and arguments as executable SQL string
+        """Return the SQL statement and arguments as executable SQL string
 
-           @param content The content as tuple with two entries, the first
+           TODO:
+           Use the mapset argument to identify the correct database driver
+
+           :param content: The content as tuple with two entries, the first
                            entry is the SQL statement with DBMI specific
                            place holder (?), the second entry is the argument
-                           list that should substitue the place holder.
+                           list that should substitute the place holder.
+           :param mapset: The mapset of the abstract dataset or temporal
+                          database location, if None the current mapset
+                          will be used
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> init()
-           >>> dbif = SQLDatabaseInterfaceConnection()
-           >>> dbif.mogrify_sql_statement(["SELECT ctime FROM raster_base WHERE id = ?",
-           ... ["soil at PERMANENT",]])
-           "SELECT ctime FROM raster_base WHERE id = 'soil at PERMANENT'"
+               >>> init()
+               >>> dbif = SQLDatabaseInterfaceConnection()
+               >>> dbif.mogrify_sql_statement(["SELECT ctime FROM raster_base WHERE id = ?",
+               ... ["soil at PERMANENT",]])
+               "SELECT ctime FROM raster_base WHERE id = 'soil at PERMANENT'"
 
-           @endcode
         """
         sql = content[0]
         args = content[1]
@@ -914,10 +1173,17 @@
                 return statement
 
     def check_table(self, table_name):
-        """!Check if a table exists in the temporal database
+        """Check if a table exists in the temporal database
 
-           @param table_name The name of the table to be checked for existance
-           @return True if the table exists, False otherwise
+           :param table_name: The name of the table to be checked for existence
+           :param mapset: The mapset of the abstract dataset or temporal
+                          database location, if None the current mapset
+                          will be used
+           :returns: True if the table exists, False otherwise
+
+           TODO:
+           There may be several temporal databases in a location, hence
+           the mapset is used to query the correct temporal database.
         """
         table_exists = False
         connected = False
@@ -928,14 +1194,15 @@
         # Check if the database already exists
         if self.dbmi.__name__ == "sqlite3":
 
-            self.cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='%s';"%table_name)
+            self.cursor.execute("SELECT name FROM sqlite_master WHERE "
+                                "type='table' AND name='%s';" % table_name)
             name = self.cursor.fetchone()
             if name and name[0] == table_name:
                 table_exists = True
         else:
             # Check for raster_base table
             self.cursor.execute("SELECT EXISTS(SELECT * FROM information_schema.tables "
-                    "WHERE table_name=%s)", ('%s'%table_name,))
+                                "WHERE table_name=%s)", ('%s' % table_name,))
             if self.cursor.fetchone()[0]:
                 table_exists = True
 
@@ -944,13 +1211,47 @@
 
         return table_exists
 
-    def execute_transaction(self, statement):
-        """!Execute a transactional SQL statement
+    def execute(self, statement,  args=None):
+        """Execute a SQL statement
 
-            The BEGIN and END TRANSACTION statements will be added automatically
-            to the sql statement
+           :param statement: The executable SQL statement or SQL script
+        """
+        connected = False
+        if not self.connected:
+            self.connect()
+            connected = True
+        try:
+            if args:
+                self.cursor.execute(statement,  args)
+            else:
+                self.cursor.execute(statement)
+        except:
+            if connected:
+                self.close()
+            self.msgr.error(_("Unable to execute :\n %(sql)s" %
+                            {"sql": statement}))
+            raise
 
-            @param statement The executable SQL statement or SQL script
+        if connected:
+            self.close()
+
+    def fetchone(self):
+        if self.connected:
+            return self.cursor.fetchone()
+        return None
+
+    def fetchall(self):
+        if self.connected:
+            return self.cursor.fetchall()
+        return None
+
+    def execute_transaction(self, statement, mapset=None):
+        """Execute a transactional SQL statement
+
+           The BEGIN and END TRANSACTION statements will be added automatically
+           to the sql statement
+
+           :param statement: The executable SQL statement or SQL script
         """
         connected = False
         if not self.connected:
@@ -971,7 +1272,8 @@
         except:
             if connected:
                 self.close()
-            self.msgr.error(_("Unable to execute transaction:\n %(sql)s" % {"sql":statement}))
+            self.msgr.error(_("Unable to execute transaction:\n %(sql)s" %
+                            {"sql": statement}))
             raise
 
         if connected:
@@ -979,32 +1281,34 @@
 
 ###############################################################################
 
+
 def init_dbif(dbif):
-    """!This method checks if the database interface connection exists,
+    """This method checks if the database interface connection exists,
         if not a new one will be created, connected and True will be returned.
-        If the database interface exists but is connected, the connection will be established.
+        If the database interface exists but is connected, the connection will
+        be established.
 
-        @return the tuple (dbif, True|False)
+        :returns: the tuple (dbif, True|False)
 
         Usage code sample:
-        @code
 
-        dbif, connect = tgis.init_dbif(None)
+        .. code-block:: python
 
-        sql = dbif.mogrify_sql_statement(["SELECT * FROM raster_base WHERE ? = ?"],
-                                               ["id", "soil at PERMANENT"])
-        dbif.execute_transaction(sql)
+            dbif, connect = tgis.init_dbif(None)
 
-        if connect:
-            dbif.close()
+            sql = dbif.mogrify_sql_statement(["SELECT * FROM raster_base WHERE ? = ?"],
+                                                   ["id", "soil at PERMANENT"])
+            dbif.execute_transaction(sql)
 
-        @endcode
+            if connect:
+                dbif.close()
+
     """
     if dbif is None:
         dbif = SQLDatabaseInterfaceConnection()
         dbif.connect()
         return dbif, True
-    elif dbif.connected is False:
+    elif dbif.is_connected() is False:
         dbif.connect()
         return dbif, True
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/datetime_math.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/datetime_math.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/datetime_math.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,17 +1,14 @@
-"""!@package grass.temporal
+"""
+Functions for mathematical datetime operations
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS datetime math functions to be used in library functions and modules.
-
 (C) 2011-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
-from datetime import datetime, date, time, timedelta
+from datetime import datetime, timedelta
 from core import *
 import copy
 
@@ -26,8 +23,9 @@
 
 ###############################################################################
 
+
 def relative_time_to_time_delta(value):
-    """!Convert the double value representing days
+    """Convert the double value representing days
        into a timedelta object.
     """
 
@@ -41,7 +39,7 @@
 
 
 def time_delta_to_relative_time(delta):
-    """!Convert the time delta into a
+    """Convert the time delta into a
        double value, representing days.
     """
 
@@ -51,7 +49,7 @@
 
 
 def relative_time_to_time_delta_seconds(value):
-    """!Convert the double value representing seconds
+    """Convert the double value representing seconds
        into a timedelta object.
     """
 
@@ -64,7 +62,7 @@
 
 
 def time_delta_to_relative_time_seconds(delta):
-    """!Convert the time delta into a
+    """Convert the time delta into a
        double value, representing seconds.
     """
 
@@ -72,163 +70,167 @@
 
 ###############################################################################
 
+
 def decrement_datetime_by_string(mydate, increment, mult=1):
 
-    """!Return a new datetime object decremented with the provided
+    """Return a new datetime object decremented with the provided
        relative dates specified as string.
        Additional a multiplier can be specified to multiply the increment
        before adding to the provided datetime object.
 
        Usage:
 
-       @code
+       .. code-block:: python
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "31 days"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(2000, 12, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "31 days"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(2000, 12, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "1 month"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(2000, 12, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "1 month"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(2000, 12, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "2 month"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(2000, 11, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "2 month"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(2000, 11, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "24 months"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(1999, 1, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "24 months"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(1999, 1, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "48 months"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(1997, 1, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "48 months"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(1997, 1, 1, 0, 0)
 
-        >>> dt = datetime(2001, 6, 1, 0, 0, 0)
-        >>> string = "5 months"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(2001, 1, 1, 0, 0)
+            >>> dt = datetime(2001, 6, 1, 0, 0, 0)
+            >>> string = "5 months"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(2001, 1, 1, 0, 0)
 
-        >>> dt = datetime(2001, 6, 1, 0, 0, 0)
-        >>> string = "7 months"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(2000, 11, 1, 0, 0)
+            >>> dt = datetime(2001, 6, 1, 0, 0, 0)
+            >>> string = "7 months"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(2000, 11, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "1 year"
-        >>> decrement_datetime_by_string(dt, string)
-        datetime.datetime(2000, 1, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "1 year"
+            >>> decrement_datetime_by_string(dt, string)
+            datetime.datetime(2000, 1, 1, 0, 0)
 
-        @endcode
 
-       @param mydate A datetime object to incremented
-       @param increment A string providing increment information:
-                  The string may include comma separated values of type seconds,
-                  minutes, hours, days, weeks, months and years
-                  Example: Increment the datetime 2001-01-01 00:00:00
-                  with "60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years"
-                  will result in the datetime 2003-02-18 12:05:00
-       @param mult A multiplier, default is 1
-       @return The new datetime object or none in case of an error
+       :param mydate: A datetime object to incremented
+       :param increment: A string providing increment information:
+                         The string may include comma separated values of type
+                         seconds, minutes, hours, days, weeks, months and years
+                         Example: Increment the datetime 2001-01-01 00:00:00
+                         with "60 seconds, 4 minutes, 12 hours, 10 days,
+                         1 weeks, 5 months, 1 years" will result in the
+                         datetime 2003-02-18 12:05:00
+       :param mult: A multiplier, default is 1
+       :return: The new datetime object or none in case of an error
     """
     return modify_datetime_by_string(mydate, increment, mult, sign=int(-1))
 
 ###############################################################################
 
+
 def increment_datetime_by_string(mydate, increment, mult=1):
-    """!Return a new datetime object incremented with the provided
+    """Return a new datetime object incremented with the provided
        relative dates specified as string.
        Additional a multiplier can be specified to multiply the increment
        before adding to the provided datetime object.
 
        Usage:
 
-       @code
+       .. code-block:: python
 
-        >>> dt = datetime(2001, 9, 1, 0, 0, 0)
-        >>> string = "60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2003, 2, 18, 12, 5)
+            >>> dt = datetime(2001, 9, 1, 0, 0, 0)
+            >>> string = "60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2003, 2, 18, 12, 5)
 
-        >>> dt = datetime(2001, 11, 1, 0, 0, 0)
-        >>> string = "1 months"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2001, 12, 1, 0, 0)
+            >>> dt = datetime(2001, 11, 1, 0, 0, 0)
+            >>> string = "1 months"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2001, 12, 1, 0, 0)
 
-        >>> dt = datetime(2001, 11, 1, 0, 0, 0)
-        >>> string = "13 months"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2002, 12, 1, 0, 0)
+            >>> dt = datetime(2001, 11, 1, 0, 0, 0)
+            >>> string = "13 months"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2002, 12, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "72 months"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2007, 1, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "72 months"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2007, 1, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "72 months"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2007, 1, 1, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "72 months"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2007, 1, 1, 0, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "5 minutes"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2001, 1, 1, 0, 5)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "5 minutes"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2001, 1, 1, 0, 5)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "49 hours"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2001, 1, 3, 1, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "49 hours"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2001, 1, 3, 1, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "3600 seconds"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2001, 1, 1, 1, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "3600 seconds"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2001, 1, 1, 1, 0)
 
-        >>> dt = datetime(2001, 1, 1, 0, 0, 0)
-        >>> string = "30 days"
-        >>> increment_datetime_by_string(dt, string)
-        datetime.datetime(2001, 1, 31, 0, 0)
+            >>> dt = datetime(2001, 1, 1, 0, 0, 0)
+            >>> string = "30 days"
+            >>> increment_datetime_by_string(dt, string)
+            datetime.datetime(2001, 1, 31, 0, 0)
 
-        @endcode
 
-       @param mydate A datetime object to incremented
-       @param increment A string providing increment information:
-                  The string may include comma separated values of type seconds,
-                  minutes, hours, days, weeks, months and years
-                  Example: Increment the datetime 2001-01-01 00:00:00
-                  with "60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years"
-                  will result in the datetime 2003-02-18 12:05:00
-       @param mult A multiplier, default is 1
-       @return The new datetime object or none in case of an error
+       :param mydate: A datetime object to incremented
+       :param increment: A string providing increment information:
+                         The string may include comma separated values of type
+                         seconds, minutes, hours, days, weeks, months and years
+                         Example: Increment the datetime 2001-01-01 00:00:00
+                         with "60 seconds, 4 minutes, 12 hours, 10 days,
+                         1 weeks, 5 months, 1 years" will result in the
+                         datetime 2003-02-18 12:05:00
+       :param mult: A multiplier, default is 1
+       :return: The new datetime object or none in case of an error
     """
     return modify_datetime_by_string(mydate, increment, mult, sign=int(1))
 
 ###############################################################################
 
+
 def modify_datetime_by_string(mydate, increment, mult=1, sign=1):
-    """!Return a new datetime object incremented with the provided
+    """Return a new datetime object incremented with the provided
        relative dates specified as string.
        Additional a multiplier can be specified to multiply the increment
        before adding to the provided datetime object.
 
-       @param mydate A datetime object to incremented
-       @param increment A string providing increment information:
-                  The string may include comma separated values of type seconds,
-                  minutes, hours, days, weeks, months and years
-                  Example: Increment the datetime 2001-01-01 00:00:00
-                  with "60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years"
-                  will result in the datetime 2003-02-18 12:05:00
-       @param mult A multiplier, default is 1
-       @param sign Choose 1 for positive sign (incrementing) or -1 for negative
-                   sign (decrementing).
-       @return The new datetime object or none in case of an error
+       :param mydate: A datetime object to incremented
+       :param increment: A string providing increment information:
+                         The string may include comma separated values of type
+                         seconds, minutes, hours, days, weeks, months and years
+                         Example: Increment the datetime 2001-01-01 00:00:00
+                         with "60 seconds, 4 minutes, 12 hours, 10 days,
+                         1 weeks, 5 months, 1 years" will result in the
+                         datetime 2003-02-18 12:05:00
+       :param mult: A multiplier, default is 1
+       :param sign: Choose 1 for positive sign (incrementing) or -1 for
+                    negative sign (decrementing).
+       :return: The new datetime object or none in case of an error
     """
-    sign  = int(sign)
+    sign = int(sign)
     if sign != 1 and sign != -1:
         return None
 
@@ -271,15 +273,17 @@
                 msgr.error(_("Wrong increment format: %s") % (increment))
                 return None
 
-        return modify_datetime(mydate, years, months, weeks, days, hours, minutes, seconds)
+        return modify_datetime(mydate, years, months, weeks, days, hours,
+                               minutes, seconds)
 
     return mydate
 
 ###############################################################################
 
+
 def modify_datetime(mydate, years=0, months=0, weeks=0, days=0, hours=0,
-                       minutes=0, seconds=0):
-    """!Return a new datetime object incremented with the provided
+                    minutes=0, seconds=0):
+    """Return a new datetime object incremented with the provided
        relative dates and times"""
 
     tdelta_seconds = timedelta(seconds=seconds)
@@ -334,7 +338,8 @@
             residual_months += 12
 
         try:
-            dt1 = dt1.replace(year=year - years_to_remove, month=residual_months)
+            dt1 = dt1.replace(year=year - years_to_remove,
+                              month=residual_months)
         except:
             raise
 
@@ -354,7 +359,7 @@
 
 
 def adjust_datetime_to_granularity(mydate, granularity):
-    """!Modify the datetime object to fit the given granularity
+    """Modify the datetime object to fit the given granularity
 
         - Years will start at the first of Januar
         - Months will start at the first day of the month
@@ -364,43 +369,42 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> dt = datetime(2001, 8, 8, 12,30,30)
-        >>> adjust_datetime_to_granularity(dt, "5 seconds")
-        datetime.datetime(2001, 8, 8, 12, 30, 30)
+            >>> dt = datetime(2001, 8, 8, 12,30,30)
+            >>> adjust_datetime_to_granularity(dt, "5 seconds")
+            datetime.datetime(2001, 8, 8, 12, 30, 30)
 
-        >>> adjust_datetime_to_granularity(dt, "20 minutes")
-        datetime.datetime(2001, 8, 8, 12, 30)
+            >>> adjust_datetime_to_granularity(dt, "20 minutes")
+            datetime.datetime(2001, 8, 8, 12, 30)
 
-        >>> adjust_datetime_to_granularity(dt, "20 minutes")
-        datetime.datetime(2001, 8, 8, 12, 30)
+            >>> adjust_datetime_to_granularity(dt, "20 minutes")
+            datetime.datetime(2001, 8, 8, 12, 30)
 
-        >>> adjust_datetime_to_granularity(dt, "3 hours")
-        datetime.datetime(2001, 8, 8, 12, 0)
+            >>> adjust_datetime_to_granularity(dt, "3 hours")
+            datetime.datetime(2001, 8, 8, 12, 0)
 
-        >>> adjust_datetime_to_granularity(dt, "5 days")
-        datetime.datetime(2001, 8, 8, 0, 0)
+            >>> adjust_datetime_to_granularity(dt, "5 days")
+            datetime.datetime(2001, 8, 8, 0, 0)
 
-        >>> adjust_datetime_to_granularity(dt, "2 weeks")
-        datetime.datetime(2001, 8, 6, 0, 0)
+            >>> adjust_datetime_to_granularity(dt, "2 weeks")
+            datetime.datetime(2001, 8, 6, 0, 0)
 
-        >>> adjust_datetime_to_granularity(dt, "6 months")
-        datetime.datetime(2001, 8, 1, 0, 0)
+            >>> adjust_datetime_to_granularity(dt, "6 months")
+            datetime.datetime(2001, 8, 1, 0, 0)
 
-        >>> adjust_datetime_to_granularity(dt, "2 years")
-        datetime.datetime(2001, 1, 1, 0, 0)
+            >>> adjust_datetime_to_granularity(dt, "2 years")
+            datetime.datetime(2001, 1, 1, 0, 0)
 
-        >>> adjust_datetime_to_granularity(dt, "2 years, 3 months, 5 days, 3 hours, 3 minutes, 2 seconds")
-        datetime.datetime(2001, 8, 8, 12, 30, 30)
+            >>> adjust_datetime_to_granularity(dt, "2 years, 3 months, 5 days, 3 hours, 3 minutes, 2 seconds")
+            datetime.datetime(2001, 8, 8, 12, 30, 30)
 
-        >>> adjust_datetime_to_granularity(dt, "3 months, 5 days, 3 minutes")
-        datetime.datetime(2001, 8, 8, 12, 30)
+            >>> adjust_datetime_to_granularity(dt, "3 months, 5 days, 3 minutes")
+            datetime.datetime(2001, 8, 8, 12, 30)
 
-        >>> adjust_datetime_to_granularity(dt, "3 weeks, 5 days")
-        datetime.datetime(2001, 8, 8, 0, 0)
+            >>> adjust_datetime_to_granularity(dt, "3 weeks, 5 days")
+            datetime.datetime(2001, 8, 8, 0, 0)
 
-        @endcode
     """
 
     if granularity:
@@ -480,142 +484,141 @@
 
         dt = copy.copy(mydate)
         return dt.replace(year=years, month=months, day=days,
-                            hour=hours, minute=minutes, second=seconds)
+                          hour=hours, minute=minutes, second=seconds)
 
 ###############################################################################
 
 
 def compute_datetime_delta(start, end):
-    """!Return a dictionary with the accumulated delta in year, month, day,
+    """Return a dictionary with the accumulated delta in year, month, day,
        hour, minute and second
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> start = datetime(2001, 1, 1, 00,00,00)
-        >>> end = datetime(2001, 1, 1, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 0, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
+            >>> start = datetime(2001, 1, 1, 00,00,00)
+            >>> end = datetime(2001, 1, 1, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 0, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2001, 1, 1, 00,00,14)
-        >>> end = datetime(2001, 1, 1, 00,00,44)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 0, 'second': 30, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
+            >>> start = datetime(2001, 1, 1, 00,00,14)
+            >>> end = datetime(2001, 1, 1, 00,00,44)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 0, 'second': 30, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2001, 1, 1, 00,00,44)
-        >>> end = datetime(2001, 1, 1, 00,01,14)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 0, 'second': 30, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 1}
+            >>> start = datetime(2001, 1, 1, 00,00,44)
+            >>> end = datetime(2001, 1, 1, 00,01,14)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 0, 'second': 30, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 1}
 
-        >>> start = datetime(2001, 1, 1, 00,00,30)
-        >>> end = datetime(2001, 1, 1, 00,05,30)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 0, 'second': 300, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 5}
+            >>> start = datetime(2001, 1, 1, 00,00,30)
+            >>> end = datetime(2001, 1, 1, 00,05,30)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 0, 'second': 300, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 5}
 
-        >>> start = datetime(2001, 1, 1, 00,00,00)
-        >>> end = datetime(2001, 1, 1, 00,01,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 0, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 1}
+            >>> start = datetime(2001, 1, 1, 00,00,00)
+            >>> end = datetime(2001, 1, 1, 00,01,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 0, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 1}
 
-        >>> start = datetime(2011,10,31, 00,45,00)
-        >>> end = datetime(2011,10,31, 01,45,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 60}
+            >>> start = datetime(2011,10,31, 00,45,00)
+            >>> end = datetime(2011,10,31, 01,45,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 60}
 
-        >>> start = datetime(2011,10,31, 00,45,00)
-        >>> end = datetime(2011,10,31, 01,15,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 30}
+            >>> start = datetime(2011,10,31, 00,45,00)
+            >>> end = datetime(2011,10,31, 01,15,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 30}
 
-        >>> start = datetime(2011,10,31, 00,45,00)
-        >>> end = datetime(2011,10,31, 12,15,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 12, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 690}
+            >>> start = datetime(2011,10,31, 00,45,00)
+            >>> end = datetime(2011,10,31, 12,15,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 12, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 690}
 
-        >>> start = datetime(2011,10,31, 00,00,00)
-        >>> end = datetime(2011,10,31, 01,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,10,31, 00,00,00)
+            >>> end = datetime(2011,10,31, 01,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,10,31, 00,00,00)
-        >>> end = datetime(2011,11,01, 01,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 25, 'second': 0, 'max_days': 1, 'year': 0, 'day': 1, 'minute': 0}
+            >>> start = datetime(2011,10,31, 00,00,00)
+            >>> end = datetime(2011,11,01, 01,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 25, 'second': 0, 'max_days': 1, 'year': 0, 'day': 1, 'minute': 0}
 
-        >>> start = datetime(2011,10,31, 12,00,00)
-        >>> end = datetime(2011,11,01, 06,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 18, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,10,31, 12,00,00)
+            >>> end = datetime(2011,11,01, 06,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 18, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,11,01, 00,00,00)
-        >>> end = datetime(2011,12,01, 01,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 721, 'month': 1, 'second': 0, 'max_days': 30, 'year': 0, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,11,01, 00,00,00)
+            >>> end = datetime(2011,12,01, 01,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 721, 'month': 1, 'second': 0, 'max_days': 30, 'year': 0, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,11,01, 00,00,00)
-        >>> end = datetime(2011,11,05, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'second': 0, 'max_days': 4, 'year': 0, 'day': 4, 'minute': 0}
+            >>> start = datetime(2011,11,01, 00,00,00)
+            >>> end = datetime(2011,11,05, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'second': 0, 'max_days': 4, 'year': 0, 'day': 4, 'minute': 0}
 
-        >>> start = datetime(2011,10,06, 00,00,00)
-        >>> end = datetime(2011,11,05, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'second': 0, 'max_days': 30, 'year': 0, 'day': 30, 'minute': 0}
+            >>> start = datetime(2011,10,06, 00,00,00)
+            >>> end = datetime(2011,11,05, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'second': 0, 'max_days': 30, 'year': 0, 'day': 30, 'minute': 0}
 
-        >>> start = datetime(2011,12,02, 00,00,00)
-        >>> end = datetime(2012,01,01, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'second': 0, 'max_days': 30, 'year': 1, 'day': 30, 'minute': 0}
+            >>> start = datetime(2011,12,02, 00,00,00)
+            >>> end = datetime(2012,01,01, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'second': 0, 'max_days': 30, 'year': 1, 'day': 30, 'minute': 0}
 
-        >>> start = datetime(2011,01,01, 00,00,00)
-        >>> end = datetime(2011,02,01, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 1, 'second': 0, 'max_days': 31, 'year': 0, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,01,01, 00,00,00)
+            >>> end = datetime(2011,02,01, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 1, 'second': 0, 'max_days': 31, 'year': 0, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,12,01, 00,00,00)
-        >>> end = datetime(2012,01,01, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 1, 'second': 0, 'max_days': 31, 'year': 1, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,12,01, 00,00,00)
+            >>> end = datetime(2012,01,01, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 1, 'second': 0, 'max_days': 31, 'year': 1, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,12,01, 00,00,00)
-        >>> end = datetime(2012,06,01, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 6, 'second': 0, 'max_days': 183, 'year': 1, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,12,01, 00,00,00)
+            >>> end = datetime(2012,06,01, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 6, 'second': 0, 'max_days': 183, 'year': 1, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,06,01, 00,00,00)
-        >>> end = datetime(2021,06,01, 00,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 120, 'second': 0, 'max_days': 3653, 'year': 10, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,06,01, 00,00,00)
+            >>> end = datetime(2021,06,01, 00,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 120, 'second': 0, 'max_days': 3653, 'year': 10, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,06,01, 00,00,00)
-        >>> end = datetime(2012,06,01, 12,00,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 8796, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,06,01, 00,00,00)
+            >>> end = datetime(2012,06,01, 12,00,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 8796, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,06,01, 00,00,00)
-        >>> end = datetime(2012,06,01, 12,30,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 8796, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 527790}
+            >>> start = datetime(2011,06,01, 00,00,00)
+            >>> end = datetime(2012,06,01, 12,30,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 8796, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 527790}
 
-        >>> start = datetime(2011,06,01, 00,00,00)
-        >>> end = datetime(2012,06,01, 12,00,05)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 8796, 'month': 12, 'second': 31665605, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,06,01, 00,00,00)
+            >>> end = datetime(2012,06,01, 12,00,05)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 8796, 'month': 12, 'second': 31665605, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}
 
-        >>> start = datetime(2011,06,01, 00,00,00)
-        >>> end = datetime(2012,06,01, 00,30,00)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 527070}
+            >>> start = datetime(2011,06,01, 00,00,00)
+            >>> end = datetime(2012,06,01, 00,30,00)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 527070}
 
-        >>> start = datetime(2011,06,01, 00,00,00)
-        >>> end = datetime(2012,06,01, 00,00,05)
-        >>> compute_datetime_delta(start, end)
-        {'hour': 0, 'month': 12, 'second': 31622405, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}
+            >>> start = datetime(2011,06,01, 00,00,00)
+            >>> end = datetime(2012,06,01, 00,00,05)
+            >>> compute_datetime_delta(start, end)
+            {'hour': 0, 'month': 12, 'second': 31622405, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}
 
-        @endcode
-
-       @return A dictionary with year, month, day, hour, minute and second as keys()
+       :return: A dictionary with year, month, day, hour, minute and second as
+                keys()
     """
     comp = {}
 
@@ -631,7 +634,7 @@
     # Count full months
     if start.month == 1 and end.month == 1:
         comp["month"] = 0
-    elif   start.day == 1 and end.day == 1:
+    elif start.day == 1 and end.day == 1:
         d = end.month - start.month
         if d < 0:
             d = d + 12 * comp["year"]
@@ -640,7 +643,7 @@
         comp["month"] = d
 
     # Count full days
-    if  start.day == 1 and end.day == 1:
+    if start.day == 1 and end.day == 1:
         comp["day"] = 0
     else:
         comp["day"] = day_diff
@@ -702,36 +705,37 @@
 
 
 def check_datetime_string(time_string):
-    """!Check if  a string can be converted into a datetime object
+    """Check if  a string can be converted 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 be checked for conversion
-        @return datetime object or an error message string in case of an error
+        :param time_string: The time string to be checked for conversion
+        :return: datetime: object or an error message string in case of an error
     """
 
     global has_dateutil
-        
+
     if has_dateutil:
-        # First check if there is only a single number, which specifies relative time.
-        # dateutil will interprete a single number as a valid time string, so we have
-        # to catch this case beforehand
+        # First check if there is only a single number, which specifies
+        # relative time. dateutil will interprete a single number as a valid
+        # time string, so we have to catch this case beforehand
         try:
             value = int(time_string)
             return _("Time string seems to specify relative time")
         except ValueError:
             pass
-        
+
         try:
             time_object = parser.parse(time_string)
         except Exception as inst:
             time_object = str(inst)
         return time_object
-        
+
     # BC is not supported
     if time_string.find("bc") > 0:
         return _("Dates Before Christ (BC) are not supported")
@@ -746,27 +750,28 @@
         time_format = "%Y-%m-%d"
 
     try:
-        return  datetime.strptime(time_string, time_format)
+        return datetime.strptime(time_string, time_format)
     except:
-        return _("Unable to parse time string: %s"%time_string)
+        return _("Unable to parse time string: %s" % time_string)
 
 ###############################################################################
 
 
 def string_to_datetime(time_string):
-    """!Convert a string into a datetime object
+    """Convert a string into a datetime object
 
         In case datutil is not installed the supported ISO string formats are:
+
         - YYYY-mm-dd
         - YYYY-mm-dd HH:MM:SS
         - Time zones are not supported
-        
+
         If dateutil is installed, all string formats of the dateutil module
         are supported, as well as time zones
 
-        @param time_string The time string to convert
-        @return datetime object or None in case the string 
-                         could not be converted
+        :param time_string: The time string to convert
+        :return: datetime object or None in case the string
+                 could not be converted
     """
 
     if not isinstance(time_string, str):
@@ -784,26 +789,25 @@
 
 
 def datetime_to_grass_datetime_string(dt):
-    """!Convert a python datetime object into a GRASS datetime string
-    
-    @code
-    
-    >>> import grass.temporal as tgis
-    >>> import dateutil.parser as parser
-    >>> dt = parser.parse("2011-01-01 10:00:00 +01:30")
-    >>> tgis.datetime_to_grass_datetime_string(dt)
-    '01 jan 2011 10:00:00 +0090'
-    >>> dt = parser.parse("2011-01-01 10:00:00 +02:30")
-    >>> tgis.datetime_to_grass_datetime_string(dt)
-    '01 jan 2011 10:00:00 +0150'
-    >>> dt = parser.parse("2011-01-01 10:00:00 +12:00")
-    >>> tgis.datetime_to_grass_datetime_string(dt)
-    '01 jan 2011 10:00:00 +0720'
-    >>> dt = parser.parse("2011-01-01 10:00:00 -01:30")
-    >>> tgis.datetime_to_grass_datetime_string(dt)
-    '01 jan 2011 10:00:00 -0090'
-    
-    @endcode
+    """Convert a python datetime object into a GRASS datetime string
+
+    .. code-block:: python
+
+        >>> import grass.temporal as tgis
+        >>> import dateutil.parser as parser
+        >>> dt = parser.parse("2011-01-01 10:00:00 +01:30")
+        >>> tgis.datetime_to_grass_datetime_string(dt)
+        '01 jan 2011 10:00:00 +0090'
+        >>> dt = parser.parse("2011-01-01 10:00:00 +02:30")
+        >>> tgis.datetime_to_grass_datetime_string(dt)
+        '01 jan 2011 10:00:00 +0150'
+        >>> dt = parser.parse("2011-01-01 10:00:00 +12:00")
+        >>> tgis.datetime_to_grass_datetime_string(dt)
+        '01 jan 2011 10:00:00 +0720'
+        >>> dt = parser.parse("2011-01-01 10:00:00 -01:30")
+        >>> tgis.datetime_to_grass_datetime_string(dt)
+        '01 jan 2011 10:00:00 -0090'
+
     """
     # GRASS datetime month names
     month_names = ["", "jan", "feb", "mar", "apr", "may", "jun",
@@ -811,16 +815,18 @@
 
     # Check for time zone info in the datetime object
     if dt.tzinfo is not None:
-        
+
         tz = dt.tzinfo.utcoffset(0)
         if tz.seconds > 86400 / 2:
             tz = (tz.seconds - 86400) / 60
         else:
             tz = tz.seconds/60
-            
+
         string = "%.2i %s %.2i %.2i:%.2i:%.2i %+.4i" % (dt.day,
-                 month_names[dt.month], dt.year,
-                 dt.hour, dt.minute, dt.second, tz)
+                                                        month_names[dt.month],
+                                                        dt.year, dt.hour,
+                                                        dt.minute, dt.second,
+                                                        tz)
     else:
         string = "%.2i %s %.4i %.2i:%.2i:%.2i" % (dt.day, month_names[
             dt.month], dt.year, dt.hour, dt.minute, dt.second)
@@ -828,7 +834,33 @@
     return string
 
 ###############################################################################
+suffix_units = {"years": "%Y",
+                "year": "%Y",
+                "months": "%Y_%m",
+                "month": "%Y_%m",
+                "weeks": "%Y_%m_%d",
+                "week": "%Y_%m_%d",
+                "days": "%Y_%m_%d",
+                "day": "%Y_%m_%d",
+                "hours": "%Y_%m_%d_%H",
+                "hour": "%Y_%m_%d_%H",
+                "minutes": "%Y_%m_%d_%H_%M",
+                "minute": "%Y_%m_%d_%H_%M"}
 
+
+def create_suffix_from_datetime(start_time,  granularity):
+    """Create a datetime string based on a datetime object and a provided
+       granularity that can be used as suffix for map names.
+
+       dateteime=2001-01-01 00:00:00, granularity="1 month" returns "2001_01"
+
+       :param start_time: The datetime object
+       :param granularity: The granularity for example "1 month" or "100 seconds"
+       :return: A string
+    """
+    global suffix_units
+    return start_time.strftime(suffix_units[granularity.split(' ')[1]])
+
 if __name__ == "__main__":
     import doctest
     doctest.testmod()

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/extract.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/extract.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/extract.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,15 +1,12 @@
-"""!@package grass.temporal
+"""
+Extract functions for space time raster, 3d raster and vector datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in Python scripts.
-
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from grass.script.utils import get_num_suffix
@@ -25,28 +22,28 @@
 def extract_dataset(input, output, type, where, expression, base, nprocs=1,
                     register_null=False, layer=1,
                     vtype="point,line,boundary,centroid,area,face"):
-    """!Extract a subset of a space time raster, raster3d or vector dataset
+    """Extract a subset of a space time raster, raster3d or vector dataset
 
        A mapcalc expression can be provided to process the temporal extracted
        maps.
        Mapcalc expressions are supported for raster and raster3d maps.
 
-       @param input The name of the input space time raster/raster3d dataset
-       @param output The name of the extracted new space time raster/raster3d
+       :param input: The name of the input space time raster/raster3d dataset
+       :param output: The name of the extracted new space time raster/raster3d
                      dataset
-       @param type The type of the dataset: "raster", "raster3d" or vector
-       @param where The temporal SQL WHERE statement for subset extraction
-       @param expression The r(3).mapcalc expression or the v.extract where
+       :param type: The type of the dataset: "raster", "raster3d" or vector
+       :param where: The temporal SQL WHERE statement for subset extraction
+       :param expression: The r(3).mapcalc expression or the v.extract where
                          statement
-       @param base The base name of the new created maps in case a mapclac
+       :param base: The base name of the new created maps in case a mapclac
                    expression is provided
-       @param nprocs The number of parallel processes to be used for mapcalc
+       :param nprocs: The number of parallel processes to be used for mapcalc
                      processing
-       @param register_null Set this number True to register empty maps
+       :param register_null: Set this number True to register empty maps
                             (only raster and raster3d maps)
-       @param layer The vector layer number to be used when no timestamped
+       :param layer: The vector layer number to be used when no timestamped
               layer is present, default is 1
-       @param vtype The feature type to be extracted for vector maps, default
+       :param vtype: The feature type to be extracted for vector maps, default
               is point,line,boundary,centroid,area and face
     """
 
@@ -61,10 +58,9 @@
     dbif = SQLDatabaseInterfaceConnection()
     dbif.connect()
 
-    sp = open_old_space_time_dataset(input, type, dbif)
+    sp = open_old_stds(input, type, dbif)
     # Check the new stds
-    new_sp = check_new_space_time_dataset(output, type, dbif,
-                                          gscript.overwrite())
+    new_sp = check_new_stds(output, type, dbif, gscript.overwrite())
     if type == "vector":
         rows = sp.get_registered_maps(
             "id,name,mapset,layer", where, "start_time", dbif)
@@ -90,7 +86,8 @@
                     msgr.percent(count, num_rows, 1)
 
                 map_name = "{base}_{suffix}".format(base=base,
-                                                    suffix=get_num_suffix(count, num_rows))
+                                                    suffix=get_num_suffix(count,
+                                                                          num_rows))
 
                 # We need to modify the r(3).mapcalc expression
                 if type != "vector":
@@ -102,7 +99,8 @@
                     # We need to build the id
                     map_id = AbstractMapDataset.build_id(map_name, mapset)
                 else:
-                    map_id = AbstractMapDataset.build_id(map_name, mapset, row["layer"])
+                    map_id = AbstractMapDataset.build_id(map_name, mapset,
+                                                         row["layer"])
 
                 new_map = sp.get_new_map_instance(map_id)
 
@@ -134,16 +132,16 @@
                                  % expression)
                     if row["layer"]:
                         proc_list.append(Process(target=run_vector_extraction,
-                                                 args=(row["name"] + "@" + \
-                                                       row["mapset"],
-                                                 map_name, row["layer"],
-                                                 vtype, expression)))
+                                                 args=(row["name"] + "@" +
+                                                       row["mapset"], map_name,
+                                                       row["layer"], vtype,
+                                                       expression)))
                     else:
                         proc_list.append(Process(target=run_vector_extraction,
-                                                 args=(row["name"] + "@" + \
-                                                       row["mapset"],
-                                                 map_name, layer, vtype,
-                                                 expression)))
+                                                 args=(row["name"] + "@" +
+                                                       row["mapset"], map_name,
+                                                       layer, vtype,
+                                                       expression)))
 
                 proc_list[proc_count].start()
                 proc_count += 1
@@ -169,11 +167,9 @@
         msgr.percent(0, num_rows, 1)
 
         temporal_type, semantic_type, title, description = sp.get_initial_values()
-        new_sp = open_new_space_time_dataset(output, type,
-                                             sp.get_temporal_type(),
-                                             title, description,
-                                             semantic_type, dbif,
-                                             gscript.overwrite())
+        new_sp = open_new_stds(output, type, sp.get_temporal_type(), title, 
+                               description, semantic_type, dbif,
+                               gscript.overwrite())
 
         # collect empty maps to remove them
         empty_maps = []
@@ -238,11 +234,14 @@
                     names += ",%s" % (map.get_name())
                 count += 1
             if type == "raster":
-                gscript.run_command("g.remove", type='rast', name=names, quiet=True, flags='f')
+                gscript.run_command("g.remove", flags='f', type='rast',
+                                    name=names, quiet=True)
             elif type == "raster3d":
-                gscript.run_command("g.remove", type='rast3d', name=names, quiet=True, flags='f')
+                gscript.run_command("g.remove", flags='f', type='rast3d',
+                                    name=names, quiet=True)
             elif type == "vector":
-                gscript.run_command("g.remove", type='vect', name=names, quiet=True, flags='f')
+                gscript.run_command("g.remove", flags='f', type='vect',
+                                    name=names, quiet=True)
 
     dbif.close()
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/factory.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/factory.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/factory.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,25 +1,21 @@
-"""!@package grass.temporal
+"""
+Object factory
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in Python scripts.
-
 Usage:
 
- at code
-import grass.temporal as tgis
+.. code-block:: python
 
-tgis.register_maps_in_space_time_dataset(type, name, maps)
+    import grass.temporal as tgis
 
-...
- at endcode
+    tgis.register_maps_in_space_time_dataset(type, name, maps)
 
+
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from space_time_datasets import *
@@ -28,11 +24,11 @@
 
 
 def dataset_factory(type, id):
-    """!A factory functions to create space time or map datasets
+    """A factory functions to create space time or map datasets
 
-       @param type the dataset type: rast or raster, rast3d,
+       :param type: the dataset type: rast or raster, rast3d,
                     vect or vector, strds, str3ds, stvds
-       @param id The id of the dataset ("name at mapset")
+       :param id: The id of the dataset ("name at mapset")
     """
     if type == "strds":
         sp = SpaceTimeRasterDataset(id)
@@ -52,4 +48,3 @@
         return None
 
     return sp
-

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/gui_support.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/gui_support.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/gui_support.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,43 +1,42 @@
-"""!@package grass.temporal
+"""
+GUI support functions
 
- at brief GRASS Python scripting module (temporal GIS functions)
 
-Temporal GIS related functions to be used in Python scripts.
-
-
 (C) 2008-2011 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from space_time_datasets import *
 from factory import *
+import grass.script as gscript
 
 ###############################################################################
 
-def tlist_grouped(type, group_type = False, dbif=None):
-    """!List of temporal elements grouped by mapsets.
 
-    Returns a dictionary where the keys are mapset 
+def tlist_grouped(type, group_type=False, dbif=None):
+    """List of temporal elements grouped by mapsets.
+
+    Returns a dictionary where the keys are mapset
     names and the values are lists of space time datasets in that
     mapset. Example:
 
-    @code
-    >>> tgis.tlist_grouped('strds')['PERMANENT']
-    ['precipitation', 'temperature']
-    @endcode
-    
-    @param type element type (strds, str3ds, stvds)
-    @param group_type TBD
+    .. code-block:: python
 
-    @return directory of mapsets/elements
+        >>> tgis.tlist_grouped('strds')['PERMANENT']
+        ['precipitation', 'temperature']
+
+    :param type: element type (strds, str3ds, stvds)
+    :param group_type: TBD
+
+    :return: directory of mapsets/elements
     """
     result = {}
     dbif, connected = init_dbif(dbif)
-    
+
     mapset = None
     if type == 'stds':
         types = ['strds', 'str3ds', 'stvds']
@@ -46,7 +45,7 @@
     for type in types:
         try:
             tlist_result = tlist(type=type, dbif=dbif)
-        except core.ScriptError as e:
+        except gscript.ScriptError as e:
             warning(e)
             continue
 
@@ -66,7 +65,7 @@
             if group_type:
                 if type in result[mapset]:
                     result[mapset][type].append(name)
-                else:        
+                else:
                     result[mapset][type] = [name, ]
             else:
                 result[mapset].append(name)
@@ -78,37 +77,42 @@
 
 ###############################################################################
 
+
 def tlist(type, dbif=None):
-    """!Return a list of space time datasets of absolute and relative time
-     
-    @param type element type (strds, str3ds, stvds)
+    """Return a list of space time datasets of absolute and relative time
 
-    @return a list of space time dataset ids
+    :param type: element type (strds, str3ds, stvds)
+
+    :return: a list of space time dataset ids
     """
     id = None
     sp = dataset_factory(type, id)
     dbif, connected = init_dbif(dbif)
 
+    mapsets = get_available_temporal_mapsets()
+
     output = []
     temporal_type = ["absolute", 'relative']
     for type in temporal_type:
-        # Table name
-        if type == "absolute":
-            table = sp.get_type() + "_view_abs_time"
-        else:
-            table = sp.get_type() + "_view_rel_time"
+        # For each available mapset
+        for mapset in mapsets.keys():
+            # Table name
+            if type == "absolute":
+                table = sp.get_type() + "_view_abs_time"
+            else:
+                table = sp.get_type() + "_view_rel_time"
 
-        # Create the sql selection statement
-        sql = "SELECT id FROM " + table
-        sql += " ORDER BY id"
+            # Create the sql selection statement
+            sql = "SELECT id FROM " + table
+            sql += " ORDER BY id"
 
-        dbif.cursor.execute(sql)
-        rows = dbif.cursor.fetchall()
+            dbif.execute(sql,  mapset=mapset)
+            rows = dbif.fetchall(mapset=mapset)
 
-        # Append the ids of the space time datasets
-        for row in rows:
-            for col in row:
-                output.append(str(col))
+            # Append the ids of the space time datasets
+            for row in rows:
+                for col in row:
+                    output.append(str(col))
 
     if connected is True:
         dbif.close()

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/list_stds.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,25 +1,21 @@
-"""!@package grass.temporal
+"""
+Functions to create space time dataset lists
 
- at brief GRASS Python scripting module (temporal GIS functions)
+Usage:
 
-Temporal GIS related functions to be used in Python scripts.
+.. code-block:: python
 
-Usage:
+    import grass.temporal as tgis
 
- at code
-import grass.temporal as tgis
+    tgis.register_maps_in_space_time_dataset(type, name, maps)
 
-tgis.register_maps_in_space_time_dataset(type, name, maps)
 
-...
- at endcode
-
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from space_time_datasets import *
@@ -28,54 +24,62 @@
 
 ###############################################################################
 
-def get_dataset_list(type,  temporal_type,  columns=None,  where=None,  order=None):
-    """! Return a list of time stamped maps or space time datasets of a specific temporal type
-         that are registred in the temporal database
-    
-         This method returns a dictionary, the keys are the available mapsets, 
-         the values are the rows from the SQL database query.
 
-        @param type The type of the datasets (strds, str3ds, stvds, rast, rast3d, vect)
-        @param temporal_type The temporal type of the datasets (absolute, relative)
-        @param columns A comma separated list of columns that will be selected
-        @param where A where statement for selected listing without "WHERE"
-        @param order A comma separated list of columns to order the
-                               datasets by category
-                      
-        @return A dictionary with the rows of the SQL query for each available mapset
-        
-        >>> import grass.temporal as tgis
-        >>> tgis.init()
-        >>> name = "list_stds_test"
-        >>> sp = tgis.open_new_space_time_dataset(name=name, type="strds", 
-        ... temporaltype="absolute", title="title", descr="descr", semantic="mean", dbif=None, overwrite=True)
-        >>> mapset = tgis.get_current_mapset()
-        >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name")
-        >>> rows =  stds_list[mapset]
-        >>> for row in rows:
-        ...     if row["name"] == name:
-        ...         print True
-        True
-        >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name,mapset", where="mapset = '%s'"%(mapset))
-        >>> rows =  stds_list[mapset]
-        >>> for row in rows:
-        ...     if row["name"] == name and row["mapset"] == mapset:
-        ...         print True
-        True
-        >>> check = sp.delete()
+def get_dataset_list(type, temporal_type, columns=None, where=None,
+                     order=None):
+    """ Return a list of time stamped maps or space time datasets of a specific
+        temporal type that are registred in the temporal database
+
+        This method returns a dictionary, the keys are the available mapsets,
+        the values are the rows from the SQL database query.
+
+        :param type: The type of the datasets (strds, str3ds, stvds, rast,
+                     rast3d, vect)
+        :param temporal_type: The temporal type of the datasets (absolute,
+                              relative)
+        :param columns: A comma separated list of columns that will be selected
+        :param where: A where statement for selected listing without "WHERE"
+        :param order: A comma separated list of columns to order the
+                      datasets by category
+
+        :return: A dictionary with the rows of the SQL query for each
+                 available mapset
+
+        .. code-block:: python
+
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> name = "list_stds_test"
+            >>> sp = tgis.open_new_stds(name=name, type="strds",
+            ... temporaltype="absolute", title="title", descr="descr", semantic="mean", dbif=None, overwrite=True)
+            >>> mapset = tgis.get_current_mapset()
+            >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name")
+            >>> rows =  stds_list[mapset]
+            >>> for row in rows:
+            ...     if row["name"] == name:
+            ...         print True
+            True
+            >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name,mapset", where="mapset = '%s'"%(mapset))
+            >>> rows =  stds_list[mapset]
+            >>> for row in rows:
+            ...     if row["name"] == name and row["mapset"] == mapset:
+            ...         print True
+            True
+            >>> check = sp.delete()
+
     """
     id = None
     sp = dataset_factory(type, id)
 
     dbif = SQLDatabaseInterfaceConnection()
     dbif.connect()
-    
-    mapsets = get_tgis_c_library_interface().available_mapsets()
-    
+
+    mapsets = get_available_temporal_mapsets()
+
     result = {}
-    
-    for mapset in mapsets:
-        
+
+    for mapset in mapsets.keys():
+
         if temporal_type == "absolute":
             table = sp.get_type() + "_view_abs_time"
         else:
@@ -88,54 +92,59 @@
 
         if where:
             sql += " WHERE " + where
-            sql += " AND mapset = '%s'"%(mapset)
+            sql += " AND mapset = '%s'" % (mapset)
         else:
-            sql += " WHERE mapset = '%s'"%(mapset)
+            sql += " WHERE mapset = '%s'" % (mapset)
 
         if order:
             sql += " ORDER BY " + order
 
-        dbif.cursor.execute(sql)
-        rows = dbif.cursor.fetchall()
-        
+        dbif.execute(sql,  mapset=mapset)
+        rows = dbif.fetchall(mapset=mapset)
+
         if rows:
             result[mapset] = rows
-        
+
     return result
-        
+
 ###############################################################################
 
-def list_maps_of_stds(type, input, columns, order, where, separator, method, no_header=False, gran=None):
-    """! List the maps of a space time dataset using diffetent methods
 
-        @param type The type of the maps raster, raster3d or vector
-        @param input Name of a space time raster dataset
-        @param columns A comma separated list of columns to be printed to stdout
-        @param order A comma separated list of columns to order the
+def list_maps_of_stds(type, input, columns, order, where, separator,
+                      method, no_header=False, gran=None):
+    """ List the maps of a space time dataset using diffetent methods
+
+        :param type: The type of the maps raster, raster3d or vector
+        :param input: Name of a space time raster dataset
+        :param columns: A comma separated list of columns to be printed to stdout
+        :param order: A comma separated list of columns to order the
                       maps by category
-        @param where A where statement for selected listing without "WHERE"
+        :param where: A where statement for selected listing without "WHERE"
                       e.g: start_time < "2001-01-01" and end_time > "2001-01-01"
-        @param separator The field separator character between the columns
-        @param method String identifier to select a method out of cols,
+        :param separator: The field separator character between the columns
+        :param method: String identifier to select a method out of cols,
                        comma,delta or deltagaps
+
             - "cols" Print preselected columns specified by columns
             - "comma" Print the map ids ("name at mapset") as comma separated string
             - "delta" Print the map ids ("name at mapset") with start time,
-                       end time, relative length of intervals and the relative
-                       distance to the begin
+               end time, relative length of intervals and the relative
+               distance to the begin
             - "deltagaps" Same as "delta" with additional listing of gaps.
-                           Gaps can be simply identified as the id is "None"
+              Gaps can be simply identified as the id is "None"
             - "gran" List map using the granularity of the space time dataset,
-                      columns are identical to deltagaps
-       @param no_header Supress the printing of column names
-        @param gran The user defined granule to be used if method=gran is set, in case gran=None the
-            granule of the space time dataset is used
+              columns are identical to deltagaps
+
+        :param no_header: Supress the printing of column names
+        :param gran: The user defined granule to be used if method=gran is
+                     set, in case gran=None the granule of the space time
+                     dataset is used
     """
 
     dbif, connected = init_dbif(None)
     msgr = get_tgis_message_interface()
 
-    sp = open_old_space_time_dataset(input, type, dbif)
+    sp = open_old_stds(input, type, dbif)
 
     if separator is None or separator == "":
         separator = "\t"
@@ -147,12 +156,16 @@
         else:
             columns = "id,name,mapset,start_time,end_time"
         if method == "deltagaps":
-            maps = sp.get_registered_maps_as_objects_with_gaps(where=where, dbif=dbif)
+            maps = sp.get_registered_maps_as_objects_with_gaps(where=where,
+                                                               dbif=dbif)
         elif method == "delta":
-            maps = sp.get_registered_maps_as_objects(where=where, order="start_time", dbif=dbif)
+            maps = sp.get_registered_maps_as_objects(where=where,
+                                                     order="start_time",
+                                                     dbif=dbif)
         elif method == "gran":
             if gran is not None and gran != "":
-                maps = sp.get_registered_maps_as_objects_by_granularity(gran=gran, dbif=dbif)
+                maps = sp.get_registered_maps_as_objects_by_granularity(gran=gran,
+                                                                        dbif=dbif)
             else:
                 maps = sp.get_registered_maps_as_objects_by_granularity(dbif=dbif)
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/mapcalc.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,15 +1,12 @@
-"""!@package grass.temporal
+"""
+Raster and 3d raster mapcalculation functions
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in Python scripts.
-
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from space_time_datasets import *
@@ -23,7 +20,7 @@
 
 def dataset_mapcalculator(inputs, output, type, expression, base, method,
                           nprocs=1, register_null=False, spatial=False):
-    """!Perform map-calculations of maps from different space time
+    """Perform map-calculations of maps from different space time
        raster/raster3d datasets, using a specific sampling method
        to select temporal related maps.
 
@@ -32,6 +29,7 @@
        the r.mapcalc operators:
 
        Supported operators for relative and absolute time are:
+
        - td() - the time delta of the current interval in days
                 and fractions of days or the unit in case of relative time
        - start_time() - The start time of the interval from the begin of
@@ -42,6 +40,7 @@
                       unit in case of relative time
 
        Supported operators for absolute time:
+
        - start_doy() - Day of year (doy) from the start time [1 - 366]
        - start_dow() - Day of week (dow) from the start time [1 - 7],
                        the start of the week is monday == 1
@@ -64,17 +63,17 @@
        - end_minute() - The minute of the end time [0 - 59]
        - end_second() - The minute of the end time [0 - 59]
 
-       @param inputs The names of the input space time raster/raster3d datasets
-       @param output The name of the extracted new space time raster(3d) dataset
-       @param type The type of the dataset: "raster" or "raster3d"
-       @param expression The r(3).mapcalc expression
-       @param base The base name of the new created maps in case a
+       :param inputs: The names of the input space time raster/raster3d datasets
+       :param output: The name of the extracted new space time raster(3d) dataset
+       :param type: The type of the dataset: "raster" or "raster3d"
+       :param expression: The r(3).mapcalc expression
+       :param base: The base name of the new created maps in case a
               mapclac expression is provided
-       @param method The method to be used for temporal sampling
-       @param nprocs The number of parallel processes to be used for
+       :param method: The method to be used for temporal sampling
+       :param nprocs: The number of parallel processes to be used for
               mapcalc processing
-       @param register_null Set this number True to register empty maps
-       @param spatial Check spatial overlap
+       :param register_null: Set this number True to register empty maps
+       :param spatial: Check spatial overlap
     """
 
     # We need a database interface for fast computation
@@ -86,7 +85,7 @@
 
     input_name_list = inputs.split(",")
 
-    first_input = open_old_space_time_dataset(input_name_list[0], type, dbif)
+    first_input = open_old_stds(input_name_list[0], type, dbif)
 
     # All additional inputs in reverse sorted order to avoid
     # wrong name substitution
@@ -96,11 +95,10 @@
     input_list = []
 
     for input in input_name_list:
-        sp = open_old_space_time_dataset(input, type, dbif)
+        sp = open_old_stds(input, type, dbif)
         input_list.append(copy.copy(sp))
 
-    new_sp = check_new_space_time_dataset(output, type, dbif,
-                                         gscript.overwrite())
+    new_sp = check_new_stds(output, type, dbif, gscript.overwrite())
 
     # Sample all inputs by the first input and create a sample matrix
     if spatial:
@@ -284,10 +282,8 @@
 
         temporal_type, semantic_type, title, description = first_input.get_initial_values()
 
-        new_sp = open_new_space_time_dataset(output, type,
-                                         temporal_type, title, description,
-                                         semantic_type, dbif,
-                                         gscript.overwrite())
+        new_sp = open_new_stds(output, type, temporal_type, title, description,
+                               semantic_type, dbif, gscript.overwrite())
         count = 0
 
         # collect empty maps to remove them
@@ -332,9 +328,11 @@
                     names += ",%s" % (map.get_name())
                 count += 1
             if type == "raster":
-                gscript.run_command("g.remove", type='rast', name=names, quiet=True, flags='f')
+                gscript.run_command("g.remove", flags='f', type='rast',
+                                    name=names, quiet=True)
             elif type == "raster3d":
-                gscript.run_command("g.remove", type='rast3d', name=names, quiet=True, flags='f')
+                gscript.run_command("g.remove", flags='f', type='rast3d',
+                                    name=names, quiet=True)
 
     dbif.close()
 
@@ -368,37 +366,38 @@
        the temporal operators with numerical values.
 
        Supported operators for relative and absolute time are:
-       * td() - the time delta of the current interval in days
+
+       - td() - the time delta of the current interval in days
          and fractions of days or the unit in case of relative time
-       * start_time() - The start time of the interval from the begin of the
+       - start_time() - The start time of the interval from the begin of the
                         time series in days and fractions of days or the unit
                         in case of relative time
-       * end_time() - The end time of the current interval from the begin of
+       - end_time() - The end time of the current interval from the begin of
                       the time series in days and fractions of days or the
                       unit in case of relative time
 
        Supported operators for absolute time:
-       * start_doy() - Day of year (doy) from the start time [1 - 366]
-       * start_dow() - Day of week (dow) from the start time [1 - 7],
-                       the start of the week is monday == 1
-       * start_year() - The year of the start time [0 - 9999]
-       * start_month() - The month of the start time [1 - 12]
-       * start_week() - Week of year of the start time [1 - 54]
-       * start_day() - Day of month from the start time [1 - 31]
-       * start_hour() - The hour of the start time [0 - 23]
-       * start_minute() - The minute of the start time [0 - 59]
-       * start_second() - The second of the start time [0 - 59]
 
-       * end_doy() - Day of year (doy) from the end time [1 - 366]
-       * end_dow() - Day of week (dow) from the end time [1 - 7],
+       - start_doy() - Day of year (doy) from the start time [1 - 366]
+       - start_dow() - Day of week (dow) from the start time [1 - 7],
+                       the start of the week is monday == 1
+       - start_year() - The year of the start time [0 - 9999]
+       - start_month() - The month of the start time [1 - 12]
+       - start_week() - Week of year of the start time [1 - 54]
+       - start_day() - Day of month from the start time [1 - 31]
+       - start_hour() - The hour of the start time [0 - 23]
+       - start_minute() - The minute of the start time [0 - 59]
+       - start_second() - The second of the start time [0 - 59]
+       - end_doy() - Day of year (doy) from the end time [1 - 366]
+       - end_dow() - Day of week (dow) from the end time [1 - 7],
                      the start of the week is monday == 1
-       * end_year() - The year of the end time [0 - 9999]
-       * end_month() - The month of the end time [1 - 12]
-       * end_week() - Week of year of the end time [1 - 54]
-       * end_day() - Day of month from the end time [1 - 31]
-       * end_hour() - The hour of the end time [0 - 23]
-       * end_minute() - The minute of the end time [0 - 59]
-       * end_second() - The minute of the end time [0 - 59]
+       - end_year() - The year of the end time [0 - 9999]
+       - end_month() - The month of the end time [1 - 12]
+       - end_week() - Week of year of the end time [1 - 54]
+       - end_day() - Day of month from the end time [1 - 31]
+       - end_hour() - The hour of the end time [0 - 23]
+       - end_minute() - The minute of the end time [0 - 59]
+       - end_second() - The minute of the end time [0 - 59]
 
        The modified expression is returned.
 
@@ -419,16 +418,16 @@
 def _parse_start_operators(expr, is_time_absolute, current):
     """
        Supported operators for absolute time:
-       * start_doy() - Day of year (doy) from the start time [1 - 366]
-       * start_dow() - Day of week (dow) from the start time [1 - 7],
+       - start_doy() - Day of year (doy) from the start time [1 - 366]
+       - start_dow() - Day of week (dow) from the start time [1 - 7],
                        the start of the week is monday == 1
-       * start_year() - The year of the start time [0 - 9999]
-       * start_month() - The month of the start time [1 - 12]
-       * start_week() - Week of year of the start time [1 - 54]
-       * start_day() - Day of month from the start time [1 - 31]
-       * start_hour() - The hour of the start time [0 - 23]
-       * start_minute() - The minute of the start time [0 - 59]
-       * start_second() - The second of the start time [0 - 59]
+       - start_year() - The year of the start time [0 - 9999]
+       - start_month() - The month of the start time [1 - 12]
+       - start_week() - Week of year of the start time [1 - 54]
+       - start_day() - Day of month from the start time [1 - 31]
+       - start_hour() - The hour of the start time [0 - 23]
+       - start_minute() - The minute of the start time [0 - 59]
+       - start_second() - The second of the start time [0 - 59]
     """
 
     start, end = current.get_absolute_time()
@@ -436,55 +435,55 @@
 
     if expr.find("start_year()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_year()", str(start.year))
 
     if expr.find("start_month()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_month()", str(start.month))
 
     if expr.find("start_week()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_week()", str(start.isocalendar()[1]))
 
     if expr.find("start_day()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_day()", str(start.day))
 
     if expr.find("start_hour()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_hour()", str(start.hour))
 
     if expr.find("start_minute()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_minute()", str(start.minute))
 
     if expr.find("start_second()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_second()", str(start.second))
 
     if expr.find("start_dow()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         expr = expr.replace("start_dow()", str(start.isoweekday()))
 
     if expr.find("start_doy()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("start_*")))
         year = datetime(start.year, 1, 1)
         delta = start - year
@@ -510,7 +509,7 @@
        - end_minute() - The minute of the end time [0 - 59]
        - end_second() - The minute of the end time [0 - 59]
 
-       In case of time instances the end_* expression will be replaced by
+       In case of time instances the end* expression will be replaced by
        null()
     """
 
@@ -519,7 +518,7 @@
 
     if expr.find("end_year()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_year()", "null()")
@@ -528,7 +527,7 @@
 
     if expr.find("end_month()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_month()", "null()")
@@ -537,7 +536,7 @@
 
     if expr.find("end_week()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_week()", "null()")
@@ -546,7 +545,7 @@
 
     if expr.find("end_day()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_day()", "null()")
@@ -555,7 +554,7 @@
 
     if expr.find("end_hour()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_hour()", "null()")
@@ -564,7 +563,7 @@
 
     if expr.find("end_minute()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_minute()", "null()")
@@ -573,7 +572,7 @@
 
     if expr.find("end_second()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_second()", "null()")
@@ -582,7 +581,7 @@
 
     if expr.find("end_dow()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_dow()", "null()")
@@ -591,7 +590,7 @@
 
     if expr.find("end_doy()") >= 0:
         if not is_time_absolute:
-            msgr.fatal(_("The temporal operators <%s> support only absolute "\
+            msgr.fatal(_("The temporal operators <%s> support only absolute "
                          "time." % ("end_*")))
         if not end:
             expr = expr.replace("end_doy()", "null()")
@@ -618,11 +617,11 @@
         td = "null()"
         if is_time_absolute:
             start, end = current.get_absolute_time()
-            if end != None:
+            if end is not None:
                 td = time_delta_to_relative_time(end - start)
         else:
             start, end, unit = current.get_relative_time()
-            if end != None:
+            if end is not None:
                 td = end - start
         expr = expr.replace("td()", str(td))
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/metadata.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/metadata.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/metadata.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,30 +1,25 @@
-"""!@package grass.temporal
+"""
+Metadata classes for map layer and space time datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related metadata functions to be used in Python scripts and tgis packages.
-
 Usage:
 
- at code
+.. code-block:: python
 
->>> import grass.temporal as tgis
->>> tgis.init()
->>> meta = tgis.RasterMetadata()
->>> meta = tgis.Raster3DMetadata()
->>> meta = tgis.VectorMetadata()
->>> meta = tgis.STRDSMetadata()
->>> meta = tgis.STR3DSMetadata()
->>> meta = tgis.STVDSMetadata()
+    >>> import grass.temporal as tgis
+    >>> tgis.init()
+    >>> meta = tgis.RasterMetadata()
+    >>> meta = tgis.Raster3DMetadata()
+    >>> meta = tgis.VectorMetadata()
+    >>> meta = tgis.STRDSMetadata()
+    >>> meta = tgis.STR3DSMetadata()
+    >>> meta = tgis.STVDSMetadata()
 
- at endcode
-
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 from base import *
 
@@ -32,56 +27,55 @@
 
 
 class RasterMetadataBase(SQLDatabaseInterface):
-    """!This is the metadata base class for time stamped raster and raster3d maps
+    """This is the metadata base class for time stamped raster and raster3d maps
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = RasterMetadataBase(table="metadata", ident="soil at PERMANENT",
-        ... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
-        ... ewres=0.1, min=0, max=100)
-        >>> meta.datatype
-        'CELL'
-        >>> meta.cols
-        100
-        >>> meta.rows
-        100
-        >>> meta.number_of_cells
-        10000
-        >>> meta.nsres
-        0.1
-        >>> meta.ewres
-        0.1
-        >>> meta.min
-        0.0
-        >>> meta.max
-        100.0
-        >>> meta.print_info()
-         | Datatype:................... CELL
-         | Number of columns:.......... 100
-         | Number of rows:............. 100
-         | Number of cells:............ 10000
-         | North-South resolution:..... 0.1
-         | East-west resolution:....... 0.1
-         | Minimum value:.............. 0.0
-         | Maximum value:.............. 100.0
-        >>> meta.print_shell_info()
-        datatype=CELL
-        cols=100
-        rows=100
-        number_of_cells=10000
-        nsres=0.1
-        ewres=0.1
-        min=0.0
-        max=100.0
+            >>> init()
+            >>> meta = RasterMetadataBase(table="metadata", ident="soil at PERMANENT",
+            ... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
+            ... ewres=0.1, min=0, max=100)
+            >>> meta.datatype
+            'CELL'
+            >>> meta.cols
+            100
+            >>> meta.rows
+            100
+            >>> meta.number_of_cells
+            10000
+            >>> meta.nsres
+            0.1
+            >>> meta.ewres
+            0.1
+            >>> meta.min
+            0.0
+            >>> meta.max
+            100.0
+            >>> meta.print_info()
+             | Datatype:................... CELL
+             | Number of columns:.......... 100
+             | Number of rows:............. 100
+             | Number of cells:............ 10000
+             | North-South resolution:..... 0.1
+             | East-west resolution:....... 0.1
+             | Minimum value:.............. 0.0
+             | Maximum value:.............. 100.0
+            >>> meta.print_shell_info()
+            datatype=CELL
+            cols=100
+            rows=100
+            number_of_cells=10000
+            nsres=0.1
+            ewres=0.1
+            min=0.0
+            max=100.0
 
-        @endcode
     """
     def __init__(self, table=None, ident=None, datatype=None, cols=None,
-		rows=None, number_of_cells=None, nsres=None, ewres=None,
-		min=None, max=None):
+                 rows=None, number_of_cells=None, nsres=None, ewres=None,
+                 min=None, max=None):
 
         SQLDatabaseInterface.__init__(self, table, ident)
 
@@ -96,66 +90,66 @@
         self.set_max(max)
 
     def set_id(self, ident):
-        """!Convenient method to set the unique identifier (primary key)"""
+        """Convenient method to set the unique identifier (primary key)"""
         self.ident = ident
         self.D["id"] = ident
 
     def set_datatype(self, datatype):
-        """!Set the datatype"""
+        """Set the datatype"""
         self.D["datatype"] = datatype
 
     def set_cols(self, cols):
-        """!Set the number of cols"""
+        """Set the number of cols"""
         if cols is not None:
             self.D["cols"] = int(cols)
         else:
             self.D["cols"] = None
 
     def set_rows(self, rows):
-        """!Set the number of rows"""
+        """Set the number of rows"""
         if rows is not None:
             self.D["rows"] = int(rows)
         else:
             self.D["rows"] = None
 
     def set_number_of_cells(self, number_of_cells):
-        """!Set the number of cells"""
+        """Set the number of cells"""
         if number_of_cells is not None:
             self.D["number_of_cells"] = int(number_of_cells)
         else:
             self.D["number_of_cells"] = None
 
     def set_nsres(self, nsres):
-        """!Set the north-south resolution"""
+        """Set the north-south resolution"""
         if nsres is not None:
             self.D["nsres"] = float(nsres)
         else:
             self.D["nsres"] = None
 
     def set_ewres(self, ewres):
-        """!Set the east-west resolution"""
+        """Set the east-west resolution"""
         if ewres is not None:
             self.D["ewres"] = float(ewres)
         else:
             self.D["ewres"] = None
 
     def set_min(self, min):
-        """!Set the minimum raster value"""
+        """Set the minimum raster value"""
         if min is not None:
             self.D["min"] = float(min)
         else:
             self.D["min"] = None
 
     def set_max(self, max):
-        """!Set the maximum raster value"""
+        """Set the maximum raster value"""
         if max is not None:
             self.D["max"] = float(max)
         else:
             self.D["max"] = None
 
     def get_id(self):
-        """!Convenient method to get the unique identifier (primary key)
-           @return None if not found
+        """Convenient method to get the unique identifier (primary key)
+           :return: None if not found
         """
         if "id" in self.D:
             return self.D["id"]
@@ -163,64 +157,64 @@
             return None
 
     def get_datatype(self):
-        """!Get the map type
-           @return None if not found"""
+        """Get the map type
+           :return: None if not found"""
         if "datatype" in self.D:
             return self.D["datatype"]
         else:
             return None
 
     def get_cols(self):
-        """!Get number of cols
-           @return None if not found"""
+        """Get number of cols
+           :return: None if not found"""
         if "cols" in self.D:
             return self.D["cols"]
         else:
             return None
 
     def get_rows(self):
-        """!Get number of rows
-           @return None if not found"""
+        """Get number of rows
+           :return: None if not found"""
         if "rows" in self.D:
             return self.D["rows"]
         else:
             return None
 
     def get_number_of_cells(self):
-        """!Get number of cells
-           @return None if not found"""
+        """Get number of cells
+           :return: None if not found"""
         if "number_of_cells" in self.D:
             return self.D["number_of_cells"]
         else:
             return None
 
     def get_nsres(self):
-        """!Get the north-south resolution
-           @return None if not found"""
+        """Get the north-south resolution
+           :return: None if not found"""
         if "nsres" in self.D:
             return self.D["nsres"]
         else:
             return None
 
     def get_ewres(self):
-        """!Get east-west resolution
-           @return None if not found"""
+        """Get east-west resolution
+           :return: None if not found"""
         if "ewres" in self.D:
             return self.D["ewres"]
         else:
             return None
 
     def get_min(self):
-        """!Get the minimum cell value
-           @return None if not found"""
+        """Get the minimum cell value
+           :return: None if not found"""
         if "min" in self.D:
             return self.D["min"]
         else:
             return None
 
     def get_max(self):
-        """!Get the maximum cell value
-           @return None if not found"""
+        """Get the maximum cell value
+           :return: None if not found"""
         if "max" in self.D:
             return self.D["max"]
         else:
@@ -230,14 +224,15 @@
     datatype = property(fget=get_datatype, fset=set_datatype)
     cols = property(fget=get_cols, fset=set_cols)
     rows = property(fget=get_rows, fset=set_rows)
-    number_of_cells = property(fget=get_number_of_cells, fset=set_number_of_cells)
+    number_of_cells = property(fget=get_number_of_cells,
+                               fset=set_number_of_cells)
     nsres = property(fget=get_nsres, fset=set_nsres)
     ewres = property(fget=get_ewres, fset=set_ewres)
     min = property(fget=get_min, fset=set_min)
     max = property(fget=get_max, fset=set_max)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " | Datatype:................... " + str(self.get_datatype())
         print " | Number of columns:.......... " + str(self.get_cols())
@@ -250,7 +245,7 @@
         print " | Maximum value:.............. " + str(self.get_max())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         print "datatype=" + str(self.get_datatype())
         print "cols=" + str(self.get_cols())
         print "rows=" + str(self.get_rows())
@@ -264,7 +259,7 @@
 
 
 class RasterMetadata(RasterMetadataBase):
-    """!This is the raster metadata class
+    """This is the raster metadata class
 
         This class is the interface to the raster_metadata table in the
         temporal database that stores the metadata of all registered raster maps.
@@ -275,73 +270,72 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = RasterMetadata(ident="soil at PERMANENT",
-        ... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
-        ... ewres=0.1, min=0, max=100)
-        >>> meta.datatype
-        'CELL'
-        >>> meta.cols
-        100
-        >>> meta.rows
-        100
-        >>> meta.number_of_cells
-        10000
-        >>> meta.nsres
-        0.1
-        >>> meta.ewres
-        0.1
-        >>> meta.min
-        0.0
-        >>> meta.max
-        100.0
-        >>> meta.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Datatype:................... CELL
-         | Number of columns:.......... 100
-         | Number of rows:............. 100
-         | Number of cells:............ 10000
-         | North-South resolution:..... 0.1
-         | East-west resolution:....... 0.1
-         | Minimum value:.............. 0.0
-         | Maximum value:.............. 100.0
-        >>> meta.print_shell_info()
-        datatype=CELL
-        cols=100
-        rows=100
-        number_of_cells=10000
-        nsres=0.1
-        ewres=0.1
-        min=0.0
-        max=100.0
+            >>> init()
+            >>> meta = RasterMetadata(ident="soil at PERMANENT",
+            ... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
+            ... ewres=0.1, min=0, max=100)
+            >>> meta.datatype
+            'CELL'
+            >>> meta.cols
+            100
+            >>> meta.rows
+            100
+            >>> meta.number_of_cells
+            10000
+            >>> meta.nsres
+            0.1
+            >>> meta.ewres
+            0.1
+            >>> meta.min
+            0.0
+            >>> meta.max
+            100.0
+            >>> meta.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Datatype:................... CELL
+             | Number of columns:.......... 100
+             | Number of rows:............. 100
+             | Number of cells:............ 10000
+             | North-South resolution:..... 0.1
+             | East-west resolution:....... 0.1
+             | Minimum value:.............. 0.0
+             | Maximum value:.............. 100.0
+            >>> meta.print_shell_info()
+            datatype=CELL
+            cols=100
+            rows=100
+            number_of_cells=10000
+            nsres=0.1
+            ewres=0.1
+            min=0.0
+            max=100.0
 
-        @endcode
     """
     def __init__(self, ident=None, datatype=None,
-		 cols=None, rows=None, number_of_cells=None, nsres=None,
-		 ewres=None, min=None, max=None):
+                 cols=None, rows=None, number_of_cells=None, nsres=None,
+                 ewres=None, min=None, max=None):
 
         RasterMetadataBase.__init__(self, "raster_metadata", ident, datatype,
-                                      cols, rows, number_of_cells, nsres,
-                                      ewres, min, max)
+                                    cols, rows, number_of_cells, nsres,
+                                    ewres, min, max)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         print " +-------------------- Metadata information ----------------------------------+"
         #      0123456789012345678901234567890
         RasterMetadataBase.print_info(self)
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         RasterMetadataBase.print_shell_info(self)
 
 ###############################################################################
 
 
 class Raster3DMetadata(RasterMetadataBase):
-    """!This is the raster3d metadata class
+    """This is the raster3d metadata class
 
         This class is the interface to the raster3d_metadata table in the
         temporal database that stores the metadata of all registered
@@ -353,95 +347,94 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = Raster3DMetadata(ident="soil at PERMANENT",
-        ... datatype="FCELL", cols=100, rows=100, depths=100,
-        ... number_of_cells=1000000, nsres=0.1, ewres=0.1, tbres=0.1,
-        ... min=0, max=100)
-        >>> meta.datatype
-        'FCELL'
-        >>> meta.cols
-        100
-        >>> meta.rows
-        100
-        >>> meta.depths
-        100
-        >>> meta.number_of_cells
-        1000000
-        >>> meta.nsres
-        0.1
-        >>> meta.ewres
-        0.1
-        >>> meta.tbres
-        0.1
-        >>> meta.min
-        0.0
-        >>> meta.max
-        100.0
-        >>> meta.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Datatype:................... FCELL
-         | Number of columns:.......... 100
-         | Number of rows:............. 100
-         | Number of cells:............ 1000000
-         | North-South resolution:..... 0.1
-         | East-west resolution:....... 0.1
-         | Minimum value:.............. 0.0
-         | Maximum value:.............. 100.0
-         | Number of depths:........... 100
-         | Top-Bottom resolution:...... 0.1
-        >>> meta.print_shell_info()
-        datatype=FCELL
-        cols=100
-        rows=100
-        number_of_cells=1000000
-        nsres=0.1
-        ewres=0.1
-        min=0.0
-        max=100.0
-        depths=100
-        tbres=0.1
+            >>> init()
+            >>> meta = Raster3DMetadata(ident="soil at PERMANENT",
+            ... datatype="FCELL", cols=100, rows=100, depths=100,
+            ... number_of_cells=1000000, nsres=0.1, ewres=0.1, tbres=0.1,
+            ... min=0, max=100)
+            >>> meta.datatype
+            'FCELL'
+            >>> meta.cols
+            100
+            >>> meta.rows
+            100
+            >>> meta.depths
+            100
+            >>> meta.number_of_cells
+            1000000
+            >>> meta.nsres
+            0.1
+            >>> meta.ewres
+            0.1
+            >>> meta.tbres
+            0.1
+            >>> meta.min
+            0.0
+            >>> meta.max
+            100.0
+            >>> meta.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Datatype:................... FCELL
+             | Number of columns:.......... 100
+             | Number of rows:............. 100
+             | Number of cells:............ 1000000
+             | North-South resolution:..... 0.1
+             | East-west resolution:....... 0.1
+             | Minimum value:.............. 0.0
+             | Maximum value:.............. 100.0
+             | Number of depths:........... 100
+             | Top-Bottom resolution:...... 0.1
+            >>> meta.print_shell_info()
+            datatype=FCELL
+            cols=100
+            rows=100
+            number_of_cells=1000000
+            nsres=0.1
+            ewres=0.1
+            min=0.0
+            max=100.0
+            depths=100
+            tbres=0.1
 
-        @endcode
     """
     def __init__(self, ident=None, datatype=None,
-		 cols=None, rows=None, depths=None, number_of_cells=None,
-		 nsres=None, ewres=None, tbres=None, min=None, max=None):
+                 cols=None, rows=None, depths=None, number_of_cells=None,
+                 nsres=None, ewres=None, tbres=None, min=None, max=None):
 
         RasterMetadataBase.__init__(self, "raster3d_metadata", ident,
-				datatype, cols, rows, number_of_cells, nsres,
-				ewres, min, max)
+                                    datatype, cols, rows, number_of_cells,
+                                    nsres,	ewres, min, max)
 
         self.set_tbres(tbres)
         self.set_depths(depths)
 
     def set_depths(self, depths):
-        """!Set the number of depths"""
+        """Set the number of depths"""
         if depths is not None:
             self.D["depths"] = int(depths)
         else:
             self.D["depths"] = None
 
     def set_tbres(self, tbres):
-        """!Set the top-bottom resolution"""
+        """Set the top-bottom resolution"""
         if tbres is not None:
             self.D["tbres"] = float(tbres)
         else:
             self.D["tbres"] = None
 
     def get_depths(self):
-        """!Get number of depths
-           @return None if not found"""
+        """Get number of depths
+           :return: None if not found"""
         if "depths" in self.D:
             return self.D["depths"]
         else:
             return None
 
     def get_tbres(self):
-        """!Get top-bottom resolution
-           @return None if not found"""
+        """Get top-bottom resolution
+           :return: None if not found"""
         if "tbres" in self.D:
             return self.D["tbres"]
         else:
@@ -451,7 +444,7 @@
     tbres = property(fget=get_tbres, fset=set_tbres)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         print " +-------------------- Metadata information ----------------------------------+"
         #      0123456789012345678901234567890
         RasterMetadataBase.print_info(self)
@@ -460,7 +453,7 @@
         print " | Top-Bottom resolution:...... " + str(self.get_tbres())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         RasterMetadataBase.print_shell_info(self)
         print "depths=" + str(self.get_depths())
         print "tbres=" + str(self.get_tbres())
@@ -469,7 +462,7 @@
 
 
 class VectorMetadata(SQLDatabaseInterface):
-    """!This is the vector metadata class
+    """This is the vector metadata class
 
         This class is the interface to the vector_metadata table in the
         temporal database that stores the metadata of all registered
@@ -477,80 +470,80 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = VectorMetadata(ident="lidar at PERMANENT", is_3d=True,
-        ... number_of_points=1, number_of_lines=2, number_of_boundaries=3,
-        ... number_of_centroids=4, number_of_faces=5, number_of_kernels=6,
-        ... number_of_primitives=7, number_of_nodes=8, number_of_areas=9,
-        ... number_of_islands=10, number_of_holes=11, number_of_volumes=12)
-        >>> meta.id
-        'lidar at PERMANENT'
-        >>> meta.is_3d
-        True
-        >>> meta.number_of_points
-        1
-        >>> meta.number_of_lines
-        2
-        >>> meta.number_of_boundaries
-        3
-        >>> meta.number_of_centroids
-        4
-        >>> meta.number_of_faces
-        5
-        >>> meta.number_of_kernels
-        6
-        >>> meta.number_of_primitives
-        7
-        >>> meta.number_of_nodes
-        8
-        >>> meta.number_of_areas
-        9
-        >>> meta.number_of_islands
-        10
-        >>> meta.number_of_holes
-        11
-        >>> meta.number_of_volumes
-        12
-        >>> meta.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Is map 3d .................. True
-         | Number of points ........... 1
-         | Number of lines ............ 2
-         | Number of boundaries ....... 3
-         | Number of centroids ........ 4
-         | Number of faces ............ 5
-         | Number of kernels .......... 6
-         | Number of primitives ....... 7
-         | Number of nodes ............ 8
-         | Number of areas ............ 9
-         | Number of islands .......... 10
-         | Number of holes ............ 11
-         | Number of volumes .......... 12
-        >>> meta.print_shell_info()
-        is_3d=True
-        points=1
-        lines=2
-        boundaries=3
-        centroids=4
-        faces=5
-        kernels=6
-        primitives=7
-        nodes=8
-        areas=9
-        islands=10
-        holes=11
-        volumes=12
+            >>> init()
+            >>> meta = VectorMetadata(ident="lidar at PERMANENT", is_3d=True,
+            ... number_of_points=1, number_of_lines=2, number_of_boundaries=3,
+            ... number_of_centroids=4, number_of_faces=5, number_of_kernels=6,
+            ... number_of_primitives=7, number_of_nodes=8, number_of_areas=9,
+            ... number_of_islands=10, number_of_holes=11, number_of_volumes=12)
+            >>> meta.id
+            'lidar at PERMANENT'
+            >>> meta.is_3d
+            True
+            >>> meta.number_of_points
+            1
+            >>> meta.number_of_lines
+            2
+            >>> meta.number_of_boundaries
+            3
+            >>> meta.number_of_centroids
+            4
+            >>> meta.number_of_faces
+            5
+            >>> meta.number_of_kernels
+            6
+            >>> meta.number_of_primitives
+            7
+            >>> meta.number_of_nodes
+            8
+            >>> meta.number_of_areas
+            9
+            >>> meta.number_of_islands
+            10
+            >>> meta.number_of_holes
+            11
+            >>> meta.number_of_volumes
+            12
+            >>> meta.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Is map 3d .................. True
+             | Number of points ........... 1
+             | Number of lines ............ 2
+             | Number of boundaries ....... 3
+             | Number of centroids ........ 4
+             | Number of faces ............ 5
+             | Number of kernels .......... 6
+             | Number of primitives ....... 7
+             | Number of nodes ............ 8
+             | Number of areas ............ 9
+             | Number of islands .......... 10
+             | Number of holes ............ 11
+             | Number of volumes .......... 12
+            >>> meta.print_shell_info()
+            is_3d=True
+            points=1
+            lines=2
+            boundaries=3
+            centroids=4
+            faces=5
+            kernels=6
+            primitives=7
+            nodes=8
+            areas=9
+            islands=10
+            holes=11
+            volumes=12
 
-        @endcode
     """
-    def __init__(
-        self, ident=None, is_3d=False,
-        number_of_points=None, number_of_lines=None, number_of_boundaries=None,
-        number_of_centroids=None, number_of_faces=None, number_of_kernels=None,
-        number_of_primitives=None, number_of_nodes=None, number_of_areas=None,
-        number_of_islands=None, number_of_holes=None, number_of_volumes=None):
+    def __init__(self, ident=None, is_3d=False, number_of_points=None,
+                 number_of_lines=None, number_of_boundaries=None,
+                 number_of_centroids=None, number_of_faces=None,
+                 number_of_kernels=None, number_of_primitives=None,
+                 number_of_nodes=None, number_of_areas=None,
+                 number_of_islands=None, number_of_holes=None,
+                 number_of_volumes=None):
 
         SQLDatabaseInterface.__init__(self, "vector_metadata", ident)
 
@@ -570,65 +563,65 @@
         self.set_number_of_volumes(number_of_volumes)
 
     def set_id(self, ident):
-        """!Convenient method to set the unique identifier (primary key)"""
+        """Convenient method to set the unique identifier (primary key)"""
         self.ident = ident
         self.D["id"] = ident
 
     def set_3d_info(self, is_3d):
-        """!Set True if the vector map is three dimensional"""
+        """Set True if the vector map is three dimensional"""
         self.D["is_3d"] = is_3d
 
     def set_number_of_points(self, number_of_points):
-        """!Set the number of points of the vector map"""
+        """Set the number of points of the vector map"""
         self.D["points"] = number_of_points
 
     def set_number_of_lines(self, number_of_lines):
-        """!Set the number of lines of the vector map"""
+        """Set the number of lines of the vector map"""
         self.D["lines"] = number_of_lines
 
     def set_number_of_boundaries(self, number_of_boundaries):
-        """!Set the number of boundaries of the vector map"""
+        """Set the number of boundaries of the vector map"""
         self.D["boundaries"] = number_of_boundaries
 
     def set_number_of_centroids(self, number_of_centroids):
-        """!Set the number of centroids of the vector map"""
+        """Set the number of centroids of the vector map"""
         self.D["centroids"] = number_of_centroids
 
     def set_number_of_faces(self, number_of_faces):
-        """!Set the number of faces of the vector map"""
+        """Set the number of faces of the vector map"""
         self.D["faces"] = number_of_faces
 
     def set_number_of_kernels(self, number_of_kernels):
-        """!Set the number of kernels of the vector map"""
+        """Set the number of kernels of the vector map"""
         self.D["kernels"] = number_of_kernels
 
     def set_number_of_primitives(self, number_of_primitives):
-        """!Set the number of primitives of the vector map"""
+        """Set the number of primitives of the vector map"""
         self.D["primitives"] = number_of_primitives
 
     def set_number_of_nodes(self, number_of_nodes):
-        """!Set the number of nodes of the vector map"""
+        """Set the number of nodes of the vector map"""
         self.D["nodes"] = number_of_nodes
 
     def set_number_of_areas(self, number_of_areas):
-        """!Set the number of areas of the vector map"""
+        """Set the number of areas of the vector map"""
         self.D["areas"] = number_of_areas
 
     def set_number_of_islands(self, number_of_islands):
-        """!Set the number of islands of the vector map"""
+        """Set the number of islands of the vector map"""
         self.D["islands"] = number_of_islands
 
     def set_number_of_holes(self, number_of_holes):
-        """!Set the number of holes of the vector map"""
+        """Set the number of holes of the vector map"""
         self.D["holes"] = number_of_holes
 
     def set_number_of_volumes(self, number_of_volumes):
-        """!Set the number of volumes of the vector map"""
+        """Set the number of volumes of the vector map"""
         self.D["volumes"] = number_of_volumes
 
     def get_id(self):
-        """!Convenient method to get the unique identifier (primary key)
-           @return None if not found
+        """Convenient method to get the unique identifier (primary key)
+           :return: None if not found
         """
         if "id" in self.D:
             return self.D["id"]
@@ -636,7 +629,7 @@
             return None
 
     def get_3d_info(self):
-        """!Return True if the map is three dimensional,
+        """Return True if the map is three dimensional,
            False if not and None if not info was found"""
         if "is_3d" in self.D:
             return self.D["is_3d"]
@@ -644,104 +637,104 @@
             return None
 
     def get_number_of_points(self):
-        """!Get the number of points of the vector map
-           @return None if not found"""
+        """Get the number of points of the vector map
+           :return: None if not found"""
         if "points" in self.D:
             return self.D["points"]
         else:
             return None
 
     def get_number_of_lines(self):
-        """!Get the number of lines of the vector map
-           @return None if not found"""
+        """Get the number of lines of the vector map
+           :return: None if not found"""
         if "lines" in self.D:
             return self.D["lines"]
         else:
             return None
 
     def get_number_of_boundaries(self):
-        """!Get the number of boundaries of the vector map
-           @return None if not found"""
+        """Get the number of boundaries of the vector map
+           :return: None if not found"""
         if "boundaries" in self.D:
             return self.D["boundaries"]
         else:
             return None
 
     def get_number_of_centroids(self):
-        """!Get the number of centroids of the vector map
-           @return None if not found"""
+        """Get the number of centroids of the vector map
+           :return: None if not found"""
         if "centroids" in self.D:
             return self.D["centroids"]
         else:
             return None
 
     def get_number_of_faces(self):
-        """!Get the number of faces of the vector map
-           @return None if not found"""
+        """Get the number of faces of the vector map
+           :return: None if not found"""
         if "faces" in self.D:
             return self.D["faces"]
         else:
             return None
 
     def get_number_of_kernels(self):
-        """!Get the number of kernels of the vector map
-           @return None if not found"""
+        """Get the number of kernels of the vector map
+           :return: None if not found"""
         if "kernels" in self.D:
             return self.D["kernels"]
         else:
             return None
 
     def get_number_of_primitives(self):
-        """!Get the number of primitives of the vector map
-           @return None if not found"""
+        """Get the number of primitives of the vector map
+           :return: None if not found"""
         if "primitives" in self.D:
             return self.D["primitives"]
         else:
             return None
 
     def get_number_of_nodes(self):
-        """!Get the number of nodes of the vector map
-           @return None if not found"""
+        """Get the number of nodes of the vector map
+           :return: None if not found"""
         if "nodes" in self.D:
             return self.D["nodes"]
         else:
             return None
 
     def get_number_of_areas(self):
-        """!Get the number of areas of the vector map
-           @return None if not found"""
+        """Get the number of areas of the vector map
+           :return: None if not found"""
         if "areas" in self.D:
             return self.D["areas"]
         else:
             return None
 
     def get_number_of_islands(self):
-        """!Get the number of islands of the vector map
-           @return None if not found"""
+        """Get the number of islands of the vector map
+           :return: None if not found"""
         if "islands" in self.D:
             return self.D["islands"]
         else:
             return None
 
     def get_number_of_holes(self):
-        """!Get the number of holes of the vector map
-           @return None if not found"""
+        """Get the number of holes of the vector map
+           :return: None if not found"""
         if "holes" in self.D:
             return self.D["holes"]
         else:
             return None
 
     def get_number_of_volumes(self):
-        """!Get the number of volumes of the vector map
-           @return None if not found"""
+        """Get the number of volumes of the vector map
+           :return: None if not found"""
         if "volumes" in self.D:
             return self.D["volumes"]
         else:
             return None
 
     # Set the properties
-    id  = property(fget=get_id, fset=set_id)
-    is_3d  = property(fget=get_3d_info, fset=set_3d_info)
+    id = property(fget=get_id, fset=set_id)
+    is_3d = property(fget=get_3d_info, fset=set_3d_info)
     number_of_points = property(fget=get_number_of_points,
                                 fset=set_number_of_points)
     number_of_lines = property(fget=get_number_of_lines,
@@ -768,7 +761,7 @@
                                  fset=set_number_of_volumes)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " +-------------------- Metadata information ----------------------------------+"
         print " | Is map 3d .................. " + str(self.get_3d_info())
@@ -786,7 +779,7 @@
         print " | Number of volumes .......... " + str(self.get_number_of_volumes())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         print "is_3d=" + str(self.get_3d_info())
         print "points=" + str(self.get_number_of_points())
         print "lines=" + str(self.get_number_of_lines())
@@ -805,38 +798,38 @@
 
 
 class STDSMetadataBase(SQLDatabaseInterface):
-    """!This is the space time dataset metadata base class for
+    """This is the space time dataset metadata base class for
        strds, stvds and str3ds datasets
        setting/getting the id, the title and the description
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = STDSMetadataBase(ident="soils at PERMANENT",
-        ... title="Soils", description="Soils 1950 - 2010")
-        >>> meta.id
-        'soils at PERMANENT'
-        >>> meta.title
-        'Soils'
-        >>> meta.description
-        'Soils 1950 - 2010'
-        >>> meta.number_of_maps
-        >>> meta.print_info()
-         | Number of registered maps:.. None
-         |
-         | Title:
-         | Soils
-         | Description:
-         | Soils 1950 - 2010
-         | Command history:
-        >>> meta.print_shell_info()
-        number_of_maps=None
+            >>> init()
+            >>> meta = STDSMetadataBase(ident="soils at PERMANENT",
+            ... title="Soils", description="Soils 1950 - 2010")
+            >>> meta.id
+            'soils at PERMANENT'
+            >>> meta.title
+            'Soils'
+            >>> meta.description
+            'Soils 1950 - 2010'
+            >>> meta.number_of_maps
+            >>> meta.print_info()
+             | Number of registered maps:.. None
+             |
+             | Title:
+             | Soils
+             | Description:
+             | Soils 1950 - 2010
+             | Command history:
+            >>> meta.print_shell_info()
+            number_of_maps=None
 
-        @endcode
     """
-    def __init__(self, table=None, ident=None, title=None, description=None, command=None):
+    def __init__(self, table=None, ident=None, title=None, description=None,
+                 command=None):
 
         SQLDatabaseInterface.__init__(self, table, ident)
 
@@ -848,25 +841,25 @@
         self.D["number_of_maps"] = None
 
     def set_id(self, ident):
-        """!Convenient method to set the unique identifier (primary key)"""
+        """Convenient method to set the unique identifier (primary key)"""
         self.ident = ident
         self.D["id"] = ident
 
     def set_title(self, title):
-        """!Set the title"""
+        """Set the title"""
         self.D["title"] = title
 
     def set_description(self, description):
-        """!Set the number of cols"""
+        """Set the number of cols"""
         self.D["description"] = description
 
     def set_command(self, command):
-        """!Set the number of cols"""
+        """Set the number of cols"""
         self.D["command"] = command
 
     def get_id(self):
-        """!Convenient method to get the unique identifier (primary key)
-           @return None if not found
+        """Convenient method to get the unique identifier (primary key)
+           :return: None if not found
         """
         if "id" in self.D:
             return self.D["id"]
@@ -874,46 +867,46 @@
             return None
 
     def get_title(self):
-        """!Get the title
-           @return None if not found"""
+        """Get the title
+           :return: None if not found"""
         if "title" in self.D:
             return self.D["title"]
         else:
             return None
 
     def get_description(self):
-        """!Get description
-           @return None if not found"""
+        """Get description
+           :return: None if not found"""
         if "description" in self.D:
             return self.D["description"]
         else:
             return None
 
     def get_command(self):
-        """!Get command
-           @return None if not found"""
+        """Get command
+           :return: None if not found"""
         if "command" in self.D:
             return self.D["command"]
         else:
             return None
 
     def get_number_of_maps(self):
-        """!Get the number of registered maps,
+        """Get the number of registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "number_of_maps" in self.D:
             return self.D["number_of_maps"]
         else:
             return None
 
-    id  = property(fget=get_id, fset=set_id)
-    title  = property(fget=get_title, fset=set_title)
-    description  = property(fget=get_description, fset=set_description)
-    number_of_maps  = property(fget=get_number_of_maps)
+    id = property(fget=get_id, fset=set_id)
+    title = property(fget=get_title, fset=set_title)
+    description = property(fget=get_description, fset=set_description)
+    number_of_maps = property(fget=get_number_of_maps)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " | Number of registered maps:.. " + str(
             self.get_number_of_maps())
@@ -929,7 +922,7 @@
                 print " | " + str(token)
 
     def print_history(self):
-        """!Print history information about this class in human readable
+        """Print history information about this class in human readable
             shell style
         """
         #      0123456789012345678901234567890
@@ -960,74 +953,74 @@
                         print token
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         print "number_of_maps=" + str(self.get_number_of_maps())
 
 ###############################################################################
 
 
 class STDSRasterMetadataBase(STDSMetadataBase):
-    """!This is the space time dataset metadata base
+    """This is the space time dataset metadata base
         class for strds and str3ds datasets
 
         Most of the metadata values are set by SQL scripts in the database when
         new maps are added. Therefor only some set- an many
         get-functions are available.
 
-
         Usage:
 
-        @code
-        >>> init()
-        >>> meta = STDSRasterMetadataBase(ident="soils at PERMANENT",
-        ... title="Soils", description="Soils 1950 - 2010")
-        >>> meta.id
-        'soils at PERMANENT'
-        >>> meta.title
-        'Soils'
-        >>> meta.description
-        'Soils 1950 - 2010'
-        >>> meta.number_of_maps
-        >>> meta.min_max
-        >>> meta.max_max
-        >>> meta.min_min
-        >>> meta.max_min
-        >>> meta.nsres_min
-        >>> meta.nsres_max
-        >>> meta.ewres_min
-        >>> meta.ewres_max
-        >>> meta.print_info()
-         | North-South resolution min:. None
-         | North-South resolution max:. None
-         | East-west resolution min:... None
-         | East-west resolution max:... None
-         | Minimum value min:.......... None
-         | Minimum value max:.......... None
-         | Maximum value min:.......... None
-         | Maximum value max:.......... None
-         | Aggregation type:........... None
-         | Number of registered maps:.. None
-         |
-         | Title:
-         | Soils
-         | Description:
-         | Soils 1950 - 2010
-         | Command history:
-        >>> meta.print_shell_info()
-        aggregation_type=None
-        number_of_maps=None
-        nsres_min=None
-        nsres_max=None
-        ewres_min=None
-        ewres_max=None
-        min_min=None
-        min_max=None
-        max_min=None
-        max_max=None
+        .. code-block:: python
 
-        @endcode
+            >>> init()
+            >>> meta = STDSRasterMetadataBase(ident="soils at PERMANENT",
+            ... title="Soils", description="Soils 1950 - 2010")
+            >>> meta.id
+            'soils at PERMANENT'
+            >>> meta.title
+            'Soils'
+            >>> meta.description
+            'Soils 1950 - 2010'
+            >>> meta.number_of_maps
+            >>> meta.min_max
+            >>> meta.max_max
+            >>> meta.min_min
+            >>> meta.max_min
+            >>> meta.nsres_min
+            >>> meta.nsres_max
+            >>> meta.ewres_min
+            >>> meta.ewres_max
+            >>> meta.print_info()
+             | North-South resolution min:. None
+             | North-South resolution max:. None
+             | East-west resolution min:... None
+             | East-west resolution max:... None
+             | Minimum value min:.......... None
+             | Minimum value max:.......... None
+             | Maximum value min:.......... None
+             | Maximum value max:.......... None
+             | Aggregation type:........... None
+             | Number of registered maps:.. None
+             |
+             | Title:
+             | Soils
+             | Description:
+             | Soils 1950 - 2010
+             | Command history:
+            >>> meta.print_shell_info()
+            aggregation_type=None
+            number_of_maps=None
+            nsres_min=None
+            nsres_max=None
+            ewres_min=None
+            ewres_max=None
+            min_min=None
+            min_max=None
+            max_min=None
+            max_max=None
+
     """
-    def __init__(self, table=None, ident=None, title=None, description=None, aggregation_type=None):
+    def __init__(self, table=None, ident=None, title=None, description=None,
+                 aggregation_type=None):
 
         STDSMetadataBase.__init__(self, table, ident, title, description)
 
@@ -1043,93 +1036,93 @@
         self.D["aggregation_type"] = aggregation_type
 
     def set_aggregation_type(self, aggregation_type):
-        """!Set the aggregation type of the dataset (mean, min, max, ...)"""
+        """Set the aggregation type of the dataset (mean, min, max, ...)"""
         self.D["aggregation_type"] = aggregation_type
 
     def get_aggregation_type(self):
-        """!Get the aggregation type of the dataset (mean, min, max, ...)
-           @return None if not found
+        """Get the aggregation type of the dataset (mean, min, max, ...)
+           :return: None if not found
         """
         if "aggregation_type" in self.D:
             return self.D["aggregation_type"]
         else:
             return None
-            
+
     def get_max_min(self):
-        """!Get the minimal maximum of all registered maps,
+        """Get the minimal maximum of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "max_min" in self.D:
             return self.D["max_min"]
         else:
             return None
 
     def get_min_min(self):
-        """!Get the minimal minimum of all registered maps,
+        """Get the minimal minimum of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "min_min" in self.D:
             return self.D["min_min"]
         else:
             return None
 
     def get_max_max(self):
-        """!Get the maximal maximum of all registered maps,
+        """Get the maximal maximum of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "max_max" in self.D:
             return self.D["max_max"]
         else:
             return None
 
     def get_min_max(self):
-        """!Get the maximal minimum of all registered maps,
+        """Get the maximal minimum of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "min_max" in self.D:
             return self.D["min_max"]
         else:
             return None
 
     def get_nsres_min(self):
-        """!Get the minimal north-south resolution of all registered maps,
+        """Get the minimal north-south resolution of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "nsres_min" in self.D:
             return self.D["nsres_min"]
         else:
             return None
 
     def get_nsres_max(self):
-        """!Get the maximal north-south resolution of all registered maps,
+        """Get the maximal north-south resolution of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "nsres_max" in self.D:
             return self.D["nsres_max"]
         else:
             return None
 
     def get_ewres_min(self):
-        """!Get the minimal east-west resolution of all registered maps,
+        """Get the minimal east-west resolution of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "ewres_min" in self.D:
             return self.D["ewres_min"]
         else:
             return None
 
     def get_ewres_max(self):
-        """!Get the maximal east-west resolution of all registered maps,
+        """Get the maximal east-west resolution of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "ewres_max" in self.D:
             return self.D["ewres_max"]
         else:
@@ -1143,11 +1136,11 @@
     min_max = property(fget=get_min_max)
     max_min = property(fget=get_max_min)
     max_max = property(fget=get_max_max)
-    aggregation_type = property(fset=set_aggregation_type, 
+    aggregation_type = property(fset=set_aggregation_type,
                                 fget=get_aggregation_type)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " | North-South resolution min:. " + str(self.get_nsres_min())
         print " | North-South resolution max:. " + str(self.get_nsres_max())
@@ -1161,7 +1154,7 @@
         STDSMetadataBase.print_info(self)
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         print "aggregation_type=" + str(self.get_aggregation_type())
         STDSMetadataBase.print_shell_info(self)
         print "nsres_min=" + str(self.get_nsres_min())
@@ -1177,7 +1170,7 @@
 ###############################################################################
 
 class STRDSMetadata(STDSRasterMetadataBase):
-    """!This is the raster metadata class
+    """This is the raster metadata class
 
         This class is the interface to the strds_metadata table in the
         temporal database that stores the metadata of all registered
@@ -1189,62 +1182,62 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = STRDSMetadata(ident="soils at PERMANENT",
-        ... title="Soils", description="Soils 1950 - 2010")
-        >>> meta.id
-        'soils at PERMANENT'
-        >>> meta.title
-        'Soils'
-        >>> meta.description
-        'Soils 1950 - 2010'
-        >>> meta.number_of_maps
-        >>> meta.min_max
-        >>> meta.max_max
-        >>> meta.min_min
-        >>> meta.max_min
-        >>> meta.nsres_min
-        >>> meta.nsres_max
-        >>> meta.ewres_min
-        >>> meta.ewres_max
-        >>> meta.raster_register
-        >>> meta.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Raster register table:...... None
-         | North-South resolution min:. None
-         | North-South resolution max:. None
-         | East-west resolution min:... None
-         | East-west resolution max:... None
-         | Minimum value min:.......... None
-         | Minimum value max:.......... None
-         | Maximum value min:.......... None
-         | Maximum value max:.......... None
-         | Aggregation type:........... None
-         | Number of registered maps:.. None
-         |
-         | Title:
-         | Soils
-         | Description:
-         | Soils 1950 - 2010
-         | Command history:
-        >>> meta.print_shell_info()
-        aggregation_type=None
-        number_of_maps=None
-        nsres_min=None
-        nsres_max=None
-        ewres_min=None
-        ewres_max=None
-        min_min=None
-        min_max=None
-        max_min=None
-        max_max=None
-        raster_register=None
+            >>> init()
+            >>> meta = STRDSMetadata(ident="soils at PERMANENT",
+            ... title="Soils", description="Soils 1950 - 2010")
+            >>> meta.id
+            'soils at PERMANENT'
+            >>> meta.title
+            'Soils'
+            >>> meta.description
+            'Soils 1950 - 2010'
+            >>> meta.number_of_maps
+            >>> meta.min_max
+            >>> meta.max_max
+            >>> meta.min_min
+            >>> meta.max_min
+            >>> meta.nsres_min
+            >>> meta.nsres_max
+            >>> meta.ewres_min
+            >>> meta.ewres_max
+            >>> meta.raster_register
+            >>> meta.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Raster register table:...... None
+             | North-South resolution min:. None
+             | North-South resolution max:. None
+             | East-west resolution min:... None
+             | East-west resolution max:... None
+             | Minimum value min:.......... None
+             | Minimum value max:.......... None
+             | Maximum value min:.......... None
+             | Maximum value max:.......... None
+             | Aggregation type:........... None
+             | Number of registered maps:.. None
+             |
+             | Title:
+             | Soils
+             | Description:
+             | Soils 1950 - 2010
+             | Command history:
+            >>> meta.print_shell_info()
+            aggregation_type=None
+            number_of_maps=None
+            nsres_min=None
+            nsres_max=None
+            ewres_min=None
+            ewres_max=None
+            min_min=None
+            min_max=None
+            max_min=None
+            max_max=None
+            raster_register=None
 
-        @endcode
     """
-    def __init__(self, ident=None, raster_register=None, title=None, description=None):
+    def __init__(self, ident=None, raster_register=None, title=None,
+                 description=None):
 
         STDSRasterMetadataBase.__init__(
             self, "strds_metadata", ident, title, description)
@@ -1252,12 +1245,12 @@
         self.set_raster_register(raster_register)
 
     def set_raster_register(self, raster_register):
-        """!Set the raster map register table name"""
+        """Set the raster map register table name"""
         self.D["raster_register"] = raster_register
 
     def get_raster_register(self):
-        """!Get the raster map register table name
-           @return None if not found"""
+        """Get the raster map register table name
+           :return: None if not found"""
         if "raster_register" in self.D:
             return self.D["raster_register"]
         else:
@@ -1267,7 +1260,7 @@
                                fset=set_raster_register)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         print " +-------------------- Metadata information ----------------------------------+"
         #      0123456789012345678901234567890
         print " | Raster register table:...... " + str(
@@ -1275,7 +1268,7 @@
         STDSRasterMetadataBase.print_info(self)
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         STDSRasterMetadataBase.print_shell_info(self)
         print "raster_register=" + str(self.get_raster_register())
 
@@ -1283,7 +1276,7 @@
 
 
 class STR3DSMetadata(STDSRasterMetadataBase):
-    """!This is the space time 3D raster metadata class
+    """This is the space time 3D raster metadata class
 
         This class is the interface to the str3ds_metadata table in the
         temporal database that stores the metadata of all registered
@@ -1295,68 +1288,68 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = STR3DSMetadata(ident="soils at PERMANENT",
-        ... title="Soils", description="Soils 1950 - 2010")
-        >>> meta.id
-        'soils at PERMANENT'
-        >>> meta.title
-        'Soils'
-        >>> meta.description
-        'Soils 1950 - 2010'
-        >>> meta.number_of_maps
-        >>> meta.min_max
-        >>> meta.max_max
-        >>> meta.min_min
-        >>> meta.max_min
-        >>> meta.nsres_min
-        >>> meta.nsres_max
-        >>> meta.ewres_min
-        >>> meta.ewres_max
-        >>> meta.tbres_min
-        >>> meta.tbres_max
-        >>> meta.raster3d_register
-        >>> meta.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | 3D raster register table:... None
-         | Top-bottom resolution min:.. None
-         | Top-bottom resolution max:.. None
-         | North-South resolution min:. None
-         | North-South resolution max:. None
-         | East-west resolution min:... None
-         | East-west resolution max:... None
-         | Minimum value min:.......... None
-         | Minimum value max:.......... None
-         | Maximum value min:.......... None
-         | Maximum value max:.......... None
-         | Aggregation type:........... None
-         | Number of registered maps:.. None
-         |
-         | Title:
-         | Soils
-         | Description:
-         | Soils 1950 - 2010
-         | Command history:
-        >>> meta.print_shell_info()
-        aggregation_type=None
-        number_of_maps=None
-        nsres_min=None
-        nsres_max=None
-        ewres_min=None
-        ewres_max=None
-        min_min=None
-        min_max=None
-        max_min=None
-        max_max=None
-        tbres_min=None
-        tbres_max=None
-        raster3d_register=None
+            >>> init()
+            >>> meta = STR3DSMetadata(ident="soils at PERMANENT",
+            ... title="Soils", description="Soils 1950 - 2010")
+            >>> meta.id
+            'soils at PERMANENT'
+            >>> meta.title
+            'Soils'
+            >>> meta.description
+            'Soils 1950 - 2010'
+            >>> meta.number_of_maps
+            >>> meta.min_max
+            >>> meta.max_max
+            >>> meta.min_min
+            >>> meta.max_min
+            >>> meta.nsres_min
+            >>> meta.nsres_max
+            >>> meta.ewres_min
+            >>> meta.ewres_max
+            >>> meta.tbres_min
+            >>> meta.tbres_max
+            >>> meta.raster3d_register
+            >>> meta.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | 3D raster register table:... None
+             | Top-bottom resolution min:.. None
+             | Top-bottom resolution max:.. None
+             | North-South resolution min:. None
+             | North-South resolution max:. None
+             | East-west resolution min:... None
+             | East-west resolution max:... None
+             | Minimum value min:.......... None
+             | Minimum value max:.......... None
+             | Maximum value min:.......... None
+             | Maximum value max:.......... None
+             | Aggregation type:........... None
+             | Number of registered maps:.. None
+             |
+             | Title:
+             | Soils
+             | Description:
+             | Soils 1950 - 2010
+             | Command history:
+            >>> meta.print_shell_info()
+            aggregation_type=None
+            number_of_maps=None
+            nsres_min=None
+            nsres_max=None
+            ewres_min=None
+            ewres_max=None
+            min_min=None
+            min_max=None
+            max_min=None
+            max_max=None
+            tbres_min=None
+            tbres_max=None
+            raster3d_register=None
 
-        @endcode
         """
-    def __init__(self, ident=None, raster3d_register=None, title=None, description=None):
+    def __init__(self, ident=None, raster3d_register=None, title=None,
+                 description=None):
 
         STDSRasterMetadataBase.__init__(
             self, "str3ds_metadata", ident, title, description)
@@ -1366,44 +1359,44 @@
         self.D["tbres_max"] = None
 
     def set_raster3d_register(self, raster3d_register):
-        """!Set the raster map register table name"""
+        """Set the raster map register table name"""
         self.D["raster3d_register"] = raster3d_register
 
     def get_raster3d_register(self):
-        """!Get the raster3d map register table name
-           @return None if not found"""
+        """Get the raster3d map register table name
+           :return: None if not found"""
         if "raster3d_register" in self.D:
             return self.D["raster3d_register"]
         else:
             return None
 
     def get_tbres_min(self):
-        """!Get the minimal top-bottom resolution of all registered maps,
+        """Get the minimal top-bottom resolution of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "tbres_min" in self.D:
             return self.D["tbres_min"]
         else:
             return None
 
     def get_tbres_max(self):
-        """!Get the maximal top-bottom resolution of all registered maps,
+        """Get the maximal top-bottom resolution of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "tbres_max" in self.D:
             return self.D["tbres_max"]
         else:
             return None
 
     raster3d_register = property(fget=get_raster3d_register,
-                               fset=set_raster3d_register)
+                                 fset=set_raster3d_register)
     tbres_min = property(fget=get_tbres_min)
     tbres_max = property(fget=get_tbres_max)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         print " +-------------------- Metadata information ----------------------------------+"
         #      0123456789012345678901234567890
         #      0123456789012345678901234567890
@@ -1414,7 +1407,7 @@
         STDSRasterMetadataBase.print_info(self)
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         STDSRasterMetadataBase.print_shell_info(self)
         print "tbres_min=" + str(self.get_tbres_min())
         print "tbres_max=" + str(self.get_tbres_max())
@@ -1422,8 +1415,9 @@
 
 ###############################################################################
 
+
 class STVDSMetadata(STDSMetadataBase):
-    """!This is the space time vector dataset metadata class
+    """This is the space time vector dataset metadata class
 
        This class is the interface to the stvds_metadata table in the
        temporal database that stores the metadata of all registered
@@ -1435,72 +1429,71 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> meta = STVDSMetadata(ident="lidars at PERMANENT",
-        ... title="LIDARS", description="LIDARS 2008 - 2010")
-        >>> meta.id
-        'lidars at PERMANENT'
-        >>> meta.title
-        'LIDARS'
-        >>> meta.description
-        'LIDARS 2008 - 2010'
-        >>> meta.number_of_maps
-        >>> meta.number_of_points
-        >>> meta.number_of_lines
-        >>> meta.number_of_boundaries
-        >>> meta.number_of_centroids
-        >>> meta.number_of_faces
-        >>> meta.number_of_kernels
-        >>> meta.number_of_primitives
-        >>> meta.number_of_nodes
-        >>> meta.number_of_areas
-        >>> meta.number_of_islands
-        >>> meta.number_of_holes
-        >>> meta.number_of_volumes
-        >>> meta.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Vector register table:...... None
-         | Number of points ........... None
-         | Number of lines ............ None
-         | Number of boundaries ....... None
-         | Number of centroids ........ None
-         | Number of faces ............ None
-         | Number of kernels .......... None
-         | Number of primitives ....... None
-         | Number of nodes ............ None
-         | Number of areas ............ None
-         | Number of islands .......... None
-         | Number of holes ............ None
-         | Number of volumes .......... None
-         | Number of registered maps:.. None
-         |
-         | Title:
-         | LIDARS
-         | Description:
-         | LIDARS 2008 - 2010
-         | Command history:
-        >>> meta.print_shell_info()
-        number_of_maps=None
-        vector_register=None
-        points=None
-        lines=None
-        boundaries=None
-        centroids=None
-        faces=None
-        kernels=None
-        primitives=None
-        nodes=None
-        areas=None
-        islands=None
-        holes=None
-        volumes=None
+            >>> init()
+            >>> meta = STVDSMetadata(ident="lidars at PERMANENT",
+            ... title="LIDARS", description="LIDARS 2008 - 2010")
+            >>> meta.id
+            'lidars at PERMANENT'
+            >>> meta.title
+            'LIDARS'
+            >>> meta.description
+            'LIDARS 2008 - 2010'
+            >>> meta.number_of_maps
+            >>> meta.number_of_points
+            >>> meta.number_of_lines
+            >>> meta.number_of_boundaries
+            >>> meta.number_of_centroids
+            >>> meta.number_of_faces
+            >>> meta.number_of_kernels
+            >>> meta.number_of_primitives
+            >>> meta.number_of_nodes
+            >>> meta.number_of_areas
+            >>> meta.number_of_islands
+            >>> meta.number_of_holes
+            >>> meta.number_of_volumes
+            >>> meta.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Vector register table:...... None
+             | Number of points ........... None
+             | Number of lines ............ None
+             | Number of boundaries ....... None
+             | Number of centroids ........ None
+             | Number of faces ............ None
+             | Number of kernels .......... None
+             | Number of primitives ....... None
+             | Number of nodes ............ None
+             | Number of areas ............ None
+             | Number of islands .......... None
+             | Number of holes ............ None
+             | Number of volumes .......... None
+             | Number of registered maps:.. None
+             |
+             | Title:
+             | LIDARS
+             | Description:
+             | LIDARS 2008 - 2010
+             | Command history:
+            >>> meta.print_shell_info()
+            number_of_maps=None
+            vector_register=None
+            points=None
+            lines=None
+            boundaries=None
+            centroids=None
+            faces=None
+            kernels=None
+            primitives=None
+            nodes=None
+            areas=None
+            islands=None
+            holes=None
+            volumes=None
 
-        @endcode
     """
-    def __init__(
-        self, ident=None, vector_register=None, title=None, description=None):
+    def __init__(self, ident=None, vector_register=None, title=None,
+                 description=None):
 
         STDSMetadataBase.__init__(
             self, "stvds_metadata", ident, title, description)
@@ -1520,140 +1513,140 @@
         self.D["volumes"] = None
 
     def set_vector_register(self, vector_register):
-        """!Set the vector map register table name"""
+        """Set the vector map register table name"""
         self.D["vector_register"] = vector_register
 
     def get_vector_register(self):
-        """!Get the vector map register table name
-           @return None if not found"""
+        """Get the vector map register table name
+           :return: None if not found"""
         if "vector_register" in self.D:
             return self.D["vector_register"]
         else:
             return None
 
     def get_number_of_points(self):
-        """!Get the number of points of all registered maps,
+        """Get the number of points of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "points" in self.D:
             return self.D["points"]
         else:
             return None
 
     def get_number_of_lines(self):
-        """!Get the number of lines of all registered maps,
+        """Get the number of lines of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "lines" in self.D:
             return self.D["lines"]
         else:
             return None
 
     def get_number_of_boundaries(self):
-        """!Get the number of boundaries of all registered maps,
+        """Get the number of boundaries of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "boundaries" in self.D:
             return self.D["boundaries"]
         else:
             return None
 
     def get_number_of_centroids(self):
-        """!Get the number of centroids of all registered maps,
+        """Get the number of centroids of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "centroids" in self.D:
             return self.D["centroids"]
         else:
             return None
 
     def get_number_of_faces(self):
-        """!Get the number of faces of all registered maps,
+        """Get the number of faces of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "faces" in self.D:
             return self.D["faces"]
         else:
             return None
 
     def get_number_of_kernels(self):
-        """!Get the number of kernels of all registered maps,
+        """Get the number of kernels of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "kernels" in self.D:
             return self.D["kernels"]
         else:
             return None
 
     def get_number_of_primitives(self):
-        """!Get the number of primitives of all registered maps,
+        """Get the number of primitives of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "primitives" in self.D:
             return self.D["primitives"]
         else:
             return None
 
     def get_number_of_nodes(self):
-        """!Get the number of nodes of all registered maps,
+        """Get the number of nodes of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "nodes" in self.D:
             return self.D["nodes"]
         else:
             return None
 
     def get_number_of_areas(self):
-        """!Get the number of areas of all registered maps,
+        """Get the number of areas of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "areas" in self.D:
             return self.D["areas"]
         else:
             return None
 
     def get_number_of_islands(self):
-        """!Get the number of islands of all registered maps,
+        """Get the number of islands of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "islands" in self.D:
             return self.D["islands"]
         else:
             return None
 
     def get_number_of_holes(self):
-        """!Get the number of holes of all registered maps,
+        """Get the number of holes of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "holes" in self.D:
             return self.D["holes"]
         else:
             return None
 
     def get_number_of_volumes(self):
-        """!Get the number of volumes of all registered maps,
+        """Get the number of volumes of all registered maps,
            this value is set in the database
            automatically via SQL, so no setter exists
-           @return None if not found"""
+           :return: None if not found"""
         if "volumes" in self.D:
             return self.D["volumes"]
         else:
             return None
 
     # Set the properties
-    vector_register  = property(fget=get_vector_register,
-                                fset=set_vector_register)
+    vector_register = property(fget=get_vector_register,
+                               fset=set_vector_register)
     number_of_points = property(fget=get_number_of_points)
     number_of_lines = property(fget=get_number_of_lines)
     number_of_boundaries = property(fget=get_number_of_boundaries)
@@ -1668,7 +1661,7 @@
     number_of_volumes = property(fget=get_number_of_volumes)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         print " +-------------------- Metadata information ----------------------------------+"
         #      0123456789012345678901234567890
         print " | Vector register table:...... " + str(
@@ -1688,7 +1681,7 @@
         STDSMetadataBase.print_info(self)
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         STDSMetadataBase.print_shell_info(self)
         print "vector_register=" + str(self.get_vector_register())
         print "points=" + str(self.get_number_of_points())

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/open_stds.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/open_stds.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/open_stds.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,44 +1,44 @@
-"""!@package grass.temporal
+"""
+Functions to open or create space time datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
+Usage:
 
-Temporal GIS related functions to be used in Python scripts.
+.. code-block:: python
 
-Usage:
+    import grass.temporal as tgis
 
- at code
-import grass.temporal as tgis
+    tgis.register_maps_in_space_time_dataset(type, name, maps)
 
-tgis.register_maps_in_space_time_dataset(type, name, maps)
 
-...
- at endcode
-
 (C) 2012-2014 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from factory import *
 
 ###############################################################################
 
-def open_old_space_time_dataset(name, type, dbif=None):
-    """!This function opens an existing space time dataset and return the
+
+def open_old_stds(name, type, dbif=None):
+    """This function opens an existing space time dataset and return the
        created and intialized object of the specified type.
 
-       This function will call exit() or raise a grass.pygrass.messages.FatalError in case the type is wrong,
+       This function will call exit() or raise a
+       grass.pygrass.messages.FatalError in case the type is wrong,
        or the space time dataset was not found.
 
-       @param name The name of the space time dataset, if the name does not
+       :param name: The name of the space time dataset, if the name does not
                     contain the mapset (name at mapset) then the current mapset
                     will be used to identifiy the space time dataset
-       @param type The type of the space time dataset (strd, str3ds, stvds,
-                                                       raster, vector, raster3d)
-       @param dbif The optional database interface to be used
+       :param type: The type of the space time dataset (strd, str3ds, stvds,
+                    raster, vector, raster3d)
+       :param dbif: The optional database interface to be used
+       
+       :return: New stds object
 
     """
     mapset = get_current_mapset()
@@ -64,8 +64,8 @@
     if not sp.is_in_db(dbif):
         dbif.close()
         msgr.fatal(_("Space time %(sp)s dataset <%(name)s> no found") %
-                     {'sp': sp.get_new_map_instance(None).get_type(),
-                      'name': name})
+                   {'sp': sp.get_new_map_instance(None).get_type(),
+                    'name': name})
 
     # Read content from temporal database
     sp.select(dbif)
@@ -76,22 +76,23 @@
 
 ###############################################################################
 
-def check_new_space_time_dataset(name, type, dbif=None, overwrite=False):
-    """!Check if a new space time dataset of a specific type can be created
 
-       @param name The name of the new space time dataset
-       @param type The type of the new space time dataset (strd, str3ds, stvds,
-                                                      raster, vector, raster3d)
-       @param dbif The temporal database interface to be used
-       @param overwrite Flag to allow overwriting
+def check_new_stds(name, type, dbif=None, overwrite=False):
+    """Check if a new space time dataset of a specific type can be created
 
-       @return A space time dataset object that must be filled with
+       :param name: The name of the new space time dataset
+       :param type: The type of the new space time dataset (strd, str3ds,
+                    stvds, raster, vector, raster3d)
+       :param dbif: The temporal database interface to be used
+       :param overwrite: Flag to allow overwriting
+
+       :return: A space time dataset object that must be filled with
                content before insertion in the temporal database
 
-       This function will raise a ScriptError in case of an error.
+       This function will raise a FatalError in case of an error.
     """
 
-    #Get the current mapset to create the id of the space time dataset
+    # Get the current mapset to create the id of the space time dataset
 
     mapset = get_current_mapset()
     msgr = get_tgis_message_interface()
@@ -119,9 +120,9 @@
 
     if sp.is_in_db(dbif) and overwrite is False:
         msgr.fatal(_("Space time %(sp)s dataset <%(name)s> is already in the"
-                      " database. Use the overwrite flag.") % {
-                      'sp': sp.get_new_map_instance(None).get_type(),
-                      'name': name})
+                     " database. Use the overwrite flag.") % {
+                   'sp': sp.get_new_map_instance(None).get_type(),
+                   'name': name})
     if connected:
         dbif.close()
 
@@ -129,39 +130,40 @@
 
 ###############################################################################
 
-def open_new_space_time_dataset(name, type, temporaltype, title, descr, semantic,
-                              dbif=None, overwrite=False):
-    """!Create a new space time dataset of a specific type
 
-       @param name The name of the new space time dataset
-       @param type The type of the new space time dataset (strd, str3ds, stvds,
-                                                      raster, vector, raster3d)
-       @param temporaltype The temporal type (relative or absolute)
-       @param title The title
-       @param descr The dataset description
-       @param semantic Semantical information
-       @param dbif The temporal database interface to be used
-       @param overwrite Flag to allow overwriting
+def open_new_stds(name, type, temporaltype, title, descr, semantic,
+                  dbif=None, overwrite=False):
+    """Create a new space time dataset of a specific type
 
-       @return The new created space time dataset
+       :param name: The name of the new space time dataset
+       :param type: The type of the new space time dataset (strd, str3ds,
+                    stvds, raster, vector, raster3d)
+       :param temporaltype: The temporal type (relative or absolute)
+       :param title: The title
+       :param descr: The dataset description
+       :param semantic: Semantical information
+       :param dbif: The temporal database interface to be used
+       :param overwrite: Flag to allow overwriting
 
+       :return: The new created space time dataset
+
        This function will raise a FatalError in case of an error.
     """
     dbif, connected = init_dbif(dbif)
     msgr = get_tgis_message_interface()
-    sp =  check_new_space_time_dataset(name, type, dbif, overwrite)
+    sp = check_new_stds(name, type, dbif, overwrite)
 
     if sp.is_in_db(dbif):
         msgr.warning(_("Overwriting space time %(sp)s dataset <%(name)s> and "
                        "unregistering all maps") % {
-                       'sp': sp.get_new_map_instance(None).get_type(),
-                       'name': name})
+                     'sp': sp.get_new_map_instance(None).get_type(),
+                     'name': name})
         id = sp.get_id()
         sp.delete(dbif)
         sp = sp.get_new_instance(id)
 
     msgr.verbose(_("Creating a new space time %s dataset") %
-                   sp.get_new_map_instance(None).get_type())
+                 sp.get_new_map_instance(None).get_type())
 
     sp.set_initial_values(temporal_type=temporaltype, semantic_type=semantic,
                           title=title, description=descr)
@@ -175,20 +177,21 @@
 
 ############################################################################
 
+
 def check_new_map_dataset(name, layer=None, type="raster",
                           overwrite=False, dbif=None):
-    """!Check if a new map dataset of a specific type can be created in
+    """Check if a new map dataset of a specific type can be created in
         the temporal database
 
-       @param name The name of the new map dataset
-       @param layer The layer of the new map dataset
-       @param type The type of the new map dataset (raster, vector, raster3d)
-       @param dbif The temporal database interface to be used
-       @param overwrite Flag to allow overwriting
+       :param name: The name of the new map dataset
+       :param layer: The layer of the new map dataset
+       :param type: The type of the new map dataset (raster, vector, raster3d)
+       :param dbif: The temporal database interface to be used
+       :param overwrite: Flag to allow overwriting
 
-       @return A map dataset object
+       :return: A map dataset object
 
-       This function will raise a ScriptError in case of an error.
+       This function will raise a FatalError in case of an error.
     """
     mapset = get_current_mapset()
     msgr = get_tgis_message_interface()
@@ -212,21 +215,21 @@
 
 ############################################################################
 
+
 def open_new_map_dataset(name, layer=None, type="raster",
                          temporal_extent=None, overwrite=False,
                          dbif=None):
-    """!Create a new map dataset object of a specific type that can be
+    """Create a new map dataset object of a specific type that can be
         registered in the temporal database
 
-       @param name The name of the new map dataset
-       @param layer The layer of the new map dataset
-       @param type The type of the new map dataset (raster, vector, raster3d)
-       @param dbif The temporal database interface to be used
-       @param overwrite Flag to allow overwriting
+       :param name: The name of the new map dataset
+       :param layer: The layer of the new map dataset
+       :param type: The type of the new map dataset (raster, vector, raster3d)
+       :param dbif: The temporal database interface to be used
+       :param overwrite: Flag to allow overwriting
 
-       @return A map dataset object
+       :return: A map dataset object
 
-       This function will raise a ScriptError in case of an error.
     """
 
     mapset = get_current_mapset()

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/register.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/register.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/register.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,28 +1,24 @@
-"""!@package grass.temporal
+"""
+Functions to register map layer in space time datasets and the temporal database
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in Python scripts.
-
 Usage:
 
- at code
-import grass.temporal as tgis
+.. code-block:: python
 
-tgis.register_maps_in_space_time_dataset(type, name, maps)
+    import grass.temporal as tgis
 
-...
- at endcode
+    tgis.register_maps_in_space_time_dataset(type, name, maps)
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from open_stds import *
+import grass.script as gscript
 
 ###############################################################################
 
@@ -31,7 +27,7 @@
     type, name, maps=None, file=None, start=None,
     end=None, unit=None, increment=None, dbif=None,
         interval=False, fs="|", update_cmd_list=True):
-    """!Use this method to register maps in space time datasets.
+    """Use this method to register maps in space time datasets.
 
        Additionally a start time string and an increment string can be
        specified to assign a time interval automatically to the maps.
@@ -39,29 +35,30 @@
        It takes care of the correct update of the space time datasets from all
        registered maps.
 
-       @param type The type of the maps rast, rast3d or vect
-       @param name The name of the space time dataset. Maps will be registered in the
-                   temporal database if the name was set to None
-       @param maps A comma separated list of map names
-       @param file Input file, one map per line map with start and optional
+       :param type: The type of the maps rast, rast3d or vect
+       :param name: The name of the space time dataset. Maps will be
+                    registered in the temporal database if the name was set
+                    to None
+       :param maps: A comma separated list of map names
+       :param file: Input file, one map per line map with start and optional
                    end time
-       @param start The start date and time of the first raster map
+       :param start: The start date and time of the first raster map
                     (format absolute: "yyyy-mm-dd HH:MM:SS" or "yyyy-mm-dd",
                     format relative is integer 5)
-       @param end The end date and time of the first raster map
+       :param end: The end date and time of the first raster map
                   (format absolute: "yyyy-mm-dd HH:MM:SS" or "yyyy-mm-dd",
                   format relative is integer 5)
-       @param unit The unit of the relative time: years, months, days,
+       :param unit: The unit of the relative time: years, months, days,
                    hours, minutes, seconds
-       @param increment Time increment between maps for time stamp creation
+       :param increment: Time increment between maps for time stamp creation
                         (format absolute: NNN seconds, minutes, hours, days,
                         weeks, months, years; format relative: 1.0)
-       @param dbif The database interface to be used
-       @param interval If True, time intervals are created in case the start
+       :param dbif: The database interface to be used
+       :param interval: If True, time intervals are created in case the start
                        time and an increment is provided
-       @param fs Field separator used in input file
-       @param update_cmd_list If is True, the command that was invoking this process
-                              will be written to the process history
+       :param fs: Field separator used in input file
+       :param update_cmd_list: If is True, the command that was invoking this
+                               process will be written to the process history
     """
     start_time_in_file = False
     end_time_in_file = False
@@ -76,35 +73,32 @@
         increment = str(increment)
 
     if maps and file:
-        msgr.fatal(_("%(m)s= and %(f)s= are mutually exclusive") % {'m': "maps",
-                                                                    'f': "file"})
+        msgr.fatal(_("%s= and %s= are mutually exclusive") % ("maps", "file"))
 
     if end and increment:
-        msgr.fatal(_("%(e)s= and %(i)s= are mutually exclusive") % {'e': "end",
-                   'i': "increment"})
+        msgr.fatal(_("%s= and %s= are mutually exclusive") % ("end",
+                                                              "increment"))
 
     if end and not start:
-        msgr.fatal(_("Please specify %(st)s= and %(e)s=") % {'st': "start_time",
-                                                             'e': "end_time"})
+        msgr.fatal(_("Please specify %s= and %s=") % ("start_time",
+                                                      "end_time"))
 
     if not maps and not file:
-        msgr.fatal(_("Please specify %(m)s= or %(f)s=") % {'m': "maps",
-                                                           'f': "file"})
+        msgr.fatal(_("Please specify %s= or %s=") % ("maps", "file"))
     # We may need the mapset
     mapset = get_current_mapset()
     dbif, connected = init_dbif(None)
 
     # The name of the space time dataset is optional
     if name:
-        sp = open_old_space_time_dataset(name, type, dbif)
+        sp = open_old_stds(name, type, dbif)
 
         if sp.is_time_relative() and (start or end) and not unit:
             dbif.close()
             msgr.fatal(_("Space time %(sp)s dataset <%(name)s> with relative"
                          " time found, but no relative unit set for %(sp)s "
-                         "maps") % {
-                         'sp': sp.get_new_map_instance(None).get_type(),
-                         'name': name})
+                         "maps") % {'name': name,
+                       'sp': sp.get_new_map_instance(None).get_type()})
 
     maplist = []
 
@@ -174,12 +168,11 @@
 
         # Get a new instance of the map type
         map = dataset_factory(type, maplist[count]["id"])
-        
+
         if map.map_exists() is not True:
             msgr.fatal(_("Unable to update %(t)s map <%(id)s>. "
-                            "The map does not exist.") %
-                            {'t': map.get_type(),
-                            'id': map.get_map_id()})
+                         "The map does not exist.") % {'t': map.get_type(),
+                                                       'id': map.get_map_id()})
 
         # Use the time data from file
         if "start" in maplist[count]:
@@ -198,20 +191,22 @@
                     msgr.fatal(_("Unable to register %(t)s map <%(id)s> with "
                                  "layer %(l)s. The map has timestamp and "
                                  "the start time is not set.") % {
-                                 't': map.get_type(), 'id': map.get_map_id(),
-                                 'l': map.get_layer()})
+                               't': map.get_type(), 'id': map.get_map_id(),
+                               'l': map.get_layer()})
                 else:
                     msgr.fatal(_("Unable to register %(t)s map <%(id)s>. The"
                                  " map has no timestamp and the start time "
                                  "is not set.") % {'t': map.get_type(),
                                                    'id': map.get_map_id()})
-            if start != "" and start != None:
+            if start != "" and start is not None:
                 # We need to check if the time is absolute and the unit was specified
                 time_object = check_datetime_string(start)
                 if isinstance(time_object, datetime) and unit:
-                    msgr.fatal(_("%(u)s= can only be set for relative time") % {'u': "unit"})
+                    msgr.fatal(_("%(u)s= can only be set for relative time") %
+                               {'u': "unit"})
                 if not isinstance(time_object, datetime) and not unit:
-                    msgr.fatal(_("%(u)s= must be set in case of relative time stamps") % {'u': "unit"})
+                    msgr.fatal(_("%(u)s= must be set in case of relative time"
+                                 " stamps") % {'u': "unit"})
 
                 if unit:
                     map.set_time_to_relative()
@@ -221,7 +216,7 @@
         else:
             is_in_db = True
             # Check the overwrite flag
-            if not core.overwrite():
+            if not gscript.overwrite():
                 if map.get_layer():
                     msgr.warning(_("Map is already registered in temporal "
                                    "database. Unable to update %(t)s map "
@@ -232,8 +227,8 @@
                 else:
                     msgr.warning(_("Map is already registered in temporal "
                                    "database. Unable to update %(t)s map "
-                                   "<%(id)s>. Overwrite flag is not set.") % {
-                                   't': map.get_type(), 'id': map.get_map_id()})
+                                   "<%(id)s>. Overwrite flag is not set.") %
+                                 {'t': map.get_type(), 'id': map.get_map_id()})
 
                 # Simple registration is allowed
                 if name:
@@ -257,13 +252,13 @@
                         msgr.fatal(_("Unable to update %(t)s map <%(id)s> "
                                      "with layer %(l)s. The temporal types "
                                      "are different.") % {'t': map.get_type(),
-                                                        'id': map.get_map_id(),
-                                                        'l': map.get_layer()})
+                                                          'id': map.get_map_id(),
+                                                          'l': map.get_layer()})
                     else:
                         msgr.fatal(_("Unable to update %(t)s map <%(id)s>. "
                                      "The temporal types are different.") %
-                                     {'t': map.get_type(),
-                                      'id': map.get_map_id()})
+                                   {'t': map.get_type(),
+                                    'id': map.get_map_id()})
 
         # Load the data from the grass file database
         map.load()
@@ -293,7 +288,7 @@
 
         # Sqlite3 performance is better for huge datasets when committing in
         # small chunks
-        if dbif.dbmi.__name__ == "sqlite3":
+        if dbif.get_dbmi().__name__ == "sqlite3":
             if count % 100 == 0:
                 if statement is not None and statement != "":
                     dbif.execute_transaction(statement)
@@ -339,7 +334,7 @@
             ds.select(dbif)
             ds.update_from_registered_maps(dbif)
 
-    if connected == True:
+    if connected is True:
         dbif.close()
 
     msgr.percent(num_maps, num_maps, 1)
@@ -349,24 +344,24 @@
 
 def assign_valid_time_to_map(ttype, map, start, end, unit, increment=None,
                              mult=1, interval=False):
-    """!Assign the valid time to a map dataset
+    """Assign the valid time to a map dataset
 
-       @param ttype The temporal type which should be assigned
+       :param ttype: The temporal type which should be assigned
                      and which the time format is of
-       @param map A map dataset object derived from abstract_map_dataset
-       @param start The start date and time of the first raster map
+       :param map: A map dataset object derived from abstract_map_dataset
+       :param start: The start date and time of the first raster map
                      (format absolute: "yyyy-mm-dd HH:MM:SS" or "yyyy-mm-dd",
                      format relative is integer 5)
-       @param end The end date and time of the first raster map
+       :param end: The end date and time of the first raster map
                    (format absolute: "yyyy-mm-dd HH:MM:SS" or "yyyy-mm-dd",
                    format relative is integer 5)
-       @param unit The unit of the relative time: years, months,
+       :param unit: The unit of the relative time: years, months,
                     days, hours, minutes, seconds
-       @param increment Time increment between maps for time stamp creation
+       :param increment: Time increment between maps for time stamp creation
                         (format absolute: NNN seconds, minutes, hours, days,
                         weeks, months, years; format relative is integer 1)
-       @param mult A multiplier for the increment
-       @param interval If True, time intervals are created in case the start
+       :param mult: A multiplier for the increment
+       :param interval: If True, time intervals are created in case the start
                         time and an increment is provided
     """
 
@@ -382,7 +377,6 @@
         if end:
             end_time = string_to_datetime(end)
             if end_time is None:
-                dbif.close()
                 msgr.fatal(_("Unable to convert string \"%s\"into a "
                              "datetime object") % (end))
 
@@ -400,12 +394,12 @@
 
         if map.get_layer():
             msgr.debug(1, _("Set absolute valid time for map <%(id)s> with "
-                           "layer %(layer)s to %(start)s - %(end)s") %
-                         {'id': map.get_map_id(), 'layer': map.get_layer(),
-                          'start': str(start_time), 'end': str(end_time)})
+                            "layer %(layer)s to %(start)s - %(end)s") %
+                       {'id': map.get_map_id(), 'layer': map.get_layer(),
+                        'start': str(start_time), 'end': str(end_time)})
         else:
-            msgr.debug(1, _("Set absolute valid time for map <%s> to %s - %s") %
-                         (map.get_map_id(), str(start_time), str(end_time)))
+            msgr.debug(1, _("Set absolute valid time for map <%s> to %s - %s")
+                       % (map.get_map_id(), str(start_time), str(end_time)))
 
         map.set_absolute_time(start_time, end_time)
     else:
@@ -421,20 +415,85 @@
                 end_time = start_time + int(increment)
 
         if map.get_layer():
-            msgr.debug(1, _("Set relative valid time for map <%s> with layer %s "
-                           "to %i - %s with unit %s") %
-                         (map.get_map_id(), map.get_layer(), start_time,
-                          str(end_time), unit))
+            msgr.debug(1, _("Set relative valid time for map <%s> with layer"
+                            " %s to %i - %s with unit %s") %
+                       (map.get_map_id(), map.get_layer(), start_time,
+                       str(end_time), unit))
         else:
             msgr.debug(1, _("Set relative valid time for map <%s> to %i - %s "
-                           "with unit %s") % (map.get_map_id(), start_time,
-                                              str(end_time), unit))
+                            "with unit %s") % (map.get_map_id(), start_time,
+                                               str(end_time), unit))
 
         map.set_relative_time(start_time, end_time, unit)
 
 
-###############################################################################
+##############################################################################
 
+def register_map_object_list(type,  map_list, output_stds,
+                             delete_empty, unit, dbif=None):
+    """Register a list of AbstractMapDataset objects in the temporal database
+       and optional in a space time dataset.
+
+       :param type: The type of the map layer (rast, rast3d, vect)
+       :param map_list: List of AbstractMapDataset objects
+       :param output_stds: The output stds
+       :param delete_empty: Set True to delete empty map layer found in the map_list
+       :param unit: The temporal unit of the space time dataset
+       :param dbif: The database interface to be used
+
+    """
+    import grass.pygrass.modules as pymod
+    import copy
+
+    dbif,  connected = init_dbif(dbif)
+
+    filename = gscript.tempfile(True)
+    file = open(filename, 'w')
+
+    empty_maps = []
+    for map_layer in map_list:
+        # Read the raster map data
+        map_layer.load()
+        # In case of a empty map continue, do not register empty maps
+
+        if delete_empty:
+            if map_layer.metadata.get_min() is None and \
+               map_layer.metadata.get_max() is None:
+                empty_maps.append(map_layer)
+                continue
+
+        start,  end = map_layer.get_temporal_extent_as_tuple()
+        id = map_layer.get_id()
+        if not end:
+            end = start
+        string = "%s|%s|%s\n" % (id,  str(start),  str(end))
+        file.write(string)
+    file.close()
+
+    if output_stds:
+        output_stds_id = output_stds.get_id()
+    else:
+        output_stds_id = None
+
+    register_maps_in_space_time_dataset(type, output_stds_id, unit=unit,
+                                        file=filename, dbif=dbif)
+
+    g_remove = pymod.Module("g.remove", flags='f', quiet=True,
+                            run_=False, finish_=True)
+
+    # Remove empty maps
+    if len(empty_maps) > 0:
+        for map in empty_maps:
+            if map.is_in_db(dbif):
+                map.delete(dbif)
+            mod = copy.deepcopy(g_remove)
+            if map.get_name():
+                mod(type='rast', name=map.get_name())
+                mod.run()
+
+    if connected:
+        dbif.close()
+
 if __name__ == "__main__":
     import doctest
     doctest.testmod()

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/sampling.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/sampling.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/sampling.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,33 +1,29 @@
-"""!@package grass.temporal
+"""
+Sampling functions for space time datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in Python scripts.
-
 Usage:
 
- at code
-import grass.temporal as tgis
+.. code-block:: python
 
-tgis.register_maps_in_space_time_dataset(type, name, maps)
+    import grass.temporal as tgis
 
-...
- at endcode
+    tgis.register_maps_in_space_time_dataset(type, name, maps)
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from factory import *
 
+
 def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
                                  separator, method, spatial=False,
                                  print_only=True):
-    """!Sample the input space time datasets with a sample
+    """Sample the input space time datasets with a sample
        space time dataset, return the created map matrix and optionally
        print the result to stdout
 
@@ -39,21 +35,24 @@
 
         Attention: Do not use the comma as separator for printing
 
-        @param intype  Type of the input space time dataset (strds, stvds or str3ds)
-        @param sampletype Type of the sample space time datasets (strds, stvds or str3ds)
-        @param inputs Name or comma separated names of space time datasets or a list of map names
-        @param sampler Name of a space time dataset used for temporal sampling
-        @param header Set True to print column names
-        @param separator The field separator character between the columns
-        @param method The method to be used for temporal sampling
-                       (start,during,contain,overlap,equal) as comma separated string
-                       or as a list of methods
-        @param spatial Perform spatial overlapping check
-        @param print_only If set True (default) then the result of the sampling will be
-                    printed to stdout, if set to False the resulting map matrix
-                    will be returned.
+        :param intype: Type of the input space time dataset (strds, stvds or
+                       str3ds)
+        :param sampletype: Type of the sample space time datasets (strds,
+                           stvds or str3ds)
+        :param inputs: Name or comma separated names of space time datasets or
+                       a list of map names
+        :param sampler: Name of a space time dataset used for temporal sampling
+        :param header: Set True to print column names
+        :param separator: The field separator character between the columns
+        :param method: The method to be used for temporal sampling
+                       (start,during,contain,overlap,equal) as comma separated
+                       string or as a list of methods
+        :param spatial: Perform spatial overlapping check
+        :param print_only: If set True (default) then the result of the
+                           sampling will be printed to stdout, if set to False
+                           the resulting map matrix will be returned.
 
-        @return The map matrix or None if nothing found
+        :return: The map matrix or None if nothing found
     """
     mapset = get_current_mapset()
     msgr = get_tgis_message_interface()
@@ -88,11 +87,12 @@
     dbif.connect()
 
     for st in sts:
-        if st.is_in_db(dbif) == False:
-            msgr.fatal(_("Dataset <%s> not found in temporal database") % (st.get_id()))
+        if st.is_in_db(dbif) is False:
+            msgr.fatal(_("Dataset <%s> not found in temporal database")
+                       % (st.get_id()))
         st.select(dbif)
 
-    if sst.is_in_db(dbif) == False:
+    if sst.is_in_db(dbif) is False:
         msgr.fatal(_("Dataset <%s> not found in temporal database") % (sid))
 
     sst.select(dbif)

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/space_time_datasets.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,173 +1,169 @@
-"""!@package grass.temporal
+"""
+Map layer and space time dataset classes
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in Python scripts.
-
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 import getpass
-import logging
 from abstract_map_dataset import *
 from abstract_space_time_dataset import *
 
 ###############################################################################
 
+
 class RasterDataset(AbstractMapDataset):
-    """!Raster dataset class
+    """Raster dataset class
 
-       This class provides functions to select, update, insert or delete raster
-       map information and valid time stamps into the SQL temporal database.
+        This class provides functions to select, update, insert or delete raster
+        map information and valid time stamps into the SQL temporal database.
 
-       Usage:
+        Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> import grass.script as grass
-        >>> init()
-        >>> grass.use_temp_region()
-        >>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
-        ... t=1.0, b=0.0, res=10.0)
-        0
-        >>> grass.run_command("r.mapcalc", overwrite=True, quiet=True,
-        ... expression="strds_map_test_case = 1")
-        0
-        >>> grass.run_command("r.timestamp", map="strds_map_test_case",
-        ...                   date="15 jan 1999", quiet=True)
-        0
-        >>> mapset = get_current_mapset()
-        >>> name = "strds_map_test_case"
-        >>> identifier = "%s@%s" % (name, mapset)
-        >>> rmap = RasterDataset(identifier)
-        >>> rmap.map_exists()
-        True
-        >>> rmap.read_timestamp_from_grass()
-        True
-        >>> rmap.get_temporal_extent_as_tuple()
-        (datetime.datetime(1999, 1, 15, 0, 0), None)
-        >>> rmap.load()
-        True
-        >>> rmap.spatial_extent.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 0.0
-         | East:.. .................... 120.0
-         | West:....................... 0.0
-         | Top:........................ 0.0
-         | Bottom:..................... 0.0
-        >>> rmap.absolute_time.print_info()
-         +-------------------- Absolute time -----------------------------------------+
-         | Start time:................. 1999-01-15 00:00:00
-         | End time:................... None
-        >>> rmap.metadata.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Datatype:................... CELL
-         | Number of columns:.......... 8
-         | Number of rows:............. 12
-         | Number of cells:............ 96
-         | North-South resolution:..... 10.0
-         | East-west resolution:....... 10.0
-         | Minimum value:.............. 1.0
-         | Maximum value:.............. 1.0
+            >>> import grass.script as grass
+            >>> init()
+            >>> grass.use_temp_region()
+            >>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
+            ... t=1.0, b=0.0, res=10.0)
+            0
+            >>> grass.run_command("r.mapcalc", overwrite=True, quiet=True,
+            ... expression="strds_map_test_case = 1")
+            0
+            >>> grass.run_command("r.timestamp", map="strds_map_test_case",
+            ...                   date="15 jan 1999", quiet=True)
+            0
+            >>> mapset = get_current_mapset()
+            >>> name = "strds_map_test_case"
+            >>> identifier = "%s@%s" % (name, mapset)
+            >>> rmap = RasterDataset(identifier)
+            >>> rmap.map_exists()
+            True
+            >>> rmap.read_timestamp_from_grass()
+            True
+            >>> rmap.get_temporal_extent_as_tuple()
+            (datetime.datetime(1999, 1, 15, 0, 0), None)
+            >>> rmap.load()
+            True
+            >>> rmap.spatial_extent.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 0.0
+             | East:.. .................... 120.0
+             | West:....................... 0.0
+             | Top:........................ 0.0
+             | Bottom:..................... 0.0
+            >>> rmap.absolute_time.print_info()
+             +-------------------- Absolute time -----------------------------------------+
+             | Start time:................. 1999-01-15 00:00:00
+             | End time:................... None
+            >>> rmap.metadata.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Datatype:................... CELL
+             | Number of columns:.......... 8
+             | Number of rows:............. 12
+             | Number of cells:............ 96
+             | North-South resolution:..... 10.0
+             | East-west resolution:....... 10.0
+             | Minimum value:.............. 1.0
+             | Maximum value:.............. 1.0
 
-        >>> newmap = rmap.get_new_instance("new at PERMANENT")
-        >>> isinstance(newmap, RasterDataset)
-        True
-        >>> newstrds = rmap.get_new_stds_instance("new at PERMANENT")
-        >>> isinstance(newstrds, SpaceTimeRasterDataset)
-        True
-        >>> rmap.get_type()
-        'raster'
-        >>> rmap.set_absolute_time(start_time=datetime(2001,1,1),
-        ...                        end_time=datetime(2012,1,1))
-        True
-        >>> rmap.get_absolute_time()
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
-        >>> rmap.get_temporal_extent_as_tuple()
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
-        >>> rmap.get_name()
-        'strds_map_test_case'
-        >>> rmap.get_mapset() == mapset
-        True
-        >>> rmap.get_temporal_type()
-        'absolute'
-        >>> rmap.get_spatial_extent_as_tuple()
-        (80.0, 0.0, 120.0, 0.0, 0.0, 0.0)
-        >>> rmap.is_time_absolute()
-        True
-        >>> rmap.is_time_relative()
-        False
+            >>> newmap = rmap.get_new_instance("new at PERMANENT")
+            >>> isinstance(newmap, RasterDataset)
+            True
+            >>> newstrds = rmap.get_new_stds_instance("new at PERMANENT")
+            >>> isinstance(newstrds, SpaceTimeRasterDataset)
+            True
+            >>> rmap.get_type()
+            'raster'
+            >>> rmap.set_absolute_time(start_time=datetime(2001,1,1),
+            ...                        end_time=datetime(2012,1,1))
+            True
+            >>> rmap.get_absolute_time()
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
+            >>> rmap.get_temporal_extent_as_tuple()
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
+            >>> rmap.get_name()
+            'strds_map_test_case'
+            >>> rmap.get_mapset() == mapset
+            True
+            >>> rmap.get_temporal_type()
+            'absolute'
+            >>> rmap.get_spatial_extent_as_tuple()
+            (80.0, 0.0, 120.0, 0.0, 0.0, 0.0)
+            >>> rmap.is_time_absolute()
+            True
+            >>> rmap.is_time_relative()
+            False
 
-        >>> grass.run_command("g.remove", type="rast", name=name, quiet=True, flags="f")
-        0
-        >>> grass.del_temp_region()
+            >>> grass.run_command("g.remove", flags="f", type="rast", name=name, quiet=True)
+            0
+            >>> grass.del_temp_region()
 
-        @endcode
     """
     def __init__(self, ident):
         AbstractMapDataset.__init__(self)
         self.reset(ident)
 
     def is_stds(self):
-        """!Return True if this class is a space time dataset
+        """Return True if this class is a space time dataset
 
-           @return True if this class is a space time dataset, False otherwise
+           :return: True if this class is a space time dataset, False otherwise
         """
         return False
-        
+
     def get_type(self):
         return 'raster'
 
     def get_new_instance(self, ident):
-        """!Return a new instance with the type of this class"""
+        """Return a new instance with the type of this class"""
         return RasterDataset(ident)
 
     def get_new_stds_instance(self, ident):
-        """!Return a new space time dataset instance in which maps
+        """Return a new space time dataset instance in which maps
         are stored with the type of this class"""
         return SpaceTimeRasterDataset(ident)
 
     def spatial_overlapping(self, dataset):
-        """!Return True if the spatial extents 2d overlap"""
+        """Return True if the spatial extents 2d overlap"""
         return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """!Return the two dimensional spatial relation"""
+        """Return the two dimensional spatial relation"""
         return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 
     def spatial_intersection(self, dataset):
-        """!Return the two dimensional intersection as spatial_extent
+        """Return the two dimensional intersection as spatial_extent
            object or None in case no intersection was found.
 
-           @param dataset The abstract dataset to intersect with
-           @return The intersection spatial extent or None
+           :param dataset: The abstract dataset to intersect with
+           :return: The intersection spatial extent or None
         """
         return self.spatial_extent.intersect_2d(dataset.spatial_extent)
 
     def spatial_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent
+        """Return the two dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent or None
+           :param dataset :The abstract dataset to create a union with
+           :return: The union spatial extent or None
         """
         return self.spatial_extent.union_2d(dataset.spatial_extent)
 
     def spatial_disjoint_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent object.
+        """Return the two dimensional union as spatial_extent object.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
         return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent)
 
     def get_np_array(self):
-        """!Return this raster map as memmap numpy style array to access the raster
+        """Return this raster map as memmap numpy style array to access the raster
            values in numpy style without loading the whole map in the RAM.
 
            In case this raster map does exists in the grass spatial database,
@@ -189,7 +185,7 @@
         return a
 
     def reset(self, ident):
-        """!Reset the internal structure and set the identifier"""
+        """Reset the internal structure and set the identifier"""
         self.base = RasterBase(ident=ident)
         self.absolute_time = RasterAbsoluteTime(ident=ident)
         self.relative_time = RasterRelativeTime(ident=ident)
@@ -198,31 +194,31 @@
         self.stds_register = RasterSTDSRegister(ident=ident)
 
     def has_grass_timestamp(self):
-        """!Check if a grass file bsased time stamp exists for this map.
+        """Check if a grass file bsased time stamp exists for this map.
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
         return self.ciface.has_raster_timestamp(self.get_name(),
                                                 self.get_mapset())
 
     def read_timestamp_from_grass(self):
-        """!Read the timestamp of this map from the map metadata
+        """Read the timestamp of this map from the map metadata
            in the grass file system based spatial database and
            set the internal time stamp that should be insert/updated
            in the temporal database.
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
 
         if not self.has_grass_timestamp():
             return False
 
         check, dates = self.ciface.read_raster_timestamp(self.get_name(),
-                                                      self.get_mapset(),)
+                                                         self.get_mapset(),)
 
         if check < 1:
             self.msgr.error(_("Unable to read timestamp file "
-                         "for raster map <%s>" % (self.get_map_id())))
+                              "for raster map <%s>" % (self.get_map_id())))
             return False
 
         if len(dates) == 2:
@@ -233,12 +229,12 @@
         return True
 
     def write_timestamp_to_grass(self):
-        """!Write the timestamp of this map into the map metadata in
+        """Write the timestamp of this map into the map metadata in
            the grass file system based spatial database.
 
            Internally the libgis API functions are used for writing
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
         check = self.ciface.write_raster_timestamp(self.get_name(),
                                                    self.get_mapset(),
@@ -246,12 +242,12 @@
 
         if check == -1:
             self.msgr.error(_("Unable to create timestamp file "
-                         "for raster map <%s>" % (self.get_map_id())))
+                              "for raster map <%s>" % (self.get_map_id())))
             return False
 
         if check == -2:
-            self.msgr.error(_("Invalid datetime in timestamp for raster map <%s>" %
-                         (self.get_map_id())))
+            self.msgr.error(_("Invalid datetime in timestamp for raster map "
+                              "<%s>" % (self.get_map_id())))
             return False
 
         if check == -3:
@@ -261,39 +257,40 @@
         return True
 
     def remove_timestamp_from_grass(self):
-        """!Remove the timestamp from the grass file system based
+        """Remove the timestamp from the grass file system based
            spatial database
 
            Internally the libgis API functions are used for removal
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
         check = self.ciface.remove_raster_timestamp(self.get_name(),
                                                     self.get_mapset())
 
         if check == -1:
-            self.msgr.error(_("Unable to remove timestamp for raster map <%s>" %
-                         (self.get_name())))
+            self.msgr.error(_("Unable to remove timestamp for raster map <%s>"
+                            % (self.get_name())))
             return False
 
         return True
 
     def map_exists(self):
-        """!Return True in case the map exists in the grass spatial database
+        """Return True in case the map exists in the grass spatial database
 
-           @return True if map exists, False otherwise
+           :return: True if map exists, False otherwise
         """
         return self.ciface.raster_map_exists(self.get_name(),
                                              self.get_mapset())
 
     def load(self):
-        """!Load all info from an existing raster map into the internal structure
-            
-            This method checks first if the map exists, in case it exists
-            the metadata of the map is put into this object and True is returned.
-            
-            @return True is the map exists and the metadata was filled successfully
-                          and getting the data was successfull, False otherwise
+        """Load all info from an existing raster map into the internal structure
+
+           This method checks first if the map exists, in case it exists
+           the metadata of the map is put into this object and True is returned
+
+           :return: True is the map exists and the metadata was filled
+                    successfully and getting the data was successfull,
+                    False otherwise
         """
 
         if self.map_exists() is not True:
@@ -327,146 +324,148 @@
             self.metadata.set_cols(cols)
             self.metadata.set_rows(rows)
             self.metadata.set_number_of_cells(ncells)
-            
+
             return True
 
         return False
 
 ###############################################################################
 
+
 class Raster3DDataset(AbstractMapDataset):
-    """!Raster3d dataset class
+    """Raster3d dataset class
 
-       This class provides functions to select, update, insert or delete raster3d
-       map information and valid time stamps into the SQL temporal database.
+        This class provides functions to select, update, insert or delete raster3d
+        map information and valid time stamps into the SQL temporal database.
 
-       Usage:
+        Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> import grass.script as grass
-        >>> init()
-        >>> grass.use_temp_region()
-        >>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
-        ... t=100.0, b=0.0, res=10.0, res3=10.0)
-        0
-        >>> grass.run_command("r3.mapcalc", overwrite=True, quiet=True,
-        ...                   expression="str3ds_map_test_case = 1")
-        0
-        >>> grass.run_command("r3.timestamp", map="str3ds_map_test_case",
-        ...                   date="15 jan 1999", quiet=True)
-        0
-        >>> mapset = get_current_mapset()
-        >>> name = "str3ds_map_test_case"
-        >>> identifier = "%s@%s" % (name, mapset)
-        >>> r3map = Raster3DDataset(identifier)
-        >>> r3map.map_exists()
-        True
-        >>> r3map.read_timestamp_from_grass()
-        True
-        >>> r3map.get_temporal_extent_as_tuple()
-        (datetime.datetime(1999, 1, 15, 0, 0), None)
-        >>> r3map.load()
-        True
-        >>> r3map.spatial_extent.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 0.0
-         | East:.. .................... 120.0
-         | West:....................... 0.0
-         | Top:........................ 100.0
-         | Bottom:..................... 0.0
-        >>> r3map.absolute_time.print_info()
-         +-------------------- Absolute time -----------------------------------------+
-         | Start time:................. 1999-01-15 00:00:00
-         | End time:................... None
-        >>> r3map.metadata.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Datatype:................... DCELL
-         | Number of columns:.......... 8
-         | Number of rows:............. 12
-         | Number of cells:............ 960
-         | North-South resolution:..... 10.0
-         | East-west resolution:....... 10.0
-         | Minimum value:.............. 1.0
-         | Maximum value:.............. 1.0
-         | Number of depths:........... 10
-         | Top-Bottom resolution:...... 10.0
+            >>> import grass.script as grass
+            >>> init()
+            >>> grass.use_temp_region()
+            >>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
+            ... t=100.0, b=0.0, res=10.0, res3=10.0)
+            0
+            >>> grass.run_command("r3.mapcalc", overwrite=True, quiet=True,
+            ...                   expression="str3ds_map_test_case = 1")
+            0
+            >>> grass.run_command("r3.timestamp", map="str3ds_map_test_case",
+            ...                   date="15 jan 1999", quiet=True)
+            0
+            >>> mapset = get_current_mapset()
+            >>> name = "str3ds_map_test_case"
+            >>> identifier = "%s@%s" % (name, mapset)
+            >>> r3map = Raster3DDataset(identifier)
+            >>> r3map.map_exists()
+            True
+            >>> r3map.read_timestamp_from_grass()
+            True
+            >>> r3map.get_temporal_extent_as_tuple()
+            (datetime.datetime(1999, 1, 15, 0, 0), None)
+            >>> r3map.load()
+            True
+            >>> r3map.spatial_extent.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 0.0
+             | East:.. .................... 120.0
+             | West:....................... 0.0
+             | Top:........................ 100.0
+             | Bottom:..................... 0.0
+            >>> r3map.absolute_time.print_info()
+             +-------------------- Absolute time -----------------------------------------+
+             | Start time:................. 1999-01-15 00:00:00
+             | End time:................... None
+            >>> r3map.metadata.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Datatype:................... DCELL
+             | Number of columns:.......... 8
+             | Number of rows:............. 12
+             | Number of cells:............ 960
+             | North-South resolution:..... 10.0
+             | East-west resolution:....... 10.0
+             | Minimum value:.............. 1.0
+             | Maximum value:.............. 1.0
+             | Number of depths:........... 10
+             | Top-Bottom resolution:...... 10.0
 
-        >>> newmap = r3map.get_new_instance("new at PERMANENT")
-        >>> isinstance(newmap, Raster3DDataset)
-        True
-        >>> newstr3ds = r3map.get_new_stds_instance("new at PERMANENT")
-        >>> isinstance(newstr3ds, SpaceTimeRaster3DDataset)
-        True
-        >>> r3map.get_type()
-        'raster3d'
-        >>> r3map.set_absolute_time(start_time=datetime(2001,1,1),
-        ...                        end_time=datetime(2012,1,1))
-        True
-        >>> r3map.get_absolute_time()
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
-        >>> r3map.get_temporal_extent_as_tuple()
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
-        >>> r3map.get_name()
-        'str3ds_map_test_case'
-        >>> r3map.get_mapset() == mapset
-        True
-        >>> r3map.get_temporal_type()
-        'absolute'
-        >>> r3map.get_spatial_extent_as_tuple()
-        (80.0, 0.0, 120.0, 0.0, 100.0, 0.0)
-        >>> r3map.is_time_absolute()
-        True
-        >>> r3map.is_time_relative()
-        False
-        >>> grass.run_command("g.remove", type="rast3d", name=name, quiet=True, flags="f")
-        0
-        >>> grass.del_temp_region()
+            >>> newmap = r3map.get_new_instance("new at PERMANENT")
+            >>> isinstance(newmap, Raster3DDataset)
+            True
+            >>> newstr3ds = r3map.get_new_stds_instance("new at PERMANENT")
+            >>> isinstance(newstr3ds, SpaceTimeRaster3DDataset)
+            True
+            >>> r3map.get_type()
+            'raster3d'
+            >>> r3map.set_absolute_time(start_time=datetime(2001,1,1),
+            ...                        end_time=datetime(2012,1,1))
+            True
+            >>> r3map.get_absolute_time()
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
+            >>> r3map.get_temporal_extent_as_tuple()
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
+            >>> r3map.get_name()
+            'str3ds_map_test_case'
+            >>> r3map.get_mapset() == mapset
+            True
+            >>> r3map.get_temporal_type()
+            'absolute'
+            >>> r3map.get_spatial_extent_as_tuple()
+            (80.0, 0.0, 120.0, 0.0, 100.0, 0.0)
+            >>> r3map.is_time_absolute()
+            True
+            >>> r3map.is_time_relative()
+            False
+            >>> grass.run_command("g.remove", flags="f", type="rast3d", name=name, quiet=True)
+            0
+            >>> grass.del_temp_region()
+
     """
     def __init__(self, ident):
         AbstractMapDataset.__init__(self)
         self.reset(ident)
 
     def is_stds(self):
-        """!Return True if this class is a space time dataset
+        """Return True if this class is a space time dataset
 
-           @return True if this class is a space time dataset, False otherwise
+           :return: True if this class is a space time dataset, False otherwise
         """
         return False
-        
+
     def get_type(self):
         return "raster3d"
 
     def get_new_instance(self, ident):
-        """!Return a new instance with the type of this class"""
+        """Return a new instance with the type of this class"""
         return Raster3DDataset(ident)
 
     def get_new_stds_instance(self, ident):
-        """!Return a new space time dataset instance in which maps
+        """Return a new space time dataset instance in which maps
         are stored with the type of this class"""
         return SpaceTimeRaster3DDataset(ident)
 
     def spatial_overlapping(self, dataset):
-        """!Return True if the spatial extents overlap"""
+        """Return True if the spatial extents overlap"""
         if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
             return self.spatial_extent.overlapping(dataset.spatial_extent)
         else:
             return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """!Return the two or three dimensional spatial relation"""
+        """Return the two or three dimensional spatial relation"""
         if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
             return self.spatial_extent.spatial_relation(dataset.spatial_extent)
         else:
             return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 
     def spatial_intersection(self, dataset):
-        """!Return the three or two dimensional intersection as spatial_extent
+        """Return the three or two dimensional intersection as spatial_extent
            object or None in case no intersection was found.
 
-           @param dataset The abstract dataset to intersect with
-           @return The intersection spatial extent or None
+           :param dataset: The abstract dataset to intersect with
+           :return: The intersection spatial extent or None
         """
         if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
             return self.spatial_extent.intersect(dataset.spatial_extent)
@@ -474,11 +473,11 @@
             return self.spatial_extent.intersect_2d(dataset.spatial_extent)
 
     def spatial_union(self, dataset):
-        """!Return the three or two dimensional union as spatial_extent
+        """Return the three or two dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent or None
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent or None
         """
         if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
             return self.spatial_extent.union(dataset.spatial_extent)
@@ -486,10 +485,10 @@
             return self.spatial_extent.union_2d(dataset.spatial_extent)
 
     def spatial_disjoint_union(self, dataset):
-        """!Return the three or two dimensional union as spatial_extent object.
+        """Return the three or two dimensional union as spatial_extent object.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
         if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
             return self.spatial_extent.disjoint_union(dataset.spatial_extent)
@@ -497,8 +496,9 @@
             return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent)
 
     def get_np_array(self):
-        """!Return this 3D raster map as memmap numpy style array to access the 3D raster
-           values in numpy style without loading the whole map in the RAM.
+        """Return this 3D raster map as memmap numpy style array to access the
+           3D raster values in numpy style without loading the whole map in
+           the RAM.
 
            In case this 3D raster map does exists in the grass spatial database,
            the map will be exported using r3.out.bin to a temporary location
@@ -519,7 +519,7 @@
         return a
 
     def reset(self, ident):
-        """!Reset the internal structure and set the identifier"""
+        """Reset the internal structure and set the identifier"""
         self.base = Raster3DBase(ident=ident)
         self.absolute_time = Raster3DAbsoluteTime(ident=ident)
         self.relative_time = Raster3DRelativeTime(ident=ident)
@@ -528,31 +528,31 @@
         self.stds_register = Raster3DSTDSRegister(ident=ident)
 
     def has_grass_timestamp(self):
-        """!Check if a grass file bsased time stamp exists for this map.
+        """Check if a grass file bsased time stamp exists for this map.
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
         return self.ciface.has_raster3d_timestamp(self.get_name(),
-                                                self.get_mapset())
+                                                  self.get_mapset())
 
     def read_timestamp_from_grass(self):
-        """!Read the timestamp of this map from the map metadata
+        """Read the timestamp of this map from the map metadata
            in the grass file system based spatial database and
            set the internal time stamp that should be insert/updated
            in the temporal database.
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
 
         if not self.has_grass_timestamp():
             return False
 
         check, dates = self.ciface.read_raster3d_timestamp(self.get_name(),
-                                                      self.get_mapset(),)
+                                                           self.get_mapset(),)
 
         if check < 1:
             self.msgr.error(_("Unable to read timestamp file "
-                         "for 3D raster map <%s>" % (self.get_map_id())))
+                              "for 3D raster map <%s>" % (self.get_map_id())))
             return False
 
         if len(dates) == 2:
@@ -563,12 +563,12 @@
         return True
 
     def write_timestamp_to_grass(self):
-        """!Write the timestamp of this map into the map metadata
+        """Write the timestamp of this map into the map metadata
         in the grass file system based spatial database.
 
            Internally the libgis API functions are used for writing
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
         check = self.ciface.write_raster3d_timestamp(self.get_name(),
                                                      self.get_mapset(),
@@ -576,12 +576,12 @@
 
         if check == -1:
             self.msgr.error(_("Unable to create timestamp file "
-                         "for 3D raster map <%s>" % (self.get_map_id())))
+                              "for 3D raster map <%s>" % (self.get_map_id())))
             return False
 
         if check == -2:
-            self.msgr.error(_("Invalid datetime in timestamp for 3D raster map <%s>" %
-                         (self.get_map_id())))
+            self.msgr.error(_("Invalid datetime in timestamp for 3D raster "
+                              "map <%s>" % (self.get_map_id())))
             return False
 
         if check == -3:
@@ -591,36 +591,37 @@
         return True
 
     def remove_timestamp_from_grass(self):
-        """!Remove the timestamp from the grass file system based spatial database
+        """Remove the timestamp from the grass file system based spatial database
 
-           @return True if success, False on error
+           :return: True if success, False on error
         """
         check = self.ciface.remove_raster3d_timestamp(self.get_name(),
                                                       self.get_mapset())
 
         if check == -1:
-            self.msgr.error(_("Unable to remove timestamp for raster map <%s>" %
-                         (self.get_name())))
+            self.msgr.error(_("Unable to remove timestamp for raster map "
+                              "<%s>" % (self.get_name())))
             return False
 
         return True
 
     def map_exists(self):
-        """!Return True in case the map exists in the grass spatial database
+        """Return True in case the map exists in the grass spatial database
 
-           @return True if map exists, False otherwise
+           :return: True if map exists, False otherwise
         """
         return self.ciface.raster3d_map_exists(self.get_name(),
                                                self.get_mapset())
 
     def load(self):
-        """!Load all info from an existing 3d raster map into the internal structure
-            
-            This method checks first if the map exists, in case it exists
-            the metadata of the map is put into this object and True is returned.
-            
-            @return True is the map exists and the metadata was filled successfully
-                          and getting the data was successfull, False otherwise
+        """Load all info from an existing 3d raster map into the internal structure
+
+           This method checks first if the map exists, in case it exists
+           the metadata of the map is put into this object and True is returned
+
+           :return: True is the map exists and the metadata was filled
+                    successfully and getting the data was successfull,
+                    False otherwise
         """
 
         if self.map_exists() is not True:
@@ -631,12 +632,15 @@
 
         # Fill spatial extent
         kvp = self.ciface.read_raster3d_info(self.get_name(),
-                                           self.get_mapset())
+                                             self.get_mapset())
 
         if kvp:
-            self.set_spatial_extent_from_values(north=kvp["north"], south=kvp["south"],
-                                    east=kvp["east"], west=kvp["west"],
-                                    top=kvp["top"], bottom=kvp["bottom"])
+            self.set_spatial_extent_from_values(north=kvp["north"],
+                                                south=kvp["south"],
+                                                east=kvp["east"],
+                                                west=kvp["west"],
+                                                top=kvp["top"],
+                                                bottom=kvp["bottom"])
 
             # Fill metadata
             self.metadata.set_nsres(kvp["nsres"])
@@ -656,162 +660,162 @@
             self.metadata.set_rows(rows)
             self.metadata.set_depths(depths)
             self.metadata.set_number_of_cells(ncells)
-            
+
             return True
 
         return False
 
 ###############################################################################
 
+
 class VectorDataset(AbstractMapDataset):
-    """!Vector dataset class
+    """Vector dataset class
 
-       This class provides functions to select, update, insert or delete vector
-       map information and valid time stamps into the SQL temporal database.
+        This class provides functions to select, update, insert or delete vector
+        map information and valid time stamps into the SQL temporal database.
 
-       Usage:
+        Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> import grass.script as grass
-        >>> init()
-        >>> grass.use_temp_region()
-        >>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
-        ... t=1.0, b=0.0, res=10.0)
-        0
-        >>> grass.run_command("v.random", overwrite=True, output="stvds_map_test_case",
-        ... n=100, zmin=0, zmax=100, flags="z", column="elevation", quiet=True)
-        0
-        >>> grass.run_command("v.timestamp", map="stvds_map_test_case",
-        ...                   date="15 jan 1999", quiet=True)
-        0
-        >>> mapset = get_current_mapset()
-        >>> name = "stvds_map_test_case"
-        >>> identifier = "%s@%s" % (name, mapset)
-        >>> vmap = VectorDataset(identifier)
-        >>> vmap.map_exists()
-        True
-        >>> vmap.read_timestamp_from_grass()
-        True
-        >>> vmap.get_temporal_extent_as_tuple()
-        (datetime.datetime(1999, 1, 15, 0, 0), None)
-        >>> vmap.load()
-        True
-        >>> vmap.absolute_time.print_info()
-         +-------------------- Absolute time -----------------------------------------+
-         | Start time:................. 1999-01-15 00:00:00
-         | End time:................... None
-        >>> vmap.metadata.print_info()
-         +-------------------- Metadata information ----------------------------------+
-         | Is map 3d .................. True
-         | Number of points ........... 100
-         | Number of lines ............ 0
-         | Number of boundaries ....... 0
-         | Number of centroids ........ 0
-         | Number of faces ............ 0
-         | Number of kernels .......... 0
-         | Number of primitives ....... 100
-         | Number of nodes ............ 0
-         | Number of areas ............ 0
-         | Number of islands .......... 0
-         | Number of holes ............ 0
-         | Number of volumes .......... 0
-        >>> newmap = vmap.get_new_instance("new at PERMANENT")
-        >>> isinstance(newmap, VectorDataset)
-        True
-        >>> newstvds = vmap.get_new_stds_instance("new at PERMANENT")
-        >>> isinstance(newstvds, SpaceTimeVectorDataset)
-        True
-        >>> vmap.get_type()
-        'vector'
-        >>> vmap.set_absolute_time(start_time=datetime(2001,1,1),
-        ...                        end_time=datetime(2012,1,1))
-        True
-        >>> vmap.get_absolute_time()
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
-        >>> vmap.get_temporal_extent_as_tuple()
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
-        >>> vmap.get_name()
-        'stvds_map_test_case'
-        >>> vmap.get_mapset() == mapset
-        True
-        >>> vmap.get_temporal_type()
-        'absolute'
-        >>> vmap.is_time_absolute()
-        True
-        >>> vmap.is_time_relative()
-        False
-        >>> grass.run_command("g.remove", type="vect", name=name, quiet=True, flags="f")
-        0
-        >>> grass.del_temp_region()
+            >>> import grass.script as grass
+            >>> init()
+            >>> grass.use_temp_region()
+            >>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
+            ... t=1.0, b=0.0, res=10.0)
+            0
+            >>> grass.run_command("v.random", overwrite=True, output="stvds_map_test_case",
+            ... n=100, zmin=0, zmax=100, flags="z", column="elevation", quiet=True)
+            0
+            >>> grass.run_command("v.timestamp", map="stvds_map_test_case",
+            ...                   date="15 jan 1999", quiet=True)
+            0
+            >>> mapset = get_current_mapset()
+            >>> name = "stvds_map_test_case"
+            >>> identifier = "%s@%s" % (name, mapset)
+            >>> vmap = VectorDataset(identifier)
+            >>> vmap.map_exists()
+            True
+            >>> vmap.read_timestamp_from_grass()
+            True
+            >>> vmap.get_temporal_extent_as_tuple()
+            (datetime.datetime(1999, 1, 15, 0, 0), None)
+            >>> vmap.load()
+            True
+            >>> vmap.absolute_time.print_info()
+             +-------------------- Absolute time -----------------------------------------+
+             | Start time:................. 1999-01-15 00:00:00
+             | End time:................... None
+            >>> vmap.metadata.print_info()
+             +-------------------- Metadata information ----------------------------------+
+             | Is map 3d .................. True
+             | Number of points ........... 100
+             | Number of lines ............ 0
+             | Number of boundaries ....... 0
+             | Number of centroids ........ 0
+             | Number of faces ............ 0
+             | Number of kernels .......... 0
+             | Number of primitives ....... 100
+             | Number of nodes ............ 0
+             | Number of areas ............ 0
+             | Number of islands .......... 0
+             | Number of holes ............ 0
+             | Number of volumes .......... 0
+            >>> newmap = vmap.get_new_instance("new at PERMANENT")
+            >>> isinstance(newmap, VectorDataset)
+            True
+            >>> newstvds = vmap.get_new_stds_instance("new at PERMANENT")
+            >>> isinstance(newstvds, SpaceTimeVectorDataset)
+            True
+            >>> vmap.get_type()
+            'vector'
+            >>> vmap.set_absolute_time(start_time=datetime(2001,1,1),
+            ...                        end_time=datetime(2012,1,1))
+            True
+            >>> vmap.get_absolute_time()
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
+            >>> vmap.get_temporal_extent_as_tuple()
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
+            >>> vmap.get_name()
+            'stvds_map_test_case'
+            >>> vmap.get_mapset() == mapset
+            True
+            >>> vmap.get_temporal_type()
+            'absolute'
+            >>> vmap.is_time_absolute()
+            True
+            >>> vmap.is_time_relative()
+            False
+            >>> grass.run_command("g.remove", flags="f", type="vect", name=name, quiet=True)
+            0
+            >>> grass.del_temp_region()
 
-        @endcode
     """
     def __init__(self, ident):
         AbstractMapDataset.__init__(self)
         self.reset(ident)
 
     def is_stds(self):
-        """!Return True if this class is a space time dataset
+        """Return True if this class is a space time dataset
 
-           @return True if this class is a space time dataset, False otherwise
+           :return: True if this class is a space time dataset, False otherwise
         """
         return False
-        
+
     def get_type(self):
         return "vector"
 
     def get_new_instance(self, ident):
-        """!Return a new instance with the type of this class"""
+        """Return a new instance with the type of this class"""
         return VectorDataset(ident)
 
     def get_new_stds_instance(self, ident):
-        """!Return a new space time dataset instance in which maps
+        """Return a new space time dataset instance in which maps
         are stored with the type of this class"""
         return SpaceTimeVectorDataset(ident)
 
     def get_layer(self):
-        """!Return the layer"""
+        """Return the layer"""
         return self.base.get_layer()
 
     def spatial_overlapping(self, dataset):
-        """!Return True if the spatial extents 2d overlap"""
+        """Return True if the spatial extents 2d overlap"""
 
         return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """!Return the two dimensional spatial relation"""
+        """Return the two dimensional spatial relation"""
 
         return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 
     def spatial_intersection(self, dataset):
-        """!Return the two dimensional intersection as spatial_extent
+        """Return the two dimensional intersection as spatial_extent
            object or None in case no intersection was found.
 
-           @param dataset The abstract dataset to intersect with
-           @return The intersection spatial extent or None
+           :param dataset: The abstract dataset to intersect with
+           :return: The intersection spatial extent or None
         """
         return self.spatial_extent.intersect_2d(dataset.spatial_extent)
 
     def spatial_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent
+        """Return the two dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent or None
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent or None
         """
         return self.spatial_extent.union_2d(dataset.spatial_extent)
 
     def spatial_disjoint_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent object.
+        """Return the two dimensional union as spatial_extent object.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
         return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent)
 
     def reset(self, ident):
-        """!Reset the internal structure and set the identifier"""
+        """Reset the internal structure and set the identifier"""
         self.base = VectorBase(ident=ident)
         self.absolute_time = VectorAbsoluteTime(ident=ident)
         self.relative_time = VectorRelativeTime(ident=ident)
@@ -820,15 +824,14 @@
         self.stds_register = VectorSTDSRegister(ident=ident)
 
     def has_grass_timestamp(self):
-        """!Check if a grass file bsased time stamp exists for this map.
+        """Check if a grass file bsased time stamp exists for this map.
         """
         return self.ciface.has_vector_timestamp(self.get_name(),
                                                 self.get_mapset(),
                                                 self.get_layer())
 
-
     def read_timestamp_from_grass(self):
-        """!Read the timestamp of this map from the map metadata
+        """Read the timestamp of this map from the map metadata
            in the grass file system based spatial database and
            set the internal time stamp that should be insert/updated
            in the temporal database.
@@ -838,11 +841,11 @@
             return False
 
         check, dates = self.ciface.read_vector_timestamp(self.get_name(),
-                                                      self.get_mapset(),)
+                                                         self.get_mapset(),)
 
         if check < 1:
             self.msgr.error(_("Unable to read timestamp file "
-                         "for vector map <%s>" % (self.get_map_id())))
+                              "for vector map <%s>" % (self.get_map_id())))
             return False
 
         if len(dates) == 2:
@@ -853,7 +856,7 @@
         return True
 
     def write_timestamp_to_grass(self):
-        """!Write the timestamp of this map into the map metadata in
+        """Write the timestamp of this map into the map metadata in
            the grass file system based spatial database.
 
            Internally the libgis API functions are used for writing
@@ -865,18 +868,18 @@
 
         if check == -1:
             self.msgr.error(_("Unable to create timestamp file "
-                         "for vector map <%s>" % (self.get_map_id())))
+                              "for vector map <%s>" % (self.get_map_id())))
             return False
 
         if check == -2:
-            self.msgr.error(_("Invalid datetime in timestamp for vector map <%s>" %
-                         (self.get_map_id())))
+            self.msgr.error(_("Invalid datetime in timestamp for vector "
+                              "map <%s>" % (self.get_map_id())))
             return False
 
         return True
 
     def remove_timestamp_from_grass(self):
-        """!Remove the timestamp from the grass file system based spatial
+        """Remove the timestamp from the grass file system based spatial
            database
 
            Internally the libgis API functions are used for removal
@@ -885,36 +888,35 @@
                                                     self.get_mapset())
 
         if check == -1:
-            self.msgr.error(_("Unable to remove timestamp for vector map <%s>" %
-                         (self.get_name())))
+            self.msgr.error(_("Unable to remove timestamp for vector "
+                              "map <%s>" % (self.get_name())))
             return False
 
         return True
 
     def map_exists(self):
-        """!Return True in case the map exists in the grass spatial database
+        """Return True in case the map exists in the grass spatial database
 
-           @return True if map exists, False otherwise
+           :return: True if map exists, False otherwise
         """
         return self.ciface.vector_map_exists(self.get_name(),
                                              self.get_mapset())
 
-
     def load(self):
 
-        """!Load all info from an existing vector map into the internal structure
-            
-            This method checks first if the map exists, in case it exists
-            the metadata of the map is put into this object and True is returned.
-            
-            @return True is the map exists and the metadata was filled successfully
-                          and getting the data was successfull, False otherwise
+        """Load all info from an existing vector map into the internal structure
+
+           This method checks first if the map exists, in case it exists
+           the metadata of the map is put into this object and True is returned
+
+           :return: True is the map exists and the metadata was filled
+                    successfully and getting the data was successfull,
+                    False otherwise
         """
 
         if self.map_exists() is not True:
             return False
 
-
         # Fill base information
         self.base.set_creator(str(getpass.getuser()))
 
@@ -925,9 +927,12 @@
 
         if kvp:
             # Fill spatial extent
-            self.set_spatial_extent_from_values(north=kvp["north"], south=kvp["south"],
-                                    east=kvp["east"], west=kvp["west"],
-                                    top=kvp["top"], bottom=kvp["bottom"])
+            self.set_spatial_extent_from_values(north=kvp["north"],
+                                                south=kvp["south"],
+                                                east=kvp["east"],
+                                                west=kvp["west"],
+                                                top=kvp["top"],
+                                                bottom=kvp["bottom"])
 
             # Fill metadata
             self.metadata.set_3d_info(kvp["map3d"])
@@ -943,83 +948,84 @@
             self.metadata.set_number_of_islands(kvp["islands"])
             self.metadata.set_number_of_holes(kvp["holes"])
             self.metadata.set_number_of_volumes(kvp["volumes"])
-            
+
             return True
 
         return False
 
 ###############################################################################
 
+
 class SpaceTimeRasterDataset(AbstractSpaceTimeDataset):
-    """!Space time raster dataset class
+    """Space time raster dataset class
     """
     def __init__(self, ident):
         AbstractSpaceTimeDataset.__init__(self, ident)
 
     def is_stds(self):
-        """!Return True if this class is a space time dataset
+        """Return True if this class is a space time dataset
 
-           @return True if this class is a space time dataset, False otherwise
+           :return: True if this class is a space time dataset, False otherwise
         """
         return True
-        
+
     def get_type(self):
         return "strds"
 
     def get_new_instance(self, ident):
-        """!Return a new instance with the type of this class"""
+        """Return a new instance with the type of this class"""
         return SpaceTimeRasterDataset(ident)
 
     def get_new_map_instance(self, ident):
-        """!Return a new instance of a map dataset which is associated "
+        """Return a new instance of a map dataset which is associated "
         "with the type of this class"""
         return RasterDataset(ident)
 
     def get_map_register(self):
-        """!Return the name of the map register table"""
+        """Return the name of the map register table"""
         return self.metadata.get_raster_register()
 
     def set_map_register(self, name):
-        """!Set the name of the map register table"""
+        """Set the name of the map register table"""
         self.metadata.set_raster_register(name)
 
     def spatial_overlapping(self, dataset):
-        """!Return True if the spatial extents 2d overlap"""
+        """Return True if the spatial extents 2d overlap"""
         return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """!Return the two dimensional spatial relation"""
+        """Return the two dimensional spatial relation"""
         return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 
     def spatial_intersection(self, dataset):
-        """!Return the two dimensional intersection as spatial_extent
+        """Return the two dimensional intersection as spatial_extent
            object or None in case no intersection was found.
 
-           @param dataset The abstract dataset to intersect with
-           @return The intersection spatial extent or None
+           :param dataset: The abstract dataset to intersect with
+           :return: The intersection spatial extent or None
         """
         return self.spatial_extent.intersect_2d(dataset.spatial_extent)
 
     def spatial_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent
+        """Return the two dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent or None
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent or None
         """
         return self.spatial_extent.union_2d(dataset.spatial_extent)
 
     def spatial_disjoint_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent object.
+        """Return the two dimensional union as spatial_extent object.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
         return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent)
 
     def reset(self, ident):
 
-        """!Reset the internal structure and set the identifier"""
+        """Reset the internal structure and set the identifier"""
         self.base = STRDSBase(ident=ident)
         self.base.set_creator(str(getpass.getuser()))
         self.absolute_time = STRDSAbsoluteTime(ident=ident)
@@ -1029,42 +1035,43 @@
 
 ###############################################################################
 
+
 class SpaceTimeRaster3DDataset(AbstractSpaceTimeDataset):
-    """!Space time raster3d dataset class
+    """Space time raster3d dataset class
     """
 
     def __init__(self, ident):
         AbstractSpaceTimeDataset.__init__(self, ident)
 
     def is_stds(self):
-        """!Return True if this class is a space time dataset
+        """Return True if this class is a space time dataset
 
-           @return True if this class is a space time dataset, False otherwise
+           :return: True if this class is a space time dataset, False otherwise
         """
         return True
-        
+
     def get_type(self):
         return "str3ds"
 
     def get_new_instance(self, ident):
-        """!Return a new instance with the type of this class"""
+        """Return a new instance with the type of this class"""
         return SpaceTimeRaster3DDataset(ident)
 
     def get_new_map_instance(self, ident):
-        """!Return a new instance of a map dataset which is associated
+        """Return a new instance of a map dataset which is associated
         with the type of this class"""
         return Raster3DDataset(ident)
 
     def get_map_register(self):
-        """!Return the name of the map register table"""
+        """Return the name of the map register table"""
         return self.metadata.get_raster3d_register()
 
     def set_map_register(self, name):
-        """!Set the name of the map register table"""
+        """Set the name of the map register table"""
         self.metadata.set_raster3d_register(name)
 
     def spatial_overlapping(self, dataset):
-        """!Return True if the spatial extents overlap"""
+        """Return True if the spatial extents overlap"""
 
         if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds":
             return self.spatial_extent.overlapping(dataset.spatial_extent)
@@ -1072,7 +1079,7 @@
             return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """!Return the two or three dimensional spatial relation"""
+        """Return the two or three dimensional spatial relation"""
 
         if self.get_type() == dataset.get_type() or \
            dataset.get_type() == "str3ds":
@@ -1081,11 +1088,11 @@
             return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 
     def spatial_intersection(self, dataset):
-        """!Return the three or two dimensional intersection as spatial_extent
+        """Return the three or two dimensional intersection as spatial_extent
            object or None in case no intersection was found.
 
-           @param dataset The abstract dataset to intersect with
-           @return The intersection spatial extent or None
+           :param dataset: The abstract dataset to intersect with
+           :return: The intersection spatial extent or None
         """
         if self.get_type() == dataset.get_type() or dataset.get_type() == "raster3d":
             return self.spatial_extent.intersect(dataset.spatial_extent)
@@ -1093,11 +1100,11 @@
             return self.spatial_extent.intersect_2d(dataset.spatial_extent)
 
     def spatial_union(self, dataset):
-        """!Return the three or two dimensional union as spatial_extent
+        """Return the three or two dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent or None
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent or None
         """
         if self.get_type() == dataset.get_type() or dataset.get_type() == "raster3d":
             return self.spatial_extent.union(dataset.spatial_extent)
@@ -1105,10 +1112,10 @@
             return self.spatial_extent.union_2d(dataset.spatial_extent)
 
     def spatial_disjoint_union(self, dataset):
-        """!Return the three or two dimensional union as spatial_extent object.
+        """Return the three or two dimensional union as spatial_extent object.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
         if self.get_type() == dataset.get_type() or dataset.get_type() == "raster3d":
             return self.spatial_extent.disjoint_union(dataset.spatial_extent)
@@ -1117,7 +1124,7 @@
 
     def reset(self, ident):
 
-        """!Reset the internal structure and set the identifier"""
+        """Reset the internal structure and set the identifier"""
         self.base = STR3DSBase(ident=ident)
         self.base.set_creator(str(getpass.getuser()))
         self.absolute_time = STR3DSAbsoluteTime(ident=ident)
@@ -1129,76 +1136,76 @@
 
 
 class SpaceTimeVectorDataset(AbstractSpaceTimeDataset):
-    """!Space time vector dataset class
+    """Space time vector dataset class
     """
 
     def __init__(self, ident):
         AbstractSpaceTimeDataset.__init__(self, ident)
 
     def is_stds(self):
-        """!Return True if this class is a space time dataset
+        """Return True if this class is a space time dataset
 
-           @return True if this class is a space time dataset, False otherwise
+           :return: True if this class is a space time dataset, False otherwise
         """
         return True
-        
+
     def get_type(self):
         return "stvds"
 
     def get_new_instance(self, ident):
-        """!Return a new instance with the type of this class"""
+        """Return a new instance with the type of this class"""
         return SpaceTimeVectorDataset(ident)
 
     def get_new_map_instance(self, ident):
-        """!Return a new instance of a map dataset which is associated
+        """Return a new instance of a map dataset which is associated
         with the type of this class"""
         return VectorDataset(ident)
 
     def get_map_register(self):
-        """!Return the name of the map register table"""
+        """Return the name of the map register table"""
         return self.metadata.get_vector_register()
 
     def set_map_register(self, name):
-        """!Set the name of the map register table"""
+        """Set the name of the map register table"""
         self.metadata.set_vector_register(name)
 
     def spatial_overlapping(self, dataset):
-        """!Return True if the spatial extents 2d overlap"""
+        """Return True if the spatial extents 2d overlap"""
         return self.spatial_extent.overlapping_2d(dataset.spatial_extent)
 
     def spatial_relation(self, dataset):
-        """!Return the two dimensional spatial relation"""
+        """Return the two dimensional spatial relation"""
         return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent)
 
     def spatial_intersection(self, dataset):
-        """!Return the two dimensional intersection as spatial_extent
+        """Return the two dimensional intersection as spatial_extent
            object or None in case no intersection was found.
 
-           @param dataset The abstract dataset to intersect with
-           @return The intersection spatial extent or None
+           :param dataset: The abstract dataset to intersect with
+           :return: The intersection spatial extent or None
         """
         return self.spatial_extent.intersect_2d(dataset.spatial_extent)
 
     def spatial_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent
+        """Return the two dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent or None
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent or None
         """
         return self.spatial_extent.union_2d(dataset.spatial_extent)
 
     def spatial_disjoint_union(self, dataset):
-        """!Return the two dimensional union as spatial_extent object.
+        """Return the two dimensional union as spatial_extent object.
 
-           @param dataset The abstract dataset to create a union with
-           @return The union spatial extent
+           :param dataset: The abstract dataset to create a union with
+           :return: The union spatial extent
         """
         return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent)
 
     def reset(self, ident):
 
-        """!Reset the internal structure and set the identifier"""
+        """Reset the internal structure and set the identifier"""
         self.base = STVDSBase(ident=ident)
         self.base.set_creator(str(getpass.getuser()))
         self.absolute_time = STVDSAbsoluteTime(ident=ident)

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/spatial_extent.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/spatial_extent.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/spatial_extent.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,102 +1,97 @@
-"""!@package grass.temporal
+"""
+Spatial extents classes for map layer and space time datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related spatial extent functions to be used in Python scripts and tgis packages.
-
 Usage:
 
- at code
+.. code-block:: python
 
->>> import grass.temporal as tgis
->>> tgis.init()
->>> extent = tgis.RasterSpatialExtent(
-... ident="raster at PERMANENT", north=90, south=90, east=180, west=180,
-... top=100, bottom=-20)
->>> extent = tgis.Raster3DSpatialExtent(
-... ident="raster3d at PERMANENT", north=90, south=90, east=180, west=180,
-... top=100, bottom=-20)
->>> extent = tgis.VectorSpatialExtent(
-... ident="vector at PERMANENT", north=90, south=90, east=180, west=180,
-... top=100, bottom=-20)
->>> extent = tgis.STRDSSpatialExtent(
-... ident="strds at PERMANENT", north=90, south=90, east=180, west=180,
-... top=100, bottom=-20)
->>> extent = tgis.STR3DSSpatialExtent(
-... ident="str3ds at PERMANENT", north=90, south=90, east=180, west=180,
-... top=100, bottom=-20)
->>> extent = tgis.STVDSSpatialExtent(
-... ident="stvds at PERMANENT", north=90, south=90, east=180, west=180,
-... top=100, bottom=-20)
+    >>> import grass.temporal as tgis
+    >>> tgis.init()
+    >>> extent = tgis.RasterSpatialExtent(
+    ... ident="raster at PERMANENT", north=90, south=90, east=180, west=180,
+    ... top=100, bottom=-20)
+    >>> extent = tgis.Raster3DSpatialExtent(
+    ... ident="raster3d at PERMANENT", north=90, south=90, east=180, west=180,
+    ... top=100, bottom=-20)
+    >>> extent = tgis.VectorSpatialExtent(
+    ... ident="vector at PERMANENT", north=90, south=90, east=180, west=180,
+    ... top=100, bottom=-20)
+    >>> extent = tgis.STRDSSpatialExtent(
+    ... ident="strds at PERMANENT", north=90, south=90, east=180, west=180,
+    ... top=100, bottom=-20)
+    >>> extent = tgis.STR3DSSpatialExtent(
+    ... ident="str3ds at PERMANENT", north=90, south=90, east=180, west=180,
+    ... top=100, bottom=-20)
+    >>> extent = tgis.STVDSSpatialExtent(
+    ... ident="stvds at PERMANENT", north=90, south=90, east=180, west=180,
+    ... top=100, bottom=-20)
 
- at endcode
-
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 from base import *
 
 
 class SpatialExtent(SQLDatabaseInterface):
-    """!This is the spatial extent base class for all maps and space time datasets
+    """This is the spatial extent base class for all maps and space time datasets
 
         This class implements a three dimensional axis aligned bounding box
         and functions to compute topological relationships
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> extent = SpatialExtent(table="raster_spatial_extent",
-        ... ident="soil at PERMANENT", north=90, south=90, east=180, west=180,
-        ... top=100, bottom=-20)
-        >>> extent.id
-        'soil at PERMANENT'
-        >>> extent.north
-        90.0
-        >>> extent.south
-        90.0
-        >>> extent.east
-        180.0
-        >>> extent.west
-        180.0
-        >>> extent.top
-        100.0
-        >>> extent.bottom
-        -20.0
-        >>> extent.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 90.0
-         | South:...................... 90.0
-         | East:.. .................... 180.0
-         | West:....................... 180.0
-         | Top:........................ 100.0
-         | Bottom:..................... -20.0
-        >>> extent.print_shell_info()
-        north=90.0
-        south=90.0
-        east=180.0
-        west=180.0
-        top=100.0
-        bottom=-20.0
+            >>> init()
+            >>> extent = SpatialExtent(table="raster_spatial_extent",
+            ... ident="soil at PERMANENT", north=90, south=90, east=180, west=180,
+            ... top=100, bottom=-20)
+            >>> extent.id
+            'soil at PERMANENT'
+            >>> extent.north
+            90.0
+            >>> extent.south
+            90.0
+            >>> extent.east
+            180.0
+            >>> extent.west
+            180.0
+            >>> extent.top
+            100.0
+            >>> extent.bottom
+            -20.0
+            >>> extent.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 90.0
+             | South:...................... 90.0
+             | East:.. .................... 180.0
+             | West:....................... 180.0
+             | Top:........................ 100.0
+             | Bottom:..................... -20.0
+            >>> extent.print_shell_info()
+            north=90.0
+            south=90.0
+            east=180.0
+            west=180.0
+            top=100.0
+            bottom=-20.0
 
-        @endcode
     """
     def __init__(self, table=None, ident=None, north=None, south=None,
                  east=None, west=None, top=None, bottom=None, proj="XY"):
 
         SQLDatabaseInterface.__init__(self, table, ident)
         self.set_id(ident)
-        self.set_spatial_extent_from_values(north, south, east, west, top, bottom)
+        self.set_spatial_extent_from_values(north, south, east, west, top,
+                                            bottom)
         self.set_projection(proj)
 
     def overlapping_2d(self, extent):
-        """!Return True if this (A) and the provided spatial extent (B) overlaps
+        """Return True if this (A) and the provided spatial extent (B) overlaps
         in two dimensional space.
         Code is lend from wind_overlap.c in lib/gis
 
@@ -108,22 +103,20 @@
         - covered
         - equivalent
 
-         @code
+        .. code-block:: python
 
-         >>> A = SpatialExtent(north=80, south=20, east=60, west=10)
-         >>> B = SpatialExtent(north=80, south=20, east=60, west=10)
-         >>> A.overlapping_2d(B)
-         True
+             >>> A = SpatialExtent(north=80, south=20, east=60, west=10)
+             >>> B = SpatialExtent(north=80, south=20, east=60, west=10)
+             >>> A.overlapping_2d(B)
+             True
 
-         @endcode
-
-        @param extent The spatial extent to check overlapping with
-        @return True or False
+        :param extent: The spatial extent to check overlapping with
+        :return: True or False
         """
 
         if self.get_projection() != extent.get_projection():
             self.msgr.error(_("Projections are different. Unable to compute "
-                         "overlapping_2d for spatial extents"))
+                              "overlapping_2d for spatial extents"))
             return False
 
         N = extent.get_north()
@@ -156,7 +149,7 @@
         return True
 
     def overlapping(self, extent):
-        """!Return True if this (A) and the provided spatial
+        """Return True if this (A) and the provided spatial
         extent (B) overlaps in three dimensional space.
 
         Overlapping includes the spatial relations:
@@ -167,19 +160,17 @@
         - covered
         - equivalent
 
-         Usage:
+        Usage:
 
-         @code
+        .. code-block:: python
 
-         >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
-         >>> B = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
-         >>> A.overlapping(B)
-         True
+             >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+             >>> B = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+             >>> A.overlapping(B)
+             True
 
-         @endcode
-
-         @param extent The spatial extent to check overlapping with
-         @return True or False
+        :param extent: The spatial extent to check overlapping with
+        :return: True or False
         """
 
         if not self.overlapping_2d(extent):
@@ -197,11 +188,11 @@
         return True
 
     def intersect_2d(self, extent):
-        """!Return the two dimensional intersection as spatial_extent
+        """Return the two dimensional intersection as spatial_extent
            object or None in case no intersection was found.
 
-        @param extent The spatial extent to intersect with
-        @return The intersection spatial extent
+        :param extent: The spatial extent to intersect with
+        :return: The intersection spatial extent
         """
 
         if not self.overlapping_2d(extent):
@@ -243,80 +234,78 @@
             nS = eS
 
         new = SpatialExtent(north=nN, south=nS, east=nE, west=nW,
-                             top=0, bottom=0, proj=self.get_projection())
+                            top=0, bottom=0, proj=self.get_projection())
         return new
 
     def intersect(self, extent):
-        """!Return the three dimensional intersection as spatial_extent
+        """Return the three dimensional intersection as spatial_extent
         object or None in case no intersection was found.
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> C = A.intersect(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 20.0
-         | East:.. .................... 60.0
-         | West:....................... 10.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> C = A.intersect(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 40.0
-         | South:...................... 30.0
-         | East:.. .................... 60.0
-         | West:....................... 10.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
-        ... bottom=-50, top=50)
-        >>> C = A.intersect(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 40.0
-         | South:...................... 30.0
-         | East:.. .................... 60.0
-         | West:....................... 30.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
-        ... bottom=-30, top=50)
-        >>> C = A.intersect(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 40.0
-         | South:...................... 30.0
-         | East:.. .................... 60.0
-         | West:....................... 30.0
-         | Top:........................ 50.0
-         | Bottom:..................... -30.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
-        ... bottom=-30, top=30)
-        >>> C = A.intersect(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 40.0
-         | South:...................... 30.0
-         | East:.. .................... 60.0
-         | West:....................... 30.0
-         | Top:........................ 30.0
-         | Bottom:..................... -30.0
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> C = A.intersect(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 20.0
+             | East:.. .................... 60.0
+             | West:....................... 10.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> C = A.intersect(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 40.0
+             | South:...................... 30.0
+             | East:.. .................... 60.0
+             | West:....................... 10.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
+            ... bottom=-50, top=50)
+            >>> C = A.intersect(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 40.0
+             | South:...................... 30.0
+             | East:.. .................... 60.0
+             | West:....................... 30.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
+            ... bottom=-30, top=50)
+            >>> C = A.intersect(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 40.0
+             | South:...................... 30.0
+             | East:.. .................... 60.0
+             | West:....................... 30.0
+             | Top:........................ 50.0
+             | Bottom:..................... -30.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
+            ... bottom=-30, top=30)
+            >>> C = A.intersect(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 40.0
+             | South:...................... 30.0
+             | East:.. .................... 60.0
+             | West:....................... 30.0
+             | Top:........................ 30.0
+             | Bottom:..................... -30.0
 
-         @endcode
 
-
-         @param extent The spatial extent to intersect with
-         @return The intersection spatial extent
+         :param extent: The spatial extent to intersect with
+         :return: The intersection spatial extent
         """
 
         if not self.overlapping(extent):
@@ -344,11 +333,11 @@
         return new
 
     def union_2d(self, extent):
-        """!Return the two dimensional union as spatial_extent
+        """Return the two dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-        @param extent The spatial extent to create a union with
-        @return The union spatial extent
+        :param extent: The spatial extent to create a union with
+        :return: The union spatial extent
         """
         if not self.overlapping_2d(extent) and not self.meet_2d(extent):
             return None
@@ -356,10 +345,10 @@
         return self.disjoint_union_2d(extent)
 
     def disjoint_union_2d(self, extent):
-        """!Return the two dimensional union as spatial_extent.
+        """Return the two dimensional union as spatial_extent.
 
-        @param extent The spatial extent to create a union with
-        @return The union spatial extent
+        :param extent: The spatial extent to create a union with
+        :return: The union spatial extent
         """
         eN = extent.get_north()
         eS = extent.get_south()
@@ -397,15 +386,15 @@
             nS = eS
 
         new = SpatialExtent(north=nN, south=nS, east=nE, west=nW,
-                             top=0, bottom=0, proj=self.get_projection())
+                            top=0, bottom=0, proj=self.get_projection())
         return new
 
     def union(self, extent):
-        """!Return the three dimensional union as spatial_extent
+        """Return the three dimensional union as spatial_extent
            object or None in case the extents does not overlap or meet.
 
-        @param extent The spatial extent to create a union with
-        @return The union spatial extent
+        :param extent: The spatial extent to create a union with
+        :return: The union spatial extent
         """
         if not self.overlapping(extent) and not self.meet(extent):
             return None
@@ -413,87 +402,86 @@
         return self.disjoint_union(extent)
 
     def disjoint_union(self, extent):
-        """!Return the three dimensional union as spatial_extent .
+        """Return the three dimensional union as spatial_extent .
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> C = A.disjoint_union(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 20.0
-         | East:.. .................... 60.0
-         | West:....................... 10.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> C = A.disjoint_union(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 20.0
-         | East:.. .................... 60.0
-         | West:....................... 10.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
-        ... bottom=-50, top=50)
-        >>> C = A.disjoint_union(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 20.0
-         | East:.. .................... 60.0
-         | West:....................... 10.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
-        ... bottom=-30, top=50)
-        >>> C = A.disjoint_union(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 20.0
-         | East:.. .................... 60.0
-         | West:....................... 10.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
-        ... bottom=-30, top=30)
-        >>> C = A.disjoint_union(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 80.0
-         | South:...................... 20.0
-         | East:.. .................... 60.0
-         | West:....................... 10.0
-         | Top:........................ 50.0
-         | Bottom:..................... -50.0
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> B = SpatialExtent(north=90, south=80, east=70, west=20,
-        ... bottom=-30, top=60)
-        >>> C = A.disjoint_union(B)
-        >>> C.print_info()
-         +-------------------- Spatial extent ----------------------------------------+
-         | North:...................... 90.0
-         | South:...................... 20.0
-         | East:.. .................... 70.0
-         | West:....................... 10.0
-         | Top:........................ 60.0
-         | Bottom:..................... -50.0
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> C = A.disjoint_union(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 20.0
+             | East:.. .................... 60.0
+             | West:....................... 10.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> C = A.disjoint_union(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 20.0
+             | East:.. .................... 60.0
+             | West:....................... 10.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
+            ... bottom=-50, top=50)
+            >>> C = A.disjoint_union(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 20.0
+             | East:.. .................... 60.0
+             | West:....................... 10.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
+            ... bottom=-30, top=50)
+            >>> C = A.disjoint_union(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 20.0
+             | East:.. .................... 60.0
+             | West:....................... 10.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
+            ... bottom=-30, top=30)
+            >>> C = A.disjoint_union(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 80.0
+             | South:...................... 20.0
+             | East:.. .................... 60.0
+             | West:....................... 10.0
+             | Top:........................ 50.0
+             | Bottom:..................... -50.0
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> B = SpatialExtent(north=90, south=80, east=70, west=20,
+            ... bottom=-30, top=60)
+            >>> C = A.disjoint_union(B)
+            >>> C.print_info()
+             +-------------------- Spatial extent ----------------------------------------+
+             | North:...................... 90.0
+             | South:...................... 20.0
+             | East:.. .................... 70.0
+             | West:....................... 10.0
+             | Top:........................ 60.0
+             | Bottom:..................... -50.0
 
-         @endcode
 
-         @param extent The spatial extent to create a disjoint union with
-         @return The union spatial extent
+         :param extent: The spatial extent to create a disjoint union with
+         :return: The union spatial extent
         """
 
         new = self.disjoint_union_2d(extent)
@@ -518,23 +506,23 @@
         return new
 
     def is_in_2d(self, extent):
-        """!Return True if this extent (A) is located in the provided spatial
+        """Return True if this extent (A) is located in the provided spatial
         extent (B) in two dimensions.
 
-        @verbatim
-         _____
-        |A _  |
-        | |_| |
-        |_____|B
+        ::
 
-        @endverbatim
+             _____
+            |A _  |
+            | |_| |
+            |_____|B
 
-        @param extent The spatial extent
-        @return True or False
+
+        :param extent: The spatial extent
+        :return: True or False
         """
         if self.get_projection() != extent.get_projection():
             self.msgr.error(_("Projections are different. Unable to compute "
-                         "is_in_2d for spatial extents"))
+                              "is_in_2d for spatial extents"))
             return False
 
         eN = extent.get_north()
@@ -569,26 +557,24 @@
         return True
 
     def is_in(self, extent):
-        """!Return True if this extent (A) is located in the provided spatial
+        """Return True if this extent (A) is located in the provided spatial
         extent (B) in three dimensions.
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=79, south=21, east=59, west=11,
-        ... bottom=-49, top=49)
-        >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> A.is_in(B)
-        True
-        >>> B.is_in(A)
-        False
+            >>> A = SpatialExtent(north=79, south=21, east=59, west=11,
+            ... bottom=-49, top=49)
+            >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> A.is_in(B)
+            True
+            >>> B.is_in(A)
+            False
 
-        @endcode
-
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
         if not self.is_in_2d(extent):
             return False
@@ -607,74 +593,68 @@
         return True
 
     def contain_2d(self, extent):
-        """!Return True if this extent (A) contains the provided spatial
+        """Return True if this extent (A) contains the provided spatial
         extent (B) in two dimensions.
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10)
-        >>> B = SpatialExtent(north=79, south=21, east=59, west=11)
-        >>> A.contain_2d(B)
-        True
-        >>> B.contain_2d(A)
-        False
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10)
+            >>> B = SpatialExtent(north=79, south=21, east=59, west=11)
+            >>> A.contain_2d(B)
+            True
+            >>> B.contain_2d(A)
+            False
 
-        @endcode
-
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
         return extent.is_in_2d(self)
 
     def contain(self, extent):
-        """!Return True if this extent (A) contains the provided spatial
+        """Return True if this extent (A) contains the provided spatial
         extent (B) in three dimensions.
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> B = SpatialExtent(north=79, south=21, east=59, west=11,
-        ... bottom=-49, top=49)
-        >>> A.contain(B)
-        True
-        >>> B.contain(A)
-        False
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> B = SpatialExtent(north=79, south=21, east=59, west=11,
+            ... bottom=-49, top=49)
+            >>> A.contain(B)
+            True
+            >>> B.contain(A)
+            False
 
-        @endcode
-
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
         return extent.is_in(self)
 
     def equivalent_2d(self, extent):
-        """!Return True if this extent (A) is equal to the provided spatial
+        """Return True if this extent (A) is equal to the provided spatial
         extent (B) in two dimensions.
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10)
-        >>> B = SpatialExtent(north=80, south=20, east=60, west=10)
-        >>> A.equivalent_2d(B)
-        True
-        >>> B.equivalent_2d(A)
-        True
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10)
+            >>> B = SpatialExtent(north=80, south=20, east=60, west=10)
+            >>> A.equivalent_2d(B)
+            True
+            >>> B.equivalent_2d(A)
+            True
 
-        @endcode
-
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
         if self.get_projection() != extent.get_projection():
             self.msgr.error(_("Projections are different. Unable to compute "
-                         "equivalent_2d for spatial extents"))
+                              "equivalent_2d for spatial extents"))
             return False
 
         eN = extent.get_north()
@@ -709,26 +689,24 @@
         return True
 
     def equivalent(self, extent):
-        """!Return True if this extent (A) is equal to the provided spatial
+        """Return True if this extent (A) is equal to the provided spatial
         extent (B) in three dimensions.
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
-        ... bottom=-50, top=50)
-        >>> A.equivalent(B)
-        True
-        >>> B.equivalent(A)
-        True
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
+            ... bottom=-50, top=50)
+            >>> A.equivalent(B)
+            True
+            >>> B.equivalent(A)
+            True
 
-        @endcode
-
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         if not self.equivalent_2d(extent):
@@ -748,39 +726,40 @@
         return True
 
     def cover_2d(self, extent):
-        """!Return True if this extent (A) covers the provided spatial
+        """Return True if this extent (A) covers the provided spatial
         extent (B) in two dimensions.
 
-        @verbatim
-         _____    _____    _____    _____
-        |A  __|  |__  A|  |A | B|  |B | A|
-        |  |B |  | B|  |  |  |__|  |__|  |
-        |__|__|  |__|__|  |_____|  |_____|
+        ::
 
-         _____    _____    _____    _____
-        |A|B| |  |A  __|  |A _  |  |__  A|
-        | |_| |  |  |__|B | |B| | B|__|  |
-        |_____|  |_____|  |_|_|_|  |_____|
+             _____    _____    _____    _____
+            |A  __|  |__  A|  |A | B|  |B | A|
+            |  |B |  | B|  |  |  |__|  |__|  |
+            |__|__|  |__|__|  |_____|  |_____|
 
-         _____    _____    _____    _____
-        |A|B  |  |_____|A |A|B|A|  |_____|A
-        | |   |  |B    |  | | | |  |_____|B
-        |_|___|  |_____|  |_|_|_|  |_____|A
+             _____    _____    _____    _____
+            |A|B| |  |A  __|  |A _  |  |__  A|
+            | |_| |  |  |__|B | |B| | B|__|  |
+            |_____|  |_____|  |_|_|_|  |_____|
 
-        @endverbatim
+             _____    _____    _____    _____
+            |A|B  |  |_____|A |A|B|A|  |_____|A
+            | |   |  |B    |  | | | |  |_____|B
+            |_|___|  |_____|  |_|_|_|  |_____|A
 
+
         The following cases are excluded:
 
         - contain
         - in
         - equivalent
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         if self.get_projection() != extent.get_projection():
-            self.msgr.error(_("Projections are different. Unable to compute cover_2d for spatial extents"))
+            self.msgr.error(_("Projections are different. Unable to compute"
+                              " cover_2d for spatial extents"))
             return False
 
         # Exclude equivalent_2d
@@ -838,7 +817,7 @@
         return True
 
     def cover(self, extent):
-        """!Return True if this extent covers the provided spatial
+        """Return True if this extent covers the provided spatial
         extent in three dimensions.
 
         The following cases are excluded:
@@ -847,12 +826,12 @@
         - in
         - equivalent
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
         if self.get_projection() != extent.get_projection():
             self.msgr.error(_("Projections are different. Unable to compute "
-                         "cover for spatial extents"))
+                              "cover for spatial extents"))
             return False
 
         # Exclude equivalent_2d
@@ -928,7 +907,7 @@
         return True
 
     def covered_2d(self, extent):
-        """!Return True if this extent is covered by the provided spatial
+        """Return True if this extent is covered by the provided spatial
         extent in two dimensions.
 
         The following cases are excluded:
@@ -937,14 +916,14 @@
         - in
         - equivalent
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         return extent.cover_2d(self)
 
     def covered(self, extent):
-        """!Return True if this extent is covered by the provided spatial
+        """Return True if this extent is covered by the provided spatial
         extent in three dimensions.
 
         The following cases are excluded:
@@ -953,26 +932,26 @@
         - in
         - equivalent
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         return extent.cover(self)
 
     def overlap_2d(self, extent):
-        """!Return True if this extent (A) overlaps with the provided spatial
+        """Return True if this extent (A) overlaps with the provided spatial
         extent (B) in two dimensions.
         Code is lend from wind_overlap.c in lib/gis
 
-        @verbatim
-         _____
-        |A  __|__
-        |  |  | B|
-        |__|__|  |
-           |_____|
+        ::
 
-        @endverbatim
+             _____
+            |A  __|__
+            |  |  | B|
+            |__|__|  |
+               |_____|
 
+
         The following cases are excluded:
 
         - contain
@@ -981,8 +960,8 @@
         - covered
         - equivalent
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         if self.contain_2d(extent):
@@ -1030,7 +1009,7 @@
         return True
 
     def overlap(self, extent):
-        """!Return True if this extent overlaps with the provided spatial
+        """Return True if this extent overlaps with the provided spatial
         extent in three dimensions.
 
         The following cases are excluded:
@@ -1041,8 +1020,8 @@
         - covered
         - equivalent
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         if self.is_in(extent):
@@ -1098,37 +1077,37 @@
         return True
 
     def meet_2d(self, extent):
-        """!Return True if this extent (A) meets with the provided spatial
+        """Return True if this extent (A) meets with the provided spatial
         extent (B) in two dimensions.
 
-        @verbatim
-          _____ _____
-         |  A  |  B  |
-         |_____|     |
+        ::
+
+              _____ _____
+             |  A  |  B  |
+             |_____|     |
+                   |_____|
+              _____ _____
+             |  B  |  A  |
+             |     |     |
+             |_____|_____|
+               ___
+              | A |
+              |   |
+              |___|
+             |  B  |
+             |     |
+             |_____|
+              _____
+             |  B  |
+             |     |
+             |_____|_
+               |  A  |
+               |     |
                |_____|
-          _____ _____
-         |  B  |  A  |
-         |     |     |
-         |_____|_____|
-           ___
-          | A |
-          |   |
-          |___|
-         |  B  |
-         |     |
-         |_____|
-          _____
-         |  B  |
-         |     |
-         |_____|_
-           |  A  |
-           |     |
-           |_____|
 
-         @endverbatim
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         eN = extent.get_north()
@@ -1183,11 +1162,11 @@
         return True
 
     def meet(self, extent):
-        """!Return True if this extent meets with the provided spatial
+        """Return True if this extent meets with the provided spatial
         extent in three dimensions.
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
         eN = extent.get_north()
         eS = extent.get_south()
@@ -1263,21 +1242,21 @@
         return True
 
     def disjoint_2d(self, extent):
-        """!Return True if this extent (A) is disjoint with the provided spatial
+        """Return True if this extent (A) is disjoint with the provided spatial
         extent (B) in three dimensions.
 
-        @verbatim
-          _____
-         |  A  |
-         |_____|
-         _______
-        |   B   |
-        |_______|
+        ::
 
-         @endverbatim
+              _____
+             |  A  |
+             |_____|
+             _______
+            |   B   |
+            |_______|
 
-        @param extent The spatial extent
-        @return True or False
+
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         if self.is_in_2d(extent):
@@ -1298,17 +1277,17 @@
         if self.overlapping_2d(extent):
             return False
 
-        if  self.meet_2d(extent):
+        if self.meet_2d(extent):
             return False
 
         return True
 
     def disjoint(self, extent):
-        """!Return True if this extent is disjoint with the provided spatial
+        """Return True if this extent is disjoint with the provided spatial
         extent in three dimensions.
 
-        @param extent The spatial extent
-        @return True or False
+        :param extent: The spatial extent
+        :return: True or False
         """
 
         if self.is_in(extent):
@@ -1329,13 +1308,13 @@
         if self.overlapping(extent):
             return False
 
-        if  self.meet(extent):
+        if self.meet(extent):
             return False
 
         return True
 
     def spatial_relation_2d(self, extent):
-        """!Returns the two dimensional spatial relation between this
+        """Returns the two dimensional spatial relation between this
         extent and the provided spatial extent in two dimensions.
 
         Spatial relations are:
@@ -1372,7 +1351,7 @@
         return "unknown"
 
     def spatial_relation(self, extent):
-        """!Returns the two dimensional spatial relation between this
+        """Returns the two dimensional spatial relation between this
         extent and the provided spatial extent in three dimensions.
 
         Spatial relations are:
@@ -1389,167 +1368,166 @@
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation(B)
-        'equivalent'
-        >>> B.spatial_relation(A)
-        'equivalent'
-        >>> B = SpatialExtent(north=70, south=20, east=60, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'cover'
-        >>> A.spatial_relation(B)
-        'cover'
-        >>> B = SpatialExtent(north=70, south=30, east=60, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'cover'
-        >>> A.spatial_relation(B)
-        'cover'
-        >>> B.spatial_relation_2d(A)
-        'covered'
-        >>> B.spatial_relation(A)
-        'covered'
-        >>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'cover'
-        >>> B.spatial_relation_2d(A)
-        'covered'
-        >>> A.spatial_relation(B)
-        'cover'
-        >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-50, top=50)
-        >>> B.spatial_relation(A)
-        'covered'
-        >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'contain'
-        >>> A.spatial_relation(B)
-        'cover'
-        >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-40, top=50)
-        >>> A.spatial_relation(B)
-        'cover'
-        >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-40, top=40)
-        >>> A.spatial_relation(B)
-        'contain'
-        >>> B.spatial_relation(A)
-        'in'
-        >>> B = SpatialExtent(north=90, south=30, east=50, west=20, bottom=-40, top=40)
-        >>> A.spatial_relation_2d(B)
-        'overlap'
-        >>> A.spatial_relation(B)
-        'overlap'
-        >>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-40, top=40)
-        >>> A.spatial_relation_2d(B)
-        'in'
-        >>> A.spatial_relation(B)
-        'overlap'
-        >>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-40, top=60)
-        >>> A.spatial_relation(B)
-        'overlap'
-        >>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-60, top=60)
-        >>> A.spatial_relation(B)
-        'in'
-        >>> A = SpatialExtent(north=80, south=60, east=60, west=10, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=60, south=20, east=60, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'meet'
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=60, south=40, east=60, west=10, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=80, south=60, east=60, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'meet'
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=40, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'meet'
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=90, south=30, east=60, west=40, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'meet'
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=70, south=50, east=60, west=40, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'meet'
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=60, south=20, east=60, west=40, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'meet'
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=40, south=20, east=60, west=40, bottom=-50, top=50)
-        >>> A.spatial_relation_2d(B)
-        'disjoint'
-        >>> A.spatial_relation(B)
-        'disjoint'
-        >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=60, south=20, east=60, west=40, bottom=-60, top=60)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=90, south=30, east=60, west=40, bottom=-40, top=40)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
-        >>> B = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
-        >>> B = SpatialExtent(north=80, south=50, east=60, west=30, bottom=-50, top=0)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
-        >>> B = SpatialExtent(north=70, south=50, east=50, west=30, bottom=-50, top=0)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
-        >>> B = SpatialExtent(north=90, south=30, east=70, west=10, bottom=-50, top=0)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
-        >>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=-50, top=0)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
-        >>> B = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
-        >>> B = SpatialExtent(north=80, south=50, east=60, west=30, bottom=0, top=50)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
-        >>> B = SpatialExtent(north=70, south=50, east=50, west=30, bottom=0, top=50)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
-        >>> B = SpatialExtent(north=90, south=30, east=70, west=10, bottom=0, top=50)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
-        >>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=0, top=50)
-        >>> A.spatial_relation(B)
-        'meet'
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=90, south=81, east=60, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation(B)
-        'disjoint'
-        >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
-        >>> B = SpatialExtent(north=90, south=80, east=60, west=10, bottom=-50, top=50)
-        >>> A.spatial_relation(B)
-        'meet'
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation(B)
+            'equivalent'
+            >>> B.spatial_relation(A)
+            'equivalent'
+            >>> B = SpatialExtent(north=70, south=20, east=60, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'cover'
+            >>> A.spatial_relation(B)
+            'cover'
+            >>> B = SpatialExtent(north=70, south=30, east=60, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'cover'
+            >>> A.spatial_relation(B)
+            'cover'
+            >>> B.spatial_relation_2d(A)
+            'covered'
+            >>> B.spatial_relation(A)
+            'covered'
+            >>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'cover'
+            >>> B.spatial_relation_2d(A)
+            'covered'
+            >>> A.spatial_relation(B)
+            'cover'
+            >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-50, top=50)
+            >>> B.spatial_relation(A)
+            'covered'
+            >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'contain'
+            >>> A.spatial_relation(B)
+            'cover'
+            >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-40, top=50)
+            >>> A.spatial_relation(B)
+            'cover'
+            >>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-40, top=40)
+            >>> A.spatial_relation(B)
+            'contain'
+            >>> B.spatial_relation(A)
+            'in'
+            >>> B = SpatialExtent(north=90, south=30, east=50, west=20, bottom=-40, top=40)
+            >>> A.spatial_relation_2d(B)
+            'overlap'
+            >>> A.spatial_relation(B)
+            'overlap'
+            >>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-40, top=40)
+            >>> A.spatial_relation_2d(B)
+            'in'
+            >>> A.spatial_relation(B)
+            'overlap'
+            >>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-40, top=60)
+            >>> A.spatial_relation(B)
+            'overlap'
+            >>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-60, top=60)
+            >>> A.spatial_relation(B)
+            'in'
+            >>> A = SpatialExtent(north=80, south=60, east=60, west=10, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=60, south=20, east=60, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'meet'
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=60, south=40, east=60, west=10, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=80, south=60, east=60, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'meet'
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=40, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'meet'
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=90, south=30, east=60, west=40, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'meet'
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=70, south=50, east=60, west=40, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'meet'
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=60, south=20, east=60, west=40, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'meet'
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=40, south=20, east=60, west=40, bottom=-50, top=50)
+            >>> A.spatial_relation_2d(B)
+            'disjoint'
+            >>> A.spatial_relation(B)
+            'disjoint'
+            >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=60, south=20, east=60, west=40, bottom=-60, top=60)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=90, south=30, east=60, west=40, bottom=-40, top=40)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
+            >>> B = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
+            >>> B = SpatialExtent(north=80, south=50, east=60, west=30, bottom=-50, top=0)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
+            >>> B = SpatialExtent(north=70, south=50, east=50, west=30, bottom=-50, top=0)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
+            >>> B = SpatialExtent(north=90, south=30, east=70, west=10, bottom=-50, top=0)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
+            >>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=-50, top=0)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
+            >>> B = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
+            >>> B = SpatialExtent(north=80, south=50, east=60, west=30, bottom=0, top=50)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
+            >>> B = SpatialExtent(north=70, south=50, east=50, west=30, bottom=0, top=50)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
+            >>> B = SpatialExtent(north=90, south=30, east=70, west=10, bottom=0, top=50)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
+            >>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=0, top=50)
+            >>> A.spatial_relation(B)
+            'meet'
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=90, south=81, east=60, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation(B)
+            'disjoint'
+            >>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
+            >>> B = SpatialExtent(north=90, south=80, east=60, west=10, bottom=-50, top=50)
+            >>> A.spatial_relation(B)
+            'meet'
 
-        @endcode
         """
 
         if self.equivalent(extent):
@@ -1571,15 +1549,16 @@
 
         return "unknown"
 
-    def set_spatial_extent_from_values(self, north, south, east, west, top, bottom):
-        """!Set the three dimensional spatial extent
+    def set_spatial_extent_from_values(self, north, south, east, west, top,
+                                       bottom):
+        """Set the three dimensional spatial extent
 
-           @param north The northern edge
-           @param south The southern edge
-           @param east The eastern edge
-           @param west The western edge
-           @param top The top edge
-           @param bottom The bottom edge
+           :param north: The northern edge
+           :param south: The southern edge
+           :param east: The eastern edge
+           :param west: The western edge
+           :param top: The top edge
+           :param bottom: The bottom edge
         """
 
         self.set_north(north)
@@ -1590,9 +1569,10 @@
         self.set_bottom(bottom)
 
     def set_spatial_extent(self, spatial_extent):
-        """!Set the three dimensional spatial extent
+        """Set the three dimensional spatial extent
 
-            @param spatial_extent An object of type SpatialExtent or its subclasses
+           :param spatial_extent: An object of type SpatialExtent or its
+                                  subclasses
         """
 
         self.set_north(spatial_extent.get_north())
@@ -1603,7 +1583,7 @@
         self.set_bottom(spatial_extent.get_bottom())
 
     def set_projection(self, proj):
-        """!Set the projection of the spatial extent it should be XY or LL.
+        """Set the projection of the spatial extent it should be XY or LL.
            As default the projection is XY
         """
         if proj is None or (proj != "XY" and proj != "LL"):
@@ -1612,12 +1592,12 @@
             self.D["proj"] = proj
 
     def set_spatial_extent_from_values_2d(self, north, south, east, west):
-        """!Set the two dimensional spatial extent from values
+        """Set the two dimensional spatial extent from values
 
-           @param north The northern edge
-           @param south The southern edge
-           @param east The eastern edge
-           @param west The western edge
+           :param north: The northern edge
+           :param south: The southern edge
+           :param east: The eastern edge
+           :param west: The western edge
         """
 
         self.set_north(north)
@@ -1626,9 +1606,10 @@
         self.set_west(west)
 
     def set_spatial_extent_2d(self, spatial_extent):
-        """!Set the three dimensional spatial extent
+        """Set the three dimensional spatial extent
 
-            @param spatial_extent An object of type SpatialExtent or its subclasses
+           :param spatial_extent: An object of type SpatialExtent or its
+                                  subclasses
         """
 
         self.set_north(spatial_extent.north)
@@ -1637,55 +1618,55 @@
         self.set_west(spatial_extent.west)
 
     def set_id(self, ident):
-        """!Convenient method to set the unique identifier (primary key)"""
+        """Convenient method to set the unique identifier (primary key)"""
         self.ident = ident
         self.D["id"] = ident
 
     def set_north(self, north):
-        """!Set the northern edge of the map"""
+        """Set the northern edge of the map"""
         if north is not None:
             self.D["north"] = float(north)
         else:
             self.D["north"] = None
 
     def set_south(self, south):
-        """!Set the southern edge of the map"""
+        """Set the southern edge of the map"""
         if south is not None:
             self.D["south"] = float(south)
         else:
             self.D["south"] = None
 
     def set_west(self, west):
-        """!Set the western edge of the map"""
+        """Set the western edge of the map"""
         if west is not None:
             self.D["west"] = float(west)
         else:
             self.D["west"] = None
 
     def set_east(self, east):
-        """!Set the eastern edge of the map"""
+        """Set the eastern edge of the map"""
         if east is not None:
             self.D["east"] = float(east)
         else:
             self.D["east"] = None
 
     def set_top(self, top):
-        """!Set the top edge of the map"""
+        """Set the top edge of the map"""
         if top is not None:
             self.D["top"] = float(top)
         else:
             self.D["top"] = None
 
     def set_bottom(self, bottom):
-        """!Set the bottom edge of the map"""
+        """Set the bottom edge of the map"""
         if bottom is not None:
             self.D["bottom"] = float(bottom)
         else:
             self.D["bottom"] = None
 
     def get_id(self):
-        """!Convenient method to get the unique identifier (primary key)
-           @return None if not found
+        """Convenient method to get the unique identifier (primary key)
+           :return: None if not found
         """
         if "id" in self.D:
             return self.D["id"]
@@ -1693,16 +1674,16 @@
             return None
 
     def get_projection(self):
-        """!Get the projection of the spatial extent"""
+        """Get the projection of the spatial extent"""
         return self.D["proj"]
 
     def get_volume(self):
-        """!Compute the volume of the extent, in case z is zero
+        """Compute the volume of the extent, in case z is zero
            (top == bottom or top - bottom = 1) the area is returned"""
 
         if self.get_projection() == "LL":
             self.msgr.error(_("Volume computation is not supported "
-                         "for LL projections"))
+                              "for LL projections"))
 
         area = self.get_area()
 
@@ -1716,11 +1697,11 @@
         return area * z
 
     def get_area(self):
-        """!Compute the area of the extent, extent in z direction is ignored"""
+        """Compute the area of the extent, extent in z direction is ignored"""
 
         if self.get_projection() == "LL":
             self.msgr.error(_("Area computation is not supported "
-                         "for LL projections"))
+                              "for LL projections"))
 
         bbox = self.get_spatial_extent_as_tuple()
 
@@ -1730,7 +1711,7 @@
         return x * y
 
     def get_spatial_extent_as_tuple(self):
-        """!Return a tuple (north, south, east, west, top, bottom)
+        """Return a tuple (north, south, east, west, top, bottom)
            of the spatial extent"""
 
         return (
@@ -1738,53 +1719,53 @@
             self.top, self.bottom)
 
     def get_spatial_extent_as_tuple_2d(self):
-        """!Return a tuple (north, south, east, west,) of the 2d spatial extent
+        """Return a tuple (north, south, east, west,) of the 2d spatial extent
         """
         return (self.north, self.south, self.east, self.west)
 
     def get_north(self):
-        """!Get the northern edge of the map
-           @return None if not found"""
+        """Get the northern edge of the map
+           :return: None if not found"""
         if "north" in self.D:
             return self.D["north"]
         else:
             return None
 
     def get_south(self):
-        """!Get the southern edge of the map
-           @return None if not found"""
+        """Get the southern edge of the map
+           :return: None if not found"""
         if "south" in self.D:
             return self.D["south"]
         else:
             return None
 
     def get_east(self):
-        """!Get the eastern edge of the map
-           @return None if not found"""
+        """Get the eastern edge of the map
+           :return: None if not found"""
         if "east" in self.D:
             return self.D["east"]
         else:
             return None
 
     def get_west(self):
-        """!Get the western edge of the map
-           @return None if not found"""
+        """Get the western edge of the map
+           :return: None if not found"""
         if "west" in self.D:
             return self.D["west"]
         else:
             return None
 
     def get_top(self):
-        """!Get the top edge of the map
-           @return None if not found"""
+        """Get the top edge of the map
+           :return: None if not found"""
         if "top" in self.D:
             return self.D["top"]
         else:
             return None
 
     def get_bottom(self):
-        """!Get the bottom edge of the map
-           @return None if not found"""
+        """Get the bottom edge of the map
+           :return: None if not found"""
         if "bottom" in self.D:
             return self.D["bottom"]
         else:
@@ -1796,10 +1777,10 @@
     east = property(fget=get_east, fset=set_east)
     west = property(fget=get_west, fset=set_west)
     top = property(fget=get_top, fset=set_top)
-    bottom= property(fget=get_bottom, fset=set_bottom)
+    bottom = property(fget=get_bottom, fset=set_bottom)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " +-------------------- Spatial extent ----------------------------------------+"
         print " | North:...................... " + str(self.get_north())
@@ -1825,37 +1806,42 @@
     def __init__(self, ident=None, north=None, south=None, east=None,
                  west=None, top=None, bottom=None):
         SpatialExtent.__init__(self, "raster_spatial_extent",
-                                ident, north, south, east, west, top, bottom)
+                               ident, north, south, east, west, top, bottom)
 
+
 class Raster3DSpatialExtent(SpatialExtent):
     def __init__(self, ident=None, north=None, south=None, east=None,
                  west=None, top=None, bottom=None):
         SpatialExtent.__init__(self, "raster3d_spatial_extent",
-                                ident, north, south, east, west, top, bottom)
+                               ident, north, south, east, west, top, bottom)
 
+
 class VectorSpatialExtent(SpatialExtent):
     def __init__(self, ident=None, north=None, south=None, east=None,
                  west=None, top=None, bottom=None):
         SpatialExtent.__init__(self, "vector_spatial_extent",
-                                ident, north, south, east, west, top, bottom)
+                               ident, north, south, east, west, top, bottom)
 
+
 class STRDSSpatialExtent(SpatialExtent):
     def __init__(self, ident=None, north=None, south=None, east=None,
                  west=None, top=None, bottom=None):
         SpatialExtent.__init__(self, "strds_spatial_extent",
-                                ident, north, south, east, west, top, bottom)
+                               ident, north, south, east, west, top, bottom)
 
+
 class STR3DSSpatialExtent(SpatialExtent):
     def __init__(self, ident=None, north=None, south=None, east=None,
                  west=None, top=None, bottom=None):
         SpatialExtent.__init__(self, "str3ds_spatial_extent",
-                                ident, north, south, east, west, top, bottom)
+                               ident, north, south, east, west, top, bottom)
 
+
 class STVDSSpatialExtent(SpatialExtent):
     def __init__(self, ident=None, north=None, south=None, east=None,
                  west=None, top=None, bottom=None):
         SpatialExtent.__init__(self, "stvds_spatial_extent",
-                                ident, north, south, east, west, top, bottom)
+                               ident, north, south, east, west, top, bottom)
 
 ###############################################################################
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/spatial_topology_dataset_connector.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/spatial_topology_dataset_connector.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/spatial_topology_dataset_connector.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,10 +1,7 @@
 # -*- coding: utf-8 -*-
-"""!@package grass.temporal
+"""
+Spatial topology connector class
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in temporal GIS Python library package.
-
 Usage:
 
 >>> import grass.temporal as tgis
@@ -15,17 +12,20 @@
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 import copy
 
+
 class SpatialTopologyDatasetConnector(object):
-    """!This class implements a spatial topology access structure to connect spatial related datasets
+    """This class implements a spatial topology access structure to connect
+       spatial related datasets
 
-       This object will be set up by spatial topology creation method provided by the 
-       SpatioTemporalTopologyBuilder.
+       This object will be set up by spatial topology creation method provided
+       by the SpatioTemporalTopologyBuilder.
 
        The following spatial relations with access methods are supported:
+
        - equivalent
        - overlap
        - in
@@ -33,265 +33,264 @@
        - meet
        - cover
        - covered
-            
+
         Usage:
-        
-        @code
-        
-        >>> import grass.temporal as tgis
-        >>> tgis.init()
-        >>> map = tgis.RasterDataset("a at P")
-        >>> tmr = tgis.SpatialTopologyDatasetConnector()
-        >>> tmr.append_equivalent(map)
-        >>> tmr.append_overlap(map)
-        >>> tmr.append_in(map)
-        >>> tmr.append_contain(map)
-        >>> tmr.append_meet(map)
-        >>> tmr.append_cover(map)
-        >>> tmr.append_covered(map)
-        >>> tmr.print_spatial_topology_info()
-         +-------------------- Spatial Topology --------------------------------------+
-         | Equivalent: ................ a at P
-         | Cover: ..................... a at P
-         | Covered: ................... a at P
-         | Overlap: ................... a at P
-         | In: ........................ a at P
-         | Contain: ................... a at P
-         | Meet: ...................... a at P
-        >>> tmr.print_spatial_topology_shell_info()
-        equivalent=a at P
-        cover=a at P
-        covered=a at P
-        overlap=a at P
-        in=a at P
-        contain=a at P
-        meet=a at P
-        >>> rlist = tmr.get_spatial_relations()
-        >>> if "COVER" in rlist.keys():
-        ...    print rlist["COVER"][0].get_id()
-        a at P
 
-        
-        @endcode
+        .. code-block:: python
+
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> map = tgis.RasterDataset("a at P")
+            >>> tmr = tgis.SpatialTopologyDatasetConnector()
+            >>> tmr.append_equivalent(map)
+            >>> tmr.append_overlap(map)
+            >>> tmr.append_in(map)
+            >>> tmr.append_contain(map)
+            >>> tmr.append_meet(map)
+            >>> tmr.append_cover(map)
+            >>> tmr.append_covered(map)
+            >>> tmr.print_spatial_topology_info()
+             +-------------------- Spatial Topology --------------------------------------+
+             | Equivalent: ................ a at P
+             | Cover: ..................... a at P
+             | Covered: ................... a at P
+             | Overlap: ................... a at P
+             | In: ........................ a at P
+             | Contain: ................... a at P
+             | Meet: ...................... a at P
+            >>> tmr.print_spatial_topology_shell_info()
+            equivalent=a at P
+            cover=a at P
+            covered=a at P
+            overlap=a at P
+            in=a at P
+            contain=a at P
+            meet=a at P
+            >>> rlist = tmr.get_spatial_relations()
+            >>> if "COVER" in rlist.keys():
+            ...    print rlist["COVER"][0].get_id()
+            a at P
+
     """
 
     def __init__(self):
         self.reset_spatial_topology()
 
     def reset_spatial_topology(self):
-        """!Reset any information about temporal topology"""
+        """Reset any information about temporal topology"""
         self._spatial_topology = {}
         self._has_spatial_topology = False
-        
+
     def get_spatial_relations(self):
-        """!Return the dictionary of spatial relationships
-        
-            Keys are the spatial relationships in upper case,
-            values are abstract map objects.
-            
-            @return The spatial relations dictionary
+        """Return the dictionary of spatial relationships
+
+           Keys are the spatial relationships in upper case,
+           values are abstract map objects.
+
+           :return: The spatial relations dictionary
         """
         return copy.copy(self._spatial_topology)
-    
+
     def get_number_of_spatial_relations(self):
-        """! Return a dictionary in which the keys are the relation names and the value
-        are the number of relations.
-        
-        The following relations are available:
-       - equivalent
-       - overlap
-       - in
-       - contain
-       - meet
-       - cover
-       - covered
-        
-        To access topological information the spatial topology must be build first
-        using the SpatialTopologyBuilder.
-        
-        @return the dictionary with relations as keys and number as values or None in case the topology wasn't build
+        """ Return a dictionary in which the keys are the relation names and the value
+            are the number of relations.
+
+            The following relations are available:
+
+            - equivalent
+            - overlap
+            - in
+            - contain
+            - meet
+            - cover
+            - covered
+
+            To access topological information the spatial topology must be
+            build first using the SpatialTopologyBuilder.
+
+            :return: the dictionary with relations as keys and number as
+                     values or None in case the topology wasn't build
         """
-        if self._has_spatial_topology == False:
+        if self._has_spatial_topology is False:
             return None
-    
+
         relations = {}
         try:
-            relations["equivalent"] = len(self._spatial_topology["EQUIVALENT"]) 
+            relations["equivalent"] = len(self._spatial_topology["EQUIVALENT"])
         except:
             relations["equivalent"] = 0
-        try: 
-            relations["overlap"] = len(self._spatial_topology["OVERLAP"]) 
-        except: 
+        try:
+            relations["overlap"] = len(self._spatial_topology["OVERLAP"])
+        except:
             relations["overlap"] = 0
-        try: 
+        try:
             relations["in"] = len(self._spatial_topology["IN"])
-        except: 
+        except:
             relations["in"] = 0
-        try: 
+        try:
             relations["contain"] = len(self._spatial_topology["CONTAIN"])
-        except: 
+        except:
             relations["contain"] = 0
-        try: 
+        try:
             relations["meet"] = len(self._spatial_topology["MEET"])
-        except: 
+        except:
             relations["meet"] = 0
-        try: 
+        try:
             relations["cover"] = len(self._spatial_topology["COVER"])
-        except: 
+        except:
             relations["cover"] = 0
-        try: 
+        try:
             relations["covered"] = len(self._spatial_topology["COVERED"])
-        except: 
+        except:
             relations["covered"] = 0
-            
+
         return relations
 
     def set_spatial_topology_build_true(self):
-        """!Same as name"""
+        """Same as name"""
         self._has_spatial_topology = True
 
     def set_spatial_topology_build_false(self):
-        """!Same as name"""
+        """Same as name"""
         self._has_spatial_topology = False
 
     def is_spatial_topology_build(self):
-        """!Check if the temporal topology was build"""
+        """Check if the temporal topology was build"""
         return self._has_spatial_topology
 
     def append_equivalent(self, map):
-        """!Append a map with equivalent spatial extent as this map
+        """Append a map with equivalent spatial extent as this map
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "EQUIVALENT" not in self._spatial_topology:
             self._spatial_topology["EQUIVALENT"] = []
         self._spatial_topology["EQUIVALENT"].append(map)
 
     def get_equivalent(self):
-        """!Return a list of map objects with equivalent spatial extent as this map
+        """Return a list of map objects with equivalent spatial extent as this map
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "EQUIVALENT" not in self._spatial_topology:
             return None
         return self._spatial_topology["EQUIVALENT"]
 
     def append_overlap(self, map):
-        """!Append a map that this spatial overlap with this map
+        """Append a map that this spatial overlap with this map
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "OVERLAP" not in self._spatial_topology:
             self._spatial_topology["OVERLAP"] = []
         self._spatial_topology["OVERLAP"].append(map)
 
     def get_overlap(self):
-        """!Return a list of map objects that this map spatial overlap with
+        """Return a list of map objects that this map spatial overlap with
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "OVERLAP" not in self._spatial_topology:
             return None
         return self._spatial_topology["OVERLAP"]
 
     def append_in(self, map):
-        """!Append a map that this is spatial in this map
+        """Append a map that this is spatial in this map
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "IN" not in self._spatial_topology:
             self._spatial_topology["IN"] = []
         self._spatial_topology["IN"].append(map)
 
     def get_in(self):
-        """!Return a list of map objects that are spatial in this map
+        """Return a list of map objects that are spatial in this map
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "IN" not in self._spatial_topology:
             return None
         return self._spatial_topology["IN"]
 
     def append_contain(self, map):
-        """!Append a map that this map spatially contains
+        """Append a map that this map spatially contains
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "CONTAIN" not in self._spatial_topology:
             self._spatial_topology["CONTAIN"] = []
         self._spatial_topology["CONTAIN"].append(map)
 
     def get_contain(self):
-        """!Return a list of map objects that this map contains
+        """Return a list of map objects that this map contains
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "CONTAIN" not in self._spatial_topology:
             return None
         return self._spatial_topology["CONTAIN"]
 
     def append_meet(self, map):
-        """!Append a map that spatially meet with this map
+        """Append a map that spatially meet with this map
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "MEET" not in self._spatial_topology:
             self._spatial_topology["MEET"] = []
         self._spatial_topology["MEET"].append(map)
 
     def get_meet(self):
-        """!Return a list of map objects that spatially meet with this map
+        """Return a list of map objects that spatially meet with this map
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "MEET" not in self._spatial_topology:
             return None
         return self._spatial_topology["MEET"]
 
     def append_cover(self, map):
-        """!Append a map that spatially cover this map
+        """Append a map that spatially cover this map
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "COVER" not in self._spatial_topology:
             self._spatial_topology["COVER"] = []
         self._spatial_topology["COVER"].append(map)
 
     def get_cover(self):
-        """!Return a list of map objects that spatially cover this map
+        """Return a list of map objects that spatially cover this map
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "COVER" not in self._spatial_topology:
             return None
         return self._spatial_topology["COVER"]
 
     def append_covered(self, map):
-        """!Append a map that is spatially covered by this map
+        """Append a map that is spatially covered by this map
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "COVERED" not in self._spatial_topology:
             self._spatial_topology["COVERED"] = []
         self._spatial_topology["COVERED"].append(map)
 
     def get_covered(self):
-        """!Return a list of map objects that are spatially covered by this map
+        """Return a list of map objects that are spatially covered by this map
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "COVERED" not in self._spatial_topology:
             return None
         return self._spatial_topology["COVERED"]
 
-
     def _generate_map_list_string(self, map_list, line_wrap=True):
         count = 0
         string = ""
@@ -306,26 +305,19 @@
             count += 1
 
         return string
-    
+
     # Set the properties
-    equivalent = property(fget=get_equivalent, 
-                                       fset=append_equivalent)
-    cover = property(fget=get_cover, 
-                                     fset=append_cover)
-    covered = property(fget=get_covered, 
-                                       fset=append_covered)
-    overlap = property(fget=get_overlap, 
-                                     fset=append_overlap)
-    in_ = property(fget=get_in, 
-                                     fset=append_in)
-    contain = property(fget=get_contain, 
-                                     fset=append_contain)
-    meet = property(fget=get_meet, 
-                                     fset=append_meet)
+    equivalent = property(fget=get_equivalent, fset=append_equivalent)
+    cover = property(fget=get_cover, fset=append_cover)
+    covered = property(fget=get_covered, fset=append_covered)
+    overlap = property(fget=get_overlap, fset=append_overlap)
+    in_ = property(fget=get_in, fset=append_in)
+    contain = property(fget=get_contain, fset=append_contain)
+    meet = property(fget=get_meet, fset=append_meet)
 
     def print_spatial_topology_info(self):
-        """!Print information about this class in human readable style"""
-        
+        """Print information about this class in human readable style"""
+
         print " +-------------------- Spatial Topology --------------------------------------+"
         #          0123456789012345678901234567890
         if self.equivalent is not None:
@@ -351,10 +343,11 @@
                 self._generate_map_list_string(self.meet)
 
     def print_spatial_topology_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
 
         if self.equivalent is not None:
-            print "equivalent=" + self._generate_map_list_string(self.equivalent, False)
+            print "equivalent=" + self._generate_map_list_string(self.equivalent,
+                                                                 False)
         if self.cover is not None:
             print "cover=" + self._generate_map_list_string(
                 self.cover, False)

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/spatio_temporal_relationships.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/spatio_temporal_relationships.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/spatio_temporal_relationships.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,24 +1,21 @@
-"""!@package grass.temporal
+"""
+Class to build the spatio-temporal topology between map lists
 
- at brief GRASS Python scripting module (temporal GIS functions)
+Usage:
 
-Temporal GIS related functions to be used in temporal GIS Python library package.
+.. code-block:: python
 
-Usage:
+    import grass.temporal as tgis
 
- at code
-import grass.temporal as tgis
+    tgis.print_temporal_relations(maps)
 
-tgis.print_temporal_relations(maps)
-...
- at endcode
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 from abstract_dataset import *
 from datetime_math import *
@@ -29,339 +26,339 @@
 
 ###############################################################################
 
+
 class SpatioTemporalTopologyBuilder(object):
-    """!This class is designed to build the spatio-temporal topology
+    """This class is designed to build the spatio-temporal topology
        of spatio-temporally related abstract dataset objects.
 
-       The abstract dataset objects must be provided as a single list, or in two lists.
+       The abstract dataset objects must be provided as a single list, or in
+       two lists.
 
         Example:
 
-        @code
+        .. code-block:: python
 
-        # We have a space time raster dataset and build a map list
-        # from all registered maps ordered by start time
-        maps = strds.get_registered_maps_as_objects()
+            # We have a space time raster dataset and build a map list
+            # from all registered maps ordered by start time
+            maps = strds.get_registered_maps_as_objects()
 
-        # Now lets build the temporal topology of the maps in the list
+            # Now lets build the temporal topology of the maps in the list
 
-        tb = SpatioTemporalTopologyBuilder()
+            tb = SpatioTemporalTopologyBuilder()
 
-        tb.build(maps)
+            tb.build(maps)
 
-        dbif, connected = init_dbif(None)
+            dbif, connected = init_dbif(None)
 
-        for map in tb:
-            map.select(dbif)
-            map.print_info()
+            for map in tb:
+                map.select(dbif)
+                map.print_info()
 
-        # Same can be done with the existing map list
-        # But be aware that this is might not be temporally ordered
-        for map in maps:
-            map.select(dbf)
-            map.print_info()
+            # Same can be done with the existing map list
+            # But be aware that this is might not be temporally ordered
+            for map in maps:
+                map.select(dbf)
+                map.print_info()
 
-        # Using the next and previous methods, we can iterate over the
-        # topological related maps in this way
+            # Using the next and previous methods, we can iterate over the
+            # topological related maps in this way
 
-        first = tb.get_first()
+            first = tb.get_first()
 
-        while first:
-            first.print_topology_info()
-            first = first.next()
+            while first:
+                first.print_topology_info()
+                first = first.next()
 
-        # Dictionary like accessed
-        map = tb["name at mapset"]
+            # Dictionary like accessed
+            map = tb["name at mapset"]
 
-        >>> # Example with two lists of maps
-        >>> import grass.temporal as tgis
-        >>> import datetime
-        >>> # Create two list of maps with equal time stamps
-        >>> mapsA = []
-        >>> mapsB = []
-        >>> for i in range(4):
-        ...     idA = "a%i at B"%(i)
-        ...     mapA = tgis.RasterDataset(idA)
-        ...     idB = "b%i at B"%(i)
-        ...     mapB = tgis.RasterDataset(idB)
-        ...     check = mapA.set_relative_time(i, i + 1, "months")
-        ...     check = mapB.set_relative_time(i, i + 1, "months")
-        ...     mapsA.append(mapA)
-        ...     mapsB.append(mapB)
-        >>> # Build the topology between the two map lists
-        >>> tb = SpatioTemporalTopologyBuilder()
-        >>> tb.build(mapsA, mapsB, None)
-        >>> # Check relations of mapsA
-        >>> for map in mapsA:
-        ...     if map.get_equal():
-        ...         relations = map.get_equal()
-        ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-        ...               relations[0].get_name())
-        Map a0 has equal relation to map b0
-        Map a1 has equal relation to map b1
-        Map a2 has equal relation to map b2
-        Map a3 has equal relation to map b3
-        >>> # Check relations of mapsB
-        >>> for map in mapsB:
-        ...     if map.get_equal():
-        ...         relations = map.get_equal()
-        ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-        ...               relations[0].get_name())
-        Map b0 has equal relation to map a0
-        Map b1 has equal relation to map a1
-        Map b2 has equal relation to map a2
-        Map b3 has equal relation to map a3
+            >>> # Example with two lists of maps
+            >>> import grass.temporal as tgis
+            >>> import datetime
+            >>> # Create two list of maps with equal time stamps
+            >>> mapsA = []
+            >>> mapsB = []
+            >>> for i in range(4):
+            ...     idA = "a%i at B"%(i)
+            ...     mapA = tgis.RasterDataset(idA)
+            ...     idB = "b%i at B"%(i)
+            ...     mapB = tgis.RasterDataset(idB)
+            ...     check = mapA.set_relative_time(i, i + 1, "months")
+            ...     check = mapB.set_relative_time(i, i + 1, "months")
+            ...     mapsA.append(mapA)
+            ...     mapsB.append(mapB)
+            >>> # Build the topology between the two map lists
+            >>> tb = SpatioTemporalTopologyBuilder()
+            >>> tb.build(mapsA, mapsB, None)
+            >>> # Check relations of mapsA
+            >>> for map in mapsA:
+            ...     if map.get_equal():
+            ...         relations = map.get_equal()
+            ...         print "Map %s has equal relation to map %s"%(map.get_name(),
+            ...               relations[0].get_name())
+            Map a0 has equal relation to map b0
+            Map a1 has equal relation to map b1
+            Map a2 has equal relation to map b2
+            Map a3 has equal relation to map b3
+            >>> # Check relations of mapsB
+            >>> for map in mapsB:
+            ...     if map.get_equal():
+            ...         relations = map.get_equal()
+            ...         print "Map %s has equal relation to map %s"%(map.get_name(),
+            ...               relations[0].get_name())
+            Map b0 has equal relation to map a0
+            Map b1 has equal relation to map a1
+            Map b2 has equal relation to map a2
+            Map b3 has equal relation to map a3
 
 
-        >>> mapsA = []
-        >>> mapsB = []
-        >>> for i in range(4):
-        ...     idA = "a%i at B"%(i)
-        ...     mapA = tgis.RasterDataset(idA)
-        ...     idB = "b%i at B"%(i)
-        ...     mapB = tgis.RasterDataset(idB)
-        ...     check = mapA.set_relative_time(i, i + 1, "months")
-        ...     check = mapB.set_relative_time(i + 1, i + 2, "months")
-        ...     mapsA.append(mapA)
-        ...     mapsB.append(mapB)
-        >>> # Build the topology between the two map lists
-        >>> tb = SpatioTemporalTopologyBuilder()
-        >>> tb.build(mapsA, mapsB, None)
-        >>> # Check relations of mapsA
-        >>> for map in mapsA:
-        ...     print(map.get_temporal_extent_as_tuple())
-        ...     m = map.get_temporal_relations()
-        ...     for key in m.keys():
-        ...         if key not in ["NEXT", "PREV"]:
-        ...             print(key, m[key][0].get_temporal_extent_as_tuple())
-        (0, 1)
-        ('PRECEDES', (1, 2))
-        (1, 2)
-        ('PRECEDES', (2, 3))
-        ('EQUAL', (1, 2))
-        (2, 3)
-        ('FOLLOWS', (1, 2))
-        ('PRECEDES', (3, 4))
-        ('EQUAL', (2, 3))
-        (3, 4)
-        ('FOLLOWS', (2, 3))
-        ('EQUAL', (3, 4))
-        ('PRECEDES', (4, 5))
+            >>> mapsA = []
+            >>> mapsB = []
+            >>> for i in range(4):
+            ...     idA = "a%i at B"%(i)
+            ...     mapA = tgis.RasterDataset(idA)
+            ...     idB = "b%i at B"%(i)
+            ...     mapB = tgis.RasterDataset(idB)
+            ...     check = mapA.set_relative_time(i, i + 1, "months")
+            ...     check = mapB.set_relative_time(i + 1, i + 2, "months")
+            ...     mapsA.append(mapA)
+            ...     mapsB.append(mapB)
+            >>> # Build the topology between the two map lists
+            >>> tb = SpatioTemporalTopologyBuilder()
+            >>> tb.build(mapsA, mapsB, None)
+            >>> # Check relations of mapsA
+            >>> for map in mapsA:
+            ...     print(map.get_temporal_extent_as_tuple())
+            ...     m = map.get_temporal_relations()
+            ...     for key in m.keys():
+            ...         if key not in ["NEXT", "PREV"]:
+            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            (0, 1)
+            ('PRECEDES', (1, 2))
+            (1, 2)
+            ('PRECEDES', (2, 3))
+            ('EQUAL', (1, 2))
+            (2, 3)
+            ('FOLLOWS', (1, 2))
+            ('PRECEDES', (3, 4))
+            ('EQUAL', (2, 3))
+            (3, 4)
+            ('FOLLOWS', (2, 3))
+            ('EQUAL', (3, 4))
+            ('PRECEDES', (4, 5))
 
-        >>> mapsA = []
-        >>> mapsB = []
-        >>> for i in range(4):
-        ...     idA = "a%i at B"%(i)
-        ...     mapA = tgis.RasterDataset(idA)
-        ...     idB = "b%i at B"%(i)
-        ...     mapB = tgis.RasterDataset(idB)
-        ...     start = datetime.datetime(2000 + i, 1, 1)
-        ...     end = datetime.datetime(2000 + i + 1, 1, 1)
-        ...     check = mapA.set_absolute_time(start, end)
-        ...     start = datetime.datetime(2000 + i + 1, 1, 1)
-        ...     end = datetime.datetime(2000 + i + 2, 1, 1)
-        ...     check = mapB.set_absolute_time(start, end)
-        ...     mapsA.append(mapA)
-        ...     mapsB.append(mapB)
-        >>> # Build the topology between the two map lists
-        >>> tb = SpatioTemporalTopologyBuilder()
-        >>> tb.build(mapsA, mapsB, None)
-        >>> # Check relations of mapsA
-        >>> for map in mapsA:
-        ...     print(map.get_temporal_extent_as_tuple())
-        ...     m = map.get_temporal_relations()
-        ...     for key in m.keys():
-        ...         if key not in ["NEXT", "PREV"]:
-        ...             print(key, m[key][0].get_temporal_extent_as_tuple())
-        (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
-        ('PRECEDES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
-        ('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('EQUAL', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
-        (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
-        ('FOLLOWS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
-        ('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('EQUAL', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
-        ('FOLLOWS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('EQUAL', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('PRECEDES', (datetime.datetime(2004, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            >>> mapsA = []
+            >>> mapsB = []
+            >>> for i in range(4):
+            ...     idA = "a%i at B"%(i)
+            ...     mapA = tgis.RasterDataset(idA)
+            ...     idB = "b%i at B"%(i)
+            ...     mapB = tgis.RasterDataset(idB)
+            ...     start = datetime.datetime(2000 + i, 1, 1)
+            ...     end = datetime.datetime(2000 + i + 1, 1, 1)
+            ...     check = mapA.set_absolute_time(start, end)
+            ...     start = datetime.datetime(2000 + i + 1, 1, 1)
+            ...     end = datetime.datetime(2000 + i + 2, 1, 1)
+            ...     check = mapB.set_absolute_time(start, end)
+            ...     mapsA.append(mapA)
+            ...     mapsB.append(mapB)
+            >>> # Build the topology between the two map lists
+            >>> tb = SpatioTemporalTopologyBuilder()
+            >>> tb.build(mapsA, mapsB, None)
+            >>> # Check relations of mapsA
+            >>> for map in mapsA:
+            ...     print(map.get_temporal_extent_as_tuple())
+            ...     m = map.get_temporal_relations()
+            ...     for key in m.keys():
+            ...         if key not in ["NEXT", "PREV"]:
+            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
+            ('PRECEDES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
+            ('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('EQUAL', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
+            (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
+            ('FOLLOWS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
+            ('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('EQUAL', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
+            ('FOLLOWS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('EQUAL', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('PRECEDES', (datetime.datetime(2004, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
 
-        >>> mapsA = []
-        >>> mapsB = []
-        >>> for i in range(4):
-        ...     idA = "a%i at B"%(i)
-        ...     mapA = tgis.RasterDataset(idA)
-        ...     idB = "b%i at B"%(i)
-        ...     mapB = tgis.RasterDataset(idB)
-        ...     start = datetime.datetime(2000 + i, 1, 1)
-        ...     end = datetime.datetime(2000 + i + 1, 1, 1)
-        ...     check = mapA.set_absolute_time(start, end)
-        ...     start = datetime.datetime(2000 + i, 1, 1)
-        ...     end = datetime.datetime(2000 + i + 3, 1, 1)
-        ...     check = mapB.set_absolute_time(start, end)
-        ...     mapsA.append(mapA)
-        ...     mapsB.append(mapB)
-        >>> # Build the topology between the two map lists
-        >>> tb = SpatioTemporalTopologyBuilder()
-        >>> tb.build(mapsA, mapsB, None)
-        >>> # Check relations of mapsA
-        >>> for map in mapsA:
-        ...     print(map.get_temporal_extent_as_tuple())
-        ...     m = map.get_temporal_relations()
-        ...     for key in m.keys():
-        ...         if key not in ["NEXT", "PREV"]:
-        ...             print(key, m[key][0].get_temporal_extent_as_tuple())
-        (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
-        ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('PRECEDES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
-        ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
-        (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
-        ('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
-        ('FINISHES', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
-        (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
-        ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('DURING', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('FINISHES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
+            >>> mapsA = []
+            >>> mapsB = []
+            >>> for i in range(4):
+            ...     idA = "a%i at B"%(i)
+            ...     mapA = tgis.RasterDataset(idA)
+            ...     idB = "b%i at B"%(i)
+            ...     mapB = tgis.RasterDataset(idB)
+            ...     start = datetime.datetime(2000 + i, 1, 1)
+            ...     end = datetime.datetime(2000 + i + 1, 1, 1)
+            ...     check = mapA.set_absolute_time(start, end)
+            ...     start = datetime.datetime(2000 + i, 1, 1)
+            ...     end = datetime.datetime(2000 + i + 3, 1, 1)
+            ...     check = mapB.set_absolute_time(start, end)
+            ...     mapsA.append(mapA)
+            ...     mapsB.append(mapB)
+            >>> # Build the topology between the two map lists
+            >>> tb = SpatioTemporalTopologyBuilder()
+            >>> tb.build(mapsA, mapsB, None)
+            >>> # Check relations of mapsA
+            >>> for map in mapsA:
+            ...     print(map.get_temporal_extent_as_tuple())
+            ...     m = map.get_temporal_relations()
+            ...     for key in m.keys():
+            ...         if key not in ["NEXT", "PREV"]:
+            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
+            ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('PRECEDES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
+            ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
+            ('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
+            ('FINISHES', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
+            ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('DURING', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('FINISHES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
 
-        >>> mapsA = []
-        >>> mapsB = []
-        >>> for i in range(4):
-        ...     idA = "a%i at B"%(i)
-        ...     mapA = tgis.RasterDataset(idA)
-        ...     idB = "b%i at B"%(i)
-        ...     mapB = tgis.RasterDataset(idB)
-        ...     start = datetime.datetime(2000 + i, 1, 1)
-        ...     end = datetime.datetime(2000 + i + 2, 1, 1)
-        ...     check = mapA.set_absolute_time(start, end)
-        ...     start = datetime.datetime(2000 + i, 1, 1)
-        ...     end = datetime.datetime(2000 + i + 3, 1, 1)
-        ...     check = mapB.set_absolute_time(start, end)
-        ...     mapsA.append(mapA)
-        ...     mapsB.append(mapB)
-        >>> # Build the topology between the two map lists
-        >>> tb = SpatioTemporalTopologyBuilder()
-        >>> tb.build(mapsA, mapsB, None)
-        >>> # Check relations of mapsA
-        >>> for map in mapsA:
-        ...     print(map.get_temporal_extent_as_tuple())
-        ...     m = map.get_temporal_relations()
-        ...     for key in m.keys():
-        ...         if key not in ["NEXT", "PREV"]:
-        ...             print(key, m[key][0].get_temporal_extent_as_tuple())
-        (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
-        ('OVERLAPS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
-        (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
-        ('OVERLAPS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
-        ('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
-        ('FINISHES', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
-        ('OVERLAPS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
-        ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
-        ('FINISHES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('DURING', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
-        (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0))
-        ('OVERLAPPED', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
-        ('DURING', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
-        ('FINISHES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
-        ('STARTS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
-        ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            >>> mapsA = []
+            >>> mapsB = []
+            >>> for i in range(4):
+            ...     idA = "a%i at B"%(i)
+            ...     mapA = tgis.RasterDataset(idA)
+            ...     idB = "b%i at B"%(i)
+            ...     mapB = tgis.RasterDataset(idB)
+            ...     start = datetime.datetime(2000 + i, 1, 1)
+            ...     end = datetime.datetime(2000 + i + 2, 1, 1)
+            ...     check = mapA.set_absolute_time(start, end)
+            ...     start = datetime.datetime(2000 + i, 1, 1)
+            ...     end = datetime.datetime(2000 + i + 3, 1, 1)
+            ...     check = mapB.set_absolute_time(start, end)
+            ...     mapsA.append(mapA)
+            ...     mapsB.append(mapB)
+            >>> # Build the topology between the two map lists
+            >>> tb = SpatioTemporalTopologyBuilder()
+            >>> tb.build(mapsA, mapsB, None)
+            >>> # Check relations of mapsA
+            >>> for map in mapsA:
+            ...     print(map.get_temporal_extent_as_tuple())
+            ...     m = map.get_temporal_relations()
+            ...     for key in m.keys():
+            ...         if key not in ["NEXT", "PREV"]:
+            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
+            ('OVERLAPS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
+            ('OVERLAPS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            ('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
+            ('FINISHES', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
+            ('OVERLAPS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
+            ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
+            ('FINISHES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('DURING', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0))
+            ('OVERLAPPED', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
+            ('DURING', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            ('FINISHES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
+            ('STARTS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
+            ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
 
-        >>> mapsA = []
-        >>> mapsB = []
-        >>> for i in range(4):
-        ...     idA = "a%i at B"%(i)
-        ...     mapA = tgis.RasterDataset(idA)
-        ...     idB = "b%i at B"%(i)
-        ...     mapB = tgis.RasterDataset(idB)
-        ...     start = datetime.datetime(2000, 1, 1, 0, 0, i)
-        ...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 2)
-        ...     check = mapA.set_absolute_time(start, end)
-        ...     start = datetime.datetime(2000, 1, 1, 0, 0, i + 1)
-        ...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 3)
-        ...     check = mapB.set_absolute_time(start, end)
-        ...     mapsA.append(mapA)
-        ...     mapsB.append(mapB)
-        >>> # Build the topology between the two map lists
-        >>> tb = SpatioTemporalTopologyBuilder()
-        >>> tb.build(mapsA, mapsB, None)
-        >>> # Check relations of mapsA
-        >>> for map in mapsA:
-        ...     print(map.get_temporal_extent_as_tuple())
-        ...     m = map.get_temporal_relations()
-        ...     for key in m.keys():
-        ...         if key not in ["NEXT", "PREV"]:
-        ...             print(key, m[key][0].get_temporal_extent_as_tuple())
-        (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
-        ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
-        ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
-        (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3))
-        ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
-        ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
-        ('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
-        (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4))
-        ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
-        ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
-        ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 4), datetime.datetime(2000, 1, 1, 0, 0, 6)))
-        ('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
-        (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5))
-        ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 4), datetime.datetime(2000, 1, 1, 0, 0, 6)))
-        ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
-        ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
-        ('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
+            >>> mapsA = []
+            >>> mapsB = []
+            >>> for i in range(4):
+            ...     idA = "a%i at B"%(i)
+            ...     mapA = tgis.RasterDataset(idA)
+            ...     idB = "b%i at B"%(i)
+            ...     mapB = tgis.RasterDataset(idB)
+            ...     start = datetime.datetime(2000, 1, 1, 0, 0, i)
+            ...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 2)
+            ...     check = mapA.set_absolute_time(start, end)
+            ...     start = datetime.datetime(2000, 1, 1, 0, 0, i + 1)
+            ...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 3)
+            ...     check = mapB.set_absolute_time(start, end)
+            ...     mapsA.append(mapA)
+            ...     mapsB.append(mapB)
+            >>> # Build the topology between the two map lists
+            >>> tb = SpatioTemporalTopologyBuilder()
+            >>> tb.build(mapsA, mapsB, None)
+            >>> # Check relations of mapsA
+            >>> for map in mapsA:
+            ...     print(map.get_temporal_extent_as_tuple())
+            ...     m = map.get_temporal_relations()
+            ...     for key in m.keys():
+            ...         if key not in ["NEXT", "PREV"]:
+            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
+            ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
+            ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
+            (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3))
+            ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
+            ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
+            ('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
+            (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4))
+            ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
+            ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
+            ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 4), datetime.datetime(2000, 1, 1, 0, 0, 6)))
+            ('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
+            (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5))
+            ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 4), datetime.datetime(2000, 1, 1, 0, 0, 6)))
+            ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
+            ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
+            ('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
 
-        >>> mapsA = []
-        >>> for i in range(4):
-        ...     idA = "a%i at B"%(i)
-        ...     mapA = tgis.RasterDataset(idA)
-        ...     start = datetime.datetime(2000, 1, 1, 0, 0, i)
-        ...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 2)
-        ...     check = mapA.set_absolute_time(start, end)
-        ...     mapsA.append(mapA)
-        >>> tb = SpatioTemporalTopologyBuilder()
-        >>> tb.build(mapsA)
-        >>> # Check relations of mapsA
-        >>> for map in mapsA:
-        ...     print(map.get_temporal_extent_as_tuple())
-        ...     m = map.get_temporal_relations()
-        ...     for key in m.keys():
-        ...         if key not in ["NEXT", "PREV"]:
-        ...             print(key, m[key][0].get_temporal_extent_as_tuple())
-        (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
-        ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
-        ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
-        (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3))
-        ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
-        ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2)))
-        ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
-        (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4))
-        ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
-        ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2)))
-        ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
-        (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5))
-        ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
-        ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
+            >>> mapsA = []
+            >>> for i in range(4):
+            ...     idA = "a%i at B"%(i)
+            ...     mapA = tgis.RasterDataset(idA)
+            ...     start = datetime.datetime(2000, 1, 1, 0, 0, i)
+            ...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 2)
+            ...     check = mapA.set_absolute_time(start, end)
+            ...     mapsA.append(mapA)
+            >>> tb = SpatioTemporalTopologyBuilder()
+            >>> tb.build(mapsA)
+            >>> # Check relations of mapsA
+            >>> for map in mapsA:
+            ...     print(map.get_temporal_extent_as_tuple())
+            ...     m = map.get_temporal_relations()
+            ...     for key in m.keys():
+            ...         if key not in ["NEXT", "PREV"]:
+            ...             print(key, m[key][0].get_temporal_extent_as_tuple())
+            (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
+            ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
+            ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
+            (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3))
+            ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
+            ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2)))
+            ('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
+            (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4))
+            ('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
+            ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2)))
+            ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
+            (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5))
+            ('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
+            ('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
 
-        @endcode
-
     """
     def __init__(self):
         self._reset()
         # 0001-01-01 00:00:00
-        self._timeref = datetime(1,1,1)
+        self._timeref = datetime(1, 1, 1)
 
     def _reset(self):
         self._store = {}
@@ -383,14 +380,14 @@
         self._store[t.get_id()] = t
 
     def get_first(self):
-        """!Return the first map with the earliest start time
+        """Return the first map with the earliest start time
 
-           @return The map with the earliest start time
+           :return: The map with the earliest start time
         """
         return self._first
 
     def _build_internal_iteratable(self, maps, spatial):
-        """!Build an iteratable temporal topology structure for all maps in
+        """Build an iteratable temporal topology structure for all maps in
            the list and store the maps internally
 
            Basically the "next" and "prev" relations will be set in the
@@ -398,7 +395,7 @@
            The maps will be added to the object, so they can be
            accessed using the iterator of this class
 
-           @param maps A sorted (by start_time)list of abstract_dataset
+           :param maps: A sorted (by start_time)list of abstract_dataset
                         objects with initiated temporal extent
         """
         self._build_iteratable(maps, spatial)
@@ -410,13 +407,13 @@
         self._detect_first()
 
     def _build_iteratable(self, maps, spatial):
-        """!Build an iteratable temporal topology structure for
+        """Build an iteratable temporal topology structure for
            all maps in the list
 
            Basically the "next" and "prev" relations will be set in
            the temporal topology structure of each map.
 
-           @param maps A sorted (by start_time)list of abstract_dataset
+           :param maps: A sorted (by start_time)list of abstract_dataset
                         objects with initiated temporal extent
         """
 #        for i in xrange(len(maps)):
@@ -446,12 +443,13 @@
                 map_.set_spatial_topology_build_true()
 
     def _map_to_rect(self, tree, map_, spatial=None):
-        """!Use the spatio-temporal extent of a map to create and
+        """Use the spatio-temporal extent of a map to create and
            return a RTree rectange
 
-           @param spatial This indicates if the spatial topology is created as well:
-                          spatial can be None (no spatial topology), "2D" using west, east,
-                          #south, north or "3D" using west, east, south, north, bottom, top
+           :param spatial: This indicates if the spatial topology is created
+                           as well: spatial can be None (no spatial topology),
+                           "2D" using west, east, south, north or "3D" using
+                           west, east, south, north, bottom, top
         """
         rect = rtree.RTreeAllocRect(tree)
 
@@ -469,21 +467,21 @@
         elif spatial == "2D":
             north, south, east, west, top, bottom = map_.get_spatial_extent_as_tuple()
             rtree.RTreeSetRect3D(rect, tree, west, east, south, north,
-                                  float(start), float(end))
+                                 float(start), float(end))
         elif spatial == "3D":
             north, south, east, west, top, bottom = map_.get_spatial_extent_as_tuple()
             rtree.RTreeSetRect4D(rect, tree, west, east, south, north,
-                                  bottom, top, float(start), float(end))
+                                 bottom, top, float(start), float(end))
 
         return rect
 
     def _build_rtree(self, maps, spatial=None):
-        """!Build and return the 1-4 dimensional R*-Tree
+        """Build and return the 1-4 dimensional R*-Tree
 
-
-           @param spatial This indicates if the spatial topology is created as well:
-                          spatial can be None (no spatial topology), "2D" using west, east,
-                          south, north or "3D" using west, east, south, north, bottom, top
+           :param spatial: This indicates if the spatial topology is created
+                           as well: spatial can be None (no spatial topology),
+                           "2D" using west, east, south, north or "3D" using
+                           west, east, south, north, bottom, top
         """
         dim = 1
         if spatial == "2D":
@@ -501,12 +499,13 @@
         return tree
 
     def build(self, mapsA, mapsB=None, spatial=None):
-        """!Build the spatio-temporal topology structure between
+        """Build the spatio-temporal topology structure between
            one or two unordered lists of abstract dataset objects
 
-           This method builds the temporal or spatio-temporal topology from mapsA to
-           mapsB and vice verse. The spatio-temporal topology structure of each map
-           will be reseted and rebuild for mapsA and mapsB.
+           This method builds the temporal or spatio-temporal topology from
+           mapsA to mapsB and vice verse. The spatio-temporal topology
+           structure of each map will be reseted and rebuild for mapsA and
+           mapsB.
 
            After building the temporal or spatio-temporal topology the modified
            map objects of mapsA can be accessed
@@ -514,20 +513,21 @@
            The implemented iterator assures
            the chronological iteration over the mapsA.
 
-           @param mapsA A list of abstract_dataset
+           :param mapsA: A list of abstract_dataset
                          objects with initiated spatio-temporal extent
-           @param mapsB An optional list of abstract_dataset
+           :param mapsB: An optional list of abstract_dataset
                          objects with initiated spatio-temporal extent
-           @param spatial This indicates if the spatial topology is created as well:
-                          spatial can be None (no spatial topology), "2D" using west, east,
-                          south, north or "3D" using west, east, south, north, bottom, top
+           :param spatial: This indicates if the spatial topology is created
+                           as well: spatial can be None (no spatial topology),
+                           "2D" using west, east, south, north or "3D" using
+                           west, east, south, north, bottom, top
         """
 
         identical = False
         if mapsA == mapsB:
             identical = True
 
-        if mapsB == None:
+        if mapsB is None:
             mapsB = mapsA
             identical = True
 
@@ -563,7 +563,7 @@
                     set_spatial_relationship(A, B, relation)
 
         self._build_internal_iteratable(mapsA, spatial)
-        if not identical and mapsB != None:
+        if not identical and mapsB is not None:
             self._build_iteratable(mapsB, spatial)
 
         gis.G_free_ilist(list_)
@@ -587,6 +587,7 @@
 
 ###############################################################################
 
+
 def set_temoral_relationship(A, B, relation):
     if relation == "equal" or relation == "equals":
         if A != B:
@@ -762,15 +763,16 @@
 
 ###############################################################################
 
+
 def print_temporal_topology_relationships(maps1, maps2=None, dbif=None):
-    """!Print the temporal relationships of the
+    """Print the temporal relationships of the
        map lists maps1 and maps2 to stdout.
 
-        @param maps1 A list of abstract_dataset
+        :param maps1: A list of abstract_dataset
                       objects with initiated temporal extent
-        @param maps2 An optional list of abstract_dataset
+        :param maps2: An optional list of abstract_dataset
                       objects with initiated temporal extent
-        @param dbif The database interface to be used
+        :param dbif: The database interface to be used
     """
 
     tb = SpatioTemporalTopologyBuilder()
@@ -790,18 +792,20 @@
 
 ###############################################################################
 
+
 def print_spatio_temporal_topology_relationships(maps1, maps2=None,
                                                  spatial="2D", dbif=None):
-    """!Print the temporal relationships of the
+    """Print the temporal relationships of the
        map lists maps1 and maps2 to stdout.
 
-        @param maps1 A list of abstract_dataset
+        :param maps1: A list of abstract_dataset
                       objects with initiated temporal extent
-        @param maps2 An optional list of abstract_dataset
+        :param maps2: An optional list of abstract_dataset
                       objects with initiated temporal extent
-        @param spatial The dimension of the spatial extent to be used: "2D" using west, east,
-                        south, north or "3D" using west, east, south, north, bottom, top
-        @param dbif The database interface to be used
+        :param spatial: The dimension of the spatial extent to be used: "2D"
+                        using west, east, south, north or "3D" using west,
+                        east, south, north, bottom, top
+        :param dbif: The database interface to be used
     """
 
     tb = SpatioTemporalTopologyBuilder()
@@ -821,19 +825,20 @@
 
 ###############################################################################
 
+
 def count_temporal_topology_relationships(maps1, maps2=None, dbif=None):
-    """!Count the temporal relations of a single list of maps or between two lists of maps
+    """Count the temporal relations of a single list of maps or between two
+       lists of maps
 
 
-        @param maps1 A list of abstract_dataset
+        :param maps1: A list of abstract_dataset
                       objects with initiated temporal extent
-        @param maps2 A list of abstract_dataset
+        :param maps2: A list of abstract_dataset
                       objects with initiated temporal extent
-        @param dbif The database interface to be used
-        @return A dictionary with counted temporal relationships
+        :param dbif: The database interface to be used
+        :return: A dictionary with counted temporal relationships
     """
 
-
     tb = SpatioTemporalTopologyBuilder()
     tb.build(maps1, maps2)
 
@@ -856,143 +861,149 @@
 
 ###############################################################################
 
-def create_temporal_relation_sql_where_statement(
-                        start, end, use_start=True, use_during=False,
-                        use_overlap=False, use_contain=False, use_equal=False,
-                        use_follows=False, use_precedes=False):
-    """!Create a SQL WHERE statement for temporal relation selection of maps in space time datasets
 
-        @param start The start time
-        @param end The end time
-        @param use_start Select maps of which the start time is located in the selection granule
-                         @verbatim
-                         map    :        s
-                         granule:  s-----------------e
+def create_temporal_relation_sql_where_statement(start, end, use_start=True,
+                                                 use_during=False,
+                                                 use_overlap=False,
+                                                 use_contain=False,
+                                                 use_equal=False,
+                                                 use_follows=False,
+                                                 use_precedes=False):
+    """Create a SQL WHERE statement for temporal relation selection of maps in
+       space time datasets
 
-                         map    :        s--------------------e
-                         granule:  s-----------------e
+        :param start: The start time
+        :param end: The end time
+        :param use_start: Select maps of which the start time is located in
+                          the selection granule ::
 
-                         map    :        s--------e
-                         granule:  s-----------------e
-                         @endverbatim
+                              map    :        s
+                              granule:  s-----------------e
 
-        @param use_during Select maps which are temporal during the selection granule
-                         @verbatim
-                         map    :     s-----------e
-                         granule:  s-----------------e
-                         @endverbatim
+                              map    :        s--------------------e
+                              granule:  s-----------------e
 
-        @param use_overlap Select maps which temporal overlap the selection granule
-                         @verbatim
-                         map    :     s-----------e
-                         granule:        s-----------------e
+                              map    :        s--------e
+                              granule:  s-----------------e
 
-                         map    :     s-----------e
-                         granule:  s----------e
-                         @endverbatim
 
-        @param use_contain Select maps which temporally contain the selection granule
-                         @verbatim
-                         map    :  s-----------------e
-                         granule:     s-----------e
-                         @endverbatim
+        :param use_during: Select maps which are temporal during the selection
+                           granule  ::
 
-        @param use_equal Select maps which temporally equal to the selection granule
-                         @verbatim
-                         map    :  s-----------e
-                         granule:  s-----------e
-                         @endverbatim
+                               map    :     s-----------e
+                               granule:  s-----------------e
 
-        @param use_follows Select maps which temporally follow the selection granule
-                         @verbatim
-                         map    :              s-----------e
-                         granule:  s-----------e
-                         @endverbatim
+        :param use_overlap: Select maps which temporal overlap the selection
+                            granule ::
 
-        @param use_precedes Select maps which temporally precedes the selection granule
-                         @verbatim
-                         map    :  s-----------e
-                         granule:              s-----------e
-                         @endverbatim
+                                map    :     s-----------e
+                                granule:        s-----------------e
 
+                                map    :     s-----------e
+                                granule:  s----------e
+
+        :param use_contain: Select maps which temporally contain the selection
+                            granule ::
+
+                                map    :  s-----------------e
+                                granule:     s-----------e
+
+        :param use_equal: Select maps which temporally equal to the selection
+                          granule ::
+
+                              map    :  s-----------e
+                              granule:  s-----------e
+
+        :param use_follows: Select maps which temporally follow the selection
+                            granule ::
+
+                                map    :              s-----------e
+                                granule:  s-----------e
+
+        :param use_precedes: Select maps which temporally precedes the
+                             selection granule ::
+
+                                 map    :  s-----------e
+                                 granule:              s-----------e
+
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> # Relative time
-        >>> start = 1
-        >>> end = 2
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False)
-        >>> create_temporal_relation_sql_where_statement(start, end)
-        '((start_time >= 1 and start_time < 2) )'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=True)
-        '((start_time >= 1 and start_time < 2) )'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_during=True)
-        '(((start_time > 1 and end_time < 2) OR (start_time >= 1 and end_time < 2) OR (start_time > 1 and end_time <= 2)))'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_overlap=True)
-        '(((start_time < 1 and end_time > 1 and end_time < 2) OR (start_time < 2 and start_time > 1 and end_time > 2)))'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_contain=True)
-        '(((start_time < 1 and end_time > 2) OR (start_time <= 1 and end_time > 2) OR (start_time < 1 and end_time >= 2)))'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_equal=True)
-        '((start_time = 1 and end_time = 2))'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_follows=True)
-        '((start_time = 2))'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_precedes=True)
-        '((end_time = 1))'
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=True, use_during=True, use_overlap=True, use_contain=True,
-        ... use_equal=True, use_follows=True, use_precedes=True)
-        '((start_time >= 1 and start_time < 2)  OR ((start_time > 1 and end_time < 2) OR (start_time >= 1 and end_time < 2) OR (start_time > 1 and end_time <= 2)) OR ((start_time < 1 and end_time > 1 and end_time < 2) OR (start_time < 2 and start_time > 1 and end_time > 2)) OR ((start_time < 1 and end_time > 2) OR (start_time <= 1 and end_time > 2) OR (start_time < 1 and end_time >= 2)) OR (start_time = 1 and end_time = 2) OR (start_time = 2) OR (end_time = 1))'
+            >>> # Relative time
+            >>> start = 1
+            >>> end = 2
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False)
+            >>> create_temporal_relation_sql_where_statement(start, end)
+            '((start_time >= 1 and start_time < 2) )'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=True)
+            '((start_time >= 1 and start_time < 2) )'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_during=True)
+            '(((start_time > 1 and end_time < 2) OR (start_time >= 1 and end_time < 2) OR (start_time > 1 and end_time <= 2)))'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_overlap=True)
+            '(((start_time < 1 and end_time > 1 and end_time < 2) OR (start_time < 2 and start_time > 1 and end_time > 2)))'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_contain=True)
+            '(((start_time < 1 and end_time > 2) OR (start_time <= 1 and end_time > 2) OR (start_time < 1 and end_time >= 2)))'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_equal=True)
+            '((start_time = 1 and end_time = 2))'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_follows=True)
+            '((start_time = 2))'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_precedes=True)
+            '((end_time = 1))'
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=True, use_during=True, use_overlap=True, use_contain=True,
+            ... use_equal=True, use_follows=True, use_precedes=True)
+            '((start_time >= 1 and start_time < 2)  OR ((start_time > 1 and end_time < 2) OR (start_time >= 1 and end_time < 2) OR (start_time > 1 and end_time <= 2)) OR ((start_time < 1 and end_time > 1 and end_time < 2) OR (start_time < 2 and start_time > 1 and end_time > 2)) OR ((start_time < 1 and end_time > 2) OR (start_time <= 1 and end_time > 2) OR (start_time < 1 and end_time >= 2)) OR (start_time = 1 and end_time = 2) OR (start_time = 2) OR (end_time = 1))'
 
-        >>> # Absolute time
-        >>> start = datetime(2001, 1, 1, 12, 30)
-        >>> end = datetime(2001, 3, 31, 14, 30)
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False)
-        >>> create_temporal_relation_sql_where_statement(start, end)
-        "((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00') )"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=True)
-        "((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00') )"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_during=True)
-        "(((start_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time >= '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time > '2001-01-01 12:30:00' and end_time <= '2001-03-31 14:30:00')))"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_overlap=True)
-        "(((start_time < '2001-01-01 12:30:00' and end_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time < '2001-03-31 14:30:00' and start_time > '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00')))"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_contain=True)
-        "(((start_time < '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time <= '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time < '2001-01-01 12:30:00' and end_time >= '2001-03-31 14:30:00')))"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_equal=True)
-        "((start_time = '2001-01-01 12:30:00' and end_time = '2001-03-31 14:30:00'))"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_follows=True)
-        "((start_time = '2001-03-31 14:30:00'))"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=False, use_precedes=True)
-        "((end_time = '2001-01-01 12:30:00'))"
-        >>> create_temporal_relation_sql_where_statement(start, end,
-        ... use_start=True, use_during=True, use_overlap=True, use_contain=True,
-        ... use_equal=True, use_follows=True, use_precedes=True)
-        "((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00')  OR ((start_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time >= '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time > '2001-01-01 12:30:00' and end_time <= '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time < '2001-03-31 14:30:00' and start_time > '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time <= '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time < '2001-01-01 12:30:00' and end_time >= '2001-03-31 14:30:00')) OR (start_time = '2001-01-01 12:30:00' and end_time = '2001-03-31 14:30:00') OR (start_time = '2001-03-31 14:30:00') OR (end_time = '2001-01-01 12:30:00'))"
+            >>> # Absolute time
+            >>> start = datetime(2001, 1, 1, 12, 30)
+            >>> end = datetime(2001, 3, 31, 14, 30)
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False)
+            >>> create_temporal_relation_sql_where_statement(start, end)
+            "((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00') )"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=True)
+            "((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00') )"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_during=True)
+            "(((start_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time >= '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time > '2001-01-01 12:30:00' and end_time <= '2001-03-31 14:30:00')))"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_overlap=True)
+            "(((start_time < '2001-01-01 12:30:00' and end_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time < '2001-03-31 14:30:00' and start_time > '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00')))"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_contain=True)
+            "(((start_time < '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time <= '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time < '2001-01-01 12:30:00' and end_time >= '2001-03-31 14:30:00')))"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_equal=True)
+            "((start_time = '2001-01-01 12:30:00' and end_time = '2001-03-31 14:30:00'))"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_follows=True)
+            "((start_time = '2001-03-31 14:30:00'))"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=False, use_precedes=True)
+            "((end_time = '2001-01-01 12:30:00'))"
+            >>> create_temporal_relation_sql_where_statement(start, end,
+            ... use_start=True, use_during=True, use_overlap=True, use_contain=True,
+            ... use_equal=True, use_follows=True, use_precedes=True)
+            "((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00')  OR ((start_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time >= '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time > '2001-01-01 12:30:00' and end_time <= '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time < '2001-03-31 14:30:00' and start_time > '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time <= '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time < '2001-01-01 12:30:00' and end_time >= '2001-03-31 14:30:00')) OR (start_time = '2001-01-01 12:30:00' and end_time = '2001-03-31 14:30:00') OR (start_time = '2001-03-31 14:30:00') OR (end_time = '2001-01-01 12:30:00'))"
 
-        @endcode
         """
 
     where = "("
 
     if use_start:
         if isinstance(start, datetime):
-            where += "(start_time >= '%s' and start_time < '%s') " % (start, end)
+            where += "(start_time >= '%s' and start_time < '%s') " % (start,
+                                                                      end)
         else:
             where += "(start_time >= %i and start_time < %i) " % (start, end)
 
@@ -1001,8 +1012,10 @@
             where += " OR "
 
         if isinstance(start, datetime):
-            where += "((start_time > '%s' and end_time < '%s') OR " % (start, end)
-            where += "(start_time >= '%s' and end_time < '%s') OR " % (start, end)
+            where += "((start_time > '%s' and end_time < '%s') OR " % (start,
+                                                                       end)
+            where += "(start_time >= '%s' and end_time < '%s') OR " % (start,
+                                                                       end)
             where += "(start_time > '%s' and end_time <= '%s'))" % (start, end)
         else:
             where += "((start_time > %i and end_time < %i) OR " % (start, end)
@@ -1014,19 +1027,25 @@
             where += " OR "
 
         if isinstance(start, datetime):
-            where += "((start_time < '%s' and end_time > '%s' and end_time < '%s') OR " % (start, start, end)
-            where += "(start_time < '%s' and start_time > '%s' and end_time > '%s'))" % (end, start, end)
+            where += "((start_time < '%s' and end_time > '%s' and end_time <" \
+                     " '%s') OR " % (start, start, end)
+            where += "(start_time < '%s' and start_time > '%s' and end_time " \
+                     "> '%s'))" % (end, start, end)
         else:
-            where += "((start_time < %i and end_time > %i and end_time < %i) OR " % (start, start, end)
-            where += "(start_time < %i and start_time > %i and end_time > %i))" % (end, start, end)
+            where += "((start_time < %i and end_time > %i and end_time < %i)" \
+                     " OR " % (start, start, end)
+            where += "(start_time < %i and start_time > %i and end_time > " \
+                     "%i))" % (end, start, end)
 
     if use_contain:
         if use_start or use_during or use_overlap:
             where += " OR "
 
         if isinstance(start, datetime):
-            where += "((start_time < '%s' and end_time > '%s') OR " % (start, end)
-            where += "(start_time <= '%s' and end_time > '%s') OR " % (start, end)
+            where += "((start_time < '%s' and end_time > '%s') OR " % (start,
+                                                                       end)
+            where += "(start_time <= '%s' and end_time > '%s') OR " % (start,
+                                                                       end)
             where += "(start_time < '%s' and end_time >= '%s'))" % (start, end)
         else:
             where += "((start_time < %i and end_time > %i) OR " % (start, end)

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/stds_export.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/stds_export.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/stds_export.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,31 +1,28 @@
-"""!@package grass.temporal
+"""
+Export functions for space time datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
+Usage:
 
-Temporal GIS export functions to be used in temporal modules
+.. code-block:: python
 
-Usage:
+    import grass.temporal as tgis
 
- at code
-import grass.temporal as tgis
+    input="temp_1950_2012 at PERMANENT"
+    output="/tmp/temp_1950_2012.tar.gz"
+    compression="gzip"
+    workdir="/tmp"
+    where=None
+    format_="GTiff"
+    type_="strds"
+    tgis.export_stds(input, output, compression, workdir, where, format_, type_)
 
-input="temp_1950_2012 at PERMANENT"
-output="/tmp/temp_1950_2012.tar.gz"
-compression="gzip"
-workdir="/tmp"
-where=None
-format_="GTiff"
-type_="strds"
-tgis.export_stds(input, output, compression, workdir, where, format_, type_)
-...
- at endcode
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 import shutil
@@ -36,6 +33,7 @@
 from space_time_datasets import *
 from factory import *
 from open_stds import *
+import grass.script as gscript
 from grass.exceptions import CalledModuleError
 
 
@@ -98,7 +96,7 @@
         except CalledModuleError:
             shutil.rmtree(new_cwd)
             tar.close()
-            core.fatal(_("Unable to export raster map <%s>" % name))
+            gscript.fatal(_("Unable to export raster map <%s>" % name))
 
         tar.add(out_name)
 
@@ -109,13 +107,14 @@
         except CalledModuleError:
             shutil.rmtree(new_cwd)
             tar.close()
-            core.fatal(_("Unable to export color rules for raster "
-                         "map <%s> r.out.gdal" % name))
+            gscript.fatal(_("Unable to export color rules for raster "
+                            "map <%s> r.out.gdal" % name))
 
         tar.add(out_name)
 
 ############################################################################
 
+
 def _export_raster_maps(rows, tar, list_file, new_cwd, fs):
     for row in rows:
         name = row["name"]
@@ -132,13 +131,14 @@
         except CalledModuleError:
             shutil.rmtree(new_cwd)
             tar.close()
-            core.fatal(_("Unable to export raster map <%s> with r.pack" %
-                         name))
+            gscript.fatal(_("Unable to export raster map <%s> with r.pack" %
+                          name))
 
         tar.add(name + ".pack")
 
 ############################################################################
 
+
 def _export_vector_maps_as_gml(rows, tar, list_file, new_cwd, fs):
     for row in rows:
         name = row["name"]
@@ -159,14 +159,15 @@
         except CalledModuleError:
             shutil.rmtree(new_cwd)
             tar.close()
-            core.fatal(_("Unable to export vector map <%s> as "
-                         "GML with v.out.ogr" % name))
+            gscript.fatal(_("Unable to export vector map <%s> as "
+                            "GML with v.out.ogr" % name))
 
         tar.add(name + ".xml")
         tar.add(name + ".xsd")
 
 ############################################################################
 
+
 def _export_vector_maps(rows, tar, list_file, new_cwd, fs):
     for row in rows:
         name = row["name"]
@@ -191,8 +192,8 @@
         except CalledModuleError:
             shutil.rmtree(new_cwd)
             tar.close()
-            core.fatal(_("Unable to export vector map <%s> with v.pack" %
-                         name))
+            gscript.fatal(_("Unable to export vector map <%s> with v.pack" %
+                          name))
 
         tar.add(name + ".pack")
 
@@ -217,8 +218,8 @@
         except CalledModuleError:
             shutil.rmtree(new_cwd)
             tar.close()
-            core.fatal(_("Unable to export raster map <%s> with r3.pack" %
-                         name))
+            gscript.fatal(_("Unable to export raster map <%s> with r3.pack" %
+                          name))
 
         tar.add(name + ".pack")
 
@@ -227,36 +228,39 @@
 
 def export_stds(input, output, compression, workdir, where, format_="pack",
                 type_="strds"):
-    """
-            !Export space time datasets as tar archive with optional compression
+    """Export space time datasets as tar archive with optional compression
 
-            This method should be used to export space time datasets
-            of type raster and vector as tar archive that can be reimported
-            with the method import_stds().
+        This method should be used to export space time datasets
+        of type raster and vector as tar archive that can be reimported
+        with the method import_stds().
 
-            @param input The name of the space time dataset to export
-            @param output The name of the archive file
-            @param compression The compression of the archive file:
+        :param input: The name of the space time dataset to export
+        :param output: The name of the archive file
+        :param compression: The compression of the archive file:
+
               - "no"  no compression
               - "gzip" GNU zip compression
               - "bzip2" Bzip compression
-            @param workdir The working directory used for extraction and packing
-            @param where The temporal WHERE SQL statement to select a subset
-                          of maps from the space time dataset
-            @param format_ The export format:
+
+        :param workdir: The working directory used for extraction and packing
+        :param where: The temporal WHERE SQL statement to select a subset
+                      of maps from the space time dataset
+        :param format_: The export format:
+
               - "GTiff" Geotiff format, only for raster maps
               - "AAIGrid" Arc/Info ASCII Grid format, only for raster maps
               - "pack" The GRASS raster, 3D raster or vector Pack format,
                        this is the default setting
               - "GML" GML file export format, only for vector maps,
                       v.out.ogr export option
-            @param type_ The space time dataset type
+
+        :param type_: The space time dataset type
+
               - "strds" Space time raster dataset
               - "str3ds" Space time 3D raster dataset
               - "stvds" Space time vector dataset
     """
 
-
     # Save current working directory path
     old_cwd = os.getcwd()
 
@@ -271,7 +275,7 @@
     else:
         columns = "name,start_time,end_time"
 
-    sp = open_old_space_time_dataset(input, type_)
+    sp = open_old_stds(input, type_)
     rows = sp.get_registered_maps(columns, where, "start_time", None)
 
     if compression == "gzip":
@@ -305,7 +309,7 @@
     list_file.close()
 
     # Write projection and metadata
-    proj = core.read_command("g.proj", flags="j")
+    proj = gscript.read_command("g.proj", flags="j")
 
     proj_file = open(proj_file_name, "w")
     proj_file.write(proj)
@@ -314,11 +318,11 @@
     init_file = open(init_file_name, "w")
     # Create the init string
     string = ""
-     # This is optional, if not present strds will be assumed for backward
-     # compatibility
+    # This is optional, if not present strds will be assumed for backward
+    # compatibility
     string += "%s=%s\n" % ("stds_type", sp.get_type())
-     # This is optional, if not present gtiff will be assumed for
-     # backward compatibility
+    # This is optional, if not present gtiff will be assumed for
+    # backward compatibility
     string += "%s=%s\n" % ("format", format_)
     string += "%s=%s\n" % ("temporal_type", sp.get_temporal_type())
     string += "%s=%s\n" % ("semantic_type", sp.get_semantic_type())
@@ -334,7 +338,7 @@
     init_file.write(string)
     init_file.close()
 
-    metadata = core.read_command("t.info", type=type_, input=sp.get_id())
+    metadata = gscript.read_command("t.info", type=type_, input=sp.get_id())
     metadata_file = open(metadata_file_name, "w")
     metadata_file.write(metadata)
     metadata_file.close()
@@ -353,13 +357,13 @@
     read_file.write("Files:\n")
     if type_ == "strds":
         if format_ == "GTiff":
-                                #123456789012345678901234567890
+                                # 123456789012345678901234567890
             read_file.write("       *.tif  -- GeoTIFF raster files\n")
             read_file.write("     *.color  -- GRASS GIS raster color rules\n")
         elif format_ == "pack":
             read_file.write("      *.pack  -- GRASS raster files packed with r.pack\n")
     elif type_ == "stvds":
-                                #123456789012345678901234567890
+                                # 123456789012345678901234567890
         if format_ == "GML":
             read_file.write("       *.xml  -- Vector GML files\n")
         else:

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/stds_import.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/stds_import.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/stds_import.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,35 +1,32 @@
-"""!@package grass.temporal
+"""
+Space time dataset import functions
 
- at brief GRASS Python scripting module (temporal GIS functions)
+Usage:
 
-Temporal GIS export functions to be used in temporal modules
+.. code-block:: python
 
-Usage:
+    import grass.temporal as tgis
 
- at code
-import grass.temporal as tgis
+    input="/tmp/temp_1950_2012.tar.gz"
+    output="temp_1950_2012"
+    extrdir="/tmp"
+    title="My new dataset"
+    descr="May new shiny dataset"
+    location=None
+    link=True
+    exp=True
+    overr=False
+    create=False
+    tgis.import_stds(input, output, extrdir, title, descr, location,
+                    link, exp, overr, create, "strds")
 
-input="/tmp/temp_1950_2012.tar.gz"
-output="temp_1950_2012"
-extrdir="/tmp"
-title="My new dataset"
-descr="May new shiny dataset"
-location=None
-link=True
-exp=True
-overr=False
-create=False
-tgis.import_stds(input, output, extrdir, title, descr, location,
-                link, exp, overr, create, "strds")
-...
- at endcode
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 import os
@@ -55,7 +52,7 @@
 ############################################################################
 
 
-def _import_raster_maps_from_gdal(maplist, overr, exp, location, link, format_, 
+def _import_raster_maps_from_gdal(maplist, overr, exp, location, link, format_,
                                   set_current_region=False):
     impflags = ""
     if overr:
@@ -66,7 +63,7 @@
         name = row["name"]
         if format_ == "GTiff":
             filename = row["filename"] + ".tif"
-        elif format_=="AAIGrid":
+        elif format_ == "AAIGrid":
             filename = row["filename"] + ".asc"
             if not overr:
                 impflags += "o"
@@ -84,8 +81,8 @@
                                     overwrite=gscript.overwrite())
 
         except CalledModuleError:
-            gscript.fatal(_("Unable to import/link raster map <%s> from file %s.") %(name, 
-                                                                     filename))
+            gscript.fatal(_("Unable to import/link raster map <%s> from file"
+                            " %s.") % (name, filename))
 
         # Set the color rules if present
         filename = row["filename"] + ".color"
@@ -96,7 +93,7 @@
                                     overwrite=gscript.overwrite())
             except CalledModuleError:
                 gscript.fatal(_("Unable to set the color rules for "
-                             "raster map <%s>.") % name)
+                                "raster map <%s>.") % name)
 
     # Set the computational region from the last map imported
     if set_current_region is True:
@@ -119,8 +116,8 @@
                                 verbose=True)
 
         except CalledModuleError:
-            gscript.fatal(_("Unable to unpack raster map <%s> from file %s.") % (name, 
-                                                                              filename))
+            gscript.fatal(_("Unable to unpack raster map <%s> from file "
+                            "%s.") % (name, filename))
 
     # Set the computational region from the last map imported
     if set_current_region is True:
@@ -143,8 +140,8 @@
                                 overwrite=gscript.overwrite())
 
         except CalledModuleError:
-            gscript.fatal(_("Unable to import vector map <%s> from file %s.") % (name,
-                                                                              filename))
+            gscript.fatal(_("Unable to import vector map <%s> from file "
+                            "%s.") % (name, filename))
 
 ############################################################################
 
@@ -167,36 +164,36 @@
                                 verbose=True)
 
         except CalledModuleError:
-            gscript.fatal(_("Unable to unpack vector map <%s> from file %s.") % (name, 
-                                                                              filename))
+            gscript.fatal(_("Unable to unpack vector map <%s> from file "
+                            "%s.") % (name, filename))
 
         imported_maps[name] = name
 ############################################################################
 
 
 def import_stds(input, output, extrdir, title=None, descr=None, location=None,
-        link=False, exp=False, overr=False, create=False, stds_type="strds", 
-        base=None, set_current_region=False):
-    """!Import space time datasets of type raster and vector
+                link=False, exp=False, overr=False, create=False,
+                stds_type="strds", base=None, set_current_region=False):
+    """Import space time datasets of type raster and vector
 
-        @param input Name of the input archive file
-        @param output The name of the output space time dataset
-        @param extrdir The extraction directory
-        @param title The title of the new created space time dataset
-        @param descr The description of the new created
+        :param input: Name of the input archive file
+        :param output: The name of the output space time dataset
+        :param extrdir: The extraction directory
+        :param title: The title of the new created space time dataset
+        :param descr: The description of the new created
                      space time dataset
-        @param location The name of the location that should be created,
+        :param location: The name of the location that should be created,
                         maps are imported into this location
-        @param link Switch to link raster maps instead importing them
-        @param exp Extend location extents based on new dataset
-        @param overr Override projection (use location's projection)
-        @param create Create the location specified by the "location"
+        :param link: Switch to link raster maps instead importing them
+        :param exp: Extend location extents based on new dataset
+        :param overr: Override projection (use location's projection)
+        :param create: Create the location specified by the "location"
                       parameter and exit.
                       Do not import the space time datasets.
-        @param stds_type The type of the space time dataset that
+        :param stds_type: The type of the space time dataset that
                          should be imported
-        @param base The base name of the new imported maps, it will be extended
-                    using a numerical index.
+        :param base: The base name of the new imported maps, it will be
+                     extended using a numerical index.
     """
 
     global raise_on_error
@@ -206,7 +203,7 @@
     # Check if input file and extraction directory exits
     if not os.path.exists(input):
         gscript.fatal(_("Space time raster dataset archive <%s> not found")
-                   % input)
+                      % input)
     if not create and not os.path.exists(extrdir):
         gscript.fatal(_("Extraction directory <%s> not found") % extrdir)
 
@@ -243,15 +240,18 @@
         p.communicate()
         temp_file.close()
 
-        if not gscript.compare_key_value_text_files(temp_name, proj_name, sep="="):
+        if not gscript.compare_key_value_text_files(temp_name, proj_name,
+                                                    sep="="):
             if overr:
                 gscript.warning(_("Projection information does not match. "
-                               "Proceeding..."))
+                                  "Proceeding..."))
             else:
                 diff = ''.join(gscript.diff_files(temp_name, proj_name))
-                gscript.warning(_("Difference between PROJ_INFO file of imported map "
-                               "and of current location:\n{diff}").format(diff=diff))
-                gscript.fatal(_("Projection information does not match. Aborting."))
+                gscript.warning(_("Difference between PROJ_INFO file of "
+                                  "imported map and of current location:"
+                                  "\n{diff}").format(diff=diff))
+                gscript.fatal(_("Projection information does not match. "
+                                "Aborting."))
 
     # Create a new location based on the projection information and switch
     # into it
@@ -260,15 +260,15 @@
         try:
             proj4_string = open(proj_file_name, 'r').read()
             gscript.create_location(dbase=old_env["GISDBASE"],
-                                 location=location,
-                                 proj4=proj4_string)
+                                    location=location,
+                                    proj4=proj4_string)
             # Just create a new location and return
             if create:
                 os.chdir(old_cwd)
                 return
         except Exception as e:
             gscript.fatal(_("Unable to create location %(l)s. Reason: %(e)s")
-                         % {'l': location, 'e': str(e)})
+                          % {'l': location, 'e': str(e)})
         # Switch to the new created location
         try:
             gscript.run_command("g.mapset", mapset="PERMANENT",
@@ -281,7 +281,7 @@
             gscript.run_command("t.connect", flags="d")
         except CalledModuleError:
             gscript.fatal(_("Unable to create default temporal database "
-                         "in new location %s") % location)
+                            "in new location %s") % location)
 
     try:
         # Make sure the temporal database exists
@@ -313,8 +313,9 @@
             # that must be extended by the file suffix
             filename = line_list[0].strip().split(":")[0]
             if base:
-                mapname = "%s_%s" % (base, gscript.get_num_suffix(line_count + 1, max_count))
-                mapid= "%s@%s"%(mapname, mapset)
+                mapname = "%s_%s" % (base, gscript.get_num_suffix(line_count + 1,
+                                                                  max_count))
+                mapid = "%s@%s" % (mapname, mapset)
             else:
                 mapname = filename
                 mapid = mapname + "@" + mapset
@@ -325,16 +326,16 @@
             row["id"] = mapid
             row["start"] = line_list[1].strip()
             row["end"] = line_list[2].strip()
-            
-            new_list_file.write("%s%s%s%s%s\n"%(mapname,fs, row["start"], 
-                                              fs, row["end"]))
 
+            new_list_file.write("%s%s%s%s%s\n" % (mapname, fs, row["start"],
+                                                  fs, row["end"]))
+
             maplist.append(row)
             line_count += 1
 
         list_file.close()
         new_list_file.close()
-        
+
         # Read the init file
         fs = "="
         init = {}
@@ -353,9 +354,9 @@
            "semantic_type" not in init or \
            "number_of_maps" not in init:
             gscript.fatal(_("Key words %(t)s, %(s)s or %(n)s not found in init"
-                         " file.") % {'t': "temporal_type",
-                                      's': "semantic_type",
-                                      'n': "number_of_maps"})
+                            " file.") % {'t': "temporal_type",
+                                         's': "semantic_type",
+                                         'n': "number_of_maps"})
 
         if line_count != int(init["number_of_maps"]):
             gscript.fatal(_("Number of maps mismatch in init and list file."))
@@ -369,7 +370,8 @@
             format_ = init["format"]
 
         if stds_type != type_:
-            gscript.fatal(_("The archive file is of wrong space time dataset type"))
+            gscript.fatal(_("The archive file is of wrong space time dataset"
+                            " type"))
 
         # Check the existence of the files
         if format_ == "GTiff":
@@ -377,19 +379,19 @@
                 filename = row["filename"] + ".tif"
                 if not os.path.exists(filename):
                     gscript.fatal(_("Unable to find GeoTIFF raster file "
-                                 "<%s> in archive.") % filename)
+                                    "<%s> in archive.") % filename)
         elif format_ == "AAIGrid":
             for row in maplist:
                 filename = row["filename"] + ".asc"
                 if not os.path.exists(filename):
                     gscript.fatal(_("Unable to find AAIGrid raster file "
-                                 "<%s> in archive.") % filename)
+                                    "<%s> in archive.") % filename)
         elif format_ == "GML":
             for row in maplist:
                 filename = row["filename"] + ".xml"
                 if not os.path.exists(filename):
                     gscript.fatal(_("Unable to find GML vector file "
-                                 "<%s> in archive.") % filename)
+                                    "<%s> in archive.") % filename)
         elif format_ == "pack":
             for row in maplist:
                 if type_ == "stvds":
@@ -398,22 +400,22 @@
                     filename = row["filename"] + ".pack"
                 if not os.path.exists(filename):
                     gscript.fatal(_("Unable to find GRASS package file "
-                                 "<%s> in archive.") % filename)
+                                    "<%s> in archive.") % filename)
         else:
             gscript.fatal(_("Unsupported input format"))
 
         # Check the space time dataset
         id = output + "@" + mapset
         sp = dataset_factory(type_, id)
-        if sp.is_in_db() and gscript.overwrite() == False:
-            gscript.fatal(_("Space time %(t)s dataset <%(sp)s> is already in the "
-                         "database. Use the overwrite flag.") % {'t': type_,
-                                                                 'sp': sp.get_id()})
+        if sp.is_in_db() and gscript.overwrite() is False:
+            gscript.fatal(_("Space time %(t)s dataset <%(sp)s> is already in"
+                            " the database. Use the overwrite flag.") %
+                          {'t': type_, 'sp': sp.get_id()})
 
         # Import the maps
         if type_ == "strds":
             if format_ == "GTiff" or format_ == "AAIGrid":
-                _import_raster_maps_from_gdal(maplist, overr, exp, location, 
+                _import_raster_maps_from_gdal(maplist, overr, exp, location,
                                               link, format_, set_current_region)
             if format_ == "pack":
                 _import_raster_maps(maplist, set_current_region)
@@ -425,11 +427,11 @@
                 _import_vector_maps(maplist)
 
         # Create the space time dataset
-        if sp.is_in_db() and gscript.overwrite() == True:
+        if sp.is_in_db() and gscript.overwrite() is True:
             gscript.info(_("Overwrite space time %(sp)s dataset "
-                        "<%(id)s> and unregister all maps.") % {
-                        'sp': sp.get_new_map_instance(None).get_type(),
-                        'id': sp.get_id()})
+                           "<%(id)s> and unregister all maps.") %
+                         {'sp': sp.get_new_map_instance(None).get_type(),
+                          'id': sp.get_id()})
             sp.delete()
             sp = sp.get_new_instance(id)
 
@@ -438,12 +440,13 @@
         relative_time_unit = None
         if temporal_type == "relative":
             if "relative_time_unit" not in init:
-                gscript.fatal(_("Key word %s not found in init file.") % ("relative_time_unit"))
+                gscript.fatal(_("Key word %s not found in init file.") %
+                              ("relative_time_unit"))
             relative_time_unit = init["relative_time_unit"]
             sp.set_relative_time_unit(relative_time_unit)
 
         gscript.verbose(_("Create space time %s dataset.") %
-                     sp.get_new_map_instance(None).get_type())
+                        sp.get_new_map_instance(None).get_type())
 
         sp.set_initial_values(temporal_type=temporal_type,
                               semantic_type=semantic_type, title=title,

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_algebra.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,4 +1,4 @@
-"""!@package grass.temporal
+"""@package grass.temporal
 
 Temporal algebra parser class
 
@@ -7,9 +7,9 @@
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at authors Thomas Leppelt and Soeren Gebbert
+:authors: Thomas Leppelt and Soeren Gebbert
 
- at code
+.. code-block:: python
 
     >>> import grass.temporal as tgis
     >>> tgis.init(True)
@@ -32,21 +32,21 @@
     LexToken(NAME,'test1',1,4)
     LexToken(T_NOT_SELECT,'!:',1,10)
     LexToken(NAME,'test2',1,13)
-    >>> expression =  "C = test1 {equal,:} test2"
+    >>> expression =  "C = test1 {:,equal} test2"
     >>> p.test(expression)
-    C = test1 {equal,:} test2
+    C = test1 {:,equal} test2
     LexToken(NAME,'C',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(NAME,'test1',1,4)
-    LexToken(T_SELECT_OPERATOR,'{equal,:}',1,10)
+    LexToken(T_SELECT_OPERATOR,'{:,equal}',1,10)
     LexToken(NAME,'test2',1,20)
-    >>> expression =  "C = test1 {equal,!:} test2"
+    >>> expression =  "C = test1 {!:,equal} test2"
     >>> p.test(expression)
-    C = test1 {equal,!:} test2
+    C = test1 {!:,equal} test2
     LexToken(NAME,'C',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(NAME,'test1',1,4)
-    LexToken(T_SELECT_OPERATOR,'{equal,!:}',1,10)
+    LexToken(T_SELECT_OPERATOR,'{!:,equal}',1,10)
     LexToken(NAME,'test2',1,21)
     >>> expression =  "C = test1 # test2"
     >>> p.test(expression)
@@ -64,21 +64,21 @@
     LexToken(NAME,'test1',1,4)
     LexToken(T_HASH_OPERATOR,'{#}',1,10)
     LexToken(NAME,'test2',1,14)
-    >>> expression =  "C = test1 {equal,#} test2"
+    >>> expression =  "C = test1 {#,equal} test2"
     >>> p.test(expression)
-    C = test1 {equal,#} test2
+    C = test1 {#,equal} test2
     LexToken(NAME,'C',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(NAME,'test1',1,4)
-    LexToken(T_HASH_OPERATOR,'{equal,#}',1,10)
+    LexToken(T_HASH_OPERATOR,'{#,equal}',1,10)
     LexToken(NAME,'test2',1,20)
-    >>> expression =  "C = test1 {equal|during,#} test2"
+    >>> expression =  "C = test1 {#,equal|during} test2"
     >>> p.test(expression)
-    C = test1 {equal|during,#} test2
+    C = test1 {#,equal|during} test2
     LexToken(NAME,'C',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(NAME,'test1',1,4)
-    LexToken(T_HASH_OPERATOR,'{equal|during,#}',1,10)
+    LexToken(T_HASH_OPERATOR,'{#,equal|during}',1,10)
     LexToken(NAME,'test2',1,27)
     >>> expression =  "E = test1 : test2 !: test1"
     >>> p.test(expression)
@@ -113,15 +113,15 @@
     LexToken(LPAREN,'(',1,9)
     LexToken(NAME,'test1',1,10)
     LexToken(RPAREN,')',1,15)
-    >>> expression =  'H = tsnap(test2 {during,:} buff_t(test1, "1 days"))'
+    >>> expression =  'H = tsnap(test2 {:,during} buff_t(test1, "1 days"))'
     >>> p.test(expression)
-    H = tsnap(test2 {during,:} buff_t(test1, "1 days"))
+    H = tsnap(test2 {:,during} buff_t(test1, "1 days"))
     LexToken(NAME,'H',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(TSNAP,'tsnap',1,4)
     LexToken(LPAREN,'(',1,9)
     LexToken(NAME,'test2',1,10)
-    LexToken(T_SELECT_OPERATOR,'{during,:}',1,16)
+    LexToken(T_SELECT_OPERATOR,'{:,during}',1,16)
     LexToken(BUFF_T,'buff_t',1,27)
     LexToken(LPAREN,'(',1,33)
     LexToken(NAME,'test1',1,34)
@@ -132,15 +132,15 @@
     LexToken(QUOTE,'"',1,48)
     LexToken(RPAREN,')',1,49)
     LexToken(RPAREN,')',1,50)
-    >>> expression =  'H = tshift(test2 {during,:} buff_t(test1, "1 days"), "1 months")'
+    >>> expression =  'H = tshift(test2 {:,during} buff_t(test1, "1 days"), "1 months")'
     >>> p.test(expression)
-    H = tshift(test2 {during,:} buff_t(test1, "1 days"), "1 months")
+    H = tshift(test2 {:,during} buff_t(test1, "1 days"), "1 months")
     LexToken(NAME,'H',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(TSHIFT,'tshift',1,4)
     LexToken(LPAREN,'(',1,10)
     LexToken(NAME,'test2',1,11)
-    LexToken(T_SELECT_OPERATOR,'{during,:}',1,17)
+    LexToken(T_SELECT_OPERATOR,'{:,during}',1,17)
     LexToken(BUFF_T,'buff_t',1,28)
     LexToken(LPAREN,'(',1,34)
     LexToken(NAME,'test1',1,35)
@@ -201,9 +201,9 @@
     LexToken(COMMA,',',1,20)
     LexToken(NAME,'B',1,22)
     LexToken(RPAREN,')',1,23)
-    >>> expression =  'I = if(equals,td(A) > 10 {equals,||} td(B) < 10, A)'
+    >>> expression =  'I = if(equals,td(A) > 10 {||,equals} td(B) < 10, A)'
     >>> p.test(expression)
-    I = if(equals,td(A) > 10 {equals,||} td(B) < 10, A)
+    I = if(equals,td(A) > 10 {||,equals} td(B) < 10, A)
     LexToken(NAME,'I',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(IF,'if',1,4)
@@ -216,7 +216,7 @@
     LexToken(RPAREN,')',1,18)
     LexToken(GREATER,'>',1,20)
     LexToken(INT,10,1,22)
-    LexToken(T_COMP_OPERATOR,'{equals,||}',1,25)
+    LexToken(T_COMP_OPERATOR,'{||,equals}',1,25)
     LexToken(TD,'td',1,37)
     LexToken(LPAREN,'(',1,39)
     LexToken(NAME,'B',1,40)
@@ -251,9 +251,9 @@
     LexToken(COMMA,',',1,44)
     LexToken(NAME,'A',1,46)
     LexToken(RPAREN,')',1,47)
-    >>> expression =  'E = if({equals},td(A) >= 4 {contain,&&} td(B) == 2, C : D)'
+    >>> expression =  'E = if({equals},td(A) >= 4 {&&,contain} td(B) == 2, C : D)'
     >>> p.test(expression)
-    E = if({equals},td(A) >= 4 {contain,&&} td(B) == 2, C : D)
+    E = if({equals},td(A) >= 4 {&&,contain} td(B) == 2, C : D)
     LexToken(NAME,'E',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(IF,'if',1,4)
@@ -266,7 +266,7 @@
     LexToken(RPAREN,')',1,20)
     LexToken(GREATER_EQUALS,'>=',1,22)
     LexToken(INT,4,1,25)
-    LexToken(T_COMP_OPERATOR,'{contain,&&}',1,27)
+    LexToken(T_COMP_OPERATOR,'{&&,contain}',1,27)
     LexToken(TD,'td',1,40)
     LexToken(LPAREN,'(',1,42)
     LexToken(NAME,'B',1,43)
@@ -278,9 +278,9 @@
     LexToken(T_SELECT,':',1,54)
     LexToken(NAME,'D',1,56)
     LexToken(RPAREN,')',1,57)
-    >>> expression =  'F = if({equals},A {equal,#}, B, C : D)'
+    >>> expression =  'F = if({equals},A {#,equal}, B, C : D)'
     >>> p.test(expression)
-    F = if({equals},A {equal,#}, B, C : D)
+    F = if({equals},A {#,equal}, B, C : D)
     LexToken(NAME,'F',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(IF,'if',1,4)
@@ -288,7 +288,7 @@
     LexToken(T_REL_OPERATOR,'{equals}',1,7)
     LexToken(COMMA,',',1,15)
     LexToken(NAME,'A',1,16)
-    LexToken(T_HASH_OPERATOR,'{equal,#}',1,18)
+    LexToken(T_HASH_OPERATOR,'{#,equal}',1,18)
     LexToken(COMMA,',',1,27)
     LexToken(NAME,'B',1,29)
     LexToken(COMMA,',',1,30)
@@ -299,33 +299,20 @@
     >>> p = tgis.TemporalAlgebraParser()
     >>> p.run = False
     >>> p.debug = True
-    >>> expression =  "D = A : (B !: C)"
-    >>> p.parse(expression)
-    B* =  B !: C
-    A* =  A : B*
-    D = A*
-    >>> expression =  "D = A {!:} B {during,:} C"
+    >>> expression =  "D = A {!:} B {:,during} C"
     >>> print(expression)
-    D = A {!:} B {during,:} C
+    D = A {!:} B {:,during} C
     >>> p.parse(expression)
     A* =  A {!:} B
-    A** =  A* {during,:} C
+    A** =  A* {:,during} C
     D = A**
-    >>> expression =  "D = A {:} B {during,!:} C"
+    >>> expression =  "D = A {:} B {!:,during} C"
     >>> print(expression)
-    D = A {:} B {during,!:} C
+    D = A {:} B {!:,during} C
     >>> p.parse(expression)
     A* =  A {:} B
-    A** =  A* {during,!:} C
+    A** =  A* {!:,during} C
     D = A**
-    >>> expression =  "D = A {:} (B {during,!:} (C : E))"
-    >>> print(expression)
-    D = A {:} (B {during,!:} (C : E))
-    >>> p.parse(expression)
-    C* =  C : E
-    B* =  B {during,!:} C*
-    A* =  A {:} B*
-    D = A*
     >>> p.run = False
     >>> p.debug = False
     >>> expression =  "C = test1 : test2"
@@ -336,24 +323,24 @@
     >>> print(expression)
     D = buff_t(test1,"10 months")
     >>> p.parse(expression, 'stvds')
-    >>> expression =  'E = test2 {during,:} buff_t(test1,"1 days")'
+    >>> expression =  'E = test2 {:,during} buff_t(test1,"1 days")'
     >>> print(expression)
-    E = test2 {during,:} buff_t(test1,"1 days")
+    E = test2 {:,during} buff_t(test1,"1 days")
     >>> p.parse(expression, 'stvds')
-    >>> expression =  'F = test2 {equal,:} buff_t(test1,"1 days")'
+    >>> expression =  'F = test2 {:,equal} buff_t(test1,"1 days")'
     >>> print(expression)
-    F = test2 {equal,:} buff_t(test1,"1 days")
+    F = test2 {:,equal} buff_t(test1,"1 days")
     >>> p.parse(expression, 'stvds')
     >>> p.debug = True
-    >>> expression =  'H = tsnap(test2 {during,:} buff_t(test1, "1 days"))'
+    >>> expression =  'H = tsnap(test2 {:,during} buff_t(test1, "1 days"))'
     >>> p.parse(expression, 'stvds')
     test1* = buff_t( test1 , " 1 days " )
-    test2* =  test2 {during,:} test1*
+    test2* =  test2 {:,during} test1*
     test2** = tsnap( test2* )
     H = test2**
-    >>> expression =  'H = tshift(test2 {during,:} test1, "1 days")'
+    >>> expression =  'H = tshift(test2 {:,during} test1, "1 days")'
     >>> p.parse(expression, 'stvds')
-    test2* =  test2 {during,:} test1
+    test2* =  test2 {:,during} test1
     test2** = tshift( test2* , " 1 days " )
     H = test2**
     >>> expression =  'H = tshift(H, 3)'
@@ -364,24 +351,92 @@
     >>> p.parse(expression, 'stvds')
     td(A)
     td(A) == 2
-    A* =  if condition True  then  A
+    A* =  if condition None  then  A
     C = A*
     >>> expression =  'C = if(td(A) == 5, A, B)'
     >>> p.parse(expression, 'stvds')
     td(A)
     td(A) == 5
-    A* =  if condition True  then  A  else  B
+    A* =  if condition None  then  A  else  B
     C = A*
-    >>> expression =  'C = if(td(A) == 5 || start_date() > "2010-01-01", A, B)'
+    >>> expression =  'C = if(td(A) == 5 || start_date(A) > "2010-01-01", A, B)'
     >>> p.parse(expression, 'stvds')
     td(A)
     td(A) == 5
-    start_date > "2010-01-01"
-    True || True
-    A* =  if condition True  then  A  else  B
+    start_date A > "2010-01-01"
+    None || None
+    A* =  if condition None  then  A  else  B
     C = A*
+    
+    >>> p = tgis.TemporalAlgebraLexer()
+    >>> p.build()
+    >>> p.debug = True
+    >>> expression =  "D = strds(A) : stvds(B) : str3ds(C)"
+    >>> p.test(expression)
+    D = strds(A) : stvds(B) : str3ds(C)
+    LexToken(NAME,'D',1,0)
+    LexToken(EQUALS,'=',1,2)
+    LexToken(STRDS,'strds',1,4)
+    LexToken(LPAREN,'(',1,9)
+    LexToken(NAME,'A',1,10)
+    LexToken(RPAREN,')',1,11)
+    LexToken(T_SELECT,':',1,13)
+    LexToken(STVDS,'stvds',1,15)
+    LexToken(LPAREN,'(',1,20)
+    LexToken(NAME,'B',1,21)
+    LexToken(RPAREN,')',1,22)
+    LexToken(T_SELECT,':',1,24)
+    LexToken(STR3DS,'str3ds',1,26)
+    LexToken(LPAREN,'(',1,32)
+    LexToken(NAME,'C',1,33)
+    LexToken(RPAREN,')',1,34)
+    
+    >>> p = tgis.TemporalAlgebraLexer()
+    >>> p.build()
+    >>> p.debug = True
+    >>> expression =  "R = if(A {#,during} stvds(C) == 1, A)"
+    >>> p.test(expression)
+    R = if(A {#,during} stvds(C) == 1, A)
+    LexToken(NAME,'R',1,0)
+    LexToken(EQUALS,'=',1,2)
+    LexToken(IF,'if',1,4)
+    LexToken(LPAREN,'(',1,6)
+    LexToken(NAME,'A',1,7)
+    LexToken(T_HASH_OPERATOR,'{#,during}',1,9)
+    LexToken(STVDS,'stvds',1,20)
+    LexToken(LPAREN,'(',1,25)
+    LexToken(NAME,'C',1,26)
+    LexToken(RPAREN,')',1,27)
+    LexToken(CEQUALS,'==',1,29)
+    LexToken(INT,1,1,32)
+    LexToken(COMMA,',',1,33)
+    LexToken(NAME,'A',1,35)
+    LexToken(RPAREN,')',1,36)
+    
+    >>> p = tgis.TemporalAlgebraLexer()
+    >>> p.build()
+    >>> p.debug = True
+    >>> expression =  "R = if({during}, stvds(C) {#,contains} A == 2, A)"
+    >>> p.test(expression)
+    R = if({during}, stvds(C) {#,contains} A == 2, A)
+    LexToken(NAME,'R',1,0)
+    LexToken(EQUALS,'=',1,2)
+    LexToken(IF,'if',1,4)
+    LexToken(LPAREN,'(',1,6)
+    LexToken(T_REL_OPERATOR,'{during}',1,7)
+    LexToken(COMMA,',',1,15)
+    LexToken(STVDS,'stvds',1,17)
+    LexToken(LPAREN,'(',1,22)
+    LexToken(NAME,'C',1,23)
+    LexToken(RPAREN,')',1,24)
+    LexToken(T_HASH_OPERATOR,'{#,contains}',1,26)
+    LexToken(NAME,'A',1,39)
+    LexToken(CEQUALS,'==',1,41)
+    LexToken(INT,2,1,44)
+    LexToken(COMMA,',',1,45)
+    LexToken(NAME,'A',1,47)
+    LexToken(RPAREN,')',1,48)
 
- at endcode
 """
 
 try:
@@ -391,26 +446,31 @@
     pass
 
 import os
+import copy
+import grass.pygrass.modules as pymod
 from space_time_datasets import *
 from factory import *
 from open_stds import *
-import copy
+from temporal_operator import *
 
-from grass.exceptions import FatalError
-
 ##############################################################################
 
 class TemporalAlgebraLexer(object):
-    """!Lexical analyzer for the GRASS GIS temporal algebra"""
+    """Lexical analyzer for the GRASS GIS temporal algebra"""
 
-    # Functions that defines an if condition, temporal buffering and snapping
+    # Functions that defines an if condition, temporal buffering, snapping and 
+    # selection of maps with temporal extent.
     conditional_functions = {
         'if'    : 'IF',
         'buff_t': 'BUFF_T',
         'tsnap'  : 'TSNAP',
         'tshift' : 'TSHIFT',
+        'tmap' : 'TMAP',
+        'strds' : 'STRDS',
+        'str3ds' : 'STR3DS',
+        'stvds' : 'STVDS',
     }
-
+    
     # Variables with date and time strings
     datetime_functions = {
         'start_time'     : 'START_TIME',     # start time as HH::MM:SS
@@ -498,13 +558,13 @@
                     + tuple(conditional_functions.values())
 
     # Regular expression rules for simple tokens
-    t_T_SELECT_OPERATOR  = r'\{([a-zA-Z\| ]+[,])?([\|&+=]?[!]?[:])\}'
-    t_T_HASH_OPERATOR    = r'\{([a-zA-Z\| ]+[,])?[#]\}'
-    t_T_COMP_OPERATOR    = r'\{([a-zA-Z\| ]+[,])?(\|\||&&)\}'
+    t_T_SELECT_OPERATOR   = r'\{[!]?[:][,]?[a-zA-Z\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\}'
+    t_T_HASH_OPERATOR   = r'\{[#][,]?[a-zA-Z\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\}'
+    t_T_COMP_OPERATOR   = r'\{(\|\||&&)[,][a-zA-Z\| ]*[,]?[\|&]?([,])?([lrudi]|left|right|union|disjoint|intersect)?\}'
     t_T_REL_OPERATOR     = r'\{([a-zA-Z\| ])+\}'
     t_T_SELECT           = r':'
     t_T_NOT_SELECT       = r'!:'
-    t_LPAREN             = r'\('
+    t_LPAREN             = r'\('    
     t_RPAREN             = r'\)'
     t_COMMA              = r','
     t_CEQUALS            = r'=='
@@ -652,10 +712,17 @@
     def __str__(self):
         return str(self.tfunc) + str(self.compop) + str(self.value)
 
+###############################################################################
 
+class FatalError(Exception):
+    def __init__(self, msg):
+        self.value = msg
+
+    def __str__(self):
+        return self.value
+
 ###############################################################################
 
-
 class TemporalAlgebraParser(object):
     """The temporal algebra class"""
 
@@ -664,11 +731,12 @@
 
     # Setting equal precedence level for select and hash operations.
     precedence = (
-        ('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT'), # 1
+        ('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT',  'T_HASH_OPERATOR',  'HASH'), # 1
         ('left', 'AND', 'OR', 'T_COMP_OPERATOR'), #2
         )
 
-    def __init__(self, pid=None, run = True, debug = False, spatial = False, null = False):
+    def __init__(self, pid=None, run = True, debug = False, spatial = False, 
+                        null = False, register_null = False,  nprocs = 1):
         self.run = run
         self.debug = debug
         self.pid = pid
@@ -682,12 +750,102 @@
         self.msgr = get_tgis_message_interface()
         self.dbif = SQLDatabaseInterfaceConnection()
         self.dbif.connect()
+        self.register_null = register_null
+        self.removable_maps = {}
+        self.m_mremove = pymod.Module('g.remove')
+        self.m_copy = pymod.Module('g.copy')
+        self.nprocs = nprocs
+        self.use_granularity = False
 
     def __del__(self):
         if self.dbif.connected:
             self.dbif.close()
+            
+    def setup_common_granularity(self,  expression,  stdstype = 'strds',  lexer = None):
+        """Configure the temporal algebra to use the common granularity of all
+             space time datasets in the expression to generate the map lists.
+             
+             This function will analyze the expression to detect space time datasets
+             and computes the common granularity  from all granularities.
+          
+             This granularity is then be used to generate the map lists. Hence, all
+             maps from all STDS will have equidistant temporal extents. The only meaningful
+             temporal relation is "equal".
+             
+             :param expression: The algebra expression to analyze
+             
+             :param lexer: The temporal algebra lexer (select, raster, voxel, vector) that should be used to
+                                    parse the expression, default is TemporalAlgebraLexer
+             
+             :return: True if successful, False otherwise
+ 
+        """
+        l = lexer
+        # Split the expression to ignore the left part
+        expressions = expression.split("=")[1:]
+        expression = " ".join(expressions)
+        
+        # Check if spatio-temporal operators are present in the expression
+        if "{" in expression or "}" in expression:
+            self.msgr.error(_("Spatio temporal operators are not supported in granularity algebra mode"))
+            return False
+            
+        # detect all STDS
+        if l is None:
+            l = TemporalAlgebraLexer()
+        l.build()
+        l.lexer.input(expression)
+        
+        name_list = []
+        tokens = []
+        
+        count = 0
+        while True:
+            tok = l.lexer.token()
+            if not tok: break
 
-    def parse(self, expression, stdstype = 'strds', basename = None, overwrite=False):
+            # Ignore map layer
+            tokens.append(tok.type)
+            ignore = False
+            if count > 1:
+                if tokens[count - 2] == "MAP" or tokens[count - 2] == "TMAP":
+                    ignore = True
+            
+            if tok.type == "NAME" and ignore == False:
+                name_list.append(tok.value)
+            count += 1
+
+        grans = []
+        ttypes = {}
+        dbif, connected = init_dbif(self.dbif)
+
+        for name in name_list:
+            stds = open_old_stds(name,  stdstype,  dbif)
+            # We need valid temporal topology
+            if stds.check_temporal_topology() is False:
+                self.msgr.error(_("All input space time datasets must have a valid temporal topology."))
+                return False
+
+            grans.append(stds.get_granularity())
+            ttypes[stds.get_temporal_type()] = stds.get_temporal_type()
+        
+        # Only one temporal type is allowed
+        if len(ttypes) > 1:
+            self.msgr.error(_("All input space time datasets must have the same temporal type."))
+            return False
+            
+        # Compute the common granularity
+        if "absolute" in ttypes.keys():
+            self.granularity = compute_common_absolute_time_granularity(grans)
+        else:
+            self.granularity = compute_common_relative_time_granularity(grans)
+            
+        self.use_granularity = True
+        
+        return True
+
+    def parse(self, expression, stdstype = 'strds', maptype = 'rast',  mapclass = RasterDataset, 
+                      basename = None, overwrite=False):
         self.lexer = TemporalAlgebraLexer()
         self.lexer.build()
         self.parser = yacc.yacc(module=self, debug=self.debug)
@@ -695,15 +853,16 @@
         self.overwrite = overwrite
         self.count = 0
         self.stdstype = stdstype
+        self.maptype = maptype
+        self.mapclass = mapclass
         self.basename = basename
         self.expression = expression
         self.parser.parse(expression)
 
     def generate_map_name(self):
-        """!Generate an unique intermediate vector map name
-            and register it in the objects map list for later removement.
+        """Generate an unique  map name and register it in the objects map list
 
-            The vector map names are unique between processes. Do not use the
+            The map names are unique between processes. Do not use the
             same object for map name generation in multiple threads.
         """
         self.count += 1
@@ -715,10 +874,19 @@
         self.names[name] = name
         return name
 
-    def generate_new_map(self, base_map, bool_op = 'and', copy = True):
-        """!Generate a new map using the spatio-temporal extent of the base map
+    def generate_new_map(self, base_map, bool_op = 'and', copy = True,  rename = True, 
+                                              remove = False):
+        """Generate a new map using the spatio-temporal extent of the base map
 
-           @param base_map This map is used to create the new map
+           :param base_map: This map is used to create the new map
+           :param bool_op: The boolean operator specifying the spatial extent
+                  operation (intersection, union, disjoint union)
+           :param copy: Specifies if the temporal extent of mapB should be
+                  copied to mapA
+           :param rename: Specifies if the generated map get a random name or get
+                  the id from the base map.
+            :param remove: Set this True if this map is an intermediate or empty map that should be removed
+           :return: Map object
         """
         # Generate an intermediate name for the result map list.
         name = self.generate_map_name()
@@ -728,22 +896,29 @@
         map_new = base_map.get_new_instance(mapname)
         # Set initial map extend of new vector map.
         self.overlay_map_extent(map_new, base_map, bool_op = bool_op, copy = copy)
-
+        if not rename:
+            name = base_map.get_id()
+            map_new.set_id(name)
+        if remove is True:
+            self.removable_maps[name] = map_new
+        # Make sure to set the uid that is used in several dictionaries
+        map_new.uid = name
         return map_new
 
-    def overlay_map_extent(self, mapA, mapB, bool_op = None, temp_op = '=',
+    def overlay_map_extent(self, mapA, mapB, bool_op = None, temp_op = 'l',
                             copy = False):
-        """!Compute the spatio-temporal extent of two topological related maps
+        """Compute the spatio-temporal extent of two topological related maps
 
-           @param mapA The first map
-           @param mapB The second maps
-           @param bool_op The boolean operator specifying the spatial extent
+           :param mapA: The first map
+           :param mapB: The second maps
+           :param bool_op: The boolean operator specifying the spatial extent
                   operation (intersection, union, disjoint union)
-           @param temp_op The temporal operator specifying the temporal
-                  extent operation (intersection, union, disjoint union)
-           @param copy Specifies if the temporal extent of mapB should be
+           :param temp_op: The temporal operator specifying the temporal
+                  extent operation (intersection, union, disjoint union, right reference)
+                  Left reference is the default temporal extent behaviour.
+           :param copy: Specifies if the temporal extent of mapB should be
                   copied to mapA
-           @return 0 if there is no overlay
+           :return: 0 if there is no overlay
         """
         returncode = 1
         if copy:
@@ -754,6 +929,8 @@
             mapA.set_temporal_extent(map_extent_temporal)
             if "cmd_list" in dir(mapB):
                 mapA.cmd_list = mapB.cmd_list
+            if "condition_value" in dir(mapB):
+                mapA.condition_value = mapB.condition_value
         else:
             # Calculate spatial extent for different overlay operations.
             if bool_op == 'and':
@@ -776,46 +953,162 @@
                     returncode = 0
 
             # Calculate temporal extent for different temporal operators.
-            if temp_op == '&':
+            if temp_op == 'i':
                 temp_ext = mapA.temporal_intersection(mapB)
                 if temp_ext != None:
                     mapA.set_temporal_extent(temp_ext)
                 else:
                     returncode = 0
-            elif temp_op == '|':
+            elif temp_op == 'u':
                 temp_ext = mapA.temporal_union(mapB)
                 if temp_ext != None:
                     mapA.set_temporal_extent(temp_ext)
                 else:
-                    returncode = 0
-            elif temp_op == '+':
+                    returncode = 0                   
+            elif temp_op == 'd':
                 temp_ext = mapA.temporal_disjoint_union(mapB)
                 if temp_ext != None:
                     mapA.set_temporal_extent(temp_ext)
                 else:
                     returncode = 0
-
+            elif temp_op == 'r':
+                temp_ext = mapB.get_temporal_extent()
+                if temp_ext != None:
+                    mapA.set_temporal_extent(temp_ext)
+                else:
+                    returncode = 0 
         return(returncode)
 
+    def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
+        """ Change temporal extent of map list based on temporal relations to 
+                other map list and given temporal operator.
+
+            :param maplist: List of map objects for which relations has been build 
+                                        correctely.
+            :param topolist: List of strings of temporal relations.
+            :param temporal: The temporal operator specifying the temporal
+                                            extent operation (intersection, union, disjoint 
+                                            union, right reference, left reference).
+
+            :return: Map list with specified temporal extent.
+        """
+        resultdict = {}
+        
+        for map_i in maplist:
+            # Loop over temporal related maps and create overlay modules.
+            tbrelations = map_i.get_temporal_relations()
+            # Generate an intermediate map for the result map list.
+            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+                                                                        copy = True,  rename = True)
+            # Combine temporal and spatial extents of intermediate map with related maps.
+            for topo in topolist:
+                if topo in tbrelations.keys():
+                    for map_j in (tbrelations[topo]):
+                        if temporal == 'r':
+                            # Generate an intermediate map for the result map list.
+                            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+                                                                                        copy = True,  rename = True)
+                        # Create overlayed map extent.
+                        returncode = self.overlay_map_extent(map_new, map_j, 'and', \
+                                                                temp_op = temporal)
+                        # Stop the loop if no temporal or spatial relationship exist.
+                        if returncode == 0:
+                            break
+                        # Append map to result map list.
+                        elif returncode == 1:
+                            print(map_new.get_id() + " " + str(map_new.get_temporal_extent_as_tuple()))
+                            print(map_new.condition_value)
+                            # print(map_new.cmd_list)
+                            # resultlist.append(map_new)
+                            resultdict[map_new.get_id()] = map_new
+        
+                        # Create r.mapcalc expression string for the operation.
+                        #cmdstring = self.build_command_string(s_expr_a = map_new,  
+                        #                                                                s_expr_b = map_j,  
+                        #                                                                operator = function)
+                        # Conditional append of module command.
+                        #map_new.cmd_list = cmdstring
+                    if returncode == 0:
+                        break
+            # Append map to result map list.
+            #if returncode == 1:
+            #    resultlist.append(map_new)
+        # Get sorted map objects as values from result dictionoary.
+        resultlist = resultdict.values()
+        resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
+        
+        return(resultlist)
+    
     ######################### Temporal functions ##############################
 
-    def check_stds(self, input, clear = False):
-        """! Check if input space time dataset exist in database and return its map list.
+    def remove_maps(self):
+        """Removes empty or intermediate maps of different type.
+        """
+        
+        map_names = {}
+        map_names["raster"] = []
+        map_names["raster3d"] = []
+        map_names["vector"] = []
+                
+        if self.removable_maps:
+            for map in self.removable_maps.values():
+                    map_names[map.get_type()].append(map.get_name())
+        
+        for key in map_names.keys():
+            if map_names[key]:
+                self.msgr.message(_("Removing un-needed or empty %s maps"%(key)))
+                self._remove_maps(map_names[key],  key)
 
-            @param input Name of space time data set as string or list of maps.
-            @param clear Reset the stored conditional values to empty list.
+    def _remove_maps(self,  namelist,  map_type):
+        """Remove maps of specific type
+        
+            :param namelist: List of map names to be removed
+            :param map_type: The type of the maps  (rast, rast3d or vect)
+        """
+        max = 100
+        chunklist = [namelist[i:i + max] for i in range(0, len(namelist), max)]
+        for chunk in chunklist:
+            stringlist = ",".join(chunk)
+            
+            # Transform the map type
+            if map_type == "raster":
+                map_type = "rast"
+            if map_type == "raster3d":
+                map_type = "rast3d"
+            if map_type == "vector":
+                map_type = "vect"
 
-            @return List of maps.
+            if self.run:
+                m = copy.deepcopy(self.m_mremove)
+                m.inputs["type"].value = map_type
+                m.inputs["name"].value = stringlist
+                m.flags["f"].value = True
+                print m.get_bash()
+                m.run()
 
+    def check_stds(self, input, clear = False,  stds_type = None,  check_type=True):
+        """ Check if input space time dataset exist in database and return its map list.
+
+            :param input: Name of space time data set as string or list of maps.
+            :param clear: Reset the stored conditional values to empty list.
+            :param check_type: Check the type of the space time dataset to match the global stds type
+            :param stds_type: The type of the space time dataset to be opened, if not provided 
+                                          then self.stdstype will be used
+
+            :return: List of maps.
+
         """
-        if not isinstance(input, list):
+        if isinstance(input, str):
             # Check for mapset in given stds input.
             if input.find("@") >= 0:
                 id_input = input
             else:
                 id_input = input + "@" + self.mapset
             # Create empty spacetime dataset.
-            stds = dataset_factory(self.stdstype, id_input)
+            if stds_type:
+                stds = dataset_factory(stds_type, id_input)
+            else:
+                stds = dataset_factory(self.stdstype, id_input)
             # Check for occurence of space time dataset.
             if stds.is_in_db(dbif=self.dbif) == False:
                 raise FatalError(_("Space time %s dataset <%s> not found") %
@@ -823,7 +1116,16 @@
             else:
                 # Select temporal dataset entry from database.
                 stds.select(dbif=self.dbif)
-                maplist = stds.get_registered_maps_as_objects(dbif=self.dbif)
+                if self.use_granularity:
+                    # We create the maplist out of the map array from none-gap objects
+                    maplist = []
+                    map_array = stds.get_registered_maps_as_objects_by_granularity(gran=self.granularity,  dbif=self.dbif)
+                    for entry in map_array:
+                        # Ignore gap objects
+                        if entry[0].get_id() is not None:
+                            maplist.append(entry[0])
+                else:
+                    maplist = stds.get_registered_maps_as_objects(dbif=self.dbif)
                 # Create map_value as empty list item.
                 for map_i in maplist:
                     if "map_value" not in dir(map_i):
@@ -843,8 +1145,11 @@
                         self.msgr.fatal(_("Wrong temporal type of space time dataset <%s> \
                                       <%s> time is required") %
                                      (id_input, self.temporaltype))
-
-        else:
+        elif isinstance(input,  self.mapclass):
+            # Check if the input is a single map and return it as list with one entry.
+            maplist = [input]
+        
+        elif isinstance(input,  list):
             maplist = input
             # Create map_value as empty list item.
             for map_i in maplist:
@@ -856,147 +1161,170 @@
                     map_i.condition_value = []
                 elif clear:
                     map_i.condition_value = []
-
+        else:
+            self.msgr.fatal(_("Wrong type of input " + str(input)))
+            
+        # We generate a unique map id that will be used
+        # in the topology analysis, since the maplist can 
+        # contain maps with equal map ids 
+        for map in maplist:
+            map.uid = self.generate_map_name()
+            if self.debug:
+                print map.get_name(), map.uid,  map.get_temporal_extent_as_tuple()
+        
         return(maplist)
 
     def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
-                               assign_val = False, count_map = False):
-        """!Build temporal topology for two space time data sets, copy map objects
+                               assign_val = False, count_map = False, compare_bool = False,  
+                               compop = None, aggregate = None):
+        """Build temporal topology for two space time data sets, copy map objects
           for given relation into map list.
-          @param maplistA List of maps.
-          @param maplistB List of maps.
-          @param topolist List of strings of temporal relations.
-          @param assign_val Boolean for assigning a boolean map value based on
+
+          :param maplistA: List of maps.
+          :param maplistB: List of maps.
+          :param topolist: List of strings of temporal relations.
+          :param assign_val: Boolean for assigning a boolean map value based on
                             the map_values from the compared map list by
                             topological relationships.
-          @param count_map Boolean if the number of topological related maps
+          :param count_map: Boolean if the number of topological related maps
                            should be returned.
-          @return List of maps from maplistA that fulfil the topological relationships
+          :param compare_bool: Boolean for comparing boolean map values based on
+                            related map list and compariosn operator.
+          :param compop: Comparison operator, && or ||.
+          :param aggregate: Aggregation operator for relation map list, & or |.
+          
+          :return: List of maps from maplistA that fulfil the topological relationships
                   to maplistB specified in topolist.
 
-          @code
+          .. code-block:: python
 
+              # Example with two lists of maps
+              >>> import grass.temporal as tgis
+              >>> tgis.init(True)
+              >>> l = tgis.TemporalAlgebraParser()
+              >>> # Create two list of maps with equal time stamps
+              >>> mapsA = []
+              >>> mapsB = []
+              >>> for i in range(10):
+              ...     idA = "a%i at B"%(i)
+              ...     mapA = tgis.RasterDataset(idA)
+              ...     mapA.uid = idA
+              ...     idB = "b%i at B"%(i)
+              ...     mapB = tgis.RasterDataset(idB)
+              ...     mapB.uid = idB
+              ...     check = mapA.set_relative_time(i, i + 1, "months")
+              ...     check = mapB.set_relative_time(i, i + 1, "months")
+              ...     mapsA.append(mapA)
+              ...     mapsB.append(mapB)
+              >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['EQUAL'])
+              >>> for map in resultlist:
+              ...     if map.get_equal():
+              ...         relations = map.get_equal()
+              ...         print "Map %s has equal relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name())
+              Map a0 has equal relation to map b0
+              Map a1 has equal relation to map b1
+              Map a2 has equal relation to map b2
+              Map a3 has equal relation to map b3
+              Map a4 has equal relation to map b4
+              Map a5 has equal relation to map b5
+              Map a6 has equal relation to map b6
+              Map a7 has equal relation to map b7
+              Map a8 has equal relation to map b8
+              Map a9 has equal relation to map b9
+              >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['DURING'])
+              >>> print(resultlist)
+              []
+              >>> # Create two list of maps with equal time stamps
+              >>> mapsA = []
+              >>> mapsB = []
+              >>> for i in range(10):
+              ...     idA = "a%i at B"%(i)
+              ...     mapA = tgis.RasterDataset(idA)
+              ...     mapA.uid = idA
+              ...     idB = "b%i at B"%(i)
+              ...     mapB = tgis.RasterDataset(idB)
+              ...     mapB.uid = idB
+              ...     check = mapA.set_relative_time(i, i + 1, "months")
+              ...     check = mapB.set_relative_time(i, i + 2, "months")
+              ...     mapsA.append(mapA)
+              ...     mapsB.append(mapB)
+              >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['starts','during'])
+              >>> for map in resultlist:
+              ...     if map.get_starts():
+              ...         relations = map.get_starts()
+              ...         print "Map %s has start relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name())
+              Map a0 has start relation to map b0
+              Map a1 has start relation to map b1
+              Map a2 has start relation to map b2
+              Map a3 has start relation to map b3
+              Map a4 has start relation to map b4
+              Map a5 has start relation to map b5
+              Map a6 has start relation to map b6
+              Map a7 has start relation to map b7
+              Map a8 has start relation to map b8
+              Map a9 has start relation to map b9
+              >>> for map in resultlist:
+              ...     if map.get_during():
+              ...         relations = map.get_during()
+              ...         print "Map %s has during relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name())
+              Map a0 has during relation to map b0
+              Map a1 has during relation to map b0
+              Map a2 has during relation to map b1
+              Map a3 has during relation to map b2
+              Map a4 has during relation to map b3
+              Map a5 has during relation to map b4
+              Map a6 has during relation to map b5
+              Map a7 has during relation to map b6
+              Map a8 has during relation to map b7
+              Map a9 has during relation to map b8
+              >>> # Create two list of maps with equal time stamps and map_value method.
+              >>> mapsA = []
+              >>> mapsB = []
+              >>> for i in range(10):
+              ...     idA = "a%i at B"%(i)
+              ...     mapA = tgis.RasterDataset(idA)
+              ...     mapA.uid = idA
+              ...     idB = "b%i at B"%(i)
+              ...     mapB = tgis.RasterDataset(idB)
+              ...     mapB.uid = idB
+              ...     check = mapA.set_relative_time(i, i + 1, "months")
+              ...     check = mapB.set_relative_time(i, i + 1, "months")
+              ...     mapB.map_value = True
+              ...     mapsA.append(mapA)
+              ...     mapsB.append(mapB)
+              >>> # Create two list of maps with equal time stamps
+              >>> mapsA = []
+              >>> mapsB = []
+              >>> for i in range(10):
+              ...     idA = "a%i at B"%(i)
+              ...     mapA = tgis.RasterDataset(idA)
+              ...     mapA.uid = idA
+              ...     mapA.map_value = True
+              ...     idB = "b%i at B"%(i)
+              ...     mapB = tgis.RasterDataset(idB)
+              ...     mapB.uid = idB
+              ...     mapB.map_value = False
+              ...     check = mapA.set_absolute_time(datetime(2000,1,i+1),
+              ...             datetime(2000,1,i + 2))
+              ...     check = mapB.set_absolute_time(datetime(2000,1,i+6),
+              ...             datetime(2000,1,i + 7))
+              ...     mapsA.append(mapA)
+              ...     mapsB.append(mapB)
+              >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB)
+              >>> for map in resultlist:
+              ...     print(map.get_id())
+              a5 at B
+              a6 at B
+              a7 at B
+              a8 at B
+              a9 at B
+              >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['during'])
+              >>> for map in resultlist:
+              ...     print(map.get_id())
 
-          # Example with two lists of maps
-          >>> import grass.temporal as tgis
-          >>> tgis.init(True)
-          >>> l = tgis.TemporalAlgebraParser()
-          >>> # Create two list of maps with equal time stamps
-          >>> mapsA = []
-          >>> mapsB = []
-          >>> for i in range(10):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     idB = "b%i at B"%(i)
-          ...     mapB = tgis.RasterDataset(idB)
-          ...     check = mapA.set_relative_time(i, i + 1, "months")
-          ...     check = mapB.set_relative_time(i, i + 1, "months")
-          ...     mapsA.append(mapA)
-          ...     mapsB.append(mapB)
-          >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['EQUAL'])
-          >>> for map in resultlist:
-          ...     if map.get_equal():
-          ...         relations = map.get_equal()
-          ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-          ...               relations[0].get_name())
-          Map a0 has equal relation to map b0
-          Map a1 has equal relation to map b1
-          Map a2 has equal relation to map b2
-          Map a3 has equal relation to map b3
-          Map a4 has equal relation to map b4
-          Map a5 has equal relation to map b5
-          Map a6 has equal relation to map b6
-          Map a7 has equal relation to map b7
-          Map a8 has equal relation to map b8
-          Map a9 has equal relation to map b9
-          >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['DURING'])
-          >>> print(resultlist)
-          []
-          >>> # Create two list of maps with equal time stamps
-          >>> mapsA = []
-          >>> mapsB = []
-          >>> for i in range(10):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     idB = "b%i at B"%(i)
-          ...     mapB = tgis.RasterDataset(idB)
-          ...     check = mapA.set_relative_time(i, i + 1, "months")
-          ...     check = mapB.set_relative_time(i, i + 2, "months")
-          ...     mapsA.append(mapA)
-          ...     mapsB.append(mapB)
-          >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['starts','during'])
-          >>> for map in resultlist:
-          ...     if map.get_starts():
-          ...         relations = map.get_starts()
-          ...         print "Map %s has start relation to map %s"%(map.get_name(),
-          ...               relations[0].get_name())
-          Map a0 has start relation to map b0
-          Map a1 has start relation to map b1
-          Map a2 has start relation to map b2
-          Map a3 has start relation to map b3
-          Map a4 has start relation to map b4
-          Map a5 has start relation to map b5
-          Map a6 has start relation to map b6
-          Map a7 has start relation to map b7
-          Map a8 has start relation to map b8
-          Map a9 has start relation to map b9
-          >>> for map in resultlist:
-          ...     if map.get_during():
-          ...         relations = map.get_during()
-          ...         print "Map %s has during relation to map %s"%(map.get_name(),
-          ...               relations[0].get_name())
-          Map a0 has during relation to map b0
-          Map a1 has during relation to map b0
-          Map a2 has during relation to map b1
-          Map a3 has during relation to map b2
-          Map a4 has during relation to map b3
-          Map a5 has during relation to map b4
-          Map a6 has during relation to map b5
-          Map a7 has during relation to map b6
-          Map a8 has during relation to map b7
-          Map a9 has during relation to map b8
-          >>> # Create two list of maps with equal time stamps and map_value method.
-          >>> mapsA = []
-          >>> mapsB = []
-          >>> for i in range(10):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     idB = "b%i at B"%(i)
-          ...     mapB = tgis.RasterDataset(idB)
-          ...     check = mapA.set_relative_time(i, i + 1, "months")
-          ...     check = mapB.set_relative_time(i, i + 1, "months")
-          ...     mapB.map_value = True
-          ...     mapsA.append(mapA)
-          ...     mapsB.append(mapB)
-          >>> # Create two list of maps with equal time stamps
-          >>> mapsA = []
-          >>> mapsB = []
-          >>> for i in range(10):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     mapA.map_value = True
-          ...     idB = "b%i at B"%(i)
-          ...     mapB = tgis.RasterDataset(idB)
-          ...     mapB.map_value = False
-          ...     check = mapA.set_absolute_time(datetime(2000,1,i+1),
-          ...             datetime(2000,1,i + 2))
-          ...     check = mapB.set_absolute_time(datetime(2000,1,i+6),
-          ...             datetime(2000,1,i + 7))
-          ...     mapsA.append(mapA)
-          ...     mapsB.append(mapB)
-          >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB)
-          >>> for map in resultlist:
-          ...     print(map.get_id())
-          a5 at B
-          a6 at B
-          a7 at B
-          a8 at B
-          a9 at B
-          >>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['during'])
-          >>> for map in resultlist:
-          ...     print(map.get_id())
-
-          @endcode
         """
         topologylist = ["EQUAL", "FOLLOWS", "PRECEDES", "OVERLAPS", "OVERLAPPED", \
                         "DURING", "STARTS", "FINISHES", "CONTAINS", "STARTED", \
@@ -1024,28 +1352,14 @@
             tb.build(maplistA, maplistB)
         # Iterate through maps in maplistA and search for relationships given
         # in topolist.
-        # TODO: Better implementation with less nesting
         for map_i in maplistA:
             tbrelations = map_i.get_temporal_relations()
+            if assign_val:
+                self.assign_bool_value(map_i,  tbrelations,  topolist)
+            elif compare_bool:
+                self.compare_bool_value(map_i,  tbrelations, compop, aggregate, topolist)
             for topo in topolist:
                 if topo.upper() in tbrelations.keys():
-                    if assign_val:
-                        mapvaluelist = []
-                        if complementdict[topo.upper()] in tbrelations:
-                            relationmaplist = tbrelations[complementdict[topo.upper()]]
-                            for relationmap in relationmaplist:
-                                if "map_value" in dir(relationmap):
-                                    for element in relationmap.map_value:
-                                        if isinstance(element, GlobalTemporalVar):
-                                            if element.get_type() == "boolean":
-                                                mapvaluelist.append(element.boolean)
-                        if all(mapvaluelist):
-                            resultbool = True
-                        else:
-                            resultbool = False
-                        if "condition_value" in dir(map_i):
-                            if isinstance(map_i.condition_value, list):
-                                map_i.condition_value.append(resultbool)
                     if count_map:
                         relationmaplist = tbrelations[topo.upper()]
                         gvar = GlobalTemporalVar()
@@ -1054,177 +1368,176 @@
                             map_i.map_value.append(gvar)
                         else:
                             map_i.map_value = gvar
-                    resultdict[map_i.get_id()] = map_i
+                    # Use unique identifier, since map names may be equal
+                    resultdict[map_i.uid] = map_i
         resultlist = resultdict.values()
-
+        
         # Sort list of maps chronological.
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
+        
         return(resultlist)
+    
+    def assign_bool_value(self,  map_i, tbrelations, topolist = ["EQUAL"]):
+        """ Function to assign boolean map value based on the map_values from the 
+                compared map list by topological relationships.
+                
+          :param map_i: Map object with temporal extent.
+          :param tbrelations: List of temporal relation to map_i.
+          :param topolist: List of strings for given temporal relations.
+          
+          :return: Map object with conditional value that has been assigned by 
+                        relation maps that fulfil the topological relationships to 
+                        maplistB specified in topolist.
+        """
+        condition_value_list = []
+        for topo in topolist:
+            if topo.upper() in tbrelations.keys():
+                #relationmaplist = tbrelations[complementdict[topo.upper()]]
+                relationmaplist = tbrelations[topo.upper()]
+                for relationmap in relationmaplist:
+                    for boolean in relationmap.condition_value:
+                        if isinstance(boolean, bool):
+                            condition_value_list.append(boolean)
+                    if self.debug:
+                        print(str(relationmap.get_temporal_extent_as_tuple()) + str(boolean))
+        if all(condition_value_list):
+            resultbool = True
+        else:
+            resultbool = False
+        map_i.condition_value = [resultbool]
+        
+        return(resultbool)
 
-    def eval_toperator(self, operator):
-        """!This function evaluates a string containing temporal operations.
+    def compare_bool_value(self,  map_i, tbrelations, compop, aggregate,  topolist = ["EQUAL"]):
+        """ Function to evaluate two map lists with boolean values by boolean 
+            comparison operator. 
+            
+          :param map_i: Map object with temporal extent.
+          :param tbrelations: List of temporal relation to map_i.
+          :param topolist: List of strings for given temporal relations.
+          :param compop: Comparison operator, && or ||.
+          :param aggregate: Aggregation operator for relation map list, & or |.
+          
+          :return: Map object with conditional value that has been evaluated by
+                        comparison operators.
+        """
+        # Build conditional list with elements from related maps and given relation operator.
+        leftbool = map_i.condition_value[0]
+        condition_value_list = [leftbool]
+        count = 0
+        for topo in topolist:
+            if topo.upper() in tbrelations.keys():
+                relationmaplist = tbrelations[topo.upper()]
+                if count == 0:
+                    condition_value_list.append(compop[0])
+                    condition_value_list.append('(')
+                for relationmap in relationmaplist:
+                    for boolean in relationmap.condition_value:
+                        if isinstance(boolean, bool):
+                            if count > 0:
+                                condition_value_list.append(aggregate)
+                            condition_value_list.append(boolean)
+                            count = count + 1
+        if count > 0:
+            condition_value_list.append(')')
+        # Convert conditional list to concatenated string and evaluate booleans.
+        condition_value_str = ''.join(map(str, condition_value_list))
+        if self.debug:
+            print(condition_value_str)
+        resultbool = eval(condition_value_str)
+        if self.debug:
+            print(resultbool)
+        # Add boolean value to result list.
+        map_i.condition_value = [resultbool]
+        
+        return(resultbool)
+    
+    def eval_toperator(self, operator, optype = 'relation'):
+        """This function evaluates a string containing temporal operations.
 
-          @param operator String of temporal operations, e.g. {equal|during,=!:}.
+         :param operator: String of temporal operations, e.g. {!=,equal|during,l}.
+         :param optype: String to define operator type.
+         
+         :return :List of temporal relations (equal, during), the given function
+          (!:) and the interval/instances (l).
+          
+        .. code-block:: python
+        
+             >>> import grass.temporal as tgis
+             >>> tgis.init()
+             >>> p = tgis.TemporalOperatorParser()
+             >>> operator = "{+, during}"
+             >>> p.parse(operator, optype = 'raster')
+             >>> print(p.relations, p.temporal, p.function)
+             (['during'], 'l', '+')
 
-          @return List of temporal relations (equal, during), the given function
-           (!:) and the interval/instances (=).
-
-          @code
-          >>> import grass.temporal as tgis
-          >>> tgis.init()
-          >>> p = tgis.TemporalAlgebraParser()
-          >>> operator = "{equal,:}"
-          >>> p.eval_toperator(operator)
-          (['equal'], '=', ':')
-          >>> operator = "{equal|during,:}"
-          >>> p.eval_toperator(operator)
-          (['equal', 'during'], '=', ':')
-          >>> operator = "{equal,!:}"
-          >>> p.eval_toperator(operator)
-          (['equal'], '=', '!:')
-          >>> operator = "{equal|during,!:}"
-          >>> p.eval_toperator(operator)
-          (['equal', 'during'], '=', '!:')
-          >>> operator = "{equal|during,=!:}"
-          >>> p.eval_toperator(operator)
-          (['equal', 'during'], '=', '!:')
-          >>> operator = "{equal|during|starts,#}"
-          >>> p.eval_toperator(operator)
-          (['equal', 'during', 'starts'], '=', '#')
-          >>> operator = "{!:}"
-          >>> p.eval_toperator(operator)
-          (['equal'], '=', '!:')
-          >>> operator = "{=:}"
-          >>> p.eval_toperator(operator)
-          (['equal'], '=', ':')
-          >>> operator = "{#}"
-          >>> p.eval_toperator(operator)
-          (['equal'], '=', '#')
-          >>> operator = "{equal|during}"
-          >>> p.eval_toperator(operator)
-          (['equal', 'during'], '=', '')
-          >>> operator = "{equal}"
-          >>> p.eval_toperator(operator)
-          (['equal'], '=', '')
-          >>> operator = "{equal,||}"
-          >>> p.eval_toperator(operator)
-          (['equal'], '=', '||')
-          >>> operator = "{equal|during,&&}"
-          >>> p.eval_toperator(operator)
-          (['equal', 'during'], '=', '&&')
-
-          @endcode
-
         """
-        topologylist = ["EQUAL", "FOLLOWS", "PRECEDES", "OVERLAPS", "OVERLAPPED", \
-                        "DURING", "STARTS", "FINISHES", "CONTAINS", "STARTED", \
-                        "FINISHED"]
-        functionlist = [":", "!:", "#"]
-        intervallist = ["=", "|", "&", "+"]
-        comparelist  = ["||", "&&"]
-        relations = []
-        interval = '='
-        function = ''
-        op = operator.strip('{}')
-        oplist = op.split(',')
-        if len(oplist) > 1:
-            relationlist =  oplist[0].split('|')
-            for relation in relationlist:
-                if relation.upper() in topologylist and relation not in relations:
-                    relations.append(relation)
-                else:
-                    raise SyntaxError("invalid syntax")
-            opright = oplist[1]
-            if opright in comparelist:
-                function = opright
-            elif opright[0] in intervallist:
-                interval = opright[0]
-                if opright[1:] in functionlist:
-                    function = opright[1:]
-                else:
-                    raise SyntaxError("invalid syntax")
-            elif opright in functionlist:
-                function = opright
-            else:
-                raise SyntaxError("invalid syntax")
-        elif all([rel.upper() in topologylist for rel in oplist[0].split('|')]):
-            relations = oplist[0].split('|')
-        else:
-            relations = ['equal']
-            opstr = str(oplist[0])
-            if opstr[0] in intervallist:
-                interval = opstr[0]
-                if opstr[1:] in functionlist:
-                    function = opstr[1:]
-                else:
-                    raise SyntaxError("invalid syntax")
-            elif opstr in functionlist:
-                function = opstr
-            #else:
-                #raise SyntaxError("invalid syntax")
+        p = TemporalOperatorParser()
+        p.parse(operator, optype)
+        p.relations = [rel.upper() for rel in p.relations]
+        
+        return(p.relations, p.temporal, p.function,  p.aggregate)
 
-        return(relations, interval, function)
-
     def perform_temporal_selection(self, maplistA, maplistB, topolist = ["EQUAL"],
                                    inverse = False, assign_val = False):
-        """!This function performs temporal selection operation.
+        """This function performs temporal selection operation.
 
-          @param maplistA   List of maps representing the left side of a temporal
+          :param maplistA:   List of maps representing the left side of a temporal
                              expression.
-          @param maplistB   List of maps representing the right side of a temporal
+          :param maplistB:   List of maps representing the right side of a temporal
                              expression.
-          @param topolist   List of strings of temporal relations.
-          @param inverse    Boolean value that specifies if the selection should be
+          :param topolist: List of strings of temporal relations.
+          :param inverse: Boolean value that specifies if the selection should be
                              inverted.
-          @param assign_val Boolean for assigning a boolean map value based on
+          :param assign_val: Boolean for assigning a boolean map value based on
                             the map_values from the compared map list by
                             topological relationships.
 
-          @return List of selected maps from maplistA.
+          :return: List of selected maps from maplistA.
 
-          @code
+          .. code-block:: python
 
-          >>> import grass.temporal as tgis
-          >>> tgis.init()
-          >>> l = tgis.TemporalAlgebraParser()
-          >>> # Example with two lists of maps
-          >>> # Create two list of maps with equal time stamps
-          >>> mapsA = []
-          >>> mapsB = []
-          >>> for i in range(10):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     idB = "b%i at B"%(i)
-          ...     mapB = tgis.RasterDataset(idB)
-          ...     check = mapA.set_relative_time(i, i + 1, "months")
-          ...     check = mapB.set_relative_time(i + 5, i + 6, "months")
-          ...     mapsA.append(mapA)
-          ...     mapsB.append(mapB)
-          >>> resultlist = l.perform_temporal_selection(mapsA, mapsB, ['EQUAL'],
-          ...                                           False)
-          >>> for map in resultlist:
-          ...     if map.get_equal():
-          ...         relations = map.get_equal()
-          ...         print "Map %s has equal relation to map %s"%(map.get_name(),
-          ...               relations[0].get_name())
-          Map a5 has equal relation to map b0
-          Map a6 has equal relation to map b1
-          Map a7 has equal relation to map b2
-          Map a8 has equal relation to map b3
-          Map a9 has equal relation to map b4
-          >>> resultlist = l.perform_temporal_selection(mapsA, mapsB, ['EQUAL'],
-          ...                                           True)
-          >>> for map in resultlist:
-          ...     if not map.get_equal():
-          ...         print "Map %s has no equal relation to mapset mapsB"%(map.get_name())
-          Map a0 has no equal relation to mapset mapsB
-          Map a1 has no equal relation to mapset mapsB
-          Map a2 has no equal relation to mapset mapsB
-          Map a3 has no equal relation to mapset mapsB
-          Map a4 has no equal relation to mapset mapsB
+              >>> import grass.temporal as tgis
+              >>> tgis.init()
+              >>> l = tgis.TemporalAlgebraParser()
+              >>> # Example with two lists of maps
+              >>> # Create two list of maps with equal time stamps
+              >>> mapsA = []
+              >>> mapsB = []
+              >>> for i in range(10):
+              ...     idA = "a%i at B"%(i)
+              ...     mapA = tgis.RasterDataset(idA)
+              ...     mapA.uid = idA
+              ...     idB = "b%i at B"%(i)
+              ...     mapB = tgis.RasterDataset(idB)
+              ...     mapB.uid = idB
+              ...     check = mapA.set_relative_time(i, i + 1, "months")
+              ...     check = mapB.set_relative_time(i + 5, i + 6, "months")
+              ...     mapsA.append(mapA)
+              ...     mapsB.append(mapB)
+              >>> resultlist = l.perform_temporal_selection(mapsA, mapsB, ['EQUAL'],
+              ...                                           False)
+              >>> for map in resultlist:
+              ...     if map.get_equal():
+              ...         relations = map.get_equal()
+              ...         print "Map %s has equal relation to map %s"%(map.get_name(),
+              ...               relations[0].get_name())
+              Map a5 has equal relation to map b0
+              Map a6 has equal relation to map b1
+              Map a7 has equal relation to map b2
+              Map a8 has equal relation to map b3
+              Map a9 has equal relation to map b4
+              >>> resultlist = l.perform_temporal_selection(mapsA, mapsB, ['EQUAL'],
+              ...                                           True)
+              >>> for map in resultlist:
+              ...     if not map.get_equal():
+              ...         print "Map %s has no equal relation to mapset mapsB"%(map.get_name())
+              Map a0 has no equal relation to mapset mapsB
+              Map a1 has no equal relation to mapset mapsB
+              Map a2 has no equal relation to mapset mapsB
+              Map a3 has no equal relation to mapset mapsB
+              Map a4 has no equal relation to mapset mapsB
 
-          @endcode
         """
         if not inverse:
             topolist = self.get_temporal_topo_list(maplistA, maplistB, topolist,
@@ -1233,64 +1546,64 @@
 
         else:
             topolist = self.get_temporal_topo_list(maplistA, maplistB, topolist,
-                                                    assign_val = False)
+                                                    assign_val = assign_val)
             resultlist = []
-
             for map_i in maplistA:
                 if map_i not in topolist:
                     resultlist.append(map_i)
-                    if assign_val:
-                        if "condition_value" in dir(map_i):
-                            map_i.condition_value.append(False)
+                    #if assign_val:
+                    #   if "condition_value" in dir(map_i):
+                    #        map_i.condition_value.append(False)
 
         # Sort list of maps chronological.
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
-
         return(resultlist)
 
-    def set_granularity(self, maplistA, maplistB, toperator = '=', topolist = ["EQUAL"]):
-        """!This function sets the temporal extends of a list of maps based on
+    def set_granularity(self, maplistA, maplistB, toperator = 'l', topolist = ["EQUAL"]):
+        """This function sets the temporal extends of a list of maps based on
              another map list.
 
-          @param maplistB List of maps.
-          @param maplistB List of maps.
-          @param toperator String containing the temporal operator: =, +, &, |.
-          @param topolist List of topological relations.
+          :param maplistB: List of maps.
+          :param maplistB: List of maps.
+          :param toperator: String containing the temporal operator: l, r, d, i, u.
+          :param topolist: List of topological relations.
 
-          @return List of maps with the new temporal extends.
+          :return: List of maps with the new temporal extends.
 
-          @code
-          >>> import grass.temporal as tgis
-          >>> tgis.init()
-          >>> p = tgis.TemporalAlgebraParser()
-          >>> # Create two list of maps with equal time stamps
-          >>> mapsA = []
-          >>> mapsB = []
-          >>> for i in range(10):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     idB = "b%i at B"%(i)
-          ...     mapB = tgis.RasterDataset(idB)
-          ...     check = mapA.set_relative_time(i, i + 1, "months")
-          ...     check = mapB.set_relative_time(i*2, i*2 + 2, "months")
-          ...     mapsA.append(mapA)
-          ...     mapsB.append(mapB)
-          >>> resultlist = p.set_granularity(mapsA, mapsB, toperator = "|", topolist = ["during"])
-          >>> for map in resultlist:
-          ...     start,end,unit = map.get_relative_time()
-          ...     print(map.get_id() + ' - start: ' + str(start) + ' end: ' + str(end))
-          a1 at B - start: 0 end: 2
-          a0 at B - start: 0 end: 2
-          a3 at B - start: 2 end: 4
-          a2 at B - start: 2 end: 4
-          a5 at B - start: 4 end: 6
-          a4 at B - start: 4 end: 6
-          a7 at B - start: 6 end: 8
-          a6 at B - start: 6 end: 8
-          a9 at B - start: 8 end: 10
-          a8 at B - start: 8 end: 10
+          .. code-block:: python
 
-          @endcode
+              >>> import grass.temporal as tgis
+              >>> tgis.init()
+              >>> p = tgis.TemporalAlgebraParser()
+              >>> # Create two list of maps with equal time stamps
+              >>> mapsA = []
+              >>> mapsB = []
+              >>> for i in range(10):
+              ...     idA = "a%i at B"%(i)
+              ...     mapA = tgis.RasterDataset(idA)
+              ...     mapA.uid = idA
+              ...     idB = "b%i at B"%(i)
+              ...     mapB = tgis.RasterDataset(idB)
+              ...     mapB.uid = idB
+              ...     check = mapA.set_relative_time(i, i + 1, "months")
+              ...     check = mapB.set_relative_time(i*2, i*2 + 2, "months")
+              ...     mapsA.append(mapA)
+              ...     mapsB.append(mapB)
+              >>> resultlist = p.set_granularity(mapsA, mapsB, toperator = "u", topolist = ["during"])
+              >>> for map in resultlist:
+              ...     start,end,unit = map.get_relative_time()
+              ...     print(map.get_id() + ' - start: ' + str(start) + ' end: ' + str(end))
+              a1 at B - start: 0 end: 2
+              a0 at B - start: 0 end: 2
+              a3 at B - start: 2 end: 4
+              a2 at B - start: 2 end: 4
+              a5 at B - start: 4 end: 6
+              a4 at B - start: 4 end: 6
+              a7 at B - start: 6 end: 8
+              a6 at B - start: 6 end: 8
+              a9 at B - start: 8 end: 10
+              a8 at B - start: 8 end: 10
+
         """
         topologylist = ["EQUAL", "FOLLOWS", "PRECEDES", "OVERLAPS", "OVERLAPPED", \
                         "DURING", "STARTS", "FINISHES", "CONTAINS", "STARTED", \
@@ -1310,35 +1623,51 @@
         else:
             tb.build(maplistA, maplistB)
         resultdict = {}
+
         # Iterate through maps in maplistA and search for relationships given
         # in topolist.
         for map_i in maplistA:
             tbrelations = map_i.get_temporal_relations()
+            map_extent = map_i.get_temporal_extent()
+            map_start = map_extent.get_start_time()
+            map_end = map_extent.get_end_time()
+            unchanged = True
             for topo in topolist:
                 if topo.upper() in tbrelations.keys():
                     relationmaplist = tbrelations[topo.upper()]
                     for relationmap in relationmaplist:
-                        newextend = None
-                        if toperator == "&":
-                            newextend = map_i.temporal_intersection(relationmap)
-                        elif toperator == "|":
-                            newextend = map_i.temporal_union(relationmap)
-                        elif toperator == "+":
-                            newextend = map_i.temporal_disjoint_union(relationmap)
-                        elif toperator == "=":
-                            resultdict[map_i.get_id()] = map_i
-
-                        if newextend != None:
-                            start = newextend.get_start_time()
-                            end = newextend.get_end_time()
+                        newextent = None
+                        if toperator == "i":
+                            newextent = map_i.temporal_intersection(relationmap)
+                        elif toperator == "u":
+                            newextent = map_i.temporal_union(relationmap)
+                        elif toperator == "d":
+                            newextent = map_i.temporal_disjoint_union(relationmap)
+                        elif toperator == "l":
+                            newextent = map_i.get_temporal_extent()
+                        elif toperator == "r":
+                            newextent = relationmap.get_temporal_extent()
+                        if newextent != None:
+                            start = newextent.get_start_time()
+                            end = newextent.get_end_time()
                             #print(map_i.get_id() + ' - start: ' + str(start) + ' end: ' + str(end))
+                            # Track changes in temporal extents of maps.
+                            if map_start != start or map_end != end :
+                                unchanged = False
                             if map_i.is_time_absolute():
                                 map_i.set_absolute_time(start, end)
                             else:
                                 relunit = map_i.get_relative_time_unit()
                                 map_i.set_relative_time(int(start), int(end), relunit)
                             resultdict[map_i.get_id()] = map_i
-
+                else:
+                    if self.debug:
+                        print('Topologic relation: ' + topo.upper() + ' not found.')
+                    resultdict[map_i.get_id()] = map_i
+            if unchanged == True:
+                if self.debug:
+                    print('Leave temporal extend of result map: ' +  map_i.get_map_id() + ' unchanged.')
+        
         resultlist = resultdict.values()
         # Sort list of maps chronological.
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
@@ -1350,37 +1679,37 @@
         return(resultlist)
 
     def get_temporal_func_dict(self, map):
-        """! This function creates a dictionary containing temporal functions for a
+        """ This function creates a dictionary containing temporal functions for a
              map dataset with time stamp.
 
-          @param map Map object with time stamps.
+          :param map: Map object with time stamps.
 
-          @return Dictionary with temporal functions for given input map.
+          :return: Dictionary with temporal functions for given input map.
 
-          @code
-          >>> import grass.temporal as tgis
-          >>> import datetime
-          >>> tgis.init()
-          >>> l = tgis.TemporalAlgebraParser()
-          >>> # Example with one list of maps
-          >>> # Create one list of maps with equal time stamps
-          >>> for i in range(1):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     check = mapA.set_absolute_time(datetime.datetime(2000,1,1),
-          ...             datetime.datetime(2000,10,1))
-          ...     tfuncdict = l.get_temporal_func_dict(mapA)
-          >>> print(tfuncdict["START_YEAR"])
-          2000
-          >>> print(tfuncdict["START_TIME"])
-          00:00:00
-          >>> print(tfuncdict["START_DATE"])
-          2000-01-01
-          >>> print(tfuncdict["START_DATETIME"])
-          2000-01-01 00:00:00
+          .. code-block:: python
+          
+              >>> import grass.temporal as tgis
+              >>> import datetime
+              >>> tgis.init()
+              >>> l = tgis.TemporalAlgebraParser()
+              >>> # Example with one list of maps
+              >>> # Create one list of maps with equal time stamps
+              >>> for i in range(1):
+              ...     idA = "a%i at B"%(i)
+              ...     mapA = tgis.RasterDataset(idA)
+              ...     mapA.uid = idA
+              ...     check = mapA.set_absolute_time(datetime.datetime(2000,1,1),
+              ...             datetime.datetime(2000,10,1))
+              ...     tfuncdict = l.get_temporal_func_dict(mapA)
+              >>> print(tfuncdict["START_YEAR"])
+              2000
+              >>> print(tfuncdict["START_TIME"])
+              00:00:00
+              >>> print(tfuncdict["START_DATE"])
+              2000-01-01
+              >>> print(tfuncdict["START_DATETIME"])
+              2000-01-01 00:00:00
 
-          @endcode
-
         """
         tvardict = {"START_DOY" : None, "START_DOW" : None, "START_YEAR" : None,
             "START_MONTH" : None, "START_WEEK" : None, "START_DAY" : None,
@@ -1456,13 +1785,13 @@
         return(boolname)
 
     def eval_global_var(self, gvar, maplist):
-        """! This function evaluates a global variable expression for a map list.
+        """ This function evaluates a global variable expression for a map list.
              For example: start_day() > 5 , end_month() == 2.
 
-          @param gvar    Object of type GlobalTemporalVar containing temporal.
-          @param maplist List of map objects.
+          :param gvar: Object of type GlobalTemporalVar containing temporal.
+          :param maplist: List of map objects.
 
-          @return List of maps from maplist with added conditional boolean values.
+          :return: List of maps from maplist with added conditional boolean values.
         """
         boollist = []
         # Loop over maps of input map list.
@@ -1497,19 +1826,18 @@
                 map_i.condition_value.append(boolname)
             else:
                 map_i.condition_value = boolname
-
         return(maplist)
 
     def eval_map_list(self, maplist ,thenlist, topolist = ["EQUAL"]):
-        """! This function transfers boolean values from temporal expression
+        """ This function transfers boolean values from temporal expression
              from one map list to another by their topology. These boolean
              values are added to the maps as condition_value.
 
-          @param maplist  List of map objects containing boolean map values.
-          @param thenlist List of map objects where the boolean values
+          :param maplist:  List of map objects containing boolean map values.
+          :param thenlist: List of map objects where the boolean values
                           should be added.
 
-          @return List of maps from thenlist with added conditional boolean values.
+          :return: List of maps from thenlist with added conditional boolean values.
         """
         # Get topology of then statement map list in relation to the other maplist
         # and assign boolean values of the maplist to the thenlist.
@@ -1517,117 +1845,76 @@
                                                         assign_val = True,
                                                         topolist = topolist)
         # Inverse selection of maps from thenlist and assigning False values.
-        excludelist = self.perform_temporal_selection(thenlist, maplist,
-                                                        assign_val = True,
-                                                        inverse = True,
-                                                        topolist = topolist)
+        #excludelist = self.perform_temporal_selection(thenlist, maplist,
+         #                                               assign_val = True,
+          #                                              inverse = True,
+          #                                              topolist = topolist)
         # Combining the selection and inverse selection list.
-        resultlist = containlist + excludelist
+        resultlist = containlist# + excludelist
 
         return(resultlist)
 
-    def build_condition_list(self, tvarexpr, thenlist, topolist = ["EQUAL"]):
-        """! This function evaluates temporal variable expressions of a conditional
-             expression related to the map list of the then statement.
-             Global variables or map lists with booleans are compared to the topology
-             of the conclusion map list and a conditional list will be appended to
-             every map. It contain the boolean expressions from these comparisons
-             and optional operators to combine several temporal expressions, like
-             "&&" or "||".
+    def build_condition_list(self, tvarexpr, thenlist,  topolist = ["EQUAL"]):
+        """ This function evaluates temporal variable expressions of a conditional
+             expression in two steps.
+             At first it combines stepwise the single conditions by their relations with LALR.
+             In this prossess sub condition map lists will be created which will include 
+             information of the underlying single conditions. Important: The temporal 
+             relations between conditions are evaluated by implicit aggregation. 
+             In the second step the aggregated condition map list will be compared with the 
+             map list of conclusion statements by the given temporal relation.
+             
+             The result is writen as 'condition_value' attribute to the resulting map objects. 
+             These attribute consists of boolean expressions and operators which can be 
+             evaluated with the eval_condition_list function.
+             [True,  '||', False, '&&', True]
 
              For example: td(A) == 1 && start_day() > 5 --> [True || False]
                           (for one map.condition_value in a then map list)
 
-          @param tvarexpr List of GlobalTemporalVar objects and map lists.
-                          The list is constructed by the TemporalAlgebraParser
-                          in order of expression evaluation in the parser.
+             :param tvarexpr: List of GlobalTemporalVar objects and map lists.
+                         The list is constructed by the TemporalAlgebraParser
+                         in order of expression evaluation in the parser.
 
-          @param thenlist Map list object of the conclusion statement.
-                          It will be compared and evaluated by the conditions.
+             :param thenlist: Map list object of the conclusion statement.
+                         It will be compared and evaluated by the conditions.
+          
+             :param topolist: List of temporal relations between the conditions and the 
+                         conclusions.
+                          
+             :return: Map list with conditional values for all temporal expressions.
 
-          @return Map list with conditional values for all temporal expressions.
-
-          @code
-          >>> import grass.temporal as tgis
-          >>> tgis.init()
-          >>> p = tgis.TemporalAlgebraParser()
-          >>> # Example with two lists of maps
-          >>> # Create two list of maps with equal time stamps
-          >>> mapsA = []
-          >>> mapsB = []
-          >>> for i in range(10):
-          ...     idA = "a%i at B"%(i)
-          ...     mapA = tgis.RasterDataset(idA)
-          ...     idB = "b%i at B"%(i)
-          ...     mapB = tgis.RasterDataset(idB)
-          ...     check = mapA.set_absolute_time(datetime(2000,1,i + 1),
-          ...             datetime(2000,1,i + 2))
-          ...     check = mapB.set_absolute_time(datetime(2000,1,i + 6),
-          ...             datetime(2000,1,i + 7))
-          ...     mapsA.append(mapA)
-          ...     mapsB.append(mapB)
-          >>> mapsA = p.check_stds(mapsA)
-          >>> mapsB = p.check_stds(mapsB)
-          >>> # Create global expression object.
-          >>> gvarA = tgis.GlobalTemporalVar()
-          >>> gvarA.tfunc = "start_day"
-          >>> gvarA.compop = ">"
-          >>> gvarA.value = 5
-          >>> gvarB = tgis.GlobalTemporalVar()
-          >>> gvarB.tfunc = "start_day"
-          >>> gvarB.compop = "<="
-          >>> gvarB.value = 8
-          >>> gvarOP = tgis.GlobalTemporalVar()
-          >>> gvarOP.relationop = "&&"
-          >>> gvarOP.topology.append("EQUAL")
-          >>> tvarexpr = gvarA
-          >>> result = p.build_condition_list(tvarexpr, mapsA)
-          >>> for map_i in result:
-          ...     print(map_i.get_map_id() + ' ' + str(map_i.condition_value))
-          a0 at B [False]
-          a1 at B [False]
-          a2 at B [False]
-          a3 at B [False]
-          a4 at B [False]
-          a5 at B [True]
-          a6 at B [True]
-          a7 at B [True]
-          a8 at B [True]
-          a9 at B [True]
-          >>> tvarexpr = [gvarA, gvarOP, gvarB]
-          >>> result = p.build_condition_list(tvarexpr, mapsB)
-          >>> for map_i in result:
-          ...     print(map_i.get_map_id() + ' ' + str(map_i.condition_value))
-          b0 at B [True, ['EQUAL'], '&&', True]
-          b1 at B [True, ['EQUAL'], '&&', True]
-          b2 at B [True, ['EQUAL'], '&&', True]
-          b3 at B [True, ['EQUAL'], '&&', False]
-          b4 at B [True, ['EQUAL'], '&&', False]
-          b5 at B [True, ['EQUAL'], '&&', False]
-          b6 at B [True, ['EQUAL'], '&&', False]
-          b7 at B [True, ['EQUAL'], '&&', False]
-          b8 at B [True, ['EQUAL'], '&&', False]
-          b9 at B [True, ['EQUAL'], '&&', False]
-
-          @endcode
         """
-
+        
+        # Evaluate the temporal variable expression and compute the temporal combination 
+        # of conditions.
+        
         # Check if the input expression is a valid single global variable.
-        if not isinstance(tvarexpr, list):
-            if isinstance(tvarexpr, GlobalTemporalVar):
-                if tvarexpr.get_type() == "global":
-                    # Use method eval_global_var to evaluate expression.
-                    resultlist = self.eval_global_var(tvarexpr, thenlist)
-        else:
-            # Check if a given list is a list of maps.
-            if all([issubclass(type(ele), AbstractMapDataset) for ele in tvarexpr]):
-                # Use method eval_map_list to evaluate map_list in comparison to thenlist.
-                resultlist = self.eval_map_list(tvarexpr, thenlist, topolist)
-
+        if isinstance(tvarexpr, GlobalTemporalVar) and tvarexpr.get_type() == "global" :
+            # Use method eval_global_var to evaluate expression.
+            resultlist = self.eval_global_var(tvarexpr, thenlist)
+        # Check if a given list is a list of maps.
+        elif all([issubclass(type(ele), AbstractMapDataset) for ele in tvarexpr]):
+            # Use method eval_map_list to evaluate map_list in comparison to thenlist.
+            resultlist = self.eval_map_list(tvarexpr, thenlist, topolist)
+        elif len(tvarexpr) % 2 != 0:
+            # Define variables for map list comparisons.
+            left_obj = []
+            operator = []
+            right_obj =[]
+            count = 0
+            #self.msgr.fatal("Condition list is not complete. Elements missing")
+            for iter in range(len(tvarexpr)):
+                expr = tvarexpr[iter]
+                operator = tvarexpr[iter +1]
+                relexpr = tvarexpr[iter +2]
+                if all([issubclass(type(ele), list) for ele in [expr,  relexpr]]):
+                    resultlist = self.get_temporal_topo_list(expr,  relexpr)
             # Loop through the list, search for map lists or global variables.
             for expr in tvarexpr:
                 if isinstance(expr, list):
                     if all([issubclass(type(ele), AbstractMapDataset) for ele in expr]):
+
                         # Use method eval_map_list to evaluate map_list
                         resultlist = self.eval_map_list(expr, thenlist, topolist)
                     else:
@@ -1648,64 +1935,29 @@
         resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
 
         return(resultlist)
-
+        
     def eval_condition_list(self, maplist, inverse = False):
-        """! This function evaluates conditional values of a map list.
+        """ This function evaluates conditional values of a map list.
              A recursive function is used to evaluate comparison statements
              from left to right in the given conditional list.
 
-            For example: [True,  '||', False, '&&', True]  -> True
-                          [True,  '||', False, '&&', False] -> False
-                          [True,  '&&', False, '&&', True]  -> False
-                          [False, '||', True,  '||', False] -> True
-                          [False, '&&', True,  '&&', True]  -> False
-                          [True,  '&&', True,  '&&', True]  -> True
-                          [True,  '&&', True]               -> True
-                          [True,  '&&', False]              -> False
-                          [False, '||', True]               -> True
+             For example: 
+            
+                  - [True,  '||', False, '&&', True]  -> True
+                  - [True,  '||', False, '&&', False] -> False
+                  - [True,  '&&', False, '&&', True]  -> False
+                  - [False, '||', True,  '||', False] -> True
+                  - [False, '&&', True,  '&&', True]  -> False
+                  - [True,  '&&', True,  '&&', True]  -> True
+                  - [True,  '&&', True]               -> True
+                  - [True,  '&&', False]              -> False
+                  - [False, '||', True]               -> True
 
-          @param tvarexpr List of GlobalTemporalVar objects and map lists.
+             :param tvarexpr: List of GlobalTemporalVar objects and map lists.
                           The list is constructed by the TemporalAlgebraParser
                           in order of expression evaluation in the parser.
 
-          @return Map list with conditional values for all temporal expressions.
-
-        @code
-            >>> import grass.temporal as tgis
-            >>> tgis.init()
-            >>> p = tgis.TemporalAlgebraParser()
-            >>> # Example with two lists of maps
-            >>> # Create two list of maps with equal time stamps
-            >>> mapsA = []
-            >>> mapsB = []
-            >>> for i in range(10):
-            ...     idA = "a%i at B"%(i)
-            ...     mapA = tgis.RasterDataset(idA)
-            ...     idB = "b%i at B"%(i)
-            ...     mapB = tgis.RasterDataset(idB)
-            ...     check = mapA.set_absolute_time(datetime(2000,1,i + 1),
-            ...             datetime(2000,1,i + 2))
-            ...     check = mapB.set_absolute_time(datetime(2000,1,i + 6),
-            ...             datetime(2000,1,i + 7))
-            ...     mapsA.append(mapA)
-            ...     mapsB.append(mapB)
-            >>> mapsA = p.check_stds(mapsA)
-            >>> mapsB = p.check_stds(mapsB)
-            >>> # Create global expression object.
-            >>> gvarA = tgis.GlobalTemporalVar()
-            >>> gvarA.tfunc = "start_day"
-            >>> gvarA.compop = ">"
-            >>> gvarA.value = 5
-            >>> gvarB = tgis.GlobalTemporalVar()
-            >>> gvarB.tfunc = "start_day"
-            >>> gvarB.compop = "<="
-            >>> gvarB.value = 8
-            >>> gvarOP = tgis.GlobalTemporalVar()
-            >>> gvarOP.relationop = "&&"
-            >>> gvarOP.topology.append("EQUAL")
-            >>> tvarexpr = [mapsA, gvarOP,gvarA]
-
-          @endcode
+             :return: Map list with conditional values for all temporal expressions.
         """
         def recurse_compare(conditionlist):
             for ele in conditionlist:
@@ -1737,11 +1989,12 @@
 
         resultlist  = []
         inverselist = []
+
+        # Loop through map list and evaluate conditional values.
         for map_i in maplist:
             if "condition_value" in dir(map_i):
                 # Get condition values from map object.
                 conditionlist = map_i.condition_value
-                #print(map_i.get_map_id() + ' ' + str(map_i.condition_value))
                 # Evaluate conditions in list with recursive function.
                 resultbool = recurse_compare(conditionlist)
                 # Set conditional value of map to resulting boolean.
@@ -1749,15 +2002,16 @@
                 # Add all maps that fulfill the conditions to result list.
                 if resultbool[0]:
                     resultlist.append(map_i)
+                    if self.debug:
+                        print(map_i.get_map_id() + ' ' + str(map_i.condition_value))
                 else:
                     inverselist.append(map_i)
-                #print(map_i.get_map_id() + ' ' + str(map_i.condition_value))
         if inverse:
             return(inverselist)
         else:
             return(resultlist)
 
-    ###########################################################################
+###########################################################################
 
     def p_statement_assign(self, t):
         # The expression should always return a list of maps.
@@ -1766,28 +2020,118 @@
 
         """
         if self.run:
-            resultstds = open_new_space_time_dataset(t[1], self.stdstype, \
-                                                        self.temporaltype, "", "", \
-                                                        'mean', dbif=self.dbif, \
-                                                        overwrite = self.overwrite)
+            dbif, connected = init_dbif(self.dbif)
+            map_stds_type = None
+            map_type = None
             if isinstance(t[3], list):
                 num = len(t[3])
                 count = 0
+                register_list = []      
                 if num > 0:
-                    dbif, connected = init_dbif(None)
-                    for map in t[3]:
-                        map.select(dbif=dbif)
-                        #map.update()
-                        resultstds.register_map(map, dbif=dbif)
-                        count += 1
-                        if count % 10 == 0:
-                            self.msgr.percent(count, num, 1)
+                    process_queue = pymod.ParallelModuleQueue(int(self.nprocs))
+                    for map_i in t[3]:
+                        # Test if temporal extents have been changed by temporal 
+                        # relation operators (i|r). 
+                        if count == 0:
+                            maps_stds_type = map_i.get_new_stds_instance(None).get_type()
+                            map_type = map_i.get_type()
+                            if maps_stds_type != self.stdstype:
+                                self.msgr.warning(_("The resulting space time dataset type <%(a)s> is "\
+                                                                "different from the requested type <%(b)s>"\
+                                                                %({"a":maps_stds_type,  "b":self.stdstype})))
+                        else:
+                            map_type_2 = map_i.get_type()
+                            if map_type != map_type_2:
+                                self.msgr.fatal(_("Maps that should be registered in the "\
+                                                           "resulting space time dataset have different types."))
 
-                    resultstds.update_from_registered_maps(dbif=dbif)
-                    if connected:
-                        dbif.close()
+                        map_i_extent = map_i.get_temporal_extent_as_tuple()
+                        map_test = map_i.get_new_instance(map_i.get_id())
+                        map_test.select(dbif)
+                        map_test_extent = map_test.get_temporal_extent_as_tuple()
+                        if map_test_extent != map_i_extent:
+                            # Create new map with basename
+                            newident = self.basename + "_" + str(count)
+                            map_result = map_i.get_new_instance(newident + "@" + self.mapset)
+
+                            if map_test.map_exists() and self.overwrite == False:
+                                self.msgr.fatal("Error raster maps with basename %s exist. "\
+                                                        "Use --o flag to overwrite existing file" \
+                                                        %(mapname))
+
+                            map_result.set_temporal_extent(map_i.get_temporal_extent())
+                            map_result.set_spatial_extent(map_i.get_spatial_extent())
+                            # Attention we attach a new attribute
+                            map_result.is_new = True
+                            register_list.append(map_result)
+
+                            # Copy the map
+                            if map_i.get_type() == 'raster':
+                                m = copy.deepcopy(self.m_copy)
+                                m.inputs["rast"].value = map_i.get_id(),  newident
+                                m.flags["overwrite"].value = self.overwrite
+                                process_queue.put(m)
+                            elif map_i.get_type() == 'raster3d':
+                                m = copy.deepcopy(self.m_copy)
+                                m.inputs["rast3d"].value = map_i.get_id(),  newident
+                                m.flags["overwrite"].value = self.overwrite
+                                process_queue.put(m)
+                            elif map_i.get_type() == 'vector':
+                                m = copy.deepcopy(self.m_copy)
+                                m.inputs["vect"].value = map_i.get_id(),  newident
+                                m.flags["overwrite"].value = self.overwrite
+                                process_queue.put(m)
+                        else:
+                            register_list.append(map_i)
+                        count  += 1
+
+                    # Wait for running processes
+                    process_queue.wait()
+                    
+                    # Open connection to temporal database.
+                    # Create result space time dataset based on the map stds type        
+                    resultstds = open_new_stds(t[1],maps_stds_type, \
+                                                             'absolute', t[1], t[1], \
+                                                             'mean', self.dbif, \
+                                                             overwrite = self.overwrite)                            
+                    for map_i in register_list:                
+                        # Get meta data from grass database.
+                        map_i.load()
+                        # Check if temporal extents have changed and a new map was created
+                        if hasattr(map_i,  "is_new") is True:
+                            # Do not register empty maps if not required
+                            # In case of a null map continue, do not register null maps
+                            if map_i.metadata.get_min() is None and \
+                               map_i.metadata.get_max() is None:
+                                if not self.register_null:
+                                    self.removable_maps[map_i.get_name()] = map_i
+                                    continue
+                            if map_i.is_in_db(dbif) and self.overwrite:
+                                # Update map in temporal database.
+                                map_i.update_all(dbif)
+                            elif map_i.is_in_db(dbif) and self.overwrite == False:
+                                # Raise error if map exists and no overwrite flag is given.
+                                self.msgr.fatal("Error map %s exist in temporal database. "
+                                                        "Use overwrite flag.  : \n%s" \
+                                                        %(map_i.get_map_id(), cmd.popen.stderr))
+                            else:
+                                # Insert map into temporal database.
+                                map_i.insert(dbif)
+                        # Register map in result space time dataset.
+                        success = resultstds.register_map(map_i, dbif)
+                    resultstds.update_from_registered_maps(dbif)
+                elif num == 0:
+                    self.msgr.warning("Empty result space time dataset. "\
+                                                  "No map has been registered in %s"  %(t[1] ))
+                    # Open connection to temporal database.
+                    # Create result space time dataset.                        
+                    resultstds = open_new_stds(t[1], self.stdstype, \
+                                                             'absolute', t[1], t[1], \
+                                                             'mean', dbif, \
+                                                             overwrite = self.overwrite)
+            if connected:
+                dbif.close()
             t[0] = t[3]
-
         else:
             t[0] = t[3]
 
@@ -1811,12 +2155,91 @@
         """
         t[0] = t[1]
 
+    def p_expr_strds_function(self, t):
+        # Specifiy a explicitely a space time raster dataset
+        # R = A : strds(B) 
+        """
+        expr : STRDS LPAREN stds RPAREN
+        """
+        if self.run:
+            t[0] = self.check_stds(t[3], stds_type = "strds",  check_type=False)
+        else:
+            t[0] = t[3]
+            if self.debug:
+                print "Opening STRDS: ",  t[0]
+
+    def p_expr_str3ds_function(self, t):
+        # Specifiy a explicitely a space time raster dataset
+        # R = A : str3ds(B) 
+        """
+        expr : STR3DS LPAREN stds RPAREN
+        """
+        if self.run:
+            t[0] = self.check_stds(t[3], stds_type = "str3ds",  check_type=False)
+        else:
+            t[0] = t[3]
+            if self.debug:
+                print "Opening STR3DS: ",  t[0]
+
+    def p_expr_stvds_function(self, t):
+        # Specifiy a explicitely a space time vector dataset
+        # R = A : stvds(B) 
+        """
+        expr : STVDS LPAREN stds RPAREN
+        """
+        if self.run:
+            print t[3]
+            t[0] = self.check_stds(t[3], stds_type = "stvds",  check_type=False)
+        else:
+            t[0] = t[3]
+            if self.debug:
+                print "Opening STVDS: ",  t[0]
+
+    def p_expr_tmap_function(self, t):
+        # Add a single map.
+        # Only the spatial extent of the map is evaluated. 
+        # Temporal extent is not existing.
+        # Examples:
+        #    R = tmap(A) 
+        """
+        expr : TMAP LPAREN stds RPAREN
+        """
+        if self.run:
+            # Check input map.
+            input = t[3]
+            if not isinstance(input, list):
+                # Check for mapset in given stds input.
+                if input.find("@") >= 0:
+                    id_input = input
+                else:
+                    id_input = input + "@" + self.mapset
+                # Create empty map dataset.
+                map_i = dataset_factory(self.maptype, id_input)
+                # Check for occurence of space time dataset.
+                if map_i.map_exists() == False:
+                    raise FatalError(_("%s map <%s> not found in GRASS spatial database") %
+                        (map_i.get_type(), id_input))
+                else:
+                    # Select dataset entry from database.
+                    map_i.select(dbif=self.dbif)
+            else:
+                raise FatalError(_("Wrong map type <%s> . TMAP only supports single "\
+                                             "maps that are registered in the temporal GRASS database")\
+                                              %(map_i.get_type()))
+            # Return map object.
+            t[0] = [map_i]
+        else:
+            t[0] = "tmap(",  t[3] , ")"
+
+        if self.debug:
+            print "tmap(", t[3] , ")"
+
     def p_t_hash(self,t):
         """
         t_hash_var : stds HASH stds
-                   | stds HASH expr
-                   | expr HASH stds
-                   | expr HASH expr
+                        | expr HASH stds
+                        | stds HASH expr
+                        | expr HASH expr
         """
 
         if self.run:
@@ -1824,24 +2247,22 @@
             maplistB   = self.check_stds(t[3])
             resultlist = self.get_temporal_topo_list(maplistA, maplistB,
                                                         count_map = True)
-
             t[0] = resultlist
 
     def p_t_hash2(self,t):
         """
         t_hash_var : stds T_HASH_OPERATOR stds
-                   | stds T_HASH_OPERATOR expr
-                   | expr T_HASH_OPERATOR stds
-                   | expr T_HASH_OPERATOR expr
+                      | stds T_HASH_OPERATOR expr
+                      | expr T_HASH_OPERATOR stds
+                      | expr T_HASH_OPERATOR expr
         """
 
         if self.run:
             maplistA   = self.check_stds(t[1])
             maplistB   = self.check_stds(t[3])
-            topolist   = self.eval_toperator(t[2])[0]
+            topolist   = self.eval_toperator(t[2],  optype = 'hash')[0]
             resultlist = self.get_temporal_topo_list(maplistA, maplistB, topolist,
                                                      count_map = True)
-
             t[0] = resultlist
 
     def p_t_td_var(self, t):
@@ -1912,102 +2333,102 @@
         """
         t[0] = t[1]
 
-    def p_t_var_expr(self, t):
+    def p_t_var_expr_td_hash(self, t):
         # Examples:
-        #    start_month() > 2
-        #    start_day() < 14
-        #    start_day() < start_month()
-        #    td() < 31
+        #    A # B == 2
+        #    td(A) < 31
         """
-        t_var_expr : t_var LPAREN RPAREN comp_op number
-                   | t_var LPAREN RPAREN comp_op t_var
-                   | t_td_var comp_op number
-                   | t_td_var comp_op t_var
-                   | t_hash_var comp_op number
-                   | t_hash_var comp_op t_var
+        t_var_expr :  t_td_var comp_op number
+                | t_hash_var comp_op number
         """
         if self.run:
-            if len(t) == 4:
-                maplist = self.check_stds(t[1])
-                comp_op = t[2]
-                for map_i in maplist:
-                    for obj in map_i.map_value:
-                        if isinstance(obj, GlobalTemporalVar):
-                            td = obj.td
-                            boolnum = eval(str(td) + comp_op + str(t[3]))
-                            gvar = GlobalTemporalVar()
-                            gvar.boolean = boolnum
-                            if obj.get_type() == "timediff":
-                                index = map_i.map_value.index(obj)
-                                map_i.map_value[index] = gvar
-
-                t[0] = maplist
-
-            if len(t) == 6:
-                if isinstance(t[1], GlobalTemporalVar):
-                    pass
-                gvar = GlobalTemporalVar()
-                gvar.tfunc  = t[1]
-                gvar.compop = t[4]
-                gvar.value  = t[5]
-                t[0] = gvar
-        else:
-            t[0] = True
-
+            maplist = self.check_stds(t[1])
+            comp_op = t[2]
+            value  = str(t[3])
+            for map_i in maplist:
+                # Evaluate time diferences and hash operator statements for each map.
+                try:
+                    td = map_i.map_value[0].td
+                    boolname = eval(str(td) + comp_op + value)
+                    # Add conditional boolean value to the map.
+                    if "condition_value" in dir(map_i):
+                        map_i.condition_value.append(boolname)
+                    else:
+                        map_i.condition_value = boolname
+                except:
+                    self.msgr.fatal("Error: the given expression does not contain a correct time difference object.")
+            
+            t[0] = maplist
+            
         if self.debug:
-            if len(t) == 6:
-                print t[1], t[4], t[5]
-            if len(t) == 4:
-                print t[1], t[2], t[3]
+            print t[1], t[2], t[3]
 
-    def p_t_var_expr_time1(self, t):
+    def p_t_var_expr_number(self, t):
         # Examples:
-        #   start_time() == "12:30:00"
-        #   start_date() <= "2001-01-01"
-        #   start_datetime() > "2001-01-01 12:30:00"
+        #    start_month(A) > 2
+        #    start_day(B) < 14
+        #    start_day(B) < start_month(A)
         """
-        t_var_expr : START_TIME LPAREN RPAREN comp_op TIME
-                   | START_DATE LPAREN RPAREN comp_op DATE
-                   | START_DATETIME LPAREN RPAREN comp_op DATETIME
-                   | END_TIME LPAREN RPAREN comp_op TIME
-                   | END_DATE LPAREN RPAREN comp_op DATE
-                   | END_DATETIME LPAREN RPAREN comp_op DATETIME
+        t_var_expr : t_var LPAREN stds RPAREN comp_op number
+                | t_var LPAREN expr RPAREN comp_op number      
         """
+        # TODO:  Implement comparison operator for map lists.
+        #| t_var LPAREN stds RPAREN comp_op t_var LPAREN stds RPAREN
+        #| t_var LPAREN stds RPAREN comp_op t_var LPAREN expr RPAREN
+        #| t_var LPAREN expr RPAREN comp_op t_var LPAREN expr RPAREN
+        #| t_var LPAREN expr RPAREN comp_op t_var LPAREN stds RPAREN
+        # TODO:  Implement statement in backward direction:
+        # number comp_op t_var LPAREN stds RPAREN
         if self.run:
+            maplist = self.check_stds(t[3])
             gvar = GlobalTemporalVar()
             gvar.tfunc  = t[1]
-            gvar.compop = t[4]
-            gvar.value  = t[5]
-            t[0] = gvar
-        else:
-            t[0] = True
+            gvar.compop = t[5]
+            gvar.value  = t[6]
+            # Evaluate temporal variable for given maplist.
+            resultlist = self.eval_global_var(gvar, maplist)
+            t[0] = resultlist
 
         if self.debug:
-            print t[1], t[4], t[5]
+                print t[1], t[3], t[5], t[6]
 
-    def p_t_var_expr_time2(self, t):
+    def p_t_var_expr_time(self, t):
+        # Examples:
+        #   start_time(A) == "12:30:00"
+        #   start_date(B) <= "2001-01-01"
+        #   start_datetime(C) > "2001-01-01 12:30:00"
+        # TODO:  Implement statement in backward direction:
+        # TIME comp_op START_TIME LPAREN stds RPAREN
         """
-        t_var_expr : TIME     comp_op START_TIME LPAREN RPAREN
-                   | DATE     comp_op START_DATE LPAREN RPAREN
-                   | DATETIME comp_op START_DATETIME LPAREN RPAREN
-                   | TIME     comp_op END_TIME LPAREN RPAREN
-                   | DATE     comp_op END_DATE LPAREN RPAREN
-                   | DATETIME comp_op END_DATETIME LPAREN RPAREN
+        t_var_expr : START_TIME LPAREN stds RPAREN comp_op TIME
+                   | START_DATE LPAREN stds RPAREN comp_op DATE
+                   | START_DATETIME LPAREN stds RPAREN comp_op DATETIME
+                   | END_TIME LPAREN stds RPAREN comp_op TIME
+                   | END_DATE LPAREN stds RPAREN comp_op DATE
+                   | END_DATETIME LPAREN stds RPAREN comp_op DATETIME
+                   | START_TIME LPAREN expr RPAREN comp_op TIME
+                   | START_DATE LPAREN expr RPAREN comp_op DATE
+                   | START_DATETIME LPAREN expr RPAREN comp_op DATETIME
+                   | END_TIME LPAREN expr RPAREN comp_op TIME
+                   | END_DATE LPAREN expr RPAREN comp_op DATE
+                   | END_DATETIME LPAREN expr RPAREN comp_op DATETIME
         """
         if self.run:
-            reverseop = {"<" : ">", ">" : "<", "<=" : ">=", ">=" : "<=",
-                          "==" : "==", "!=" : "!="}
+            # Check input maplist.
+            maplist = self.check_stds(t[3])
+            # Build global temporal variable.
             gvar = GlobalTemporalVar()
-            gvar.tfunc  = t[3]
-            gvar.compop = reverseop[t[2]]
-            gvar.value  = t[1]
-            t[0] = gvar
-        else:
-            t[0] = True
+            gvar.tfunc  = t[1]
+            gvar.compop = t[5]
+            gvar.value  = t[6]
+            # Evaluate temporal variable for given maplist.
+            resultlist = self.eval_global_var(gvar, maplist)
+            
+            t[0] = resultlist
 
+
         if self.debug:
-            print(t[4])
-            print t[1], t[4], t[5]
+            print t[1], t[3],  t[5], t[6]
 
     def p_t_var_expr_comp(self, t):
         """
@@ -2015,19 +2436,21 @@
                    | t_var_expr OR OR t_var_expr
         """
         if self.run:
+            # Check input maplists and operators.
             tvarexprA  = t[1]
             tvarexprB  = t[4]
-            operator   = GlobalTemporalVar()
-            operator.relationop = t[2] + t[3]
-            operator.topology.append("EQUAL")
-            resultlist = []
-            resultlist.append(tvarexprA)
-            resultlist.append(operator)
-            resultlist.append(tvarexprB)
-
+            relations = ["EQUAL"]
+            temporal = "l"
+            function = t[2] + t[3]
+            aggregate = t[2] 
+            # Build conditional values based on topological relationships.            
+            complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
+                               compare_bool = True, compop = function[0], aggregate = aggregate)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
+            
             t[0] = resultlist
-        else:
-            t[0] = True
 
         if self.debug:
             print t[1], t[2] + t[3], t[4]
@@ -2039,20 +2462,16 @@
         if self.run:
             tvarexprA  = t[1]
             tvarexprB  = t[3]
-            operator   = GlobalTemporalVar()
-            toperator  = self.eval_toperator(t[2])[0]
-            relationop = toperator[2]
-            relations  = toperator[0]
-            operator.relationop = relationop
-            operator.topology.extend(relations)
-            resultlist = []
-            resultlist.append(tvarexprA)
-            resultlist.append(operator)
-            resultlist.append(tvarexprB)
+            # Evaluate temporal comparison operator.
+            relations, temporal, function, aggregate  = self.eval_toperator(t[2],  optype = 'boolean')
+            # Build conditional values based on topological relationships.
+            complist = self.get_temporal_topo_list(tvarexprA, tvarexprB, topolist = relations,
+                               compare_bool = True, compop = function[0], aggregate = aggregate)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
 
             t[0] = resultlist
-        else:
-            t[0] = True
 
         if self.debug:
             print t[1], t[2], t[3]
@@ -2079,10 +2498,10 @@
             # Return map list.
             t[0] = selectlist
         else:
-            t[0] = t[1] + "*"
+            t[0] = t[1] , "*"
 
         if self.debug:
-            print t[1] + "* = ", t[1], t[2], t[3]
+            print str(t[1]),  "* = ", t[1], t[2], t[3]
 
     def p_expr_t_not_select(self, t):
         # Temporal equal selection
@@ -2132,7 +2551,7 @@
             maplistA     = self.check_stds(t[1])
             maplistB     = self.check_stds(t[3])
             # Evaluate temporal operator.
-            operators  = self.eval_toperator(t[2])
+            operators  = self.eval_toperator(t[2],  optype = 'select')
             # Check for negative selection.
             if operators[2] == "!:":
                 negation = True
@@ -2141,9 +2560,8 @@
             # Perform selection.
             selectlist = self.perform_temporal_selection(maplistA, maplistB,
                          topolist = operators[0], inverse = negation)
-            selectlist = self.set_granularity(selectlist, maplistB, operators[1],
-                                              operators[0])
-
+            selectlist = self.set_granularity(selectlist, maplistB, operators[1], 
+                operators[0])
             # Return map list.
             t[0] = selectlist
         else:
@@ -2165,7 +2583,7 @@
             thenlist     = self.check_stds(t[5])
             # Get temporal conditional statement.
             tvarexpr     = t[3]
-            thencond     = self.build_condition_list(tvarexpr, thenlist)
+            thencond     = self.build_condition_list(tvarexpr, thenlist)      
             thenresult   = self.eval_condition_list(thencond)
             # Clear the map and conditional values of the map list.
             resultlist   = self.check_stds(thenresult, clear = True)
@@ -2189,9 +2607,9 @@
             thenlist     = self.check_stds(t[7])
             # Get temporal conditional statement.
             tvarexpr     = t[5]
-            topolist     = self.eval_toperator(t[3])[0]
-            thencond     = self.build_condition_list(tvarexpr, thenlist, topolist)
-            thenresult   = self.eval_condition_list(thencond)
+            topolist     = self.eval_toperator(t[3],  optype = 'relation')[0]
+            thencond     = self.build_condition_list(tvarexpr, thenlist, topolist)            
+            thenresult   = self.eval_condition_list(thencond)          
             # Clear the map and conditional values of the map list.
             resultlist   = self.check_stds(thenresult, clear = True)
             # Return resulting map list.
@@ -2252,7 +2670,7 @@
             elselist     = self.check_stds(t[9])
             # Get temporal conditional statement.
             tvarexpr     = t[5]
-            topolist     = self.eval_toperator(t[3])[0]
+            topolist     = self.eval_toperator(t[3],  optype = 'relation')[0]
             thencond     = self.build_condition_list(tvarexpr, thenlist, topolist)
             thenresult   = self.eval_condition_list(thencond)
             elsecond     = self.build_condition_list(tvarexpr, elselist, topolist)

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_extent.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,45 +1,43 @@
-"""!@package grass.temporal
+"""
+Temporal extent classes
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related temporal extent functions to be used in Python scripts and tgis packages.
-
 Usage:
 
- at code
+.. code-block:: python
 
->>> import grass.temporal as tgis
->>> from datetime import datetime
->>> tgis.init()
->>> t = tgis.RasterRelativeTime()
->>> t = tgis.RasterAbsoluteTime()
+    >>> import grass.temporal as tgis
+    >>> from datetime import datetime
+    >>> tgis.init()
+    >>> t = tgis.RasterRelativeTime()
+    >>> t = tgis.RasterAbsoluteTime()
 
- at endcode
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 from base import *
 
 ###############################################################################
 
+
 class TemporalExtent(SQLDatabaseInterface):
-    """!This is the abstract time base class for relative and absolute time objects
+    """This is the abstract time base class for relative and absolute time
+    objects.
 
-        It abstract class implements the interface to absolute and relative time.
-        Absolute time is represented by datetime time stamps,
-        relative time is represented by a unit an integer value.
+    It abstract class implements the interface to absolute and relative time.
+    Absolute time is represented by datetime time stamps,
+    relative time is represented by a unit an integer value.
 
-        This class implements temporal topology relationships computation
-        after [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic].
+    This class implements temporal topology relationships computation
+    after [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic].
 
-        Usage:
+    Usage:
 
-        @code
+    .. code-block:: python
 
         >>> init()
         >>> A = TemporalExtent(table="raster_absolute_time",
@@ -73,7 +71,6 @@
         start_time=0
         end_time=1
 
-        @endcode
     """
     def __init__(self, table=None, ident=None, start_time=None, end_time=None):
 
@@ -84,91 +81,90 @@
         self.set_end_time(end_time)
 
     def intersect(self, extent):
-        """!Intersect this temporal extent with the provided temporal extent and
+        """Intersect this temporal extent with the provided temporal extent and
            return a new temporal extent with the new start and end time
 
-           @param extent The temporal extent to intersect with
-           @return The new temporal extent with start and end time,
+           :param extent: The temporal extent to intersect with
+           :return: The new temporal extent with start and end time,
                    or None in case of no intersection
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=6 )
-           >>> inter = A.intersect(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
+               >>> A = TemporalExtent(start_time=5, end_time=6 )
+               >>> inter = A.intersect(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
 
-           >>> A = TemporalExtent(start_time=5, end_time=6 )
-           >>> B = TemporalExtent(start_time=5, end_time=7 )
-           >>> inter = A.intersect(B)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
-           >>> inter = B.intersect(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
+               >>> A = TemporalExtent(start_time=5, end_time=6 )
+               >>> B = TemporalExtent(start_time=5, end_time=7 )
+               >>> inter = A.intersect(B)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
+               >>> inter = B.intersect(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
 
-           >>> A = TemporalExtent(start_time=3, end_time=6 )
-           >>> B = TemporalExtent(start_time=5, end_time=7 )
-           >>> inter = A.intersect(B)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
-           >>> inter = B.intersect(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
+               >>> A = TemporalExtent(start_time=3, end_time=6 )
+               >>> B = TemporalExtent(start_time=5, end_time=7 )
+               >>> inter = A.intersect(B)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
+               >>> inter = B.intersect(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
 
-           >>> A = TemporalExtent(start_time=3, end_time=8 )
-           >>> B = TemporalExtent(start_time=5, end_time=6 )
-           >>> inter = A.intersect(B)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
-           >>> inter = B.intersect(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
+               >>> A = TemporalExtent(start_time=3, end_time=8 )
+               >>> B = TemporalExtent(start_time=5, end_time=6 )
+               >>> inter = A.intersect(B)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
+               >>> inter = B.intersect(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
 
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=6 )
-           >>> inter = A.intersect(B)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
-           >>> inter = B.intersect(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=6 )
+               >>> inter = A.intersect(B)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
+               >>> inter = B.intersect(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
 
-           >>> A = TemporalExtent(start_time=5, end_time=None )
-           >>> B = TemporalExtent(start_time=3, end_time=6 )
-           >>> inter = A.intersect(B)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... None
-           >>> inter = B.intersect(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... None
+               >>> A = TemporalExtent(start_time=5, end_time=None )
+               >>> B = TemporalExtent(start_time=3, end_time=6 )
+               >>> inter = A.intersect(B)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... None
+               >>> inter = B.intersect(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... None
 
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=4 )
-           >>> inter = A.intersect(B)
-           >>> print inter
-           None
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=4 )
+               >>> inter = A.intersect(B)
+               >>> print inter
+               None
 
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=None )
-           >>> inter = A.intersect(B)
-           >>> print inter
-           None
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=None )
+               >>> inter = A.intersect(B)
+               >>> print inter
+               None
 
-           @endcode
         """
         relation = self.temporal_relation(extent)
 
@@ -203,151 +199,150 @@
             return TemporalExtent(start_time=start, end_time=end)
 
     def disjoint_union(self, extent):
-        """!Creates a disjoint union with this temporal extent and the provided one.
+        """Creates a disjoint union with this temporal extent and the provided one.
            Return a new temporal extent with the new start and end time.
 
-           @param extent The temporal extent to create a union with
-           @return The new temporal extent with start and end time
+           :param extent: The temporal extent to create a union with
+           :return: The new temporal extent with start and end time
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=6 )
-           >>> inter = A.intersect(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 6
+               >>> A = TemporalExtent(start_time=5, end_time=6 )
+               >>> inter = A.intersect(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 6
 
-           >>> A = TemporalExtent(start_time=5, end_time=6 )
-           >>> B = TemporalExtent(start_time=5, end_time=7 )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 7
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 5
-            | End time:................... 7
+               >>> A = TemporalExtent(start_time=5, end_time=6 )
+               >>> B = TemporalExtent(start_time=5, end_time=7 )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 7
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 5
+                | End time:................... 7
 
-           >>> A = TemporalExtent(start_time=3, end_time=6 )
-           >>> B = TemporalExtent(start_time=5, end_time=7 )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 7
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 7
+               >>> A = TemporalExtent(start_time=3, end_time=6 )
+               >>> B = TemporalExtent(start_time=5, end_time=7 )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 7
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 7
 
-           >>> A = TemporalExtent(start_time=3, end_time=8 )
-           >>> B = TemporalExtent(start_time=5, end_time=6 )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
+               >>> A = TemporalExtent(start_time=3, end_time=8 )
+               >>> B = TemporalExtent(start_time=5, end_time=6 )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
 
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=6 )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=6 )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
 
-           >>> A = TemporalExtent(start_time=5, end_time=None )
-           >>> B = TemporalExtent(start_time=3, end_time=6 )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 6
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 6
+               >>> A = TemporalExtent(start_time=5, end_time=None )
+               >>> B = TemporalExtent(start_time=3, end_time=6 )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 6
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 6
 
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=4 )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=None )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> A = TemporalExtent(start_time=5, end_time=None )
-           >>> B = TemporalExtent(start_time=3, end_time=8 )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 8
-           >>> A = TemporalExtent(start_time=5, end_time=None )
-           >>> B = TemporalExtent(start_time=3, end_time=None )
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 5
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            | Start time:................. 3
-            | End time:................... 5
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=4 )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=None )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> A = TemporalExtent(start_time=5, end_time=None )
+               >>> B = TemporalExtent(start_time=3, end_time=8 )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 8
+               >>> A = TemporalExtent(start_time=5, end_time=None )
+               >>> B = TemporalExtent(start_time=3, end_time=None )
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                | Start time:................. 3
+                | End time:................... 5
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                | 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
+               >>> 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
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                +-------------------- Relative time -----------------------------------------+
+                | Start time:................. 3
+                | End time:................... 5
+                | Relative time unit:......... years
 
 
-           >>> from datetime import datetime as dt
-           >>> A = AbsoluteTemporalExtent(start_time=dt(2001,1,10), end_time=dt(2003,1,1))
-           >>> B = AbsoluteTemporalExtent(start_time=dt(2005,1,10), end_time=dt(2008,1,1))
-           >>> inter = A.disjoint_union(B)
-           >>> inter.print_info()
-            +-------------------- Absolute time -----------------------------------------+
-            | Start time:................. 2001-01-10 00:00:00
-            | End time:................... 2008-01-01 00:00:00
+               >>> from datetime import datetime as dt
+               >>> A = AbsoluteTemporalExtent(start_time=dt(2001,1,10), end_time=dt(2003,1,1))
+               >>> B = AbsoluteTemporalExtent(start_time=dt(2005,1,10), end_time=dt(2008,1,1))
+               >>> inter = A.disjoint_union(B)
+               >>> inter.print_info()
+                +-------------------- Absolute time -----------------------------------------+
+                | Start time:................. 2001-01-10 00:00:00
+                | End time:................... 2008-01-01 00:00:00
 
-           >>> inter = B.disjoint_union(A)
-           >>> inter.print_info()
-            +-------------------- Absolute time -----------------------------------------+
-            | Start time:................. 2001-01-10 00:00:00
-            | End time:................... 2008-01-01 00:00:00
+               >>> inter = B.disjoint_union(A)
+               >>> inter.print_info()
+                +-------------------- Absolute time -----------------------------------------+
+                | Start time:................. 2001-01-10 00:00:00
+                | End time:................... 2008-01-01 00:00:00
 
-           @endcoe
         """
 
         start = None
@@ -388,28 +383,28 @@
             return TemporalExtent(start_time=start, end_time=end)
 
     def union(self, extent):
-        """!Creates a union with this temporal extent and the provided one.
+        """Creates a union with this temporal extent and the provided one.
            Return a new temporal extent with the new start and end time.
 
-           @param extent The temporal extent to create a union with
-           @return The new temporal extent with start and end time,
-                   or None in case the temporal extents are unrelated (before or after)
+           :param extent: The temporal extent to create a union with
+           :return: The new temporal extent with start and end time,
+                    or None in case the temporal extents are unrelated
+                    (before or after)
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=4 )
-           >>> inter = A.intersect(B)
-           >>> print inter
-           None
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=4 )
+               >>> inter = A.intersect(B)
+               >>> print inter
+               None
 
-           >>> A = TemporalExtent(start_time=5, end_time=8 )
-           >>> B = TemporalExtent(start_time=3, end_time=None )
-           >>> inter = A.intersect(B)
-           >>> print inter
-           None
+               >>> A = TemporalExtent(start_time=5, end_time=8 )
+               >>> B = TemporalExtent(start_time=3, end_time=None )
+               >>> inter = A.intersect(B)
+               >>> print inter
+               None
 
-           @endcode
         """
 
         relation = self.temporal_relation(extent)
@@ -420,29 +415,30 @@
         return self.disjoint_union(extent)
 
     def starts(self, extent):
-        """!Return True if this temporal extent (A) starts at the start of the
+        """Return True if this temporal extent (A) starts at the start of the
            provided temporal extent (B) and finishes within it
-           @verbatim
-           A  |-----|
-           B  |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object with which this extent starts
+               A  |-----|
+               B  |---------|
 
+
+           :param extent: The temporal extent object with which this extent
+                          starts
+
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=6 )
-           >>> B = TemporalExtent(start_time=5, end_time=7 )
-           >>> A.starts(B)
-           True
-           >>> B.starts(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=6 )
+               >>> B = TemporalExtent(start_time=5, end_time=7 )
+               >>> A.starts(B)
+               True
+               >>> B.starts(A)
+               False
 
-           @endcode
         """
-        if  self.D["end_time"] is None or extent.D["end_time"] is None:
+        if self.D["end_time"] is None or extent.D["end_time"] is None:
             return False
 
         if self.D["start_time"] == extent.D["start_time"] and \
@@ -452,29 +448,29 @@
             return False
 
     def started(self, extent):
-        """!Return True if this temporal extent (A) started at the start of the
+        """Return True if this temporal extent (A) started at the start of the
            provided temporal extent (B) and finishes after it
-           @verbatim
-           A  |---------|
-           B  |-----|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object with which this extent started
+               A  |---------|
+               B  |-----|
 
+           :param extent: The temporal extent object with which this extent
+                          started
+
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=5, end_time=6 )
-           >>> A.started(B)
-           True
-           >>> B.started(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=5, end_time=6 )
+               >>> A.started(B)
+               True
+               >>> B.started(A)
+               False
 
-           @endcode
         """
-        if  self.D["end_time"] is None or extent.D["end_time"] is None:
+        if self.D["end_time"] is None or extent.D["end_time"] is None:
             return False
 
         if self.D["start_time"] == extent.D["start_time"] and \
@@ -484,29 +480,29 @@
             return False
 
     def finishes(self, extent):
-        """!Return True if this temporal extent (A) starts after the start of the
-           provided temporal extent (B) and finishes with it
-           @verbatim
-           A      |-----|
-           B  |---------|
-           @endverbatim
+        """Return True if this temporal extent (A) starts after the start of
+           the provided temporal extent (B) and finishes with it
+           ::
 
-           @param extent The temporal extent object with which this extent finishes
+               A      |-----|
+               B  |---------|
 
+           :param extent: The temporal extent object with which this extent
+                          finishes
+
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=6, end_time=7 )
-           >>> B = TemporalExtent(start_time=5, end_time=7 )
-           >>> A.finishes(B)
-           True
-           >>> B.finishes(A)
-           False
+               >>> A = TemporalExtent(start_time=6, end_time=7 )
+               >>> B = TemporalExtent(start_time=5, end_time=7 )
+               >>> A.finishes(B)
+               True
+               >>> B.finishes(A)
+               False
 
-           @endcode
         """
-        if  self.D["end_time"] is None or extent.D["end_time"] is None:
+        if self.D["end_time"] is None or extent.D["end_time"] is None:
             return False
 
         if self.D["end_time"] == extent.D["end_time"] and \
@@ -516,29 +512,29 @@
             return False
 
     def finished(self, extent):
-        """!Return True if this temporal extent (A) starts before the start of the
-           provided temporal extent (B) and finishes with it
-           @verbatim
-           A  |---------|
-           B      |-----|
-           @endverbatim
+        """Return True if this temporal extent (A) starts before the start of
+           the provided temporal extent (B) and finishes with it
+           ::
 
-           @param extent The temporal extent object with which this extent finishes
+               A  |---------|
+               B      |-----|
 
+           :param extent: The temporal extent object with which this extent
+                          finishes
+
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=6, end_time=7 )
-           >>> A.finished(B)
-           True
-           >>> B.finished(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=6, end_time=7 )
+               >>> A.finished(B)
+               True
+               >>> B.finished(A)
+               False
 
-           @endcode
         """
-        if  self.D["end_time"] is None or extent.D["end_time"] is None:
+        if self.D["end_time"] is None or extent.D["end_time"] is None:
             return False
 
         if self.D["end_time"] == extent.D["end_time"] and \
@@ -548,27 +544,27 @@
             return False
 
     def after(self, extent):
-        """!Return True if this temporal extent (A) is located after the
+        """Return True if this temporal extent (A) is located after the
            provided temporal extent (B)
-           @verbatim
-           A             |---------|
-           B  |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is located before this extent
+               A             |---------|
+               B  |---------|
 
+           :param extent: The temporal extent object that is located before
+                          this extent
+
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=8, end_time=9 )
-           >>> B = TemporalExtent(start_time=6, end_time=7 )
-           >>> A.after(B)
-           True
-           >>> B.after(A)
-           False
+               >>> A = TemporalExtent(start_time=8, end_time=9 )
+               >>> B = TemporalExtent(start_time=6, end_time=7 )
+               >>> A.after(B)
+               True
+               >>> B.after(A)
+               False
 
-           @endcode
         """
         if extent.D["end_time"] is None:
             if self.D["start_time"] > extent.D["start_time"]:
@@ -582,27 +578,27 @@
             return False
 
     def before(self, extent):
-        """!Return True if this temporal extent (A) is located before the
+        """Return True if this temporal extent (A) is located before the
            provided temporal extent (B)
-           @verbatim
-           A  |---------|
-           B             |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is located after this extent
+               A  |---------|
+               B             |---------|
 
+           :param extent: The temporal extent object that is located after
+                          this extent
+
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=6, end_time=7 )
-           >>> B = TemporalExtent(start_time=8, end_time=9 )
-           >>> A.before(B)
-           True
-           >>> B.before(A)
-           False
+               >>> A = TemporalExtent(start_time=6, end_time=7 )
+               >>> B = TemporalExtent(start_time=8, end_time=9 )
+               >>> A.before(B)
+               True
+               >>> B.before(A)
+               False
 
-           @endcode
         """
         if self.D["end_time"] is None:
             if self.D["start_time"] < extent.D["start_time"]:
@@ -616,38 +612,37 @@
             return False
 
     def adjacent(self, extent):
-        """!Return True if this temporal extent (A) is a meeting neighbor the
+        """Return True if this temporal extent (A) is a meeting neighbor the
            provided temporal extent (B)
-           @verbatim
-           A            |---------|
-           B  |---------|
-           A  |---------|
-           B            |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is a meeting neighbor
+               A            |---------|
+               B  |---------|
+               A  |---------|
+               B            |---------|
+
+           :param extent: The temporal extent object that is a meeting neighbor
                           of this extent
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=7, end_time=9 )
-           >>> A.adjacent(B)
-           True
-           >>> B.adjacent(A)
-           True
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=3, end_time=5 )
-           >>> A.adjacent(B)
-           True
-           >>> B.adjacent(A)
-           True
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=7, end_time=9 )
+               >>> A.adjacent(B)
+               True
+               >>> B.adjacent(A)
+               True
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=3, end_time=5 )
+               >>> A.adjacent(B)
+               True
+               >>> B.adjacent(A)
+               True
 
-           @endcode
         """
-        if  self.D["end_time"] is None and extent.D["end_time"] is None:
+        if self.D["end_time"] is None and extent.D["end_time"] is None:
             return False
 
         if (self.D["start_time"] == extent.D["end_time"]) or \
@@ -657,30 +652,29 @@
             return False
 
     def follows(self, extent):
-        """!Return True if this temporal extent (A) follows the
+        """Return True if this temporal extent (A) follows the
            provided temporal extent (B)
-           @verbatim
-           A            |---------|
-           B  |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is the predecessor
+               A            |---------|
+               B  |---------|
+
+           :param extent: The temporal extent object that is the predecessor
                           of this extent
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=3, end_time=5 )
-           >>> A.follows(B)
-           True
-           >>> B.follows(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=3, end_time=5 )
+               >>> A.follows(B)
+               True
+               >>> B.follows(A)
+               False
 
-           @endcode
         """
-        if  extent.D["end_time"] is None:
+        if extent.D["end_time"] is None:
             return False
 
         if self.D["start_time"] == extent.D["end_time"]:
@@ -689,30 +683,31 @@
             return False
 
     def precedes(self, extent):
-        """!Return True if this temporal extent (A) precedes the provided
+        """Return True if this temporal extent (A) precedes the provided
            temporal extent (B)
-           @verbatim
-           A  |---------|
-           B            |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is the successor
+               A  |---------|
+               B            |---------|
+
+
+           :param extent: The temporal extent object that is the successor
                           of this extent
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=7, end_time=9 )
-           >>> A.precedes(B)
-           True
-           >>> B.precedes(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=7, end_time=9 )
+               >>> A.precedes(B)
+               True
+               >>> B.precedes(A)
+               False
 
-           @endcode
+
         """
-        if  self.D["end_time"] is None:
+        if self.D["end_time"] is None:
             return False
 
         if self.D["end_time"] == extent.D["start_time"]:
@@ -721,34 +716,33 @@
             return False
 
     def during(self, extent):
-        """!Return True if this temporal extent (A) is located during the provided
+        """Return True if this temporal extent (A) is located during the provided
            temporal extent (B)
-           @verbatim
-           A   |-------|
-           B  |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that contains this extent
+               A   |-------|
+               B  |---------|
 
+           :param extent: The temporal extent object that contains this extent
+
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=4, end_time=9 )
-           >>> A.during(B)
-           True
-           >>> B.during(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=4, end_time=9 )
+               >>> A.during(B)
+               True
+               >>> B.during(A)
+               False
 
-           @endcode
         """
         # Check single point of time in interval
-        if  extent.D["end_time"] is None:
+        if extent.D["end_time"] is None:
             return False
 
         # Check single point of time in interval
-        if  self.D["end_time"] is None:
+        if self.D["end_time"] is None:
             if self.D["start_time"] >= extent.D["start_time"] and \
                self.D["start_time"] < extent.D["end_time"]:
                 return True
@@ -762,35 +756,34 @@
             return False
 
     def contains(self, extent):
-        """!Return True if this temporal extent (A) contains the provided
+        """Return True if this temporal extent (A) contains the provided
            temporal extent (B)
-           @verbatim
-           A  |---------|
-           B   |-------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is located
+               A  |---------|
+               B   |-------|
+
+           :param extent: The temporal extent object that is located
                           during this extent
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=4, end_time=9 )
-           >>> B = TemporalExtent(start_time=5, end_time=8 )
-           >>> A.contains(B)
-           True
-           >>> B.contains(A)
-           False
+               >>> A = TemporalExtent(start_time=4, end_time=9 )
+               >>> B = TemporalExtent(start_time=5, end_time=8 )
+               >>> A.contains(B)
+               True
+               >>> B.contains(A)
+               False
 
-           @endcode
         """
         # Check single point of time in interval
-        if  self.D["end_time"] is None:
+        if self.D["end_time"] is None:
             return False
 
         # Check single point of time in interval
-        if  extent.D["end_time"] is None:
+        if extent.D["end_time"] is None:
             if self.D["start_time"] <= extent.D["start_time"] and \
                self.D["end_time"] > extent.D["start_time"]:
                 return True
@@ -804,36 +797,35 @@
             return False
 
     def equal(self, extent):
-        """!Return True if this temporal extent (A) is equal to the provided
+        """Return True if this temporal extent (A) is equal to the provided
            temporal extent (B)
-           @verbatim
-           A  |---------|
-           B  |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is equal
+               A  |---------|
+               B  |---------|
+
+           :param extent: The temporal extent object that is equal
                           during this extent
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=6 )
-           >>> B = TemporalExtent(start_time=5, end_time=6 )
-           >>> A.equal(B)
-           True
-           >>> B.equal(A)
-           True
+               >>> A = TemporalExtent(start_time=5, end_time=6 )
+               >>> B = TemporalExtent(start_time=5, end_time=6 )
+               >>> A.equal(B)
+               True
+               >>> B.equal(A)
+               True
 
-           @endcode
         """
-        if  self.D["end_time"] is None and extent.D["end_time"] is None:
+        if self.D["end_time"] is None and extent.D["end_time"] is None:
             if self.D["start_time"] == extent.D["start_time"]:
                 return True
             else:
                 return False
 
-        if  self.D["end_time"] is None or extent.D["end_time"] is None:
+        if self.D["end_time"] is None or extent.D["end_time"] is None:
             return False
 
         if self.D["start_time"] == extent.D["start_time"] and \
@@ -843,36 +835,36 @@
             return False
 
     def overlaps(self, extent):
-        """!Return True if this temporal extent (A) overlapped the provided
+        """Return True if this temporal extent (A) overlapped the provided
            temporal extent (B)
-           @verbatim
-           A  |---------|
-           B    |---------|
-           @endverbatim
-           @param extent The temporal extent object that is overlaps
+           ::
+
+               A  |---------|
+               B    |---------|
+
+           :param extent: The temporal extent object that is overlaps
                           this extent
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=5, end_time=7 )
-           >>> B = TemporalExtent(start_time=6, end_time=8 )
-           >>> A.overlaps(B)
-           True
-           >>> B.overlaps(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=7 )
+               >>> B = TemporalExtent(start_time=6, end_time=8 )
+               >>> A.overlaps(B)
+               True
+               >>> B.overlaps(A)
+               False
 
-           >>> A = TemporalExtent(start_time=5, end_time=6 )
-           >>> B = TemporalExtent(start_time=6, end_time=8 )
-           >>> A.overlaps(B)
-           False
-           >>> B.overlaps(A)
-           False
+               >>> A = TemporalExtent(start_time=5, end_time=6 )
+               >>> B = TemporalExtent(start_time=6, end_time=8 )
+               >>> A.overlaps(B)
+               False
+               >>> B.overlaps(A)
+               False
 
-           @endcode
         """
-        if  self.D["end_time"] is None or extent.D["end_time"] is None:
+        if self.D["end_time"] is None or extent.D["end_time"] is None:
             return False
 
         if self.D["start_time"] < extent.D["start_time"] and \
@@ -883,37 +875,37 @@
             return False
 
     def overlapped(self, extent):
-        """!Return True if this temporal extent (A) overlapps the provided
+        """Return True if this temporal extent (A) overlapps the provided
            temporal extent (B)
-           @verbatim
-           A    |---------|
-           B  |---------|
-           @endverbatim
+           ::
 
-           @param extent The temporal extent object that is overlapped
+               A    |---------|
+               B  |---------|
+
+
+           :param extent: The temporal extent object that is overlapped
                           this extent
 
            Usage:
 
-           @code
+           .. code-block:: python
 
-           >>> A = TemporalExtent(start_time=6, end_time=8 )
-           >>> B = TemporalExtent(start_time=5, end_time=7 )
-           >>> A.overlapped(B)
-           True
-           >>> B.overlapped(A)
-           False
+               >>> A = TemporalExtent(start_time=6, end_time=8 )
+               >>> B = TemporalExtent(start_time=5, end_time=7 )
+               >>> A.overlapped(B)
+               True
+               >>> B.overlapped(A)
+               False
 
-           >>> A = TemporalExtent(start_time=6, end_time=8 )
-           >>> B = TemporalExtent(start_time=5, end_time=6 )
-           >>> A.overlapped(B)
-           False
-           >>> B.overlapped(A)
-           False
+               >>> A = TemporalExtent(start_time=6, end_time=8 )
+               >>> B = TemporalExtent(start_time=5, end_time=6 )
+               >>> A.overlapped(B)
+               False
+               >>> B.overlapped(A)
+               False
 
-           @endcode
         """
-        if  self.D["end_time"] is None or extent.D["end_time"] is None:
+        if self.D["end_time"] is None or extent.D["end_time"] is None:
             return False
 
         if self.D["start_time"] > extent.D["start_time"] and \
@@ -924,28 +916,29 @@
             return False
 
     def temporal_relation(self, extent):
-        """!Returns the temporal relation between temporal objects
-           Temporal relationships are implemented after
-           [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic]
+        """Returns the temporal relation between temporal objects
+        Temporal relationships are implemented after
+        [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic]
 
-           The following temporal relationships are supported:
+        The following temporal relationships are supported:
 
-               - equal
-               - during
-               - contains
-               - overlaps
-               - overlapped
-               - after
-               - before
-               - starts
-               - finishes
-               - started
-               - finished
-               - follows
-               - precedes
+            - equal
+            - during
+            - contains
+            - overlaps
+            - overlapped
+            - after
+            - before
+            - starts
+            - finishes
+            - started
+            - finished
+            - follows
+            - precedes
 
-           @param extent The temporal extent
-           @return The name of the temporal relation or None if no relation found
+        :param extent: The temporal extent
+        :return: The name of the temporal relation or None if no relation
+                 found
         """
 
         # First check for correct time
@@ -990,21 +983,21 @@
         return None
 
     def set_id(self, ident):
-        """!Convenient method to set the unique identifier (primary key)"""
+        """Convenient method to set the unique identifier (primary key)"""
         self.ident = ident
         self.D["id"] = ident
 
     def set_start_time(self, start_time):
-        """!Set the valid start time of the extent"""
+        """Set the valid start time of the extent"""
         self.D["start_time"] = start_time
 
     def set_end_time(self, end_time):
-        """!Set the valid end time of the extent"""
+        """Set the valid end time of the extent"""
         self.D["end_time"] = end_time
 
     def get_id(self):
-        """!Convenient method to get the unique identifier (primary key)
-           @return None if not found
+        """Convenient method to get the unique identifier (primary key)
+           :return: None if not found
         """
         if "id" in self.D:
             return self.D["id"]
@@ -1012,16 +1005,16 @@
             return None
 
     def get_start_time(self):
-        """!Get the valid start time of the extent
-           @return None if not found"""
+        """Get the valid start time of the extent
+           :return: None if not found"""
         if "start_time" in self.D:
             return self.D["start_time"]
         else:
             return None
 
     def get_end_time(self):
-        """!Get the valid end time of the extent
-           @return None if not found"""
+        """Get the valid end time of the extent
+           :return: None if not found"""
         if "end_time" in self.D:
             return self.D["end_time"]
         else:
@@ -1033,13 +1026,13 @@
     end_time = property(fget=get_end_time, fset=set_end_time)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " | Start time:................. " + str(self.get_start_time())
         print " | End time:................... " + str(self.get_end_time())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         print "start_time=" + str(self.get_start_time())
         print "end_time=" + str(self.get_end_time())
 
@@ -1047,7 +1040,7 @@
 
 
 class AbsoluteTemporalExtent(TemporalExtent):
-    """!This is the absolute time class for all maps and spacetime datasets
+    """This is the absolute time class for all maps and spacetime datasets
 
         start_time and end_time must be of type datetime
     """
@@ -1057,72 +1050,75 @@
             self, table, ident, start_time, end_time)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " +-------------------- Absolute time -----------------------------------------+"
         TemporalExtent.print_info(self)
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         TemporalExtent.print_shell_info(self)
 
 ###############################################################################
 
+
 class RasterAbsoluteTime(AbsoluteTemporalExtent):
     def __init__(self, ident=None, start_time=None, end_time=None):
         AbsoluteTemporalExtent.__init__(self, "raster_absolute_time",
-            ident, start_time, end_time)
+                                        ident, start_time, end_time)
 
+
 class Raster3DAbsoluteTime(AbsoluteTemporalExtent):
     def __init__(self, ident=None, start_time=None, end_time=None):
         AbsoluteTemporalExtent.__init__(self, "raster3d_absolute_time",
-            ident, start_time, end_time)
+                                        ident, start_time, end_time)
 
+
 class VectorAbsoluteTime(AbsoluteTemporalExtent):
     def __init__(self, ident=None, start_time=None, end_time=None):
         AbsoluteTemporalExtent.__init__(self, "vector_absolute_time",
-            ident, start_time, end_time)
+                                        ident, start_time, end_time)
 
 ###############################################################################
 
+
 class STDSAbsoluteTime(AbsoluteTemporalExtent):
-    """!This class implements the absolute time extent for space time dataset
+    """This class implements the absolute time extent for space time dataset
 
         In addition to the existing functionality the granularity and the
         map_time are added.
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> A = STDSAbsoluteTime(table="strds_absolute_time",
-        ... ident="strds at PERMANENT", start_time=datetime(2001, 01, 01),
-        ... end_time=datetime(2005,01,01), granularity="1 days",
-        ... map_time="interval")
-        >>> A.id
-        'strds at PERMANENT'
-        >>> A.start_time
-        datetime.datetime(2001, 1, 1, 0, 0)
-        >>> A.end_time
-        datetime.datetime(2005, 1, 1, 0, 0)
-        >>> A.granularity
-        '1 days'
-        >>> A.map_time
-        'interval'
-        >>> A.print_info()
-         +-------------------- Absolute time -----------------------------------------+
-         | Start time:................. 2001-01-01 00:00:00
-         | End time:................... 2005-01-01 00:00:00
-         | Granularity:................ 1 days
-         | Temporal type of maps:...... interval
-        >>> A.print_shell_info()
-        start_time=2001-01-01 00:00:00
-        end_time=2005-01-01 00:00:00
-        granularity=1 days
-        map_time=interval
+            >>> init()
+            >>> A = STDSAbsoluteTime(table="strds_absolute_time",
+            ... ident="strds at PERMANENT", start_time=datetime(2001, 01, 01),
+            ... end_time=datetime(2005,01,01), granularity="1 days",
+            ... map_time="interval")
+            >>> A.id
+            'strds at PERMANENT'
+            >>> A.start_time
+            datetime.datetime(2001, 1, 1, 0, 0)
+            >>> A.end_time
+            datetime.datetime(2005, 1, 1, 0, 0)
+            >>> A.granularity
+            '1 days'
+            >>> A.map_time
+            'interval'
+            >>> A.print_info()
+             +-------------------- Absolute time -----------------------------------------+
+             | Start time:................. 2001-01-01 00:00:00
+             | End time:................... 2005-01-01 00:00:00
+             | Granularity:................ 1 days
+             | Temporal type of maps:...... interval
+            >>> A.print_shell_info()
+            start_time=2001-01-01 00:00:00
+            end_time=2005-01-01 00:00:00
+            granularity=1 days
+            map_time=interval
 
-        @endcode
     """
     def __init__(self, table=None, ident=None, start_time=None, end_time=None,
                  granularity=None, map_time=None):
@@ -1133,13 +1129,14 @@
         self.set_map_time(map_time)
 
     def set_granularity(self, granularity):
-        """!Set the granularity of the space time dataset"""
+        """Set the granularity of the space time dataset"""
         self.D["granularity"] = granularity
 
     def set_map_time(self, map_time):
-        """!Set the type of the map time
+        """Set the type of the map time
 
            Registered maps may have different types of time:
+
            - Single point of time "point"
            - Time intervals "interval"
            - Single point and interval time "mixed"
@@ -1149,21 +1146,22 @@
         self.D["map_time"] = map_time
 
     def get_granularity(self):
-        """!Get the granularity of the space time dataset
-           @return None if not found"""
+        """Get the granularity of the space time dataset
+           :return: None if not found"""
         if "granularity" in self.D:
             return self.D["granularity"]
         else:
             return None
 
     def get_map_time(self):
-        """!Get the type of the map time
+        """Get the type of the map time
 
            Registered maps may have different types of time:
-           Single point of time "point"
-           Time intervals "interval"
-           Or single point and interval time "mixed"
 
+           - Single point of time "point"
+           - Time intervals "interval"
+           - Single point and interval time "mixed"
+
            This variable will be set automatically when maps are registered.
         """
         if "map_time" in self.D:
@@ -1176,73 +1174,74 @@
     map_time = property(fget=get_map_time, fset=set_map_time)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         AbsoluteTemporalExtent.print_info(self)
         #      0123456789012345678901234567890
         print " | Granularity:................ " + str(self.get_granularity())
         print " | Temporal type of maps:...... " + str(self.get_map_time())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         AbsoluteTemporalExtent.print_shell_info(self)
         print "granularity=" + str(self.get_granularity())
         print "map_time=" + str(self.get_map_time())
 
 ###############################################################################
 
+
 class STRDSAbsoluteTime(STDSAbsoluteTime):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  granularity=None):
         STDSAbsoluteTime.__init__(self, "strds_absolute_time",
-            ident, start_time, end_time, granularity)
+                                  ident, start_time, end_time, granularity)
 
 
 class STR3DSAbsoluteTime(STDSAbsoluteTime):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  granularity=None):
         STDSAbsoluteTime.__init__(self, "str3ds_absolute_time",
-            ident, start_time, end_time, granularity)
+                                  ident, start_time, end_time, granularity)
 
 
 class STVDSAbsoluteTime(STDSAbsoluteTime):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  granularity=None):
         STDSAbsoluteTime.__init__(self, "stvds_absolute_time",
-            ident, start_time, end_time, granularity)
+                                  ident, start_time, end_time, granularity)
 
 ###############################################################################
 
+
 class RelativeTemporalExtent(TemporalExtent):
-    """!This is the relative time class for all maps and space time datasets
+    """This is the relative time class for all maps and space time datasets
 
         start_time and end_time must be of type integer
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> A = RelativeTemporalExtent(table="raster_relative_time",
-        ... ident="soil at PERMANENT", start_time=0, end_time=1, unit="years")
-        >>> A.id
-        'soil at PERMANENT'
-        >>> A.start_time
-        0
-        >>> A.end_time
-        1
-        >>> A.unit
-        'years'
-        >>> A.print_info()
-         +-------------------- Relative time -----------------------------------------+
-         | Start time:................. 0
-         | End time:................... 1
-         | Relative time unit:......... years
-        >>> A.print_shell_info()
-        start_time=0
-        end_time=1
-        unit=years
+            >>> init()
+            >>> A = RelativeTemporalExtent(table="raster_relative_time",
+            ... ident="soil at PERMANENT", start_time=0, end_time=1, unit="years")
+            >>> A.id
+            'soil at PERMANENT'
+            >>> A.start_time
+            0
+            >>> A.end_time
+            1
+            >>> A.unit
+            'years'
+            >>> A.print_info()
+             +-------------------- Relative time -----------------------------------------+
+             | Start time:................. 0
+             | End time:................... 1
+             | Relative time unit:......... years
+            >>> A.print_shell_info()
+            start_time=0
+            end_time=1
+            unit=years
 
-        @endcode
     """
     def __init__(self, table=None, ident=None, start_time=None, end_time=None,
                  unit=None):
@@ -1252,7 +1251,7 @@
         self.set_unit(unit)
 
     def set_unit(self, unit):
-        """!Set the unit of the relative time. Valid units are:
+        """Set the unit of the relative time. Valid units are:
 
            - years
            - months
@@ -1264,15 +1263,15 @@
         self.D["unit"] = unit
 
     def get_unit(self):
-        """!Get the unit of the relative time
-           @return None if not found"""
+        """Get the unit of the relative time
+           :return: None if not found"""
         if "unit" in self.D:
             return self.D["unit"]
         else:
             return None
 
     def temporal_relation(self, map):
-        """!Returns the temporal relation between temporal objects
+        """Returns the temporal relation between temporal objects
            Temporal relationships are implemented after
            [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic]
         """
@@ -1293,31 +1292,32 @@
     unit = property(fget=get_unit, fset=set_unit)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         #      0123456789012345678901234567890
         print " +-------------------- Relative time -----------------------------------------+"
         TemporalExtent.print_info(self)
         print " | Relative time unit:......... " + str(self.get_unit())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         TemporalExtent.print_shell_info(self)
         print "unit=" + str(self.get_unit())
 
 ###############################################################################
 
+
 class RasterRelativeTime(RelativeTemporalExtent):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  unit=None):
-        RelativeTemporalExtent.__init__(
-            self, "raster_relative_time", ident, start_time, end_time, unit)
+        RelativeTemporalExtent.__init__(self, "raster_relative_time", ident,
+                                        start_time, end_time, unit)
 
 
 class Raster3DRelativeTime(RelativeTemporalExtent):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  unit=None):
-        RelativeTemporalExtent.__init__(self,
-            "raster3d_relative_time", ident, start_time, end_time, unit)
+        RelativeTemporalExtent.__init__(self, "raster3d_relative_time", ident,
+                                        start_time, end_time, unit)
 
 
 class VectorRelativeTime(RelativeTemporalExtent):
@@ -1328,46 +1328,46 @@
 
 ###############################################################################
 
+
 class STDSRelativeTime(RelativeTemporalExtent):
-    """!This is the relative time class for all maps and space time datasets
+    """This is the relative time class for all maps and space time datasets
 
         start_time and end_time must be of type integer
 
         Usage:
 
-        @code
+        .. code-block:: python
 
-        >>> init()
-        >>> A = STDSRelativeTime(table="strds_relative_time",
-        ... ident="strds at PERMANENT", start_time=0, end_time=1, unit="years",
-        ... granularity=5, map_time="interval")
-        >>> A.id
-        'strds at PERMANENT'
-        >>> A.start_time
-        0
-        >>> A.end_time
-        1
-        >>> A.unit
-        'years'
-        >>> A.granularity
-        5
-        >>> A.map_time
-        'interval'
-        >>> A.print_info()
-         +-------------------- Relative time -----------------------------------------+
-         | Start time:................. 0
-         | End time:................... 1
-         | Relative time unit:......... years
-         | Granularity:................ 5
-         | Temporal type of maps:...... interval
-        >>> A.print_shell_info()
-        start_time=0
-        end_time=1
-        unit=years
-        granularity=5
-        map_time=interval
+            >>> init()
+            >>> A = STDSRelativeTime(table="strds_relative_time",
+            ... ident="strds at PERMANENT", start_time=0, end_time=1, unit="years",
+            ... granularity=5, map_time="interval")
+            >>> A.id
+            'strds at PERMANENT'
+            >>> A.start_time
+            0
+            >>> A.end_time
+            1
+            >>> A.unit
+            'years'
+            >>> A.granularity
+            5
+            >>> A.map_time
+            'interval'
+            >>> A.print_info()
+             +-------------------- Relative time -----------------------------------------+
+             | Start time:................. 0
+             | End time:................... 1
+             | Relative time unit:......... years
+             | Granularity:................ 5
+             | Temporal type of maps:...... interval
+            >>> A.print_shell_info()
+            start_time=0
+            end_time=1
+            unit=years
+            granularity=5
+            map_time=interval
 
-        @endcode
     """
     def __init__(self, table=None, ident=None, start_time=None, end_time=None,
                  unit=None, granularity=None, map_time=None):
@@ -1378,37 +1378,39 @@
         self.set_map_time(map_time)
 
     def set_granularity(self, granularity):
-        """!Set the granularity of the space time dataset"""
+        """Set the granularity of the space time dataset"""
         self.D["granularity"] = granularity
 
     def set_map_time(self, map_time):
-        """!Set the type of the map time
+        """Set the type of the map time
 
            Registered maps may have different types of time:
-           Single point of time "point"
-           Time intervals "interval"
-           Or single point and interval time "mixed"
 
+           - Single point of time "point"
+           - Time intervals "interval"
+           - Single point and interval time "mixed"
+
            This variable will be set automatically when maps are registered.
         """
         self.D["map_time"] = map_time
 
     def get_granularity(self):
-        """!Get the granularity of the space time dataset
-           @return None if not found"""
+        """Get the granularity of the space time dataset
+           :return: None if not found"""
         if "granularity" in self.D:
             return self.D["granularity"]
         else:
             return None
 
     def get_map_time(self):
-        """!Get the type of the map time
+        """Get the type of the map time
 
            Registered maps may have different types of time:
-           Single point of time "point"
-           Time intervals "interval"
-           Or single point and interval time "mixed"
 
+           - Single point of time "point"
+           - Time intervals "interval"
+           - Single point and interval time "mixed"
+
            This variable will be set automatically when maps are registered.
         """
         if "map_time" in self.D:
@@ -1421,39 +1423,43 @@
     map_time = property(fget=get_map_time, fset=set_map_time)
 
     def print_info(self):
-        """!Print information about this class in human readable style"""
+        """Print information about this class in human readable style"""
         RelativeTemporalExtent.print_info(self)
         #      0123456789012345678901234567890
         print " | Granularity:................ " + str(self.get_granularity())
         print " | Temporal type of maps:...... " + str(self.get_map_time())
 
     def print_shell_info(self):
-        """!Print information about this class in shell style"""
+        """Print information about this class in shell style"""
         RelativeTemporalExtent.print_shell_info(self)
         print "granularity=" + str(self.get_granularity())
         print "map_time=" + str(self.get_map_time())
 
 ###############################################################################
 
+
 class STRDSRelativeTime(STDSRelativeTime):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  unit=None, granularity=None, map_time=None):
-        STDSRelativeTime.__init__(self, "strds_relative_time",
-            ident, start_time, end_time, unit, granularity, map_time)
+        STDSRelativeTime.__init__(self, "strds_relative_time", ident,
+                                  start_time, end_time, unit, granularity,
+                                  map_time)
 
 
 class STR3DSRelativeTime(STDSRelativeTime):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  unit=None, granularity=None, map_time=None):
-        STDSRelativeTime.__init__(self, "str3ds_relative_time",
-            ident, start_time, end_time, unit, granularity, map_time)
+        STDSRelativeTime.__init__(self, "str3ds_relative_time", ident,
+                                  start_time, end_time, unit, granularity,
+                                  map_time)
 
 
 class STVDSRelativeTime(STDSRelativeTime):
     def __init__(self, ident=None, start_time=None, end_time=None,
                  unit=None, granularity=None, map_time=None):
-        STDSRelativeTime.__init__(self, "stvds_relative_time",
-            ident, start_time, end_time, unit, granularity, map_time)
+        STDSRelativeTime.__init__(self, "stvds_relative_time", ident,
+                                  start_time, end_time, unit, granularity,
+                                  map_time)
 
 ###############################################################################
 

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_granularity.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_granularity.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_granularity.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,75 +1,73 @@
-"""!@package grass.temporal
+"""
+Functions to compute the temporal granularity of a map list
 
- at brief GRASS Python scripting module (temporal GIS functions)
+Usage:
 
-Temporal GIS related functions to be used in temporal GIS Python library package.
+.. code-block:: python
 
-Usage:
+    import grass.temporal as tgis
 
- at code
-import grass.temporal as tgis
+    tgis.compute_relative_time_granularity(maps)
 
-tgis.compute_relative_time_granularity(maps)
-...
- at endcode
 
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 from abstract_dataset import *
 from datetime_math import *
 
 ###############################################################################
 
+
 def check_granularity_string(granularity, temporal_type):
-    """!Check if the granularity string is valid
+    """Check if the granularity string is valid
 
-        @param granularity The granularity string
-        @param temporal_type The temporal type of the granularity relative or absolute
-        @return True if valid, False if invalid
+        :param granularity: The granularity string
+        :param temporal_type: The temporal type of the granularity relative or
+                              absolute
+        :return: True if valid, False if invalid
 
-        @code
+        .. code-block:: python
 
-        >>> check_granularity_string("1 year", "absolute")
-        True
-        >>> check_granularity_string("1 month", "absolute")
-        True
-        >>> check_granularity_string("1 day", "absolute")
-        True
-        >>> check_granularity_string("1 minute", "absolute")
-        True
-        >>> check_granularity_string("1 hour", "absolute")
-        True
-        >>> check_granularity_string("1 second", "absolute")
-        True
-        >>> check_granularity_string("5 months", "absolute")
-        True
-        >>> check_granularity_string("5 days", "absolute")
-        True
-        >>> check_granularity_string("5 minutes", "absolute")
-        True
-        >>> check_granularity_string("5 years", "absolute")
-        True
-        >>> check_granularity_string("5 hours", "absolute")
-        True
-        >>> check_granularity_string("2 seconds", "absolute")
-        True
-        >>> check_granularity_string("1 secondo", "absolute")
-        False
-        >>> check_granularity_string("bla second", "absolute")
-        False
-        >>> check_granularity_string("bla", "absolute")
-        False
-        >>> check_granularity_string(1, "relative")
-        True
-        >>> check_granularity_string("bla", "relative")
-        False
+            >>> check_granularity_string("1 year", "absolute")
+            True
+            >>> check_granularity_string("1 month", "absolute")
+            True
+            >>> check_granularity_string("1 day", "absolute")
+            True
+            >>> check_granularity_string("1 minute", "absolute")
+            True
+            >>> check_granularity_string("1 hour", "absolute")
+            True
+            >>> check_granularity_string("1 second", "absolute")
+            True
+            >>> check_granularity_string("5 months", "absolute")
+            True
+            >>> check_granularity_string("5 days", "absolute")
+            True
+            >>> check_granularity_string("5 minutes", "absolute")
+            True
+            >>> check_granularity_string("5 years", "absolute")
+            True
+            >>> check_granularity_string("5 hours", "absolute")
+            True
+            >>> check_granularity_string("2 seconds", "absolute")
+            True
+            >>> check_granularity_string("1 secondo", "absolute")
+            False
+            >>> check_granularity_string("bla second", "absolute")
+            False
+            >>> check_granularity_string("bla", "absolute")
+            False
+            >>> check_granularity_string(1, "relative")
+            True
+            >>> check_granularity_string("bla", "relative")
+            False
 
-        @endcode
     """
     temporal_type
 
@@ -102,113 +100,124 @@
 
 ###############################################################################
 
+
 def compute_relative_time_granularity(maps):
-    """!Compute the relative time granularity
+    """Compute the relative time granularity
 
         Attention: The computation of the granularity
         is only correct in case of not overlapping intervals.
         Hence a correct temporal topology is required for computation.
 
-        @param maps a ordered by start_time list of map objects
-        @return An integer
+        :param maps: a ordered by start_time list of map objects
+        :return: An integer
 
 
-        @code
+        .. code-block:: python
 
-        >>> import grass.temporal as tgis
-        >>> tgis.init()
-        >>> maps = []
-        >>> for i in range(5):
-        ...   map = tgis.RasterDataset("a%i at P"%i)
-        ...   check = map.set_relative_time(i,i + 1,"seconds")
-        ...   if check:
-        ...     maps.append(map)
-        >>> tgis.compute_relative_time_granularity(maps)
-        1
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> maps = []
+            >>> for i in range(5):
+            ...   map = tgis.RasterDataset("a%i at P"%i)
+            ...   check = map.set_relative_time(i,i + 1,"seconds")
+            ...   if check:
+            ...     maps.append(map)
+            >>> tgis.compute_relative_time_granularity(maps)
+            1
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((0,3), (3,6), (6,9))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_relative_time(t[0],t[1],"years")
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_relative_time_granularity(maps)
-        3
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,3), (3,6), (6,9))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"years")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            3
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((0,3), (4,6), (8,11))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_relative_time(t[0],t[1],"years")
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_relative_time_granularity(maps)
-        1
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,3), (4,6), (8,11))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"years")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            1
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((0,8), (2,6), (5,9))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_relative_time(t[0],t[1],"months")
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_relative_time_granularity(maps)
-        4
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,8), (2,6), (5,9))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"months")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            4
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((0,8), (8,12), (12,18))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_relative_time(t[0],t[1],"days")
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_relative_time_granularity(maps)
-        2
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,8), (8,12), (12,18))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"days")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            2
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((0,None), (8,None), (12,None), (24,None))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_relative_time(t[0],t[1],"minutes")
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_relative_time_granularity(maps)
-        4
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,None), (8,None), (12,None), (24,None))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"minutes")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            4
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((0,None), (8,14), (18,None), (24,None))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_relative_time(t[0],t[1],"hours")
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_relative_time_granularity(maps)
-        2
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,None), (8,14), (18,None), (24,None))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"hours")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            2
 
-        @endcode
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((0,21),)
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_relative_time(t[0],t[1],"hours")
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_relative_time_granularity(maps)
+            21
+
     """
 
     # The interval time must be scaled to days resolution
     granularity = None
-
     delta = []
     # First we compute the timedelta of the intervals
     for map in maps:
         start, end = map.get_temporal_extent_as_tuple()
-        if start and end:
+        if (start == 0 or start) and end:
             t = abs(end - start)
             delta.append(int(t))
 
@@ -244,85 +253,84 @@
 
 
 def compute_absolute_time_granularity(maps):
-    """!Compute the absolute time granularity
+    """Compute the absolute time granularity
 
         Attention: The computation of the granularity
         is only correct in case of not overlapping intervals.
         Hence a correct temporal topology is required for computation.
 
-        The computed granularity is returned as number of seconds or minutes or hours
-        or days or months or years.
+        The computed granularity is returned as number of seconds or minutes
+        or hours or days or months or years.
 
-        @param maps a ordered by start_time list of map objects
-        @return The temporal topology as string "integer unit"
+        :param maps: a ordered by start_time list of map objects
+        :return: The temporal topology as string "integer unit"
 
-        @code
+        .. code-block:: python
 
-        >>> import grass.temporal as tgis
-        >>> import datetime
-        >>> dt = datetime.datetime
-        >>> tgis.init()
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((dt(2000,01,01),None), (dt(2000,02,01),None))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_absolute_time(t[0],t[1])
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_absolute_time_granularity(maps)
-        '1 month'
+            >>> import grass.temporal as tgis
+            >>> import datetime
+            >>> dt = datetime.datetime
+            >>> tgis.init()
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((dt(2000,01,01),None), (dt(2000,02,01),None))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_absolute_time(t[0],t[1])
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_absolute_time_granularity(maps)
+            '1 month'
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((dt(2000,01,01),None), (dt(2000,01,02),None), (dt(2000,01,03),None))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_absolute_time(t[0],t[1])
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_absolute_time_granularity(maps)
-        '1 day'
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((dt(2000,01,01),None), (dt(2000,01,02),None), (dt(2000,01,03),None))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_absolute_time(t[0],t[1])
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_absolute_time_granularity(maps)
+            '1 day'
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((dt(2000,01,01),None), (dt(2000,01,02),None), (dt(2000,05,04,0,5,30),None))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_absolute_time(t[0],t[1])
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_absolute_time_granularity(maps)
-        '30 seconds'
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((dt(2000,01,01),None), (dt(2000,01,02),None), (dt(2000,05,04,0,5,30),None))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_absolute_time(t[0],t[1])
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_absolute_time_granularity(maps)
+            '30 seconds'
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((dt(2000,01,01),dt(2000,05,02)), (dt(2000,05,04,2),None))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_absolute_time(t[0],t[1])
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_absolute_time_granularity(maps)
-        '2 hours'
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((dt(2000,01,01),dt(2000,05,02)), (dt(2000,05,04,2),None))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_absolute_time(t[0],t[1])
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_absolute_time_granularity(maps)
+            '2 hours'
 
-        >>> maps = []
-        >>> count = 0
-        >>> timelist = ((dt(2000,01,01),dt(2000,02,01)), (dt(2005,05,04,12),dt(2007,05,20,6)))
-        >>> for t in timelist:
-        ...   map = tgis.RasterDataset("a%i at P"%count)
-        ...   check = map.set_absolute_time(t[0],t[1])
-        ...   if check:
-        ...     maps.append(map)
-        ...   count += 1
-        >>> tgis.compute_absolute_time_granularity(maps)
-        '6 hours'
+            >>> maps = []
+            >>> count = 0
+            >>> timelist = ((dt(2000,01,01),dt(2000,02,01)), (dt(2005,05,04,12),dt(2007,05,20,6)))
+            >>> for t in timelist:
+            ...   map = tgis.RasterDataset("a%i at P"%count)
+            ...   check = map.set_absolute_time(t[0],t[1])
+            ...   if check:
+            ...     maps.append(map)
+            ...   count += 1
+            >>> tgis.compute_absolute_time_granularity(maps)
+            '6 hours'
 
-        @endcode
     """
 
     has_seconds = False
@@ -486,6 +494,269 @@
     return None
 
 ###############################################################################
+
+def compute_common_relative_time_granularity(gran_list):
+	"""Compute the greatest common granule from a list of relative time granules
+    
+        .. code-block:: python
+
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> grans = [1,2,30]
+            >>> tgis.compute_common_relative_time_granularity(grans)
+            1
+            
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> grans = [10,20,30]
+            >>> tgis.compute_common_relative_time_granularity(grans)
+            10
+    """
+	return gcd_list(gran_list)
+
+###############################################################################
+
+def compute_common_absolute_time_granularity(gran_list):
+    """Compute the greatest common granule from a list of absolute time granules
+
+        .. code-block:: python
+
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> grans = ["1 second", "2 seconds", "30 seconds"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '1 seconds'
+            
+            >>> grans = ["3 second", "6 seconds", "30 seconds"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '3 seconds'
+            
+            >>> grans = ["12 second", "18 seconds", "30 seconds", "10 minutes"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '6 seconds'
+            
+            >>> grans = ["20 second", "10 minutes", "2 hours"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '20 seconds'
+            
+            >>> grans = ["7200 second", "240 minutes", "1 year"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '7200 seconds'
+            
+            >>> grans = ["7200 second", "89 minutes", "1 year"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '60 seconds'
+
+            >>> grans = ["10 minutes", "20 minutes", "30 minutes", "40 minutes", "2 hours"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '10 minutes'
+
+            >>> grans = ["120 minutes", "2 hours"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '120 minutes'
+
+            >>> grans = ["360 minutes", "3 hours"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '180 minutes'
+
+            >>> grans = ["2 hours", "4 hours", "8 hours"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '2 hours'
+
+            >>> grans = ["8 hours", "2 days"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '8 hours'
+
+            >>> grans = ["48 hours", "1 month"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '24 hours'
+
+            >>> grans = ["48 hours", "1 year"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '24 hours'
+
+            >>> grans = ["2 months", "4 months", "1 year"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '2 months'
+
+            >>> grans = ["120 months", "360 months", "4 years"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '24 months'
+
+            >>> grans = ["120 months", "361 months", "4 years"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '1 months'
+
+            >>> grans = ["2 years", "3 years", "4 years"]
+            >>> tgis.compute_common_absolute_time_granularity(grans)
+            '1 years'
+    """
+    
+    has_seconds = False # 0
+    has_minutes = False # 1
+    has_hours = False     # 2
+    has_days = False      # 3
+    has_months = False  # 4
+    has_years = False     # 5
+    
+    seconds = []
+    minutes = []
+    hours = []
+    days = []
+    months = []
+    years = []
+    
+    min_gran = 6
+    max_gran = -1
+    
+    for entry in gran_list:
+        if not check_granularity_string(entry, "absolute"):
+            return False
+
+        num,  gran = entry.split()
+        
+        if gran in ["seconds",  "second"]:
+            has_seconds = True
+            if min_gran > 0:
+                min_gran = 0
+            if max_gran < 0:
+                max_gran = 0
+                
+            seconds.append(int(num))
+
+        if gran in ["minutes",  "minute"]:
+            has_minutes = True
+            if min_gran > 1:
+                min_gran = 1
+            if max_gran < 1:
+                max_gran = 1
+                
+            minutes.append(int(num))
+
+        if gran in ["hours",  "hour"]:
+            has_hours = True
+            if min_gran > 2:
+                min_gran = 2
+            if max_gran < 2:
+                max_gran = 2
+                
+            hours.append(int(num))
+
+        if gran in ["days",  "day"]:
+            has_days = True
+            if min_gran > 3:
+                min_gran = 3
+            if max_gran < 3:
+                max_gran = 3
+                
+            days.append(int(num))
+
+        if gran in ["months",  "month"]:
+            has_months = True
+            if min_gran > 4:
+                min_gran = 4
+            if max_gran < 4:
+                max_gran = 4
+                
+            months.append(int(num))
+
+        if gran in ["years",  "year"]:
+            has_years = True
+            if min_gran > 5:
+                min_gran = 5
+            if max_gran < 5:
+                max_gran = 5
+                
+            years.append(int(num))
+            
+    if has_seconds:
+        if has_minutes:
+            minutes.sort()
+            seconds.append(minutes[0]*60)
+        if has_hours:
+            hours.sort()
+            seconds.append(hours[0]*60*60)
+        if has_days:
+            days.sort()
+            seconds.append(days[0]*60*60*24)
+        if has_months:
+            months.sort()
+            seconds.append(months[0]*60*60*24*28)
+            seconds.append(months[0]*60*60*24*29)
+            seconds.append(months[0]*60*60*24*30)
+            seconds.append(months[0]*60*60*24*31)
+        if has_years:
+            years.sort()
+            seconds.append(years[0]*60*60*24*365)
+            seconds.append(years[0]*60*60*24*366)
+
+        num = gcd_list(seconds)
+        return "%i %s"%(num,  "seconds")
+        
+    elif has_minutes:
+        if has_hours:
+            hours.sort()
+            minutes.append(hours[0]*60)
+        if has_days:
+            days.sort()
+            minutes.append(days[0]*60*24)
+        if has_months:
+            months.sort()
+            minutes.append(months[0]*60*24*28)
+            minutes.append(months[0]*60*24*29)
+            minutes.append(months[0]*60*24*30)
+            minutes.append(months[0]*60*24*31)
+        if has_years:
+            years.sort()
+            minutes.append(years[0]*60*24*365)
+            minutes.append(years[0]*60*24*366)
+        num = gcd_list(minutes)
+        return "%i %s"%(num,  "minutes")
+        
+    elif has_hours:
+        if has_days:
+            days.sort()
+            hours.append(days[0]*24)
+        if has_months:
+            months.sort()
+            hours.append(months[0]*24*28)
+            hours.append(months[0]*24*29)
+            hours.append(months[0]*24*30)
+            hours.append(months[0]*24*31)
+        if has_years:
+            years.sort()
+            hours.append(years[0]*24*365)
+            hours.append(years[0]*24*366)
+        num = gcd_list(hours)
+        return "%i %s"%(num,  "hours")
+
+    elif has_days:
+        if has_months:
+            months.sort()
+            days.append(months[0]*28)
+            days.append(months[0]*29)
+            days.append(months[0]*30)
+            days.append(months[0]*31)
+        if has_years:
+            years.sort()
+            days.append(years[0]*365)
+            days.append(years[0]*366)
+        num = gcd_list(days)
+        return "%i %s"%(num,  "days")
+
+    elif has_months:
+        if has_years:
+            years.sort()
+            months.append(years[0]*12)
+        num = gcd_list(months)
+        return "%i %s"%(num,  "months")
+        
+    elif has_years:
+        num = gcd_list(years)
+        return "%i %s"%(num,  "years")
+        
+
+###############################################################################
 # http://akiscode.com/articles/gcd_of_a_list.shtml
 # Copyright (c) 2010 Stephen Akiki
 # MIT License (Means you can do whatever you want with this)
@@ -495,7 +766,7 @@
 
 
 def gcd(a, b):
-    """!The Euclidean Algorithm """
+    """The Euclidean Algorithm """
     a = abs(a)
     b = abs(b)
     while a:
@@ -506,10 +777,12 @@
 
 
 def gcd_list(list):
-    """!Finds the GCD of numbers in a list.
-    Input: List of numbers you want to find the GCD of
-            E.g. [8, 24, 12]
-    Returns: GCD of all numbers
+    """Finds the GCD of numbers in a list.
+
+    :param list: List of numbers you want to find the GCD of
+                 E.g. [8, 24, 12]
+    :return: GCD of all numbers
+
     """
     return reduce(gcd, list)
 

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_operator.py (from rev 62594, grass/trunk/lib/python/temporal/temporal_operator.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_operator.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_operator.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,615 @@
+"""@package grass.temporal
+
+Temporal operator evaluation with PLY
+
+(C) 2013 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Thomas Leppelt and Soeren Gebbert
+
+.. code-block:: python
+
+    >>> p = TemporalOperatorParser()
+    >>> expression =  "{equal| during}"
+    >>> p.parse(expression, optype = 'relation')
+    >>> print(p.relations, p.temporal, p.function)
+    (['equal', 'during'], None, None)
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{contains | starts}"
+    >>> p.parse(expression)
+    >>> print(p.relations, p.temporal, p.function)
+    (['contains', 'starts'], None, None)
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{&&, during}"
+    >>> p.parse(expression, optype = 'boolean')
+    >>> print(p.relations, p.temporal, p.function,p.aggregate)
+    (['during'], 'l', '&&', '&')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{||, equal | during}"
+    >>> p.parse(expression, optype = 'boolean')
+    >>> print(p.relations, p.temporal, p.function,p.aggregate)
+    (['equal', 'during'], 'l', '||', '|')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{||, equal | during, &}"
+    >>> p.parse(expression, optype = 'boolean')
+    >>> print(p.relations, p.temporal, p.function,p.aggregate)
+    (['equal', 'during'], 'l', '||', '&')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{&&, during, |}"
+    >>> p.parse(expression, optype = 'boolean')
+    >>> print(p.relations, p.temporal, p.function,p.aggregate)
+    (['during'], 'l', '&&', '|')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{&&, during, |, r}"
+    >>> p.parse(expression, optype = 'boolean')
+    >>> print(p.relations, p.temporal, p.function,p.aggregate)
+    (['during'], 'r', '&&', '|')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{&&, during, u}"
+    >>> p.parse(expression, optype = 'boolean')
+    >>> print(p.relations, p.temporal, p.function,p.aggregate)
+    (['during'], 'u', '&&', '&')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{:, during, r}"
+    >>> p.parse(expression, optype = 'select')
+    >>> print(p.relations, p.temporal, p.function)
+    (['during'], 'r', ':')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{!:, equal | contains, d}"
+    >>> p.parse(expression, optype = 'select')
+    >>> print(p.relations, p.temporal, p.function)
+    (['equal', 'contains'], 'd', '!:')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{#, during, r}"
+    >>> p.parse(expression, optype = 'hash')
+    >>> print(p.relations, p.temporal, p.function)
+    (['during'], 'r', '#')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{#, equal | contains}"
+    >>> p.parse(expression, optype = 'hash')
+    >>> print(p.relations, p.temporal, p.function)
+    (['equal', 'contains'], 'l', '#')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{+, during, r}"
+    >>> p.parse(expression, optype = 'raster')
+    >>> print(p.relations, p.temporal, p.function)
+    (['during'], 'r', '+')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{/, equal | contains}"
+    >>> p.parse(expression, optype = 'raster')
+    >>> print(p.relations, p.temporal, p.function)
+    (['equal', 'contains'], 'l', '/')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{+, equal | contains,intersect}"
+    >>> p.parse(expression, optype = 'raster')
+    >>> print(p.relations, p.temporal, p.function)
+    (['equal', 'contains'], 'i', '+')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{*, contains,disjoint}"
+    >>> p.parse(expression, optype = 'raster')
+    >>> print(p.relations, p.temporal, p.function)
+    (['contains'], 'd', '*')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{~, equal,left}"
+    >>> p.parse(expression, optype = 'overlay')
+    >>> print(p.relations, p.temporal, p.function)
+    (['equal'], 'l', '~')
+    >>> p = TemporalOperatorParser()    
+    >>> expression =  "{^, over,right}"
+    >>> p.parse(expression, optype = 'overlay')
+    >>> print(p.relations, p.temporal, p.function)
+    (['overlaps', 'overlapped'], 'r', '^')
+
+"""
+
+try:
+    import ply.lex as lex
+    import ply.yacc as yacc
+except:
+    pass
+
+class TemporalOperatorLexer(object):
+    """Lexical analyzer for the GRASS GIS temporal operator"""
+
+    # Functions that defines topological relations.
+    relations = {
+        'equal'      : "EQUAL",
+        'follows'    : "FOLLOWS",
+        'precedes'   : "PRECEDES",
+        'overlaps'   : "OVERLAPS",
+        'overlapped' : "OVERLAPPED",
+        'during'     : "DURING",
+        'starts'     : "STARTS",
+        'finishes'   : "FINISHES",
+        'contains'   : "CONTAINS",
+        'started'    : "STARTED",
+        'finished'   : "FINISHED",
+        'over'       : "OVER"
+        }
+
+    # This is the list of token names.
+    tokens = (
+        'COMMA',
+        'LEFTREF',
+        'RIGHTREF',
+        'UNION', 
+        'DISJOINT',
+        'INTERSECT',
+        'HASH',
+        'OR',
+        'AND',
+        'DISOR',
+        'XOR',
+        'NOT',        
+        'MOD',
+        'DIV',
+        'MULT',
+        'ADD',      
+        'SUB',
+        'T_SELECT',
+        'T_NOT_SELECT',
+        'CLPAREN',
+        'CRPAREN',
+    )
+
+    # Build the token list
+    tokens = tokens + tuple(relations.values())
+
+    # Regular expression rules for simple tokens
+    t_T_SELECT                = r':'
+    t_T_NOT_SELECT        = r'!:'
+    t_COMMA                    = r','
+    t_LEFTREF                  = '^[l|left]'
+    t_RIGHTREF                ='^[r|right]'
+    t_UNION                     = '^[u|union]'
+    t_DISJOINT                 = '^[d|disjoint]'
+    t_INTERSECT             = '^[i|intersect]'
+    t_HASH                      = r'\#'
+    t_OR                          = r'[\|]'
+    t_AND                        = r'[&]'
+    t_DISOR                     = r'\+'
+    t_XOR                         = r'\^'
+    t_NOT                         = r'\~'    
+    t_MOD                       = r'[\%]'
+    t_DIV                         = r'[\/]'
+    t_MULT                      = r'[\*]'
+    t_ADD                       = r'[\+]'
+    t_SUB                        = r'[-]'
+    t_CLPAREN                = r'\{'
+    t_CRPAREN                = r'\}'
+
+    # These are the things that should be ignored.
+    t_ignore = ' \t'
+
+    # Track line numbers.
+    def t_newline(self, t):
+        r'\n+'
+        t.lineno += len(t.value)
+
+    def t_NAME(self, t):
+        r'[a-zA-Z_][a-zA-Z_0-9]*'
+        self.temporal_symbol(t)
+        return t
+
+    # Parse symbols
+    def temporal_symbol(self, t):
+        # Check for reserved words
+        if t.value in TemporalOperatorLexer.relations.keys():
+            t.type = TemporalOperatorLexer.relations.get(t.value)
+        elif t.value == 'l' or t.value == 'left':
+            t.value = 'l'
+            t.type = 'LEFTREF'
+        elif t.value == 'r' or t.value == 'right':
+            t.value = 'r'
+            t.type = 'RIGHTREF'
+        elif t.value == 'u' or t.value == 'union':
+            t.value = 'u'
+            t.type = 'UNION'
+        elif t.value == 'd' or t.value == 'disjoint':
+            t.value = 'd'
+            t.type = 'DISJOINT'
+        elif t.value == 'i' or t.value == 'intersect':
+            t.value = 'i'
+            t.type = 'INTERSECT'
+        #else:
+        #    t.type = 'NAME'
+        return(t)
+
+    # Handle errors.
+    def t_error(self, t):
+        raise SyntaxError("syntax error on line %d near '%s'" %
+            (t.lineno, t.value))
+
+    # Build the lexer
+    def build(self,**kwargs):
+        self.lexer = lex.lex(module=self, **kwargs)
+
+    # Just for testing
+    def test(self,data):
+        self.name_list = {}
+        print(data)
+        self.lexer.input(data)
+        while True:
+             tok = self.lexer.token()
+             if not tok: break
+             print tok
+
+###############################################################################
+
+class TemporalOperatorParser(object):
+    """The temporal operator class"""
+
+    def __init__(self):
+        self.lexer = TemporalOperatorLexer()
+        self.lexer.build()
+        self.parser = yacc.yacc(module=self)
+        self.relations = None
+        self.temporal  = None
+        self.function  = None
+        self.aggregate = None
+
+    def parse(self, expression,  optype = 'relation'):
+        self.optype = optype        
+        self.parser.parse(expression)
+        # The paramter optype can be of type: select {:, during, r}, boolean{&&, contains, |}, 
+        #                                                            raster{*, equal, |}, vector {|, starts, &},
+        #                                                            hash{#, during, l} or relation {during}.
+    
+    # Error rule for syntax errors.
+    def p_error(self, t):
+        raise SyntaxError("Unexpected syntax error")
+
+    # Get the tokens from the lexer class
+    tokens = TemporalOperatorLexer.tokens
+ 
+    def p_relation_operator(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN relation CRPAREN
+                 | CLPAREN relationlist CRPAREN
+        """
+        # Check for correct type.
+        if not self.optype == 'relation':
+            raise SyntaxError("invalid syntax")
+        else:
+            # Set three operator components.
+            if isinstance(t[2], list):
+                self.relations = t[2]
+            else:
+                self.relations = [t[2]]
+            self.temporal  = None
+            self.function  = None
+
+            t[0] = t[2]
+
+    def p_relation_bool_operator(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN OR OR COMMA relation CRPAREN
+                | CLPAREN AND AND COMMA relation CRPAREN
+                | CLPAREN OR OR COMMA relationlist CRPAREN
+                | CLPAREN AND AND COMMA relationlist CRPAREN
+        """
+        if not self.optype == 'boolean':
+            raise SyntaxError("invalid syntax")
+        else:        
+            # Set three operator components.
+            if isinstance(t[5], list):
+                self.relations = t[5]
+            else:
+                self.relations = [t[5]]
+            self.temporal  = "l"
+            self.function  = t[2] + t[3]
+            self.aggregate = t[2]
+            
+            t[0] = t[2]
+
+    def p_relation_bool_combi_operator(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN OR OR COMMA relation COMMA OR CRPAREN
+                | CLPAREN OR OR COMMA relation COMMA AND CRPAREN
+                | CLPAREN AND AND COMMA relation COMMA OR CRPAREN
+                | CLPAREN AND AND COMMA relation COMMA AND CRPAREN
+                | CLPAREN OR OR COMMA relationlist COMMA OR CRPAREN
+                | CLPAREN OR OR COMMA relationlist COMMA AND CRPAREN
+                | CLPAREN AND AND COMMA relationlist COMMA OR CRPAREN
+                | CLPAREN AND AND COMMA relationlist COMMA AND CRPAREN
+        """
+        if not self.optype == 'boolean':
+            raise SyntaxError("invalid syntax")
+        else:        
+            # Set three operator components.
+            if isinstance(t[5], list):
+                self.relations = t[5]
+            else:
+                self.relations = [t[5]]
+            self.temporal  = "l"
+            self.function  = t[2] + t[3]
+            self.aggregate = t[7]
+            
+            t[0] = t[2]
+
+    def p_relation_bool_combi_operator2(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN OR OR COMMA relation COMMA temporal CRPAREN
+                | CLPAREN AND AND COMMA relation COMMA temporal CRPAREN
+                | CLPAREN OR OR COMMA relationlist COMMA temporal CRPAREN
+                | CLPAREN AND AND COMMA relationlist COMMA temporal CRPAREN
+        """
+        if not self.optype == 'boolean':
+            raise SyntaxError("invalid syntax")
+        else:        
+            # Set three operator components.
+            if isinstance(t[5], list):
+                self.relations = t[5]
+            else:
+                self.relations = [t[5]]
+            self.temporal  = t[7]
+            self.function  = t[2] + t[3]
+            self.aggregate = t[2]
+            
+            t[0] = t[2]
+    
+    def p_relation_bool_combi_operator3(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN OR OR COMMA relation COMMA OR COMMA temporal CRPAREN
+                | CLPAREN OR OR COMMA relation COMMA AND COMMA temporal CRPAREN
+                | CLPAREN AND AND COMMA relation COMMA OR COMMA temporal CRPAREN
+                | CLPAREN AND AND COMMA relation COMMA AND COMMA temporal CRPAREN
+                | CLPAREN OR OR COMMA relationlist COMMA OR COMMA temporal CRPAREN
+                | CLPAREN OR OR COMMA relationlist COMMA AND COMMA temporal CRPAREN
+                | CLPAREN AND AND COMMA relationlist COMMA OR COMMA temporal CRPAREN
+                | CLPAREN AND AND COMMA relationlist COMMA AND COMMA temporal CRPAREN
+        """
+        if not self.optype == 'boolean':
+            raise SyntaxError("invalid syntax")
+        else:        
+            # Set three operator components.
+            if isinstance(t[5], list):
+                self.relations = t[5]
+            else:
+                self.relations = [t[5]]
+            self.temporal  = t[9]
+            self.function  = t[2] + t[3]
+            self.aggregate = t[7]
+            
+            t[0] = t[2]
+    
+    def p_select_relation_operator(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN select CRPAREN
+                    | CLPAREN select COMMA relation CRPAREN
+                    | CLPAREN select COMMA relationlist CRPAREN
+                    | CLPAREN select COMMA relation COMMA temporal CRPAREN
+                    | CLPAREN select COMMA relationlist COMMA temporal CRPAREN
+        """
+        if not self.optype == 'select':
+            raise SyntaxError("invalid syntax")
+        else:
+            if len(t) == 4:
+                # Set three operator components.
+                self.relations = ['equal']
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 5:
+                self.relations = ['equal']
+                self.temporal  = t[3]
+                self.function  = t[2]
+            elif len(t) == 6:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 8:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = t[6]
+                self.function  = t[2]
+            t[0] = t[2]
+
+    def p_hash_relation_operator(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN HASH CRPAREN
+                    | CLPAREN HASH COMMA relation CRPAREN
+                    | CLPAREN HASH COMMA relationlist CRPAREN
+                    | CLPAREN HASH COMMA relation COMMA temporal CRPAREN
+                    | CLPAREN HASH COMMA relationlist COMMA temporal CRPAREN
+        """
+        if not self.optype == 'hash':
+            raise SyntaxError("invalid syntax")
+        else:
+            if len(t) == 4:
+                # Set three operator components.
+                self.relations = ['equal']
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 5:
+                self.relations = ['equal']
+                self.temporal  = t[3]
+                self.function  = t[2]
+            elif len(t) == 6:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 8:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = t[6]
+                self.function  = t[2]
+            t[0] = t[2]
+
+    def p_raster_relation_operator(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN arithmetic CRPAREN
+                    | CLPAREN arithmetic COMMA relation CRPAREN
+                    | CLPAREN arithmetic COMMA relationlist CRPAREN
+                    | CLPAREN arithmetic COMMA relation COMMA temporal CRPAREN
+                    | CLPAREN arithmetic COMMA relationlist COMMA temporal CRPAREN
+        """
+        if not self.optype == 'raster':
+            raise SyntaxError("invalid syntax")
+        else:
+            if len(t) == 4:
+                # Set three operator components.
+                self.relations = ['equal']
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 5:
+                self.relations = ['equal']
+                self.temporal  = t[3]
+                self.function  = t[2]
+            elif len(t) == 6:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 8:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = t[6]
+                self.function  = t[2]
+            t[0] = t[2]
+
+    def p_overlay_relation_operator(self, t):
+        # The expression should always return a list of maps.
+        """
+        operator : CLPAREN overlay CRPAREN
+                    | CLPAREN overlay COMMA relation CRPAREN
+                    | CLPAREN overlay COMMA relationlist CRPAREN
+                    | CLPAREN overlay COMMA relation COMMA temporal CRPAREN
+                    | CLPAREN overlay COMMA relationlist COMMA temporal CRPAREN
+        """
+        if not self.optype == 'overlay':
+            raise SyntaxError("invalid syntax")
+        else:
+            if len(t) == 4:
+                # Set three operator components.
+                self.relations = ['equal']
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 5:
+                self.relations = ['equal']
+                self.temporal  = t[3]
+                self.function  = t[2]
+            elif len(t) == 6:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = "l"
+                self.function  = t[2]
+            elif len(t) == 8:
+                if isinstance(t[4], list):
+                    self.relations = t[4]
+                else:
+                    self.relations = [t[4]]
+                self.temporal  = t[6]
+                self.function  = t[2]
+            t[0] = t[2]
+
+    def p_relation(self, t):
+        # The list of relations.
+        """
+        relation : EQUAL
+                 | FOLLOWS
+                 | PRECEDES
+                 | OVERLAPS
+                 | OVERLAPPED
+                 | DURING
+                 | STARTS
+                 | FINISHES
+                 | CONTAINS
+                 | STARTED
+                 | FINISHED
+        """
+        t[0] = t[1]
+
+    def p_over(self, t):
+        # The list of relations.
+        """
+        relation : OVER
+        """
+        over_list = ["overlaps", "overlapped"]
+        t[0] = over_list
+
+    def p_relationlist(self, t):
+        # The list of relations.
+        """
+        relationlist : relation OR relation
+                     | relation OR relationlist
+        """
+        rel_list = []
+        rel_list.append(t[1])
+        if isinstance(t[3], list):
+            rel_list = rel_list + t[3]
+        else:
+            rel_list.append(t[3])
+        t[0] =  rel_list
+
+    def p_temporal_operator(self, t):
+        # The list of relations.
+        """
+        temporal : LEFTREF
+                | RIGHTREF
+                | UNION
+                | DISJOINT
+                | INTERSECT
+        """
+        t[0] = t[1]
+
+    def p_select_operator(self, t):
+        # The list of relations.
+        """
+        select : T_SELECT
+               | T_NOT_SELECT
+        """
+        t[0] = t[1]
+
+    def p_arithmetic_operator(self, t):
+        # The list of relations.
+        """
+        arithmetic : MOD
+                   | DIV
+                   | MULT
+                   | ADD
+                   | SUB
+        """
+        t[0] = t[1]
+
+    def p_overlay_operator(self, t):
+        # The list of relations.
+        """
+        overlay : AND
+                   | OR
+                   | XOR
+                   | DISOR
+                   | NOT
+        """
+        t[0] = t[1]
+###############################################################################
+
+if __name__ == "__main__":
+    import doctest
+    doctest.testmod()
+

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster3d_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster3d_algebra.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster3d_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -7,7 +7,7 @@
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Thomas Leppelt and Soeren Gebbert
+:authors: Thomas Leppelt and Soeren Gebbert
 
 """
 
@@ -23,9 +23,21 @@
         TemporalRasterBaseAlgebraParser.__init__(self, pid, run, debug, spatial, nprocs, register_null)
 
         self.m_mapcalc = pymod.Module('r3.mapcalc')
-        self.m_remove = pymod.Module('g.remove')
+        self.m_mremove = pymod.Module('g.remove')
 
     def parse(self, expression, basename = None, overwrite=False):
+        # Check for space time dataset type definitions from temporal algebra
+        l = TemporalRasterAlgebraLexer()
+        l.build()
+        l.lexer.input(expression)
+
+        while True:
+            tok = l.lexer.token()
+            if not tok: break
+            
+            if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
+                raise SyntaxError("Syntax error near '%s'" %(tok.type))
+
         self.lexer = TemporalRasterAlgebraLexer()
         self.lexer.build()
         self.parser = yacc.yacc(module=self, debug=self.debug)
@@ -33,28 +45,12 @@
         self.overwrite = overwrite
         self.count = 0
         self.stdstype = "str3ds"
+        self.maptype = "rast3d"
+        self.mapclass = Raster3DDataset
         self.basename = basename
         self.expression = expression
         self.parser.parse(expression)
 
-    def remove_empty_maps(self):
-        """! Removes the intermediate vector maps.
-        """
-        if self.empty_maps:
-            self.msgr.message(_("Removing empty 3D raster maps"))
-            namelist = self.empty_maps.values()
-            max = 100
-            chunklist = [namelist[i:i + max] for i in range(0, len(namelist), max)]
-            for chunk in chunklist:
-                stringlist = ",".join(chunk)
-
-                if self.run:
-                    m = copy.deepcopy(self.m_remove)
-                    m.inputs["type"].value = "rast3d"
-                    m.inputs["pattern"].value = stringlist
-                    m.flags["f"].value = True
-                    m.run()
-
     ######################### Temporal functions ##############################
 
     def p_statement_assign(self, t):

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_algebra.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -7,9 +7,9 @@
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Thomas Leppelt and Soeren Gebbert
+:authors: Thomas Leppelt and Soeren Gebbert
 
- at code
+.. code-block:: python
 
     >>> p = TemporalRasterAlgebraLexer()
     >>> p.build()
@@ -50,7 +50,6 @@
     LexToken(SUB,'-',1,40)
     LexToken(FLOAT,2.45,1,42)
 
- at endcode
 """
 
 from temporal_raster_base_algebra import *
@@ -64,9 +63,21 @@
         TemporalRasterBaseAlgebraParser.__init__(self, pid, run, debug, spatial, nprocs, register_null)
 
         self.m_mapcalc = pymod.Module('r.mapcalc')
-        self.m_remove = pymod.Module('g.remove')
+        self.m_mremove = pymod.Module('g.remove')
 
     def parse(self, expression, basename = None, overwrite=False):
+        # Check for space time dataset type definitions from temporal algebra
+        l = TemporalRasterAlgebraLexer()
+        l.build()
+        l.lexer.input(expression)
+
+        while True:
+            tok = l.lexer.token()
+            if not tok: break
+            
+            if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
+                raise SyntaxError("Syntax error near '%s'" %(tok.type))
+        
         self.lexer = TemporalRasterAlgebraLexer()
         self.lexer.build()
         self.parser = yacc.yacc(module=self, debug=self.debug)
@@ -74,28 +85,12 @@
         self.overwrite = overwrite
         self.count = 0
         self.stdstype = "strds"
+        self.maptype = "rast"
+        self.mapclass = RasterDataset
         self.basename = basename
         self.expression = expression
         self.parser.parse(expression)
 
-    def remove_empty_maps(self):
-        """! Removes the intermediate vector maps.
-        """
-        if self.empty_maps:
-            self.msgr.message(_("Removing empty raster maps"))
-            namelist = self.empty_maps.values()
-            max = 100
-            chunklist = [namelist[i:i + max] for i in range(0, len(namelist), max)]
-            for chunk in chunklist:
-                stringlist = ",".join(chunk)
-
-                if self.run:
-                    m = copy.deepcopy(self.m_remove)
-                    m.inputs["type"].value = "rast"
-                    m.inputs["pattern"].value = stringlist
-                    m.flags["f"].value = True
-                    m.run()
-
     ######################### Temporal functions ##############################
 
     def p_statement_assign(self, t):

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_base_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,4 +1,4 @@
-"""!@package grass.temporal
+"""@package grass.temporal
 
 Temporal raster algebra
 
@@ -7,103 +7,48 @@
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Thomas Leppelt and Soeren Gebbert
+:authors: Thomas Leppelt and Soeren Gebbert
 
- at code
+.. code-block:: python
 
     >>> p = TemporalRasterAlgebraLexer()
     >>> p.build()
     >>> p.debug = True
-    >>> expression =  'R = A / B * 20 + C - 2.45'
+    >>> expression =  'R = A {+,equal,l} B '
     >>> p.test(expression)
-    R = A / B * 20 + C - 2.45
+    R = A {+,equal,l} B 
     LexToken(NAME,'R',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(NAME,'A',1,4)
-    LexToken(DIV,'/',1,6)
-    LexToken(NAME,'B',1,8)
-    LexToken(MULT,'*',1,10)
-    LexToken(INT,20,1,12)
-    LexToken(ADD,'+',1,15)
-    LexToken(NAME,'C',1,17)
-    LexToken(SUB,'-',1,19)
-    LexToken(FLOAT,2.45,1,21)
-    >>> expression =  'R = A {equal,|/} B'
+    LexToken(T_ARITH2_OPERATOR,'{+,equal,l}',1,6)
+    LexToken(NAME,'B',1,18)
+    >>> expression =  'R = A {*,equal|during,r} B '
     >>> p.test(expression)
-    R = A {equal,|/} B
+    R = A {*,equal|during,r} B 
     LexToken(NAME,'R',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(NAME,'A',1,4)
-    LexToken(T_ARITH1_OPERATOR,'{equal,|/}',1,6)
-    LexToken(NAME,'B',1,17)
-    >>> expression =  'R = A {equal,||} B'
+    LexToken(T_ARITH1_OPERATOR,'{*,equal|during,r}',1,6)
+    LexToken(NAME,'B',1,25)
+    >>> expression =  'R = A {+,equal|during} B '
     >>> p.test(expression)
-    R = A {equal,||} B
+    R = A {+,equal|during} B 
     LexToken(NAME,'R',1,0)
     LexToken(EQUALS,'=',1,2)
     LexToken(NAME,'A',1,4)
-    LexToken(T_COMP_OPERATOR,'{equal,||}',1,6)
-    LexToken(NAME,'B',1,17)
-    >>> expression =  'R = A {equal,&&} B'
-    >>> p.test(expression)
-    R = A {equal,&&} B
-    LexToken(NAME,'R',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'A',1,4)
-    LexToken(T_COMP_OPERATOR,'{equal,&&}',1,6)
-    LexToken(NAME,'B',1,17)
-    >>> expression =  'R = A {equal | during,+*} B'
-    >>> p.test(expression)
-    R = A {equal | during,+*} B
-    LexToken(NAME,'R',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'A',1,4)
-    LexToken(T_ARITH1_OPERATOR,'{equal | during,+*}',1,6)
-    LexToken(NAME,'B',1,26)
-    >>> expression =  'R = A {equal | during,+:} B'
-    >>> p.test(expression)
-    R = A {equal | during,+:} B
-    LexToken(NAME,'R',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'A',1,4)
-    LexToken(T_SELECT_OPERATOR,'{equal | during,+:}',1,6)
-    LexToken(NAME,'B',1,26)
-    >>> expression =  'R = abs(A) {equal,+:} exp(B) / sqrt(C) - log(D)'
-    >>> p.test(expression)
-    R = abs(A) {equal,+:} exp(B) / sqrt(C) - log(D)
-    LexToken(NAME,'R',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(ABS,'abs',1,4)
-    LexToken(LPAREN,'(',1,7)
-    LexToken(NAME,'A',1,8)
-    LexToken(RPAREN,')',1,9)
-    LexToken(T_SELECT_OPERATOR,'{equal,+:}',1,11)
-    LexToken(EXP,'exp',1,22)
-    LexToken(LPAREN,'(',1,25)
-    LexToken(NAME,'B',1,26)
-    LexToken(RPAREN,')',1,27)
-    LexToken(DIV,'/',1,29)
-    LexToken(SQRT,'sqrt',1,31)
-    LexToken(LPAREN,'(',1,35)
-    LexToken(NAME,'C',1,36)
-    LexToken(RPAREN,')',1,37)
-    LexToken(SUB,'-',1,39)
-    LexToken(LOG,'log',1,41)
-    LexToken(LPAREN,'(',1,44)
-    LexToken(NAME,'D',1,45)
-    LexToken(RPAREN,')',1,46)
+    LexToken(T_ARITH2_OPERATOR,'{+,equal|during}',1,6)
+    LexToken(NAME,'B',1,23)
 
- at endcode
 """
 
 import grass.pygrass.modules as pymod
-from temporal_raster_operator import *
+from temporal_operator import *
 from temporal_algebra import *
 
 ##############################################################################
 
 class TemporalRasterAlgebraLexer(TemporalAlgebraLexer):
-    """!Lexical analyzer for the GRASS GIS temporal algebra"""
+    """Lexical analyzer for the GRASS GIS temporal algebra"""
 
     def __init__(self):
         TemporalAlgebraLexer.__init__(self)
@@ -125,9 +70,12 @@
         'isnull'  : 'ISNULL',
         'isntnull': 'ISNTNULL',
         'null'    : 'NULL',
-        'exist'   : 'EXIST',
+        'exist'   : 'EXIST',   
     }
-
+    
+    # Functions that defines single maps with time stamp and without temporal extent.
+    map_functions = {'map' : 'MAP'}
+    
     # This is the list of token names.
     raster_tokens = (
         'MOD',
@@ -144,7 +92,8 @@
     # Build the token list
     tokens = TemporalAlgebraLexer.tokens \
                     + raster_tokens \
-                    + tuple(mapcalc_functions.values())
+                    + tuple(mapcalc_functions.values()) \
+                    + tuple(map_functions.values())
 
     # Regular expression rules for simple tokens
     t_MOD                 = r'[\%]'
@@ -152,8 +101,8 @@
     t_MULT                = r'[\*]'
     t_ADD                 = r'[\+]'
     t_SUB                 = r'[-]'
-    t_T_ARITH1_OPERATOR   = r'\{([a-zA-Z\| ]+[,])?([\|&+=]?[\%\*\/])\}'
-    t_T_ARITH2_OPERATOR   = r'\{([a-zA-Z\| ]+[,])?([\|&+=]?[+-])\}'
+    t_T_ARITH1_OPERATOR   = r'\{[\%\*\/][,]?[a-zA-Z\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\}'
+    t_T_ARITH2_OPERATOR   = r'\{[+-][,]?[a-zA-Z\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\}'
     t_L_SPAREN            = r'\['
     t_R_SPAREN            = r'\]'
 
@@ -168,6 +117,8 @@
             t.type = TemporalRasterAlgebraLexer.conditional_functions.get(t.value)
         elif t.value in TemporalRasterAlgebraLexer.mapcalc_functions.keys():
             t.type = TemporalRasterAlgebraLexer.mapcalc_functions.get(t.value)
+        elif t.value in TemporalRasterAlgebraLexer.map_functions.keys():
+            t.type = TemporalRasterAlgebraLexer.map_functions.get(t.value)
         else:
             t.type = 'NAME'
         return t
@@ -183,7 +134,7 @@
     # Setting equal precedence level for select and hash operations.
     precedence = (
         ('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT'), # 1
-        ('left', 'ADD', 'SUB', 'T_ARITH2_OPERATOR'), #2
+        ('left', 'ADD', 'SUB', 'T_ARITH2_OPERATOR',  'T_HASH_OPERATOR',  'HASH'), #2
         ('left', 'AND', 'OR', 'T_COMP_OPERATOR', 'MOD', 'DIV', 'MULT',
          'T_ARITH1_OPERATOR'))
 
@@ -191,7 +142,6 @@
                   nprocs = 1, register_null = False):
         TemporalAlgebraParser.__init__(self, pid, run, debug, spatial)
         self.nprocs = nprocs
-        self.empty_maps = {}
         self.register_null = register_null
 
     def check_null(self, t):
@@ -202,73 +152,385 @@
             return "null()"
 
     ######################### Temporal functions ##############################
+    def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
+                               assign_val = False, count_map = False, compare_bool = False,  
+                               compare_cmd = False,  compop = None, aggregate = None,  
+                               new = False,  convert = False,  operator_cmd = False):
+        """Build temporal topology for two space time data sets, copy map objects
+          for given relation into map list.
+          
+          :param maplistA: List of maps.
+          :param maplistB: List of maps.
+          :param topolist: List of strings of temporal relations.
+          :param assign_val: Boolean for assigning a boolean map value based on
+                            the map_values from the compared map list by
+                            topological relationships.
+          :param count_map: Boolean if the number of topological related maps
+                           should be returned.
+          :param compare_bool: Boolean for comparing boolean map values based on
+                            related map list and compariosn operator.
+          :param compare_cmd: Boolean for comparing command list values based on
+                            related map list and compariosn operator.
+          :param compop: Comparison operator, && or ||.
+          :param aggregate: Aggregation operator for relation map list, & or |.
+          :param new: Boolean if new temporary maps should be created.
+          :param convert: Boolean if conditional values should be converted to 
+                        r.mapcalc command strings.
+          :param operator_cmd: Boolean for aggregate arithmetic operators implicitly 
+                        in command list values based on related map lists.
+                    
+          :return: List of maps from maplistA that fulfil the topological relationships
+                  to maplistB specified in topolist.
+        """
+        topologylist = ["EQUAL", "FOLLOWS", "PRECEDES", "OVERLAPS", "OVERLAPPED", \
+                        "DURING", "STARTS", "FINISHES", "CONTAINS", "STARTED", \
+                        "FINISHED"]
+        complementdict = {"EQUAL": "EQUAL", "FOLLOWS" : "PRECEDES",
+                          "PRECEDES" : "FOLLOWS", "OVERLAPS" : "OVERLAPPED",
+                          "OVERLAPPED" : "OVERLAPS", "DURING" : "CONTAINS",
+                          "CONTAINS" : "DURING", "STARTS" : "STARTED",
+                          "STARTED" : "STARTS", "FINISHES" : "FINISHED",
+                          "FINISHED" : "FINISHES"}
+        resultdict = {}
+        # Check if given temporal relation are valid.
+        for topo in topolist:
+          if topo.upper() not in topologylist:
+              raise SyntaxError("Unpermitted temporal relation name '" + topo + "'")
 
-    def eval_toperator(self, operator, comparison = False):
-        """!This function evaluates a string containing temporal operations.
+        # Create temporal topology for maplistA to maplistB.
+        tb = SpatioTemporalTopologyBuilder()
+        # Dictionary with different spatial variables used for topology builder.
+        spatialdict = {'strds' : '2D', 'stvds' : '2D', 'str3ds' : '3D'}
+        # Build spatial temporal topology
+        if self.spatial:
+            tb.build(maplistA, maplistB, spatial = spatialdict[self.stdstype])
+        else:
+            tb.build(maplistA, maplistB)
+        # Iterate through maps in maplistA and search for relationships given
+        # in topolist.
+        for map_i in maplistA:
+            tbrelations = map_i.get_temporal_relations()
+            # Check for boolean parameters for further calculations.
+            if assign_val:
+                self.assign_bool_value(map_i,  tbrelations,  topolist)
+            elif compare_bool:
+                self.compare_bool_value(map_i,  tbrelations, compop, aggregate, topolist)
+            elif compare_cmd:
+                self.compare_cmd_value(map_i,  tbrelations, compop, aggregate, topolist, convert)
+            elif operator_cmd:
+                self.operator_cmd_value(map_i,  tbrelations, compop, topolist)
+                
+            for topo in topolist:
+                if topo.upper() in tbrelations.keys():
+                    if count_map:
+                        relationmaplist = tbrelations[topo.upper()]
+                        gvar = GlobalTemporalVar()
+                        gvar.td = len(relationmaplist)
+                        if "map_value" in dir(map_i):
+                            map_i.map_value.append(gvar)
+                        else:
+                            map_i.map_value = gvar
+                    # Use unique identifier, since map names may be equal
+                    resultdict[map_i.uid] = map_i
+        resultlist = resultdict.values()
+        
+        # Sort list of maps chronological.
+        resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
+        
+        return(resultlist)    
+    
+    def build_command_string(self, map_i,  relmap, operator = None, cmd_type = None):
+        """This function build the r.mapcalc command string for conditionals, 
+            spatial variable combinations and boolean comparisons.
+            
+            For Example: 'if(a1 == 1, b1, c2)' or 'exist(a1) && sin(b1)'
+            
+            :param map_i: map object with temporal extent and built relations.
+            :param relmap: map object with defined temporal relation to map_i.
+            :param operator: String representing operator between two spatial variables 
+                            (&&,||,+,-,*,/).
+            :param cmd_type: map object with defined temporal relation to map_i:
+                            condition, conclusion or operator.
+            
+            :return: the resulting command string for conditionals or spatial variable 
+                combinations
+        """    
+        def sub_cmdstring(map_i):
+            """This function search for command string in a map object and 
+            return substitute string (contained commandstring or map name)"""
+            if "cmd_list" in dir(map_i):
+                map_sub = map_i.cmd_list
+            elif "map_value" in dir(map_i) and len(map_i.map_value) > 0 and map_i.map_value[0].get_type() == "timediff":
+                map_sub = map_i.map_value[0].get_type_value()[0]
+            else:
+                try:
+                    map_sub = map_i.get_id()
+                except:
+                    map_sub = map_i
+            return(map_sub)
+        
+        # Check  for type of operation, conditional or spatial variable combination 
+        # and Create r.mapcalc expression string for the operation.
+        cmdstring = ""
+        if cmd_type == 'condition':
+            conditionsub = sub_cmdstring(map_i)
+            conclusionsub = sub_cmdstring(relmap)
+            cmdstring = "if(%s, %s)" %(conditionsub, conclusionsub)
+        elif cmd_type == 'conclusion':
+            thensub = sub_cmdstring(map_i)
+            elsesub = sub_cmdstring(relmap)
+            cmdstring = "%s, %s" %(thensub, elsesub)
+        elif cmd_type == 'operator':
+            leftsub = sub_cmdstring(map_i)
+            rightsub = sub_cmdstring(relmap)
+            if operator == None:
+                self.msgr.fatal("Error: Can't build command string for map %s, operator is missing" \
+                    %(map_i.get_map_id()))
+            cmdstring = "(%s %s %s)" %(leftsub, operator,  rightsub)
+        return(cmdstring)
 
-         @param operator String of temporal operations, e.g. {equal|during,=!:}.
+    def compare_cmd_value(self,  map_i, tbrelations, compop, aggregate,  
+                                                topolist = ["EQUAL"],  convert = False):
+        """ Function to evaluate two map lists with boolean values by boolean 
+            comparison operator. Extended temporal algebra version with command 
+            list builder for temporal raster algebra.
+            
+            :param map_i: Map object with temporal extent.
+            :param tbrelations: List of temporal relation to map_i.
+            :param topolist: List of strings for given temporal relations.
+            :param compop: Comparison operator, && or ||.
+            :param aggregate: Aggregation operator for relation map list, & or |.
+            :param convert: Boolean if conditional values should be converted to 
+                        r.mapcalc command strings.
 
-         @return List of temporal relations (equal, during), the given function
-          (!:) and the interval/instances (=).
-        @code
-         >>> init(True)
-         >>> p = TemporalRasterBaseAlgebraParser()
-         >>> operator = "{equal,:}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL'], '=', ':')
-         >>> operator = "{equal|during,:}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL', 'DURING'], '=', ':')
-         >>> operator = "{equal,!:}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL'], '=', '!:')
-         >>> operator = "{equal|during,!:}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL', 'DURING'], '=', '!:')
-         >>> operator = "{equal|during,=!:}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL', 'DURING'], '=', '!:')
-         >>> operator = "{equal|during|starts,#}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL', 'DURING', 'STARTS'], '=', '#')
-         >>> operator = "{!:}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL'], '=', '!:')
-         >>> operator = "{=:}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL'], '=', ':')
-         >>> operator = "{#}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL'], '=', '#')
-         >>> operator = "{equal|during}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL', 'DURING'], None, None)
-         >>> operator = "{equal}"
-         >>> p.eval_toperator(operator)
-         (['EQUAL'], None, None)
-         >>> operator = "{equal,||}"
-         >>> p.eval_toperator(operator, True)
-         (['EQUAL'], '=', '||')
-         >>> operator = "{equal|during,&&}"
-         >>> p.eval_toperator(operator, True)
-         (['EQUAL', 'DURING'], '=', '&&')
+            :return: Map object with conditional value that has been evaluated by
+                        comparison operators.
+        """
+        # Build comandlist list with elements from related maps and given relation operator.
+        if convert and "condition_value" in dir(map_i):
+            if map_i.condition_value != []:
+                cmdstring = str(int(map_i.condition_value[0]))
+                map_i.cmd_list = cmdstring
+        if "cmd_list" in dir(map_i):
+            leftcmd = map_i.cmd_list
+            cmd_value_list = [leftcmd]
+        count = 0
+        
+        for topo in topolist:
+            if topo.upper() in tbrelations.keys():
+                relationmaplist = tbrelations[topo.upper()]
+                if count == 0 and "cmd_list" in dir(map_i):
+                    cmd_value_list.append(compop)
+                    cmd_value_list.append('(')
+                for relationmap in relationmaplist:
+                    if convert and "condition_value" in dir(relationmap):
+                        if relationmap.condition_value != []:
+                            cmdstring = str(int(relationmap.condition_value[0]))
+                            relationmap.cmd_list = cmdstring
+                    if "cmd_list" in dir(relationmap):
+                        if count > 0:
+                            cmd_value_list.append(aggregate + aggregate)
+                        cmd_value_list.append(relationmap.cmd_list)
+                        count = count + 1
+        if count > 0:
+            cmd_value_list.append(')')
+            cmd_value_str = ''.join(map(str, cmd_value_list))
+            # Add command list to result map.
+            map_i.cmd_list = cmd_value_str
+        
+            return(cmd_value_str)
 
-        @endcode
+    def operator_cmd_value(self,  map_i, tbrelations, operator, topolist = ["EQUAL"]):
+        """ Function to evaluate two map lists by given arithmetic operator.
+        
+            :param map_i: Map object with temporal extent.
+            :param tbrelations: List of temporal relation to map_i.
+            :param topolist: List of strings for given temporal relations.
+            :param operator: Arithmetic operator, +-*/%.
 
+            :return: Map object with command list with  operators that has been 
+                        evaluated by implicit aggregration.
         """
-        p = TemporalRasterOperatorParser()
-        p.parse(operator, comparison)
-        p.relations = [rel.upper() for rel in p.relations]
+        # Build comandlist list with elements from related maps and given relation operator.
+        leftcmd = map_i
+        cmdstring = ""
+        for topo in topolist:
+            if topo.upper() in tbrelations.keys():
+                relationmaplist = tbrelations[topo.upper()]
+                for relationmap in relationmaplist:
+                    # Create r.mapcalc expression string for the operation.
+                    cmdstring = self.build_command_string(leftcmd,  
+                                                                                        relationmap, 
+                                                                                        operator = operator, 
+                                                                                        cmd_type = "operator")
+                    leftcmd = cmdstring
+        # Add command list to result map.
+        map_i.cmd_list = cmdstring
+        
+        return(cmdstring)
+    
+    def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' , 
+                                                        cmd_bool = False, cmd_type = None,  operator = None):
+        """ Change temporal extent of map list based on temporal relations to 
+                other map list and given temporal operator.
 
-        return(p.relations, p.temporal, p.function)
+            :param maplist: List of map objects for which relations has been build 
+                                        correctely.
+            :param topolist: List of strings of temporal relations.
+            :param temporal: The temporal operator specifying the temporal
+                                            extent operation (intersection, union, disjoint 
+                                            union, right reference, left reference).
+            :param cmd_bool: Boolean if command string should be merged for related maps.
+            :param cmd_type: map object with defined temporal relation to map_i:
+                            condition, conclusion or operator.
+            :param operator: String defining the type of operator.
 
+            :return: Map list with specified temporal extent and optional command string.
+        """
+        resultdict = {}
+        
+        for map_i in maplist:
+            # Loop over temporal related maps and create overlay modules.
+            tbrelations = map_i.get_temporal_relations()
+            # Generate an intermediate map for the result map list.
+            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+                                                                        copy = True,  rename = True)
+            # Combine temporal and spatial extents of intermediate map with related maps.
+            for topo in topolist:
+                if topo in tbrelations.keys():
+                    for map_j in (tbrelations[topo]):
+                        if temporal == 'r':
+                            # Generate an intermediate map for the result map list.
+                            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+                                                                                        copy = True,  rename = True)
+                        # Create overlayed map extent.
+                        returncode = self.overlay_map_extent(map_new, map_j, 'and', \
+                                                                temp_op = temporal)
+                        # Stop the loop if no temporal or spatial relationship exist.
+                        if returncode == 0:
+                            break
+                        # Append map to result map list.
+                        elif returncode == 1:
+                            # print(map_new.cmd_list)
+                            # resultlist.append(map_new)
+                            if cmd_bool:
+                                # Create r.mapcalc expression string for the operation.
+                                cmdstring = self.build_command_string(map_i,  
+                                                                                                    map_j, 
+                                                                                                    operator = operator, 
+                                                                                                    cmd_type = cmd_type)
+                                # Conditional append of module command.
+                                map_new.cmd_list = cmdstring
+                            # Write map object to result dictionary.
+                            resultdict[map_new.uid] = map_new
+                    if returncode == 0:
+                        break
+            # Append map to result map list.
+            #if returncode == 1:
+            #    resultlist.append(map_new)
+        # Get sorted map objects as values from result dictionoary.
+        resultlist = resultdict.values()
+        resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
+        
+        return(resultlist)
+    
+    def build_condition_cmd_list(self, iflist, thenlist,  elselist = None,  
+                                                        condition_topolist = ["EQUAL"], 
+                                                        conclusion_topolist = ["EQUAL"], 
+                                                        temporal = 'l', null = False):
+        """This function build the r.mapcalc command strings for spatial conditionals.
+            For Example: 'if(a1 == 1, b1, c2)'
+
+            :param iflist: Map list with temporal extents and command list.
+            :param thenlist: Map list with temporal extents and command list or numeric string.
+            :param elselist: Map list with temporal extents and command list or numeric string.
+            :param condition_topolist: List of strings for given temporal relations between 
+                            conditions and conclusions.
+            :param conclusion_topolist: List of strings for given temporal relations between 
+                            conditions (then and else).
+            :param temporal: The temporal operator specifying the temporal
+                                            extent operation (intersection, union, disjoint 
+                                            union, right reference, left reference).
+            :param null: Boolean if null map support should be activated.
+
+            :return: map list with resulting command string for given condition type.
+        """    
+        resultlist = []
+        # First merge conclusion command maplists or strings.
+        # Check if alternative conclusion map list is given.
+        if all([isinstance(thenlist, list), isinstance(elselist, list)]):
+            # Build conclusion command map list.
+            conclusiontopolist = self.get_temporal_topo_list(thenlist, elselist,  conclusion_topolist)
+            conclusionlist = self.set_temporal_extent_list(conclusiontopolist, 
+                                                                                    topolist = conclusion_topolist, 
+                                                                                    temporal = temporal , 
+                                                                                    cmd_bool = True, 
+                                                                                    cmd_type = "conclusion")
+        # Check if any conclusion is a numeric statements.
+        elif any([isinstance(thenlist, str), isinstance(elselist, str)]):
+            conclusionlist = []            
+            # Check if only alternative conclusion is a numeric statements.
+            if all([isinstance(thenlist, list), isinstance(elselist, str)]):
+                listinput = thenlist
+                numinput = elselist
+                for map_i in listinput:
+                    # Create r.mapcalc expression string for the operation.
+                    cmdstring = self.build_command_string( map_i,  
+                                                                                            numinput, 
+                                                                                            cmd_type = 'conclusion')
+                    # Conditional append of module command.
+                    map_i.cmd_list = cmdstring
+                    # Append map to result map list.
+                    conclusionlist.append(map_i)
+            # Check if only direct conclusion is a numeric statements.
+            elif all([isinstance(thenlist, str), isinstance(elselist, list)]):                
+                listinput = elselist
+                numinput =  thenlist
+                for map_i in listinput:
+                    # Create r.mapcalc expression string for the operation.
+                    cmdstring = self.build_command_string(numinput,  
+                                                                                            map_i,  
+                                                                                            cmd_type = 'conclusion')
+                    # Conditional append of module command.
+                    map_i.cmd_list = cmdstring
+                    # Append map to result map list.
+                    conclusionlist.append(map_i)
+            elif all([isinstance(thenlist, str), isinstance(elselist, str)]):
+                conclusionlist = thenlist + ',' + elselist
+        else:
+            # The direct conclusion is used.
+            conclusionlist = thenlist
+        # Use the conclusion map or string to merge it with the condition and 
+        # return maplist.
+        if isinstance(conclusionlist,  str):
+            resultlist = []
+            for map_i in iflist:
+                # Create r.mapcalc expression string for the operation.
+                cmdstring = self.build_command_string(map_i,  
+                                                                                        conclusionlist,  
+                                                                                        cmd_type = 'condition')
+                # Conditional append of module command.
+                map_i.cmd_list = cmdstring
+                # Append map to result map list.
+                resultlist.append(map_i)
+            return(resultlist)
+        elif isinstance(conclusionlist,  list):
+            # Build result command map list between conditions and conclusions.
+            conditiontopolist = self.get_temporal_topo_list(iflist, conclusionlist,  
+                                                                                        topolist = condition_topolist)
+            resultlist = self.set_temporal_extent_list(conditiontopolist, 
+                                                                            topolist = condition_topolist, 
+                                                                            temporal = 'r' , 
+                                                                            cmd_bool = True, 
+                                                                            cmd_type = "condition")
+            return(resultlist)
+
     ###########################################################################
 
     def p_statement_assign(self, t):
         # The expression should always return a list of maps.
         """
         statement : stds EQUALS expr
-
         """
         if self.run:
             # Create the process queue for parallel mapcalc processing
@@ -280,16 +542,18 @@
                 register_list = []
                 for i in range(num):
                     # Check if resultmap names exist in GRASS database.
-                    rastername = self.basename + "_" + str(i) + "@" + self.mapset
-                    rastermap = RasterDataset(rastername)
-                    if rastermap.map_exists() and self.overwrite == False:
-                        self.msgr.fatal("Error raster maps with basename %s exist. Use --o flag to overwrite existing file" \
-                                            %(rastername))
+                    map_name = self.basename + "_" + str(i) + "@" + self.mapset
+                    if self.stdstype == "strds":
+                        new_map = RasterDataset(map_name)
+                    else:
+                        new_map = Raster3DDataset(map_name)
+                    if new_map.map_exists() and self.overwrite == False:
+                        self.msgr.fatal("Error maps with basename %s exist. Use --o flag to overwrite existing file" \
+                                            %(map_name))
                 map_test_list = []
                 for map_i in t[3]:
                     newident = self.basename + "_" + str(count)
                     if "cmd_list" in dir(map_i):
-                        print(newident + ' = ' + map_i.cmd_list)
                         # Build r.mapcalc module and execute expression.
                         # Change map name to given basename.
                         # Create deepcopy of r.mapcalc module.
@@ -304,23 +568,34 @@
                         m.inputs["expression"].value = str(m_expression)
                         m.flags["overwrite"].value = self.overwrite
                         process_queue.put(m)
+                    
+                    elif map_i.map_exists():
+                        # Copy map if it exists
+                        map_test = map_i.get_new_instance(newident + "@" + self.mapset)
+                        map_test.set_temporal_extent(map_i.get_temporal_extent())
+                        map_test.set_spatial_extent(map_i.get_spatial_extent())
+                        map_test_list.append(map_test)
+                        
+                        m = copy.deepcopy(self.m_mapcalc)
+                        m_expression = newident + "=" + map_i.get_map_id()
+                        m.inputs["expression"].value = str(m_expression)
+                        m.flags["overwrite"].value = self.overwrite
+                        print m.get_bash()
+                        process_queue.put(m)
+                        
                     else:
-                        map_i.set_id(newident + "@" + self.mapset)
-                        map_test_list.append(map_i)
+                        self.msgr.error(_("Error computing map <%s>"%(map_i.get_id()) ))
                     count  += 1
 
                 process_queue.wait()
 
                 for map_i in map_test_list:
-                    if not map_test.map_exists():
-                        self.msgr.error(_("Error computing map <%s>"%(map_i.get_id()) ))
-                    else:
-                        register_list.append(map_i)
+                    register_list.append(map_i)
 
                 # Open connection to temporal database.
                 dbif, connect = init_dbif(self.dbif)
                 # Create result space time dataset.
-                resultstds = open_new_space_time_dataset(t[1], self.stdstype, \
+                resultstds = open_new_stds(t[1], self.stdstype, \
                                                          'absolute', t[1], t[1], \
                                                          'mean', self.dbif, \
                                                          overwrite = self.overwrite)
@@ -328,12 +603,11 @@
                     # Get meta data from grass database.
                     map_i.load()
                     # Do not register empty maps if not required
-
                     # In case of a null map continue, do not register null maps
                     if map_i.metadata.get_min() is None and \
                        map_i.metadata.get_max() is None:
                         if not self.register_null:
-                            self.empty_maps[map_i.get_name()] = map_i.get_name()
+                            self.removable_maps[map_i.get_name()] = map_i
                             continue
 
                     if map_i.is_in_db(dbif) and self.overwrite:
@@ -341,7 +615,7 @@
                         map_i.update_all(dbif)
                     elif map_i.is_in_db(dbif) and self.overwrite == False:
                         # Raise error if map exists and no overwrite flag is given.
-                        self.msgr.fatal("Error vector map %s exist in temporal database. Use overwrite flag.  : \n%s" \
+                        self.msgr.fatal("Error raster map %s exist in temporal database. Use overwrite flag.  : \n%s" \
                                             %(map_i.get_map_id(), cmd.popen.stderr))
                     else:
                         # Insert map into temporal database.
@@ -352,8 +626,46 @@
                 dbif.close()
                 t[0] = register_list
 
-                self.remove_empty_maps()
+                self.remove_maps()
+    
+    def p_expr_spmap_function(self, t):
+        # Add a single map.
+        # Only the spatial extent of the map is evaluated. 
+        # Temporal extent is not existing.
+        # Examples:
+        #    R = map(A) 
+        """
+        mapexpr : MAP LPAREN stds RPAREN
+        """
+        if self.run:
+            # Check input map.
+            input = t[3]
+            if not isinstance(input, list):
+                # Check for mapset in given stds input.
+                if input.find("@") >= 0:
+                    id_input = input
+                else:
+                    id_input = input + "@" + self.mapset
+                # Create empty map dataset.
+                map_i = dataset_factory(self.maptype, id_input)
+                # Check for occurence of space time dataset.
+                if map_i.map_exists() == False:
+                    raise FatalError(_("%s map <%s> not found in GRASS spatial database") %
+                        (map_i.get_type(), id_input))
+                else:
+                    # Select dataset entry from database.
+                    map_i.select(dbif=self.dbif)
+                    # Create command list for map object.
+                    cmdstring = "(%s)" %(map_i.get_map_id())
+                    map_i.cmd_list = cmdstring
+            # Return map object.
+            t[0] = cmdstring
+        else:
+            t[0] = "map(" + t[3] + ")"
 
+        if self.debug:
+            print "map(" + t[3] + ")"
+
     def p_arith1_operation(self, t):
         """
         expr : stds MOD stds
@@ -378,6 +690,7 @@
         # Check input stds.
         maplistA = self.check_stds(t[1])
         maplistB = self.check_stds(t[3])
+        
         topolist = self.get_temporal_topo_list(maplistA, maplistB)
 
         if self.run:
@@ -385,15 +698,13 @@
             for map_i in topolist:
                 # Generate an intermediate map for the result map list.
                 map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
                 # Loop over temporal related maps and create overlay modules.
                 tbrelations = map_i.get_temporal_relations()
                 count = 0
                 for map_j in (tbrelations['EQUAL']):
                     # Create overlayed map extent.
                     returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                            temp_op = '=')
+                                                            temp_op = 'l')
                     # Stop the loop if no temporal or spatial relationship exist.
                     if returncode == 0:
                         break
@@ -404,25 +715,12 @@
                         # Generate an intermediate map
                         name = self.generate_map_name()
 
-                    if "map_value" in dir(map_j) and len(map_j.map_value) > 0 and map_j.map_value[0].get_type() == "timediff":
-                        mapbinput = map_j.map_value[0].get_type_value()[0]
-                    else:
-                    # Set first input for overlay module.
-                        mapbinput = map_j.get_id()
-
                     # Create r.mapcalc expression string for the operation.
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "(%s %s %s)" %(map_new.cmd_list, t[2], mapbinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "(%s %s %s)" %(mapainput, t[2], map_j.cmd_list)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "(%s %s %s)" %(map_new.cmd_list, t[2], map_j.cmd_list)
-                    else:
-                        cmdstring = "(%s %s %s)" %(mapainput, t[2], mapbinput)
+                    cmdstring = self.build_command_string(map_i, map_j,  
+                                                                                    operator = t[2], 
+                                                                                    cmd_type = "operator")
                     # Conditional append of module command.
                     map_new.cmd_list = cmdstring
-                    # Set new map name to temporary map name.
-                    mapainput = name
                     count += 1
                 # Append map to result map list.
                 if returncode == 1:
@@ -437,11 +735,23 @@
     def p_arith1_operation_numeric1(self, t):
         """
         expr : stds MOD number
-             | expr MOD number
-             | stds DIV number
-             | expr DIV number
-             | stds MULT number
-             | expr MULT number
+            | expr MOD number
+            | stds DIV number
+            | expr DIV number
+            | stds MULT number
+            | expr MULT number
+            | stds MOD numberstr
+            | expr MOD numberstr
+            | stds DIV numberstr
+            | expr DIV numberstr
+            | stds MULT numberstr
+            | expr MULT numberstr            
+            | stds MOD mapexpr
+            | expr MOD mapexpr
+            | stds DIV mapexpr
+            | expr DIV mapexpr
+            | stds MULT mapexpr
+            | expr MULT mapexpr            
         """
         # Check input stds.
         maplist = self.check_stds(t[1])
@@ -470,11 +780,23 @@
     def p_arith1_operation_numeric2(self, t):
         """
         expr : number MOD stds
-             | number MOD expr
-             | number DIV stds
-             | number DIV expr
-             | number MULT stds
-             | number MULT expr
+            | number MOD expr
+            | number DIV stds
+            | number DIV expr
+            | number MULT stds
+            | number MULT expr
+            | numberstr MOD stds
+            | numberstr MOD expr
+            | numberstr DIV stds
+            | numberstr DIV expr
+            | numberstr MULT stds
+            | numberstr MULT expr            
+            | mapexpr MOD stds
+            | mapexpr MOD expr
+            | mapexpr DIV stds
+            | mapexpr DIV expr
+            | mapexpr MULT stds
+            | mapexpr MULT expr             
         """
         # Check input stds.
         maplist = self.check_stds(t[3])
@@ -526,15 +848,14 @@
             for map_i in topolist:
                 # Generate an intermediate map for the result map list.
                 map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
+
                 # Loop over temporal related maps and create overlay modules.
                 tbrelations = map_i.get_temporal_relations()
                 count = 0
                 for map_j in (tbrelations['EQUAL']):
                     # Create overlayed map extent.
                     returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                            temp_op = '=')
+                                                            temp_op = 'l')
                     # Stop the loop if no temporal or spatial relationship exist.
                     if returncode == 0:
                         break
@@ -544,26 +865,13 @@
                     else:
                         # Generate an intermediate map
                         name = self.generate_map_name()
-
-                    if "map_value" in dir(map_j) and len(map_j.map_value) > 0 and map_j.map_value[0].get_type() == "timediff":
-                        mapbinput = map_j.map_value[0].get_type_value()[0]
-                    else:
-                    # Set first input for overlay module.
-                        mapbinput = map_j.get_id()
-
+                    
                     # Create r.mapcalc expression string for the operation.
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "(%s %s %s)" %(map_new.cmd_list, t[2], mapbinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "(%s %s %s)" %(mapainput, t[2], map_j.cmd_list)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "(%s %s %s)" %(map_new.cmd_list, t[2], map_j.cmd_list)
-                    else:
-                        cmdstring = "(%s %s %s)" %(mapainput, t[2], mapbinput)
+                    cmdstring = self.build_command_string(map_i, map_j,  
+                                                                                    operator = t[2], 
+                                                                                    cmd_type = "operator")
                     # Conditional append of module command.
                     map_new.cmd_list = cmdstring
-                    # Set new map name to temporary map name.
-                    mapainput = name
                     count += 1
 
                 # Append map to result map list.
@@ -579,9 +887,17 @@
     def p_arith2_operation_numeric1(self, t):
         """
         expr : stds ADD number
-             | expr ADD number
-             | stds SUB number
-             | expr SUB number
+            | expr ADD number
+            | stds SUB number
+            | expr SUB number
+            | stds ADD numberstr
+            | expr ADD numberstr
+            | stds SUB numberstr
+            | expr SUB numberstr            
+            | stds ADD mapexpr
+            | expr ADD mapexpr
+            | stds SUB mapexpr
+            | expr SUB mapexpr
         """
         # Check input stds.
         maplist = self.check_stds(t[1])
@@ -609,9 +925,17 @@
     def p_arith2_operation_numeric2(self, t):
         """
         expr : number ADD stds
-             | number ADD expr
-             | number SUB stds
-             | number SUB expr
+            | number ADD expr
+            | number SUB stds
+            | number SUB expr
+            | numberstr ADD stds
+            | numberstr ADD expr
+            | numberstr SUB stds            
+            | numberstr SUB expr     
+            | mapexpr ADD stds
+            | mapexpr ADD expr
+            | mapexpr SUB stds
+            | mapexpr SUB expr   
         """
         # Check input stds.
         maplist = self.check_stds(t[3])
@@ -645,73 +969,20 @@
              | stds T_ARITH1_OPERATOR t_td_var
              | expr T_ARITH1_OPERATOR t_td_var
         """
-        # Check input stds.
-        maplistA = self.check_stds(t[1])
-        maplistB = self.check_stds(t[3])
-        relations, temporal, function= self.eval_toperator(t[2])
-        topolist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations)
+        if self.run:        
+            # Check input stds.
+            maplistA = self.check_stds(t[1])
+            maplistB = self.check_stds(t[3])
+            relations, temporal, function, aggregate = self.eval_toperator(t[2],  optype = 'raster')
+            # Build conditional values based on topological relationships.
+            complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
+                               operator_cmd = True, compop = function)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
+        
+        t[0] = resultlist   
 
-        if self.run:
-            resultlist = []
-            for map_i in topolist:
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
-                # Loop over temporal related maps and create overlay modules.
-                tbrelations = map_i.get_temporal_relations()
-                count = 0
-                for topo in relations:
-                    if topo in tbrelations.keys():
-                        for map_j in (tbrelations[topo]):
-                            # Create overlayed map extent.
-                            returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                                    temp_op = temporal)
-                            print(returncode)
-                            # Stop the loop if no temporal or spatial relationship exist.
-                            if returncode == 0:
-                                break
-                            if count == 0:
-                                # Set map name.
-                                name = map_new.get_id()
-                            else:
-                                # Generate an intermediate map
-                                name = self.generate_map_name()
-                                map_new.set_id(name + "@" + mapset)
-                            # Set second input for overlay module.
-
-                            if "map_value" in dir(map_j) and len(map_j.map_value) > 0 and map_j.map_value[0].get_type() == "timediff":
-                                mapbinput = map_j.map_value[0].get_type_value()[0]
-                            else:
-                            # Set first input for overlay module.
-                                mapbinput = map_j.get_id()
-
-                            # Create r.mapcalc expression string for the operation.
-                            if "cmd_list" in dir(map_new):
-                                cmdstring = "(%s %s %s)" %(map_new.cmd_list, function, mapbinput)
-                                print('with cmd in a: ' + map_j.get_id())
-                            elif "cmd_list" in dir(map_j):
-                                cmdstring = "(%s %s %s)" %(mapainput, function, map_j.cmd_list)
-                                print('with cmd in b')
-                            elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                                cmdstring = "(%s %s %s)" %(map_new.cmd_list, function, map_j.cmd_list)
-                                print('with cmd in b')
-                            else:
-                                cmdstring = "(%s %s %s)" %(mapainput, function, mapbinput)
-                            print(cmdstring)
-                            # Conditional append of module command.
-                            map_new.cmd_list = cmdstring
-                            # Set new map name to temporary map name.
-                            mapainput = name
-                            count += 1
-                        if returncode == 0:
-                            break
-                # Append map to result map list.
-                if returncode == 1:
-                    resultlist.append(map_new)
-
-            t[0] = resultlist
-
         if self.debug:
             for map in resultlist:
                 print map.cmd_list
@@ -725,72 +996,39 @@
              | stds T_ARITH2_OPERATOR t_td_var
              | expr T_ARITH2_OPERATOR t_td_var
         """
-        # Check input stds.
-        maplistA = self.check_stds(t[1])
-        maplistB = self.check_stds(t[3])
-        relations, temporal, function= self.eval_toperator(t[2])
-        topolist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations)
-
-        if self.run:
-            resultlist = []
-            for map_i in topolist:
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
-                # Loop over temporal related maps and create overlay modules.
-                tbrelations = map_i.get_temporal_relations()
-                count = 0
-                for topo in relations:
-                    if topo in tbrelations.keys():
-                        for map_j in (tbrelations[topo]):
-                            # Create overlayed map extent.
-                            returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                                    temp_op = temporal)
-                            # Stop the loop if no temporal or spatial relationship exist.
-                            if returncode == 0:
-                                break
-                            if count == 0:
-                                # Set map name.
-                                name = map_new.get_id()
-                            else:
-                                # Generate an intermediate map
-                                name = self.generate_map_name()
-                                map_new.set_id(name + "@" + self.mapset)
-                            # Set second input for overlay module.
-
-                            if "map_value" in dir(map_j) and len(map_j.map_value) > 0 and map_j.map_value[0].get_type() == "timediff":
-                                mapbinput = map_j.map_value[0].get_type_value()[0]
-                            else:
-                            # Set first input for overlay module.
-                                mapbinput = map_j.get_id()
-
-                            # Create r.mapcalc expression string for the operation.
-                            if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                                cmdstring = "(%s %s %s)" %(map_new.cmd_list, function, mapbinput)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                                cmdstring = "(%s %s %s)" %(mapainput, function, map_j.cmd_list)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                                cmdstring = "(%s %s %s)" %(map_new.cmd_list, function, map_j.cmd_list)
-                            else:
-                                cmdstring = "(%s %s %s)" %(mapainput, function, mapbinput)
-                            # Conditional append of module command.
-                            map_new.cmd_list = cmdstring
-                            # Set new map name to temporary map name.
-                            mapainput = name
-                            count += 1
-                        if returncode == 0:
-                            break
-                # Append map to result map list.
-                if returncode == 1:
-                    resultlist.append(map_new)
-
-            t[0] = resultlist
-
+        if self.run:        
+            # Check input stds.
+            maplistA = self.check_stds(t[1])
+            maplistB = self.check_stds(t[3])
+            relations, temporal, function, aggregate = self.eval_toperator(t[2],  optype = 'raster')
+            # Build conditional values based on topological relationships.
+            complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
+                               operator_cmd = True, compop = function)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
+        
+        t[0] = resultlist
+  
         if self.debug:
             for map in resultlist:
                 print map.cmd_list
 
+    def p_arith_operation_numeric_string(self, t):
+        """
+        numberstr : number ADD number
+            | number SUB number
+            | number DIV number
+            | number MULT number
+            | number MOD number
+        """
+        numstring = "(%s %s %s)" %(t[1], t[2], t[3])
+
+        t[0] = numstring
+
+        if self.debug:
+            print(numstring)
+    
     def p_mapcalc_function(self, t):
         # Supported mapcalc functions.
         """
@@ -814,7 +1052,7 @@
                 print map.cmd_list
 
 
-    def p_mapcalc_operation(self, t):
+    def p_mapcalc_operation1(self, t):
         # Examples:
         # sin(A)
         # log(B)
@@ -844,8 +1082,24 @@
             for map in resultlist:
                 print map.cmd_list
 
+    def p_mapexpr_operation(self, t):
+        # Examples:
+        # sin(map(a))
+        """
+        mapexpr : mapcalc_arith LPAREN mapexpr RPAREN
+        """
+        # Check input stds.
+        mapstring = t[3]
 
-    def p_s_var_expr(self, t):
+        if self.run:
+            cmdstring = "%s(%s)" %(t[1].lower(), mapstring)
+
+            t[0] = cmdstring
+
+        if self.debug:
+            print mapstring
+
+    def p_s_var_expr_1(self, t):
         # Examples:
         #   isnull(A)
         """
@@ -874,7 +1128,7 @@
             for map in resultlist:
                 print map.cmd_list
 
-    def p_s_var_expr_1(self, t):
+    def p_s_var_expr_2(self, t):
         # Examples:
         #   isntnull(A)
         """
@@ -903,7 +1157,7 @@
             for map in resultlist:
                 print map.cmd_list
 
-    def p_s_var_expr2(self, t):
+    def p_s_var_expr_3(self, t):
         # Examples:
         #   A <= 2
         """
@@ -932,70 +1186,8 @@
             for map in resultlist:
                 print map.cmd_list
 
-    def p_s_var_expr3(self, t):
+    def p_s_var_expr_4(self, t):
         # Examples:
-        #   A <= 2 || B == 10
-        #   A < 3 && A > 1
-        """
-        s_var_expr : s_var_expr AND AND s_var_expr
-                   | s_var_expr OR OR s_var_expr
-        """
-        # Check input stds.
-        maplistA = self.check_stds(t[1])
-        maplistB = self.check_stds(t[4])
-        topolist = self.get_temporal_topo_list(maplistA, maplistB)
-
-        if self.run:
-            resultlist = []
-            for map_i in topolist:
-                # Loop over temporal related maps and create overlay modules.
-                tbrelations = map_i.get_temporal_relations()
-                count = 0
-                for map_j in (tbrelations['EQUAL']):
-                    # Generate an intermediate map for the result map list.
-                    map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                    # Set first input for overlay module.
-                    mapainput = map_i.get_id()
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                            temp_op = '=')
-                    # Stop the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        break
-                    if count == 0:
-                        # Set map name.
-                        name = map_new.get_id()
-                    else:
-                        # Generate an intermediate map
-                        name = self.generate_map_name()
-
-                    # Set first input for overlay module.
-                    mapbinput = map_j.get_id()
-                    # Create r.mapcalc expression string for the operation.
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "%s %s %s" %(map_new.cmd_list, t[2] + t[3], mapbinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "%s %s %s" %(mapainput, t[2] + t[3], map_j.cmd_list)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "%s %s %s" %(map_new.cmd_list, t[2] + t[3], map_j.cmd_list)
-                    else:
-                        cmdstring = "%s %s %s" %(mapainput, t[2] + t[3], mapbinput)
-                    # Conditional append of module command.
-                    map_new.cmd_list = cmdstring
-                    # Set new map name to temporary map name.
-                    #mapainput = name
-                    count += 1
-                    # Append map to result map list.
-                    if returncode == 1:
-                        resultlist.append(map_new)
-            t[0] = resultlist
-
-        if self.debug:
-            for map in resultlist:
-                print map.cmd_list
-
-    def p_s_var_expr4(self, t):
-        # Examples:
         #   exist(B)
         """
         s_var_expr : EXIST LPAREN stds RPAREN
@@ -1022,7 +1214,62 @@
         if self.debug:
             for map in resultlist:
                 print map.cmd_list
+    
+    def p_s_var_expr_comp(self, t):
+        # Examples:
+        #   A <= 2 || B == 10
+        #   A < 3 && A > 1
+        """
+        s_var_expr : s_var_expr AND AND s_var_expr
+                   | s_var_expr OR OR s_var_expr
+        """        
+        if self.run:
+            # Check input stds.
+            s_var_exprA = self.check_stds(t[1])
+            s_var_exprB = self.check_stds(t[4])
+            relations = ["EQUAL"]
+            temporal = "l"
+            function = t[2] + t[3]
+            aggregate = t[2]
+            # Build conditional values based on topological relationships.            
+            complist = self.get_temporal_topo_list(s_var_exprA, s_var_exprB, topolist = relations,
+                               compare_cmd = True, compop = function, aggregate = aggregate)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
+                                
+            t[0] = resultlist
 
+        if self.debug:
+            for map in resultlist:
+                print map.cmd_list
+
+    def p_s_var_expr_comp_op(self, t):
+        # Examples:
+        #   A <= 2 {||} B == 10
+        #   A < 3 {&&, equal} A > 1
+        """
+        s_var_expr : s_var_expr T_COMP_OPERATOR s_var_expr
+        """
+        if self.run:
+            # Check input stds.
+            s_var_exprA = self.check_stds(t[1])
+            s_var_exprB = self.check_stds(t[3])
+            # Evaluate temporal comparison operator.
+            relations, temporal, function, aggregate  = self.eval_toperator(t[2],  optype = 'boolean')
+            # Build conditional values based on topological relationships.
+            complist = self.get_temporal_topo_list(s_var_exprA, s_var_exprB, topolist = relations,
+                               compare_cmd = True, compop = function, aggregate = aggregate)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
+            
+            t[0] = resultlist
+
+        if self.debug:
+            for map in resultlist:
+                print map.cmd_list
+
     def p_s_expr_condition_if(self, t):
         # Examples:
         #   if(s_var_expr, B)
@@ -1030,55 +1277,16 @@
         """
         expr : IF LPAREN s_var_expr COMMA stds RPAREN
              | IF LPAREN s_var_expr COMMA expr RPAREN
+             | IF LPAREN ts_var_expr COMMA stds RPAREN
+             | IF LPAREN ts_var_expr COMMA expr RPAREN
         """
-
         ifmaplist = self.check_stds(t[3])
         thenmaplist = self.check_stds(t[5])
-        topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist)
-        resultlist = []
-        for map_i in topolist:
-            #print(map_i.get_id())
-            # Loop over temporal related maps and create overlay modules.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for map_j in (tbrelations['EQUAL']):
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
-                # Create overlayed map extent.
-                returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                        temp_op = '=')
-                # Stop the loop if no temporal or spatial relationship exist.
-                if returncode == 0:
-                    break
-                if count == 0:
-                    # Set map name.
-                    name = map_new.get_id()
-                else:
-                    # Generate an intermediate map
-                    name = self.generate_map_name()
-
-                # Set first input for overlay module.
-                mapbinput = map_j.get_id()
-                # Create r.mapcalc expression string for the operation.
-                if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                    cmdstring = "if(%s,%s)" %(map_new.cmd_list, mapbinput)
-                elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                    cmdstring = "if(%s,%s)" %(mapainput, map_j.cmd_list)
-                elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                    cmdstring = "if(%s,%s)" %(map_new.cmd_list, map_j.cmd_list)
-                else:
-                    cmdstring = "if(%s,%s)" %(mapainput, mapbinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
-                # Set new map name to temporary map name.
-                #mapainput = name
-                count += 1
-                # Append map to result map list.
-                if returncode == 1:
-                    resultlist.append(map_new)
-
+        resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,  
+                                                                            elselist = None, 
+                                                                            condition_topolist = ["EQUAL"], 
+                                                                            conclusion_topolist = ["EQUAL"], 
+                                                                            temporal = 'r', null = False)
         t[0] = resultlist
 
         if self.debug:
@@ -1092,23 +1300,20 @@
         """
         expr : IF LPAREN s_var_expr COMMA number RPAREN
              | IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN RPAREN
+             | IF LPAREN ts_var_expr COMMA number RPAREN
+             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN RPAREN
         """
         ifmaplist = self.check_stds(t[3])
         resultlist = []
         # Select input for r.mapcalc expression based on length of PLY object.
         if len(t) == 7:
-            numinput = t[5]
+            numinput = str(t[5])
         elif len(t) == 9:
-            numinput = self.check_null(t[5])
-
+            numinput = str(t[5] + t[6] + t[7])
         # Iterate over condition map list.
         for map_i in ifmaplist:
-            mapinput = map_i.get_id()
             # Create r.mapcalc expression string for the operation.
-            if "cmd_list" in dir(map_i):
-                cmdstring = "if(%s,%s)" %(map_i.cmd_list, numinput)
-            else:
-                cmdstring = "if(%s,%s)" %(mapinput, numinput)
+            cmdstring = self.build_command_string(map_i, numinput, cmd_type = 'condition')
             # Conditional append of module command.
             map_i.cmd_list = cmdstring
             # Append map to result map list.
@@ -1126,59 +1331,18 @@
         """
         expr : IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds RPAREN
              | IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr RPAREN
         """
-        relations, temporal, function= self.eval_toperator(t[3])
+        relations, temporal, function,  aggregation = self.eval_toperator(t[3],  
+                                                                                        optype = 'relation')
         ifmaplist = self.check_stds(t[5])
         thenmaplist = self.check_stds(t[7])
-        topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist,
-                    topolist = relations)
-        resultlist = []
-        for map_i in topolist:
-            #print(map_i.get_id())
-            # Loop over temporal related maps.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for topo in relations:
-                if topo in tbrelations.keys():
-                    for map_j in (tbrelations[topo]):
-                        # Generate an intermediate map for the result map list.
-                        map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                        # Set first input for overlay module.
-                        mapainput = map_i.get_id()
-                        # Create overlayed map extent.
-                        returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                                temp_op = '=')
-                        # Stop the loop if no temporal or spatial relationship exist.
-                        if returncode == 0:
-                            break
-                        if count == 0:
-                            # Set map name.
-                            name = map_new.get_id()
-                        else:
-                            # Generate an intermediate map
-                            name = self.generate_map_name()
-
-                        # Set first input for overlay module.
-                        mapbinput = map_j.get_id()
-                        #print(mapbinput)
-                        #mapbinput = mapbinput.split('@')[0]
-                        # Create r.mapcalc expression string for the operation.
-                        if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                            cmdstring = "if(%s,%s)" %(map_new.cmd_list, mapbinput)
-                        elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                            cmdstring = "if(%s,%s)" %(mapainput, map_j.cmd_list)
-                        elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                            cmdstring = "if(%s,%s)" %(map_new.cmd_list, map_j.cmd_list)
-                        else:
-                            cmdstring = "if(%s,%s)" %(mapainput, mapbinput)
-                        # Conditional append of module command.
-                        map_new.cmd_list = cmdstring
-                        # Set new map name to temporary map name.
-                        #mapainput = name
-                        count += 1
-                        # Append map to result map list.
-                        if returncode == 1:
-                            resultlist.append(map_new)
+        resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,  
+                                                                            elselist = None, 
+                                                                            condition_topolist = relations, 
+                                                                            conclusion_topolist = ["EQUAL"], 
+                                                                            temporal = 'r', null = False)
         t[0] = resultlist
 
         if self.debug:
@@ -1193,127 +1357,22 @@
              | IF LPAREN s_var_expr COMMA stds COMMA expr RPAREN
              | IF LPAREN s_var_expr COMMA expr COMMA stds RPAREN
              | IF LPAREN s_var_expr COMMA expr COMMA expr RPAREN
+             | IF LPAREN ts_var_expr COMMA stds COMMA stds RPAREN
+             | IF LPAREN ts_var_expr COMMA stds COMMA expr RPAREN
+             | IF LPAREN ts_var_expr COMMA expr COMMA stds RPAREN
+             | IF LPAREN ts_var_expr COMMA expr COMMA expr RPAREN
         """
+        # Check map list inputs.
         ifmaplist = self.check_stds(t[3])
         thenmaplist = self.check_stds(t[5])
         elsemaplist = self.check_stds(t[7])
-        resultlist = []
-        thendict = {}
-        elsedict = {}
-        # Get topologies for the appropriate conclusion term.
-        thentopolist = self.get_temporal_topo_list(ifmaplist, thenmaplist)
-        # Fill dictionaries with related maps for both conclusion terms.
-        for map_i in thentopolist:
-            thenrelations = map_i.get_temporal_relations()
-            relationmaps = thenrelations['EQUAL']
-            thendict[map_i.get_id()] = relationmaps
-        # Get topologies for the alternative conclusion term.
-        elsetopolist = self.get_temporal_topo_list(ifmaplist, elsemaplist)
-        for map_i in elsetopolist:
-            elserelations = map_i.get_temporal_relations()
-            relationmaps = elserelations['EQUAL']
-            elsedict[map_i.get_id()] = relationmaps
-        # Loop through conditional map list.
-        for map_i in ifmaplist:
-            if map_i.get_id() in thendict.keys():
-                thenlist = thendict[map_i.get_id()]
-            else:
-                thenlist = []
-            if map_i.get_id() in elsedict.keys():
-                elselist = elsedict[map_i.get_id()]
-            else:
-                elselist = []
-            # Set iteration amount to maximal or minimum number of related
-            # conclusion maps, depending on null map creation flag.
-            if self.null:
-                iternum = max(len(thenlist), len(elselist))
-            else:
-                iternum = min(len(thenlist), len(elselist))
-            # Calculate difference in conclusion lengths.
-            iterthen = iternum - len(thenlist)
-            iterelse = iternum - len(elselist)
-            # Extend null maps to the list to get conclusions with same length.
-            if iterthen != 0:
-                for i in range(iterthen):
-                    thenlist.extend(['null()'])
-            if iterelse != 0:
-                for i in range(iterelse):
-                    elselist.extend(['null()'])
+        # Create conditional command map list.
+        resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,  
+                                                                            elselist = elsemaplist, 
+                                                                            condition_topolist = ["EQUAL"], 
+                                                                            conclusion_topolist = ["EQUAL"], 
+                                                                            temporal = 'r', null = False)
 
-            # Combine the conclusions in a paired list.
-            conclusionlist = zip(thenlist, elselist)
-            for i in range(iternum):
-                conclusionmaps = conclusionlist[i]
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapifinput = map_i.get_id()
-                # Get conclusion maps.
-                map_then = conclusionmaps[0]
-                map_else = conclusionmaps[1]
-
-                # Check if conclusions are map objects.
-                if map_then != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_then, 'and', \
-                                                            temp_op = '=')
-                    maptheninput = map_then.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    maptheninput = 'null()'
-                # Check if conclusions are map objects.
-                if map_else != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_else, 'and', \
-                                                            temp_op = '=')
-                    mapelseinput = map_else.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    mapelseinput = 'null()'
-
-                #if map_then != 'null()' and map_else != 'null()':
-                # Create r.mapcalc expression string for the operation.
-                if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    map_else.cmd_list)
-                else:
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    mapelseinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
-                # Append map to result map list.
-                if returncode == 1:
-                    resultlist.append(map_new)
-
         t[0] = resultlist
 
         if self.debug:
@@ -1329,6 +1388,10 @@
              | IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN COMMA number RPAREN
              | IF LPAREN s_var_expr COMMA number COMMA NULL LPAREN RPAREN RPAREN
              | IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN COMMA NULL LPAREN RPAREN RPAREN
+             | IF LPAREN ts_var_expr COMMA number COMMA number RPAREN
+             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA number RPAREN
+             | IF LPAREN ts_var_expr COMMA number COMMA NULL LPAREN RPAREN RPAREN
+             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA NULL LPAREN RPAREN RPAREN             
         """
         ifmaplist = self.check_stds(t[3])
         resultlist = []
@@ -1345,18 +1408,14 @@
         elif len(t) == 13:
             numthen = t[5] + t[6] + t[7]
             numelse = t[9] + t[10] + t[11]
-        # Iterate over condition map list.
-        for map_i in ifmaplist:
-            mapinput = map_i.get_id()
-            # Create r.mapcalc expression string for the operation.
-            if "cmd_list" in dir(map_i):
-                cmdstring = "if(%s, %s, %s)" %(map_i.cmd_list, numthen, numelse)
-            else:
-                cmdstring = "if(%s, %s, %s)" %(mapinput, numthen, numelse)
-            # Conditional append of module command.
-            map_i.cmd_list = cmdstring
-            # Append map to result map list.
-            resultlist.append(map_i)
+        numthen = str(numthen)
+        numelse = str(numelse)
+        print(numthen + " " +numelse )
+        # Create conditional command map list.
+        resultlist = self.build_condition_cmd_list(ifmaplist, numthen,  numelse,  
+                                                        condition_topolist = ["EQUAL"], 
+                                                        conclusion_topolist = ["EQUAL"], 
+                                                        temporal = 'r', null = False)
 
         t[0] = resultlist
 
@@ -1377,101 +1436,39 @@
              | IF LPAREN s_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
              | IF LPAREN s_var_expr COMMA expr COMMA number RPAREN
              | IF LPAREN s_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
+             | IF LPAREN ts_var_expr COMMA number COMMA stds RPAREN
+             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
+             | IF LPAREN ts_var_expr COMMA number COMMA expr RPAREN
+             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
+             | IF LPAREN ts_var_expr COMMA stds COMMA number RPAREN
+             | IF LPAREN ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
+             | IF LPAREN ts_var_expr COMMA expr COMMA number RPAREN
+             | IF LPAREN ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN             
         """
         ifmaplist = self.check_stds(t[3])
-        resultlist = []
-        thenmaplist = []
-        numthen = ''
-        elsemaplist = []
-        numelse = ''
         # Select input for r.mapcalc expression based on length of PLY object.
         if len(t) == 9:
-            try:
-                thenmaplist = self.check_stds(t[5])
-            except:
-                numthen = self.check_null(t[5])
-            try:
-                elsemaplist = self.check_stds(t[7])
-            except:
-                numelse = self.check_null(t[7])
+            if isinstance(t[5],  int):
+                theninput = str(t[5])
+                elseinput = self.check_stds(t[7])
+            elif isinstance(t[7],  int):
+                theninput = self.check_stds(t[5])
+                elseinput = str(t[7])
         elif len(t) == 11:
-            try:
-                thenmaplist = self.check_stds(t[5])
-            except:
-                numthen = self.check_null(t[5])
-            try:
-                elsemaplist = self.check_stds(t[9])
-            except:
-                numelse = self.check_null(t[7])
+            if t[5] == 'null':
+                theninput = str(t[5] + t[6] + t[7])
+                elseinput = self.check_stds(t[9])
+            elif t[7] == 'null':
+                theninput = self.check_stds(t[5])
+                elseinput = str(t[7] + t[8] + t[9])
+        print(theninput)
+        print(elseinput)
+        # Create conditional command map list.
+        resultlist = self.build_condition_cmd_list(ifmaplist, theninput,  elseinput,  
+                                                        condition_topolist = ["EQUAL"], 
+                                                        conclusion_topolist = ["EQUAL"], 
+                                                        temporal = 'r', null = False)
 
-        if thenmaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist)
-        elif elsemaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, elsemaplist)
-        if numthen !=  '':
-            numinput = numthen
-        elif numelse !=  '':
-            numinput = numelse
-
-        # Iterate over condition map lists with temporal relations.
-        for map_i in topolist:
-            # Loop over temporal related maps and create overlay modules.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for map_j in (tbrelations['EQUAL']):
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
-                # Create overlayed map extent.
-                returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                        temp_op = '=')
-                # Stop the loop if no temporal or spatial relationship exist.
-                if returncode == 0:
-                    break
-                if count == 0:
-                    # Set map name.
-                    name = map_new.get_id()
-                else:
-                    # Generate an intermediate map
-                    name = self.generate_map_name()
-
-                # Set first input for overlay module.
-                mapbinput = map_j.get_id()
-                # Create r.mapcalc expression string for the operation.
-                if thenmaplist != []:
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, mapbinput, \
-                                                      numinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, map_j.cmd_list, \
-                                                      numinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, map_j.cmd_list, \
-                                                      numinput)
-                    else:
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, mapbinput, numinput)
-                if elsemaplist != []:
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                      mapbinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, \
-                                                      map_j.cmd_list)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                      map_j.cmd_list)
-                    else:
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, mapbinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
-                # Set new map name to temporary map name.
-                #mapainput = name
-                count += 1
-                # Append map to result map list.
-                if returncode == 1:
-                    resultlist.append(map_new)
-
         t[0] = resultlist
 
         if self.debug:
@@ -1491,106 +1488,39 @@
              | IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
              | IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA number RPAREN
              | IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA number COMMA stds RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA number COMMA expr RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA number RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA number RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN             
         """
-        relations, temporal, function= self.eval_toperator(t[3])
+        relations, temporal, function,  aggregation = self.eval_toperator(t[3],  optype = 'relation')
         ifmaplist = self.check_stds(t[5])
-        resultlist = []
-        thenmaplist = []
-        numthen = ''
-        elsemaplist = []
-        numelse = ''
         # Select input for r.mapcalc expression based on length of PLY object.
         if len(t) == 11:
-            try:
-                thenmaplist = self.check_stds(t[7])
-            except:
-                numthen = self.check_null(t[7])
-            try:
-                elsemaplist = self.check_stds(t[9])
-            except:
-                numelse = self.check_null(t[9])
+            if isinstance(t[7],  int):
+                theninput = str(t[7])
+                elseinput = self.check_stds(t[9])
+            elif isinstance(t[9],  int):
+                theninput = self.check_stds(t[7])
+                elseinput = str(t[9])
         elif len(t) == 13:
-            try:
-                thenmaplist = self.check_stds(t[7])
-            except:
-                numthen = self.check_null(t[7])
-            try:
-                elsemaplist = self.check_stds(t[11])
-            except:
-                numelse = self.check_null(t[9])
+            if isinstance(t[7],  int):
+                theninput = str(t[7] + t[8] + t[9])
+                elseinput = self.check_stds(t[11])
+            elif isinstance(t[9],  int):
+                theninput = self.check_stds(t[7])
+                elseinput = str(t[9] + t[10] + t[11])
 
-        if thenmaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist, \
-                                                    topolist = relations)
-        elif elsemaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, elsemaplist, \
-                                                    topolist = relations)
-        if numthen !=  '':
-            numinput = numthen
-        elif numelse !=  '':
-            numinput = numelse
+        # Create conditional command map list.
+        resultlist = self.build_condition_cmd_list(ifmaplist, theninput,  elseinput,  
+                                                        condition_topolist = relations, 
+                                                        conclusion_topolist = ["EQUAL"], 
+                                                        temporal = 'r', null = False)
 
-        # Iterate over condition map lists with temporal relations.
-        for map_i in topolist:
-            # Loop over temporal related maps and create overlay modules.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for topo in relations:
-                if topo in tbrelations.keys():
-                    for map_j in (tbrelations[topo]):
-                        # Generate an intermediate map for the result map list.
-                        map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                        # Set first input for overlay module.
-                        mapainput = map_i.get_id()
-                        # Create overlayed map extent.
-                        returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                                temp_op = '=')
-                        # Stop the loop if no temporal or spatial relationship exist.
-                        if returncode == 0:
-                            break
-                        if count == 0:
-                            # Set map name.
-                            name = map_new.get_id()
-                        else:
-                            # Generate an intermediate map
-                            name = self.generate_map_name()
-
-                        # Set first input for overlay module.
-                        mapbinput = map_j.get_id()
-                        # Create r.mapcalc expression string for the operation.
-                        if thenmaplist != []:
-                            if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, mapbinput, \
-                                                              numinput)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, map_j.cmd_list, \
-                                                              numinput)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, map_j.cmd_list, \
-                                                              numinput)
-                            else:
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, mapbinput, numinput)
-                        if elsemaplist != []:
-                            if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                              mapbinput)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, \
-                                                              map_j.cmd_list)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                              map_j.cmd_list)
-                            else:
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, mapbinput)
-                        # Conditional append of module command.
-                        map_new.cmd_list = cmdstring
-                        # Set new map name to temporary map name.
-                        #mapainput = name
-                        count += 1
-                        # Append map to result map list.
-                        if returncode == 1:
-                            resultlist.append(map_new)
-
         t[0] = resultlist
 
         if self.debug:
@@ -1606,136 +1536,22 @@
              | IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds COMMA expr RPAREN
              | IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA stds RPAREN
              | IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA expr RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA stds RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA expr RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA stds RPAREN
+             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA expr RPAREN
         """
-        relations, temporal, function= self.eval_toperator(t[3])
+        relations, temporal, function, aggregation = self.eval_toperator(t[3],  optype = 'relation')
         ifmaplist = self.check_stds(t[5])
         thenmaplist = self.check_stds(t[7])
         elsemaplist = self.check_stds(t[9])
-        resultlist = []
-        thendict = {}
-        elsedict = {}
-        # Get topologies for the appropriate conclusion term.
-        thentopolist = self.get_temporal_topo_list(ifmaplist, thenmaplist, \
-                                                    topolist = relations)
-        # Fill dictionaries with related maps for both conclusion terms.
-        for map_i in thentopolist:
-            thenrelations = map_i.get_temporal_relations()
-            relationmaps = []
-            for topo in relations:
-                if topo in thenrelations.keys():
-                    relationmaps = relationmaps + thenrelations[topo]
-            thendict[map_i.get_id()] = relationmaps
-        # Get topologies for the alternative conclusion term.
-        elsetopolist = self.get_temporal_topo_list(ifmaplist, elsemaplist, \
-                                                    topolist = relations)
-        for map_i in elsetopolist:
-            elserelations = map_i.get_temporal_relations()
-            relationmaps = []
-            for topo in relations:
-                if topo in elserelations.keys():
-                    relationmaps = relationmaps + elserelations[topo]
-            elsedict[map_i.get_id()] = relationmaps
-        # Loop trough conditional map list.
-        for map_i in ifmaplist:
-            if map_i.get_id() in thendict.keys():
-                thenlist = thendict[map_i.get_id()]
-            else:
-                thenlist = []
-            if map_i.get_id() in elsedict.keys():
-                elselist = elsedict[map_i.get_id()]
-            else:
-                elselist = []
-            # Set iteration amount to maximal or minimum number of related
-            # conclusion maps, depending on null map creation flag.
-            if self.null:
-                iternum = max(len(thenlist), len(elselist))
-            else:
-                iternum = min(len(thenlist), len(elselist))
-            # Calculate difference in conclusion lengths.
-            iterthen = iternum - len(thenlist)
-            iterelse = iternum - len(elselist)
-            # Extend null maps to the list to get conclusions with same length.
-            if iterthen != 0:
-                for i in range(iterthen):
-                    thenlist.extend(['null()'])
-            if iterelse != 0:
-                for i in range(iterelse):
-                    elselist.extend(['null()'])
+        
+        # Create conditional command map list.
+        resultlist = self.build_condition_cmd_list(ifmaplist, thenmaplist,  elsemaplist,  
+                                                        condition_topolist = relations, 
+                                                        conclusion_topolist = ["EQUAL"], 
+                                                        temporal = 'r', null = False)
 
-            # Combine the conclusions in a paired list.
-            conclusionlist = zip(thenlist, elselist)
-            for i in range(iternum):
-                conclusionmaps = conclusionlist[i]
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapifinput = map_i.get_id()
-                # Get conclusion maps.
-                map_then = conclusionmaps[0]
-                map_else = conclusionmaps[1]
-
-                # Check if conclusions are map objects.
-                if map_then != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_then, 'and', \
-                                                            temp_op = '=')
-                    maptheninput = map_then.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    maptheninput = 'null()'
-                # Check if conclusions are map objects.
-                if map_else != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_else, 'and', \
-                                                            temp_op = '=')
-                    mapelseinput = map_else.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    mapelseinput = 'null()'
-
-                #if map_then != 'null()' and map_else != 'null()':
-                # Create r.mapcalc expression string for the operation.
-                if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    map_else.cmd_list)
-                else:
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    mapelseinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
-                # Append map to result map list.
-                if returncode == 1:
-                    resultlist.append(map_new)
-
         t[0] = resultlist
 
         if self.debug:
@@ -1763,917 +1579,56 @@
                     | s_var_expr OR OR ts_var_expr
                     | t_var_expr OR OR ts_var_expr
         """
-        # Check whether inputs are map lists or global temporal variables and
-        # store each in separate lists.
-        ts_var_dict = {"temporal" : [], "spatial" : []}
-        temporal_list = []
-        spatial_list = []
-        operator = t[2] + t[3]
-        temporalop = GlobalTemporalVar()
-        temporalop.relationop = operator
-        temporalop.topology.append("EQUAL")
+        if self.run:
+            # Check input stds.
+            s_var_exprA = self.check_stds(t[1])
+            s_var_exprB = self.check_stds(t[4])
+            relations = ["EQUAL"]
+            temporal = "l"
+            function = t[2] + t[3]
+            aggregate = t[2]
+            # Build conditional values based on topological relationships.            
+            complist = self.get_temporal_topo_list(s_var_exprA, s_var_exprB, 
+                                                                            topolist = relations, compare_cmd = True, 
+                                                                            compop = function, aggregate = aggregate,  
+                                                                            convert = True)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
 
-        if isinstance(t[1], dict) and "spatial" in t[1]:
-            temporal_list = temporal_list + t[1]["temporal"]
-            spatial_list.append(t[1]["spatial"])
-        elif isinstance(t[1], list):
-            if all([isinstance(i, ta.GlobalTemporalVar) for i in t[1]]):
-                temporal_list = temporal_list + t[1]
-            else:
-                tsexprA = self.check_stds(t[1])
-                spatial_list.append(tsexprA)
-        elif isinstance(t[1], ta.GlobalTemporalVar):
-            temporal_list.append(t[1])
-        if temporal_list != [] and \
-            isinstance(t[4], ta.GlobalTemporalVar):
-            temporal_list.append(temporalop)
-        if temporal_list != [] and \
-            isinstance(t[4], list) and \
-            all([isinstance(i, ta.GlobalTemporalVar) for i in t[4]]):
-            temporal_list.append(temporalop)
-        if isinstance(t[4], dict) and "spatial" in t[4]:
-            temporal_list = temporal_list + t[4]["temporal"]
-            spatial_list.append(t[4]["spatial"])
-        elif isinstance(t[4], list):
-            if all([isinstance(i, ta.GlobalTemporalVar) for i in t[4]]):
-                temporal_list = temporal_list + t[4]
-            else:
-                tsexprB = self.check_stds(t[4])
-                spatial_list.append(tsexprB)
-        elif isinstance(t[4], ta.GlobalTemporalVar):
-            temporal_list.append(t[4])
-
-        ts_var_dict["temporal"] = temporal_list
-        # Condition for two map lists in spatio temporal expression.
-        if len(spatial_list) == 2:
-            # Build topology for both map lists in spatio temporal expression.
-            topolist = self.get_temporal_topo_list(spatial_list[0], spatial_list[1])
-            resultlist = []
-            for map_i in topolist:
-                # Loop over temporal related maps and create overlay modules.
-                tbrelations = map_i.get_temporal_relations()
-                count = 0
-                for map_j in (tbrelations['EQUAL']):
-                    # Generate an intermediate map for the result map list.
-                    map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                    # Set first input for overlay module.
-                    mapainput = map_i.get_id()
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                            temp_op = '=')
-                    # Stop the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        break
-                    if count == 0:
-                        # Set map name.
-                        name = map_new.get_id()
-                    else:
-                        # Generate an intermediate map
-                        name = self.generate_map_name()
-
-                    # Set first input for overlay module.
-                    mapbinput = map_j.get_id()
-                    # Create r.mapcalc expression string for the operation.
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "%s %s %s" %(map_new.cmd_list, operator, mapbinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "%s %s %s" %(mapainput, operator, map_j.cmd_list)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "%s %s %s" %(map_new.cmd_list, operator, map_j.cmd_list)
-                    else:
-                        cmdstring = "%s %s %s" %(mapainput, operator, mapbinput)
-                    # Conditional append of module command.
-                    map_new.cmd_list = cmdstring
-                    # Set new map name to temporary map name.
-                    #mapainput = name
-                    count += 1
-                    # Append map to result map list.
-                    if returncode == 1:
-                      resultlist.append(map_new)
-                    # Return dictionary with spatial map list of temporal
-                    # intersected maps and temporal expression in list form.
-                    ts_var_dict["spatial"] = resultlist
-        # Condition for only one map list in spatio temporal expression.
-        elif len(spatial_list) == 1:
-            ts_var_dict["spatial"] = spatial_list[0]
-
-        t[0] = ts_var_dict
-
-    def p_ts_expr_condition_if(self, t):
-        # Examples:
-        #   if(ts_var_expr, A)
-        #   if(start_year == 2013 || B != 5, A)
-        """
-        expr : IF LPAREN ts_var_expr COMMA stds RPAREN
-             | IF LPAREN ts_var_expr COMMA expr RPAREN
-        """
-        ts_var_dict = t[3]
-        spatialcond = ts_var_dict["spatial"]
-        # Extract spatial map list from condition.
-        ifmaplist = self.check_stds(spatialcond)
-        thenmaplist = self.check_stds(t[5])
-        topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist)
-        resultlist = []
-        resultspatial = []
-        for map_i in topolist:
-            #print(map_i.get_id())
-            # Loop over temporal related maps and create overlay modules.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for map_j in (tbrelations['EQUAL']):
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
-                # Create overlayed map extent.
-                returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                        temp_op = '=')
-                # Stop the loop if no temporal or spatial relationship exist.
-                if returncode == 0:
-                    break
-                if count == 0:
-                    # Set map name.
-                    name = map_new.get_id()
-                else:
-                    # Generate an intermediate map
-                    name = self.generate_map_name()
-
-                # Set first input for overlay module.
-                mapbinput = map_j.get_id()
-                # Create r.mapcalc expression string for the operation.
-                if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                    cmdstring = "if(%s,%s)" %(map_new.cmd_list, mapbinput)
-                elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                    cmdstring = "if(%s,%s)" %(mapainput, map_j.cmd_list)
-                elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                    cmdstring = "if(%s,%s)" %(map_new.cmd_list, map_j.cmd_list)
-                else:
-                    cmdstring = "if(%s,%s)" %(mapainput, mapbinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
-                # Set new map name to temporary map name.
-                #mapainput = name
-                count += 1
-                # Append map to result map list.
-                if returncode == 1:
-                    resultspatial.append(map_new)
-        # Evaluate temporal statements in spatio temporal condition.
-
-        #if len(ts_var_dict["temporal"]) == 1:
-            #temporalcond = ts_var_dict["temporal"][0]
-        #else:
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial)
-        thenresult = self.eval_condition_list(thencond)
-        # Clear the map list.
-        resultlist = self.check_stds(thenresult, clear = True)
-
         t[0] = resultlist
-
-        if self.debug:
-            for map in resultlist:
-                print map.cmd_list
-
-
-    def p_ts_expr_condition_if_relation(self, t):
-        # Examples:
-        #   if({equal||during}, ts_var_expr, A)
-        #   if({starts||during}, B > 2 || end_month() == 4, A)
+    
+    def p_hash_operation(self, t):
+        # Calculate the number of maps within an interval of another map from a 
+        # second space time dataset.
+        # A # B
+        # A {equal,r#} B
         """
-        expr : IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr RPAREN
+        expr : t_hash_var
         """
-        relations, temporal, function= self.eval_toperator(t[3])
-        ts_var_dict = t[5]
-        spatialcond = ts_var_dict["spatial"]
-        # Extract spatial map list from condition.
-        ifmaplist = self.check_stds(spatialcond)
-        thenmaplist = self.check_stds(t[7])
-        topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist,
-                                                topolist = relations)
-        resultspatial = []
-        for map_i in topolist:
-            #print(map_i.get_id())
-            # Loop over temporal related maps and create overlay modules.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for topo in relations:
-                if topo in tbrelations.keys():
-                    for map_j in (tbrelations[topo]):
-                        # Generate an intermediate map for the result map list.
-                        map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                        # Set first input for overlay module.
-                        mapainput = map_i.get_id()
-                        # Create overlayed map extent.
-                        returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                                temp_op = '=')
-                        # Stop the loop if no temporal or spatial relationship exist.
-                        if returncode == 0:
-                            break
-                        if count == 0:
-                            # Set map name.
-                            name = map_new.get_id()
-                        else:
-                            # Generate an intermediate map
-                            name = self.generate_map_name()
+        # Check input stds.
+        maplist = self.check_stds(t[1])
 
-                        # Set first input for overlay module.
-                        mapbinput = map_j.get_id()
-                        # Create r.mapcalc expression string for the operation.
-                        if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                            cmdstring = "if(%s,%s)" %(map_new.cmd_list, mapbinput)
-                        elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                            cmdstring = "if(%s,%s)" %(mapainput, map_j.cmd_list)
-                        elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                            cmdstring = "if(%s,%s)" %(map_new.cmd_list, map_j.cmd_list)
-                        else:
-                            cmdstring = "if(%s,%s)" %(mapainput, mapbinput)
-                        # Conditional append of module command.
-                        map_new.cmd_list = cmdstring
-                        # Set new map name to temporary map name.
-                        #mapainput = name
-                        count += 1
-                        # Append map to result map list.
-                        if returncode == 1:
-                            resultspatial.append(map_new)
-        # Evaluate temporal statements in spatio temporal condition.
-
-        #if len(ts_var_dict["temporal"]) == 1:
-            #temporalcond = ts_var_dict["temporal"][0]
-        #else:
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial, relations)
-        thenresult = self.eval_condition_list(thencond)
-        # Clear the map list.
-        resultlist = self.check_stds(thenresult, clear = True)
-
-        t[0] = resultlist
-
-        if self.debug:
-            for map in resultlist:
-                print map.cmd_list
-
-
-    def p_ts_numeric_condition_if(self, t):
-        # Examples:
-        #   if(ts_var_expr, 1)
-        #   if(A == 5 && start_day() > 5, 10)
-        """
-        expr : IF LPAREN ts_var_expr COMMA number RPAREN
-             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN RPAREN
-        """
-        ts_var_dict = t[3]
-        spatialcond = ts_var_dict["spatial"]
-        ifmaplist = self.check_stds(spatialcond)
-        resultspatial = []
-        # Select input for r.mapcalc expression based on length of PLY object.
-        if len(t) == 7:
-            numinput = t[5]
-        elif len(t) == 9:
-            numinput = t[5] + t[6] + t[7]
-        # Iterate over condition map list.
-        for map_i in ifmaplist:
-            mapinput = map_i.get_id()
-            # Create r.mapcalc expression string for the operation.
-            if "cmd_list" in dir(map_i):
-                cmdstring = "if(%s,%s)" %(map_i.cmd_list, numinput)
-            else:
-                cmdstring = "if(%s,%s)" %(mapinput, numinput)
-            # Conditional append of module command.
-            map_i.cmd_list = cmdstring
-            # Append map to result map list.
-            resultspatial.append(map_i)
-
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial)
-        thenresult = self.eval_condition_list(thencond)
-        # Clear the map list.
-        resultlist = self.check_stds(thenresult, clear = True)
-
-        t[0] = resultlist
-
-        if self.debug:
-            for map in resultlist:
-                print map.cmd_list
-
-
-    def p_ts_expr_condition_elif(self, t):
-        # Examples:
-        #   if(s_var_expr, A, B)
-        #   if(start_day() < 20 && B > 2, A, B)
-        """
-        expr : IF LPAREN ts_var_expr COMMA stds COMMA stds RPAREN
-             | IF LPAREN ts_var_expr COMMA stds COMMA expr RPAREN
-             | IF LPAREN ts_var_expr COMMA expr COMMA stds RPAREN
-             | IF LPAREN ts_var_expr COMMA expr COMMA expr RPAREN
-        """
-        ts_var_dict = t[3]
-        spatialcond = ts_var_dict["spatial"]
-        ifmaplist = self.check_stds(spatialcond)
-        thenmaplist = self.check_stds(t[5])
-        elsemaplist = self.check_stds(t[7])
-        resultspatial = []
-        thendict = {}
-        elsedict = {}
-        # Get topologies for the appropriate conclusion term.
-        thentopolist = self.get_temporal_topo_list(ifmaplist, thenmaplist)
-        # Fill dictionaries with related maps for both conclusion terms.
-        for map_i in thentopolist:
-            thenrelations = map_i.get_temporal_relations()
-            relationmaps = thenrelations['EQUAL']
-            thendict[map_i.get_id()] = relationmaps
-        # Get topologies for the alternative conclusion term.
-        elsetopolist = self.get_temporal_topo_list(ifmaplist, elsemaplist)
-        for map_i in elsetopolist:
-            elserelations = map_i.get_temporal_relations()
-            relationmaps = elserelations['EQUAL']
-            elsedict[map_i.get_id()] = relationmaps
-        # Loop through conditional map list.
-        for map_i in ifmaplist:
-            if map_i.get_id() in thendict.keys():
-                thenlist = thendict[map_i.get_id()]
-            else:
-                thenlist = []
-            if map_i.get_id() in elsedict.keys():
-                elselist = elsedict[map_i.get_id()]
-            else:
-                elselist = []
-            # Set iteration amount to maximal or minimum number of related
-            # conclusion maps, depending on null map creation flag.
-            if self.null:
-                iternum = max(len(thenlist), len(elselist))
-            else:
-                iternum = min(len(thenlist), len(elselist))
-            # Calculate difference in conclusion lengths.
-            iterthen = iternum - len(thenlist)
-            iterelse = iternum - len(elselist)
-            # Extend null maps to the list to get conclusions with same length.
-            if iterthen != 0:
-                for i in range(iterthen):
-                    thenlist.extend(['null()'])
-            if iterelse != 0:
-                for i in range(iterelse):
-                    elselist.extend(['null()'])
-            # Combine the conclusions in a paired list.
-            conclusionlist = zip(thenlist, elselist)
-            for i in range(iternum):
-                conclusionmaps = conclusionlist[i]
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapifinput = map_i.get_id()
-                # Get conclusion maps.
-                map_then = conclusionmaps[0]
-                map_else = conclusionmaps[1]
-
-                # Check if conclusions are map objects.
-                if map_then != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_then, 'and', \
-                                                            temp_op = '=')
-                    maptheninput = map_then.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    maptheninput = 'null()'
-                # Check if conclusions are map objects.
-                if map_else != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_else, 'and', \
-                                                            temp_op = '=')
-                    mapelseinput = map_else.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    mapelseinput = 'null()'
-
-                #if map_then != 'null()' and map_else != 'null()':
+        if self.run:
+            resultlist = []
+            for map_i in maplist:
+                for obj in map_i.map_value:
+                    if isinstance(obj, GlobalTemporalVar):
+                        n_maps = obj.td
+                mapinput = map_i.get_id()
                 # Create r.mapcalc expression string for the operation.
-                if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    map_else.cmd_list)
-                else:
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    mapelseinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
+                cmdstring = "(%s)" %(n_maps)
+                 # Append module command.
+                map_i.cmd_list = cmdstring
                 # Append map to result map list.
-                if returncode == 1:
-                    resultspatial.append(map_new)
+                resultlist.append(map_i)
 
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial)
-        thenresult = self.eval_condition_list(thencond)
-        #elseresult = self.eval_condition_list(thencond, inverse = True)
-        # Combine and sort else and then statement to result map list.
-        #combilist = thenresult + elseresult
-        #resultlist = sorted(combilist, key = AbstractDatasetComparisonKeyStartTime)
-        # Clear the map list.
-        #resultlist = self.check_stds(resultlist, clear = True)
-        resultlist = self.check_stds(thenresult, clear = True)
+            t[0] = resultlist
 
-        t[0] = resultlist
-
         if self.debug:
             for map in resultlist:
                 print map.cmd_list
 
-
-    def p_ts_expr_condition_elif_relation(self, t):
-        # Examples:
-        #   if({equal||during}, s_var_expr, A, B)
-        #   if({contains}, start_day() == 3 || C != 2, A, B)
-        """
-        expr : IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA stds RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA expr RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA stds RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA expr RPAREN
-        """
-        relations, temporal, function= self.eval_toperator(t[3])
-        ts_var_dict = t[5]
-        spatialcond = ts_var_dict["spatial"]
-        # Extract spatial map list from condition.
-        ifmaplist = self.check_stds(spatialcond)
-        thenmaplist = self.check_stds(t[7])
-        elsemaplist = self.check_stds(t[9])
-        resultspatial = []
-        thendict = {}
-        elsedict = {}
-        # Get topologies for the appropriate conclusion term.
-        thentopolist = self.get_temporal_topo_list(ifmaplist, thenmaplist, \
-                                                    topolist = relations)
-        # Fill dictionaries with related maps for both conclusion terms.
-        for map_i in thentopolist:
-            thenrelations = map_i.get_temporal_relations()
-            relationmaps = []
-            for topo in relations:
-                if topo in thenrelations.keys():
-                    relationmaps = relationmaps + thenrelations[topo]
-            thendict[map_i.get_id()] = relationmaps
-        # Get topologies for the alternative conclusion term.
-        elsetopolist = self.get_temporal_topo_list(ifmaplist, elsemaplist, \
-                                                    topolist = relations)
-        for map_i in elsetopolist:
-            elserelations = map_i.get_temporal_relations()
-            relationmaps = []
-            for topo in relations:
-                if topo in elserelations.keys():
-                    relationmaps = relationmaps + elserelations[topo]
-            elsedict[map_i.get_id()] = relationmaps
-        # Loop trough conditional map list.
-        for map_i in ifmaplist:
-            if map_i.get_id() in thendict.keys():
-                thenlist = thendict[map_i.get_id()]
-            else:
-                thenlist = []
-            if map_i.get_id() in elsedict.keys():
-                elselist = elsedict[map_i.get_id()]
-            else:
-                elselist = []
-            # Set iteration amount to maximal or minimum number of related
-            # conclusion maps, depending on null map creation flag.
-            if self.null:
-                iternum = max(len(thenlist), len(elselist))
-            else:
-                iternum = min(len(thenlist), len(elselist))
-            # Calculate difference in conclusion lengths.
-            iterthen = iternum - len(thenlist)
-            iterelse = iternum - len(elselist)
-            # Extend null maps to the list to get conclusions with same length.
-            if iterthen != 0:
-                for i in range(iterthen):
-                    thenlist.extend(['null()'])
-            if iterelse != 0:
-                for i in range(iterelse):
-                    elselist.extend(['null()'])
-
-            # Combine the conclusions in a paired list.
-            conclusionlist = zip(thenlist, elselist)
-            for i in range(iternum):
-                conclusionmaps = conclusionlist[i]
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapifinput = map_i.get_id()
-                # Get conclusion maps.
-                map_then = conclusionmaps[0]
-                map_else = conclusionmaps[1]
-
-                # Check if conclusions are map objects.
-                if map_then != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_then, 'and', \
-                                                            temp_op = '=')
-                    maptheninput = map_then.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    maptheninput = 'null()'
-                # Check if conclusions are map objects.
-                if map_else != 'null()':
-                    # Create overlayed map extent.
-                    returncode = self.overlay_map_extent(map_new, map_else, 'and', \
-                                                            temp_op = '=')
-                    mapelseinput = map_else.get_id()
-                    # Continue the loop if no temporal or spatial relationship exist.
-                    if returncode == 0:
-                        continue
-                else:
-                    mapelseinput = 'null()'
-
-                #if map_then != 'null()' and map_else != 'null()':
-                # Create r.mapcalc expression string for the operation.
-                if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(map_new.cmd_list, map_then.cmd_list,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" not in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    mapelseinput)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" not in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    map_else.cmd_list)
-                elif "cmd_list" not in dir(map_new) and "cmd_list" in dir(map_then) \
-                    and "cmd_list" in dir(map_else):
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, map_then.cmd_list,
-                    map_else.cmd_list)
-                else:
-                    cmdstring = "if(%s, %s, %s)" %(mapifinput, maptheninput,
-                    mapelseinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
-                # Append map to result map list.
-                if returncode == 1:
-                    resultspatial.append(map_new)
-
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial, relations)
-        thenresult = self.eval_condition_list(thencond)
-        #elseresult = self.eval_condition_list(thencond, inverse = True)
-        # Combine and sort else and then statement to result map list.
-        #combilist = thenresult + elseresult
-        #resultlist = sorted(combilist, key = AbstractDatasetComparisonKeyStartTime)
-        # Clear the map list.
-        resultlist = self.check_stds(thenresult, clear = True)
-
-        t[0] = resultlist
-
-        if self.debug:
-            for map in resultlist:
-                print map.cmd_list
-
-
-    def p_ts_numeric_condition_elif(self, t):
-        # Examples:
-        #   if(ts_var_expr, 1, 2)
-        #   if(A == 1 || end_year == 2013, 10, null())
-        """
-        expr : IF LPAREN ts_var_expr COMMA number COMMA number RPAREN
-             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA number RPAREN
-             | IF LPAREN ts_var_expr COMMA number COMMA NULL LPAREN RPAREN RPAREN
-             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA NULL LPAREN RPAREN RPAREN
-        """
-        ts_var_dict = t[3]
-        spatialcond = ts_var_dict["spatial"]
-        # Extract spatial map list from condition.
-        ifmaplist = self.check_stds(spatialcond)
-        resultspatial = []
-        # Select input for r.mapcalc expression based on length of PLY object.
-        if len(t) == 9:
-            numthen = t[5]
-            numelse = t[7]
-        elif len(t) == 11:
-            numthen = self.check_null(t[5])
-            numelse = self.check_null(t[7])
-        elif len(t) == 13:
-            numthen = self.check_null(t[5])
-            numelse = self.check_null(t[9])
-
-        # Iterate over condition map list.
-        for map_i in ifmaplist:
-            mapinput = map_i.get_id()
-            # Create r.mapcalc expression string for the operation.
-            if "cmd_list" in dir(map_i):
-                cmdstring = "if(%s, %s, %s)" %(map_i.cmd_list, numthen, numelse)
-            else:
-                cmdstring = "if(%s, %s, %s)" %(mapinput, numthen, numelse)
-            # Conditional append of module command.
-            map_i.cmd_list = cmdstring
-            # Append map to result map list.
-            resultspatial.append(map_i)
-
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial)
-        thenresult = self.eval_condition_list(thencond)
-        #elseresult = self.eval_condition_list(thencond, inverse = True)
-        # Combine and sort else and then statement to result map list.
-        #combilist = thenresult + elseresult
-        #resultlist = sorted(combilist, key = AbstractDatasetComparisonKeyStartTime)
-        # Clear the map list.
-        #resultlist = self.check_stds(resultlist, clear = True)
-        resultlist = self.check_stds(thenresult, clear = True)
-
-        t[0] = resultlist
-
-    def p_ts_numeric_expr_condition_elif(self, t):
-        # Examples:
-        #   if(ts_var_expr, 1, A)
-        #   if(A == 5 && start_day() > 5, A, null())
-        """
-        expr : IF LPAREN ts_var_expr COMMA number COMMA stds RPAREN
-             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
-             | IF LPAREN ts_var_expr COMMA number COMMA expr RPAREN
-             | IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
-             | IF LPAREN ts_var_expr COMMA stds COMMA number RPAREN
-             | IF LPAREN ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
-             | IF LPAREN ts_var_expr COMMA expr COMMA number RPAREN
-             | IF LPAREN ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
-        """
-        ts_var_dict = t[3]
-        spatialcond = ts_var_dict["spatial"]
-        ifmaplist = self.check_stds(spatialcond)
-        resultspatial = []
-        thenmaplist = []
-        numthen = ''
-        elsemaplist = []
-        numelse = ''
-        # Select input for r.mapcalc expression based on length of PLY object.
-        if len(t) == 9:
-            try:
-                thenmaplist = self.check_stds(t[5])
-            except:
-                numthen = t[5]
-            try:
-                elsemaplist = self.check_stds(t[7])
-            except:
-                numelse = t[7]
-        elif len(t) == 11:
-            try:
-                thenmaplist = self.check_stds(t[5])
-            except:
-                numthen = t[5] + t[6] + t[7]
-            try:
-                elsemaplist = self.check_stds(t[9])
-            except:
-                numelse = t[7] + t[8] + t[9]
-        if thenmaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist)
-        elif elsemaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, elsemaplist)
-        if numthen !=  '':
-            numinput = numthen
-        elif numelse !=  '':
-            numinput = numelse
-
-        # Iterate over condition map lists with temporal relations.
-        for map_i in topolist:
-            # Loop over temporal related maps and create overlay modules.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for map_j in (tbrelations['EQUAL']):
-                # Generate an intermediate map for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
-                # Create overlayed map extent.
-                returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                        temp_op = '=')
-                # Stop the loop if no temporal or spatial relationship exist.
-                if returncode == 0:
-                    break
-                if count == 0:
-                    # Set map name.
-                    name = map_new.get_id()
-                else:
-                    # Generate an intermediate map
-                    name = self.generate_map_name()
-
-                # Set first input for overlay module.
-                mapbinput = map_j.get_id()
-                # Create r.mapcalc expression string for the operation.
-                if thenmaplist != []:
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, mapbinput, \
-                                                      numinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, map_j.cmd_list, \
-                                                      numinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, map_j.cmd_list, \
-                                                      numinput)
-                    else:
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, mapbinput, numinput)
-                if elsemaplist != []:
-                    if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                      mapbinput)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, \
-                                                      map_j.cmd_list)
-                    elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                        cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                      map_j.cmd_list)
-                    else:
-                        cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, mapbinput)
-                # Conditional append of module command.
-                map_new.cmd_list = cmdstring
-                # Set new map name to temporary map name.
-                #mapainput = name
-                count += 1
-                # Append map to result map list.
-                if returncode == 1:
-                    resultspatial.append(map_new)
-
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial)
-        thenresult = self.eval_condition_list(thencond)
-        # Clear the map list.
-        resultlist = self.check_stds(thenresult, clear = True)
-
-        t[0] = resultlist
-
-        if self.debug:
-            for map in resultlist:
-                print map.cmd_list
-
-
-    def p_ts_numeric_expr_condition_elif_relation(self, t):
-        # Examples:
-        #   if({during},ts_var_expr, 1, A)
-        #   if({during}, A == 5 && start_day() > 5, A, null())
-        """
-        expr : IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA number COMMA stds RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA number COMMA expr RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA number RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA number RPAREN
-             | IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
-        """
-        relations, temporal, function= self.eval_toperator(t[3])
-        ts_var_dict = t[5]
-        spatialcond = ts_var_dict["spatial"]
-        ifmaplist = self.check_stds(spatialcond)
-        resultspatial = []
-        thenmaplist = []
-        numthen = ''
-        elsemaplist = []
-        numelse = ''
-        # Select input for r.mapcalc expression based on length of PLY object.
-        if len(t) == 11:
-            try:
-                thenmaplist = self.check_stds(t[7])
-            except:
-                numthen = t[7]
-            try:
-                elsemaplist = self.check_stds(t[9])
-            except:
-                numelse = t[9]
-        elif len(t) == 13:
-            try:
-                thenmaplist = self.check_stds(t[7])
-            except:
-                numthen = t[9] + t[10] + t[11]
-            try:
-                elsemaplist = self.check_stds(t[11])
-            except:
-                numelse = t[9] + t[10] + t[11]
-        if thenmaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, thenmaplist, \
-                                                    topolist = relations)
-        elif elsemaplist != []:
-            topolist = self.get_temporal_topo_list(ifmaplist, elsemaplist, \
-                                                    topolist = relations)
-        if numthen !=  '':
-            numinput = numthen
-        elif numelse !=  '':
-            numinput = numelse
-
-        # Iterate over condition map lists with temporal relations.
-        for map_i in topolist:
-            # Loop over temporal related maps and create overlay modules.
-            tbrelations = map_i.get_temporal_relations()
-            count = 0
-            for topo in relations:
-                if topo in tbrelations.keys():
-                    for map_j in (tbrelations[topo]):
-                        # Generate an intermediate map for the result map list.
-                        map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', copy = True)
-                        # Set first input for overlay module.
-                        mapainput = map_i.get_id()
-                        # Create overlayed map extent.
-                        returncode = self.overlay_map_extent(map_new, map_j, 'and', \
-                                                                temp_op = '=')
-                        # Stop the loop if no temporal or spatial relationship exist.
-                        if returncode == 0:
-                            break
-                        if count == 0:
-                            # Set map name.
-                            name = map_new.get_id()
-                        else:
-                            # Generate an intermediate map
-                            name = self.generate_map_name()
-
-                        # Set first input for overlay module.
-                        mapbinput = map_j.get_id()
-                        # Create r.mapcalc expression string for the operation.
-                        if thenmaplist != []:
-                            if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, mapbinput, \
-                                                              numinput)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, map_j.cmd_list, \
-                                                              numinput)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, map_j.cmd_list, \
-                                                              numinput)
-                            else:
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, mapbinput, numinput)
-                        if elsemaplist != []:
-                            if "cmd_list" in dir(map_new) and "cmd_list" not in dir(map_j):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                              mapbinput)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" not in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, \
-                                                              map_j.cmd_list)
-                            elif "cmd_list" in dir(map_j) and "cmd_list" in dir(map_new):
-                                cmdstring = "if(%s,%s,%s)" %(map_new.cmd_list, numinput, \
-                                                              map_j.cmd_list)
-                            else:
-                                cmdstring = "if(%s,%s,%s)" %(mapainput, numinput, mapbinput)
-                        # Conditional append of module command.
-                        map_new.cmd_list = cmdstring
-                        # Set new map name to temporary map name.
-                        #mapainput = name
-                        count += 1
-                        # Append map to result map list.
-                        if returncode == 1:
-                            resultspatial.append(map_new)
-
-        temporalcond = ts_var_dict["temporal"]
-        resultspatial = self.check_stds(resultspatial)
-        thencond = self.build_condition_list(temporalcond, resultspatial)
-        thenresult = self.eval_condition_list(thencond)
-        # Clear the map list.
-        resultlist = self.check_stds(thenresult, clear = True)
-
-        t[0] = resultlist
-
-        if self.debug:
-            for map in resultlist:
-                print map.cmd_list
-
-
 ###############################################################################
 
 if __name__ == "__main__":

Deleted: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_operator.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_operator.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_raster_operator.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,390 +0,0 @@
-"""!@package grass.temporal
-
-Temporal operator evaluation with PLY
-
-(C) 2013 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Thomas Leppelt and Soeren Gebbert
-
- at code
-    >>> p = TemporalRasterOperatorParser()
-    >>> expression =  "{equal| during | follows,+!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'follows'], '+', '!:')
-    >>> expression =  "{equal| during,!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during'], '=', '!:')
-    >>> expression =  "{!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '=', '!:')
-    >>> expression =  "{|#}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '|', '#')
-    >>> expression =  "{equal|during,=!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during'], '=', '!:')
-    >>> expression =  "{equal|during|starts}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'starts'], None, None)
-    >>> expression =  "{equal,++}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '+', '+')
-    >>> expression =  "{equal | during,|%}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during'], '|', '%')
-    >>> expression =  "{||}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '=', '||')
-    >>> expression =  "{equal,||}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '=', '||')
-    >>> expression =  "{equal | during | contains,&&}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'contains'], '=', '&&')
-    >>> expression =  "{equal | during | contains,/}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'contains'], '=', '/')
-    >>> expression =  "{equal | during | contains,|*}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'contains'], '|', '*')
-
- at endcode
-"""
-
-try:
-    import ply.lex as lex
-    import ply.yacc as yacc
-except:
-    pass
-
-class TemporalRasterOperatorLexer(object):
-    """!Lexical analyzer for the GRASS GIS temporal operator"""
-
-    # Functions that defines topological relations.
-    relations = {
-        'equal'      : "EQUAL",
-        'follows'    : "FOLLOWS",
-        'precedes'   : "PRECEDES",
-        'overlaps'   : "OVERLAPS",
-        'overlapped' : "OVERLAPPED",
-        'during'     : "DURING",
-        'starts'     : "STARTS",
-        'finishes'   : "FINISHES",
-        'contains'   : "CONTAINS",
-        'started'    : "STARTED",
-        'finished'   : "FINISHED",
-        'over'       : "OVER"
-        }
-
-    # This is the list of token names.
-    tokens = (
-        'COMMA',
-        'LEFTREF',
-        'HASH',
-        'OR',
-        'AND',
-        'MOD',
-        'DIV',
-        'MULT',
-        'ADD',
-        'SUB',
-        'T_SELECT',
-        'T_NOT_SELECT',
-        'CLPAREN',
-        'CRPAREN',
-    )
-
-    # Build the token list
-    tokens = tokens + tuple(relations.values())
-
-    # Regular expression rules for simple tokens
-    t_T_SELECT           = r':'
-    t_T_NOT_SELECT       = r'!:'
-    t_COMMA              = r','
-    t_LEFTREF             = r'='
-    t_HASH               = r'\#'
-    t_OR                 = r'[\|]'
-    t_AND                = r'[&]'
-    t_MOD                = r'[\%]'
-    t_DIV                = r'[\/]'
-    t_MULT               = r'[\*]'
-    t_ADD                = r'[\+]'
-    t_SUB                = r'[-]'
-    t_CLPAREN             = r'\{'
-    t_CRPAREN             = r'\}'
-
-    # These are the things that should be ignored.
-    t_ignore = ' \t'
-
-    # Track line numbers.
-    def t_newline(self, t):
-        r'\n+'
-        t.lineno += len(t.value)
-
-    def t_NAME(self, t):
-        r'[a-zA-Z_][a-zA-Z_0-9]*'
-        self.temporal_symbol(t)
-        return t
-
-    # Parse symbols
-    def temporal_symbol(self, t):
-        # Check for reserved words
-        if t.value in TemporalRasterOperatorLexer.relations.keys():
-            t.type = TemporalRasterOperatorLexer.relations.get(t.value)
-        #else:
-        #    t.type = 'NAME'
-        return(t)
-
-    # Handle errors.
-    def t_error(self, t):
-        raise SyntaxError("syntax error on line %d near '%s'" %
-            (t.lineno, t.value))
-
-    # Build the lexer
-    def build(self,**kwargs):
-        self.lexer = lex.lex(module=self, **kwargs)
-
-    # Just for testing
-    def test(self,data):
-        self.name_list = {}
-        print(data)
-        self.lexer.input(data)
-        while True:
-             tok = self.lexer.token()
-             if not tok: break
-             print tok
-
-###############################################################################
-
-class TemporalRasterOperatorParser(object):
-    """The temporal algebra class"""
-
-    def __init__(self):
-        self.lexer = TemporalRasterOperatorLexer()
-        self.lexer.build()
-        self.parser = yacc.yacc(module=self)
-
-    def parse(self, expression, comparison = False):
-        self.comparison = comparison
-        self.parser.parse(expression)
-
-    # Error rule for syntax errors.
-    def p_error(self, t):
-        raise SyntaxError("invalid syntax")
-
-    # Get the tokens from the lexer class
-    tokens = TemporalRasterOperatorLexer.tokens
-
-    def p_relation_only(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN relation CRPAREN
-                 | CLPAREN relationlist CRPAREN
-        """
-        # Set three operator components.
-        if isinstance(t[2], list):
-            self.relations = t[2]
-        else:
-            self.relations = [t[2]]
-        self.temporal  = None
-        self.function  = None
-
-        t[0] = t[2]
-
-
-    def p_operator(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN select CRPAREN
-                 | CLPAREN HASH CRPAREN
-                 | CLPAREN arithmetic CRPAREN
-        """
-        # Set three operator components.
-        self.relations = ['equal']
-        self.temporal  = "="
-        self.function  = t[2]
-
-        t[0] = t[2]
-
-    def p_comparison(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN temporal AND CRPAREN
-                 | CLPAREN temporal OR CRPAREN
-        """
-        # Set three operator components.
-        self.relations = ['equal']
-        self.temporal  = "="
-        if t[2] == t[3]:
-            self.function  = t[2] + t[3]
-        else:
-            raise SyntaxError("syntax error on line %d near '%s'" %
-                                (t.lineno, t.value))
-
-        t[0] = t[2]
-
-    def p_operator_temporal(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN temporal select CRPAREN
-                 | CLPAREN temporal HASH CRPAREN
-                 | CLPAREN temporal arithmetic CRPAREN
-        """
-        # Set three operator components.
-        self.relations = ['equal']
-        self.temporal = t[2]
-        self.function = t[3]
-
-        t[0] = t[3]
-
-    def p_operator_relation(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN relation COMMA select CRPAREN
-                 | CLPAREN relationlist COMMA select CRPAREN
-                 | CLPAREN relation COMMA HASH CRPAREN
-                 | CLPAREN relationlist COMMA HASH CRPAREN
-                 | CLPAREN relation COMMA arithmetic CRPAREN
-                 | CLPAREN relationlist COMMA arithmetic CRPAREN
-        """
-        # Set three operator components.
-        if isinstance(t[2], list):
-            self.relations = t[2]
-        else:
-            self.relations = [t[2]]
-        self.temporal  = "="
-        self.function  = t[4]
-
-        t[0] = t[4]
-
-    def p_comparison_relation(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN relation COMMA temporal AND CRPAREN
-                 | CLPAREN relation COMMA temporal OR CRPAREN
-                 | CLPAREN relationlist COMMA temporal AND CRPAREN
-                 | CLPAREN relationlist COMMA temporal OR CRPAREN
-        """
-        # Set three operator components.
-        if isinstance(t[2], list):
-            self.relations = t[2]
-        else:
-            self.relations = [t[2]]
-        self.temporal  = "="
-        if t[4] == t[5]:
-            self.function  = t[4] + t[5]
-        else:
-            raise SyntaxError("syntax error on line %d near '%s'" %
-                                (t.lineno, t.value))
-
-        t[0] = t[4]
-
-    def p_operator_relation_temporal(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN relation COMMA temporal select CRPAREN
-                 | CLPAREN relationlist COMMA temporal select CRPAREN
-                 | CLPAREN relation COMMA temporal HASH CRPAREN
-                 | CLPAREN relationlist COMMA temporal HASH CRPAREN
-                 | CLPAREN relation COMMA temporal arithmetic CRPAREN
-                 | CLPAREN relationlist COMMA temporal arithmetic CRPAREN
-        """
-        # Set three operator components.
-        if isinstance(t[2], list):
-            self.relations = t[2]
-        else:
-            self.relations = [t[2]]
-        self.temporal = t[4]
-        self.function = t[5]
-        t[0] = t[5]
-
-    def p_relation(self, t):
-        # The list of relations.
-        """
-        relation : EQUAL
-                 | FOLLOWS
-                 | PRECEDES
-                 | OVERLAPS
-                 | OVERLAPPED
-                 | DURING
-                 | STARTS
-                 | FINISHES
-                 | CONTAINS
-                 | STARTED
-                 | FINISHED
-        """
-        t[0] = t[1]
-
-    def p_over(self, t):
-        # The list of relations.
-        """
-        relation : OVER
-        """
-        over_list = ["overlaps", "overlapped"]
-        t[0] = over_list
-
-    def p_relationlist(self, t):
-        # The list of relations.
-        """
-        relationlist : relation OR relation
-                     | relation OR relationlist
-        """
-        rel_list = []
-        rel_list.append(t[1])
-        if isinstance(t[3], list):
-            rel_list = rel_list + t[3]
-        else:
-            rel_list.append(t[3])
-        t[0] =  rel_list
-
-    def p_temporal_operator(self, t):
-        # The list of relations.
-        """
-        temporal : LEFTREF
-                 | OR
-                 | AND
-                 | ADD
-        """
-        t[0] = t[1]
-
-    def p_select_operator(self, t):
-        # The list of relations.
-        """
-        select : T_SELECT
-               | T_NOT_SELECT
-        """
-        t[0] = t[1]
-
-    def p_arithmetic_operator(self, t):
-        # The list of relations.
-        """
-        arithmetic : MOD
-                   | DIV
-                   | MULT
-                   | ADD
-                   | SUB
-        """
-        t[0] = t[1]
-
-###############################################################################
-
-if __name__ == "__main__":
-    import doctest
-    doctest.testmod()
-

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_topology_dataset_connector.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_topology_dataset_connector.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_topology_dataset_connector.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,34 +1,36 @@
 # -*- coding: utf-8 -*-
-"""!@package grass.temporal
+"""
+Temporal topology dataset connector class
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS related functions to be used in temporal GIS Python library package.
-
 Usage:
 
->>> import grass.temporal as tgis
->>> tmr = tgis.TemporalTopologyDatasetConnector()
+.. code-block:: python:
 
+    >>> import grass.temporal as tgis
+    >>> tmr = tgis.TemporalTopologyDatasetConnector()
+
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 import copy
 
+
 class TemporalTopologyDatasetConnector(object):
-    """!This class implements a temporal topology access structure to connect temporal related datasets
+    """This class implements a temporal topology access structure to connect
+       temporal related datasets
 
-       This object will be set up by temporal topology creation method provided by the 
-       SpatioTemporalTopologyBuilder.
+       This object will be set up by temporal topology creation method provided
+       by the SpatioTemporalTopologyBuilder.
 
-       If correctly initialize the calls next() and prev() 
+       If correctly initialize the calls next() and prev()
        let the user walk temporally forward and backward in time.
 
        The following temporal relations with access methods are supported:
+
        - equal
        - follows
        - precedes
@@ -41,101 +43,96 @@
        - finishes
        - finished
 
+       .. code-block:: python:
 
-       @code:
-       # We have build the temporal topology and we know the first map
-       start = first
-       while start:
+           # We have build the temporal topology and we know the first map
+           start = first
+           while start:
 
-           # Print all maps this map temporally contains
-           dlist = start.get_contains()
-           for map in dlist:
-               map.print_info()
+               # Print all maps this map temporally contains
+               dlist = start.get_contains()
+               for map in dlist:
+                   map.print_info()
 
-           start = start.next()
-         @endcode  
-        
-        Usage:
-        
-        @code
-        
-        >>> import grass.temporal as tgis
-        >>> tgis.init()
-        >>> map = tgis.RasterDataset("a at P")
-        >>> tmr = tgis.TemporalTopologyDatasetConnector()
-        >>> tmr.set_next(map)
-        >>> tmr.set_prev(map)
-        >>> tmr.append_equal(map)
-        >>> tmr.append_follows(map)
-        >>> tmr.append_precedes(map)
-        >>> tmr.append_overlapped(map)
-        >>> tmr.append_overlaps(map)
-        >>> tmr.append_during(map)
-        >>> tmr.append_contains(map)
-        >>> tmr.append_starts(map)
-        >>> tmr.append_started(map)
-        >>> tmr.append_finishes(map)
-        >>> tmr.append_finished(map)
-        >>> tmr.print_temporal_topology_info()
-         +-------------------- Temporal Topology -------------------------------------+
-         | Next: ...................... a at P
-         | Previous: .................. a at P
-         | Equal:...................... a at P
-         | Follows: ................... a at P
-         | Precedes: .................. a at P
-         | Overlaps: .................. a at P
-         | Overlapped: ................ a at P
-         | During: .................... a at P
-         | Contains: .................. a at P
-         | Starts:.. .................. a at P
-         | Started:. .................. a at P
-         | Finishes:................... a at P
-         | Finished:................... a at P
-        >>> tmr.print_temporal_topology_shell_info()
-        next=a at P
-        prev=a at P
-        equal=a at P
-        follows=a at P
-        precedes=a at P
-        overlaps=a at P
-        overlapped=a at P
-        during=a at P
-        contains=a at P
-        starts=a at P
-        started=a at P
-        finishes=a at P
-        finished=a at P
-        >>> rlist = tmr.get_temporal_relations()
-        >>> if "FINISHED" in rlist.keys():
-        ...    print rlist["FINISHED"][0].get_id()
-        a at P
+               start = start.next()
 
-        @endcode
+            >>> import grass.temporal as tgis
+            >>> tgis.init()
+            >>> map = tgis.RasterDataset("a at P")
+            >>> tmr = tgis.TemporalTopologyDatasetConnector()
+            >>> tmr.set_next(map)
+            >>> tmr.set_prev(map)
+            >>> tmr.append_equal(map)
+            >>> tmr.append_follows(map)
+            >>> tmr.append_precedes(map)
+            >>> tmr.append_overlapped(map)
+            >>> tmr.append_overlaps(map)
+            >>> tmr.append_during(map)
+            >>> tmr.append_contains(map)
+            >>> tmr.append_starts(map)
+            >>> tmr.append_started(map)
+            >>> tmr.append_finishes(map)
+            >>> tmr.append_finished(map)
+            >>> tmr.print_temporal_topology_info()
+             +-------------------- Temporal Topology -------------------------------------+
+             | Next: ...................... a at P
+             | Previous: .................. a at P
+             | Equal:...................... a at P
+             | Follows: ................... a at P
+             | Precedes: .................. a at P
+             | Overlaps: .................. a at P
+             | Overlapped: ................ a at P
+             | During: .................... a at P
+             | Contains: .................. a at P
+             | Starts:.. .................. a at P
+             | Started:. .................. a at P
+             | Finishes:................... a at P
+             | Finished:................... a at P
+            >>> tmr.print_temporal_topology_shell_info()
+            next=a at P
+            prev=a at P
+            equal=a at P
+            follows=a at P
+            precedes=a at P
+            overlaps=a at P
+            overlapped=a at P
+            during=a at P
+            contains=a at P
+            starts=a at P
+            started=a at P
+            finishes=a at P
+            finished=a at P
+            >>> rlist = tmr.get_temporal_relations()
+            >>> if "FINISHED" in rlist.keys():
+            ...    print rlist["FINISHED"][0].get_id()
+            a at P
+
     """
 
     def __init__(self):
         self.reset_temporal_topology()
 
     def reset_temporal_topology(self):
-        """!Reset any information about temporal topology"""
+        """Reset any information about temporal topology"""
         self._temporal_topology = {}
         self._has_temporal_topology = False
-        
+
     def get_temporal_relations(self):
-        """!Return the dictionary of temporal relationships
-        
+        """Return the dictionary of temporal relationships
+
             Keys are the temporal relationships in upper case,
             values are abstract map objects.
-            
-            @return The temporal relations dictionary
+
+            :return: The temporal relations dictionary
         """
         return copy.copy(self._temporal_topology)
-        
+
     def get_number_of_temporal_relations(self):
-        """! Return a dictionary in which the keys are the relation names and the value
-        are the number of relations.
-        
+        """ Return a dictionary in which the keys are the relation names and
+        the value are the number of relations.
+
         The following relations are available:
+
         - equal
         - follows
         - precedes
@@ -147,327 +144,329 @@
         - started
         - finishes
         - finished
-        
-        To access topological information the temporal topology must be build first
-        using the SpatioTemporalTopologyBuilder.
-        
-        @return the dictionary with relations as keys and number as values or None in case the topology wasn't build
+
+        To access topological information the temporal topology must be build
+        first using the SpatioTemporalTopologyBuilder.
+
+        :return: the dictionary with relations as keys and number as values
+                 or None in case the topology wasn't build
         """
-        if self._has_temporal_topology == False:
+        if self._has_temporal_topology is False:
             return None
-    
+
         relations = {}
         try:
-            relations["equal"] = len(self._temporal_topology["EQUAL"]) 
+            relations["equal"] = len(self._temporal_topology["EQUAL"])
         except:
             relations["equal"] = 0
-        try: 
-            relations["follows"] = len(self._temporal_topology["FOLLOWS"]) 
-        except: 
+        try:
+            relations["follows"] = len(self._temporal_topology["FOLLOWS"])
+        except:
             relations["follows"] = 0
-        try: 
+        try:
             relations["precedes"] = len(self._temporal_topology["PRECEDES"])
-        except: 
+        except:
             relations["precedes"] = 0
-        try: 
+        try:
             relations["overlaps"] = len(self._temporal_topology["OVERLAPS"])
-        except: 
+        except:
             relations["overlaps"] = 0
-        try: 
+        try:
             relations["overlapped"] = len(self._temporal_topology["OVERLAPPED"])
-        except: 
+        except:
             relations["overlapped"] = 0
-        try: 
+        try:
             relations["during"] = len(self._temporal_topology["DURING"])
-        except: 
+        except:
             relations["during"] = 0
-        try: 
+        try:
             relations["contains"] = len(self._temporal_topology["CONTAINS"])
-        except: 
+        except:
             relations["contains"] = 0
-        try: 
+        try:
             relations["starts"] = len(self._temporal_topology["STARTS"])
-        except: 
+        except:
             relations["starts"] = 0
-        try:    
+        try:
             relations["started"] = len(self._temporal_topology["STARTED"])
-        except: 
+        except:
             relations["started"] = 0
-        try: 
+        try:
             relations["finishes"] = len(self._temporal_topology["FINISHES"])
-        except: 
+        except:
             relations["finishes"] = 0
-        try: 
+        try:
             relations["finished"] = len(self._temporal_topology["FINISHED"])
-        except: 
+        except:
             relations["finished"] = 0
-            
+
         return relations
 
     def set_temporal_topology_build_true(self):
-        """!Same as name"""
+        """Same as name"""
         self._has_temporal_topology = True
 
     def set_temporal_topology_build_false(self):
-        """!Same as name"""
+        """Same as name"""
         self._has_temporal_topology = False
 
     def is_temporal_topology_build(self):
-        """!Check if the temporal topology was build"""
+        """Check if the temporal topology was build"""
         return self._has_temporal_topology
 
     def set_next(self, map):
-        """!Set the map that is temporally as closest located after this map.
+        """Set the map that is temporally as closest located after this map.
 
            Temporally located means that the start time of the "next" map is
            temporally located AFTER the start time of this map, but temporally
            near than other maps of the same dataset.
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         self._temporal_topology["NEXT"] = map
 
     def set_prev(self, map):
-        """!Set the map that is temporally as closest located before this map.
+        """Set the map that is temporally as closest located before this map.
 
-           Temporally located means that the start time of the "previous" map is
-           temporally located BEFORE the start time of this map, but temporally
-           near than other maps of the same dataset.
+           Temporally located means that the start time of the "previous" map
+           is temporally located BEFORE the start time of this map, but
+           temporally near than other maps of the same dataset.
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         self._temporal_topology["PREV"] = map
 
     def next(self):
-        """!Return the map with a start time temporally located after
+        """Return the map with a start time temporally located after
            the start time of this map, but temporal closer than other maps
 
-           @return A map object or None
+           :return: A map object or None
         """
         if "NEXT" not in self._temporal_topology:
             return None
         return self._temporal_topology["NEXT"]
 
     def prev(self):
-        """!Return the map with a start time temporally located before
+        """Return the map with a start time temporally located before
            the start time of this map, but temporal closer than other maps
 
-           @return A map object or None
+           :return: A map object or None
         """
         if "PREV" not in self._temporal_topology:
             return None
         return self._temporal_topology["PREV"]
 
     def append_equal(self, map):
-        """!Append a map with equivalent temporal extent as this map
+        """Append a map with equivalent temporal extent as this map
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "EQUAL" not in self._temporal_topology:
             self._temporal_topology["EQUAL"] = []
         self._temporal_topology["EQUAL"].append(map)
 
     def get_equal(self):
-        """!Return a list of map objects with equivalent temporal extent as this map
+        """Return a list of map objects with equivalent temporal extent as
+           this map
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "EQUAL" not in self._temporal_topology:
             return None
         return self._temporal_topology["EQUAL"]
 
     def append_starts(self, map):
-        """!Append a map that this map temporally starts with
+        """Append a map that this map temporally starts with
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "STARTS" not in self._temporal_topology:
             self._temporal_topology["STARTS"] = []
         self._temporal_topology["STARTS"].append(map)
 
     def get_starts(self):
-        """!Return a list of map objects that this map temporally starts with
+        """Return a list of map objects that this map temporally starts with
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "STARTS" not in self._temporal_topology:
             return None
         return self._temporal_topology["STARTS"]
 
     def append_started(self, map):
-        """!Append a map that this map temporally started with
+        """Append a map that this map temporally started with
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "STARTED" not in self._temporal_topology:
             self._temporal_topology["STARTED"] = []
         self._temporal_topology["STARTED"].append(map)
 
     def get_started(self):
-        """!Return a list of map objects that this map temporally started with
+        """Return a list of map objects that this map temporally started with
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "STARTED" not in self._temporal_topology:
             return None
         return self._temporal_topology["STARTED"]
 
     def append_finishes(self, map):
-        """!Append a map that this map temporally finishes with
+        """Append a map that this map temporally finishes with
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "FINISHES" not in self._temporal_topology:
             self._temporal_topology["FINISHES"] = []
         self._temporal_topology["FINISHES"].append(map)
 
     def get_finishes(self):
-        """!Return a list of map objects that this map temporally finishes with
+        """Return a list of map objects that this map temporally finishes with
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "FINISHES" not in self._temporal_topology:
             return None
         return self._temporal_topology["FINISHES"]
 
     def append_finished(self, map):
-        """!Append a map that this map temporally finished with
+        """Append a map that this map temporally finished with
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "FINISHED" not in self._temporal_topology:
             self._temporal_topology["FINISHED"] = []
         self._temporal_topology["FINISHED"].append(map)
 
     def get_finished(self):
-        """!Return a list of map objects that this map temporally finished with
+        """Return a list of map objects that this map temporally finished with
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "FINISHED" not in self._temporal_topology:
             return None
         return self._temporal_topology["FINISHED"]
 
     def append_overlaps(self, map):
-        """!Append a map that this map temporally overlaps
+        """Append a map that this map temporally overlaps
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "OVERLAPS" not in self._temporal_topology:
             self._temporal_topology["OVERLAPS"] = []
         self._temporal_topology["OVERLAPS"].append(map)
 
     def get_overlaps(self):
-        """!Return a list of map objects that this map temporally overlaps
+        """Return a list of map objects that this map temporally overlaps
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "OVERLAPS" not in self._temporal_topology:
             return None
         return self._temporal_topology["OVERLAPS"]
 
     def append_overlapped(self, map):
-        """!Append a map that this map temporally overlapped
+        """Append a map that this map temporally overlapped
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "OVERLAPPED" not in self._temporal_topology:
             self._temporal_topology["OVERLAPPED"] = []
         self._temporal_topology["OVERLAPPED"].append(map)
 
     def get_overlapped(self):
-        """!Return a list of map objects that this map temporally overlapped
+        """Return a list of map objects that this map temporally overlapped
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "OVERLAPPED" not in self._temporal_topology:
             return None
         return self._temporal_topology["OVERLAPPED"]
 
     def append_follows(self, map):
-        """!Append a map that this map temporally follows
+        """Append a map that this map temporally follows
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "FOLLOWS" not in self._temporal_topology:
             self._temporal_topology["FOLLOWS"] = []
         self._temporal_topology["FOLLOWS"].append(map)
 
     def get_follows(self):
-        """!Return a list of map objects that this map temporally follows
+        """Return a list of map objects that this map temporally follows
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "FOLLOWS" not in self._temporal_topology:
             return None
         return self._temporal_topology["FOLLOWS"]
 
     def append_precedes(self, map):
-        """!Append a map that this map temporally precedes
+        """Append a map that this map temporally precedes
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "PRECEDES" not in self._temporal_topology:
             self._temporal_topology["PRECEDES"] = []
         self._temporal_topology["PRECEDES"].append(map)
 
     def get_precedes(self):
-        """!Return a list of map objects that this map temporally precedes
+        """Return a list of map objects that this map temporally precedes
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "PRECEDES" not in self._temporal_topology:
             return None
         return self._temporal_topology["PRECEDES"]
 
     def append_during(self, map):
-        """!Append a map that this map is temporally located during
+        """Append a map that this map is temporally located during
            This includes temporal relationships starts and finishes
 
-           @param map This object should be of type 
-                        AbstractMapDataset or derived classes
+           :param map: This object should be of type
+                       AbstractMapDataset or derived classes
         """
         if "DURING" not in self._temporal_topology:
             self._temporal_topology["DURING"] = []
         self._temporal_topology["DURING"].append(map)
 
     def get_during(self):
-        """!Return a list of map objects that this map is temporally located during
+        """Return a list of map objects that this map is temporally located during
            This includes temporally relationships starts and finishes
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "DURING" not in self._temporal_topology:
             return None
         return self._temporal_topology["DURING"]
 
     def append_contains(self, map):
-        """!Append a map that this map temporally contains
+        """Append a map that this map temporally contains
            This includes temporal relationships started and finished
 
-           @param map This object should be of type AbstractMapDataset 
-                        or derived classes
+           :param map: This object should be of type AbstractMapDataset
+                       or derived classes
         """
         if "CONTAINS" not in self._temporal_topology:
             self._temporal_topology["CONTAINS"] = []
         self._temporal_topology["CONTAINS"].append(map)
 
     def get_contains(self):
-        """!Return a list of map objects that this map temporally contains
+        """Return a list of map objects that this map temporally contains
            This includes temporal relationships started and finished
 
-           @return A list of map objects or None
+           :return: A list of map objects or None
         """
         if "CONTAINS" not in self._temporal_topology:
             return None
@@ -487,34 +486,23 @@
             count += 1
 
         return string
-    
+
     # Set the properties
-    equal = property(fget=get_equal, 
-                                       fset=append_equal)
-    follows = property(fget=get_follows, 
-                                    fset=append_follows)
-    precedes = property(fget=get_precedes, 
-                                     fset=append_precedes)
-    overlaps = property(fget=get_overlaps, 
-                                     fset=append_overlaps)
-    overlapped = property(fget=get_overlapped, 
-                                       fset=append_overlapped)
-    during = property(fget=get_during, 
-                                   fset=append_during)
-    contains = property(fget=get_contains, 
-                                     fset=append_contains)
-    starts = property(fget=get_starts, 
-                                     fset=append_starts)
-    started = property(fget=get_started, 
-                                     fset=append_started)
-    finishes = property(fget=get_finishes, 
-                                     fset=append_finishes)
-    finished = property(fget=get_finished, 
-                                     fset=append_finished)
+    equal = property(fget=get_equal, fset=append_equal)
+    follows = property(fget=get_follows, fset=append_follows)
+    precedes = property(fget=get_precedes, fset=append_precedes)
+    overlaps = property(fget=get_overlaps, fset=append_overlaps)
+    overlapped = property(fget=get_overlapped, fset=append_overlapped)
+    during = property(fget=get_during, fset=append_during)
+    contains = property(fget=get_contains, fset=append_contains)
+    starts = property(fget=get_starts, fset=append_starts)
+    started = property(fget=get_started, fset=append_started)
+    finishes = property(fget=get_finishes, fset=append_finishes)
+    finished = property(fget=get_finished, fset=append_finished)
 
     def print_temporal_topology_info(self):
-        """!Print information about this class in human readable style"""
-        
+        """Print information about this class in human readable style"""
+
         print " +-------------------- Temporal Topology -------------------------------------+"
         #          0123456789012345678901234567890
         if self.next() is not None:
@@ -556,8 +544,8 @@
                 self._generate_map_list_string(self.finished)
 
     def print_temporal_topology_shell_info(self):
-        """!Print information about this class in shell style"""
-        
+        """Print information about this class in shell style"""
+
         if self.next() is not None:
             print "next=" + self.next().get_id()
         if self.prev() is not None:
@@ -565,7 +553,8 @@
         if self.equal is not None:
             print "equal=" + self._generate_map_list_string(self.equal, False)
         if self.follows is not None:
-            print "follows=" + self._generate_map_list_string(self.follows, False)
+            print "follows=" + self._generate_map_list_string(self.follows,
+                                                              False)
         if self.precedes is not None:
             print "precedes=" + self._generate_map_list_string(
                 self.precedes, False)
@@ -576,7 +565,8 @@
             print "overlapped=" + \
                 self._generate_map_list_string(self.overlapped, False)
         if self.during is not None:
-            print "during=" + self._generate_map_list_string(self.during, False)
+            print "during=" + self._generate_map_list_string(self.during,
+                                                             False)
         if self.contains is not None:
             print "contains=" + self._generate_map_list_string(
                 self.contains, False)

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_algebra.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,4 +1,4 @@
-"""!@package grass.temporal
+"""@package grass.temporal
 
 Temporal vector algebra
 
@@ -7,295 +7,15 @@
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at authors Thomas Leppelt and Soeren Gebbert
+:authors: Thomas Leppelt and Soeren Gebbert
 
- at code
+.. code-block:: python
 
     >>> import grass.temporal as tgis
     >>> tgis.init(True)
     >>> p = tgis.TemporalVectorAlgebraLexer()
     >>> p.build()
     >>> p.debug = True
-    >>> expression =  "C = A : B"
-    >>> p.test(expression)
-    C = A : B
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'A',1,4)
-    LexToken(T_SELECT,':',1,6)
-    LexToken(NAME,'B',1,8)
-    >>> expression =  "C = test1 !: test2"
-    >>> p.test(expression)
-    C = test1 !: test2
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(T_NOT_SELECT,'!:',1,10)
-    LexToken(NAME,'test2',1,13)
-    >>> expression =  "C = test1 {equal,:} test2"
-    >>> p.test(expression)
-    C = test1 {equal,:} test2
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(T_SELECT_OPERATOR,'{equal,:}',1,10)
-    LexToken(NAME,'test2',1,20)
-    >>> expression =  "C = test1 {equal,!:} test2"
-    >>> p.test(expression)
-    C = test1 {equal,!:} test2
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(T_SELECT_OPERATOR,'{equal,!:}',1,10)
-    LexToken(NAME,'test2',1,21)
-    >>> expression =  "C = test1 # test2"
-    >>> p.test(expression)
-    C = test1 # test2
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(HASH,'#',1,10)
-    LexToken(NAME,'test2',1,12)
-    >>> expression =  "C = test1 {#} test2"
-    >>> p.test(expression)
-    C = test1 {#} test2
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(T_HASH_OPERATOR,'{#}',1,10)
-    LexToken(NAME,'test2',1,14)
-    >>> expression =  "C = test1 {equal,#} test2"
-    >>> p.test(expression)
-    C = test1 {equal,#} test2
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(T_HASH_OPERATOR,'{equal,#}',1,10)
-    LexToken(NAME,'test2',1,20)
-    >>> expression =  "C = test1 {equal|during,#} test2"
-    >>> p.test(expression)
-    C = test1 {equal|during,#} test2
-    LexToken(NAME,'C',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(T_HASH_OPERATOR,'{equal|during,#}',1,10)
-    LexToken(NAME,'test2',1,27)
-    >>> expression =  "E = test1 : test2 !: test1"
-    >>> p.test(expression)
-    E = test1 : test2 !: test1
-    LexToken(NAME,'E',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'test1',1,4)
-    LexToken(T_SELECT,':',1,10)
-    LexToken(NAME,'test2',1,12)
-    LexToken(T_NOT_SELECT,'!:',1,18)
-    LexToken(NAME,'test1',1,21)
-    >>> expression =  'D = buff_t(test1,"10 months")'
-    >>> p.test(expression)
-    D = buff_t(test1,"10 months")
-    LexToken(NAME,'D',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(BUFF_T,'buff_t',1,4)
-    LexToken(LPAREN,'(',1,10)
-    LexToken(NAME,'test1',1,11)
-    LexToken(COMMA,',',1,16)
-    LexToken(QUOTE,'"',1,17)
-    LexToken(INT,10,1,18)
-    LexToken(NAME,'months',1,21)
-    LexToken(QUOTE,'"',1,27)
-    LexToken(RPAREN,')',1,28)
-    >>> expression =  'H = tsnap(test1)'
-    >>> p.test(expression)
-    H = tsnap(test1)
-    LexToken(NAME,'H',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(TSNAP,'tsnap',1,4)
-    LexToken(LPAREN,'(',1,9)
-    LexToken(NAME,'test1',1,10)
-    LexToken(RPAREN,')',1,15)
-    >>> expression =  'H = tsnap(test2 {during,:} buff_t(test1, "1 days"))'
-    >>> p.test(expression)
-    H = tsnap(test2 {during,:} buff_t(test1, "1 days"))
-    LexToken(NAME,'H',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(TSNAP,'tsnap',1,4)
-    LexToken(LPAREN,'(',1,9)
-    LexToken(NAME,'test2',1,10)
-    LexToken(T_SELECT_OPERATOR,'{during,:}',1,16)
-    LexToken(BUFF_T,'buff_t',1,27)
-    LexToken(LPAREN,'(',1,33)
-    LexToken(NAME,'test1',1,34)
-    LexToken(COMMA,',',1,39)
-    LexToken(QUOTE,'"',1,41)
-    LexToken(INT,1,1,42)
-    LexToken(NAME,'days',1,44)
-    LexToken(QUOTE,'"',1,48)
-    LexToken(RPAREN,')',1,49)
-    LexToken(RPAREN,')',1,50)
-    >>> expression =  'H = tshift(test2 {during,:} buff_t(test1, "1 days"), "1 months")'
-    >>> p.test(expression)
-    H = tshift(test2 {during,:} buff_t(test1, "1 days"), "1 months")
-    LexToken(NAME,'H',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(TSHIFT,'tshift',1,4)
-    LexToken(LPAREN,'(',1,10)
-    LexToken(NAME,'test2',1,11)
-    LexToken(T_SELECT_OPERATOR,'{during,:}',1,17)
-    LexToken(BUFF_T,'buff_t',1,28)
-    LexToken(LPAREN,'(',1,34)
-    LexToken(NAME,'test1',1,35)
-    LexToken(COMMA,',',1,40)
-    LexToken(QUOTE,'"',1,42)
-    LexToken(INT,1,1,43)
-    LexToken(NAME,'days',1,45)
-    LexToken(QUOTE,'"',1,49)
-    LexToken(RPAREN,')',1,50)
-    LexToken(COMMA,',',1,51)
-    LexToken(QUOTE,'"',1,53)
-    LexToken(INT,1,1,54)
-    LexToken(NAME,'months',1,56)
-    LexToken(QUOTE,'"',1,62)
-    LexToken(RPAREN,')',1,63)
-    >>> expression =  'H = tshift(A , 10)'
-    >>> p.test(expression)
-    H = tshift(A , 10)
-    LexToken(NAME,'H',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(TSHIFT,'tshift',1,4)
-    LexToken(LPAREN,'(',1,10)
-    LexToken(NAME,'A',1,11)
-    LexToken(COMMA,',',1,13)
-    LexToken(INT,10,1,15)
-    LexToken(RPAREN,')',1,17)
-    >>> expression =  'H = if(td(A) > 10, A)'
-    >>> p.test(expression)
-    H = if(td(A) > 10, A)
-    LexToken(NAME,'H',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(IF,'if',1,4)
-    LexToken(LPAREN,'(',1,6)
-    LexToken(TD,'td',1,7)
-    LexToken(LPAREN,'(',1,9)
-    LexToken(NAME,'A',1,10)
-    LexToken(RPAREN,')',1,11)
-    LexToken(GREATER,'>',1,13)
-    LexToken(INT,10,1,15)
-    LexToken(COMMA,',',1,17)
-    LexToken(NAME,'A',1,19)
-    LexToken(RPAREN,')',1,20)
-    >>> expression =  'H = if(td(A) > 10, A, B)'
-    >>> p.test(expression)
-    H = if(td(A) > 10, A, B)
-    LexToken(NAME,'H',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(IF,'if',1,4)
-    LexToken(LPAREN,'(',1,6)
-    LexToken(TD,'td',1,7)
-    LexToken(LPAREN,'(',1,9)
-    LexToken(NAME,'A',1,10)
-    LexToken(RPAREN,')',1,11)
-    LexToken(GREATER,'>',1,13)
-    LexToken(INT,10,1,15)
-    LexToken(COMMA,',',1,17)
-    LexToken(NAME,'A',1,19)
-    LexToken(COMMA,',',1,20)
-    LexToken(NAME,'B',1,22)
-    LexToken(RPAREN,')',1,23)
-    >>> expression =  'I = if(equals,td(A) > 10 {equals,||} td(B) < 10, A)'
-    >>> p.test(expression)
-    I = if(equals,td(A) > 10 {equals,||} td(B) < 10, A)
-    LexToken(NAME,'I',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(IF,'if',1,4)
-    LexToken(LPAREN,'(',1,6)
-    LexToken(NAME,'equals',1,7)
-    LexToken(COMMA,',',1,13)
-    LexToken(TD,'td',1,14)
-    LexToken(LPAREN,'(',1,16)
-    LexToken(NAME,'A',1,17)
-    LexToken(RPAREN,')',1,18)
-    LexToken(GREATER,'>',1,20)
-    LexToken(INT,10,1,22)
-    LexToken(T_OVERLAY_OPERATOR,'{equals,||}',1,25)
-    LexToken(TD,'td',1,37)
-    LexToken(LPAREN,'(',1,39)
-    LexToken(NAME,'B',1,40)
-    LexToken(RPAREN,')',1,41)
-    LexToken(LOWER,'<',1,43)
-    LexToken(INT,10,1,45)
-    LexToken(COMMA,',',1,47)
-    LexToken(NAME,'A',1,49)
-    LexToken(RPAREN,')',1,50)
-    >>> expression =  'I = if(equals,td(A) > 10 || start_day() < 10, A)'
-    >>> p.test(expression)
-    I = if(equals,td(A) > 10 || start_day() < 10, A)
-    LexToken(NAME,'I',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(IF,'if',1,4)
-    LexToken(LPAREN,'(',1,6)
-    LexToken(NAME,'equals',1,7)
-    LexToken(COMMA,',',1,13)
-    LexToken(TD,'td',1,14)
-    LexToken(LPAREN,'(',1,16)
-    LexToken(NAME,'A',1,17)
-    LexToken(RPAREN,')',1,18)
-    LexToken(GREATER,'>',1,20)
-    LexToken(INT,10,1,22)
-    LexToken(OR,'|',1,25)
-    LexToken(OR,'|',1,26)
-    LexToken(START_DAY,'start_day',1,28)
-    LexToken(LPAREN,'(',1,37)
-    LexToken(RPAREN,')',1,38)
-    LexToken(LOWER,'<',1,40)
-    LexToken(INT,10,1,42)
-    LexToken(COMMA,',',1,44)
-    LexToken(NAME,'A',1,46)
-    LexToken(RPAREN,')',1,47)
-    >>> expression =  'E = if({equals},td(A) >= 4 {contain,&&} td(B) == 2, C : D)'
-    >>> p.test(expression)
-    E = if({equals},td(A) >= 4 {contain,&&} td(B) == 2, C : D)
-    LexToken(NAME,'E',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(IF,'if',1,4)
-    LexToken(LPAREN,'(',1,6)
-    LexToken(T_REL_OPERATOR,'{equals}',1,7)
-    LexToken(COMMA,',',1,15)
-    LexToken(TD,'td',1,16)
-    LexToken(LPAREN,'(',1,18)
-    LexToken(NAME,'A',1,19)
-    LexToken(RPAREN,')',1,20)
-    LexToken(GREATER_EQUALS,'>=',1,22)
-    LexToken(INT,4,1,25)
-    LexToken(T_OVERLAY_OPERATOR,'{contain,&&}',1,27)
-    LexToken(TD,'td',1,40)
-    LexToken(LPAREN,'(',1,42)
-    LexToken(NAME,'B',1,43)
-    LexToken(RPAREN,')',1,44)
-    LexToken(CEQUALS,'==',1,46)
-    LexToken(INT,2,1,49)
-    LexToken(COMMA,',',1,50)
-    LexToken(NAME,'C',1,52)
-    LexToken(T_SELECT,':',1,54)
-    LexToken(NAME,'D',1,56)
-    LexToken(RPAREN,')',1,57)
-    >>> expression =  'F = if({equals},A {equal,#}, B, C : D)'
-    >>> p.test(expression)
-    F = if({equals},A {equal,#}, B, C : D)
-    LexToken(NAME,'F',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(IF,'if',1,4)
-    LexToken(LPAREN,'(',1,6)
-    LexToken(T_REL_OPERATOR,'{equals}',1,7)
-    LexToken(COMMA,',',1,15)
-    LexToken(NAME,'A',1,16)
-    LexToken(T_HASH_OPERATOR,'{equal,#}',1,18)
-    LexToken(COMMA,',',1,27)
-    LexToken(NAME,'B',1,29)
-    LexToken(COMMA,',',1,30)
-    LexToken(NAME,'C',1,32)
-    LexToken(T_SELECT,':',1,34)
-    LexToken(NAME,'D',1,36)
-    LexToken(RPAREN,')',1,37)
     >>> expression =  'E = A : B ^ C : D'
     >>> p.test(expression)
     E = A : B ^ C : D
@@ -308,18 +28,6 @@
     LexToken(NAME,'C',1,12)
     LexToken(T_SELECT,':',1,14)
     LexToken(NAME,'D',1,16)
-    >>> expression =  'E = A : B {|^} C : D'
-    >>> p.test(expression)
-    E = A : B {|^} C : D
-    LexToken(NAME,'E',1,0)
-    LexToken(EQUALS,'=',1,2)
-    LexToken(NAME,'A',1,4)
-    LexToken(T_SELECT,':',1,6)
-    LexToken(NAME,'B',1,8)
-    LexToken(T_OVERLAY_OPERATOR,'{|^}',1,10)
-    LexToken(NAME,'C',1,15)
-    LexToken(T_SELECT,':',1,17)
-    LexToken(NAME,'D',1,19)
     >>> expression =  'E = buff_a(A, 10)'
     >>> p.test(expression)
     E = buff_a(A, 10)
@@ -331,102 +39,17 @@
     LexToken(COMMA,',',1,12)
     LexToken(INT,10,1,14)
     LexToken(RPAREN,')',1,16)
-    >>> p = tgis.TemporalVectorAlgebraParser()
-    >>> p.run = False
-    >>> p.debug = True
-    >>> expression =  "D = A : (B !: C)"
-    >>> p.parse(expression)
-    B* =  B !: C
-    A* =  A : B*
-    D = A*
-    >>> expression =  "D = A {!:} B {during,:} C"
-    >>> print(expression)
-    D = A {!:} B {during,:} C
-    >>> p.parse(expression)
-    A* =  A {!:} B
-    A** =  A* {during,:} C
-    D = A**
-    >>> expression =  "D = A {:} B {during,!:} C"
-    >>> print(expression)
-    D = A {:} B {during,!:} C
-    >>> p.parse(expression)
-    A* =  A {:} B
-    A** =  A* {during,!:} C
-    D = A**
-    >>> expression =  "D = A {:} (B {during,!:} (C : E))"
-    >>> print(expression)
-    D = A {:} (B {during,!:} (C : E))
-    >>> p.parse(expression)
-    C* =  C : E
-    B* =  B {during,!:} C*
-    A* =  A {:} B*
-    D = A*
-    >>> p.run = False
-    >>> p.debug = False
-    >>> expression =  "C = test1 : test2"
-    >>> print(expression)
-    C = test1 : test2
-    >>> p.parse(expression, 'stvds')
-    >>> expression =  'D = buff_t(test1,"10 months")'
-    >>> print(expression)
-    D = buff_t(test1,"10 months")
-    >>> p.parse(expression, 'stvds')
-    >>> expression =  'E = test2 {during,:} buff_t(test1,"1 days")'
-    >>> print(expression)
-    E = test2 {during,:} buff_t(test1,"1 days")
-    >>> p.parse(expression, 'stvds')
-    >>> expression =  'F = test2 {equal,:} buff_t(test1,"1 days")'
-    >>> print(expression)
-    F = test2 {equal,:} buff_t(test1,"1 days")
-    >>> p.parse(expression, 'stvds')
-    >>> p.debug = True
-    >>> expression =  'H = tsnap(test2 {during,:} buff_t(test1, "1 days"))'
-    >>> p.parse(expression, 'stvds')
-    test1* = buff_t( test1 , " 1 days " )
-    test2* =  test2 {during,:} test1*
-    test2** = tsnap( test2* )
-    H = test2**
-    >>> expression =  'H = tshift(test2 {during,:} test1, "1 days")'
-    >>> p.parse(expression, 'stvds')
-    test2* =  test2 {during,:} test1
-    test2** = tshift( test2* , " 1 days " )
-    H = test2**
-    >>> expression =  'H = tshift(H, 3)'
-    >>> p.parse(expression, 'stvds')
-    H* = tshift( H , 3 )
-    H = H*
-    >>> expression =  'C = if(td(A) == 2, A)'
-    >>> p.parse(expression, 'stvds')
-    td(A)
-    td(A) == 2
-    A* =  if condition True  then  A
-    C = A*
-    >>> expression =  'C = if(td(A) == 5 || start_date() >= "2010-01-01", A, B)'
-    >>> p.parse(expression, 'stvds')
-    td(A)
-    td(A) == 5
-    start_date >= "2010-01-01"
-    True || True
-    A* =  if condition True  then  A  else  B
-    C = A*
-    >>> expression =  'C = if(td(A) == 5, A, B)'
-    >>> p.parse(expression, 'stvds')
-    td(A)
-    td(A) == 5
-    A* =  if condition True  then  A  else  B
-    C = A*
 
- at endcode
 """
 
 import grass.pygrass.modules as pygrass
-from temporal_vector_operator import *
+from temporal_operator import *
 from temporal_algebra import *
 
 ##############################################################################
 
 class TemporalVectorAlgebraLexer(TemporalAlgebraLexer):
-    """!Lexical analyzer for the GRASS GIS temporal vector algebra"""
+    """Lexical analyzer for the GRASS GIS temporal vector algebra"""
 
     def __init__(self):
         TemporalAlgebraLexer.__init__(self)
@@ -455,7 +78,8 @@
     t_DISOR              = r'\+'
     t_XOR                = r'\^'
     t_NOT                = r'\~'
-    t_T_OVERLAY_OPERATOR = r'\{([a-zA-Z\|]+[,])?([\|&+=]?[\|&+=\^\~])\}'
+    #t_T_OVERLAY_OPERATOR = r'\{([a-zA-Z\|]+[,])?([\|&+=]?[\|&+=\^\~])\}'
+    t_T_OVERLAY_OPERATOR = r'\{[\|&+\^\~][,]?[a-zA-Z\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\}'
 
     # Parse symbols
     def temporal_symbol(self, t):
@@ -482,7 +106,7 @@
 
     # Setting equal precedence level for select and hash operations.
     precedence = (
-        ('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT'), # 1
+        ('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT',  'T_HASH_OPERATOR',  'HASH'), # 1
         ('left', 'AND', 'OR', 'T_COMP_OPERATOR', 'T_OVERLAY_OPERATOR', 'DISOR', \
           'NOT', 'XOR'), #2
         )
@@ -493,10 +117,22 @@
         self.m_overlay = pygrass.Module('v.overlay', quiet=True, run_=False)
         self.m_rename = pygrass.Module('g.rename', quiet=True, run_=False)
         self.m_patch = pygrass.Module('v.patch', quiet=True, run_=False)
-        self.m_remove = pygrass.Module('g.remove', quiet=True, run_=False)
+        self.m_mremove = pygrass.Module('g.remove', quiet=True, run_=False)
         self.m_buffer = pygrass.Module('v.buffer', quiet=True, run_=False)
 
     def parse(self, expression, basename = None, overwrite = False):
+        # Check for space time dataset type definitions from temporal algebra
+        l = TemporalVectorAlgebraLexer()
+        l.build()
+        l.lexer.input(expression)
+
+        while True:
+            tok = l.lexer.token()
+            if not tok: break
+            
+            if tok.type == "STVDS" or tok.type == "STRDS" or tok.type == "STR3DS":
+                raise SyntaxError("Syntax error near '%s'" %(tok.type))
+
         self.lexer = TemporalVectorAlgebraLexer()
         self.lexer.build()
         self.parser = yacc.yacc(module=self, debug=self.debug)
@@ -504,121 +140,213 @@
         self.overwrite = overwrite
         self.count = 0
         self.stdstype = "stvds"
+        self.maptype = "vect"
+        self.mapclass = VectorDataset
         self.basename = basename
         self.expression = expression
         self.parser.parse(expression)
 
     ######################### Temporal functions ##############################
 
-    def remove_intermediate_vector_maps(self):
-        """! Removes the intermediate vector maps.
+    def get_temporal_topo_list(self, maplistA, maplistB = None, topolist = ["EQUAL"],
+                               assign_val = False, count_map = False, compare_bool = False,  
+                               compare_cmd = False,  compop = None, aggregate = None,  
+                               new = False,  convert = False,  overlay_cmd = False):
+        """Build temporal topology for two space time data sets, copy map objects
+          for given relation into map list.
+          
+          :param maplistA: List of maps.
+          :param maplistB: List of maps.
+          :param topolist: List of strings of temporal relations.
+          :param assign_val: Boolean for assigning a boolean map value based on
+                            the map_values from the compared map list by
+                            topological relationships.
+          :param count_map: Boolean if the number of topological related maps
+                           should be returned.
+          :param compare_bool: Boolean for comparing boolean map values based on
+                            related map list and compariosn operator.
+          :param compare_cmd: Boolean for comparing command list values based on
+                            related map list and compariosn operator.
+          :param compop: Comparison operator, && or ||.
+          :param aggregate: Aggregation operator for relation map list, & or |.
+          :param new: Boolean if new temporary maps should be created.
+          :param convert: Boolean if conditional values should be converted to 
+                        r.mapcalc command strings.
+          :param overlay_cmd: Boolean for aggregate overlay operators implicitly 
+                        in command list values based on related map lists.
+                    
+          :return: List of maps from maplistA that fulfil the topological relationships
+                  to maplistB specified in topolist.
         """
-        if self.names != {}:
-            namelist = self.names.values()
-            max = 100
-            chunklist = [namelist[i:i + max] for i in range(0, len(namelist), max)]
-            for chunk in chunklist:
-                stringlist = ",".join(chunk)
-                if self.debug:
-                    print "g.remove type=vect pattern=%s"%(stringlist)
+        topologylist = ["EQUAL", "FOLLOWS", "PRECEDES", "OVERLAPS", "OVERLAPPED", \
+                        "DURING", "STARTS", "FINISHES", "CONTAINS", "STARTED", \
+                        "FINISHED"]
+        complementdict = {"EQUAL": "EQUAL", "FOLLOWS" : "PRECEDES",
+                          "PRECEDES" : "FOLLOWS", "OVERLAPS" : "OVERLAPPED",
+                          "OVERLAPPED" : "OVERLAPS", "DURING" : "CONTAINS",
+                          "CONTAINS" : "DURING", "STARTS" : "STARTED",
+                          "STARTED" : "STARTS", "FINISHES" : "FINISHED",
+                          "FINISHED" : "FINISHES"}
+        resultdict = {}
+        # Check if given temporal relation are valid.
+        for topo in topolist:
+          if topo.upper() not in topologylist:
+              raise SyntaxError("Unpermitted temporal relation name '" + topo + "'")
 
-                if self.run:
-                    m = copy.deepcopy(self.m_remove)
-                    m.inputs["type"].value = "vect"
-                    m.inputs["pattern"].value = stringlist
-                    m.flags["f"].value = True
-                    m.run()
+        # Create temporal topology for maplistA to maplistB.
+        tb = SpatioTemporalTopologyBuilder()
+        # Dictionary with different spatial variables used for topology builder.
+        spatialdict = {'strds' : '2D', 'stvds' : '2D', 'str3ds' : '3D'}
+        # Build spatial temporal topology
+        if self.spatial:
+            tb.build(maplistA, maplistB, spatial = spatialdict[self.stdstype])
+        else:
+            tb.build(maplistA, maplistB)
+        # Iterate through maps in maplistA and search for relationships given
+        # in topolist.
+        for map_i in maplistA:
+            tbrelations = map_i.get_temporal_relations()
+            # Check for boolean parameters for further calculations.
+            if assign_val:
+                self.assign_bool_value(map_i,  tbrelations,  topolist)
+            elif compare_bool:
+                self.compare_bool_value(map_i,  tbrelations, compop, aggregate, topolist)
+            elif compare_cmd:
+                self.compare_cmd_value(map_i,  tbrelations, compop, aggregate, topolist, convert)
+            elif overlay_cmd:
+                self.overlay_cmd_value(map_i,  tbrelations, compop, topolist)
+                
+            for topo in topolist:
+                if topo.upper() in tbrelations.keys():
+                    if count_map:
+                        relationmaplist = tbrelations[topo.upper()]
+                        gvar = GlobalTemporalVar()
+                        gvar.td = len(relationmaplist)
+                        if "map_value" in dir(map_i):
+                            map_i.map_value.append(gvar)
+                        else:
+                            map_i.map_value = gvar
+                    # Use unique identifier, since map names may be equal
+                    resultdict[map_i.uid] = map_i
+        resultlist = resultdict.values()
+        
+        # Sort list of maps chronological.
+        resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
+        
+        return(resultlist)
 
-    def eval_toperator(self, operator, comparison = False):
-        """!This function evaluates a string containing temporal operations.
-
-          @param operator String of temporal operations, e.g. {equal|during,=!:}.
-
-          @return List of temporal relations (equal, during), the given function
-           (!:) and the interval/instances (=).
-
-          @code
-          >>> import grass.temporal as tgis
-          >>> tgis.init(True)
-          >>> p = tgis.TemporalVectorAlgebraParser()
-          >>> operator = "{equal,:}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL'], '=', ':')
-          >>> operator = "{equal|during,:}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL', 'DURING'], '=', ':')
-          >>> operator = "{equal,!:}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL'], '=', '!:')
-          >>> operator = "{equal|during,!:}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL', 'DURING'], '=', '!:')
-          >>> operator = "{equal|during,=!:}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL', 'DURING'], '=', '!:')
-          >>> operator = "{equal|during|starts,#}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL', 'DURING', 'STARTS'], '=', '#')
-          >>> operator = "{!:}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL'], '=', '!:')
-          >>> operator = "{=:}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL'], '=', ':')
-          >>> operator = "{#}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL'], '=', '#')
-          >>> operator = "{equal|during}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL', 'DURING'], None, None)
-          >>> operator = "{equal}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL'], None, None)
-          >>> operator = "{equal,||}"
-          >>> p.eval_toperator(operator, True)
-          (['EQUAL'], '=', '||')
-          >>> operator = "{equal|during,&&}"
-          >>> p.eval_toperator(operator, True)
-          (['EQUAL', 'DURING'], '=', '&&')
-          >>> operator = "{&}"
-          >>> p.eval_toperator(operator)
-          (['EQUAL'], '=', '&')
-
-          @endcode
-
+    def overlay_cmd_value(self,  map_i, tbrelations, function, topolist = ["EQUAL"]):
+        """ Function to evaluate two map lists by given overlay operator.
+        
+          :param map_i: Map object with temporal extent.
+          :param tbrelations: List of temporal relation to map_i.
+          :param topolist: List of strings for given temporal relations.
+          :param function: Overlay operator, &|+^~.
+          
+          :return: Map object with command list with  operators that has been 
+                        evaluated by implicit aggregration.
         """
+        # Build comandlist list with elements from related maps and given relation operator.
+        resultlist = []
+        # Define overlay operation dictionary.
+        overlaydict = {"&":"and",  "|":"or",  "^":"xor",  "~":"not", "+":"disor"}
+        operator = overlaydict[function]
+        # Set first input for overlay module.
+        mapainput = map_i.get_id()
+        # Append command list of given map to result command list.
+        if "cmd_list" in dir(map_i):
+            resultlist = resultlist + map_i.cmd_list
+        for topo in topolist:
+            if topo.upper() in tbrelations.keys():
+                relationmaplist = tbrelations[topo.upper()]
+                for relationmap in relationmaplist:
+                    # Append command list of given map to result command list.
+                    if "cmd_list" in dir(relationmap):
+                        resultlist = resultlist + relationmap.cmd_list
+                    # Generate an intermediate name
+                    name = self.generate_map_name()
+                    # Put it into the removalbe map list
+                    self.removable_maps[name] = VectorDataset(name + "@%s"%(self.mapset))
+                    map_i.set_id(name + "@" + self.mapset)
+                    # Set second input for overlay module.
+                    mapbinput = relationmap.get_id()
+                    # Create module command in PyGRASS for v.overlay and v.patch.
+                    if operator != "disor":
+                        m = copy.deepcopy(self.m_overlay)
+                        m.run_ = False
+                        m.inputs["operator"].value = operator
+                        m.inputs["ainput"].value = str(mapainput)
+                        m.inputs["binput"].value = str(mapbinput)
+                        m.outputs["output"].value = name
+                        m.flags["overwrite"].value = self.overwrite
+                    else:
+                        patchinput = str(mapainput) + ',' + str(mapbinput)
+                        m = copy.deepcopy(self.m_patch)
+                        m.run_ = False
+                        m.inputs["input"].value = patchinput
+                        m.outputs["output"].value = name
+                        m.flags["overwrite"].value = self.overwrite
+                    # Conditional append of module command.
+                    resultlist.append(m)
+                    # Set new map name to temporary map name.
+                    mapainput = name
+        # Add command list to result map.
+        map_i.cmd_list = resultlist
+        
+        return(resultlist)
 
-        p = TemporalVectorOperatorParser()
-        p.parse(operator, comparison)
-        p.relations = [rel.upper() for rel in p.relations]
+    def set_temporal_extent_list(self, maplist, topolist = ["EQUAL"], temporal = 'l' ):
+        """ Change temporal extent of map list based on temporal relations to 
+                other map list and given temporal operator.
 
-        return(p.relations, p.temporal, p.function)
+            :param maplist: List of map objects for which relations has been build 
+                                        correctely.
+            :param topolist: List of strings of temporal relations.
+            :param temporal: The temporal operator specifying the temporal
+                                            extent operation (intersection, union, disjoint 
+                                            union, right reference, left reference).
 
-    def overlay_map_extent(self, mapA, mapB, bool_op = None, temp_op = '=',
-                            copy = False):
-        """!Compute the spatio-temporal extent of two topological related maps
-
-           @param mapA The first map
-           @param mapB The second maps
-           @param bool_op The boolean operator specifying the spatial extent
-                  operation (intersection, union, disjoint union)
-           @param temp_op The temporal operator specifying the temporal
-                  exntent operation (intersection, union, disjoint union)
-           @param copy Specifies if the temporal extent of mapB should be
-                  copied to mapA
+            :return: Map list with specified temporal extent.
         """
-        returncode = TemporalAlgebraParser.overlay_map_extent(self, mapA, mapB,
-                                                              bool_op, temp_op,
-                                                              copy)
-        if not copy and returncode == 1:
-            # Conditional append of command list.
-            if "cmd_list" in dir(mapA) and "cmd_list" in dir(mapB):
-                mapA.cmd_list = mapA.cmd_list + mapB.cmd_list
-            elif "cmd_list" not in dir(mapA) and "cmd_list" in dir(mapB):
-                mapA.cmd_list = mapB.cmd_list
-
-        return(returncode)
-
+        resultdict = {}
+        
+        for map_i in maplist:
+            # Loop over temporal related maps and create overlay modules.
+            tbrelations = map_i.get_temporal_relations()
+            # Generate an intermediate map for the result map list.
+            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+                                                                        copy = True,  rename = False,  
+                                                                        remove = True)
+            # Combine temporal and spatial extents of intermediate map with related maps.
+            for topo in topolist:
+                if topo in tbrelations.keys():
+                    for map_j in (tbrelations[topo]):
+                        if temporal == 'r':
+                            # Generate an intermediate map for the result map list.
+                            map_new = self.generate_new_map(base_map=map_i, bool_op = 'and', 
+                                                                                        copy = True,  rename = False,  
+                                                                                        remove = True)
+                        # Create overlayed map extent.
+                        returncode = self.overlay_map_extent(map_new, map_j, 'and', \
+                                                                temp_op = temporal)
+                        # Stop the loop if no temporal or spatial relationship exist.
+                        if returncode == 0:
+                            break
+                        # Append map to result map list.
+                        elif returncode == 1:
+                            # resultlist.append(map_new)
+                            resultdict[map_new.get_id()] = map_new
+                    if returncode == 0:
+                        break
+            # Append map to result map list.
+            #if returncode == 1:
+            #    resultlist.append(map_new)
+        # Get sorted map objects as values from result dictionoary.
+        resultlist = resultdict.values()
+        resultlist = sorted(resultlist, key = AbstractDatasetComparisonKeyStartTime)
+        
+        return(resultlist)
+    
     ###########################################################################
 
     def p_statement_assign(self, t):
@@ -629,6 +357,8 @@
         """
         # Execute the command lists
         if self.run:
+            # Open connection to temporal database.
+            dbif, connected = init_dbif(dbif=self.dbif)
             if isinstance(t[3], list):
                 num = len(t[3])
                 count = 0
@@ -684,8 +414,8 @@
                                 break
                         if returncode == 0:
                             # We remove the invalid vector name from the remove list.
-                            if self.names.has_key(map_i.get_name()):
-                                self.names.pop(map_i.get_name())
+                            if self.removable_maps.has_key(map_i.get_name()):
+                                self.removable_maps.pop(map_i.get_name())
                             mapset = map_i.get_mapset()
                             # Change map name to given basename.
                             newident = self.basename + "_" + str(count)
@@ -693,25 +423,49 @@
                             m.inputs["vect"].value = (map_i.get_name(),newident)
                             m.flags["overwrite"].value = self.overwrite
                             m.run()
-                            #m(vect = (map_i.get_name(),newident), \
-                            #    overwrite = self.overwrite)
                             map_i.set_id(newident + "@" + mapset)
                             count += 1
                             register_list.append(map_i)
                     else:
-                        register_list.append(map_i)
+                        # Test if temporal extents have been changed by temporal 
+                        # relation operators (i|r). This is a code copy from temporal_algebra.py
+                        map_i_extent = map_i.get_temporal_extent_as_tuple()
+                        map_test = map_i.get_new_instance(map_i.get_id())
+                        map_test.select(dbif)
+                        map_test_extent = map_test.get_temporal_extent_as_tuple()
+                        if map_test_extent != map_i_extent:
+                            # Create new map with basename
+                            newident = self.basename + "_" + str(count)
+                            map_result = map_i.get_new_instance(newident + "@" + self.mapset)
 
+                            if map_test.map_exists() and self.overwrite == False:
+                                self.msgr.fatal("Error raster maps with basename %s exist. Use --o flag to overwrite existing file" \
+                                                    %(mapname))
+
+                            map_result.set_temporal_extent(map_i.get_temporal_extent())
+                            map_result.set_spatial_extent(map_i.get_spatial_extent())
+                            # Attention we attach a new attribute
+                            map_result.is_new = True
+                            count += 1
+                            register_list.append(map_result)
+
+                            # Copy the map
+                            m = copy.deepcopy(self.m_copy)
+                            m.inputs["vect"].value = map_i.get_id(),  newident
+                            m.flags["overwrite"].value = self.overwrite
+                            m.run()
+                        else:
+                            register_list.append(map_i)
+
                 if len(register_list) > 0:
-                    # Open connection to temporal database.
-                    dbif, connected = init_dbif(dbif=self.dbif)
                     # Create result space time dataset.
-                    resultstds = open_new_space_time_dataset(t[1], self.stdstype, \
+                    resultstds = open_new_stds(t[1], self.stdstype, \
                                                                 'absolute', t[1], t[1], \
-                                                                "temporal vector algebra", dbif=dbif,
+                                                                "temporal vector algebra", self.dbif,
                                                                 overwrite = self.overwrite)
                     for map_i in register_list:
                         # Check if modules should be executed from command list.
-                        if "cmd_list" in dir(map_i):
+                        if hasattr(map_i, "cmd_list") or hasattr(map_i, "is_new"):
                             # Get meta data from grass database.
                             map_i.load()
                             if map_i.is_in_db(dbif=dbif) and self.overwrite:
@@ -726,18 +480,18 @@
                                 # Insert map into temporal database.
                                 map_i.insert(dbif=dbif)
                         else:
-                            #Get metadata from temporal database.
-                            map_i.select(dbif=dbif)
+                            # Map is original from an input STVDS
+                            map_i.load()
                         # Register map in result space time dataset.
-                        resultstds.register_map(map_i, dbif=dbif)
-                        #count += 1
-                        #if count % 10 == 0:
-                        #    grass.percent(count, num, 1)
-                    resultstds.update_from_registered_maps(dbif=dbif)
-                    if connected:
-                        dbif.close()
-                self.remove_intermediate_vector_maps()
-            t[0] = register_list
+                        print map_i.get_temporal_extent_as_tuple()
+                        success = resultstds.register_map(map_i, dbif=dbif)
+                    resultstds.update_from_registered_maps(dbif)
+                
+            # Remove intermediate maps    
+            self.remove_maps()
+            if connected:
+                dbif.close()
+            t[0] = t[3]
 
     def p_overlay_operation(self, t):
         """
@@ -762,15 +516,24 @@
              | stds DISOR expr
              | expr DISOR expr
         """
-        # Check input stds.
-        maplistA = self.check_stds(t[1])
-        maplistB = self.check_stds(t[3])
-
         if self.run:
-            t[0] = self.create_overlay_operations(maplistA, maplistB, ("EQUAL",), "=", t[2])
-        else:
-            t[0] = t[1]
+            # Check input stds and operator.
+            maplistA = self.check_stds(t[1])
+            maplistB = self.check_stds(t[3])
+            relations = ["EQUAL"]
+            temporal = 'l' 
+            function = t[2] 
+            # Build commmand list for related maps.
+            complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
+                                                                    compop = function, overlay_cmd = True)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
 
+            t[0] = resultlist
+        if self.debug:
+            str(t[1]) + t[2] + str(t[3])
+
     def p_overlay_operation_relation(self, t):
         """
         expr : stds T_OVERLAY_OPERATOR stds
@@ -778,102 +541,22 @@
              | stds T_OVERLAY_OPERATOR expr
              | expr T_OVERLAY_OPERATOR expr
         """
-        # Check input stds.
-        maplistA = self.check_stds(t[1])
-        maplistB = self.check_stds(t[3])
-        relations, temporal, function= self.eval_toperator(t[2])
-
         if self.run:
-            t[0] = self.create_overlay_operations(maplistA, maplistB, relations, temporal, function)
-        else:
-            t[0] = t[1]
+            # Check input stds and operator.
+            maplistA = self.check_stds(t[1])
+            maplistB = self.check_stds(t[3])
+            relations, temporal, function,  aggregate = self.eval_toperator(t[2],  optype = 'overlay')
+            # Build commmand list for related maps.
+            complist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations,
+                                                                    compop = function, overlay_cmd = True)
+            # Set temporal extent based on topological relationships.
+            resultlist = self.set_temporal_extent_list(complist, topolist = relations, 
+                                temporal = temporal)
+          
+            t[0] = resultlist
+        if self.debug:
+            str(t[1]) + t[2] + str(t[3])
 
-    def create_overlay_operations(self, maplistA, maplistB, relations, temporal, function):
-        """!Create the spatial overlay operation commad list
-
-           @param maplistA A list of map objects
-           @param maplistB A list of map objects
-           @param relations The temporal relationships that must be fullfilled as list of strings
-                            ("EQUAL", "DURING", ...)
-           @param temporal The temporal operator as string "=" or "&", ...
-           @param function The spatial overlay operations as string "&", "|", ...
-           @return Return the list of maps with overlay commands
-        """
-        topolist = self.get_temporal_topo_list(maplistA, maplistB, topolist = relations)
-
-        # Select operation name.
-        if function == "&":
-            opname = "and"
-        elif function == "|":
-            opname = "or"
-        elif function == "^":
-            opname = "xor"
-        elif function == "~":
-            opname = "not"
-        elif function == "+":
-            opname = "disor"
-
-        if self.run:
-            resultlist = []
-            for map_i in topolist:
-                # Generate an intermediate name for the result map list.
-                map_new = self.generate_new_map(base_map=map_i, bool_op=opname,
-                                                copy=True)
-                # Set first input for overlay module.
-                mapainput = map_i.get_id()
-                # Loop over temporal related maps and create overlay modules.
-                tbrelations = map_i.get_temporal_relations()
-                count = 0
-                for topo in relations:
-                    if topo in tbrelations.keys():
-                        for map_j in (tbrelations[topo]):
-                            # Create overlayed map extent.
-                            returncode = self.overlay_map_extent(map_new, map_j, opname, \
-                                                                    temp_op = temporal)
-                            # Stop the loop if no temporal or spatial relationship exist.
-                            if returncode == 0:
-                                break
-                            if count == 0:
-                                # Set map name.
-                                name = map_new.get_id()
-                            else:
-                                # Generate an intermediate name
-                                name = self.generate_map_name()
-                                map_new.set_id(name + "@" + mapset)
-                            # Set second input for overlay module.
-                            mapbinput = map_j.get_id()
-                            # Create module command in PyGRASS for v.overlay and v.patch.
-                            if opname != "disor":
-                                m = copy.deepcopy(self.m_overlay)
-                                m.run_ = False
-                                m.inputs["operator"].value = opname
-                                m.inputs["ainput"].value = str(mapainput)
-                                m.inputs["binput"].value = str(mapbinput)
-                                m.outputs["output"].value = name
-                                m.flags["overwrite"].value = self.overwrite
-                            else:
-                                patchinput = str(mapainput) + ',' + str(mapbinput)
-                                m = copy.deepcopy(self.m_patch)
-                                m.run_ = False
-                                m.inputs["input"].value = patchinput
-                                m.outputs["output"].value = name
-                                m.flags["overwrite"].value = self.overwrite
-                            # Conditional append of module command.
-                            if "cmd_list" in dir(map_new):
-                                map_new.cmd_list.append(m)
-                            else:
-                                map_new.cmd_list = [m]
-                            # Set new map name to temporary map name.
-                            mapainput = name
-                            count += 1
-                        if returncode == 0:
-                            break
-                # Append map to result map list.
-                if returncode == 1:
-                    resultlist.append(map_new)
-
-            return resultlist
-
     def p_buffer_operation(self,t):
         """
         expr : buff_function LPAREN stds COMMA number RPAREN
@@ -889,7 +572,7 @@
             for map_i in bufflist:
                 # Generate an intermediate name for the result map list.
                 map_new = self.generate_new_map(base_map=map_i, bool_op=None,
-                                                copy=True)
+                                                copy=True,  remove = True)
                 # Change spatial extent based on buffer size.
                 map_new.spatial_buffer(float(t[5]))
                 # Check buff type.

Deleted: grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_operator.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_operator.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/temporal_vector_operator.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,349 +0,0 @@
-"""!@package grass.temporal
-
-Temporal vector operator evaluation with PLY
-
-(C) 2014 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at authors Thomas Leppelt and Soeren Gebbert
-
- at code
-    >>> import grass.temporal as tgis
-    >>> tgis.init(True)
-    >>> p = tgis.TemporalVectorOperatorParser()
-    >>> expression =  "{equal| during,&&}"
-    >>> p.parse(expression, True)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during'], '=', '&&')
-    >>> expression =  "{equal| during | follows,&&}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'follows'], '&', '&')
-    >>> expression =  "{equal| during | follows,+!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'follows'], '+', '!:')
-    >>> expression =  "{equal| during,!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during'], '=', '!:')
-    >>> expression =  "{!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '=', '!:')
-    >>> expression =  "{&&}"
-    >>> p.parse(expression, True)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '=', '&&')
-    >>> expression =  "{&&}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '&', '&')
-    >>> expression =  "{|#}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '|', '#')
-    >>> expression =  "{equal,||}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal'], '|', '|')
-    >>> expression =  "{equal|during,=!:}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during'], '=', '!:')
-    >>> expression =  "{equal|during|starts}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    (['equal', 'during', 'starts'], None, None)
-    >>> expression =  "{over| equal,||}"
-    >>> p.parse(expression)
-    >>> print(p.relations, p.temporal, p.function)
-    ([['overlaps', 'overlapped'], 'equal'], '|', '|')
-    
- at endcode
-"""
-try:
-    import ply.lex as lex
-    import ply.yacc as yacc
-except:
-    pass
-
-class TemporalVectorOperatorLexer(object):
-    """!Lexical analyzer for the GRASS GIS temporal vector operators"""
-    
-    # Functions that defines topological relations.
-    relations = {
-        'equal'      : "EQUAL",
-        'follows'    : "FOLLOWS",
-        'precedes'   : "PRECEDES",
-        'overlaps'   : "OVERLAPS",
-        'overlapped' : "OVERLAPPED",
-        'during'     : "DURING",
-        'starts'     : "STARTS",
-        'finishes'   : "FINISHES",
-        'contains'   : "CONTAINS",
-        'started'    : "STARTED",
-        'finished'   : "FINISHED",
-        'over'       : "OVER"
-        }
-        
-    # This is the list of token names.
-    tokens = (
-        'COMMA',
-        'LEFTREF',
-        'HASH',
-        'OR',
-        'AND',
-        'DISOR',
-        'XOR',
-        'NOT',
-        'T_SELECT',
-        'T_NOT_SELECT',
-        'CLPAREN',
-        'CRPAREN',
-    )
-    
-    # Build the token list
-    tokens = tokens + tuple(relations.values())
-
-    # Regular expression rules for simple tokens
-    t_T_SELECT           = r':'
-    t_T_NOT_SELECT       = r'!:'
-    t_COMMA              = r','
-    t_LEFTREF             = r'='
-    t_HASH               = r'\#'
-    t_OR                 = r'[\|]'
-    t_AND                = r'[&]'
-    t_DISOR              = r'\+'
-    t_XOR                = r'\^'
-    t_NOT                = r'\~'
-    t_CLPAREN             = r'\{'
-    t_CRPAREN             = r'\}'
-    
-    # These are the things that should be ignored.
-    t_ignore = ' \t'
-
-    # Track line numbers.
-    def t_newline(self, t):
-        r'\n+'
-        t.lineno += len(t.value)
-        
-    def t_NAME(self, t):
-        r'[a-zA-Z_][a-zA-Z_0-9]*'
-        self.temporal_symbol(t)
-        return t
-        
-    # Parse symbols
-    def temporal_symbol(self, t):
-        # Check for reserved words
-        if t.value in TemporalVectorOperatorLexer.relations.keys():
-            t.type = TemporalVectorOperatorLexer.relations.get(t.value)
-        #else:
-        #    t.type = 'NAME'
-        return(t)
-
-    # Handle errors.
-    def t_error(self, t):
-        raise SyntaxError("syntax error on line %d near '%s'" % 
-            (t.lineno, t.value))
-
-    # Build the lexer
-    def build(self,**kwargs):
-        self.lexer = lex.lex(module=self, **kwargs)
-        
-    # Just for testing
-    def test(self,data):
-        self.name_list = {}
-        print(data)
-        self.lexer.input(data)
-        while True:
-             tok = self.lexer.token()
-             if not tok: break
-             print tok
-             
-class TemporalVectorOperatorParser(object):
-    """!The parser for the GRASS GIS temporal vector operators"""
-    
-    def __init__(self):
-        self.lexer = TemporalVectorOperatorLexer()
-        self.lexer.build()
-        self.parser = yacc.yacc(module=self)
-
-    def parse(self, expression, comparison = False):
-        self.comparison = comparison
-        self.parser.parse(expression)
-        
-    # Error rule for syntax errors.
-    def p_error(self, t):
-        raise SyntaxError("invalid syntax")
-
-    # Get the tokens from the lexer class
-    tokens = TemporalVectorOperatorLexer.tokens
-
-    def p_relation_only(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN relation CRPAREN
-                 | CLPAREN relationlist CRPAREN
-        """
-        # Set three operator components.
-        if isinstance(t[2], list):
-            self.relations = t[2]
-        else:
-            self.relations = [t[2]]
-        self.temporal  = None 
-        self.function  = None
-        
-        t[0] = t[2]
-
-
-    def p_operator(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN select CRPAREN
-                 | CLPAREN HASH CRPAREN
-                 | CLPAREN overlay CRPAREN
-        """
-        # Set three operator components.
-        self.relations = ['equal']
-        self.temporal  = "=" 
-        self.function  = t[2]
-        
-        t[0] = t[2]
-        
-    def p_operator_temporal(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN temporal select CRPAREN
-                 | CLPAREN temporal HASH CRPAREN
-                 | CLPAREN temporal overlay CRPAREN
-        """
-        # Set three operator components.
-        self.relations = ['equal']
-        if self.comparison:
-            self.temporal = "="
-            self.function = t[2] + t[3]
-        else:
-            self.temporal = t[2]
-            self.function = t[3]
-        
-        t[0] = t[3]
-
-    def p_operator_relation(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN relation COMMA select CRPAREN
-                 | CLPAREN relationlist COMMA select CRPAREN
-                 | CLPAREN relation COMMA HASH CRPAREN
-                 | CLPAREN relationlist COMMA HASH CRPAREN
-                 | CLPAREN relation COMMA overlay CRPAREN
-                 | CLPAREN relationlist COMMA overlay CRPAREN
-        """
-        # Set three operator components.
-        if isinstance(t[2], list):
-            self.relations = t[2]
-        else:
-            self.relations = [t[2]]
-        self.temporal  = "=" 
-        self.function  = t[4]
-        
-        t[0] = t[4]
-
-    def p_operator_relation_temporal(self, t):
-        # The expression should always return a list of maps.
-        """
-        operator : CLPAREN relation COMMA temporal select CRPAREN
-                 | CLPAREN relationlist COMMA temporal select CRPAREN
-                 | CLPAREN relation COMMA temporal HASH CRPAREN
-                 | CLPAREN relationlist COMMA temporal HASH CRPAREN
-                 | CLPAREN relation COMMA temporal overlay CRPAREN
-                 | CLPAREN relationlist COMMA temporal overlay CRPAREN
-        """
-        # Set three operator components.
-        if isinstance(t[2], list):
-            self.relations = t[2]
-        else:
-            self.relations = [t[2]]
-        if self.comparison:
-            self.temporal = "="
-            self.function = t[4] + t[5]
-        else:
-            self.temporal = t[4]
-            self.function = t[5]
-        t[0] = t[5]
-        
-    def p_relation(self, t):
-        # The list of relations.
-        """
-        relation : EQUAL
-                 | FOLLOWS
-                 | PRECEDES
-                 | OVERLAPS
-                 | OVERLAPPED
-                 | DURING
-                 | STARTS
-                 | FINISHES
-                 | CONTAINS
-                 | STARTED
-                 | FINISHED
-        """
-        t[0] = t[1]
-        
-    def p_over(self, t):
-        # The list of relations.
-        """
-        relation : OVER
-        """
-        over_list = ["overlaps", "overlapped"]
-        t[0] = over_list
-
-    def p_relationlist(self, t):
-        # The list of relations.
-        """
-        relationlist : relation OR relation
-                     | relation OR relationlist
-        """
-        rel_list = []
-        rel_list.append(t[1])
-        if isinstance(t[3], list):
-            rel_list = rel_list + t[3]
-        else:
-            rel_list.append(t[3])
-        t[0] =  rel_list
-
-    def p_temporal_operator(self, t):
-        # The list of relations.
-        """
-        temporal : LEFTREF
-                 | OR
-                 | AND
-                 | DISOR
-        """
-        t[0] = t[1]
-
-    def p_select_operator(self, t):
-        # The list of relations.
-        """
-        select : T_SELECT
-               | T_NOT_SELECT
-        """
-        t[0] = t[1]
-
-    def p_overlay_operator(self, t):
-        # The list of relations.
-        """
-        overlay : OR
-                | AND
-                | DISOR
-                | XOR
-                | NOT
-        """
-        t[0] = t[1]
-###############################################################################             
-        
-if __name__ == "__main__":
-    import doctest
-    doctest.testmod()
-    
\ No newline at end of file

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_doctests.py (from rev 61431, grass/trunk/lib/python/temporal/testsuite/test_doctests.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_doctests.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_doctests.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+"""
+Temporal framework doctests
+"""
+
+import doctest
+import grass.temporal
+import grass.gunittest
+import grass.gunittest.utils
+import os
+
+doctest.DocFileCase = type('DocFileCase',
+                           (grass.gunittest.TestCase,),
+                           dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+                               (grass.gunittest.TestCase,),
+                               dict(doctest.SkipDocTestCase.__dict__))
+
+def load_tests(loader, tests, ignore):
+    grass.gunittest.utils.do_doctest_gettext_workaround()
+    tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_dataset))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_map_dataset))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_space_time_dataset))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.base))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.c_libraries_interface))
+    # Unexpected error here
+    #tests.addTests(doctest.DocTestSuite(grass.temporal.core))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.datetime_math))
+    # Unexpected error here
+    #tests.addTests(doctest.DocTestSuite(grass.temporal.list_stds))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.metadata))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.register))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.space_time_datasets))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.spatial_extent))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.spatial_topology_dataset_connector))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.spatio_temporal_relationships))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_extent))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_granularity))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_topology_dataset_connector))
+    # Algebra is still very experimental
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_algebra))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster3d_algebra))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster_algebra))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster_base_algebra))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_operator))
+    tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_vector_algebra))
+    return tests
+
+if __name__ == '__main__':
+    grass.gunittest.test()

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_register_function.py (from rev 61433, grass/trunk/lib/python/temporal/testsuite/test_register_function.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_register_function.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/test_register_function.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,302 @@
+"""Unit test to register raster maps with absolute and relative
+   time using tgis.register_maps_in_space_time_dataset()
+
+(C) 2013 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Soeren Gebbert
+"""
+
+import grass.temporal as tgis
+import grass.gunittest
+import datetime
+import os
+
+class TestRegisterFunctions(grass.gunittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        """Initiate the temporal GIS and set the region
+        """
+        os.putenv("GRASS_OVERWRITE", "1")
+        # Use always the current mapset as temporal database
+        cls.runModule("g.gisenv", set="TGIS_USE_CURRENT_MAPSET=1")
+        tgis.init()
+        cls.use_temp_region()
+        cls.runModule('g.region', n=80.0, s=0.0, e=120.0, w=0.0,
+                      t=1.0, b=0.0, res=10.0)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region
+        """
+        cls.del_temp_region()
+
+    def setUp(self):
+        """Create the test maps and the space time raster datasets
+        """
+        self.runModule("r.mapcalc", overwrite=True, quiet=True,
+                       expression="register_map_1 = 1")
+        self.runModule("r.mapcalc", overwrite=True, quiet=True,
+                       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")
+        self.strds_rel = tgis.open_new_stds(name="register_test_rel", type="strds", temporaltype="relative",
+                                            title="Test strds", descr="Test strds", semantic="field")
+
+    def tearDown(self):
+        """Remove maps from temporal database
+        """
+        self.runModule("t.unregister", maps="register_map_1,register_map_2", quiet=True)
+        self.runModule("g.remove", flags='f', type="rast", name="register_map_1,register_map_2", quiet=True)
+        self.strds_abs.delete()
+        self.strds_rel.delete()
+
+    def test_absolute_time_strds_1(self):
+        """Test the registration of maps with absolute time in a
+           space time raster dataset
+        """
+        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(),
+                 maps="register_map_1,register_map_2",
+                 start="2001-01-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, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 2))
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+        self.strds_abs.select()
+        start, end = self.strds_abs.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+    def test_absolute_time_strds_2(self):
+        """Test the registration of maps with absolute time in a
+           space time raster dataset.
+           The timestamps are set using the C-Interface beforehand, so that the register function needs
+           to read the timetsamp from the map metadata.
+        """
+
+        ciface = tgis.get_tgis_c_library_interface()
+        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001")
+        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "2 Jan 2001/3 Jan 2001")
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(),
+                                                 maps="register_map_1,register_map_2")
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 2))
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+        self.strds_abs.select()
+        start, end = self.strds_abs.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+    def test_absolute_time_1(self):
+        """Test the registration of maps with absolute time
+        """
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+                 maps="register_map_1,register_map_2",
+                 start="2001-01-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, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 2))
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+
+    def test_absolute_time_2(self):
+        """Test the registration of maps with absolute time
+        """
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+                 maps="register_map_1,register_map_2",
+                 start="2001-01-01 10:30:01", increment="8 hours", interval=False)
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
+
+    def test_absolute_time_3(self):
+        """Test the registration of maps with absolute time.
+           The timestamps are set using the C-Interface beforehand, so that the register function needs
+           to read the timetsamp from the map metadata.
+        """
+
+        ciface = tgis.get_tgis_c_library_interface()
+        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001 10:30:01")
+        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1 Jan 2001 18:30:01")
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+                 maps="register_map_1,register_map_2")
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end = map.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
+
+    def test_relative_time_strds_1(self):
+        """Test the registration of maps with relative time in a
+           space time raster dataset
+        """
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(),
+                                                 maps="register_map_1,register_map_2", start=0,
+                                                 increment=1, unit="day", interval=True)
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 0)
+        self.assertEqual(end, 1)
+        self.assertEqual(unit, "day")
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1)
+        self.assertEqual(end, 2)
+        self.assertEqual(unit, "day")
+
+        self.strds_rel.select()
+        start, end, unit = self.strds_rel.get_relative_time()
+        self.assertEqual(start, 0)
+        self.assertEqual(end, 2)
+        self.assertEqual(unit, "day")
+
+    def test_relative_time_strds_2(self):
+        """Test the registration of maps with relative time in a
+           space time raster dataset. The timetsamps are set for the maps using the
+           C-interface before registration.
+        """
+        ciface = tgis.get_tgis_c_library_interface()
+        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
+        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(),
+                                                 maps="register_map_1,register_map_2")
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1000000)
+        self.assertEqual(end, 1500000)
+        self.assertEqual(unit, "seconds")
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1500000)
+        self.assertEqual(end, 2000000)
+        self.assertEqual(unit, "seconds")
+
+        self.strds_rel.select()
+        start, end, unit = self.strds_rel.get_relative_time()
+        self.assertEqual(start, 1000000)
+        self.assertEqual(end, 2000000)
+        self.assertEqual(unit, "seconds")
+
+    def test_relative_time_1(self):
+        """Test the registration of maps with relative time
+        """
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+                 maps="register_map_1,register_map_2",
+                 start=0, increment=1, unit="day", interval=True)
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 0)
+        self.assertEqual(end, 1)
+        self.assertEqual(unit, "day")
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1)
+        self.assertEqual(end, 2)
+        self.assertEqual(unit, "day")
+
+    def test_relative_time_2(self):
+        """Test the registration of maps with relative time
+        """
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+                 maps="register_map_1,register_map_2",
+                 start=1000000, increment=500000, unit="seconds", interval=True)
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1000000)
+        self.assertEqual(end, 1500000)
+        self.assertEqual(unit, "seconds")
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1500000)
+        self.assertEqual(end, 2000000)
+        self.assertEqual(unit, "seconds")
+
+    def test_relative_time_3(self):
+        """Test the registration of maps with relative time. The timetsamps are set beforhand using
+           the C-interface.
+        """
+        ciface = tgis.get_tgis_c_library_interface()
+        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
+        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,
+                 maps="register_map_1,register_map_2")
+
+        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1000000)
+        self.assertEqual(end, 1500000)
+        self.assertEqual(unit, "seconds")
+
+        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
+        map.select()
+        start, end, unit = map.get_relative_time()
+        self.assertEqual(start, 1500000)
+        self.assertEqual(end, 2000000)
+        self.assertEqual(unit, "seconds")
+
+if __name__ == '__main__':
+    grass.gunittest.test()

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra.py (from rev 62594, grass/trunk/lib/python/temporal/testsuite/unittests_temporal_algebra.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,354 @@
+"""
+(C) 2013 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Soeren Gebbert and Thomas Leppelt
+"""
+
+import grass.script
+import grass.temporal as tgis
+import grass.gunittest
+import datetime
+import os
+
+class TestTemporalAlgebra(grass.gunittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        """Initiate the temporal GIS and set the region
+        """
+        tgis.init(True) # Raise on error instead of exit(1)
+        cls.use_temp_region()
+        cls.runModule("g.region", n=80.0, s=0.0, e=120.0,
+                                       w=0.0, t=1.0, b=0.0, res=10.0)
+
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d1 = 8")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d2 = 9")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d3 = 10")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="singletmap = 99")
+
+
+        tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
+                                         title="A", descr="A", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
+                                         title="B", descr="B", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
+                                         title="C", descr="C", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="D", type="strds", temporaltype="absolute",
+                                         title="D", descr="D", semantic="field", overwrite=True)
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4",
+                                                 start="2001-01-01", increment="1 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
+                                                 start="2001-01-01", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
+                                                 start="2001-01-02", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d1,d2,d3",
+                                                 start="2001-01-03", increment="1 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,  maps="singletmap", 
+                                                start="2001-01-03", end="2001-01-04", interval=True)
+
+    def tearDown(self):
+        self.runModule("t.remove", inputs="R", quiet=True)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region
+        """
+        cls.runModule("t.remove", flags="rf", inputs="A,B,C,D", quiet=True)
+        cls.del_temp_region()
+
+    def test_temporal_select1(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A : A",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select2(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A : D",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select3(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A !: D",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 2) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select_operators1(self):
+        """Testing the temporal select operator. Including temporal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,during} C",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select_operators2(self):
+        """Testing the temporal select operator. Including temporal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,equal|during} C",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select_operators3(self):
+        """Testing the temporal select operator. Including temporal relations 
+            and negation operation. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {!:,during} C",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select_operators4(self):
+        """Testing the temporal select operator. Including temporal relations and 
+            temporal operators. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,during,d} C",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        for map_i in maplist:
+            start_map, end_map = map_i.get_absolute_time()
+            self.assertEqual(start_map, datetime.datetime(2001, 1, 2))
+            self.assertEqual(end_map, datetime.datetime(2001, 1, 4))
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_select_operators5(self):
+        """Testing the temporal select operator. Including temporal relations and 
+            temporal operators. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = C {:,contains} A",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        for map_i in maplist:
+            start_map, end_map = map_i.get_absolute_time()
+            self.assertEqual(start_map, datetime.datetime(2001, 1, 2))
+            self.assertEqual(end_map, datetime.datetime(2001, 1, 4))
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 7) 
+        self.assertEqual(D.metadata.get_max_max(), 7) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_extent1(self):
+        """Testing the temporal extent operators. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,during,r} C",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_extent2(self):
+        """Testing the temporal extent operators. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,during,d} C",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()    
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_extent3(self):
+        """Testing the temporal extent operators. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,during,u} C",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        for map_i in maplist:
+            start_map, end_map = map_i.get_absolute_time()
+            self.assertEqual(start_map, datetime.datetime(2001, 1, 2))
+            self.assertEqual(end_map, datetime.datetime(2001, 1, 4))            
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_hash1(self):
+        """Testing the hash function in conditional statement. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = if(A # D == 1, A)",  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_hash_operator1(self):
+        """Testing the hash operator function in conditional statement. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = if(A {#,during} C == 1, A)",  stdstype = 'strds', 
+                                       basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_hash_operator2(self):
+        """Testing the hash operator function in conditional statement. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = if({during}, C {#,contains} A == 2, A)",  
+                                                 stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+    
+    def test_tmap_function1(self):
+        """Testing the tmap function. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = tmap(singletmap)',  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 99) 
+        self.assertEqual(D.metadata.get_max_max(), 99) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_tmap_function2(self):
+        """Testing the tmap function. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = A : tmap(singletmap)',  stdstype = 'strds', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+if __name__ == '__main__':
+    grass.gunittest.test()

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra_grs.py (from rev 62635, grass/trunk/lib/python/temporal/testsuite/unittests_temporal_algebra_grs.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra_grs.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_algebra_grs.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,228 @@
+"""
+(C) 2013 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Soeren Gebbert and Thomas Leppelt
+"""
+
+import grass.script
+import grass.temporal as tgis
+import grass.gunittest
+import datetime
+import os
+
+class TestTemporalAlgebraGranularity(grass.gunittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        """Initiate the temporal GIS and set the region
+        """
+        tgis.init(True) # Raise on error instead of exit(1)
+        cls.use_temp_region()
+        cls.runModule("g.region", n=80.0, s=0.0, e=120.0,
+                                       w=0.0, t=1.0, b=0.0, res=10.0)
+
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a5 = 5")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a6 = 6")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 7")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 8")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 9")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d1 = 10")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d2 = 11")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d3 = 12")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="singletmap = 99")
+
+
+        tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
+                                         title="A", descr="A", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
+                                         title="B", descr="B", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
+                                         title="C", descr="C", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="D", type="strds", temporaltype="absolute",
+                                         title="D", descr="D", semantic="field", overwrite=True)
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4,a5,a6",
+                                                 start="2001-01-01", increment="1 month", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
+                                                 start="2001-01-01", increment="3 months", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
+                                                 start="2001-01-01", increment="1 year", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d1",
+                                                 start="2001-01-01", increment="31 days", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d2",
+                                                 start="2001-03-01", increment="31 days", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d3",
+                                                 start="2001-05-01", increment="31 days", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,  maps="singletmap", 
+                                                start="2001-01-03", end="2001-01-04", interval=True)
+
+    def tearDown(self):
+        pass
+        #self.runModule("t.remove", inputs="R", quiet=True)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region
+        """
+        #cls.runModule("t.remove", flags="rf", inputs="A,B,C,D", quiet=True)
+        cls.del_temp_region()
+
+    def test_common_granularity_1(self):
+        """Testing the common granularity function. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        expr = 'R = A : B'
+        ret = ta.setup_common_granularity(expression=expr)
+
+        self.assertEqual(ret, True)
+        self.assertEqual(ta.granularity, "1 months")
+
+        ta.count = 0
+        ta.stdstype = "strds"
+        ta.maptype = "rast"
+        ta.mapclass = tgis.RasterDataset
+
+        maplist = ta.check_stds("A")
+        self.assertEqual(len(maplist), 6)
+        maplist = ta.check_stds("B")
+        self.assertEqual(len(maplist), 6)
+        
+        ta.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 6) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+       
+    def test_common_granularity_2(self):
+        """Testing the common granularity function year to month samping. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        expr = 'R = A : C'
+        ret = ta.setup_common_granularity(expression=expr)
+        
+        ta.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 6) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+       
+
+    def test_common_granularity_3(self):
+        """Testing the common granularity function with gaps. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        expr = 'R = A : D'
+        ret = ta.setup_common_granularity(expression=expr)
+        
+        ta.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 3)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 5) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 6, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+       
+
+    def test_common_granularity_4(self):
+        """Testing the common granularity function year to month with gaps. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        expr = 'R = C : D'
+        ret = ta.setup_common_granularity(expression=expr)
+        
+        ta.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 3)
+        self.assertEqual(D.metadata.get_min_min(), 9) 
+        self.assertEqual(D.metadata.get_max_max(), 9) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 6, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+       
+    def test_common_granularity_4(self):
+        """Testing the common granularity function year to month with gaps. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        expr = 'R = C : D'
+        ret = ta.setup_common_granularity(expression=expr)
+        
+        ta.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 3)
+        self.assertEqual(D.metadata.get_min_min(), 9) 
+        self.assertEqual(D.metadata.get_max_max(), 9) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 6, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+       
+    def test_common_granularity_5(self):
+        """Testing the common granularity function year to month with gaps. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        expr = 'R = A : C : D'
+        ret = ta.setup_common_granularity(expression=expr)
+        
+        ta.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 3)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 5) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 6, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+         
+    def test_common_granularity_6(self):
+        """Testing the common granularity function year to month with gaps. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        expr = 'R = if(start_month(A) > 2, A : C : D)'
+        ret = ta.setup_common_granularity(expression=expr)
+        
+        ta.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 5) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 3, 1))
+        self.assertEqual(end, datetime.datetime(2001, 6, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+       
+
+
+if __name__ == '__main__':
+    grass.gunittest.test()

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_conditionals.py (from rev 62594, grass/trunk/lib/python/temporal/testsuite/unittests_temporal_conditionals.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_conditionals.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_conditionals.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,356 @@
+"""
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Thomas leppelt and Soeren Gebbert
+"""
+
+import grass.script
+import grass.temporal as tgis
+import grass.gunittest
+import datetime
+import os
+
+class TestTemporalConditionals(grass.gunittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        """Initiate the temporal GIS and set the region
+        """
+        tgis.init(True) # Raise on error instead of exit(1)
+        cls.use_temp_region()
+        cls.runModule("g.region", n=80.0, s=0.0, e=120.0,
+                                       w=0.0, t=1.0, b=0.0, res=10.0)
+
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d1 = 8")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d2 = 9")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d3 = 10")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="e1 = 11")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="e2 = 12")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="e3 = 13")
+        
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="singletmap = 99")
+
+        tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
+                                         title="A", descr="A", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
+                                         title="B", descr="B", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
+                                         title="C", descr="C", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="D", type="strds", temporaltype="absolute",
+                                         title="D", descr="D", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="E", type="strds", temporaltype="absolute",
+                                         title="E", descr="E", semantic="field", overwrite=True)
+                                         
+        tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4",
+                                                 start="2001-01-01", increment="1 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
+                                                 start="2001-01-01", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
+                                                 start="2001-01-02", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d1,d2,d3",
+                                                 start="2001-01-03", increment="1 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="E", maps="e1,e2,e3",
+                                                 start="2000-12-31", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,  maps="singletmap", 
+                                                start="2001-01-03", end="2001-01-04", interval=True)
+
+    def tearDown(self):
+        self.runModule("t.remove", inputs="R", quiet=True)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region
+        """
+        cls.runModule("t.remove", flags="rf", inputs="A,B,C,D,E", quiet=True)
+        cls.del_temp_region()
+
+    def test_temporal_condition_1(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(A) >= "2001-01-03", A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_condition_2(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(td(A) == 1, A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+    
+    def test_temporal_condition_3(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(td(A) == 1 || start_date(A) >= "2001-01-03", A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+    
+    def test_temporal_condition_4(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(A) >= "2001-01-03", A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_condition_5(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_day(A) <= 2, A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 2) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+    
+    def test_temporal_condition_6(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(td(A) == 1 {||,during} start_date(C) < "2001-01-02", A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_condition_7(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if({over},start_date(C) == "2001-01-02" {&&,contains} td(A) == 1, B)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 5) 
+        self.assertEqual(D.metadata.get_max_max(), 6) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_condition_8(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(B) <= "2001-01-01" {||,over,|} td(E) == 2, B)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 5) 
+        self.assertEqual(D.metadata.get_max_max(), 6) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_condition_9(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(B) <= "2001-01-01" {&&,over,&} td(E) == 2, B)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 5) 
+        self.assertEqual(D.metadata.get_max_max(), 5) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_condition_10(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(B) <= "2001-01-01" {||,over,|,r} td(E) == 2, E)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 3)
+        self.assertEqual(D.metadata.get_min_min(), 11) 
+        self.assertEqual(D.metadata.get_max_max(), 13) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2000, 12, 31))
+        self.assertEqual(end, datetime.datetime(2001, 1, 6))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+ 
+    def test_temporal_condition_11(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(B) <= "2001-01-01" {&&,over,r} td(E) == 2, E)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 11) 
+        self.assertEqual(D.metadata.get_max_max(), 11) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2000, 12, 31))
+        self.assertEqual(end, datetime.datetime(2001, 1, 2))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_condition_12(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(B) <= "2001-01-01" {&&,over,|,r} td(E) == 2, E)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 11) 
+        self.assertEqual(D.metadata.get_max_max(), 11) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2000, 12, 31))
+        self.assertEqual(end, datetime.datetime(2001, 1, 2))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+    
+    def test_temporal_conditional_13(self):
+        """Testing the hash operator function in conditional statement. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if({equal|during},td(B) == 2 {&&,contains} td(A) == 1, A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+ 
+    def test_temporal_condition_else_1(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(start_date(A) <= "2001-01-03", A, D)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 9) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+    
+    def test_temporal_condition_else_2(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if(td(D) == 1 && start_date(A) >= "2001-01-04", A, D)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 4) 
+        self.assertEqual(D.metadata.get_max_max(), 8) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_condition_else_3(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if({during},td(B) == 2 {&&,contains} start_date(D) >= "2001-01-04", A, D)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 8) 
+        self.assertEqual(D.metadata.get_max_max(), 9) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_condition_else_4(self):
+        """Testing the temporal select operator with equal relations. """
+        ta = tgis.TemporalAlgebraParser(run = True, debug = True)
+        ta.parse(expression='R = if({equal|over},start_date(B) <= "2001-01-01" {&&,over,|,r} td(E) == 2, E, B)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        for map in D.get_registered_maps_as_objects():
+            print(map.get_map_id())
+        self.assertEqual(D.metadata.get_number_of_maps(), 3)
+        self.assertEqual(D.metadata.get_min_min(), 5) 
+        self.assertEqual(D.metadata.get_max_max(), 11) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2000, 12, 31))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+if __name__ == '__main__':
+    grass.gunittest.test()
+
+
+

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py	2014-07-04 17:54:55 UTC (rev 61158)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster3d_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,43 +1,51 @@
-"""!Unit test to register raster maps with absolute and relative
-   time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
+"""
+(C) 2014 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert and Thomas Leppelt
 """
 
+
 import grass.script
 import grass.temporal as tgis
-import unittest
+import grass.gunittest as gunittest
 import datetime
 import os
 
-class TestRegisterFunctions(unittest.TestCase):
+class TestTemporalRaster3dAlgebra(gunittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
-        """!Initiate the temporal GIS and set the region
+        """Initiate the temporal GIS and set the region
         """
         tgis.init(True) # Raise on error instead of exit(1)
-        grass.script.use_temp_region()
+        cls.use_temp_region()
         ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
                                        w=0.0, t=100.0, b=0.0, res=10.0)
 
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+        cls.runModule("r3.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+        cls.runModule("r3.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+        cls.runModule("r3.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+        cls.runModule("r3.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
 
-
         tgis.open_new_stds(name="A", type="str3ds", temporaltype="absolute",
                                          title="A", descr="A", semantic="field", overwrite=True)
 
         tgis.register_maps_in_space_time_dataset(type="rast3d", name="A", maps="a1,a2,a3,a4",
                                                  start="2001-01-01", increment="1 day", interval=True)
 
+    def tearDown(self):
+        self.runModule("t.remove", type="str3ds", flags="rf", inputs="D", quiet=True)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region
+        """
+        cls.runModule("t.remove", type="str3ds", flags="rf", inputs="A", quiet=True)
+        cls.del_temp_region()
+
     def test_temporal_neighbors_1(self):
         """Simple temporal neighborhood computation test"""
         tra = tgis.TemporalRaster3DAlgebraParser(run = True, debug = True)
@@ -68,17 +76,8 @@
         self.assertEqual(start, datetime.datetime(2001, 1, 2))
         self.assertEqual(end, datetime.datetime(2001, 1, 4))
 
-    def tearDown(self):
-        ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="D", quiet=True)
-
-    @classmethod
-    def tearDownClass(cls):
-        """!Remove the temporary region
-        """
-        ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="A", quiet=True)
-        grass.script.del_temp_region()
-
 if __name__ == '__main__':
-    unittest.main()
+    grass.gunittest.test()
 
 
+

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py	2014-07-04 17:54:55 UTC (rev 61158)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,64 +1,98 @@
-"""!Unit test to register raster maps with absolute and relative
-   time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
+"""
+(C) 2014 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert and Thomas Leppelt
 """
 
+import datetime
+import os
 import grass.script
 import grass.temporal as tgis
-import unittest
-import datetime
-import os
+import grass.gunittest as gunittest
 
-class TestRegisterFunctions(unittest.TestCase):
+class TestTemporalRasterAlgebra(gunittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
-        """!Initiate the temporal GIS and set the region
+        """Initiate the temporal GIS and set the region
         """
         tgis.init(True) # Raise on error instead of exit(1)
-        grass.script.use_temp_region()
-        ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
+        cls.use_temp_region()
+        cls.runModule("g.region", n=80.0, s=0.0, e=120.0,
                                        w=0.0, t=1.0, b=0.0, res=10.0)
 
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d1 = 8")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d2 = 9")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d3 = 10")        
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="singletmap = 99")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="singlemap = 100")
 
-
         tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
                                          title="A", descr="A", semantic="field", overwrite=True)
         tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
                                          title="B", descr="B", semantic="field", overwrite=True)
         tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
                                          title="B", descr="C", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="D", type="strds", temporaltype="absolute",
+                                         title="D", descr="D", semantic="field", overwrite=True)
 
         tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4",
                                                  start="2001-01-01", increment="1 day", interval=True)
         tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
                                                  start="2001-01-01", increment="2 day", interval=True)
-
         tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
                                                  start="2001-01-02", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d1,d2,d3",
+                                                 start="2001-01-03", increment="1 day", interval=True)                                                 
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,  maps="singletmap", 
+                                                start="2001-01-03", end="2001-01-04", interval=True)
+        
+    def tearDown(self):
+        self.runModule("t.remove", flags="rf", inputs="R", quiet=True)
 
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region 
+        """
+        cls.runModule("t.remove", flags="rf", inputs="A,B,C,D", quiet=True)
+        cls.runModule("t.unregister", maps="singletmap", quiet=True)
+        cls.del_temp_region()
 
+    def test_temporal_extent1(self):
+        """Testing the temporal extent operators. """
+        ta = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,during,r} C",   basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 3) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
     def test_temporal_conditional_time_dimension_bug(self):
         """Testing the conditional time dimension bug, that uses the time 
             dimension of the conditional statement instead the time dimension 
             of the then/else statement."""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = if({contains}, B == 5,  A - 1,  A + 1)", basename="d", overwrite=True)
+        tra.parse(expression="R = if({contains}, B == 5,  A - 1,  A + 1)", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 0) # 1 - 1
@@ -72,9 +106,9 @@
     def test_simple_arith_hash_1(self):
         """Simple arithmetic test including the hash operator"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A + A{equal,=#}A', basename="d", overwrite=True)
+        tra.parse(expression='R = A + (A {#, equal,l} A)', basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 2)
@@ -87,9 +121,9 @@
     def test_simple_arith_td_1(self):
         """Simple arithmetic test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A + td(A)', basename="d", overwrite=True)
+        tra.parse(expression='R = A + td(A)', basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 2)
@@ -101,9 +135,9 @@
     def test_simple_arith_td_2(self):
         """Simple arithmetic test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A / td(A)', basename="d", overwrite=True)
+        tra.parse(expression='R = A / td(A)', basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 1)
@@ -115,9 +149,9 @@
     def test_simple_arith_td_3(self):
         """Simple arithmetic test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A {equal,+} td(A)', basename="d", overwrite=True)
+        tra.parse(expression='R = A {+,equal} td(A)', basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 2)
@@ -130,9 +164,9 @@
     def test_simple_arith_td_4(self):
         """Simple arithmetic test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A {equal,/} td(A)', basename="d", overwrite=True)
+        tra.parse(expression='R = A {/, equal} td(A)', basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 1)
@@ -145,9 +179,9 @@
     def test_simple_arith_if_1(self):
         """Simple arithmetic test with if condition"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = if({equal}, start_date() >= "2001-01-02", A + A)', basename="d", overwrite=True)
+        tra.parse(expression='R = if({equal}, start_date(A) >= "2001-01-02", A + A)', basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 3)
         self.assertEqual(D.metadata.get_min_min(), 4)
@@ -159,9 +193,9 @@
     def test_simple_arith_if_2(self):
         """Simple arithmetic test with if condition"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = if({equal}, A#A == 1, A - A)', basename="d", overwrite=True)
+        tra.parse(expression='R = if({equal}, A#A == 1, A - A)', basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 0)
@@ -173,10 +207,10 @@
     def test_complex_arith_if_1(self):
         """Complex arithmetic test with if condition"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = if(start_date() < "2001-01-03" && A#A == 1, A{starts,=+}C, A{finishes,=+}C)', \
-                  basename="d", overwrite=True)
+        tra.parse(expression='R = if(start_date(A) < "2001-01-03" && A#A == 1, A{+, starts,l}C, A{+, finishes,l}C)', \
+                  basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 9)  # 2 + 7 a2 + c1
@@ -188,9 +222,9 @@
     def test_simple_arith_1(self):
         """Simple arithmetic test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {equal,*} A {equal,+} A", basename="d", overwrite=True)
+        tra.parse(expression="R = A {*, equal} A {+, equal} A", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 2)  # 1*1 + 1
@@ -202,17 +236,17 @@
     def test_simple_arith_2(self):
         """Simple arithmetic test that creates an empty strds"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {during,*} A {during,+} A", basename="d", overwrite=True)
-        D = tgis.open_old_stds("D", type="strds")
+        tra.parse(expression="R = A {*, during} A {+, during} A", basename="r", overwrite=True)
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 0)
 
     def test_simple_arith_3(self):
         """Simple arithmetic test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A / A + A*A/A", basename="d", overwrite=True)
+        tra.parse(expression="R = A / A + A*A/A", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 2) # 1/1 + 1*1/1
@@ -224,17 +258,17 @@
     def test_temporal_intersection_1(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {equal,&+} B", basename="d", overwrite=True)
-        D = tgis.open_old_stds("D", type="strds")
+        tra.parse(expression="R = A {+,equal,i} B", basename="r", overwrite=True)
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 0)
 
     def test_temporal_intersection_2(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {during,&+} B", basename="d", overwrite=True)
+        tra.parse(expression="R = A {+,during,i} B", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
@@ -246,9 +280,9 @@
     def test_temporal_intersection_3(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {starts,&+} B", basename="d", overwrite=True)
+        tra.parse(expression="R = A {+,starts,i} B", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
@@ -260,9 +294,9 @@
     def test_temporal_intersection_4(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {finishes,&+} B", basename="d", overwrite=True)
+        tra.parse(expression="R = A {+,finishes,intersect} B", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 7)  # 2 + 5
@@ -274,9 +308,9 @@
     def test_temporal_intersection_5(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {starts|finishes,&+} B", basename="d", overwrite=True)
+        tra.parse(expression="R = A {+,starts|finishes,i} B", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 6)  # 1 + 5
@@ -288,9 +322,9 @@
     def test_temporal_intersection_6(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = B {overlaps,|+} C", basename="d", overwrite=True)
+        tra.parse(expression="R = B {+,overlaps,u} C", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 1)
         self.assertEqual(D.metadata.get_min_min(), 12) # 5 + 7
@@ -302,9 +336,9 @@
     def test_temporal_intersection_7(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = B {overlapped,|+} C", basename="d", overwrite=True)
+        tra.parse(expression="R = B {+,overlapped,u} C", basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 1)
         self.assertEqual(D.metadata.get_min_min(), 13) # 6 + 7
@@ -316,10 +350,10 @@
     def test_temporal_intersection_8(self):
         """Simple temporal intersection test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A {during,=+} buff_t(C, "1 day") ',
-                  basename="d", overwrite=True)
+        tra.parse(expression='R = A {+,during,l} buff_t(C, "1 day") ',
+                  basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 4)
         self.assertEqual(D.metadata.get_min_min(), 8)  # 1 + 7  a1 + c1
@@ -331,10 +365,10 @@
     def test_temporal_neighbors_1(self):
         """Simple temporal neighborhood computation test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A[-1] + A[1]',
-                  basename="d", overwrite=True)
+        tra.parse(expression='R = A[-1] + A[1]',
+                  basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3
@@ -346,10 +380,10 @@
     def test_temporal_neighbors_2(self):
         """Simple temporal neighborhood computation test"""
         tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A[0,0,-1] + A[0,0,1]',
-                  basename="d", overwrite=True)
+        tra.parse(expression='R = A[0,0,-1] + A[0,0,1]',
+                  basename="r", overwrite=True)
 
-        D = tgis.open_old_stds("D", type="strds")
+        D = tgis.open_old_stds("R", type="strds")
         D.select()
         self.assertEqual(D.metadata.get_number_of_maps(), 2)
         self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3
@@ -358,17 +392,320 @@
         self.assertEqual(start, datetime.datetime(2001, 1, 2))
         self.assertEqual(end, datetime.datetime(2001, 1, 4))
 
-    def tearDown(self):
-        ret = grass.script.run_command("t.remove", flags="rf", input="D", quiet=True)
+    def test_tmap_function1(self):
+        """Testing the tmap function. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = tmap(singletmap)', basename="r", overwrite=True)
 
-    @classmethod
-    def tearDownClass(cls):
-        """!Remove the temporary region
-        """
-        ret = grass.script.run_command("t.remove", flags="rf", input="A,B,C", quiet=True)
-        grass.script.del_temp_region()
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 99) 
+        self.assertEqual(D.metadata.get_max_max(), 99) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
 
-if __name__ == '__main__':
-    unittest.main()
+    def test_tmap_function2(self):
+        """Testing the tmap function. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = tmap(singletmap) + 1', basename="r", overwrite=True)
 
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 100) 
+        self.assertEqual(D.metadata.get_max_max(), 100) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
 
+    def test_map_function1(self):
+        """Testing the map function. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = map(singlemap) + A', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 101) 
+        self.assertEqual(D.metadata.get_max_max(), 104) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_map_function2(self):
+        """Testing the map function. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R =  A * map(singlemap)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 100) 
+        self.assertEqual(D.metadata.get_max_max(), 400) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select(self):
+        """Testing the temporal select operator. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = A : A", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select(self):
+        """Testing the temporal select operator. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = A : D", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select_operators1(self):
+        """Testing the temporal select operator. Including temporal relations. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = A : D", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select_operators2(self):
+        """Testing the temporal select operator. Including temporal relations. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = A {!:,during} C", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_select_operators3(self):
+        """Testing the temporal select operator. Including temporal relations and 
+            different temporal operators (lr|+&)"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = A {:,during,d} B", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_select_operators4(self):
+        """Testing the temporal select operator. Including temporal relations and 
+            different temporal operators (lr|+&)"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = A {:,equal|during,r} C", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        maplist = D.get_registered_maps_as_objects()
+        for map_i in maplist:
+            start_map, end_map = map_i.get_absolute_time()
+            self.assertEqual(start_map, datetime.datetime(2001, 1, 2))
+            self.assertEqual(end_map, datetime.datetime(2001, 1, 4))
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 2)
+        self.assertEqual(D.metadata.get_max_max(), 3)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_hash_operator1(self):
+        """Testing the temporal hash operator in the raster algebra. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = if(A # D == 1, A)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 3) 
+        self.assertEqual(D.metadata.get_max_max(), 4) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_hash_operator2(self):
+        """Testing the temporal hash operator in the raster algebra. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = A # D", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 1) 
+        self.assertEqual(D.metadata.get_max_max(), 1) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_hash_operator3(self):
+        """Testing the temporal hash operator in the raster algebra. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = C {#,contains} A", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 2) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_hash_operator4(self):
+        """Testing the temporal hash operator in the raster algebra. """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = if({contains},A # D == 1, C {#,contains} A)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 1)
+        self.assertEqual(D.metadata.get_min_min(), 2) 
+        self.assertEqual(D.metadata.get_max_max(), 2) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+ 
+    def test_raster_arithmetic_relation_1(self):
+        """Arithmetic test with temporal intersection"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = B {+,contains,l} A ", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 8) 
+        self.assertEqual(D.metadata.get_max_max(), 13) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_raster_arithmetic_relation_2(self):
+        """Arithmetic test with temporal intersection"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = B {*,contains,l} A ", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 10) 
+        self.assertEqual(D.metadata.get_max_max(), 72) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_raster_arithmetic_relation_3(self):
+        """Arithmetic test with temporal intersection"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = B {+,contains,l} A ", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_min_min(), 8) 
+        self.assertEqual(D.metadata.get_max_max(), 13) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+    
+    def test_raster_arithmetic_relation_4(self):
+        """Arithmetic test with temporal intersection"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = B {+,contains,r} A ", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(),4)
+        self.assertEqual(D.metadata.get_min_min(), 8) 
+        self.assertEqual(D.metadata.get_max_max(), 13) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+    
+    def test_raster_arithmetic_relation_5(self):
+        """Complex arithmetic test with temporal intersection"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression="R = tmap(singletmap) {+,equal| precedes| follows,l} A + map(singlemap)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(),1)
+        self.assertEqual(D.metadata.get_min_min(), 208) 
+        self.assertEqual(D.metadata.get_max_max(), 208)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+if __name__ == '__main__':
+    gunittest.test()

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_algebra_grs.py (from rev 62635, grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster_algebra_grs.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_algebra_grs.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_algebra_grs.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,277 @@
+"""
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Soeren Gebbert and Thomas Leppelt
+"""
+
+import datetime
+import os
+import grass.script
+import grass.temporal as tgis
+import grass.gunittest as gunittest
+
+class TestTemporalRasterAlgebra(gunittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        """Initiate the temporal GIS and set the region
+        """
+        tgis.init(True) # Raise on error instead of exit(1)
+        cls.use_temp_region()
+        cls.runModule("g.region", n=80.0, s=0.0, e=120.0,
+                                       w=0.0, t=1.0, b=0.0, res=10.0)
+
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a5 = 5")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a6 = 6")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 7")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 8")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 9")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d1 = 10")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d2 = 11")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d3 = 12")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="singletmap = 99")
+
+        tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
+                                         title="A", descr="A", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
+                                         title="B", descr="B", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
+                                         title="C", descr="C", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="D", type="strds", temporaltype="absolute",
+                                         title="D", descr="D", semantic="field", overwrite=True)
+
+        tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4,a5,a6",
+                                                 start="2001-01-01", increment="1 month", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
+                                                 start="2001-01-01", increment="3 months", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
+                                                 start="2001-01-01", increment="1 year", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d1",
+                                                 start="2001-01-01", increment="5 days", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d2",
+                                                 start="2001-03-01", increment="5 days", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d3",
+                                                 start="2001-05-01", increment="5 days", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name=None,  maps="singletmap", 
+                                                start="2001-03-01", end="2001-04-01", interval=True)
+        
+    def tearDown(self):
+        return
+        self.runModule("t.remove", flags="rf", inputs="R", quiet=True)
+
+    @classmethod
+    def tearDownClass(cls):
+        return
+        """Remove the temporary region 
+        """
+        cls.runModule("t.remove", flags="rf", inputs="A,B,C,D", quiet=True)
+        cls.runModule("t.unregister", maps="singletmap", quiet=True)
+        cls.del_temp_region()
+
+    def test_1(self):
+        """Simple arithmetik test"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = "R = if(C == 9,  A - 1)"
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), 0) # 1 - 1
+        self.assertEqual(D.metadata.get_max_max(), 5) # 6 - 1
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+
+    def test_2(self):
+        """Simple arithmetik test"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = "R = if(D == 11,  A - 1, A + 1)"
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 15)
+        self.assertEqual(D.metadata.get_min_min(), 2) # 1 - 1
+        self.assertEqual(D.metadata.get_max_max(), 6) # 5 + 1
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 5, 6))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_simple_arith_hash_1(self):
+        """Simple arithmetic test including the hash operator"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = A + (A # A)', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), 2)
+        self.assertEqual(D.metadata.get_max_max(), 7)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+
+    def test_simple_arith_hash_2(self):
+        """Simple arithmetic test including the hash operator"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = (A + A) # A', basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), 1)
+        self.assertEqual(D.metadata.get_max_max(), 1)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+
+    def test_simple_arith_td_1(self):
+        """Simple arithmetic test"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = 'R = A + td(A:D)'
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 15)
+        self.assertEqual(D.metadata.get_min_min(), 2) # 1 - 1
+        self.assertEqual(D.metadata.get_max_max(), 6) # 5 + 1
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 5, 6))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_simple_arith_if_1(self):
+        """Simple arithmetic test with if condition"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = 'R = if(start_date(A) >= "2001-02-01", A + A)'
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 5)
+        self.assertEqual(D.metadata.get_min_min(), 4)
+        self.assertEqual(D.metadata.get_max_max(), 12)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 2, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+
+    def test_simple_arith_if_2(self):
+        """Simple arithmetic test with if condition"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = 'R = if(A#A == 1, A - A)'
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), 0)
+        self.assertEqual(D.metadata.get_max_max(), 0)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+
+    def test_complex_arith_if_1(self):
+        """Complex arithmetic test with if condition"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = 'R = if(start_date(A) < "2001-03-01" && A#A == 1, A+C, A-C)'
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), -6)  # 3 - 9
+        self.assertEqual(D.metadata.get_max_max(), 11) # 2 + 2
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+
+    def test_temporal_neighbors(self):
+        """Simple temporal neighborhood computation test"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr ='R = (A[0,0,-1] : D) + (A[0,0,1] : D)'
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 14)
+        self.assertEqual(D.metadata.get_min_min(), 2)  # 1 + 1
+        self.assertEqual(D.metadata.get_max_max(), 10) # 5 + 5
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 5, 6))
+    
+    def test_map(self):
+        """Test STDS + single map without timestamp"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = "R = A + map(singletmap)"
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(), 6)
+        self.assertEqual(D.metadata.get_min_min(), 100)  # 1 + 99
+        self.assertEqual(D.metadata.get_max_max(), 105) # 6 + 99
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 7, 1))
+        
+    def test_tmap_map(self):
+        """Test STDS + single map with and without timestamp"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        expr = "R = tmap(singletmap) + A + map(singletmap)"
+        ret = tra.setup_common_granularity(expression=expr,  lexer = tgis.TemporalRasterAlgebraLexer())
+        self.assertEqual(ret, True)
+        
+        tra.parse(expression=expr, basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="strds")
+
+        self.assertEqual(D.metadata.get_number_of_maps(),1)
+        self.assertEqual(D.metadata.get_min_min(), 201) 
+        self.assertEqual(D.metadata.get_max_max(), 201)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 3, 1))
+        self.assertEqual(end, datetime.datetime(2001, 4, 1))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 month')
+
+if __name__ == '__main__':
+    gunittest.test()

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_conditionals.py (from rev 62594, grass/trunk/lib/python/temporal/testsuite/unittests_temporal_raster_conditionals.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_conditionals.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_raster_conditionals.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,498 @@
+"""
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Thomas Leppelt
+"""
+
+import datetime
+import os
+import grass.script
+import grass.temporal as tgis
+import grass.gunittest as gunittest
+
+class TestTemporalRasterAlgebraConditionals(gunittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        """Initiate the temporal GIS and set the region
+        """
+        tgis.init(True) # Raise on error instead of exit(1)
+        cls.use_temp_region()
+        cls.runModule("g.region", n=80.0, s=0.0, e=120.0,
+                                       w=0.0, t=1.0, b=0.0, res=10.0)
+
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d1 = 8")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d2 = 9")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d3 = 10")
+        cls.runModule("r.mapcalc", overwrite=True, quiet=True, expression="d4 = 11")
+
+        tgis.open_new_stds(name="A", type="strds", temporaltype="absolute",
+                                         title="A", descr="A", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="B", type="strds", temporaltype="absolute",
+                                         title="B", descr="B", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="C", type="strds", temporaltype="absolute",
+                                         title="C", descr="C", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="D", type="strds", temporaltype="absolute",
+                                         title="D", descr="D", semantic="field", overwrite=True)
+ 
+        tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4",
+                                                 start="2001-01-01", increment="1 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
+                                                 start="2001-01-01", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
+                                                 start="2001-01-02", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="rast", name="D", maps="d1,d2,d3,d4",
+                                                 start="2001-01-03", increment="1 day", interval=True)
+        
+    def tearDown(self):
+        self.runModule("t.remove", flags="rf", inputs="R", quiet=True)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region
+        """
+        cls.runModule("t.remove", flags="rf", inputs="A,B,C,D", quiet=True)
+        cls.del_temp_region()
+
+    def test_temporal_conditional_time_dimension_bug(self):
+        """Testing the conditional time dimension bug, that uses the time 
+            dimension of the conditional statement instead the time dimension 
+            of the then/else statement."""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains}, B == 5,  A - 1,  A + 1)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0) # 1 - 1
+        self.assertEqual(R.metadata.get_max_max(), 5) # 4 + 1
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_temporal_conditional_1(self):
+        """Testing the conditional time dimension bug, that uses the time 
+            dimension of the conditional statement instead the time dimension 
+            of the then/else statement."""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(td(A) == 1,  D * 2, D)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 2)
+        self.assertEqual(R.metadata.get_min_min(), 16)
+        self.assertEqual(R.metadata.get_max_max(), 18)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1,  3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_temporal_conditional_relation_1(self):
+        """Testing the conditional time dimension bug, that uses the time 
+            dimension of the conditional statement instead the time dimension 
+            of the then/else statement."""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({during},exist(A),  B - 1,  B + 1)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 4)
+        self.assertEqual(R.metadata.get_max_max(), 5)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  False)
+        self.assertEqual(R.get_granularity(),  u'2 days')
+
+    def test_spatial_conditional_1(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 1 && A < 4 && isntnull(A), A)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 3)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_2(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 1 && A < 4 && isntnull(A), A, null())', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 2)
+        self.assertEqual(R.metadata.get_min_min(), 2)
+        self.assertEqual(R.metadata.get_max_max(), 3)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_3(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 1, A, D)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 2)
+        self.assertEqual(R.metadata.get_min_min(), 3)
+        self.assertEqual(R.metadata.get_max_max(), 4)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_4(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 0, A)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 1)
+        self.assertEqual(R.metadata.get_max_max(), 4)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_5(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(B > 5 {&&,contains,l} A < 5, B)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 2)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 6)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'2 days')
+    
+    def test_spatial_conditional_relation_1(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains},B > 5, D)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 2)
+        self.assertEqual(R.metadata.get_min_min(), 8)
+        self.assertEqual(R.metadata.get_max_max(), 9)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_relation_2(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains}, B <= 5, A, A * 2)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 1)
+        self.assertEqual(R.metadata.get_max_max(), 8)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_numeric_relation_1(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains}, B > 5, A, 10)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 3)
+        self.assertEqual(R.metadata.get_max_max(), 10)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+    
+    def test_spatial_conditional_numeric_relation_2(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains},B > 5, A + 2 / 4.0)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 4.5)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+    
+    def test_spatial_conditional_numeric_1(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 2, 0, A)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 2)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_numeric_2(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 2, A, 8)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 3)
+        self.assertEqual(R.metadata.get_max_max(), 8)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_numeric_3(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 2, 1, 0)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 1)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatial_conditional_numeric_4(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 2, null())', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 2)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 0)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 3))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_1(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A < 2 && start_date(A) < "2001-01-03", A)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 1)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_2(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A < 3 || start_date(A) < "2001-01-04", A + 1, A - 1)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(),2)
+        self.assertEqual(R.metadata.get_max_max(),4)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_relation_1(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains},B > 5 && start_day(B) < 3, D)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 2)
+        self.assertEqual(R.metadata.get_min_min(),0)
+        self.assertEqual(R.metadata.get_max_max(),0)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_relation_2(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains}, start_date(B) < "2001-01-03" || B <= 5, A, A * 2)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 1)
+        self.assertEqual(R.metadata.get_max_max(), 8)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_numeric_relation_1(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains}, start_date(B) >= "2001-01-03" && B > 5, A, 10)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 3)
+        self.assertEqual(R.metadata.get_max_max(), 10)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+    
+    def test_spatiotemporal_conditional_numeric_relation_2(self):
+        """Testing the spatial conditionals combined by AND/OR operators. 
+            Evaluation  """
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if({contains},td(B) == 2 && start_date(B) == "2001-01-03" && B > 5 , A + 2 / 4.0)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 4.5)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+ 
+    def test_spatiotemporal_conditional_numeric_1(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(start_date(A) < "2001-01-04" && A > 2, 0, A)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 4)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_numeric_2(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 2 || start_date(A) > "2001-01-01" && start_date(A) < "2001-01-04", A, 8)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 2)
+        self.assertEqual(R.metadata.get_max_max(), 8)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_numeric_3(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(start_date(A) < "2001-01-04" && A > 2, 1, 0)', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 4)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 1)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+    def test_spatiotemporal_conditional_numeric_4(self):
+        """Testing the spatial conditionals with numeric conclusions"""
+        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
+        tra.parse(expression='R = if(A > 2 || start_date(A) > "2001-01-01", null())', basename="r", overwrite=True)
+
+        R = tgis.open_old_stds("R", type="strds")
+        R.select()
+        self.assertEqual(R.metadata.get_number_of_maps(), 1)
+        self.assertEqual(R.metadata.get_min_min(), 0)
+        self.assertEqual(R.metadata.get_max_max(), 0)
+        start, end = R.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 2))
+        self.assertEqual( R.check_temporal_topology(),  True)
+        self.assertEqual(R.get_granularity(),  u'1 day')
+
+if __name__ == '__main__':
+    gunittest.test()

Copied: grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py (from rev 62594, grass/trunk/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py)
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/testsuite/unittests_temporal_vector_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -0,0 +1,209 @@
+"""
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Soeren Gebbert and Thomas Leppelt
+"""
+
+import datetime
+import os
+import grass.script
+import grass.temporal as tgis
+import grass.gunittest as gunittest
+
+class TestTemporalVectorAlgebra(gunittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        """Initiate the temporal GIS and set the region
+        """
+        tgis.init(True) # Raise on error instead of exit(1)
+        cls.use_temp_region()
+        cls.runModule("g.region", n=80.0, s=0.0, e=120.0,
+                                       w=0.0, t=1.0, b=0.0, res=10.0)
+
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=1,  output='a1')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=1,  output='a2')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=1,  output='a3')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=1,  output='a4')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=2,  output='b1')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=2,  output='b2')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=3,  output='c1')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=4,  output='d1')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=4,  output='d2')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=4,  output='d3')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=5,  output='singletmap')
+        cls.runModule("v.random", overwrite=True, quiet=True, n=20, seed=6,  output='singlemap')        
+
+        tgis.open_new_stds(name="A", type="stvds", temporaltype="absolute",
+                                         title="A", descr="A", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="B", type="stvds", temporaltype="absolute",
+                                         title="B", descr="B", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="C", type="stvds", temporaltype="absolute",
+                                         title="B", descr="C", semantic="field", overwrite=True)
+        tgis.open_new_stds(name="D", type="stvds", temporaltype="absolute",
+                                         title="D", descr="D", semantic="field", overwrite=True)
+
+        tgis.register_maps_in_space_time_dataset(type="vect", name="A", maps="a1,a2,a3,a4",
+                                                 start="2001-01-01", increment="1 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="vect", name="B", maps="b1,b2",
+                                                 start="2001-01-01", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="vect", name="C", maps="c1",
+                                                 start="2001-01-02", increment="2 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="vect", name="D", maps="d1,d2,d3",
+                                                 start="2001-01-03", increment="1 day", interval=True)
+        tgis.register_maps_in_space_time_dataset(type="vect", name=None,  maps="singletmap", 
+                                                start="2001-01-03", end="2001-01-04", interval=True)
+    
+    def tearDown(self):
+        self.runModule("t.remove", type="stvds", inputs="R", quiet=True)
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region 
+        """
+        cls.runModule("t.remove", flags="rf", inputs="A,B,C,D", type='stvds',  quiet=True)
+        cls.del_temp_region()
+
+    def test_temporal_select(self):
+        """Testing the temporal select operator. """
+        tva = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        tva.parse(expression="R = A : A", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_number_of_points(), 80) 
+        self.assertEqual(D.metadata.get_number_of_areas(), 0) 
+        self.assertEqual(D.metadata.get_number_of_centroids(), 0) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_extent1(self):
+        """Testing the temporal extent operators. """
+        ta = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        ta.parse(expression="R = A {:,during,r} C",  basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        D.print_info()
+        maplist = D.get_registered_maps_as_objects()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_select_operators(self):
+        """Testing the temporal select operator. Including temporal relations. """
+        tva = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        tva.parse(expression="R = A {:,during} C", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_number_of_points(), 40) 
+        self.assertEqual(D.metadata.get_number_of_areas(), 0) 
+        self.assertEqual(D.metadata.get_number_of_centroids(), 0) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_buff_operators_1(self):
+        """Testing the bufferoperator."""
+        tva = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        tva.parse(expression="R = buff_p(A,0.5)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_number_of_points(), 0) 
+        self.assertEqual(D.metadata.get_number_of_areas(), 80) 
+        self.assertEqual(D.metadata.get_number_of_centroids(), 80) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_buff_operators_2(self):
+        """Testing the bufferoperator."""
+        tva = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        tva.parse(expression="R = buff_a(buff_p(A,1),10)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_number_of_points(), 0) 
+        self.assertEqual(D.metadata.get_number_of_areas(), 20) 
+        self.assertEqual(D.metadata.get_number_of_centroids(), 20) 
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_overlay_operators_1(self):
+        """Testing the spatial overlay operator."""
+        tva = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        tva.parse(expression="R = buff_p(A,2) & buff_p(D,2)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_number_of_points(), 0)
+        self.assertEqual(D.metadata.get_number_of_areas(), 6)
+        self.assertEqual(D.metadata.get_number_of_centroids(), 6)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 3))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+    def test_temporal_overlay_operators_2(self):
+        """Testing the spatial overlay operator."""
+        tva = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        tva.parse(expression="R = buff_p(A,1.5) {&,during,r} buff_p(B,1.5)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 4)
+        self.assertEqual(D.metadata.get_number_of_points(), 0)
+        self.assertEqual(D.metadata.get_number_of_areas(), 8)
+        self.assertEqual(D.metadata.get_number_of_centroids(), 8)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 1))
+        self.assertEqual(end, datetime.datetime(2001, 1, 5))
+        self.assertEqual( D.check_temporal_topology(),  False)
+        self.assertEqual(D.get_granularity(),  u'2 days')
+
+    def test_temporal_overlay_operators_3(self):
+        """Testing the spatial overlay operator."""
+        tva = tgis.TemporalVectorAlgebraParser(run = True, debug = True)
+        tva.parse(expression="R = buff_p(A,2.5) {&,during,l} buff_p(C,2.5)", basename="r", overwrite=True)
+
+        D = tgis.open_old_stds("R", type="stvds")
+        D.select()
+        self.assertEqual(D.metadata.get_number_of_maps(), 2)
+        self.assertEqual(D.metadata.get_number_of_points(), 0)
+        self.assertEqual(D.metadata.get_number_of_areas(), 8)
+        self.assertEqual(D.metadata.get_number_of_centroids(), 8)
+        start, end = D.get_absolute_time()
+        self.assertEqual(start, datetime.datetime(2001, 1, 2))
+        self.assertEqual(end, datetime.datetime(2001, 1, 4))
+        self.assertEqual( D.check_temporal_topology(),  True)
+        self.assertEqual(D.get_granularity(),  u'1 day')
+
+if __name__ == '__main__':
+    gunittest.test()
+
+
+

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/unit_tests.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/unit_tests.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/unit_tests.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,27 +1,15 @@
-"""!@package grass.temporal
+"""
+Depricazed unittests
 
- at brief GRASS Python scripting module (temporal GIS functions)
-
-Temporal GIS unit tests
-
-Usage:
-
- at code
-import grass.temporal as tgis
-
-tgis.test_increment_datetime_by_string()
-...
- at endcode
-
 (C) 2008-2011 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 import copy
-from datetime import datetime, date, time, timedelta
+from datetime import datetime
 import grass.script.core as core
 from temporal_granularity import *
 from datetime_math import *
@@ -37,6 +25,7 @@
 
 ###############################################################################
 
+
 def test_increment_datetime_by_string():
 
     # First test
@@ -105,6 +94,7 @@
 
 ###############################################################################
 
+
 def test_adjust_datetime_to_granularity():
 
     # First test
@@ -221,6 +211,7 @@
 
 ###############################################################################
 
+
 def test_compute_datetime_delta():
 
     print "Test 1"
@@ -564,6 +555,7 @@
     if delta != 0:
         core.fatal("Compute datetime delta is wrong %s" % (delta))
 
+
 def test_compute_absolute_time_granularity():
 
     # First we test intervals
@@ -902,6 +894,7 @@
 
 ###############################################################################
 
+
 def test_spatial_extent_intersection():
     # Generate the extents
 
@@ -965,6 +958,7 @@
 
 ###############################################################################
 
+
 def test_spatial_relations():
     # Generate the extents
 
@@ -1320,7 +1314,6 @@
     print relation
     if relation != "meet":
         core.fatal("Wrong spatial relation: %s" % (relation))
- ###
 
     A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
     A.print_info()
@@ -1374,6 +1367,7 @@
 
 ###############################################################################
 
+
 def test_temporal_topology_builder():
     map_listA = []
 
@@ -1402,7 +1396,7 @@
         _map.print_topology_info()
         if _map.get_id() != map_listA[count].get_id():
             core.fatal("Error building temporal topology <%s> != <%s>" %
-                (_map.get_id(), map_listA[count].get_id()))
+                       (_map.get_id(), map_listA[count].get_id()))
         count += 1
 
     map_listB = []
@@ -1438,12 +1432,11 @@
 
     count = 0
     for _map in tb:
-        print "[%s]" % (_map.get_map_id
-        ())
+        print "[%s]" % (_map.get_map_id())
         _map.print_topology_shell_info()
         if _map.get_id() != map_listB[count].get_id():
             core.fatal("Error building temporal topology <%s> != <%s>" %
-                (_map.get_id(), map_listB[count].get_id()))
+                       (_map.get_id(), map_listB[count].get_id()))
         count += 1
 
     tb = SpatioTemporalTopologyBuilder()
@@ -1455,7 +1448,7 @@
         _map.print_topology_shell_info()
         if _map.get_id() != map_listA[count].get_id():
             core.fatal("Error building temporal topology <%s> != <%s>" %
-                (_map.get_id(), map_listA[count].get_id()))
+                       (_map.get_id(), map_listA[count].get_id()))
         count += 1
 
     count = 0
@@ -1480,6 +1473,7 @@
 
 ###############################################################################
 
+
 def test_map_list_sorting():
 
     map_list = []
@@ -1523,13 +1517,14 @@
 
 ###############################################################################
 
+
 def test_1d_rtree():
     """Testing the rtree ctypes wrapper"""
 
     tree = rtree.RTreeCreateTree(-1, 0, 1)
 
     for i in xrange(10):
-        
+
         rect = rtree.RTreeAllocRect(tree)
         rtree.RTreeSetRect1D(rect, tree, float(i - 2), float(i + 2))
         rtree.RTreeInsertRect(rect, i + 1, tree)
@@ -1540,7 +1535,7 @@
     list_ = gis.ilist()
 
     num = vector.RTreeSearch2(tree, rect, byref(list_))
-    
+
     rtree.RTreeFreeRect(rect)
 
     # print rectangle ids
@@ -1549,24 +1544,24 @@
         print "id", list_.value[i]
 
     rtree.RTreeDestroyTree(tree)
-    
+
 ###############################################################################
 
+
 def test_2d_rtree():
     """Testing the rtree ctypes wrapper"""
 
     tree = rtree.RTreeCreateTree(-1, 0, 2)
 
     for i in xrange(10):
-        
-        
+
         rect = rtree.RTreeAllocRect(tree)
 
-        rtree.RTreeSetRect2D(rect, tree, 
-                              float(i - 2), float(i + 2), 
-                              float(i - 2), float(i + 2))
+        rtree.RTreeSetRect2D(rect, tree,
+                             float(i - 2), float(i + 2),
+                             float(i - 2), float(i + 2))
         rtree.RTreeInsertRect(rect, i + 1, tree)
-    
+
     rect = rtree.RTreeAllocRect(tree)
     rtree.RTreeSetRect2D(rect, tree, 2.0, 7.0, 2.0, 7.0)
 
@@ -1581,21 +1576,22 @@
         print "id", list_.value[i]
 
     rtree.RTreeDestroyTree(tree)
-    
+
 ###############################################################################
 
+
 def test_3d_rtree():
     """Testing the rtree ctypes wrapper"""
 
     tree = rtree.RTreeCreateTree(-1, 0, 3)
 
     for i in xrange(10):
-        
+
         rect = rtree.RTreeAllocRect(tree)
-        rtree.RTreeSetRect3D(rect, tree, 
-                              float(i - 2), float(i + 2), 
-                              float(i - 2), float(i + 2), 
-                              float(i - 2), float(i + 2))
+        rtree.RTreeSetRect3D(rect, tree,
+                             float(i - 2), float(i + 2),
+                             float(i - 2), float(i + 2),
+                             float(i - 2), float(i + 2))
         rtree.RTreeInsertRect(rect, i + 1, tree)
         print i + 1
         rtree.RTreePrintRect(rect, 1, tree)
@@ -1604,7 +1600,7 @@
     rtree.RTreeSetRect3D(rect, tree, 2.0, 7.0, 2.0, 7.0, 2.0, 7.0)
     print "Select"
     rtree.RTreePrintRect(rect, 1, tree)
-        
+
     list_ = gis.ilist()
 
     num = vector.RTreeSearch2(tree, rect, byref(list_))
@@ -1614,31 +1610,32 @@
     print "Number of overlapping rectangles", num
     for i in xrange(list_.n_values):
         print "id", list_.value[i]
-        
+
     rtree.RTreeDestroyTree(tree)
 
 ###############################################################################
 
+
 def test_4d_rtree():
     """Testing the rtree ctypes wrapper"""
 
     tree = rtree.RTreeCreateTree(-1, 0, 4)
 
     for i in xrange(10):
-        
+
         # Allocate the boundary
         rect = rtree.RTreeAllocRect(tree)
-        rtree.RTreeSetRect4D(rect, tree, 
-                              float(i - 2), float(i + 2), 
-                              float(i - 2), float(i + 2), 
-                              float(i - 2), float(i + 2), 
-                              float(i - 2), float(i + 2))
+        rtree.RTreeSetRect4D(rect, tree,
+                             float(i - 2), float(i + 2),
+                             float(i - 2), float(i + 2),
+                             float(i - 2), float(i + 2),
+                             float(i - 2), float(i + 2))
         rtree.RTreeInsertRect(rect, i + 1, tree)
 
     rect = rtree.RTreeAllocRect(tree)
-    rtree.RTreeSetRect4D(rect, tree, 2.0, 7.0, 2.0, 
-                          7.0, 2.0, 7.0, 2.0, 7.0)
-    
+    rtree.RTreeSetRect4D(rect, tree, 2.0, 7.0, 2.0,
+                         7.0, 2.0, 7.0, 2.0, 7.0)
+
     list_ = gis.ilist()
 
     num = vector.RTreeSearch2(tree, rect, byref(list_))
@@ -1649,7 +1646,7 @@
     print "Number of overlapping rectangles", num
     for i in xrange(list_.n_values):
         print "id", list_.value[i]
-        
+
     rtree.RTreeDestroyTree(tree)
 
 ###############################################################################

Deleted: grass/branches/releasebranch_7_0/lib/python/temporal/unittests_register.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/unittests_register.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/unittests_register.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,314 +0,0 @@
-"""!Unit test to register raster maps with absolute and relative 
-   time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-import grass.script as grass
-import grass.temporal as tgis
-import unittest
-import datetime
-
-class TestRegisterFunctions(unittest.TestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        """!Initiate the temporal GIS and set the region
-        """
-        tgis.init()
-        grass.overwrite = True
-        grass.use_temp_region()
-        ret = grass.run_command("g.region", n=80.0, s=0.0, e=120.0, 
-                                w=0.0, t=1.0, b=0.0, res=10.0)
-
-    def setUp(self):
-        """!Create the test maps and the space time raster datasets
-        """
-        ret = 0
-        ret += grass.run_command("r.mapcalc", overwrite=True, quiet=True, 
-                          expression="register_map_1 = 1")
-        ret += grass.run_command("r.mapcalc", overwrite=True, quiet=True, 
-                          expression="register_map_2 = 2")
-        self.assertEqual(ret, 0)
-        
-        
-        self.strds_abs = tgis.open_new_space_time_dataset(name="register_test_abs", type="strds", temporaltype="absolute", 
-                                            title="Test strds", descr="Test strds", semantic="field")
-        self.strds_rel = tgis.open_new_space_time_dataset(name="register_test_rel", type="strds", temporaltype="relative", 
-                                            title="Test strds", descr="Test strds", semantic="field")
-
-    def test_absolute_time_strds_1(self):
-        """!Test the registration of maps with absolute time in a
-           space time raster dataset
-        """
-        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(), 
-                 maps="register_map_1,register_map_2",
-                 start="2001-01-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, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 2))
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
-        self.strds_abs.select()
-        start, end = self.strds_abs.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
-        self.strds_abs.print_info()
-
-    def test_absolute_time_strds_2(self):
-        """!Test the registration of maps with absolute time in a
-           space time raster dataset.
-           The timestamps are set using the C-Interface beforehand, so that the register function needs
-           to read the timetsamp from the map metadata.
-        """
-
-        ciface = tgis.get_tgis_c_library_interface()
-        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001")
-        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "2 Jan 2001/3 Jan 2001")
-
-        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_abs.get_name(), 
-                                                 maps="register_map_1,register_map_2")
-
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 2))
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
-        self.strds_abs.select()
-        start, end = self.strds_abs.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
-        self.strds_abs.print_info()
-
-    def test_absolute_time_1(self):
-        """!Test the registration of maps with absolute time
-        """
-        tgis.register_maps_in_space_time_dataset(type="rast", name=None, 
-                 maps="register_map_1,register_map_2",
-                 start="2001-01-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, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 2))
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 3))
-
-    def test_absolute_time_2(self):
-        """!Test the registration of maps with absolute time
-        """
-        tgis.register_maps_in_space_time_dataset(type="rast", name=None, 
-                 maps="register_map_1,register_map_2",
-                 start="2001-01-01 10:30:01", increment="8 hours", interval=False)
-
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
-
-    def test_absolute_time_3(self):
-        """!Test the registration of maps with absolute time. 
-           The timestamps are set using the C-Interface beforehand, so that the register function needs
-           to read the timetsamp from the map metadata.
-        """
-                 
-        ciface = tgis.get_tgis_c_library_interface()
-        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 Jan 2001 10:30:01")
-        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1 Jan 2001 18:30:01")
-
-        tgis.register_maps_in_space_time_dataset(type="rast", name=None, 
-                 maps="register_map_1,register_map_2")
-                 
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end = map.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))
-
-    def test_relative_time_strds_1(self):
-        """!Test the registration of maps with relative time in a
-           space time raster dataset
-        """
-
-        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(), 
-                                                 maps="register_map_1,register_map_2", start=0, 
-                                                 increment=1, unit="day", interval=True)
-
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 0)
-        self.assertEqual(end, 1)
-        self.assertEqual(unit, "day")
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1)
-        self.assertEqual(end, 2)
-        self.assertEqual(unit, "day")
-
-        self.strds_rel.select()
-        start, end, unit = self.strds_rel.get_relative_time()
-        self.assertEqual(start, 0)
-        self.assertEqual(end, 2)
-        self.assertEqual(unit, "day")
-        
-        self.strds_rel.print_info()
-
-    def test_relative_time_strds_2(self):
-        """!Test the registration of maps with relative time in a
-           space time raster dataset. The timetsamps are set for the maps using the 
-           C-interface before registration.
-        """
-        ciface = tgis.get_tgis_c_library_interface()
-        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
-        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
-
-        tgis.register_maps_in_space_time_dataset(type="rast", name=self.strds_rel.get_name(), 
-                                                 maps="register_map_1,register_map_2")
-
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1000000)
-        self.assertEqual(end, 1500000)
-        self.assertEqual(unit, "seconds")
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1500000)
-        self.assertEqual(end, 2000000)
-        self.assertEqual(unit, "seconds")
-
-        self.strds_rel.select()
-        start, end, unit = self.strds_rel.get_relative_time()
-        self.assertEqual(start, 1000000)
-        self.assertEqual(end, 2000000)
-        self.assertEqual(unit, "seconds")
-        
-        self.strds_rel.print_info()
-        
-    def test_relative_time_1(self):
-        """!Test the registration of maps with relative time
-        """
-        tgis.register_maps_in_space_time_dataset(type="rast", name=None, 
-                 maps="register_map_1,register_map_2",
-                 start=0, increment=1, unit="day", interval=True)
-
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 0)
-        self.assertEqual(end, 1)
-        self.assertEqual(unit, "day")
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1)
-        self.assertEqual(end, 2)
-        self.assertEqual(unit, "day")
-
-    def test_relative_time_2(self):
-        """!Test the registration of maps with relative time
-        """
-        tgis.register_maps_in_space_time_dataset(type="rast", name=None, 
-                 maps="register_map_1,register_map_2",
-                 start=1000000, increment=500000, unit="seconds", interval=True)
-
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1000000)
-        self.assertEqual(end, 1500000)
-        self.assertEqual(unit, "seconds")
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1500000)
-        self.assertEqual(end, 2000000)
-        self.assertEqual(unit, "seconds")
-
-    def test_relative_time_3(self):
-        """!Test the registration of maps with relative time. The timetsamps are set beforhand using
-           the C-interface.
-        """
-        ciface = tgis.get_tgis_c_library_interface()
-        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1000000 seconds/1500000 seconds")
-        ciface.write_raster_timestamp("register_map_2", tgis.get_current_mapset(), "1500000 seconds/2000000 seconds")
-        
-        tgis.register_maps_in_space_time_dataset(type="rast", name=None, 
-                 maps="register_map_1,register_map_2")
-
-        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1000000)
-        self.assertEqual(end, 1500000)
-        self.assertEqual(unit, "seconds")
-
-        map = tgis.RasterDataset("register_map_2@" + tgis.get_current_mapset())
-        map.select()
-        start, end, unit = map.get_relative_time()
-        self.assertEqual(start, 1500000)
-        self.assertEqual(end, 2000000)
-        self.assertEqual(unit, "seconds")
-
-    def tearDown(self):
-        """!Remove maps from temporal database
-        """
-        ret = grass.run_command("t.unregister", maps="register_map_1,register_map_2", quiet=True)
-        ret = grass.run_command("g.remove", type="rast", name="register_map_1,register_map_2", quiet=True, flags="f")
-        self.assertEqual(ret, 0)
-        self.strds_abs.delete()
-        self.strds_rel.delete()
-
-    @classmethod
-    def tearDownClass(cls):
-        """!Remove the temporary region
-        """
-        grass.del_temp_region()
-
-if __name__ == '__main__':
-    unittest.main()
-
-

Deleted: grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster3d_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster3d_algebra.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster3d_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,84 +0,0 @@
-"""!Unit test to register raster maps with absolute and relative
-   time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-import grass.script
-import grass.temporal as tgis
-import unittest
-import datetime
-import os
-
-class TestRegisterFunctions(unittest.TestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        """!Initiate the temporal GIS and set the region
-        """
-        tgis.init(True) # Raise on error instead of exit(1)
-        grass.script.use_temp_region()
-        ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
-                                       w=0.0, t=100.0, b=0.0, res=10.0)
-
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
-        ret += grass.script.run_command("r3.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
-
-
-        tgis.open_new_space_time_dataset(name="A", type="str3ds", temporaltype="absolute",
-                                         title="A", descr="A", semantic="field", overwrite=True)
-
-        tgis.register_maps_in_space_time_dataset(type="rast3d", name="A", maps="a1,a2,a3,a4",
-                                                 start="2001-01-01", increment="1 day", interval=True)
-
-    def test_temporal_neighbors_1(self):
-        """Simple temporal neighborhood computation test"""
-        tra = tgis.TemporalRaster3DAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A[-1] + A[1]',
-                  basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="str3ds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 2)
-        self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3
-        self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
-    def test_temporal_neighbors_2(self):
-        """Simple temporal neighborhood computation test"""
-        tra = tgis.TemporalRaster3DAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A[0,0,0,-1] + A[0,0,0,1]',
-                  basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="str3ds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 2)
-        self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3
-        self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
-    def tearDown(self):
-        ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="D", quiet=True)
-
-    @classmethod
-    def tearDownClass(cls):
-        """!Remove the temporary region
-        """
-        ret = grass.script.run_command("t.remove", type="str3ds", flags="rf", input="A", quiet=True)
-        grass.script.del_temp_region()
-
-if __name__ == '__main__':
-    unittest.main()
-
-

Deleted: grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/unittests_temporal_raster_algebra.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,374 +0,0 @@
-"""!Unit test to register raster maps with absolute and relative
-   time using tgis.register_maps_in_space_time_dataset()
-
-(C) 2013 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-import grass.script
-import grass.temporal as tgis
-import unittest
-import datetime
-import os
-
-class TestRegisterFunctions(unittest.TestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        """!Initiate the temporal GIS and set the region
-        """
-        tgis.init(True) # Raise on error instead of exit(1)
-        grass.script.use_temp_region()
-        ret = grass.script.run_command("g.region", n=80.0, s=0.0, e=120.0,
-                                       w=0.0, t=1.0, b=0.0, res=10.0)
-
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a1 = 1")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a2 = 2")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a3 = 3")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="a4 = 4")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b1 = 5")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="b2 = 6")
-        ret += grass.script.run_command("r.mapcalc", overwrite=True, quiet=True, expression="c1 = 7")
-
-
-        tgis.open_new_space_time_dataset(name="A", type="strds", temporaltype="absolute",
-                                         title="A", descr="A", semantic="field", overwrite=True)
-        tgis.open_new_space_time_dataset(name="B", type="strds", temporaltype="absolute",
-                                         title="B", descr="B", semantic="field", overwrite=True)
-        tgis.open_new_space_time_dataset(name="C", type="strds", temporaltype="absolute",
-                                         title="B", descr="C", semantic="field", overwrite=True)
-
-        tgis.register_maps_in_space_time_dataset(type="rast", name="A", maps="a1,a2,a3,a4",
-                                                 start="2001-01-01", increment="1 day", interval=True)
-        tgis.register_maps_in_space_time_dataset(type="rast", name="B", maps="b1,b2",
-                                                 start="2001-01-01", increment="2 day", interval=True)
-
-        tgis.register_maps_in_space_time_dataset(type="rast", name="C", maps="c1",
-                                                 start="2001-01-02", increment="2 day", interval=True)
-
-
-    def test_temporal_conditional_time_dimension_bug(self):
-        """Testing the conditional time dimension bug, that uses the time 
-            dimension of the conditional statement instead the time dimension 
-            of the then/else statement."""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = if({contains}, B == 5,  A - 1,  A + 1)", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 0) # 1 - 1
-        self.assertEqual(D.metadata.get_max_max(), 5) # 4 + 1
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-        self.assertEqual( D.check_temporal_topology(),  True)
-        self.assertEqual(D.get_granularity(),  u'1 day')
-
-    def test_simple_arith_hash_1(self):
-        """Simple arithmetic test including the hash operator"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A + A{equal,=#}A', basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 2)
-        self.assertEqual(D.metadata.get_max_max(), 5)
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-
-    def test_simple_arith_td_1(self):
-        """Simple arithmetic test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A + td(A)', basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 2)
-        self.assertEqual(D.metadata.get_max_max(), 5)
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_simple_arith_td_2(self):
-        """Simple arithmetic test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A / td(A)', basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 1)
-        self.assertEqual(D.metadata.get_max_max(), 4)
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_simple_arith_td_3(self):
-        """Simple arithmetic test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A {equal,+} td(A)', basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 2)
-        self.assertEqual(D.metadata.get_max_max(), 5)
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-
-    def test_simple_arith_td_4(self):
-        """Simple arithmetic test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A {equal,/} td(A)', basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 1)
-        self.assertEqual(D.metadata.get_max_max(), 4)
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-
-    def test_simple_arith_if_1(self):
-        """Simple arithmetic test with if condition"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = if({equal}, start_date() >= "2001-01-02", A + A)', basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 3)
-        self.assertEqual(D.metadata.get_min_min(), 4)
-        self.assertEqual(D.metadata.get_max_max(), 8)
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_simple_arith_if_2(self):
-        """Simple arithmetic test with if condition"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = if({equal}, A#A == 1, A - A)', basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 0)
-        self.assertEqual(D.metadata.get_max_max(), 0)
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_complex_arith_if_1(self):
-        """Complex arithmetic test with if condition"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = if(start_date() < "2001-01-03" && A#A == 1, A{starts,=+}C, A{finishes,=+}C)', \
-                  basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 2)
-        self.assertEqual(D.metadata.get_min_min(), 9)  # 2 + 7 a2 + c1
-        self.assertEqual(D.metadata.get_max_max(), 10) # 3 + 7 a3 + c1
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
-    def test_simple_arith_1(self):
-        """Simple arithmetic test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {equal,*} A {equal,+} A", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 2)  # 1*1 + 1
-        self.assertEqual(D.metadata.get_max_max(), 20) # 4*4 + 4
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_simple_arith_2(self):
-        """Simple arithmetic test that creates an empty strds"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {during,*} A {during,+} A", basename="d", overwrite=True)
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 0)
-
-    def test_simple_arith_3(self):
-        """Simple arithmetic test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A / A + A*A/A", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 2) # 1/1 + 1*1/1
-        self.assertEqual(D.metadata.get_max_max(), 5) # 4/4 + 4*4/4
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-        
-    def test_temporal_intersection_1(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {equal,&+} B", basename="d", overwrite=True)
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 0)
-
-    def test_temporal_intersection_2(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {during,&+} B", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
-        self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_temporal_intersection_3(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {starts,&+} B", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 2)
-        self.assertEqual(D.metadata.get_min_min(), 6) # 1 + 5
-        self.assertEqual(D.metadata.get_max_max(), 9) # 3 + 6
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
-    def test_temporal_intersection_4(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {finishes,&+} B", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 2)
-        self.assertEqual(D.metadata.get_min_min(), 7)  # 2 + 5
-        self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_temporal_intersection_5(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = A {starts|finishes,&+} B", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 6)  # 1 + 5
-        self.assertEqual(D.metadata.get_max_max(), 10) # 4 + 6
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_temporal_intersection_6(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = B {overlaps,|+} C", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 1)
-        self.assertEqual(D.metadata.get_min_min(), 12) # 5 + 7
-        self.assertEqual(D.metadata.get_max_max(), 12) # 5 + 7
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
-    def test_temporal_intersection_7(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression="D = B {overlapped,|+} C", basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 1)
-        self.assertEqual(D.metadata.get_min_min(), 13) # 6 + 7
-        self.assertEqual(D.metadata.get_max_max(), 13) # 6 + 7
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_temporal_intersection_8(self):
-        """Simple temporal intersection test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A {during,=+} buff_t(C, "1 day") ',
-                  basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 4)
-        self.assertEqual(D.metadata.get_min_min(), 8)  # 1 + 7  a1 + c1
-        self.assertEqual(D.metadata.get_max_max(), 11) # 4 + 7  a4 + c1
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 1))
-        self.assertEqual(end, datetime.datetime(2001, 1, 5))
-
-    def test_temporal_neighbors_1(self):
-        """Simple temporal neighborhood computation test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A[-1] + A[1]',
-                  basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 2)
-        self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3
-        self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
-    def test_temporal_neighbors_2(self):
-        """Simple temporal neighborhood computation test"""
-        tra = tgis.TemporalRasterAlgebraParser(run = True, debug = True)
-        tra.parse(expression='D = A[0,0,-1] + A[0,0,1]',
-                  basename="d", overwrite=True)
-
-        D = tgis.open_old_space_time_dataset("D", type="strds")
-        D.select()
-        self.assertEqual(D.metadata.get_number_of_maps(), 2)
-        self.assertEqual(D.metadata.get_min_min(), 4)  # 1 + 3
-        self.assertEqual(D.metadata.get_max_max(), 6) # 2 + 4
-        start, end = D.get_absolute_time()
-        self.assertEqual(start, datetime.datetime(2001, 1, 2))
-        self.assertEqual(end, datetime.datetime(2001, 1, 4))
-
-    def tearDown(self):
-        ret = grass.script.run_command("t.remove", flags="rf", input="D", quiet=True)
-
-    @classmethod
-    def tearDownClass(cls):
-        """!Remove the temporary region
-        """
-        ret = grass.script.run_command("t.remove", flags="rf", input="A,B,C", quiet=True)
-        grass.script.del_temp_region()
-
-if __name__ == '__main__':
-    unittest.main()
-
-

Modified: grass/branches/releasebranch_7_0/lib/python/temporal/univar_statistics.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/temporal/univar_statistics.py	2014-11-22 22:29:06 UTC (rev 62863)
+++ grass/branches/releasebranch_7_0/lib/python/temporal/univar_statistics.py	2014-11-22 23:17:39 UTC (rev 62864)
@@ -1,58 +1,55 @@
-"""!@package grass.temporal
+"""
+Univariate statistic function for space time datasets
 
- at brief GRASS Python scripting module (temporal GIS functions)
+Usage:
 
-Temporal GIS related functions to be used in Python scripts.
+.. code-block:: python
 
-Usage:
+    import grass.temporal as tgis
 
- at code
-import grass.temporal as tgis
+    tgis.print_gridded_dataset_univar_statistics(type, input, where, extended, no_header, fs)
 
-tgis.print_gridded_dataset_univar_statistics(
-    type, input, where, extended, no_header, fs)
 
-...
- at endcode
-
 (C) 2012-2013 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
- at author Soeren Gebbert
+:authors: Soeren Gebbert
 """
 
 from open_stds import *
+import grass.script as gscript
 
 ###############################################################################
 
 
 def print_gridded_dataset_univar_statistics(type, input, where, extended,
                                             no_header=False, fs="|"):
-    """!Print univariate statistics for a space time raster or raster3d dataset
+    """Print univariate statistics for a space time raster or raster3d dataset
 
-       @param type Must be "strds" or "str3ds"
-       @param input The name of the space time dataset
-       @param where A temporal database where statement
-       @param extended If True compute extended statistics
-       @param no_header Supress the printing of column names
-       @param fs Field separator
+       :param type: Must be "strds" or "str3ds"
+       :param input: The name of the space time dataset
+       :param where: A temporal database where statement
+       :param extended: If True compute extended statistics
+       :param no_header: Supress the printing of column names
+       :param fs: Field separator
     """
 
     # We need a database interface
     dbif = SQLDatabaseInterfaceConnection()
     dbif.connect()
 
-    sp = open_old_space_time_dataset(input, type, dbif)
+    sp = open_old_stds(input, type, dbif)
 
     rows = sp.get_registered_maps(
         "id,start_time,end_time", where, "start_time", dbif)
 
     if not rows:
         dbif.close()
-        core.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
-                     'sp': sp.get_new_map_instance(None).get_type(), 'i': sp.get_id()})
+        gscript.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
+                      'sp': sp.get_new_map_instance(None).get_type(),
+                      'i': sp.get_id()})
 
     if no_header is False:
         string = ""
@@ -60,7 +57,7 @@
         string += "min" + fs + "max" + fs
         string += "mean_of_abs" + fs + "stddev" + fs + "variance" + fs
         string += "coeff_var" + fs + "sum" + fs + "null_cells" + fs + "cells"
-        if extended == True:
+        if extended is True:
             string += fs + "first_quartile" + fs + "median" + fs
             string += "third_quartile" + fs + "percentile_90"
 
@@ -74,28 +71,30 @@
 
         flag = "g"
 
-        if extended == True:
+        if extended is True:
             flag += "e"
 
         if type == "strds":
-            stats = core.parse_command("r.univar", map=id, flags=flag)
+            stats = gscript.parse_command("r.univar", map=id, flags=flag)
         elif type == "str3ds":
-            stats = core.parse_command("r3.univar", map=id, flags=flag)
+            stats = gscript.parse_command("r3.univar", map=id, flags=flag)
 
         if not stats:
             if type == "strds":
-                core.warning(_("Unable to get statistics for raster map <%s>") % id)
+                gscript.warning(_("Unable to get statistics for raster map "
+                                  "<%s>") % id)
             elif type == "str3ds":
-                core.warning(_("Unable to get statistics for 3d raster map <%s>") % id)
+                gscript.warning(_("Unable to get statistics for 3d raster map"
+                                  " <%s>") % id)
             continue
-        
+
         string += str(id) + fs + str(start) + fs + str(end)
         string += fs + str(stats["mean"]) + fs + str(stats["min"])
         string += fs + str(stats["max"]) + fs + str(stats["mean_of_abs"])
         string += fs + str(stats["stddev"]) + fs + str(stats["variance"])
         string += fs + str(stats["coeff_var"]) + fs + str(stats["sum"])
         string += fs + str(stats["null_cells"]) + fs + str(stats["cells"])
-        if extended == True:            
+        if extended is True:
             string += fs + str(stats["first_quartile"]) + fs + str(stats["median"])
             string += fs + str(stats["third_quartile"]) + fs + str(stats["percentile_90"])
         print string
@@ -106,19 +105,20 @@
 
 
 def print_vector_dataset_univar_statistics(input, twhere, layer, type, column,
-                                           where, extended, no_header=False, fs="|"):
-    """!Print univariate statistics for a space time vector dataset
+                                           where, extended, no_header=False,
+                                           fs="|"):
+    """Print univariate statistics for a space time vector dataset
 
-       @param input The name of the space time dataset
-       @param twhere A temporal database where statement
-       @param layer The layer number used in case no layer is present
+       :param input: The name of the space time dataset
+       :param twhere: A temporal database where statement
+       :param layer: The layer number used in case no layer is present
               in the temporal dataset
-       @param type options: point,line,boundary,centroid,area
-       @param column The name of the attribute column
-       @param where A temporal database where statement
-       @param extended If True compute extended statistics
-       @param no_header Supress the printing of column names
-       @param fs Field separator
+       :param type: options: point,line,boundary,centroid,area
+       :param column: The name of the attribute column
+       :param where: A temporal database where statement
+       :param extended: If True compute extended statistics
+       :param no_header: Supress the printing of column names
+       :param fs: Field separator
     """
 
     # We need a database interface
@@ -134,10 +134,10 @@
 
     sp = dataset_factory("stvds", id)
 
-    if sp.is_in_db(dbif) == False:
+    if sp.is_in_db(dbif) is False:
         dbif.close()
-        core.fatal(_("Space time %(sp)s dataset <%(i)s> not found") % {
-                     'sp': sp.get_new_map_instance(None).get_type(), 'i': id})
+        gscript.fatal(_("Space time %(sp)s dataset <%(i)s> not found") % {
+                      'sp': sp.get_new_map_instance(None).get_type(), 'i': id})
 
     sp.select(dbif)
 
@@ -146,8 +146,8 @@
 
     if not rows:
         dbif.close()
-        core.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
-                     'sp': sp.get_new_map_instance(None).get_type(), 'i': id})
+        gscript.fatal(_("Space time %(sp)s dataset <%(i)s> is empty") % {
+                      'sp': sp.get_new_map_instance(None).get_type(), 'i': id})
 
     string = ""
     if no_header is False:
@@ -160,7 +160,7 @@
             string += "population_coeff_variation" + fs + \
                 "sample_stddev" + fs + "sample_variance" + fs
             string += "kurtosis" + fs + "skewness"
-            if extended == True:
+            if extended is True:
                 string += fs + "first_quartile" + fs + "median" + fs + \
                     "third_quartile" + fs + "percentile_90"
 
@@ -174,22 +174,23 @@
 
         flags = "g"
 
-        if extended == True:
+        if extended is True:
             flags += "e"
 
         if not mylayer:
             mylayer = layer
 
-        stats = core.parse_command("v.univar", map=id, where=where,
-                                   column=column, layer=mylayer,
-                                   type=type, flags=flags)
+        stats = gscript.parse_command("v.univar", map=id, where=where,
+                                      column=column, layer=mylayer,
+                                      type=type, flags=flags)
 
         string = ""
 
         if not stats:
-            core.warning(_("Unable to get statistics for vector map <%s>") % id)
+            gscript.warning(_("Unable to get statistics for vector map <%s>")
+                            % id)
             continue
-        
+
         string += str(id) + fs + str(start) + fs + str(end)
         string += fs + str(stats["n"]) + fs + str(stats[
             "nmissing"]) + fs + str(stats["nnull"])
@@ -211,15 +212,15 @@
                 str(stats["sample_variance"])
 
                 string += fs + str(stats["kurtosis"]) + fs + \
-                str(stats["skewness"])
+                          str(stats["skewness"])
             else:
                 string += fs + fs + fs + fs + fs + fs + fs + fs + fs
-            if extended == True:
+            if extended is True:
                 if "first_quartile" in stats:
                     string += fs + str(stats["first_quartile"]) + fs + \
-                    str(stats["median"]) + fs + \
-                    str(stats["third_quartile"]) + fs + \
-                    str(stats["percentile_90"])
+                              str(stats["median"]) + fs + \
+                              str(stats["third_quartile"]) + fs + \
+                              str(stats["percentile_90"])
                 else:
                     string += fs + fs + fs + fs
 



More information about the grass-commit mailing list