[GRASS-dev] QGIS winGRASS blank space problem

Hamish hamish_nospam at yahoo.com
Tue Jun 5 23:32:07 EDT 2007


Glynn Clements wrote:
> 
> Hamish wrote:
> 
> > > AFAICT, $SQLTMP is unnecessary. You can just as easily use a
> > > subshell with its output piped directly to db.execute; no need for
> > > a temporary file.
> > 
> > It is used in a loop- that would make it call db.execute nine times
> > per vector cat instead of once. db.execute is slow to start/stop, so
> > it is much faster to use a single call with $SQLTMP.
> 
> That's incorrect.
> 
> In terms of the number of times that db.execute is run, there is no
> difference between the existing code with a temporary file:

ah, I missed the "subshell", I thought you meant once per line.

still, a .tmp file is nice for debugging (even better if db.execute was
only run once), and it doesn't hurt much.


> Also, I would be inclined to clean up the above by looping over the
> column names i.e.:
> 
>  (
>   for var in n min max range mean stddev variance cf_var sum ; do
>   eval val=\${$var}
>   if [ $DBFDRIVER -eq 1 ] ; then
>    col="`echo ${COLPREFIX}_${var}| cut -b1-10`"
>   else
>    col="${COLPREFIX}_${var}"
>   fi
>   echo "UPDATE $VECTOR SET ${col}=${val} WHERE cat=$i;"
>  ) | db.execute database=$DB_DATABASE driver=$DB_SQLDRIVER

yes, but in that case you'd have to do something about cf_var:

> echo "UPDATE $VECTOR SET ${COLPREFIX}_cf_var=$coeff_var WHERE cat=$i;"

it was shortended from 'r.univar -g's coeff_var to work within DBF
column name width restrictions.


Hamish




More information about the grass-dev mailing list