[GRASS-SVN] r58024 - in grass/trunk/lib: python/temporal temporal/lib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 17 00:48:49 PDT 2013
Author: huhabla
Date: 2013-10-17 00:48:49 -0700 (Thu, 17 Oct 2013)
New Revision: 58024
Modified:
grass/trunk/lib/python/temporal/core.py
grass/trunk/lib/python/temporal/sampling.py
grass/trunk/lib/temporal/lib/default_name.c
Log:
Fixed t.connect $MAPSET issue, enhanced the sampling code
Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py 2013-10-17 07:28:26 UTC (rev 58023)
+++ grass/trunk/lib/python/temporal/core.py 2013-10-17 07:48:49 UTC (rev 58024)
@@ -133,11 +133,14 @@
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 "
Modified: grass/trunk/lib/python/temporal/sampling.py
===================================================================
--- grass/trunk/lib/python/temporal/sampling.py 2013-10-17 07:28:26 UTC (rev 58023)
+++ grass/trunk/lib/python/temporal/sampling.py 2013-10-17 07:48:49 UTC (rev 58024)
@@ -42,13 +42,14 @@
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 @@
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:
Modified: grass/trunk/lib/temporal/lib/default_name.c
===================================================================
--- grass/trunk/lib/temporal/lib/default_name.c 2013-10-17 07:28:26 UTC (rev 58023)
+++ grass/trunk/lib/temporal/lib/default_name.c 2013-10-17 07:48:49 UTC (rev 58024)
@@ -38,29 +38,11 @@
*/
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);
}
More information about the grass-commit
mailing list