Ejemplo n.º 1
0
    def test_absolute_time_strds_4(self):
        """Test the registration of maps with absolute time in a
           space time raster dataset. The timestamps are set via method arguments and with the
           c-interface. The timestamps of the method arguments should overwrite the
           time stamps set via the C-interface. The C-interface sets relative time stamps.
        """

        ciface = tgis.get_tgis_c_library_interface()
        ciface.write_raster_timestamp("register_map_1", tgis.get_current_mapset(), "1 day")

        tgis.register_maps_in_space_time_dataset(type="raster", name=self.strds_abs.get_name(),
                                                 maps="register_map_1",
                                                 start="2001-02-01", increment="1 day",
                                                 interval=True)

        map = tgis.RasterDataset("register_map_1@" + tgis.get_current_mapset())
        map.select()
        start, end = map.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 2, 1))
        self.assertEqual(end, datetime.datetime(2001, 2, 2))

        self.strds_abs.select()
        start, end = self.strds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 2, 1))
        self.assertEqual(end, datetime.datetime(2001, 2, 2))
Ejemplo n.º 2
0
    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="raster", 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))
Ejemplo n.º 3
0
    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="raster", 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))
Ejemplo n.º 4
0
    def test_relative_time_3(self):
        """Test the registration of maps with relative time. The timetsamps are set beforehand 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="raster", 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")
Ejemplo n.º 5
0
    def _checkDatasets(self, datasets, typ):
        """Checks and validates datasets.

        Reports also type of dataset (e.g. 'strds').

        :param list datasets: list of temporal dataset's name
        :return: (mapName, mapset, type)
        """
        validated = []
        tDict = tgis.tlist_grouped(type=typ, group_type=True, dbif=self.dbif)
        # nested list with '(map, mapset, etype)' items
        allDatasets = [[[(map, mapset, etype) for map in maps]
                        for etype, maps in etypesDict.iteritems()]
                       for mapset, etypesDict in tDict.iteritems()]
        # flatten this list
        if allDatasets:
            allDatasets = reduce(lambda x, y: x + y, reduce(lambda x, y: x + y,
                                                            allDatasets))
            mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
            allDatasets = [
                i
                for i in sorted(
                    allDatasets, key=lambda l: mapsets.index(l[1]))]

        for dataset in datasets:
            errorMsg = _("Space time dataset <%s> not found.") % dataset
            if dataset.find("@") >= 0:
                nameShort, mapset = dataset.split('@', 1)
                indices = [n for n, (mapName, mapsetName, etype) in enumerate(
                    allDatasets) if nameShort == mapName and mapsetName == mapset]
            else:
                indices = [n for n, (mapName, mapset, etype) in enumerate(
                    allDatasets) if dataset == mapName]

            if len(indices) == 0:
                raise GException(errorMsg)
            elif len(indices) >= 2:
                dlg = wx.SingleChoiceDialog(
                    self,
                    message=_(
                        "Please specify the "
                        "space time dataset "
                        "<%s>." % dataset),
                    caption=_("Ambiguous dataset name"),
                    choices=[
                        ("%(map)s@%(mapset)s:"
                         " %(etype)s" % {
                             'map': allDatasets[i][0],
                             'mapset': allDatasets[i][1],
                             'etype': allDatasets[i][2]}) for i in indices],
                    style=wx.CHOICEDLG_STYLE | wx.OK)
                if dlg.ShowModal() == wx.ID_OK:
                    index = dlg.GetSelection()
                    validated.append(allDatasets[indices[index]])
                else:
                    continue
            else:
                validated.append(allDatasets[indices[0]])

        return validated
Ejemplo n.º 6
0
    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="raster", 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")
Ejemplo n.º 7
0
    def test_absolute_time_stvds_3(self):
        """Test the registration of maps with absolute time in a
        space time raster dataset. The timestamps are set via method arguments and with the
        c-interface. The timestamps of the method arguments should overwrite the
        time stamps set via the C-interface.
        """

        ciface = tgis.get_tgis_c_library_interface()
        ciface.write_vector_timestamp(
            "register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001"
        )

        tgis.register_maps_in_space_time_dataset(
            type="vector",
            name=self.stvds_abs.get_name(),
            maps="register_map_1",
            start="2001-02-01",
            increment="1 day",
            interval=True,
        )

        map = tgis.VectorDataset("register_map_1@" + tgis.get_current_mapset())
        map.select()
        start, end = map.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 2, 1))
        self.assertEqual(end, datetime.datetime(2001, 2, 2))

        self.stvds_abs.select()
        start, end = self.stvds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 2, 1))
        self.assertEqual(end, datetime.datetime(2001, 2, 2))
Ejemplo n.º 8
0
Archivo: utils.py Proyecto: caomw/grass
def validateTimeseriesName(timeseries, etype='strds'):
    """Checks if space time dataset exists and completes missing mapset.

    Raises GException if dataset doesn't exist.
    """
    trastDict = tgis.tlist_grouped(etype)
    if timeseries.find("@") >= 0:
        nameShort, mapset = timeseries.split('@', 1)
        if nameShort in trastDict[mapset]:
            return timeseries
        else:
            raise GException(_("Space time dataset <%s> not found.") % timeseries)

    mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
    for mapset in mapsets:
        if mapset in trastDict.keys():
            if timeseries in trastDict[mapset]:
                return timeseries + "@" + mapset

    raise GException(_("Space time dataset <%s> not found.") % timeseries)
Ejemplo n.º 9
0
def validateTimeseriesName(timeseries, etype='strds'):
    """Checks if space time dataset exists and completes missing mapset.

    Raises GException if dataset doesn't exist.
    """
    trastDict = tgis.tlist_grouped(etype)
    if timeseries.find("@") >= 0:
        nameShort, mapset = timeseries.split('@', 1)
        if nameShort in trastDict[mapset]:
            return timeseries
        else:
            raise GException(
                _("Space time dataset <%s> not found.") % timeseries)

    mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
    for mapset in mapsets:
        if mapset in trastDict.keys():
            if timeseries in trastDict[mapset]:
                return timeseries + "@" + mapset

    raise GException(_("Space time dataset <%s> not found.") % timeseries)
Ejemplo n.º 10
0
    def setUpClass(cls):
        os.putenv("GRASS_OVERWRITE", "1")
        for i in range(1, 5): 
            cls.runModule("g.mapset", flags="c", mapset="test%i"%i)
            cls.runModule("g.region",  s=0,  n=80,  w=0,  e=120,  b=0,  t=50,  res=10,  res3=10)
            cls.runModule("t.info", flags="s")
            cls.runModule("r.mapcalc", expression="a1 = 100")
            cls.runModule("r.mapcalc", expression="a2 = 200")
            cls.runModule("r.mapcalc", expression="a3 = 300")
            
            cls.runModule("t.create",  type="strds",  temporaltype="absolute",  
                                         output="A",  title="A test",  description="A test")
            cls.runModule("t.register",  flags="i",  type="rast",  input="A",  
                                         maps="a1,a2,a3",  
                                         start="2001-01-01", increment="%i months"%i)

        # Here we reuse two mapset to share a temporal databse between mapsets
        tgis.init()
        ciface = tgis.get_tgis_c_library_interface()
        cls.runModule("g.mapset", flags="c", mapset="test5")
        driver = ciface.get_driver_name("test1")
        database = ciface.get_database_name("test1")
        cls.runModule("t.connect",  driver=driver,  database=database)
        
        cls.runModule("g.mapset", flags="c", mapset="test6")
        driver = ciface.get_driver_name("test2")
        database = ciface.get_database_name("test2")
        cls.runModule("t.connect",  driver=driver,  database=database)

        for i in range(5, 7): 
            cls.runModule("g.mapset", mapset="test%i"%i)
            cls.runModule("r.mapcalc", expression="a1 = 100")
            cls.runModule("r.mapcalc", expression="a2 = 200")
            cls.runModule("r.mapcalc", expression="a3 = 300")
            
            cls.runModule("t.create",  type="strds",  temporaltype="absolute",  
                                         output="A",  title="A test",  description="A test")
            cls.runModule("t.register",  flags="i",  type="rast",  input="A",  
                                         maps="a1,a2,a3",  
                                         start="2001-01-01", increment="%i months"%i)
Ejemplo n.º 11
0
    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))
Ejemplo n.º 12
0
    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")
Ejemplo n.º 13
0
    def test_absolute_time_stvds_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_vector_timestamp(
            "register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001"
        )
        ciface.write_vector_timestamp(
            "register_map_2", tgis.get_current_mapset(), "2 Jan 2001/3 Jan 2001"
        )

        tgis.register_maps_in_space_time_dataset(
            type="vector",
            name=self.stvds_abs.get_name(),
            maps="register_map_1,register_map_2",
        )

        map = tgis.VectorDataset("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.VectorDataset("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.stvds_abs.select()
        start, end = self.stvds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 3))
Ejemplo n.º 14
0
    def _checkDatasets(self, datasets):
        """Checks and validates datasets.

        Reports also type of dataset (e.g. 'strds').

        :return: (mapName, mapset, type)
        """
        validated = []
        tDict = tgis.tlist_grouped('stds', group_type=True, dbif=self.dbif)
        # nested list with '(map, mapset, etype)' items
        allDatasets = [[[(map, mapset, etype) for map in maps]
                        for etype, maps in etypesDict.iteritems()]
                       for mapset, etypesDict in tDict.iteritems()]
        # flatten this list
        if allDatasets:
            allDatasets = reduce(
                lambda x,
                y: x + y,
                reduce(
                    lambda x,
                    y: x + y,
                    allDatasets))
            mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
            allDatasets = [
                i
                for i in sorted(
                    allDatasets, key=lambda l: mapsets.index(l[1]))]

        for dataset in datasets:
            errorMsg = _("Space time dataset <%s> not found.") % dataset
            if dataset.find("@") >= 0:
                nameShort, mapset = dataset.split('@', 1)
                indices = [n for n, (mapName, mapsetName, etype) in enumerate(
                    allDatasets) if nameShort == mapName and mapsetName == mapset]
            else:
                indices = [n for n, (mapName, mapset, etype) in enumerate(
                    allDatasets) if dataset == mapName]

            if len(indices) == 0:
                raise GException(errorMsg)
            elif len(indices) >= 2:
                dlg = wx.SingleChoiceDialog(
                    self,
                    message=_(
                        "Please specify the space time dataset <%s>." %
                        dataset),
                    caption=_("Ambiguous dataset name"),
                    choices=[("%(map)s@%(mapset)s: %(etype)s" %
                              {'map': allDatasets[i][0],
                               'mapset': allDatasets[i][1],
                               'etype': allDatasets[i][2]}) for i in indices],
                    style=wx.CHOICEDLG_STYLE | wx.OK)
                if dlg.ShowModal() == wx.ID_OK:
                    index = dlg.GetSelection()
                    validated.append(allDatasets[indices[index]])
                else:
                    continue
            else:
                validated.append(allDatasets[indices[0]])

        return validated
Ejemplo n.º 15
0
def main():
    # lazy imports
    import grass.temporal as tgis

    # Get the options
    type = options["type"]
    temporal_type = options["temporaltype"]
    columns = options["columns"]
    order = options["order"]
    where = options["where"]
    separator = gscript.separator(options["separator"])
    outpath = options["output"]
    colhead = flags['c']

    # Make sure the temporal database exists
    tgis.init()

    sp = tgis.dataset_factory(type, None)
    dbif = tgis.SQLDatabaseInterfaceConnection()
    dbif.connect()
    first = True

    if  gscript.verbosity() > 0 and not outpath:
        sys.stderr.write("----------------------------------------------\n")

    if outpath:
        outfile = open(outpath, 'w')

    for ttype in temporal_type.split(","):
        if ttype == "absolute":
            time = "absolute time"
        else:
            time = "relative time"

        stds_list = tgis.get_dataset_list(type, ttype, columns, where, order, dbif=dbif)

        # Use the correct order of the mapsets, hence first the current mapset, then
        # alphabetic ordering
        mapsets = tgis.get_tgis_c_library_interface().available_mapsets()

        # Print for each mapset separately
        for key in mapsets:
            if key in stds_list.keys():
                rows = stds_list[key]

                if rows:
                    if  gscript.verbosity() > 0 and not outpath:
                        if issubclass(sp.__class__, tgis.AbstractMapDataset):
                            sys.stderr.write(_("Time stamped %s maps with %s available in mapset <%s>:\n")%
                                                     (sp.get_type(), time, key))
                        else:
                            sys.stderr.write(_("Space time %s datasets with %s available in mapset <%s>:\n")%
                                                     (sp.get_new_map_instance(None).get_type(), time, key))

                    # Print the column names if requested
                    if colhead and first:
                        output = ""
                        count = 0
                        for key in rows[0].keys():
                            if count > 0:
                                output += separator + str(key)
                            else:
                                output += str(key)
                            count += 1
                        if outpath:
                            outfile.write("{st}\n".format(st=output))
                        else:
                            print(output)
                        first = False

                    for row in rows:
                        output = ""
                        count = 0
                        for col in row:
                            if count > 0:
                                output += separator + str(col)
                            else:
                                output += str(col)
                            count += 1
                        if outpath:
                            outfile.write("{st}\n".format(st=output))
                        else:
                            print(output)
    if outpath:
        outfile.close()
    dbif.close()
    def setUpClass(cls):
        os.putenv("GRASS_OVERWRITE", "1")
        for i in range(1, 5):
            cls.runModule("g.mapset", flags="c", mapset="test%i" % i)
            cls.runModule("g.region",
                          s=0,
                          n=80,
                          w=0,
                          e=120,
                          b=0,
                          t=50,
                          res=10,
                          res3=10)
            cls.runModule("t.info", flags="s")
            cls.runModule("r.mapcalc", expression="a1 = 100")
            cls.runModule("r.mapcalc", expression="a2 = 200")
            cls.runModule("r.mapcalc", expression="a3 = 300")

            cls.runModule("t.create",
                          type="strds",
                          temporaltype="absolute",
                          output="A",
                          title="A test",
                          description="A test")
            cls.runModule("t.register",
                          flags="i",
                          type="rast",
                          input="A",
                          maps="a1,a2,a3",
                          start="2001-01-01",
                          increment="%i months" % i)

        # Here we reuse two mapset to share a temporal databse between mapsets
        tgis.init()
        ciface = tgis.get_tgis_c_library_interface()
        cls.runModule("g.mapset", flags="c", mapset="test5")
        driver = ciface.get_driver_name("test1")
        database = ciface.get_database_name("test1")
        cls.runModule("t.connect", driver=driver, database=database)

        cls.runModule("g.mapset", flags="c", mapset="test6")
        driver = ciface.get_driver_name("test2")
        database = ciface.get_database_name("test2")
        cls.runModule("t.connect", driver=driver, database=database)

        for i in range(5, 7):
            cls.runModule("g.mapset", mapset="test%i" % i)
            cls.runModule("r.mapcalc", expression="a1 = 100")
            cls.runModule("r.mapcalc", expression="a2 = 200")
            cls.runModule("r.mapcalc", expression="a3 = 300")

            cls.runModule("t.create",
                          type="strds",
                          temporaltype="absolute",
                          output="A",
                          title="A test",
                          description="A test")
            cls.runModule("t.register",
                          flags="i",
                          type="rast",
                          input="A",
                          maps="a1,a2,a3",
                          start="2001-01-01",
                          increment="%i months" % i)
Ejemplo n.º 17
0
def main():

    # Get the options
    type = options["type"]
    temporal_type = options["temporaltype"]
    columns = options["columns"]
    order = options["order"]
    where = options["where"]
    separator = gscript.separator(options["separator"])
    outpath = options["output"]
    colhead = flags['c']

    # Make sure the temporal database exists
    tgis.init()

    sp = tgis.dataset_factory(type, None)
    dbif = tgis.SQLDatabaseInterfaceConnection()
    dbif.connect()
    first = True

    if  gscript.verbosity() > 0 and not outpath:
        sys.stderr.write("----------------------------------------------\n")

    for ttype in temporal_type.split(","):
        if ttype == "absolute":
            time = "absolute time"
        else:
            time = "relative time"

        stds_list = tgis.get_dataset_list(type,  ttype,  columns,  where,  order, dbif=dbif)

        # Use the correct order of the mapsets, hence first the current mapset, then
        # alphabetic ordering
        mapsets = tgis.get_tgis_c_library_interface().available_mapsets()

        if outpath:
            outfile = open(outpath, 'w')

        # Print for each mapset separately
        for key in mapsets:
            if key in stds_list.keys():
                rows = stds_list[key]

                if rows:
                    if  gscript.verbosity() > 0 and not outpath:
                        if issubclass(sp.__class__,  tgis.AbstractMapDataset):
                            sys.stderr.write(_("Time stamped %s maps with %s available in mapset <%s>:\n")%\
                                                     (sp.get_type(),  time,  key))
                        else:
                            sys.stderr.write(_("Space time %s datasets with %s available in mapset <%s>:\n")%\
                                                     (sp.get_new_map_instance(None).get_type(),  time,  key))

                    # Print the column names if requested
                    if colhead == True and first == True:
                        output = ""
                        count = 0
                        for key in rows[0].keys():
                            if count > 0:
                                output += separator + str(key)
                            else:
                                output += str(key)
                            count += 1
                        if outpath:
                            outfile.write("{st}\n".format(st=output))
                        else:
                            print output
                        first = False

                    for row in rows:
                        output = ""
                        count = 0
                        for col in row:
                            if count > 0:
                                output += separator + str(col)
                            else:
                                output += str(col)
                            count += 1
                        if outpath:
                            outfile.write("{st}\n".format(st=output))
                        else:
                            print output
    if outpath:
        outfile.close()
    dbif.close()