2
# -*- coding: utf-8 -*-
3
############################################################################
6
# AUTHOR(S): Soeren Gebbert
8
# PURPOSE: List space time datasets and maps registered in the temporal database
9
# COPYRIGHT: (C) 2011-2014, Soeren Gebbert and the GRASS Development Team
11
# This program is free software under the GNU General Public
12
# License (version 2). Read the file COPYING that comes with GRASS
15
#############################################################################
18
#% description: Lists space time datasets and maps registered in the temporal database.
20
#% keyword: map management
27
#% description: Type of the space time dataset or map, default is strds
28
#% guisection: Selection
30
#% options: strds, str3ds, stvds, raster, raster_3d, vector
36
#% answer: absolute,relative
37
#% guisection: Selection
43
#% description: Columns number_of_maps and granularity only available for space time datasets
44
#% label: Sort the space time dataset by category
45
#% guisection: Formatting
48
#% options: id,name,creator,mapset,number_of_maps,creation_time,start_time,end_time,interval,north,south,west,east,granularity
55
#% description: Columns number_of_maps and granularity only available for space time datasets
56
#% label: Columns to be printed to stdout
57
#% guisection: Selection
60
#% options: id,name,creator,mapset,number_of_maps,creation_time,start_time,end_time,north,south,west,east,granularity,all
64
#%option G_OPT_T_WHERE
65
#% guisection: Selection
69
#% description: Field separator character between the output columns
70
#% guisection: Formatting
75
#% description: Print the column names as first row
76
#% guisection: Formatting
79
import grass.script as gscript
80
import grass.temporal as tgis
83
############################################################################
89
type = options["type"]
90
temporal_type = options["temporaltype"]
91
columns = options["columns"]
92
order = options["order"]
93
where = options["where"]
94
separator = gscript.separator(options["separator"])
97
# Make sure the temporal database exists
100
sp = tgis.dataset_factory(type, None)
103
if gscript.verbosity() > 0:
104
sys.stderr.write("----------------------------------------------\n")
106
for ttype in temporal_type.split(","):
107
if ttype == "absolute":
108
time = "absolute time"
110
time = "relative time"
112
stds_list = tgis.get_dataset_list(type, ttype, columns, where, order)
114
# Use the correct order of the mapsets, hence first the current mapset, then
115
# alphabetic ordering
116
mapsets = tgis.get_tgis_c_library_interface().available_mapsets()
118
# Print for each mapset separately
120
if key in stds_list.keys():
121
rows = stds_list[key]
124
if gscript.verbosity() > 0:
125
if issubclass(sp.__class__, tgis.AbstractMapDataset):
126
sys.stderr.write(_("Time stamped %s maps with %s available in mapset <%s>:\n")%\
127
(sp.get_type(), time, key))
129
sys.stderr.write(_("Space time %s datasets with %s available in mapset <%s>:\n")%\
130
(sp.get_new_map_instance(None).get_type(), time, key))
132
# Print the column names if requested
133
if colhead == True and first == True:
136
for key in rows[0].keys():
138
output += separator + str(key)
150
output += separator + str(col)
157
if __name__ == "__main__":
158
options, flags = gscript.parser()