[GRASS-SVN] r51897 - in grass-addons/grass7/vector: . v.external.all
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 31 03:36:10 PDT 2012
Author: martinl
Date: 2012-05-31 03:36:09 -0700 (Thu, 31 May 2012)
New Revision: 51897
Added:
grass-addons/grass7/vector/v.external.all/
grass-addons/grass7/vector/v.external.all/Makefile
grass-addons/grass7/vector/v.external.all/v.external.all.html
grass-addons/grass7/vector/v.external.all/v.external.all.py
Log:
new module v.external.all
Added: grass-addons/grass7/vector/v.external.all/Makefile
===================================================================
--- grass-addons/grass7/vector/v.external.all/Makefile (rev 0)
+++ grass-addons/grass7/vector/v.external.all/Makefile 2012-05-31 10:36:09 UTC (rev 51897)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.external.all
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Property changes on: grass-addons/grass7/vector/v.external.all/Makefile
___________________________________________________________________
Added: svn:mime-type
+ text/x-makefile
Added: svn:eol-style
+ native
Added: grass-addons/grass7/vector/v.external.all/v.external.all.html
===================================================================
--- grass-addons/grass7/vector/v.external.all/v.external.all.html (rev 0)
+++ grass-addons/grass7/vector/v.external.all/v.external.all.html 2012-05-31 10:36:09 UTC (rev 51897)
@@ -0,0 +1,65 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.external.all</em> creates
+(using <em><a href="v.external.html">v.external</a></em>) in the
+current mapset new pseudo-vector maps for all OGR layers from given
+OGR datasource (<b>dsn</b> option).
+
+<h2>EXAMPLES</h2>
+
+<h3>PostGIS</h3>
+
+List available feature tables in given PostGIS database
+
+<div class="code"><pre>
+v.external.all -l dsn=PG:dbname=pgis_nc
+
+PostGIS database <pgis_nc> contains 55 feature table(s):
+boundary_county
+boundary_municp
+bridges
+busroute1
+busroute11
+busroute6
+busroute_a
+busroutesall
+busstopsall
+censusblk_swwake
+census_wake2000
+...
+</pre></div>
+
+Create links (ie. pseudo-vector maps) in the current mapset for all
+PostGIS feature tables
+
+<div class="code"><pre>
+v.external.all dsn=PG:dbname=pgis_nc
+</pre></div>
+
+<h3>Esri Shapefile</h3>
+
+<div class="code"><pre>
+v.external.all -l dsn=~/geodata/ncshape/
+Data source </home/martin/geodata/ncshape/> (format 'ESRI Shapefile')
+contains 44 layers:
+poi_names_wake
+schools_wake
+urbanarea
+geodetic_swwake_pts
+usgsgages
+busroute_a
+busroute6
+hospitals
+...
+</pre></div>
+
+<div class="code"><pre>
+v.external.all -l dsn=~/geodata/ncshape/
+</pre></div>
+
+<h2>AUTHOR</h2>
+
+Martin Landa, Czech Technical University in Prague
+
+<p>
+<i>Last changed: $Date$</i>
Property changes on: grass-addons/grass7/vector/v.external.all/v.external.all.html
___________________________________________________________________
Added: svn:mime-type
+ text/html
Added: svn:keywords
+ Author Date Id
Added: svn:eol-style
+ native
Added: grass-addons/grass7/vector/v.external.all/v.external.all.py
===================================================================
--- grass-addons/grass7/vector/v.external.all/v.external.all.py (rev 0)
+++ grass-addons/grass7/vector/v.external.all/v.external.all.py 2012-05-31 10:36:09 UTC (rev 51897)
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+############################################################################
+#
+# MODULE: v.external.all
+# AUTHOR(S): Martin Landa
+# PURPOSE: Links all OGR layers available in given OGR datasource.
+# COPYRIGHT: (C) 2012 by Martin Landa, and the GRASS Development Team
+#
+# This program is free software under the GNU General
+# Public License (>=v2). Read the file COPYING that
+# comes with GRASS for details.
+#
+#############################################################################
+
+#%module
+#% description: Links all OGR layers available in given OGR datasource.
+#% keywords: vector
+#% keywords: external
+#%end
+#%flag
+#% key: l
+#% description: List available layers in data source and exit
+#%end
+#%option
+#% key: dsn
+#% type: string
+#% description: Name of input OGR or PostGIS data source
+#% required: yes
+#%end
+
+import os
+import sys
+
+from grass.script import core as grass
+
+def list_layers(dsn):
+ ret = grass.read_command('v.external',
+ flags = 'l',
+ dsn = dsn)
+ if not ret:
+ sys.exit(1)
+
+ return ret.splitlines()
+
+def make_links(dsn):
+ layers = list_layers(dsn)
+
+ for layer in layers:
+ oname = layer.replace('.', '_')
+ grass.message(_("%s\nCreating link for OGR layer <%s> as <%s>...\n%s") % \
+ ('-' * 80, layer, oname, '-' * 80))
+ if 0 != grass.run_command('v.external',
+ dsn = dsn, layer = layer, output = oname):
+ grass.warning(_("Unable to create link for OGR layer <%s>") % layer)
+
+def main():
+ if flags['l']:
+ ret = list_layers(options['dsn'])
+ sys.stdout.write(os.linesep.join(ret))
+ sys.stdout.write(os.linesep)
+ else:
+ make_links(options['dsn'])
+
+ return 0
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ sys.exit(main())
Property changes on: grass-addons/grass7/vector/v.external.all/v.external.all.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list