Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
4c59e71a77

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

@@ -133,11 +133,14 @@ def get_temporal_dbmi_init_string():
     grassenv = core.gisenv()
     global tgis_backend
     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:
             string = kv["database"]
             string = string.replace("$GISDBASE", grassenv["GISDBASE"])
             string = string.replace(
                 "$LOCATION_NAME", grassenv["LOCATION_NAME"])
+            string = string.replace("$MAPSET", grassenv["MAPSET"])
             return string
         else:
             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
 
         @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 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)
+                       (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
@@ -59,13 +60,16 @@ def sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header,
     mapset = get_current_mapset()
 
     # Make a method list
-    method = method.split(",")
+    if not issubclass(type(method), type([])):
+        method = method.split(",")
 
     # Split the inputs
-    input_list = inputs.split(",")
+    if not issubclass(type(inputs), type([])):
+        inputs = inputs.split(",")
+
     sts = []
 
-    for input in input_list:
+    for input in inputs:
         if input.find("@") >= 0:
             id = input
         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)
 {
-    int n;
-    const char *name = NULL, *value = NULL;
-    char *location = NULL, *gisbase = NULL;
     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);
 
-    if(location)
-        G_free(location);
-    if(gisbase)
-        G_free(gisbase);
-
     return G_store(default_connection);
 }