[GRASS-SVN] r31789 - in grass-addons/raster/r.rast4d: . bin globals
lib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jun 21 16:56:25 EDT 2008
Author: neteler
Date: 2008-06-21 16:56:25 -0400 (Sat, 21 Jun 2008)
New Revision: 31789
Added:
grass-addons/raster/r.rast4d/Makefile
Modified:
grass-addons/raster/r.rast4d/QuickStart.txt
grass-addons/raster/r.rast4d/bin/init_db.sh
grass-addons/raster/r.rast4d/bin/tg.list
grass-addons/raster/r.rast4d/bin/tg.remove
grass-addons/raster/r.rast4d/bin/tg.update
grass-addons/raster/r.rast4d/globals/defines.sh
grass-addons/raster/r.rast4d/lib/insert_raster.sh
grass-addons/raster/r.rast4d/lib/remove_raster.sh
grass-addons/raster/r.rast4d/r.rast4d.init
Log:
Makefile added. Related variables fixed
Added: grass-addons/raster/r.rast4d/Makefile
===================================================================
--- grass-addons/raster/r.rast4d/Makefile (rev 0)
+++ grass-addons/raster/r.rast4d/Makefile 2008-06-21 20:56:25 UTC (rev 31789)
@@ -0,0 +1,21 @@
+MODULE_TOPDIR = ../..
+
+PGM1=r.rast4d.init
+PGM2=tg.update
+PGM3=tg.list
+PGM4=tg.remove
+PGM5=init_db.sh
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default:
+ $(INSTALL) ${PGM1} bin/${PGM2} bin/${PGM3} bin/${PGM4} $(GISBASE)/scripts/
+ if [ ! -d $(ETC)/r.rast4d ]; then $(MKDIR) $(ETC)/r.rast4d ; fi
+ if [ ! -d $(ETC)/r.rast4d/globals ]; then $(MKDIR) $(ETC)/r.rast4d/globals ; fi
+ if [ ! -d $(ETC)/r.rast4d/sql ]; then $(MKDIR) $(ETC)/r.rast4d/sql ; fi
+ if [ ! -d $(ETC)/r.rast4d/lib ]; then $(MKDIR) $(ETC)/r.rast4d/lib ; fi
+ if [ ! -d $(ETC)/r.rast4d/bin ]; then $(MKDIR) $(ETC)/r.rast4d/bin ; fi
+ $(INSTALL) bin/${PGM5} $(ETC)/r.rast4d/bin/
+ $(INSTALL) lib/*.sh $(ETC)/r.rast4d/lib
+ $(INSTALL_DATA) globals/defines.sh $(ETC)/r.rast4d/globals/
+ $(INSTALL_DATA) sql/create_* $(ETC)/r.rast4d/sql/
Property changes on: grass-addons/raster/r.rast4d/Makefile
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: grass-addons/raster/r.rast4d/QuickStart.txt
===================================================================
--- grass-addons/raster/r.rast4d/QuickStart.txt 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/QuickStart.txt 2008-06-21 20:56:25 UTC (rev 31789)
@@ -9,22 +9,22 @@
this is very important!
The sqlite3 database will be created in the ./db/ directory.
Use a graphical frontend to explore the database structure or read the
-code in the sql directory.
+code in the sql directory (e.g., sqlitebrowser or the Firefox SQLite addon).
-* ./r.rast4d.init
+* r.rast4d.init
Start r.rast4d.init to create the database,
- if the database already exists, nothing will be performed
- if you want to create a new database just remove the one in
the ./db/ directory and run r.rast4d.init again
-* bin/tg.update
+* tg.update
Use tg.update to register/update your raster maps in the sqlite table
-* bin/tg.list
+* tg.list
Use tg.list to show the registered maps, performe sql where statements on the view
and use the order option to order your data
-* bin/tg.remove
+* tg.remove
Remove the raster map entries from the database
The maps are not removed from grass!
@@ -36,12 +36,12 @@
Then (we assume a wildcard for raster names):
for i in `g.mlist type=rast pat="rastname*"` ; do
- bin/tg.update $i
+ tg.update $i
done
###########################################
Sören Gebbert
-to Markus, me
+to neteler at itc it
Apr 5 2007
Fertig,
Modified: grass-addons/raster/r.rast4d/bin/init_db.sh
===================================================================
--- grass-addons/raster/r.rast4d/bin/init_db.sh 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/bin/init_db.sh 2008-06-21 20:56:25 UTC (rev 31789)
@@ -1,15 +1,15 @@
-#!/bin/sh
+#!/bin/sh -x
#this script creates the database tables needed to store raster and temporal map informations
#create the raster and temporal tables
-cat $SQL_DIR/create_raster_table.sql | sed s/TABLE_NAME/$RASTER_TABLE_NAME/ | $DBM $DATABASE
-cat $SQL_DIR/create_raster_time_table.sql | sed s/TABLE_NAME/$RASTER_TIME_TABLE_NAME/ | $DBM $DATABASE
-cat $SQL_DIR/create_raster_metadata_table.sql | sed s/TABLE_NAME/$RASTER_METADATA_TABLE_NAME/ | $DBM $DATABASE
-cat $SQL_DIR/create_temporal_raster_table.sql | sed s/TABLE_NAME/$TEMPORAL_RASTER_TABLE_NAME/ | $DBM $DATABASE
-cat $SQL_DIR/create_temporal_raster_metadata_table.sql | sed s/TABLE_NAME/$TEMPORAL_RASTER_METADATA_TABLE_NAME/ | $DBM $DATABASE
+cat $GRAST4D_SQL_DIR/create_raster_table.sql | sed s/TABLE_NAME/$GRASTER_TABLE_NAME/ | $GRAST4D_DBM $GRAST4D_DATABASE
+cat $GRAST4D_SQL_DIR/create_raster_time_table.sql | sed s/TABLE_NAME/$GRASTER_TIME_TABLE_NAME/ | $GRAST4D_DBM $GRAST4D_DATABASE
+cat $GRAST4D_SQL_DIR/create_raster_metadata_table.sql | sed s/TABLE_NAME/$GRASTER_METADATA_TABLE_NAME/ | $GRAST4D_DBM $GRAST4D_DATABASE
+cat $GRAST4D_SQL_DIR/create_temporal_raster_table.sql | sed s/TABLE_NAME/$GTEMPORAL_RASTER_TABLE_NAME/ | $GRAST4D_DBM $GRAST4D_DATABASE
+cat $GRAST4D_SQL_DIR/create_temporal_raster_metadata_table.sql | sed s/TABLE_NAME/$GTEMPORAL_RASTER_METADATA_TABLE_NAME/ | $GRAST4D_DBM $GRAST4D_DATABASE
# create the raster view
-echo "create view $RASTER_VIEW_NAME as select * from $RASTER_TABLE_NAME, $RASTER_TIME_TABLE_NAME, $RASTER_METADATA_TABLE_NAME where $RASTER_TABLE_NAME.name = $RASTER_TIME_TABLE_NAME.name AND $RASTER_TABLE_NAME.name = $RASTER_TIME_TABLE_NAME.name AND $RASTER_METADATA_TABLE_NAME.name = $RASTER_TIME_TABLE_NAME.name;" | $DBM $DATABASE
+echo "create view $GRASTER_VIEW_NAME as select * from $GRASTER_TABLE_NAME, $GRASTER_TIME_TABLE_NAME, $GRASTER_METADATA_TABLE_NAME where $GRASTER_TABLE_NAME.name = $GRASTER_TIME_TABLE_NAME.name AND $GRASTER_TABLE_NAME.name = $GRASTER_TIME_TABLE_NAME.name AND $GRASTER_METADATA_TABLE_NAME.name = $GRASTER_TIME_TABLE_NAME.name;" | $GRAST4D_DBM $GRAST4D_DATABASE
#register trigger functions
Modified: grass-addons/raster/r.rast4d/bin/tg.list
===================================================================
--- grass-addons/raster/r.rast4d/bin/tg.list 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/bin/tg.list 2008-06-21 20:56:25 UTC (rev 31789)
@@ -63,9 +63,14 @@
fi
fi
-source globals/defines.sh
-echo "select $GIS_OPT_SELECTION from $RASTER_VIEW_NAME where $GIS_OPT_WHERE order by $GIS_OPT_ORDER"
-$DBM $DATABASE "select $GIS_OPT_SELECTION from $RASTER_VIEW_NAME where $GIS_OPT_WHERE order by $GIS_OPT_ORDER"
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+source ${GISBASE}/etc/r.rast4d/globals/defines.sh
+
+echo "select $GIS_OPT_SELECTION from $GRASTER_VIEW_NAME where $GIS_OPT_WHERE order by $GIS_OPT_ORDER"
+$GRAST4D_DBM $GRAST4D_DATABASE "select $GIS_OPT_SELECTION from $GRASTER_VIEW_NAME where $GIS_OPT_WHERE order by $GIS_OPT_ORDER"
+
exit 0
Modified: grass-addons/raster/r.rast4d/bin/tg.remove
===================================================================
--- grass-addons/raster/r.rast4d/bin/tg.remove 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/bin/tg.remove 2008-06-21 20:56:25 UTC (rev 31789)
@@ -40,8 +40,12 @@
fi
# source some library functions
-source lib/remove_raster.sh
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+source ${GISBASE}/etc/r.rast4d/lib/remove_raster.sh
+
# remove the table entries
for i in `echo $GIS_OPT_INPUT | sed s/,/\ /g | xargs` ; do
remove_raster_map $i
Modified: grass-addons/raster/r.rast4d/bin/tg.update
===================================================================
--- grass-addons/raster/r.rast4d/bin/tg.update 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/bin/tg.update 2008-06-21 20:56:25 UTC (rev 31789)
@@ -40,8 +40,12 @@
fi
# source some library functions
-source lib/insert_raster.sh
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+source ${GISBASE}/etc/r.rast4d/lib/insert_raster.sh
+
echo $GIS_OPT_INPUT
# create/update the table entries
Modified: grass-addons/raster/r.rast4d/globals/defines.sh
===================================================================
--- grass-addons/raster/r.rast4d/globals/defines.sh 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/globals/defines.sh 2008-06-21 20:56:25 UTC (rev 31789)
@@ -1,27 +1,32 @@
#!/bin/sh
#definitions
-export BASE="`pwd`"
-export DB_DIR="$BASE/db"
-export BIN_DIR="$BASE/bin"
-export LIB_DIR="$BASE/lib"
-export SQL_DIR="$BASE/sql"
-export DATABASE=$DB_DIR/database.sqlite
-export PATH=$BIN_DIR:$PATH
-export DBM="sqlite3"
+export GRAST4D_BASE="`pwd`"
+export GRAST4D_DB_DIR="$GRAST4D_BASE/db"
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+
+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 GRAST4D_DATABASE=$GRAST4D_DB_DIR/database.sqlite
+export PATH=$GRAST4D_BIN_DIR:$PATH
+export GRAST4D_DBM="sqlite3"
+
# Table name definitions
-export RASTER_VIEW_NAME="raster_view"
-export RASTER_TABLE_NAME="raster_table"
-export RASTER_TIME_TABLE_NAME="raster_time_table"
-export RASTER_METADATA_TABLE_NAME="raster_metadata_table"
-export TEMPORAL_VIEW_NAME="temporal_view"
-export TEMPORAL_RASTER_TABLE_NAME="temporal_raster_table"
-export TEMPORAL_RASTER_METADATA_TABLE_NAME="temporal_raster_metadata_table"
+export GRASTER_VIEW_NAME="raster_view"
+export GRASTER_TABLE_NAME="raster_table"
+export GRASTER_TIME_TABLE_NAME="raster_time_table"
+export GRASTER_METADATA_TABLE_NAME="raster_metadata_table"
+export GTEMPORAL_VIEW_NAME="temporal_view"
+export GTEMPORAL_RASTER_TABLE_NAME="temporal_raster_table"
+export GTEMPORAL_RASTER_METADATA_TABLE_NAME="temporal_raster_metadata_table"
-export RASTER_REFERENCE_TABLE_PREFIX="raster_reference_table"
-export RASTER_GROUP_TABLE_PREFIX="raster_group_table"
-export RASTER_TEMPORAL_TABLE_PREFIX="raster_temporal_table"
-export RASTER_METADATA_TABLE_PREFIX="raster_metadata_table"
-export RASTER_CATEGORY_TABLE_PREFIX="raster_category_table"
+export GRASTER_REFERENCE_TABLE_PREFIX="raster_reference_table"
+export GRASTER_GROUP_TABLE_PREFIX="raster_group_table"
+export GRASTER_TEMPORAL_TABLE_PREFIX="raster_temporal_table"
+export GRASTER_METADATA_TABLE_PREFIX="raster_metadata_table"
+export GRASTER_CATEGORY_TABLE_PREFIX="raster_category_table"
Modified: grass-addons/raster/r.rast4d/lib/insert_raster.sh
===================================================================
--- grass-addons/raster/r.rast4d/lib/insert_raster.sh 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/lib/insert_raster.sh 2008-06-21 20:56:25 UTC (rev 31789)
@@ -1,8 +1,12 @@
#!/bin/sh
# functions to insert or update raster map entries to the grass sql database
-source globals/defines.sh
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+source ${GISBASE}/etc/r.rast4d/globals/defines.sh
+
#this var is used to store the computed sqlite timestamps
GLOBAL_DATE_VAR=""
@@ -34,37 +38,37 @@
BASE_MAP=""
COLOR="unknown"
CAT_NUM=""
-GROUP_TABLE="${RASTER_GROUP_TABLE_PREFIX}_${MAPNAME}"
-REFERENCE_TABLE="${RASTER_REFERENCE_TABLE_PREFIX}_${MAPNAME}"
-METADATA_TABLE="${RASTER_METADATA_TABLE_PREFIX}_${MAPNAME}"
-CATEGORY_TABLE="${RASTER_CATEGORY_TABLE_PREFIX}_${MAPNAME}"
-TEMPORAL_TABLE="${RASTER_TEMPORAL_TABLE_PREFIX}_${MAPNAME}"
+GROUP_TABLE="${GRASTER_GROUP_TABLE_PREFIX}_${MAPNAME}"
+REFERENCE_TABLE="${GRASTER_REFERENCE_TABLE_PREFIX}_${MAPNAME}"
+METADATA_TABLE="${GRASTER_METADATA_TABLE_PREFIX}_${MAPNAME}"
+CATEGORY_TABLE="${GRASTER_CATEGORY_TABLE_PREFIX}_${MAPNAME}"
+TEMPORAL_TABLE="${GRASTER_TEMPORAL_TABLE_PREFIX}_${MAPNAME}"
# get the number of cats
CAT_NUM=`r.info $MAPNAME | grep "Categories:" | awk '{print $9}'`
# create or update the database table
-STRING=`$DBM $DATABASE "select name from $RASTER_TABLE_NAME where name='$MAPNAME'"`
+STRING=`$GRAST4D_DBM $GRAST4D_DATABASE "select name from $GRASTER_TABLE_NAME where name='$MAPNAME'"`
if [ "$STRING" = "" ] ; then
- echo "INSERT NEW $RASTER_TABLE_NAME ENTRY $MAPNAME"
+ echo "INSERT NEW $GRASTER_TABLE_NAME ENTRY $MAPNAME"
SQL_DATATYPE_STRING="(name, base_map, reference_table, color, group_table, temporal_table, metadata_table, category_table, category_num)"
SQL_VALUE_STRING="('$MAPNAME', '$BASE_MAP', '$REFERENCE_TABLE','$COLOR', '$GROUP_TABLE', '$TEMPORAL_TABLE', '$METADATA_TABLE', '$CATEGORY_TABLE', '$CAT_NUM')"
- $DBM $DATABASE "INSERT INTO $RASTER_TABLE_NAME $SQL_DATATYPE_STRING values $SQL_VALUE_STRING"
+ $GRAST4D_DBM $GRAST4D_DATABASE "INSERT INTO $GRASTER_TABLE_NAME $SQL_DATATYPE_STRING values $SQL_VALUE_STRING"
#create the raster map tables
- #cat $SQL_DIR/create_name_list_table.sql | sed s/TABLE_NAME/$REFERENCE_TABLE/ | $DBM $DATABASE
- #cat $SQL_DIR/create_name_list_table.sql | sed s/TABLE_NAME/$GROUP_TABLE/ | $DBM $DATABASE
- #cat $SQL_DIR/create_name_list_table.sql | sed s/TABLE_NAME/$TEMPORAL_TABLE/ | $DBM $DATABASE
- #cat $SQL_DIR/create_raster_metadata_table.sql | sed s/TABLE_NAME/$METADATA_TABLE/ | $DBM $DATABASE
- #cat $SQL_DIR/create_raster_categorie_table.sql | sed s/TABLE_NAME/$CATEGORY_TABLE/ | $DBM $DATABASE
+ #cat $SQL_DIR/create_name_list_table.sql | sed s/TABLE_NAME/$REFERENCE_TABLE/ | $GRAST4D_DBM $GRAST4D_DATABASE
+ #cat $SQL_DIR/create_name_list_table.sql | sed s/TABLE_NAME/$GROUP_TABLE/ | $GRAST4D_DBM $GRAST4D_DATABASE
+ #cat $SQL_DIR/create_name_list_table.sql | sed s/TABLE_NAME/$TEMPORAL_TABLE/ | $GRAST4D_DBM $GRAST4D_DATABASE
+ #cat $SQL_DIR/create_raster_metadata_table.sql | sed s/TABLE_NAME/$METADATA_TABLE/ | $GRAST4D_DBM $GRAST4D_DATABASE
+ #cat $SQL_DIR/create_raster_categorie_table.sql | sed s/TABLE_NAME/$CATEGORY_TABLE/ | $GRAST4D_DBM $GRAST4D_DATABASE
else
- echo "UPDATE $RASTER_TABLE_NAME ENTRY $MAPNAME"
- $DBM $DATABASE "UPDATE $RASTER_TABLE_NAME SET base_map='$BASE_MAP' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $RASTER_TABLE_NAME SET color='$COLOR' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $RASTER_TABLE_NAME SET category_num='$CAT_NUM' WHERE name='$MAPNAME'"
+ echo "UPDATE $GRASTER_TABLE_NAME ENTRY $MAPNAME"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $GRASTER_TABLE_NAME SET base_map='$BASE_MAP' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $GRASTER_TABLE_NAME SET color='$COLOR' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $GRASTER_TABLE_NAME SET category_num='$CAT_NUM' WHERE name='$MAPNAME'"
fi
}
@@ -72,7 +76,7 @@
insert_raster_map_metadata ()
{
MAPNAME=$1
-METADATA_TABLE="${RASTER_METADATA_TABLE_NAME}"
+METADATA_TABLE="${GRASTER_METADATA_TABLE_NAME}"
PROJECTION=`g.proj -w`
ROWS=`r.info $MAPNAME | grep "Rows:" | awk '{print $3}'`
COLS=`r.info $MAPNAME | grep "Columns" | awk '{print $3}'`
@@ -112,35 +116,35 @@
# insert or update
-STRING=`$DBM $DATABASE "select name from $METADATA_TABLE where name='$MAPNAME'"`
+STRING=`$GRAST4D_DBM $GRAST4D_DATABASE "select name from $METADATA_TABLE where name='$MAPNAME'"`
if [ "$STRING" = "" ] ; then
echo "INSERT NEW $METADATA_TABLE ENTRY $MAPNAME"
SQL_DATATYPE_STRING="(name, projection, datatype, rows, cols, cell_num, north, south, west, east, ns_res,
ew_res, min, max, mtime, creator, data_source, comments, description, additional_data)"
SQL_VALUE_STRING="('$MAPNAME', '$PROJECTION', '$datatype', '$ROWS', '$COLS', '$CELLNUM', '$north', '$south', '$west', '$east',
'$nsres' , '$ewres', '$min', '$max', $MTIME, '$CREATOR', '$DATA_SOURCE', '$COMMENTS', '$DESCRIPTION' , '$ADDITIONAL_DATA')"
- $DBM $DATABASE "INSERT INTO $METADATA_TABLE $SQL_DATATYPE_STRING values $SQL_VALUE_STRING"
+ $GRAST4D_DBM $GRAST4D_DATABASE "INSERT INTO $METADATA_TABLE $SQL_DATATYPE_STRING values $SQL_VALUE_STRING"
else
echo "UPDATE $METADATA_TABLE ENTRY $MAPNAME"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET projection='$PROJECTION' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET datatype='$datatype' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET rows='$ROWS' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET cols='$COLS' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET cell_num='$CELLNUM' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET north='$north' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET south='$south' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET west='$west' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET east='$east' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET ns_res='$nsres' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET ew_res='$ewres' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET min='$min' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET max='$max' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET mtime=$MTIME WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET creator='$CREATOR' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET data_source='$DATA_SOURCE' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET comments='$COMMENTS' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET description='$DESCRIPTION' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $METADATA_TABLE SET additional_data='$ADDITIONAL_DATA' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET projection='$PROJECTION' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET datatype='$datatype' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET rows='$ROWS' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET cols='$COLS' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET cell_num='$CELLNUM' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET north='$north' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET south='$south' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET west='$west' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET east='$east' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET ns_res='$nsres' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET ew_res='$ewres' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET min='$min' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET max='$max' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET mtime=$MTIME WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET creator='$CREATOR' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET data_source='$DATA_SOURCE' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET comments='$COMMENTS' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET description='$DESCRIPTION' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $METADATA_TABLE SET additional_data='$ADDITIONAL_DATA' WHERE name='$MAPNAME'"
fi
}
@@ -175,21 +179,21 @@
#echo $VTIME_END
# insert or update
-STRING=`$DBM $DATABASE "select name from $RASTER_TIME_TABLE_NAME where name='$MAPNAME'"`
+STRING=`$GRAST4D_DBM $GRAST4D_DATABASE "select name from $GRASTER_TIME_TABLE_NAME where name='$MAPNAME'"`
if [ "$STRING" = "" ] ; then
- echo "INSERT NEW $RASTER_TIME_TABLE_NAME ENTRY $MAPNAME"
+ echo "INSERT NEW $GRASTER_TIME_TABLE_NAME ENTRY $MAPNAME"
SQL_DATATYPE_STRING="(name, ctime, mtime, vtime_start, vtime_end)"
SQL_VALUE_STRING="('$MAPNAME', '$CTIME', $MTIME, '$VTIME_START', $VTIME_END)"
- $DBM $DATABASE "INSERT INTO $RASTER_TIME_TABLE_NAME $SQL_DATATYPE_STRING values $SQL_VALUE_STRING"
+ $GRAST4D_DBM $GRAST4D_DATABASE "INSERT INTO $GRASTER_TIME_TABLE_NAME $SQL_DATATYPE_STRING values $SQL_VALUE_STRING"
else
- echo "UPDATE $RASTER_TIME_TABLE_NAME ENTRY $MAPNAME"
- $DBM $DATABASE "UPDATE $RASTER_TIME_TABLE_NAME SET ctime='$CTIME' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $RASTER_TIME_TABLE_NAME SET mtime=$MTIME WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $RASTER_TIME_TABLE_NAME SET vtime_start='$VTIME_START' WHERE name='$MAPNAME'"
- $DBM $DATABASE "UPDATE $RASTER_TIME_TABLE_NAME SET vtime_end=$VTIME_END WHERE name='$MAPNAME'"
+ echo "UPDATE $GRASTER_TIME_TABLE_NAME ENTRY $MAPNAME"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $GRASTER_TIME_TABLE_NAME SET ctime='$CTIME' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $GRASTER_TIME_TABLE_NAME SET mtime=$MTIME WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $GRASTER_TIME_TABLE_NAME SET vtime_start='$VTIME_START' WHERE name='$MAPNAME'"
+ $GRAST4D_DBM $GRAST4D_DATABASE "UPDATE $GRASTER_TIME_TABLE_NAME SET vtime_end=$VTIME_END WHERE name='$MAPNAME'"
fi
exit
}
Modified: grass-addons/raster/r.rast4d/lib/remove_raster.sh
===================================================================
--- grass-addons/raster/r.rast4d/lib/remove_raster.sh 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/lib/remove_raster.sh 2008-06-21 20:56:25 UTC (rev 31789)
@@ -1,16 +1,20 @@
#!/bin/sh
# functions to remove raster map entries to the grass sql database
-source globals/defines.sh
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+source ${GISBASE}/etc/r.rast4d/globals/defines.sh
+
remove_raster_map ()
{
MAPNAME=$1
-GROUP_TABLE="${RASTER_GROUP_TABLE_PREFIX}_${MAPNAME}"
-REFERENCE_TABLE="${RASTER_REFERENCE_TABLE_PREFIX}_${MAPNAME}"
-METADATA_TABLE="${RASTER_METADATA_TABLE_PREFIX}_${MAPNAME}"
-CATEGORY_TABLE="${RASTER_CATEGORY_TABLE_PREFIX}_${MAPNAME}"
-TEMPORAL_TABLE="${RASTER_TEMPORAL_TABLE_PREFIX}_${MAPNAME}"
+GROUP_TABLE="${GRASTER_GROUP_TABLE_PREFIX}_${MAPNAME}"
+REFERENCE_TABLE="${GRASTER_REFERENCE_TABLE_PREFIX}_${MAPNAME}"
+METADATA_TABLE="${GRASTER_METADATA_TABLE_PREFIX}_${MAPNAME}"
+CATEGORY_TABLE="${GRASTER_CATEGORY_TABLE_PREFIX}_${MAPNAME}"
+TEMPORAL_TABLE="${GRASTER_TEMPORAL_TABLE_PREFIX}_${MAPNAME}"
#$DBM $DATABASE "DROP TABLE $REFERENCE_TABLE"
#$DBM $DATABASE "DROP TABLE $METADATA_TABLE"
@@ -18,21 +22,21 @@
#$DBM $DATABASE "DROP TABLE $CATEGORY_TABLE"
#$DBM $DATABASE "DROP TABLE $TEMPORAL_TABLE"
-echo "REMOVE $MAPNAME FROM $RASTER_TABLE_NAME"
-$DBM $DATABASE "DELETE FROM $RASTER_TABLE_NAME WHERE name='$MAPNAME'"
+echo "REMOVE $MAPNAME FROM $GRASTER_TABLE_NAME"
+$GRAST4D_DBM $GRAST4D_DATABASE "DELETE FROM $GRASTER_TABLE_NAME WHERE name='$MAPNAME'"
}
remove_raster_map_metadata ()
{
MAPNAME=$1
-echo "REMOVE $MAPNAME FROM $RASTER_METADATA_TABLE_NAME"
-$DBM $DATABASE "DELETE FROM $RASTER_METADATA_TABLE_NAME WHERE name='$MAPNAME'"
+echo "REMOVE $MAPNAME FROM $GRASTER_METADATA_TABLE_NAME"
+$GRAST4D_DBM $GRAST4D_DATABASE "DELETE FROM $GRASTER_METADATA_TABLE_NAME WHERE name='$MAPNAME'"
}
remove_raster_map_time ()
{
MAPNAME=$1
-echo "REMOVE $MAPNAME FROM $RASTER_TIME_TABLE_NAME"
-$DBM $DATABASE "DELETE FROM $RASTER_TIME_TABLE_NAME WHERE name='$MAPNAME'"
+echo "REMOVE $MAPNAME FROM $GRASTER_TIME_TABLE_NAME"
+$GRAST4D_DBM $GRAST4D_DATABASE "DELETE FROM $GRASTER_TIME_TABLE_NAME WHERE name='$MAPNAME'"
}
Modified: grass-addons/raster/r.rast4d/r.rast4d.init
===================================================================
--- grass-addons/raster/r.rast4d/r.rast4d.init 2008-06-21 19:05:36 UTC (rev 31788)
+++ grass-addons/raster/r.rast4d/r.rast4d.init 2008-06-21 20:56:25 UTC (rev 31789)
@@ -1,10 +1,20 @@
#!/bin/sh
-source globals/defines.sh
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." >&2
+ exit 1
+fi
-if [ ! -f $DATABASE ]
+### setup enviro vars ###
+eval `g.gisenv`
+: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
+
+source ${GISBASE}/etc/r.rast4d/globals/defines.sh
+
+if [ ! -f $GRAST4D_DATABASE ]
then
- init_db.sh
+ if [ ! -d ./db/ ]; then mkdir ./db/ ; fi
+ ${GISBASE}/etc/r.rast4d/bin/init_db.sh
else
- echo "$DATABASE already exists. Doing nothing. Remove that DB file to start over"
+ echo "$GRAST4D_DATABASE already exists. Doing nothing. Remove that DB file to start over"
fi
More information about the grass-commit
mailing list