[GRASS-SVN] r34540 - grass/branches/develbranch_6/scripts/db.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 27 12:11:52 EST 2008


Author: neteler
Date: 2008-11-27 12:11:52 -0500 (Thu, 27 Nov 2008)
New Revision: 34540

Modified:
   grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr
Log:
bugfix for key parameter which never worked so far

Modified: grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr
===================================================================
--- grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr	2008-11-27 16:39:38 UTC (rev 34539)
+++ grass/branches/develbranch_6/scripts/db.in.ogr/db.in.ogr	2008-11-27 17:11:52 UTC (rev 34540)
@@ -5,7 +5,7 @@
 # MODULE:       db.in.ogr
 # AUTHOR(S):   	Markus Neteler
 # PURPOSE:      imports attribute tables in various formats
-# COPYRIGHT:    (C) 2007 by Markus Neteler and the GRASS Development Team
+# COPYRIGHT:    (C) 2007, 2008 by Markus Neteler and the GRASS Development Team
 #
 #               This program is free software under the GNU General Public
 #               License (>=v2). Read the file COPYING that comes with GRASS
@@ -100,7 +100,7 @@
   fi
 else
   # user gave --o
-  echo "DROP TABLE ${GIS_OPT_OUTPUT}" | db.execute
+  db.droptable -f --q ${GIS_OPT_OUTPUT} >/dev/null 2>/dev/null
 fi
 
 # treat DB as real vector map...
@@ -109,9 +109,10 @@
 fi
 
 # check ERRORs and cat and cat_ issues (maybe problem with translated messages)
-WARNING="`v.in.ogr --q dsn=\"$GIS_OPT_DSN\" $LAYER out=$GIS_OPT_OUTPUT -o 2>&1 | grep 'ERROR\|cat' | grep -v 'truncated'`"
-#if [ $? -ne 0 ] ;  then
+# we import faking a map which generates only the attribute table:
+WARNING="`v.in.ogr --q dsn=\"$GIS_OPT_DSN\" $LAYER out=$GIS_OPT_OUTPUT -o --o 2>&1 | grep -i 'ERROR\|cat' | grep -v 'truncated'`"
 if [ ! -z "$WARNING" ] ; then
+   echo "$WARNING"
    if [ ! -z "$GIS_OPT_DB_TABLE" ] ; then
       g.message -e "Input DSN <$INPUT> not found or not readable"
    else
@@ -120,9 +121,10 @@
    exit 1
 fi
 
-# rename ID col if requested from cat to new name
+# rename "key"  col if requested from "cat" (generated by v.in.ogr) to new name:
 if [ ! -z ${GIS_OPT_KEY} ] ; then
-   v.db.renamecol --q $GIS_OPT_OUTPUT layer=1 column=cat,${GIS_OPT_KEY} 2> /dev/null > /dev/null
+   echo "ALTER TABLE $GIS_OPT_OUTPUT ADD COLUMN $GIS_OPT_KEY integer" | db.execute
+   echo "UPDATE $GIS_OPT_OUTPUT SET $GIS_OPT_KEY=cat" | db.execute
 fi
 
 # ... and immediately drop the empty geometry
@@ -143,5 +145,5 @@
 
 RECORDS=`db.describe -c $GIS_OPT_OUTPUT | grep '^nrows' | sed 's+ ++g' | cut -d':' -f2`
 g.message "Imported table <$GIS_OPT_OUTPUT> with $RECORDS rows"
+
 exit 0
-



More information about the grass-commit mailing list