[GRASS-SVN] r32779 - in grass-addons/raster/r.rast4d: . globals

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 15 09:06:14 EDT 2008


Author: neteler
Date: 2008-08-15 09:06:14 -0400 (Fri, 15 Aug 2008)
New Revision: 32779

Modified:
   grass-addons/raster/r.rast4d/globals/defines.sh
   grass-addons/raster/r.rast4d/r.rast4d.init
Log:
(commented) postgresql support

Modified: grass-addons/raster/r.rast4d/globals/defines.sh
===================================================================
--- grass-addons/raster/r.rast4d/globals/defines.sh	2008-08-15 13:05:07 UTC (rev 32778)
+++ grass-addons/raster/r.rast4d/globals/defines.sh	2008-08-15 13:06:14 UTC (rev 32779)
@@ -9,13 +9,18 @@
 export GRAST4D_BASE=${GISDBASE}/${LOCATION_NAME}/${MAPSET}
 export GRAST4D_DB_DIR="$GRAST4D_BASE/rast4d_db"
 
-##############################à
+##############################
 export GRAST4D_BIN_DIR="${GISBASE}/etc/r.rast4d/bin"
 export GRAST4D_LIB_DIR="${GISBASE}/etc/r.rast4d/lib"
 export GRAST4D_SQL_DIR="${GISBASE}/etc/r.rast4d/sql"
+export PATH=$GRAST4D_BIN_DIR:$PATH
+# SQLite:
 export GRAST4D_DATABASE=$GRAST4D_DB_DIR/database.sqlite
-export PATH=$GRAST4D_BIN_DIR:$PATH
 export GRAST4D_DBM="sqlite3"
+# PostgreSQL:
+#export PGDB=rast4d_database
+#export GRAST4D_DATABASE="-h localhost -p 5432 -U $USER $PGDB"
+#export GRAST4D_DBM="psql"
 
 # Table name definitions
 export GRASTER_VIEW_NAME="raster_view"

Modified: grass-addons/raster/r.rast4d/r.rast4d.init
===================================================================
--- grass-addons/raster/r.rast4d/r.rast4d.init	2008-08-15 13:05:07 UTC (rev 32778)
+++ grass-addons/raster/r.rast4d/r.rast4d.init	2008-08-15 13:06:14 UTC (rev 32779)
@@ -11,10 +11,25 @@
 
 source ${GISBASE}/etc/r.rast4d/globals/defines.sh
 
-if [ ! -f $GRAST4D_DATABASE ]
-  then
-  if [ ! -d ./db/ ]; then mkdir ./db/ ; fi
-  ${GISBASE}/etc/r.rast4d/bin/init_db.sh
+if [ "$GRAST4D_DBM" = "sqlite3" ] ; then
+   if [ ! -f $GRAST4D_DATABASE ] ; then
+      if [ ! -d ./db/ ]; then mkdir ./db/ ; fi
+         echo "Initializing SQLite db..."
+         ${GISBASE}/etc/r.rast4d/bin/init_db.sh
+      else
+         echo "$GRAST4D_DATABASE already exists. Doing nothing. Remove that DB file to start over"
+   fi
 else
-  echo "$GRAST4D_DATABASE already exists. Doing nothing. Remove that DB file to start over"
+   psql -l | grep $PGDB > /dev/null
+   if [ $? -ne 0 ] ; then
+     # TODO: implement psql magic to call 'createdb'
+     echo "ERROR: PostgreSQL database <$PGDB> does not exist. Run 'createdb $PGDB' as appropriate."
+     exit 1
+   else
+     echo "Initializing PostgreSQL database..."
+     ${GISBASE}/etc/r.rast4d/bin/init_db.sh
+   fi
 fi
+echo "Done. Now you can use the tg.* commands."
+
+exit 0



More information about the grass-commit mailing list