Opened 5 years ago

Closed 3 years ago

#2460 closed defect (fixed)

v.out.postgis doesn't export attribute table

Reported by: martin Owned by: grass-dev@…
Priority: normal Milestone: 7.2.1
Component: Default Version: svn-trunk
Keywords: v.out.postgis Cc:
CPU: x86-64 Platform: Linux

Description

Attribute table has one column.
"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)

Change History (15)

comment:1 Changed 5 years ago by martin

Ping

comment:2 Changed 5 years ago by martin

Ping

comment:3 Changed 5 years ago 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

comment:4 Changed 5 years ago by neteler

Milestone: 7.1.0

Perhaps related: r62360 (reported in #2436)?

comment:5 Changed 5 years ago 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);

comment:6 Changed 4 years ago by neteler

Milestone: 7.1.07.2.0

Milestone renamed

comment:7 Changed 3 years ago by martinl

In 69672:

v.out.postgis doesn't export attribute table (see #2460)

comment:8 in reply to:  5 Changed 3 years ago by martinl

Replying to 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...

Please try out r69672 (trunk).

comment:9 in reply to:  3 ; Changed 3 years ago by martinl

Replying to mlennert:

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

Right, it's still issue and must be solved before closing this ticket.

comment:10 Changed 3 years ago by neteler

Milestone: 7.2.07.2.1

comment:11 Changed 3 years ago by martinl

In 70179:

v.out.postgis doesn't export attribute table (see #2460)

(relbr72: merge r69672 from trunk)

comment:12 Changed 3 years ago by martinl

In 70505:

v.out.postgis: fix type parameter issues (see #2460)

comment:13 in reply to:  9 Changed 3 years ago by martinl

Replying to martinl:

Right, it's still issue and must be solved before closing this ticket.

Should be fixed in r70505.

v.out.postgis in=censusblk_swwake output='PG:dbname=nc_grass' --o type=point
-> nothing is exported

v.out.postgis in=censusblk_swwake output='PG:dbname=nc_grass' --o type=line
-> nothing is exported

v.out.postgis in=censusblk_swwake output='PG:dbname=nc_grass' --o type=centroid
-> centroids exported as points

v.out.postgis in=censusblk_swwake output='PG:dbname=nc_grass' --o type=boundary
-> boundaries exported as linestrings

v.out.postgis in=censusblk_swwake output='PG:dbname=nc_grass' --o type=area
-> areas exported as polygons

Testing welcome.

comment:14 Changed 3 years ago by martinl

In 70513:

vlib: copy areas - turn is_isle() into debug message (see #2460)

comment:15 Changed 3 years ago by martinl

Resolution: fixed
Status: newclosed

In 70619:

v.out.postgis: fix type option (closes #2460)

Note: See TracTickets for help on using tickets.