[GRASS-dev] [GRASS-SVN] r60596 - grass/trunk/vector/v.in.ogr

Anna Petrášová kratochanna at gmail.com
Fri Sep 5 20:54:46 PDT 2014


On Fri, May 30, 2014 at 12:46 AM, <svn_grass at osgeo.org> wrote:

> Author: hcho
> Date: 2014-05-29 21:46:55 -0700 (Thu, 29 May 2014)
> New Revision: 60596
>
> Modified:
>    grass/trunk/vector/v.in.ogr/main.c
> Log:
> v.in.ogr: fallback datetime type for pg and dbf drivers
>
> Modified: grass/trunk/vector/v.in.ogr/main.c
> ===================================================================
> --- grass/trunk/vector/v.in.ogr/main.c  2014-05-30 04:01:53 UTC (rev 60595)
> +++ grass/trunk/vector/v.in.ogr/main.c  2014-05-30 04:46:55 UTC (rev 60596)
> @@ -103,6 +103,8 @@
>      int OFTIntegerListlength;
>
>      char *dsn;
> +    const char *driver_name;
> +    char *datetime_type;
>      char *output;
>      char **layer_names;                /* names of layers to be imported
> */
>      int *layers;               /* layer indexes */
> @@ -336,9 +338,18 @@
>         G_fatal_error(_("Required parameter <%s> not set"),
> param.dsn->key);
>      }
>
> +    driver_name = db_get_default_driver_name();
> +
> +    if (strcmp(driver_name, "pg") == 0)
> +       datetime_type = G_store("timestamp with time zone");
> +    else if (strcmp(driver_name, "dbf") == 0)
> +       datetime_type = G_store("varchar(22)");
> +    else
> +       datetime_type = G_store("datetime");
> +
>      /* dsn is 'PG:', check default connection settings */
>      dsn = NULL;
> -    if (strcmp(db_get_default_driver_name(), "pg") == 0 &&
> +    if (strcmp(driver_name, "pg") == 0 &&
>          G_strcasecmp(param.dsn->answer, "PG:") == 0) {
>          const char *dbname;
>          dbConnection conn;
> @@ -1010,7 +1021,7 @@
>                     sprintf(buf, ", %s time", Ogr_fieldname);
>                 }
>                 else if (Ogr_ftype == OFTDateTime) {
> -                   sprintf(buf, ", %s datetime", Ogr_fieldname);
> +                   sprintf(buf, ", %s %s", Ogr_fieldname, datetime_type);
>  #endif
>                 }
>                 else if (Ogr_ftype == OFTString) {
>
> _______________________________________________
> grass-commit mailing list
> grass-commit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-commit
>


Hi,

this revision broke running v.in.ogr during creating a new location with
Location Wizard based on georeferenced file (e.g. shapefile). User is asked
if he wants to also import the data into that location and then it fails
because v.in.ogr crashes. The problem is on line

driver_name = db_get_default_driver_name();

driver_name seems to be NULL. Running the same v.in.ogr command after
starting normal grass session works. Is there and initialization missing?

Thanks,

Anna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140905/6773ff07/attachment.html>


More information about the grass-dev mailing list