[GRASS-SVN] r56397 - grass/trunk/vector/v.out.postgis
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri May 24 04:45:08 PDT 2013
Author: martinl
Date: 2013-05-24 04:45:07 -0700 (Fri, 24 May 2013)
New Revision: 56397
Modified:
grass/trunk/vector/v.out.postgis/args.c
grass/trunk/vector/v.out.postgis/local_proto.h
grass/trunk/vector/v.out.postgis/main.c
grass/trunk/vector/v.out.postgis/v.out.postgis.html
Log:
v.out.postgis: add 'type' parameter
update manual - add note about 3D data support
Modified: grass/trunk/vector/v.out.postgis/args.c
===================================================================
--- grass/trunk/vector/v.out.postgis/args.c 2013-05-24 10:54:57 UTC (rev 56396)
+++ grass/trunk/vector/v.out.postgis/args.c 2013-05-24 11:45:07 UTC (rev 56397)
@@ -7,6 +7,11 @@
{
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;
Modified: grass/trunk/vector/v.out.postgis/local_proto.h
===================================================================
--- grass/trunk/vector/v.out.postgis/local_proto.h 2013-05-24 10:54:57 UTC (rev 56396)
+++ grass/trunk/vector/v.out.postgis/local_proto.h 2013-05-24 11:45:07 UTC (rev 56397)
@@ -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 {
Modified: grass/trunk/vector/v.out.postgis/main.c
===================================================================
--- grass/trunk/vector/v.out.postgis/main.c 2013-05-24 10:54:57 UTC (rev 56396)
+++ grass/trunk/vector/v.out.postgis/main.c 2013-05-24 11:45:07 UTC (rev 56397)
@@ -32,7 +32,7 @@
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 @@
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 @@
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 @@
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"));
Modified: grass/trunk/vector/v.out.postgis/v.out.postgis.html
===================================================================
--- grass/trunk/vector/v.out.postgis/v.out.postgis.html 2013-05-24 10:54:57 UTC (rev 56396)
+++ grass/trunk/vector/v.out.postgis/v.out.postgis.html 2013-05-24 11:45:07 UTC (rev 56397)
@@ -36,20 +36,16 @@
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
-"geom". Default name of the geometry column can be changed
+elements is stored in PostGIS feature table in the column named
+"geom". Name of the geometry column can be changed
by <b>options=</b><tt>GEOMETRY_NAME=<column></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,11 +55,24 @@
<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
<em>topological elements</em>
in <a href="http://postgis.refractions.net/docs/Topology.html">PostGIS
@@ -86,9 +95,10 @@
</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_<input></tt>. Name of topology schema can be
-defined by <b>options=</b><tt>TOPOSCHEMA_NAME=<name></tt>.
+topological schema. By default <em>v.out.postgis</em> defines its name
+as <tt>topo_<input></tt>. Alternatively, the name for topology
+schema can be defined
+by <b>options=</b><tt>TOPOSCHEMA_NAME=<name></tt>.
<h2>EXAMPLES</h2>
@@ -218,10 +228,10 @@
<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>
More information about the grass-commit
mailing list