Browse Source

Fixed t.connect $MAPSET issue, enhanced the sampling code

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58024 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 11 years ago
parent
commit
4c59e71a77
3 changed files with 14 additions and 25 deletions
  1. 3 0
      lib/python/temporal/core.py
  2. 10 6
      lib/python/temporal/sampling.py
  3. 1 19
      lib/temporal/lib/default_name.c

+ 3 - 0
lib/python/temporal/core.py

@@ -133,11 +133,14 @@ def get_temporal_dbmi_init_string():
     grassenv = core.gisenv()
     grassenv = core.gisenv()
     global tgis_backend
     global tgis_backend
     if tgis_backend == "sqlite":
     if tgis_backend == "sqlite":
+        # We substitute GRASS variables if they are located in the database string
+        # This behavior is in conjunction with db.connect 
         if "database" in kv:
         if "database" in kv:
             string = kv["database"]
             string = kv["database"]
             string = string.replace("$GISDBASE", grassenv["GISDBASE"])
             string = string.replace("$GISDBASE", grassenv["GISDBASE"])
             string = string.replace(
             string = string.replace(
                 "$LOCATION_NAME", grassenv["LOCATION_NAME"])
                 "$LOCATION_NAME", grassenv["LOCATION_NAME"])
+            string = string.replace("$MAPSET", grassenv["MAPSET"])
             return string
             return string
         else:
         else:
             core.fatal(_("Unable to initialize the temporal GIS DBMI "
             core.fatal(_("Unable to initialize the temporal GIS DBMI "

+ 10 - 6
lib/python/temporal/sampling.py

@@ -42,13 +42,14 @@ def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
         Attention: Do not use the comma as separator for printing
         Attention: Do not use the comma as separator for printing
 
 
         @param intype  Type of the input space time dataset (strds, stvds or str3ds)
         @param intype  Type of the input space time dataset (strds, stvds or str3ds)
-        @param sampletype Type of the sample space time dataset (strds, stvds or str3ds)
-        @param inputs Name or comma separated names of space time datasets
+        @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 sampler Name of a space time dataset used for temporal sampling
         @param header Set True to print column names
         @param header Set True to print column names
         @param separator The field separator character between the columns
         @param separator The field separator character between the columns
         @param method The method to be used for temporal sampling
         @param method The method to be used for temporal sampling
-                       (start,during,contain,overlap,equal)
+                       (start,during,contain,overlap,equal) as comma separated string
+                       or as a list of methods
         @param spatial Perform spatial overlapping check
         @param spatial Perform spatial overlapping check
         @param print_only If set True (default) then the result of the sampling will be
         @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
                     printed to stdout, if set to False the resulting map matrix
@@ -59,13 +60,16 @@ def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
     mapset = get_current_mapset()
     mapset = get_current_mapset()
 
 
     # Make a method list
     # Make a method list
-    method = method.split(",")
+    if not issubclass(type(method), type([])):
+        method = method.split(",")
 
 
     # Split the inputs
     # Split the inputs
-    input_list = inputs.split(",")
+    if not issubclass(type(inputs), type([])):
+        inputs = inputs.split(",")
+
     sts = []
     sts = []
 
 
-    for input in input_list:
+    for input in inputs:
         if input.find("@") >= 0:
         if input.find("@") >= 0:
             id = input
             id = input
         else:
         else:

+ 1 - 19
lib/temporal/lib/default_name.c

@@ -38,29 +38,11 @@ const char *tgis_get_default_driver_name(void)
 */
 */
 char *tgis_get_default_database_name(void)
 char *tgis_get_default_database_name(void)
 {
 {
-    int n;
-    const char *name = NULL, *value = NULL;
-    char *location = NULL, *gisbase = NULL;
     char default_connection[2048];
     char default_connection[2048];
 
 
-    for (n = 0; (name = G__env_name(n)); n++) {
-        value = (char *)G__getenv(name);
-        if (value) {
-            if (G_strcasecmp("GISDBASE", name) == 0)
-                gisbase = G_store(value);
-            if (G_strcasecmp("LOCATION_NAME", name) == 0)
-                location = G_store(value);
-        }
-    }
-
-    G_snprintf(default_connection, 2048, "%s/%s/%s", gisbase, location,
+    G_snprintf(default_connection, 2048, "%s/%s/%s", G_gisdbase(), G_location(),
                TGISDB_DEFAULT_SQLITE_PATH);
                TGISDB_DEFAULT_SQLITE_PATH);
 
 
-    if(location)
-        G_free(location);
-    if(gisbase)
-        G_free(gisbase);
-
     return G_store(default_connection);
     return G_store(default_connection);
 }
 }