[GRASS-SVN] r40373 - grass/branches/releasebranch_6_4/scripts/v.db.addtable

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 11 20:38:32 EST 2010


Author: hamish
Date: 2010-01-11 20:38:31 -0500 (Mon, 11 Jan 2010)
New Revision: 40373

Modified:
   grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable
Log:
use the mapset's default DB instead of being locked to the one that layer 1 has used. (bug #809; merge from devbr6 r40336)

Modified: grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable
===================================================================
--- grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable	2010-01-11 06:43:22 UTC (rev 40372)
+++ grass/branches/releasebranch_6_4/scripts/v.db.addtable/v.db.addtable	2010-01-12 01:38:31 UTC (rev 40373)
@@ -14,7 +14,7 @@
 #############################################################################
 
 #%Module
-#%  description: Creates and adds a new attribute table to a given layer of an existing vector map.
+#%  description: Creates and connects a new attribute table to a given layer of an existing vector map.
 #%  keywords: vector, database, attribute table
 #%End
 #%option
@@ -121,27 +121,11 @@
 if [ $? -ne 0 ] ; then
    # nothing defined for layer 1
    g.message "Creating new DB connection based on default mapset settings..."
-   database=`db.connect -p | grep '^database' | cut -d':' -f2-`
-   driver=`db.connect -p | grep '^driver' | cut -d':' -f2`
-else
-   # there is a definition for layer 1, so we check for the user defined layer
-   # v.db.connect expands $VARIABLES, we want to keep them relative so use the raw file
-   eval `g.findfile elem="vector/$GIS_OPT_MAP" file=dbln`
-   if [ ! "$file" ] ; then
-      database=""
-   else
-      database=`grep -w "^$QUERYLAYER" "$file" | cut -f4- -d' ' | sed -e 's/ [^ ]*$//'`
-   fi
-
-   if [ -z "$database" ] ; then
-      #nothing on user defined layer, so we use the default mapset settings in this case:
-      database=`db.connect -p | grep '^database' | cut -d':' -f2-`
-      driver=`db.connect -p | grep '^driver' | cut -d':' -f2`
-   else
-       driver=`grep -w "^$QUERYLAYER" "$file" | sed -e 's/^.* \(.*\)$/\1/'`
-   fi
 fi
+database=`db.connect -p | grep '^database' | cut -d':' -f2-`
+driver=`db.connect -p | grep '^driver' | cut -d':' -f2`
 
+
 #maybe there is already a table linked to the selected layer?
 if [ "$GIS_OPT_LAYER" -eq 1 ] ; then
   v.db.connect "$GIS_OPT_MAP" -g 2> /dev/null | grep -w "^$GIS_OPT_LAYER" > /dev/null
@@ -176,7 +160,8 @@
        fi
    fi
 
-   echo "CREATE TABLE $table ($COLUMN_DEF)" | db.execute database="$database" driver="$driver"
+   echo "CREATE TABLE $table ($COLUMN_DEF)" | \
+      db.execute database="$database" driver="$driver"
    if [ $? -ne 0 ] ; then
      g.message -e "Cannot continue."
      exit 1



More information about the grass-commit mailing list