[GRASS-dev] How to calculate log() in v.db.update with SQLite backend?

Markus Neteler neteler at osgeo.org
Thu Nov 20 01:53:45 PST 2014


Congrats, Moritz.

On Thu, Nov 20, 2014 at 9:22 AM, Moritz Lennert
<mlennert at club.worldonline.be> wrote:
> Below is a proposal after a very superficial reading of the docs and code,
> so no guarantees (and I cannot really test here since it seems enabled by
> default).
>
> However, this means that we enable this automatically for each sqlite db
> opened by GRASS...

Maybe an issue, maybe not. The sqlite3 cmd line software has it enabled, too.


> Index: db/drivers/sqlite/db.c
> ===================================================================
> --- db/drivers/sqlite/db.c      (révision 62792)
> +++ db/drivers/sqlite/db.c      (copie de travail)
> @@ -110,6 +110,9 @@
>         return DB_FAILED;
>      }
>
> +    /* enable loading of extensions */
> +    sqlite3_enable_load_extension(sqlite, 1);
> +
>      /* set the sqlite busy handler */
>      sqlite3_busy_handler(sqlite, sqlite_busy_callback, NULL);

Trying with my locally modified  v.db.update

GRASS 7.1.svn (nc_spm_08_grass7):~ > g.copy
vect=precip_30ynormals,myprecip_30ynormals

GRASS 7.1.svn (nc_spm_08_grass7):~ > v.db.addcolumn
myprecip_30ynormals column="logjuly double precision"

GRASS 7.1.svn (nc_spm_08_grass7):~ > v.db.update myprecip_30ynormals
column="logjuly" qcolumn="log(jul)"
sqliteextra=/home/neteler/software/sqlite_extensions/libsqlitefunctions.so

GRASS 7.1.svn (nc_spm_08_grass7):~ > v.db.select myprecip_30ynormals
columns=jul,logjuly
jul|logjuly
132.842|4.88916045210132
127|4.84418708645859
124.206|4.82194147751127
104.648|4.65060233738593
98.298|4.58800368106618
...

Works.

Markus


More information about the grass-dev mailing list