Browse Source

vlib/pg: report categories also for centroids (it fixes eg. v.out.ascii map=pglink format=wkt)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70247 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 8 years ago
parent
commit
94bcc28111
1 changed files with 6 additions and 3 deletions
  1. 6 3
      lib/vector/Vlib/read_pg.c

+ 6 - 3
lib/vector/Vlib/read_pg.c

@@ -54,7 +54,7 @@ static int geometry_collection_from_wkb(const unsigned char *, int, int, int,
                                         struct feat_parts *);
 static int error_corrupted_data(const char *);
 static void add_fpart(struct feat_parts *, SF_FeatureType, int, int);
-static int get_centroid(struct Map_info *, int, struct line_pnts *);
+static int get_centroid(struct Map_info *, int, struct line_pnts *, struct line_cats *);
 static void error_tuples(struct Format_info_pg *);
 #endif
 
@@ -348,7 +348,7 @@ int V2_read_line_pg(struct Map_info *Map, struct line_pnts *line_p,
         Vect_reset_line(line_p);
     if (Line->type == GV_CENTROID && !pg_info->toposchema_name) {
         /* simple features access: get centroid from sidx */
-        return get_centroid(Map, line, line_p);
+        return get_centroid(Map, line, line_p, line_c);
     }
     
     /* get feature id */
@@ -1633,7 +1633,7 @@ void add_fpart(struct feat_parts *fparts, SF_FeatureType ftype,
   \return -1 on error
 */
 int get_centroid(struct Map_info *Map, int centroid,
-                 struct line_pnts *line_p)
+                 struct line_pnts *line_p, struct line_cats *line_c)
 {
     int i, found;
     struct bound_box box;
@@ -1665,6 +1665,9 @@ int get_centroid(struct Map_info *Map, int centroid,
         Vect_reset_line(line_p);
         Vect_append_point(line_p, list.box[found].E, list.box[found].N, 0.0);
     }
+    if (line_c) {
+        Vect_cat_set(line_c, 1, topo->area);
+    }
     
     return GV_CENTROID;
 }