[GRASS-SVN] r50614 - grass/branches/develbranch_6/scripts/v.db.join
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Feb 1 08:56:19 EST 2012
Author: lucadelu
Date: 2012-02-01 05:56:19 -0800 (Wed, 01 Feb 2012)
New Revision: 50614
Modified:
grass/branches/develbranch_6/scripts/v.db.join/description.html
grass/branches/develbranch_6/scripts/v.db.join/v.db.join
Log:
fix problems with c and a flag; improve documentation
Modified: grass/branches/develbranch_6/scripts/v.db.join/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.join/description.html 2012-02-01 10:45:01 UTC (rev 50613)
+++ grass/branches/develbranch_6/scripts/v.db.join/description.html 2012-02-01 13:56:19 UTC (rev 50614)
@@ -62,6 +62,20 @@
4|BcB|4|BcB|Boneek silt loam, 2 to 6
5|BcC|5|BcC|Boneek silt loam, 6 to 9
...
+
+# join soils_legend into mysoils attribute table, escape shortname column that it is a duplicate of label; it add also _o suffix for the columns contained by soils_legend table
+g.copy vect=soils,mysoils_ac
+v.db.join -ac mysoils col=label otable=soils_legend ocol=shortname
+
+# verification of join
+v.db.select mysoils_ac
+cat|label|id|longname_o
+1|Aab|||
+2|Ba|2|Barnum silt loam
+3|Bb|3|Barnum silt loam, channeled
+4|BcB|4|Boneek silt loam, 2 to 6
+5|BcC|5|Boneek silt loam, 6 to 9
+
</pre></div>
<h2>SEE ALSO</h2>
Modified: grass/branches/develbranch_6/scripts/v.db.join/v.db.join
===================================================================
--- grass/branches/develbranch_6/scripts/v.db.join/v.db.join 2012-02-01 10:45:01 UTC (rev 50613)
+++ grass/branches/develbranch_6/scripts/v.db.join/v.db.join 2012-02-01 13:56:19 UTC (rev 50614)
@@ -25,7 +25,8 @@
#%flag
#% key: a
-#% description: Copy all the columns from other table to map
+#% label: Add suffix _o for the columns of otable
+#% description: Add suffix _o for the columns of otable; it is useful if you have columns with the same name in the two tables
#%end
#%option
@@ -132,25 +133,18 @@
elif [ "$GIS_FLAG_A" -eq 1 ] ; then
col="${col}_other"
fi
- if [ "$GIS_FLAG_C" -eq 1 ] && [ "$col" = "$GIS_OPT_OCOLUMN" ] ; then
- continue
- else
- v.db.addcol "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" \
- col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
- fi
+ v.db.addcol "$GIS_OPT_MAP" layer="$GIS_OPT_LAYER" \
+ col="$col `echo $COLTYPES | cut -d' ' -f$i | tr -s '_' ' '`"
+
if [ $? -ne 0 ] ; then
g.message -e "Column creation failed. Cannot continue."
exit 1
fi
-
- if [ "$GIS_FLAG_C" -eq 1 ] && [ "$col" = "$GIS_OPT_OCOLUMN" ] ; then
- continue
- else
- echo "UPDATE $maptable SET $col=(SELECT $col
- FROM $GIS_OPT_OTABLE WHERE $GIS_OPT_OTABLE.$GIS_OPT_OCOLUMN=$maptable.$GIS_OPT_COLUMN);" | \
- db.execute database="$database" driver="$driver"
- fi
+
+ echo "UPDATE $maptable SET $col=(SELECT $col
+ FROM $GIS_OPT_OTABLE WHERE $GIS_OPT_OTABLE.$GIS_OPT_OCOLUMN=$maptable.$GIS_OPT_COLUMN);" | \
+ db.execute database="$database" driver="$driver"
i=`expr $i + 1`
done
More information about the grass-commit
mailing list