[GRASS-SVN] r53429 - in grass/trunk/temporal: t.create t.info t.list

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 16 08:03:45 PDT 2012


Author: huhabla
Date: 2012-10-16 08:03:44 -0700 (Tue, 16 Oct 2012)
New Revision: 53429

Modified:
   grass/trunk/temporal/t.create/t.create.html
   grass/trunk/temporal/t.info/t.info.html
   grass/trunk/temporal/t.info/t.info.py
   grass/trunk/temporal/t.info/test.t.info.sh
   grass/trunk/temporal/t.list/t.list.py
Log:
Added more documentation and corrected tests


Modified: grass/trunk/temporal/t.create/t.create.html
===================================================================
--- grass/trunk/temporal/t.create/t.create.html	2012-10-16 14:50:56 UTC (rev 53428)
+++ grass/trunk/temporal/t.create/t.create.html	2012-10-16 15:03:44 UTC (rev 53429)
@@ -25,7 +25,7 @@
 We use <em>t.create</em> for the space time raster dataset creation 
 and <em>t.register</em> to register the raster maps
 in the space time raster dataset.
-At the end we print extent and metadata informations about the 
+At the end we report informations about the 
 space time raster dataset to stdout using <em>t.info</em>.
 <div class="code"><pre>
 

Modified: grass/trunk/temporal/t.info/t.info.html
===================================================================
--- grass/trunk/temporal/t.info/t.info.html	2012-10-16 14:50:56 UTC (rev 53428)
+++ grass/trunk/temporal/t.info/t.info.html	2012-10-16 15:03:44 UTC (rev 53429)
@@ -1,12 +1,132 @@
 <h2>DESCRIPTION</h2>
 
-TBD.
+<em>t.info</em> reports informations about any dataset that is registered in the temporal database in
+human readable or shell script style. Datasets are raster, 3D raster and vector maps as well as their 
+corresponding space time datasets (STRDS, STR3DS and STVDS). This module reports the informations that 
+are stored in the temporal database. These are basic informations (id, name, mapset, creator, 
+creation time, temporal type),
+the temporal and spatial extent and dataset type specific metadata. 
+The user has to utilize <em>r.info, r3.info, v.info</em> 
+to report detailed informations about raster, 3D raster and vector maps, since
+not all map specific informations and metadata are stored in the temporal database. 
+<p>
+In addition informations about the chosen temporal database backend can be reported.
 
+<h2>EXAMPLE</h2>
+
+In this example we first report temporal database backend information using <em>t.info -s</em>.
+Then we create a single raster maps using <em>r.mapcalc</em> with random values 
+that will be registered in a single space time
+raster dataset named <em>precipitation_daily</em> using a daily temporal granularity.
+We use <em>t.create</em> for the space time raster dataset creation 
+and <em>t.register</em> to register the raster map
+in the space time raster dataset.
+At the end we report informations about the raster map and the
+space time raster dataset to stdout.
+
+<div class="code"><pre>
+
+t.info -s
+
+ +------------------- Temporal DBMI backend information ----------------------+
+ | DBMI Python interface:...... sqlite3
+ | DBMI init string:........... /1/soeren/grassdata/TestLL/PERMANENT/tgis.db
+ | SQL template path:.......... /home/soeren/src/grass7.0/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/sql
+ +----------------------------------------------------------------------------+
+
+r.mapcalc --o expr="map1 = rand(0, 10)" 
+
+t.create type=strds temporaltype=absolute \
+         output=precipitation_daily \
+         title="Daily precipitation" \
+         description="Test dataset with daily precipitation"
+
+t.register -i type=rast input=precipitation_daily \
+           maps=map1 start=20-08-2012 increment="1 days"
+
+t.info type=rast input=map1
+
+ +-------------------- Raster Dataset ----------------------------------------+
+ |                                                                            |
+ +-------------------- Basic information -------------------------------------+
+ | Id: ........................ map1 at PERMANENT
+ | Name: ...................... map1
+ | Mapset: .................... PERMANENT
+ | Creator: ................... soeren
+ | Creation time: ............. 2012-10-16 14:45:24.554908
+ | Temporal type: ............. absolute
+ +-------------------- Absolute time -----------------------------------------+
+ | Start time:................. 2012-08-20 00:00:00
+ | End time:................... 2012-08-21 00:00:00
+ +-------------------- Spatial extent ----------------------------------------+
+ | North:...................... 80.0
+ | South:...................... 0.0
+ | East:.. .................... 120.0
+ | West:....................... 0.0
+ | Top:........................ 0.0
+ | Bottom:..................... 0.0
+ +-------------------- 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:.............. 0.0
+ | Maximum value:.............. 9.0
+ | STRDS register table ....... map_989e88525bae40db9c16d03d3574d656_strds_register
+ | Registered datasets ........ precipitation_daily at PERMANENT
+ +----------------------------------------------------------------------------+
+
+t.info type=strds input=precipitation_daily
+
+ +-------------------- Space Time Raster Dataset -----------------------------+
+ |                                                                            |
+ +-------------------- Basic information -------------------------------------+
+ | Id: ........................ precipitation_daily at PERMANENT
+ | Name: ...................... precipitation_daily
+ | Mapset: .................... PERMANENT
+ | Creator: ................... soeren
+ | Creation time: ............. 2012-10-16 14:52:24.093147
+ | Temporal type: ............. absolute
+ | Semantic type:.............. mean
+ +-------------------- Absolute time -----------------------------------------+
+ | Start time:................. 2012-08-20 00:00:00
+ | End time:................... 2012-08-21 00:00:00
+ | Granularity:................ 1 days
+ | Temporal type of maps:...... interval
+ +-------------------- Spatial extent ----------------------------------------+
+ | North:...................... 80.0
+ | South:...................... 0.0
+ | East:.. .................... 120.0
+ | West:....................... 0.0
+ | Top:........................ 0.0
+ | Bottom:..................... 0.0
+ +-------------------- Metadata information ----------------------------------+
+ | Number of registered maps:.. 1
+ | Title:
+ | Daily precipitation
+ | Description:
+ | Test dataset with daily precipitation
+ | North-South resolution min:. 10.0
+ | North-South resolution max:. 10.0
+ | East-west resolution min:... 10.0
+ | East-west resolution max:... 10.0
+ | Minimum value min:.......... 0.0
+ | Minimum value max:.......... 0.0
+ | Maximum value min:.......... 9.0
+ | Maximum value max:.......... 9.0
+ | Raster register table:...... precipitation_daily_PERMANENT_raster_register
+ +----------------------------------------------------------------------------+
+</pre></div>
 <h2>SEE ALSO</h2>
 
 <em>
 <a href="t.create.html">t.create</a>,
-<a href="t.info.html">t.info</a>
+<a href="t.register.html">t.register</a>,
+<a href="r.info.html">r.info</a>,
+<a href="r3.info.html">r3.info</a>,
+<a href="v.info.html">v.info</a>
 </em>
 
 <h2>AUTHOR</h2>

Modified: grass/trunk/temporal/t.info/t.info.py
===================================================================
--- grass/trunk/temporal/t.info/t.info.py	2012-10-16 14:50:56 UTC (rev 53428)
+++ grass/trunk/temporal/t.info/t.info.py	2012-10-16 15:03:44 UTC (rev 53429)
@@ -23,7 +23,7 @@
 #%option
 #% key: input
 #% type: string
-#% description: Name of an existing space time or map dataset
+#% description: Name of an existing space time dataset or map
 #% required: no
 #% multiple: no
 #%end
@@ -64,7 +64,7 @@
     # Make sure the temporal database exists
     tgis.create_temporal_database()
 
-    if system:
+    if system and not shellstyle:
         #      0123456789012345678901234567890
         print " +------------------- Temporal DBMI backend information ----------------------+"
         print " | DBMI Python interface:...... " + str(tgis.dbmi.__name__)
@@ -74,6 +74,11 @@
             tgis.get_sql_template_path())
         print " +----------------------------------------------------------------------------+"
         return
+    elif system:
+        print "dbmi_python_interface=" + str(tgis.dbmi.__name__)
+        print "dbmi_init_string=" + str(tgis.get_temporal_dbmi_init_string())
+        print "sql_template_path=" + str(tgis.get_sql_template_path())
+        return
 
     if not system and not name:
         grass.fatal(_("Please specify %s=") % ("name"))
@@ -87,7 +92,7 @@
     ds = tgis.dataset_factory(type, id)
 
     if ds.is_in_db() == False:
-        grass.fatal(_("Dataset <%s> not found") % (id))
+        grass.fatal(_("Dataset <%s> not found in temporal database") % (id))
 
     ds.select()
 

Modified: grass/trunk/temporal/t.info/test.t.info.sh
===================================================================
--- grass/trunk/temporal/t.info/test.t.info.sh	2012-10-16 14:50:56 UTC (rev 53428)
+++ grass/trunk/temporal/t.info/test.t.info.sh	2012-10-16 15:03:44 UTC (rev 53429)
@@ -15,6 +15,8 @@
 v.random --o -z output=lidar_abs_2 n=20 zmin=0 zmax=100 column=height
 
 # The first @test
+t.info -s
+t.info -sg
 
 t.create --o type=strds temporaltype=absolute output=precip_abs1 title="A test" descr="A test"
 t.create --o type=strds temporaltype=absolute output=precip_abs2 title="A test" descr="A test"
@@ -25,11 +27,11 @@
 t.create --o type=stvds temporaltype=absolute output=lidar_abs_ds1 title="A test" descr="A test"
 t.create --o type=stvds temporaltype=absolute output=lidar_abs_ds2 title="A test" descr="A test"
 
-t.register type=rast -i input=precip_abs1 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
+t.register --o type=rast -i input=precip_abs1 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
 t.info type=strds input=precip_abs1
 t.info -g type=strds input=precip_abs1
 
-t.register type=rast -i input=precip_abs2 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
+t.register --o type=rast -i input=precip_abs2 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
 t.info type=strds input=precip_abs2
 t.info -g type=strds input=precip_abs2
 t.info type=rast input=prec_1
@@ -38,11 +40,11 @@
 t.info -g type=rast input=prec_2
 
 
-t.register type=rast3d -i input=precip_abs1 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
+t.register --o type=rast3d -i input=precip_abs1 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
 t.info type=str3ds input=precip_abs1
 t.info -g type=str3ds input=precip_abs1
 
-t.register type=rast3d -i input=precip_abs2 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
+t.register --o type=rast3d -i input=precip_abs2 maps=prec_1,prec_2 start="2001-01-01" increment="20 years"
 t.info type=str3ds input=precip_abs2
 t.info -g type=str3ds input=precip_abs2
 t.info type=rast3 input=prec_1
@@ -50,11 +52,11 @@
 t.info type=rast3 input=prec_2
 t.info -g type=rast3 input=prec_2
 
-t.register type=vect --v -i input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2 start="2001-01-01" increment="20 years"
+t.register --o type=vect --v -i input=lidar_abs_ds1 maps=lidar_abs_1,lidar_abs_2 start="2001-01-01" increment="20 years"
 t.info type=stvds input=lidar_abs_ds1
 t.info -g type=stvds input=lidar_abs_ds1
 
-t.register type=vect --v -i input=lidar_abs_ds2 maps=lidar_abs_1,lidar_abs_2 start="2001-01-01" increment="20 years"
+t.register --o type=vect --v -i input=lidar_abs_ds2 maps=lidar_abs_1,lidar_abs_2 start="2001-01-01" increment="20 years"
 t.info type=stvds input=lidar_abs_ds2
 t.info -g type=stvds input=lidar_abs_ds2
 t.info type=vect input=lidar_abs_1

Modified: grass/trunk/temporal/t.list/t.list.py
===================================================================
--- grass/trunk/temporal/t.list/t.list.py	2012-10-16 14:50:56 UTC (rev 53428)
+++ grass/trunk/temporal/t.list/t.list.py	2012-10-16 15:03:44 UTC (rev 53429)
@@ -54,6 +54,8 @@
 #%end
 
 #%option G_OPT_T_TYPE
+#% multiple: yes
+#% answer: absolute,relative
 #%end
 
 #%option
@@ -93,58 +95,64 @@
 
     dbif = tgis.SQLDatabaseInterfaceConnection()
     dbif.connect()
+    
+    first = True
+    
+    for ttype in temporaltype.split(","):
+    
+        # Create the sql selection statement
+        # Table name
+        if ttype == "absolute":
+            table = sp.get_type() + "_view_abs_time"
+        else:
+            table = sp.get_type() + "_view_rel_time"
+    
+        if columns.find("all") == -1:
+            sql = "SELECT " + str(columns) + " FROM " + table
+        else:
+            sql = "SELECT * FROM " + table
+    
+        if where:
+            sql += " WHERE " + where
+    
+        if order:
+            sql += " ORDER BY " + order
+    
+        dbif.cursor.execute(sql)
+        rows = dbif.cursor.fetchall()
+    
+        # Print the query result to stout
+        if rows:
+            if separator is None or separator == "":
+                separator = "\t"
+    
+            # 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
+                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
+    
+                print output
 
-    # Create the sql selection statement
-    # Table name
-    if temporaltype == "absolute":
-        table = sp.get_type() + "_view_abs_time"
-    else:
-        table = sp.get_type() + "_view_rel_time"
-
-    if columns.find("all") == -1:
-        sql = "SELECT " + str(columns) + " FROM " + table
-    else:
-        sql = "SELECT * FROM " + table
-
-    if where:
-        sql += " WHERE " + where
-
-    if order:
-        sql += " ORDER BY " + order
-
-    dbif.cursor.execute(sql)
-    rows = dbif.cursor.fetchall()
     dbif.close()
-
-    # Print the query result to stout
-    if rows:
-        if separator is None or separator == "":
-            separator = "\t"
-
-        # Print the column names if requested
-        if colhead == True:
-            output = ""
-            count = 0
-            for key in rows[0].keys():
-                if count > 0:
-                    output += separator + str(key)
-                else:
-                    output += str(key)
-                count += 1
-            print output
-
-        for row in rows:
-            output = ""
-            count = 0
-            for col in row:
-                if count > 0:
-                    output += separator + str(col)
-                else:
-                    output += str(col)
-                count += 1
-
-            print output
-
+        
 if __name__ == "__main__":
     options, flags = grass.parser()
     main()



More information about the grass-commit mailing list