[GRASS-SVN] r44641 - in grass/branches/develbranch_6/scripts: d.vect.thematic v.db.addcol v.db.addtable v.db.dropcol v.db.droptable v.db.join v.db.renamecol v.db.update v.out.gpsbabel v.rast.stats v.report

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 20 23:59:12 EST 2010


Author: hamish
Date: 2010-12-20 20:59:12 -0800 (Mon, 20 Dec 2010)
New Revision: 44641

Modified:
   grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic
   grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol
   grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable
   grass/branches/develbranch_6/scripts/v.db.dropcol/v.db.dropcol
   grass/branches/develbranch_6/scripts/v.db.droptable/v.db.droptable
   grass/branches/develbranch_6/scripts/v.db.join/v.db.join
   grass/branches/develbranch_6/scripts/v.db.renamecol/v.db.renamecol
   grass/branches/develbranch_6/scripts/v.db.update/v.db.update
   grass/branches/develbranch_6/scripts/v.out.gpsbabel/v.out.gpsbabel
   grass/branches/develbranch_6/scripts/v.rast.stats/v.rast.stats
   grass/branches/develbranch_6/scripts/v.report/v.report
Log:
use v.db.connect -l to make sqlite table num/name happy (#1245)

Modified: grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic
===================================================================
--- grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/d.vect.thematic/d.vect.thematic	2010-12-21 04:59:12 UTC (rev 44641)
@@ -361,15 +361,14 @@
     export GRASS_PNG_AUTO_WRITE
 fi
 
-table=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
-database=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
-driver=`v.db.connect $GIS_OPT_MAP -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
+table=`v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f2 -d'|'`
+database=`v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f4 -d'|'`
+driver=`v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f5 -d'|'`
 
-if [ -z "$table" ]
-    then
+if [ -z "$table" ] ; then
     g.message -e message="No table connected or layer <$GIS_OPT_LAYER> does not exist."
     exit 1
- fi
+fi
 
 # update color values to the table?
 if [ "$GIS_FLAG_U" -eq 1 ] ; then

Modified: grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.db.addcol/v.db.addcol	2010-12-21 04:59:12 UTC (rev 44641)
@@ -87,14 +87,14 @@
    exit 1
 fi
 
-table=`v.db.connect "$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+table=`v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f2 -d'|'`
 if [ -z "$table" ] ; then
    g.message -e 'There is no table connected to this map! Run v.db.connect or v.db.addtable first.'
    exit 1
 fi
 
-database=`v.db.connect "$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
-driver=`v.db.connect "$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
+database=`v.db.connect "$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f4 -d'|'`
+driver=`v.db.connect "$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f5 -d'|'`
 
 colnum=`echo "$GIS_OPT_COLUMNS" | awk -F, '{print NF}'`
 

Modified: grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.db.addtable/v.db.addtable	2010-12-21 04:59:12 UTC (rev 44641)
@@ -116,8 +116,8 @@
 # check if DB parameters are set, and if not set them.
 db.connect -c
 
-#check if anything is connected:
-v.db.connect map="$GIS_OPT_MAP" -g  2> /dev/null | grep '^1 ' > /dev/null
+#check if anything is connected to layer 1:
+v.db.connect map="$GIS_OPT_MAP" -gl layer=1  2> /dev/null | grep -w '^1' > /dev/null
 if [ $? -ne 0 ] ; then
    # nothing defined for layer 1
    g.message "Creating new DB connection based on default mapset settings..."
@@ -128,7 +128,7 @@
 
 #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
+  v.db.connect "$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" 2> /dev/null | grep -w "^$GIS_OPT_LAYER" > /dev/null
   if [ $? -eq 0 ] ; then
      g.message -e "There is already a table linked to layer <$GIS_OPT_LAYER>" 
      exit 1

Modified: grass/branches/develbranch_6/scripts/v.db.dropcol/v.db.dropcol
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.dropcol/v.db.dropcol	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.db.dropcol/v.db.dropcol	2010-12-21 04:59:12 UTC (rev 44641)
@@ -93,21 +93,21 @@
 : ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
 
 # does map exist in CURRENT mapset?
-eval `g.findfile element=vector file=$GIS_OPT_MAP mapset=$MAPSET`
+eval `g.findfile element=vector file="$GIS_OPT_MAP" mapset="$MAPSET"`
 if [ ! "$file" ] ; then
    g.message -e "Vector map <$GIS_OPT_MAP> not found in current mapset"
    exit 1
 fi
 
-table=`v.db.connect map=$GIS_OPT_MAP -g fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f2 -d";"`
+table=`v.db.connect map="$GIS_OPT_MAP" -gl layer="$GIS_OPT_LAYER" fs="|" | cut -f2 -d"|"`
 if [ -z "$table" ] ; then
    g.message -e 'There is no table connected to the input vector map! Cannot delete any column'
    cleanup
    exit 1
 fi
-keycol=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w "^$GIS_OPT_LAYER" | cut -f3 -d';'`
-database=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w "^$GIS_OPT_LAYER" | cut -f4 -d';'`
-driver=`v.db.connect -g fs=";" map=$GIS_OPT_MAP | grep -w "^$GIS_OPT_LAYER" | cut -f5 -d';'`
+keycol=`v.db.connect -gl fs="|" map="$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" | cut -f3 -d'|'`
+database=`v.db.connect -gl fs="|" map="$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" | cut -f4 -d'|'`
+driver=`v.db.connect -gl fs="|" map="$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" | cut -f5 -d'|'`
 col="$GIS_OPT_COLUMN"
 
 if [ "$col" = "$keycol" ] ; then

Modified: grass/branches/develbranch_6/scripts/v.db.droptable/v.db.droptable
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.droptable/v.db.droptable	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.db.droptable/v.db.droptable	2010-12-21 04:59:12 UTC (rev 44641)
@@ -78,7 +78,7 @@
        g.message -e "An error occured while running v.db.connect"
        exit 1
     fi
-    table=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+    table=`v.db.connect map="$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f2 -d'|'`
     if [ -z "$table" ] ; then
        g.message -e "No table assigned to layer <$GIS_OPT_LAYER>"
        exit 1
@@ -86,7 +86,7 @@
     # Removing table name connected to selected layer
 else
     # Removing user specified table
-    existingtable=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+    existingtable=`v.db.connect map="$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f2 -d'|'`
     table="$GIS_OPT_TABLE"
     if [ "$existingtable" != "$table" ] ; then
        g.message -e "User selected table <$table> but the table <$existingtable> is linked to layer <$GIS_OPT_LAYER>" 
@@ -100,8 +100,8 @@
    g.message -e "An error occured while running v.db.connect" 
    exit 1
 fi
-database=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
-driver=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
+database=`v.db.connect map="$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f4 -d'|'`
+driver=`v.db.connect map="$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f5 -d'|'`
 
 g.message "Removing table <$table> linked to layer <$GIS_OPT_LAYER> of vector map <$GIS_OPT_MAP>" 
 

Modified: grass/branches/develbranch_6/scripts/v.db.join/v.db.join
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.join/v.db.join	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.db.join/v.db.join	2010-12-21 04:59:12 UTC (rev 44641)
@@ -77,15 +77,15 @@
 
 PROG=`basename $0`
 
-driver=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep "^$GIS_OPT_LAYER" | cut -d';' -f5`
-database=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep "^$GIS_OPT_LAYER" | cut -d';' -f4`
+database=`v.db.connect -gl map="$GIS_OPT_MAP" fs="|" layer="$GIS_OPT_LAYER" | cut -d'|' -f4`
+driver=`v.db.connect -gl map="$GIS_OPT_MAP" fs="|" layer="$GIS_OPT_LAYER" | cut -d'|' -f5`
 
 if [ "$driver" = "dbf" ] ; then
    g.message -e "JOIN is not supported for tables stored in DBF format."
    exit 1
 fi
 
-maptable=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep "^$GIS_OPT_LAYER" | cut -d';' -f2`
+maptable=`v.db.connect -gl map="$GIS_OPT_MAP" fs="|" layer="$GIS_OPT_LAYER" | cut -d'|' -f2`
 
 if [ -z "$maptable" ] ; then
    g.message 'There is no table connected to this map! Cannot join any column.'

Modified: grass/branches/develbranch_6/scripts/v.db.renamecol/v.db.renamecol
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.renamecol/v.db.renamecol	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.db.renamecol/v.db.renamecol	2010-12-21 04:59:12 UTC (rev 44641)
@@ -90,15 +90,15 @@
    exit 1
 fi
 
-table="`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f2 -d';'`"
+table=`v.db.connect -gl map="$GIS_OPT_MAP" fs="|" layer="$GIS_OPT_LAYER" | cut -f2 -d'|'`
 if [ -z "$table" ] ; then
    g.message -e 'There is no table connected to the input vector map! Cannot rename any column'
    exit 1
 fi
 
-keycol=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f3 -d';'`
-database="`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w ^$GIS_OPT_LAYER | cut -f4 -d';'`"
-driver=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$GIS_OPT_LAYER" | cut -f5 -d';'`
+keycol=`v.db.connect -gl map="$GIS_OPT_MAP" fs="|" layer="$GIS_OPT_LAYER" | cut -f3 -d'|'`
+database="`v.db.connect -gl map="$GIS_OPT_MAP" fs='|' layer=$GIS_OPT_LAYER | cut -f4 -d'|'`"
+driver=`v.db.connect -gl map="$GIS_OPT_MAP" fs="|" layer="$GIS_OPT_LAYER" | cut -f5 -d'|'`
 oldcol="`echo $GIS_OPT_COLUMN | cut -d',' -f1`"
 newcol="`echo $GIS_OPT_COLUMN | cut -d',' -f2`"
 

Modified: grass/branches/develbranch_6/scripts/v.db.update/v.db.update
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.update/v.db.update	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.db.update/v.db.update	2010-12-21 04:59:12 UTC (rev 44641)
@@ -99,14 +99,14 @@
    exit 1
 fi
 
-table=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+table=`v.db.connect map="$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f2 -d'|'`
 if [ -z "$table" ] ; then
    g.message -e 'There is no table connected to this map! Run v.db.connect or v.db.addtable first.'
    exit 1
 fi
 
-database=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $4}'`
-driver=`v.db.connect map="$GIS_OPT_MAP" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $5}'`
+database=`v.db.connect map="$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f4 -d'|'`
+driver=`v.db.connect map="$GIS_OPT_MAP" -gl fs="|" layer="$GIS_OPT_LAYER" | cut -f5 -d'|'`
 
 # checking column types
 coltype=`v.info -c map="$GIS_OPT_MAP" layer=$GIS_OPT_LAYER --quiet | grep -w "$GIS_OPT_COLUMN" | cut -d'|' -f1`

Modified: grass/branches/develbranch_6/scripts/v.out.gpsbabel/v.out.gpsbabel
===================================================================
--- grass/branches/develbranch_6/scripts/v.out.gpsbabel/v.out.gpsbabel	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.out.gpsbabel/v.out.gpsbabel	2010-12-21 04:59:12 UTC (rev 44641)
@@ -266,7 +266,7 @@
 
 # don't v.db.connect directly as source table will be removed with
 # temporary map in that case. So we make a temp copy of it to work with.
-DB_PARAMS=`v.db.connect -g "$INMAP" fs='|' 2> /dev/null | grep "^$GIS_OPT_LAYER "`
+DB_PARAMS=`v.db.connect -gl map="$INMAP" fs='|' layer="$GIS_OPT_LAYER" 2> /dev/null`
 if [ -n "$DB_PARAMS" ] ; then
    DB_TABLE=`echo "$DB_PARAMS" | cut -f2 -d'|'`
    DB_KEY=`echo "$DB_PARAMS" | cut -f3 -d'|'`

Modified: grass/branches/develbranch_6/scripts/v.rast.stats/v.rast.stats
===================================================================
--- grass/branches/develbranch_6/scripts/v.rast.stats/v.rast.stats	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.rast.stats/v.rast.stats	2010-12-21 04:59:12 UTC (rev 44641)
@@ -198,8 +198,8 @@
 
 #check if DBF driver used, in this case cut to 10 chars col names:
 DBFDRIVER=0
-v.db.connect -g "$VECTOR" fs=";" | grep -w "^$GIS_OPT_LAYER" | \
-   cut -d';' -f5 | grep -i dbf -q
+v.db.connect -gl map="$VECTOR" fs="|" layer="$GIS_OPT_LAYER" | \
+   cut -d'|' -f5 | grep -i 'dbf' -q
 if [ $? -eq 0 ] ; then
    DBFDRIVER=1
 else
@@ -219,14 +219,14 @@
 fi
 
 # we need this for non-DBF driver:
-DB_SQLDRIVER=`v.db.connect -g "$VECTOR" fs=";" | cut -d';' -f5`
+DB_SQLDRIVER=`v.db.connect -gl map="$VECTOR" fs="|" layer="$GIS_OPT_LAYER" | cut -d'|' -f5`
 g.message -d message="sql driver: [$DB_SQLDRIVER]"
 
-DB_DATABASE="`v.db.connect -g "$VECTOR" fs=";" | cut -d';' -f4`"
+DB_DATABASE="`v.db.connect -gl map=$VECTOR fs='|' layer=$GIS_OPT_LAYER | cut -d'|' -f4`"
 g.message -d message="database: [$DB_DATABASE]"
 
 #Find out which table is linked to the vector map on the given layer
-TABLE=`v.db.connect map="$VECTOR" -g fs=";" | grep -w "^$GIS_OPT_LAYER" | awk -F ";" '{print $2}'`
+TABLE=`v.db.connect map="$VECTOR" -gl fs='|' layer="$GIS_OPT_LAYER" | cut -d'|' -f2`
 if [ -z "$TABLE" ] ; then
    g.message -e 'There is no table connected to this map! Run v.db.connect or v.db.addtable first.'
    exit 1

Modified: grass/branches/develbranch_6/scripts/v.report/v.report
===================================================================
--- grass/branches/develbranch_6/scripts/v.report/v.report	2010-12-20 12:18:32 UTC (rev 44640)
+++ grass/branches/develbranch_6/scripts/v.report/v.report	2010-12-21 04:59:12 UTC (rev 44641)
@@ -143,7 +143,7 @@
 if [ $TABLEEXISTS -eq 1 ] ; then
    v.db.select -c map="$MAP" layer="$LAYER" | sort -n -t'|' -k 1 | grep -v '^0' > "$TMP1"
    if [ `wc -l "$TMP1" | awk '{print $1}'` -eq 0 ] ; then
-      KEY=`v.db.connect -g map="$GIS_OPT_MAP" fs=";" | grep -w "^$LAYER" | cut -f3 -d';'`
+      KEY=`v.db.connect -gl map="$GIS_OPT_MAP" fs="|" layer="$LAYER" | cut -f3 -d'|'`
       g.message -e "There is a table connected to input vector map '$MAP', but\
       there are no categories present in the key column '$KEY'. Consider using\
       v.to.db to correct this."



More information about the grass-commit mailing list