[GRASS-SVN] r53898 - in grass/trunk: lib/vector/Vlib vector/v.external.out vector/v.out.postgis
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 18 10:14:39 PST 2012
Author: martinl
Date: 2012-11-18 10:14:38 -0800 (Sun, 18 Nov 2012)
New Revision: 53898
Modified:
grass/trunk/lib/vector/Vlib/build.c
grass/trunk/lib/vector/Vlib/close.c
grass/trunk/lib/vector/Vlib/close_pg.c
grass/trunk/lib/vector/Vlib/open_pg.c
grass/trunk/vector/v.external.out/v.external.out.html
grass/trunk/vector/v.out.postgis/create.c
grass/trunk/vector/v.out.postgis/local_proto.h
grass/trunk/vector/v.out.postgis/main.c
grass/trunk/vector/v.out.postgis/options.c
grass/trunk/vector/v.out.postgis/v.out.postgis.html
Log:
v.out.postgis: better support for creation options
new parameter for creating links (link is not created by default)
update Vlib
v.external.out: manual cosmetics
Modified: grass/trunk/lib/vector/Vlib/build.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build.c 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/lib/vector/Vlib/build.c 2012-11-18 18:14:38 UTC (rev 53898)
@@ -973,7 +973,7 @@
/*!
\brief Save topology file for vector map
- \param Map vector map
+ \param Map pointer to Map_info structure
\return 1 on success
\return 0 on error
@@ -981,7 +981,7 @@
int Vect_save_topo(struct Map_info *Map)
{
struct Plus_head *plus;
- char fname[GPATH_MAX], buf[GPATH_MAX];
+ char buf[GPATH_MAX];
struct gvfile fp;
G_debug(1, "Vect_save_topo()");
@@ -990,12 +990,10 @@
/* write out all the accumulated info to the plus file */
sprintf(buf, "%s/%s", GV_DIRECTORY, Map->name);
- G_file_name(fname, buf, GV_TOPO_ELEMENT, Map->mapset);
- G_debug(1, "Open topo: %s", fname);
dig_file_init(&fp);
- fp.file = fopen(fname, "w");
+ fp.file = G_fopen_new(buf, GV_TOPO_ELEMENT);
if (fp.file == NULL) {
- G_warning(_("Unable to open topo file for write <%s>"), fname);
+ G_warning(_("Unable to create topo file for vector map <%s>"), Map->name);
return 0;
}
Modified: grass/trunk/lib/vector/Vlib/close.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close.c 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/lib/vector/Vlib/close.c 2012-11-18 18:14:38 UTC (rev 53898)
@@ -72,17 +72,64 @@
*/
int Vect_close(struct Map_info *Map)
{
+ int create_link; /* used for external formats only */
struct Coor_info CInfo;
-
+
G_debug(1, "Vect_close(): name = %s, mapset = %s, format = %d, level = %d",
Map->name, Map->mapset, Map->format, Map->level);
-
+
+ /* check for external formats whether to create a link */
+ create_link = TRUE;
+ if (Map->format == GV_FORMAT_OGR ||
+ Map->format == GV_FORMAT_POSTGIS) {
+ char *def_file;
+
+ if (Map->format == GV_FORMAT_POSTGIS) {
+ if (getenv("GRASS_VECTOR_PGFILE"))
+ def_file = getenv("GRASS_VECTOR_PGFILE");
+ else
+ def_file = "PG";
+ }
+ else {
+ def_file = "OGR";
+ }
+ if (G_find_file2("", def_file, G_mapset())) {
+ FILE *fp;
+ const char *p;
+
+ struct Key_Value *key_val;
+
+ fp = G_fopen_old("", def_file, G_mapset());
+ if (!fp) {
+ G_warning(_("Unable to open %s file"), def_file);
+ }
+ else {
+ key_val = G_fread_key_value(fp);
+ fclose(fp);
+
+ /* create a vector link in the current mapset ? */
+ p = G_find_key_value("link", key_val);
+ if (p && G_strcasecmp(p, "no") == 0) {
+ create_link = FALSE;
+ }
+ else {
+ p = G_find_key_value("link_name", key_val);
+ if (p) {
+ /* use different name for a link */
+ G_free(Map->name);
+ Map->name = G_store(p);
+ }
+ }
+ }
+ }
+ }
+
/* store support files for vector maps in the current mapset if in
write mode on level 2 */
if (strcmp(Map->mapset, G_mapset()) == 0 &&
- Map->support_updated &&
- Map->plus.built == GV_BUILD_ALL &&
- getenv("GRASS_VECTOR_PGFILE") == NULL) { /* GRASS_VECTOR_PGFILE defined by v.out.postgis */
+ Map->support_updated &&
+ Map->plus.built == GV_BUILD_ALL &&
+ create_link) {
unlink_file(Map, GV_TOPO_ELEMENT); /* topo */
@@ -121,7 +168,7 @@
if (Map->format != GV_FORMAT_OGR_DIRECT &&
Map->plus.Spidx_built == TRUE &&
Map->plus.built == GV_BUILD_ALL &&
- getenv("GRASS_VECTOR_PGFILE") == NULL) /* GRASS_VECTOR_PGFILE defined by v.out.postgis */
+ create_link)
fclose(Map->plus.spidx_fp.file);
}
@@ -143,7 +190,7 @@
/* close level 1 files / data sources if not head_only */
if (!Map->head_only) {
- if (((*Close_array[Map->format][1]) (Map)) != 0) {
+ if (create_link && ((*Close_array[Map->format][1]) (Map)) != 0) {
G_warning(_("Unable to close vector <%s>"),
Vect_get_full_name(Map));
return 1;
Modified: grass/trunk/lib/vector/Vlib/close_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/close_pg.c 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/lib/vector/Vlib/close_pg.c 2012-11-18 18:14:38 UTC (rev 53898)
@@ -46,10 +46,8 @@
if (Map->mode == GV_MODE_WRITE || Map->mode == GV_MODE_RW) {
/* write header */
Vect__write_head(Map);
- if (G_find_file2("", "PG", G_mapset())) {
- /* write frmt file for created PG-link */
- Vect_save_frmt(Map);
- }
+ /* write frmt file for created PG-link */
+ Vect_save_frmt(Map);
}
/* close connection */
Modified: grass/trunk/lib/vector/Vlib/open_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open_pg.c 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/lib/vector/Vlib/open_pg.c 2012-11-18 18:14:38 UTC (rev 53898)
@@ -234,20 +234,17 @@
}
/* if schema not defined, use 'public' */
- if (!pg_info->schema_name) {
+ if (!pg_info->schema_name)
pg_info->schema_name = G_store("public");
- }
- /* if fid_column not defined, use 'ogc_fid' */
- if (!pg_info->fid_column) {
+ /* if fid_column not defined, use 'fid' */
+ if (!pg_info->fid_column)
pg_info->fid_column = G_store(FID_COLUMN);
- }
- /* if geom_column not defined, use 'wkb_geometry' */
- if (!pg_info->geom_column) {
+ /* if geom_column not defined, use 'geom' */
+ if (!pg_info->geom_column)
pg_info->geom_column = G_store(GEOMETRY_COLUMN);
- }
-
+
/* check if feature table already exists */
sprintf(stmt, "SELECT * FROM pg_tables "
"WHERE schemaname = '%s' AND tablename = '%s'",
@@ -650,32 +647,34 @@
fp = G_fopen_old("", def_file ? def_file : "PG", G_mapset());
if (!fp) {
- G_fatal_error(_("Unable to open PG file"));
+ G_warning(_("Unable to open PG file"));
}
- key_val = G_fread_key_value(fp);
- fclose(fp);
-
- /* disable spatial index ? */
- p = G_find_key_value("spatial_index", key_val);
- if (p && G_strcasecmp(p, "off") == 0)
- spatial_index = FALSE;
-
- /* disable primary key ? */
- p = G_find_key_value("primary_key", key_val);
- if (p && G_strcasecmp(p, "off") == 0)
- primary_key = FALSE;
-
- /* PostGIS topology enabled ? */
- p = G_find_key_value("topology", key_val);
- if (p && G_strcasecmp(p, "on") == 0) {
- /* define topology name
- this should be configurable by the user
- */
- G_asprintf(&(pg_info->toposchema_name), "topo_%s",
- pg_info->table_name);
+ else {
+ key_val = G_fread_key_value(fp);
+ fclose(fp);
+
+ /* disable spatial index ? */
+ p = G_find_key_value("spatial_index", key_val);
+ if (p && G_strcasecmp(p, "no") == 0)
+ spatial_index = FALSE;
+
+ /* disable primary key ? */
+ p = G_find_key_value("primary_key", key_val);
+ if (p && G_strcasecmp(p, "no") == 0)
+ primary_key = FALSE;
+
+ /* PostGIS topology enabled ? */
+ p = G_find_key_value("topology", key_val);
+ if (p && G_strcasecmp(p, "yes") == 0) {
+ /* define topology name
+ this should be configurable by the user
+ */
+ G_asprintf(&(pg_info->toposchema_name), "topo_%s",
+ pg_info->table_name);
+ }
}
}
-
+
/* create schema if not exists */
if (G_strcasecmp(pg_info->schema_name, "public") != 0) {
if (check_schema(pg_info) != 0)
Modified: grass/trunk/vector/v.external.out/v.external.out.html
===================================================================
--- grass/trunk/vector/v.external.out/v.external.out.html 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/vector/v.external.out/v.external.out.html 2012-11-18 18:14:38 UTC (rev 53898)
@@ -40,11 +40,11 @@
primary key (feature id), default: <tt>fid</tt></li>
<li><tt>GEOMETRY_NAME=<column></tt> name of column which will
be used for storing geometry data in feature table, default: <tt>geom</tt></li>
- <li><tt>SPATIAL_INDEX=ON|OFF</tt> - enable/disable spatial index on geometry column, default: ON</li>
- <li><tt>PRIMARY_KEY=ON|OFF</tt> - enable/disable primary key on FID column, default: ON</li>
- <li><tt>TOPOLOGY=ON|OFF</tt> - enable/disable
+ <li><tt>SPATIAL_INDEX=YES|NO</tt> - enable/disable spatial index on geometry column, default: YES</li>
+ <li><tt>PRIMARY_KEY=YES|NO</tt> - enable/disable primary key on FID column, default: YES</li>
+ <li><tt>TOPOLOGY=YES|NO</tt> - enable/disable
native <a href="http://trac.osgeo.org/postgis/wiki/UsersWikiPostgisTopology">PostGIS
- topology</a>, default: OFF</li>
+ topology</a>, default: NO</li>
</ul>
<p>
@@ -134,6 +134,7 @@
<h2>AUTHOR</h2>
Martin Landa, Czech Technical University in Prague, Czech Republic
+(development supported by Fondazione Edmund Mach and Comune di Trento, Italy)
<p>
<i>Last changed: $Date$</i>
Modified: grass/trunk/vector/v.out.postgis/create.c
===================================================================
--- grass/trunk/vector/v.out.postgis/create.c 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/vector/v.out.postgis/create.c 2012-11-18 18:14:38 UTC (rev 53898)
@@ -16,7 +16,9 @@
if (pg_info->feature_type != SF_UNKNOWN)
return;
- /* create PostGIS table if doesn't exist */
+ /* create PostGIS table if doesn't exist
+ determine feature type from the first feature */
+ Vect_rewind(In);
type = Vect_read_next_line(In, NULL, NULL);
Vect_rewind(In);
@@ -25,8 +27,10 @@
Vect_get_finfo_layer_name(Out));
}
-char *create_pgfile(const char *dsn, const char *schema, int topo)
+char *create_pgfile(const char *dsn, const char *schema, const char *olink,
+ char **options, int topo)
{
+ int i;
char *filename, *conninfo;
FILE *fp;
@@ -46,7 +50,7 @@
/* be friendly, ignored 'PG:' prefix for GRASS-PostGIS data driver */
if (G_strncasecmp(dsn, "PG:", 3) == 0) {
- int i, length;
+ int length;
length = strlen(dsn);
conninfo = (char *) G_malloc(length - 3);
@@ -58,12 +62,41 @@
conninfo = G_store(dsn);
}
+ /* required options */
G_set_key_value("conninfo", conninfo, key_val);
if (schema)
G_set_key_value("schema", schema, key_val);
if (topo)
G_set_key_value("topology", "on", key_val);
+ /* extra options */
+ if (options) {
+ char **tokens;
+
+ for(i = 0; options[i]; i++) {
+ tokens = G_tokenize(options[i], "=");
+ if (G_number_of_tokens(tokens) != 2) {
+ G_warning(_("Invalid option skipped: %s"), options[i]);
+ continue;
+ }
+ G_debug(1, "option: %s=%s", tokens[0], tokens[1]);
+ /* force upper case */
+ G_str_to_lower(tokens[0]);
+ G_set_key_value(tokens[0], tokens[1], key_val);
+
+ G_free_tokens(tokens);
+ }
+ }
+
+ if (olink) {
+ /* create a link for output feature table */
+ G_set_key_value("link", "yes", key_val);
+ G_set_key_value("link_name", olink, key_val);
+ }
+ else {
+ G_set_key_value("link", "no", key_val);
+ }
+
if (G_fwrite_key_value(fp, key_val) < 0)
G_fatal_error(_("Error writing <%s> file"), filename);
@@ -77,6 +110,7 @@
void file_handler(void *p) {
const char *filename = (const char *) p;
+ G_debug(1, "file_handler: %s", filename);
G_remove("", filename);
unsetenv("GRASS_VECTOR_PGFILE");
}
Modified: grass/trunk/vector/v.out.postgis/local_proto.h
===================================================================
--- grass/trunk/vector/v.out.postgis/local_proto.h 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/vector/v.out.postgis/local_proto.h 2012-11-18 18:14:38 UTC (rev 53898)
@@ -4,7 +4,7 @@
#include <grass/vector.h>
struct params {
- struct Option *input, *layer, *dsn, *olayer;
+ struct Option *input, *layer, *dsn, *olayer, *opts, *olink;
};
struct flags {
@@ -13,7 +13,7 @@
/* create.c */
void create_table(struct Map_info *, struct Map_info *);
-char *create_pgfile(const char *, const char *, int);
+char *create_pgfile(const char *, const char *, const char *, char **, int);
/* options.c */
void define_options(struct params *, struct flags *);
Modified: grass/trunk/vector/v.out.postgis/main.c
===================================================================
--- grass/trunk/vector/v.out.postgis/main.c 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/vector/v.out.postgis/main.c 2012-11-18 18:14:38 UTC (rev 53898)
@@ -28,7 +28,7 @@
struct flags flags;
int ret, field;
- char *schema, *olayer;
+ char *schema, *olayer, *pg_file;
struct Map_info In, Out;
G_gisinit(argv[0]);
@@ -37,9 +37,11 @@
G_add_keyword(_("vector"));
G_add_keyword(_("export"));
G_add_keyword(_("PostGIS"));
+ G_add_keyword(_("simple features"));
+ G_add_keyword(_("topology"));
module->description =
- _("Converts a vector map layer to PostGIS.");
+ _("Exports a vector map layer to PostGIS feature table.");
module->overwrite = TRUE;
define_options(¶ms, &flags);
@@ -50,7 +52,15 @@
/* if olayer not given, use input as the name */
schema = NULL;
if (!params.olayer->answer) {
- olayer = G_store(params.input->answer);
+ char name[GNAME_MAX], mapset[GMAPSET_MAX];
+
+ /* check for fully qualified name */
+ if (G_name_is_fully_qualified(params.input->answer,
+ name, mapset))
+ olayer = G_store(name);
+ else
+ olayer = G_store(params.input->answer);
+ G_debug(1, "olayer=%s", olayer);
}
else {
/* check for schema */
@@ -72,18 +82,20 @@
if (!schema)
schema = "public";
G_debug(1, "Database schema: %s", schema);
-
+
/* open input for reading */
ret = Vect_open_old2(&In, params.input->answer, "", params.layer->answer);
if (ret == -1)
G_fatal_error(_("Unable to open vector map <%s>"),
params.input->answer);
+ Vect_set_error_handler_io(&In, &Out);
if (ret < 2)
G_warning(_("Unable to open vector map <%s> on topological level"),
params.input->answer);
/* create output for writing */
- create_pgfile(params.dsn->answer, schema, flags.topo->answer ? TRUE : FALSE);
+ pg_file = create_pgfile(params.dsn->answer, schema, params.olink->answer,
+ params.opts->answers, flags.topo->answer ? TRUE : FALSE);
if (-1 == Vect_open_new(&Out, olayer, Vect_is_3d(&In)))
G_fatal_error(_("Unable to create PostGIS layer <%s>"),
@@ -115,5 +127,8 @@
Vect_close(&Out);
+ /* remove PG file */
+ G_remove("", pg_file);
+
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/vector/v.out.postgis/options.c
===================================================================
--- grass/trunk/vector/v.out.postgis/options.c 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/vector/v.out.postgis/options.c 2012-11-18 18:14:38 UTC (rev 53898)
@@ -15,7 +15,7 @@
params->dsn->key = "dsn";
params->dsn->type = TYPE_STRING;
params->dsn->required = YES;
- params->dsn->label = _("PostGIS output datasource name");
+ params->dsn->label = _("Name for output PostGIS datasource");
params->dsn->description =
_("Starts with 'PG' prefix, eg. 'PG:dbname=grass'");
@@ -23,11 +23,33 @@
params->olayer->key = "olayer";
params->olayer->type = TYPE_STRING;
params->olayer->required = NO;
+ params->olayer->key_desc = "name";
params->olayer->label =
_("Name for output PostGIS layer");
params->olayer->description =
_("If not specified, input name is used");
+ params->olink = G_define_standard_option(G_OPT_V_OUTPUT);
+ params->olink->key = "olink";
+ params->olink->required = NO;
+ params->olink->label =
+ _("Name for vector map defined as a link to the output PostGIS feature table");
+ params->olink->description =
+ _("If not specified, the vector link is not created. "
+ "The link can be also manually created by 'v.external' module.");
+
+ params->opts = G_define_option();
+ params->opts->key = "options";
+ params->opts->label = _("Creation options");
+ params->opts->description = _("Examples:\n"
+ "\t\t'FID=cat': define feature id column 'cat'\n"
+ "\t\t'GEOMETRY_NAME=wkb_geometry': define geometry column 'wkb_geometry'\n"
+ "\t\t'SPATIAL_INDEX=NO': do not create spatial index on geometry column");
+ params->opts->required = NO;
+ params->opts->multiple = YES;
+ params->opts->type = TYPE_STRING;
+ params->opts->key_desc = "key=value";
+
flags->table = G_define_flag();
flags->table->key = 't';
flags->table->description =
Modified: grass/trunk/vector/v.out.postgis/v.out.postgis.html
===================================================================
--- grass/trunk/vector/v.out.postgis/v.out.postgis.html 2012-11-18 16:32:36 UTC (rev 53897)
+++ grass/trunk/vector/v.out.postgis/v.out.postgis.html 2012-11-18 18:14:38 UTC (rev 53898)
@@ -1,45 +1,162 @@
<h2>DESCRIPTION</h2>
-<em>v.out.postgis</em> exports existing GRASS vector map layer into
+<em>v.out.postgis</em> exports an existing GRASS vector map layer to
PostGIS feature table.
+<p>
+By default GRASS topological features are converted into simple
+features
+(see <a href="http://www.opengeospatial.org/standards/sfa">OGC Simple
+Feature Access</a> specification for details). Flag <b>-l</b> allows
+to export vector features as topological elements stored
+in <a href="http://postgis.refractions.net/docs/Topology.html">PostGIS
+Topology</a> schema.
+
+<p>
+Additional creation options can be defined by <b>options</b> parameter:
+<ul>
+ <li><tt>FID=<column></tt> - name of column which will be used as
+ primary key (feature id), default: <tt>fid</tt></li>
+ <li><tt>GEOMETRY_NAME=<column></tt> name of column which will
+ be used for storing geometry data in feature table, default: <tt>geom</tt></li>
+ <li><tt>SPATIAL_INDEX=YES|NO</tt> - enable/disable creating spatial
+ index on geometry column, default: <tt>YES</tt></li>
+ <li><tt>PRIMARY_KEY=YES|NO</tt> - enable/disable adding primary key
+ on FID column, default: <tt>YES</tt></li>
+ <li><tt>TOPOSCHEMA_NAME=<schema name></tt> - name of PostGIS
+ Topology schema (relevant only for <b>-l</b> flag),
+ default: <tt>topo_<input></tt>
+</ul>
+
+Note that <em>options</em> defined
+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
+current mapset if <b>olink</b> is defined.
+
<h2>NOTES</h2>
-Currently only 2D vector features are supported.
+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.
+elements is stored in PostGIS feature table as column
+"geom". Default name of the geometry column can be changed
+by <b>options=</b><tt>GEOMETRY_NAME=<column></tt>.
<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
-Topology</a>. PostGIS Topology extension uses three tables to store
-different topological primitives which forms topological objects like
+Topology</a> schema. PostGIS Topology extension uses three tables to
+store basic topological elements which forms topological objects like
areas or isles in GRASS terminology. <em>Nodes</em> (0-dimensional
-elements) are stored in "node" table, <em>edges</em>
-(1-dimensional elements) in "edge" table and <em>faces</em>
-(2-dimensional elements) in "face" table.
+topological elements) are stored in "node"
+table, <em>edges</em> (1-dimensional elements) in "edge"
+table and <em>faces</em> (2-dimensional elements) in "face"
+table.
<ul>
<li>GRASS nodes are stored in <i>node</i> table</li>
<li>GRASS points are stored in <i>node</i> table as regular nodes</li>
<li>GRASS centroids are stored in <i>node</i> table as regular nodes
- (<tt>containing_face</tt> refers to related area)</li>
+ ("containing_face" refers to related area)</li>
<li>GRASS lines are stored in <i>edge</i> table</li>
<li>GRASS boundaries are stored in <i>edge</i> table</li>
<li>GRASS areas are stored in <i>face</i> table</li>
</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_<name of input vector map></tt>.
+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>.
<h2>EXAMPLES</h2>
-<em>To be added</em>
+<h3>Export Simple Features</h3>
+Export vector map <i>urbanarea</i> as feature table <i>urbanarea</i>
+located in database <i>grass</i>, schema <i>public</i>. Note that this
+database schema is automatically used when not defined by the user.
+
+<div class="code"><pre>
+v.out.postgis input=urbanarea dsn="PG:dbname=grass"
+</pre></div>
+
+GRASS areas are converted into polygons, isles into holes. We can
+check the number or created polygons by simple SQL query bellow.
+
+<div class="code"><pre>
+db.select driver=pg database=grass \
+ sql="SELECT ST_GeometryType(geom) as geom_type, count(*) from urbanarea group by geom_type"
+
+geom_type|count
+ST_Polygon|657
+</pre></div>
+
+<h3>Export data into specific database schema</h3>
+
+Database schema for storing exported data can be defined
+by <b>olayer</b> as
+<tt><schema_name>.<table_name></tt>. If the specified
+schema doesn't exist in the database, then it's automatically created.
+
+<p>
+Export vector map "bridges" as feature table in database
+schema "grassout".
+
+<div class="code"><pre>
+v.out.postgis input=bridges dsn="PG:dbname=grass" olayer=grassout.bridges
+</pre></div>
+
+<h3>Export data with creation options</h3>
+
+Example bellow demonstrates how to define name for geometry column and
+disable building spatial index.
+
+<div class="code"><pre>
+v.out.postgis input=roadsmajor dsn="PG:dbname=grass" options="GEOMETRY_NAME=wkb_geometry,SPATIAL_INDEX=NO"
+</pre></div>
+
+<h3>Link exported data</h3>
+
+Exported data can be linked as vector map created in the current
+mapset by specifing <b>olink</b> parameter. In the example below
+vector map "busstopsall" from PERMANENT mapset is exported
+into "grass" PostGIS database. <em>v.out.postgis</em> after
+successful export also creates in the current mapset GRASS vector map
+as a link to the PostGIS feature table.
+
+<div class="code"><pre>
+v.out.postgis input=busstopsall at PERMANENT dsn="PG:dbname=grass" olink=busstopsall_pg
+</pre></div>
+
+Created link can be checked
+by <em><a href="v.info.html">v.info</a></em>:
+
+<div class="code"><pre>
+ v.info busstopsall_pg
+
+...
+ |----------------------------------------------------------------------------|
+ | Map format: PostGIS (PostgreSQL) |
+ | DB table: public.busstopsall |
+ | DB name: grass |
+ | Geometry column: geom |
+ | Feature type: point |
+ | Topology: pseudo (simple features) |
+ |----------------------------------------------------------------------------|
+...
+
+</pre></div>
+
+<h3>Export topological data</h3>
+
<h2>TODO</h2>
<ul>
@@ -49,19 +166,23 @@
<h2>REFERENCES</h2>
<ul>
- <li><a href="http://postgis.refractions.net/docs/Topology.html">PostGIS Topology</a> manual</li>
+ <li><a href="http://www.opengeospatial.org/standards/sfa">OGC Simple Feature Access</a> specification</li>
+ <li><a href="http://postgis.refractions.net/docs/Topology.html">PostGIS Topology</a> documentation</li>
</ul>
<h2>SEE ALSO</h2>
<em>
<a href="v.out.ogr.html">v.out.ogr</a>,
- <a href="v.external.out.html">v.external.out</a>
+ <a href="v.external.html">v.external</a>,
+ <a href="v.external.out.html">v.external.out</a>,
+ <a href="v.in.ogr.html">v.in.ogr</a>
</em>
-<h2>AUTHORS</h2>
+<h2>AUTHOR</h2>
Martin Landa, Czech Technical University in Prague, Czech Republic
+(development supported by Fondazione Edmund Mach and Comune di Trento, Italy)
<p>
<i>Last changed: $Date$</i>
More information about the grass-commit
mailing list