[GRASS-SVN] r51964 - grass-addons/grass7/vector/v.build.pg
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 4 00:59:49 PDT 2012
Author: martinl
Date: 2012-06-04 00:59:48 -0700 (Mon, 04 Jun 2012)
New Revision: 51964
Modified:
grass-addons/grass7/vector/v.build.pg/v.build.pg.html
grass-addons/grass7/vector/v.build.pg/v.build.pg.py
Log:
v.build.pg: update manual
topo_schema option optional
Modified: grass-addons/grass7/vector/v.build.pg/v.build.pg.html
===================================================================
--- grass-addons/grass7/vector/v.build.pg/v.build.pg.html 2012-06-03 19:10:30 UTC (rev 51963)
+++ grass-addons/grass7/vector/v.build.pg/v.build.pg.html 2012-06-04 07:59:48 UTC (rev 51964)
@@ -8,15 +8,56 @@
Note
that <a href="http://trac.osgeo.org/postgis/wiki/UsersWikiPostgisTopology">PostGIS
Topology</a> extension is currently under
-development. <em>v.build.pg</em> requires PostGIS 2.0.0+.
+development. <em>v.build.pg</em> requires <b>PostGIS 2.0.0+</b>.
<p>
-Existing PostGIS topology can be overwrite by <b>--overwrite</b> flag.
+Existing PostGIS topology schema can be overwrite by <b>--overwrite</b> flag.
<h2>EXAMPLES</h2>
- at TODO
+<h3>Workflow example</h3>
+Export vector map into PostGIS:
+
+<div class="code"><pre>
+v.out.ogr dsn=PG:dbname=pgis_nc input=bridges format=PostgreSQL
+</pre></div>
+
+Create a new vector map as a link to PostGIS table:
+
+<div class="code"><pre>
+v.external dsn=PG:dbname=pgis_nc layer=bridges
+</pre></div>
+
+Check metadata:
+
+<div class="code"><pre>
+v.info map=bridges
+
+...
+ |----------------------------------------------------------------------------|
+ | Map format: PostGIS (PostgreSQL) |
+ | DB table: public.bridges |
+ | DB name: pgis_nc |
+ | Geometry column: wkb_geometry |
+ | Feature type: point |
+ |----------------------------------------------------------------------------|
+...
+</pre></div>
+
+Build PostGIS topology for the link:
+
+<div class="code"><pre>
+v.build.pg map=bridges
+
+...
+Topology topo_bridges (6), SRID 900914, precision 1
+10938 nodes, 0 edges, 0 faces, 10938 topogeoms in 1 layers
+Layer 1, type Puntal (1), 10938 topogeoms
+ Deploy: public.bridges.topo
+...
+</pre></div>
+
<h2>AUTHOR</h2>
Martin Landa, Czech Technical University in Prague
Modified: grass-addons/grass7/vector/v.build.pg/v.build.pg.py
===================================================================
--- grass-addons/grass7/vector/v.build.pg/v.build.pg.py 2012-06-03 19:10:30 UTC (rev 51963)
+++ grass-addons/grass7/vector/v.build.pg/v.build.pg.py 2012-06-04 07:59:48 UTC (rev 51964)
@@ -13,7 +13,7 @@
#############################################################################
#%module
-#% description: Builds PostGIS topology for PG-linked vector map.
+#% description: Builds PostGIS topology for vector map linked via v.external.
#% keywords: vector
#% keywords: external
#% keywords: PostGIS
@@ -25,9 +25,9 @@
#%end
#%option
#% key: topo_schema
-#% description: Name of schema where to build PostGIS topology
+#% label: Name of schema where to build PostGIS topology
+#% description: Default: topo_<map>
#% key_desc: name
-#% required: yes
#%end
#%option
#% key: topo_column
@@ -86,6 +86,10 @@
pg_conn = { 'driver': 'pg',
'database' : vInfo['pg_dbname'] }
+ # default topo schema
+ if not options['topo_schema']:
+ options['topo_schema'] = 'topo_%s' % options['map']
+
# check if topology schema already exists
topo_found = False
ret = grass.db_select(sql = "SELECT COUNT(*) FROM topology.topology " \
@@ -107,15 +111,15 @@
# drop topo schema if exists
execute(sql = "SELECT topology.DropTopology('%s')" % options['topo_schema'],
msg = _("Unable to remove topology schema"))
-
+
# create topo schema
schema, table = vInfo['pg_table'].split('.')
- grass.message(_("Create new topology schema..."))
+ grass.message(_("Creating new topology schema..."))
execute("SELECT topology.createtopology('%s', find_srid('%s', '%s', '%s'), %s)" % \
(options['topo_schema'], schema, table, vInfo['geometry_column'], options['tolerance']))
-
+
# add topo column to the feature table
- grass.message(_("Create new topology column..."))
+ grass.message(_("Adding new topology column..."))
execute("SELECT topology.AddTopoGeometryColumn('%s', '%s', '%s', '%s', '%s')" % \
(options['topo_schema'], schema, table, options['topo_column'], vInfo['feature_type']))
More information about the grass-commit
mailing list