Просмотр исходного кода

vlib(pg): enable srid support

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@55302 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 лет назад
Родитель
Сommit
175a1a9d3a
2 измененных файлов с 7 добавлено и 9 удалено
  1. 6 0
      lib/vector/Vlib/open.c
  2. 1 9
      lib/vector/Vlib/open_pg.c

+ 6 - 0
lib/vector/Vlib/open.c

@@ -1211,6 +1211,12 @@ int map_format(struct Map_info *Map)
 #endif
             G_debug(1, "PG: geom_column = '%s'", pg_info->geom_column);
             
+            /* srid (default: 0) */
+            p = G_find_key_value("srid", key_val);
+            if (p)
+                pg_info->srid = atoi(p);
+            G_debug(1, "PG: srid = %d", pg_info->srid);
+            
             /* table name */
             Map->fInfo.pg.table_name = G_store(Map->name);
         }

+ 1 - 9
lib/vector/Vlib/open_pg.c

@@ -328,7 +328,6 @@ int V2_open_new_pg(struct Map_info *Map, int type)
 
     struct Format_info_pg *pg_info;
     struct field_info *Fi;
-    struct Key_Value *projinfo, *projunits;
 
     Fi = NULL;
 
@@ -346,14 +345,6 @@ int V2_open_new_pg(struct Map_info *Map, int type)
     G_debug(1, "V2_open_new_pg(): conninfo='%s' table='%s' -> type = %d",
             pg_info->conninfo, pg_info->table_name, type);
 
-    /* get spatial reference */
-    projinfo = G_get_projinfo();
-    projunits = G_get_projunits();
-    pg_info->srid = 0;          /* TODO */
-    // Ogr_spatial_ref = GPJ_grass_to_osr(projinfo, projunits);
-    G_free_key_value(projinfo);
-    G_free_key_value(projunits);
-
     /* determine geometry type */
     switch (type) {
     case GV_POINT:
@@ -833,6 +824,7 @@ int create_table(struct Format_info_pg *pg_info, const struct field_info *Fi)
     result = PQexec(pg_info->conn, stmt);
     
     if (!result || PQresultStatus(result) != PGRES_TUPLES_OK) {
+        G_warning("%s", PQresultErrorMessage(result));
         PQclear(result);
         Vect__execute_pg(pg_info->conn, "ROLLBACK");
         return -1;