[GRASS-dev] [GRASS GIS] #2460: v.out.postgis doesn't export attribute table

#2460: v.out.postgis doesn't export attribute table
---------------------------+------------------------------------------------
Reporter: martin | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Default | Version: svn-trunk
Keywords: v.out.postgis | Platform: Linux
      Cpu: x86-64 |
---------------------------+------------------------------------------------
Attribute table has one column.[[BR]]
"v.out.ogr" creates a proper column in PostGIS accordingly,
"v.out.postgis" doesn't.

{{{
GRASS 7.1.svn > v.out.postgis input=newcs_errorW_full type=area
olayer=newcs_full_pg \
     dsn="PG:host=${PGHOST} dbname=${PGDATABASE} user=${PGUSER}" \
     options="FID=ogc_fid, GEOMETRY_NAME=wkb_geometry, SPATIAL_INDEX=YES,
PRIMARY_KEY=YES, SRID=4326" \
     --verbose --overwrite
WARNING: PostGIS layer <public.newcs_full_pg> already exists and will be
          overwritten
Using PostGIS format
Building spatial index on <wkb_geometry>...
Copying features (polygon)...
  100%
Exporting areas...
  100%
Building topology for vector map <newcs_full_pg@nlcd2011error>...
Using external data format 'PostgreSQL' (feature type 'polygon')
Building pseudo-topology over simple features...
Registering primitives...
26401 primitives registered
4296855 vertices registered
Topology was built
Number of nodes: 11427
Number of primitives: 26401
Number of points: 0
Number of lines: 0
Number of boundaries: 14330
Number of centroids: 12071
Number of areas: 14330
Number of isles: 14330
v.out.postgis complete. 12071 features (polygon type) written to
<newcs_full_pg>.
}}}

{{{
landcover=> \d newcs_full_pg
                                       Table "public.newcs_full_pg"
     Column | Type |
Modifiers
--------------+------------------------+-----------------------------------------------------------------
  ogc_fid | integer | not null default
nextval('newcs_full_pg_ogc_fid_seq'::regclass)
  cat | integer |
  wkb_geometry | geometry(Polygon,4326) |
Indexes:
     "newcs_full_pg_pkey" PRIMARY KEY, btree (ogc_fid)
     "newcs_full_pg_cat_idx" btree (cat)
     "newcs_full_pg_wkb_geometry_idx" gist (wkb_geometry)
}}}

{{{
GRASS 7.1.svn > v.out.ogr input=newcs_errorW_full type=area
olayer=newcs_full_ogr format=PostgreSQL \
     dsn="PG:host=${PGHOST} dbname=${PGDATABASE} user=${PGUSER}" \
     --verbose --overwrite
Warning 1: Multi-column primary key in 'fgs_overrides' detected but not
supported.
WARNING: OGR layer <newcs_full_ogr> already exists and will be overwritten
Exporting 12071 areas (may take some time)...
  100%
v.out.ogr complete. 12071 features (Polygon type) written to
<newcs_full_ogr> (PostgreSQL format).
}}}

{{{
landcover=> \d newcs_full_ogr
                                        Table "public.newcs_full_ogr"
     Column | Type |
Modifiers
--------------+-------------------------+------------------------------------------------------------------
  ogc_fid | integer | not null default
nextval('newcs_full_ogr_ogc_fid_seq'::regclass)
  wkb_geometry | geometry(Polygon,4326) |
  cat | integer |
  pglayer | character varying(1000) |
Indexes:
     "newcs_full_ogr_pk" PRIMARY KEY, btree (ogc_fid)
     "newcs_full_ogr_geom_idx" gist (wkb_geometry)
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2460&gt;
GRASS GIS <http://grass.osgeo.org>

#2460: v.out.postgis doesn't export attribute table
---------------------------+------------------------------------------------
Reporter: martin | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Default | Version: svn-trunk
Keywords: v.out.postgis | Platform: Linux
      Cpu: x86-64 |
---------------------------+------------------------------------------------

Comment(by martin):

Ping

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2460#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2460: v.out.postgis doesn't export attribute table
---------------------------+------------------------------------------------
Reporter: martin | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Default | Version: svn-trunk
Keywords: v.out.postgis | Platform: Linux
      Cpu: x86-64 |
---------------------------+------------------------------------------------

Comment(by martin):

Ping

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2460#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2460: v.out.postgis doesn't export attribute table
---------------------------+------------------------------------------------
Reporter: martin | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Default | Version: svn-trunk
Keywords: v.out.postgis | Platform: Linux
      Cpu: x86-64 |
---------------------------+------------------------------------------------

Comment(by mlennert):

This seems to be linked to the handling of feature types:

{{{
v.out.postgis in=censusblk_swwake output='PG:dbname=nc_grass' --o
}}}

gives me the full attribute table, while

{{{
v.out.postgis in=censusblk_swwake type=area output='PG:dbname=nc_grass'
--o
}}}

only gives me fid, cat and geom columns.

BTW, when I try

{{{
v.out.postgis in=censusblk_swwake type=centroid
output='PG:dbname=nc_grass' --o
}}}

I get

{{{
ATTENTION: Unsupported geometry type (8)
ATTENTION: Unable to write feature in vector map <censusblk_swwake>
ERREUR :Feature type 8 is not supported
Erreur de segmentation
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2460#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2460: v.out.postgis doesn't export attribute table
---------------------------+------------------------------------------------
Reporter: martin | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: Default | Version: svn-trunk
Keywords: v.out.postgis | Platform: Linux
      Cpu: x86-64 |
---------------------------+------------------------------------------------
Changes (by neteler):

  * milestone: => 7.1.0

Comment:

Perhaps related: r62360 (reported in #2436)?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2460#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2460: v.out.postgis doesn't export attribute table
---------------------------+------------------------------------------------
Reporter: martin | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: Default | Version: svn-trunk
Keywords: v.out.postgis | Platform: Linux
      Cpu: x86-64 |
---------------------------+------------------------------------------------

Comment(by mlennert):

The following patch apparently "solves" the problem for me, but I don't
know what consequences this might have, nor why it works as I don't get a
fatal error anyhow...

{{{
Index: main.c

--- main.c (révision 64605)
+++ main.c (copie de travail)
@@ -135,11 +135,12 @@
                        olayer);
      G_add_error_handler(output_handler, &Out);

- /* check output type */
- if (otype > 0) { /* type is not 'auto' */
+ /* check output type
+ if (otype > 0) { type is not 'auto'
          if (Vect_write_line(&Out, otype, NULL, NULL) < 0)
              G_fatal_error(_("Feature type %d is not supported"), otype);
      }
+ */

      /* copy attributes */
      field = Vect_get_field_number(&In, params.layer->answer);
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2460#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>