瀏覽代碼

v.out.postgis: add 'type' parameter
update manual - add note about 3D data support


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56397 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 12 年之前
父節點
當前提交
1806aa1b8d
共有 4 個文件被更改,包括 46 次插入21 次删除
  1. 5 0
      vector/v.out.postgis/args.c
  2. 1 1
      vector/v.out.postgis/local_proto.h
  3. 14 4
      vector/v.out.postgis/main.c
  4. 26 16
      vector/v.out.postgis/v.out.postgis.html

+ 5 - 0
vector/v.out.postgis/args.c

@@ -7,6 +7,11 @@ void define_options(struct params *params, struct flags *flags)
 {
     params->input = G_define_standard_option(G_OPT_V_INPUT);
     params->input->description = NULL;
+
+    params->type = G_define_standard_option(G_OPT_V3_TYPE);
+    params->type->options =
+	"point,line,boundary,centroid,area,face,kernel,auto";
+    params->type->answer = "auto";
     
     params->layer = G_define_standard_option(G_OPT_V_FIELD);
     params->layer->description = NULL;

+ 1 - 1
vector/v.out.postgis/local_proto.h

@@ -4,7 +4,7 @@
 #include <grass/vector.h>
 
 struct params {
-    struct Option *input, *layer, *dsn, *olayer, *opts, *olink;
+    struct Option *input, *layer, *dsn, *olayer, *opts, *olink, *type;
 };
 
 struct flags {

+ 14 - 4
vector/v.out.postgis/main.c

@@ -32,7 +32,7 @@ int main(int argc, char *argv[])
     struct params params;
     struct flags flags;
     
-    int ret, field;
+    int ret, field, otype;
     char *schema, *olayer, *pg_file;
     char *fid_column, *geom_column;
     
@@ -46,7 +46,8 @@ int main(int argc, char *argv[])
     G_add_keyword(_("PostGIS"));
     G_add_keyword(_("simple features"));
     G_add_keyword(_("topology"));
-
+    G_add_keyword(_("3D"));
+    
     module->description =
         _("Exports a vector map layer to PostGIS feature table.");
     module->overwrite = TRUE;
@@ -56,6 +57,9 @@ int main(int argc, char *argv[])
     if (G_parser(argc, argv))
         exit(EXIT_FAILURE);
 
+    /* parse parameters */
+    otype = Vect_option_to_types(params.type);
+
     /* if olayer not given, use input as the name */
     schema = NULL;
     if (!params.olayer->answer) {
@@ -130,12 +134,18 @@ int main(int argc, char *argv[])
                       olayer);
     G_add_error_handler(output_handler, &Out);
     
-    /* define attributes */
+    /* 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);
     if (!flags.table->answer)
         Vect_copy_map_dblinks(&In, &Out, TRUE);
 
-    /* copy vector features & create PostGIS table*/
+    /* copy vector features & create PostGIS table */
     if (Vect_copy_map_lines_field(&In, field, &Out) != 0)
         G_fatal_error(_("Copying features failed"));
 

+ 26 - 16
vector/v.out.postgis/v.out.postgis.html

@@ -36,20 +36,16 @@ by <em><a href="v.external.out.html">v.external.out</a></em> are
 ignored by <em>v.out.postgis</em>.
 
 <p>
-<em>v.out.postgis</em> optionally also creates new vector map in the
+<em>v.out.postgis</em> optionally also creates a new vector map in the
 current mapset if <b>olink</b> is defined.
 
 <h2>NOTES</h2>
 
-Currently only 2D vector features (points, lines, boundaries and
-centroids) are supported.
-
-<p>
 By default <em>v.out.postgis</em> exports vector data as <em>simple
 features</em>, ie. boundaries and centroids (forming topological
 areas) become polygons, isles become holes. Geometry of simple feature
-elements is stored in PostGIS feature table as column
-&quot;geom&quot;. Default name of the geometry column can be changed
+elements is stored in PostGIS feature table in the column named
+&quot;geom&quot;. Name of the geometry column can be changed
 by <b>options=</b><tt>GEOMETRY_NAME=&lt;column&gt;</tt>. Note that for
 exporting vector features as simple features can be alternatively
 used <a href="http://gdal.org/ogr/drv_pg.html">PostgreSQL driver</a>
@@ -59,9 +55,22 @@ through <em><a href="v.out.ogr.html">v.out.ogr</a></em> module.
 <p>
 Also note that it's allowed to store in the feature table only
 features of the same type, ie. mixing of points and lines is not
-possible. The feature type is determined for output feature table from
-the first read vector feature when accessing data sequentially. Vector
-features of other types are during export skipped.
+currently possible. The feature type is determined for output feature
+table from the first vector feature accessing data sequentially
+(<b>type=auto</b>). Vector features of other types are during export
+skipped. User can choose preferable feature type by <b>type</b>
+parameter. Only single type is currently allowed (see TODO section for
+details).
+
+<p>
+<em>v.out.postgis</em> currently supports only three basic output
+simple feature types: Points, Linestrings and Polygons. Also 3D
+features of the same type are supported, eg. 3D points are exported
+as <tt>PointZ</tt> simple feature. Faces are exported as 3D polygons.
+
+<p>
+Multigeometries are not currently supported. Features with the same
+category are exported as multiple singe features.
 
 <p>
 <em>v.out.postgis</em> also allows to export vector features as
@@ -86,9 +95,10 @@ table.
 </ul>
 
 Tables <i>node</i>, <i>edge</i> and <i>face</i> are stored in given
-topological schema. By default <em>v.out.postgis</em> defines it's
-name as <tt>topo_&lt;input&gt;</tt>. Name of topology schema can be
-defined by <b>options=</b><tt>TOPOSCHEMA_NAME=&lt;name&gt;</tt>.
+topological schema. By default <em>v.out.postgis</em> defines its name
+as <tt>topo_&lt;input&gt;</tt>. Alternatively, the name for topology
+schema can be defined
+by <b>options=</b><tt>TOPOSCHEMA_NAME=&lt;name&gt;</tt>.
 
 <h2>EXAMPLES</h2>
 
@@ -218,10 +228,10 @@ page</a>.
 
 <ul>
   <li>Multi-feature export</li>
-  <li>Allow mixed features (points, lines) - use
-  GeometryCollection</li>
+  <li>Allow mixed features (points, lines)</li>
+  <li>Support other simple feature types like GeometryCollection and others</li>
   <li>Implement missing options
-  from <em><a href="v.out.ogr.html">v.out.ogr</a></em>: <b>-a</b>, <b>-s</b>, <b>-c</b>, <b>-2</b>, <b>-p</b>, <b>-n</b>, <b>type</b></li>
+  from <em><a href="v.out.ogr.html">v.out.ogr</a></em>: <b>-a</b>, <b>-s</b>, <b>-c</b>, <b>-2</b>, <b>-p</b>, <b>-n</b></li>
   <li>Add options: <b>cats</b>, <b>where</b></li>
 </ul>