[GRASS-SVN] r70342 - grass/trunk/vector/v.external
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 11 06:50:26 PST 2017
Author: martinl
Date: 2017-01-11 06:50:26 -0800 (Wed, 11 Jan 2017)
New Revision: 70342
Modified:
grass/trunk/vector/v.external/dsn.c
grass/trunk/vector/v.external/main.c
Log:
v.external: fix dsn handling (full / db-login-based connection strings)
Modified: grass/trunk/vector/v.external/dsn.c
===================================================================
--- grass/trunk/vector/v.external/dsn.c 2017-01-11 13:55:54 UTC (rev 70341)
+++ grass/trunk/vector/v.external/dsn.c 2017-01-11 14:50:26 UTC (rev 70342)
@@ -27,7 +27,7 @@
database[i] = '\0';
/* build connection string */
- sprintf(connect_str, "dbname=%s", database);
+ sprintf(connect_str, "%s", opt_dsn);
/* add db.login settings (user, password, host, port) */
if (DB_OK == db_get_login2("pg", database, &user, &passwd, &host, &port)) {
@@ -61,11 +61,15 @@
}
}
- if (!use_ogr)
- /* be friendly, ignored 'PG:' prefix for PostGIS links */
+ if (use_ogr) {
dsn = G_store(connect_str);
- else
- G_asprintf(&dsn, "PG:%s", connect_str);
+ }
+ else {
+ /* strip PG: prefix */
+ p = (char *)connect_str;
+ p += strlen("PG:");
+ dsn = G_store(p);
+ }
}
else {
/* other datasources */
Modified: grass/trunk/vector/v.external/main.c
===================================================================
--- grass/trunk/vector/v.external/main.c 2017-01-11 13:55:54 UTC (rev 70341)
+++ grass/trunk/vector/v.external/main.c 2017-01-11 14:50:26 UTC (rev 70342)
@@ -138,7 +138,17 @@
if (!flags.override->answer) {
/* here must be used original dsn since check_projection() is
* using GDAL library */
- check_projection(options.dsn->answer, ilayer);
+ char dsn_ogr[DB_SQL_MAX];
+
+ if (!use_ogr && G_strncasecmp(options.dsn->answer, "PG:", 3) == 0) {
+ /* make dsn OGR-compatible */
+ strcpy(dsn_ogr, "PG:");
+ strcat(dsn_ogr, dsn);
+ }
+ else {
+ sprintf(dsn_ogr, "%s", dsn);
+ }
+ check_projection(dsn_ogr, ilayer);
}
/* create new vector map */
More information about the grass-commit
mailing list