Quellcode durchsuchen

dsn -> input/output/directory, use standardized options (https://trac.osgeo.org/grass/ticket/2409) (https://trac.osgeo.org/grass/changeset/63154 + https://trac.osgeo.org/grass/changeset/63155)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@63159 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler vor 10 Jahren
Ursprung
Commit
337ebd4879

+ 1 - 1
db/drivers/postgres/grass-pg.html

@@ -90,7 +90,7 @@ select AddGeometryColumn ('postgis', 'test', 'geometry', -1, 'GEOMETRY', 2);
 GRASS can import this PostGIS polygon map as follows:
 
 <div class="code"><pre>
-v.in.ogr dsn="PG:host=localhost dbname=postgis user=neteler" layer=test \
+v.in.ogr input="PG:host=localhost dbname=postgis user=neteler" layer=test \
          output=test type=boundary,centroid
 v.db.select test
 v.info -t test

+ 5 - 5
scripts/db.in.ogr/db.in.ogr.html

@@ -15,7 +15,7 @@ columns through a descriptive file with same name as the CSV file, but .csvt ext
 
 <div class="code"><pre>
 # NOTE: create koeppen_gridcode.csvt first for type recognition
-db.in.ogr dsn=koeppen_gridcode.csv output=koeppen_gridcode
+db.in.ogr input=koeppen_gridcode.csv output=koeppen_gridcode
 db.select koeppen_gridcode
 </pre></div>
 
@@ -25,14 +25,14 @@ Import of a DBF table with additional unique key column (e.g., needed
 for <em><a href="v.in.db.html">v.in.db</a></em>).
 
 <div class="code"><pre>
-db.in.ogr dsn=/path/to/mydata.dbf output=census_raleigh key=myid
+db.in.ogr input=/path/to/mydata.dbf output=census_raleigh key=myid
 db.describe -c census_raleigh
 </pre></div>
 
 <h3>Import of a SQLite table</h3>
 
 <div class="code"><pre>
-db.in.ogr dsn=/path/to/sqlite.db db_table=census_raleigh output=census_raleigh
+db.in.ogr input=/path/to/sqlite.db db_table=census_raleigh output=census_raleigh
 </pre></div>
 
 <h3>Import of a PostgreSQL table</h3>
@@ -40,7 +40,7 @@ db.in.ogr dsn=/path/to/sqlite.db db_table=census_raleigh output=census_raleigh
 # HINT: if the database contains spatial tables, but you want to import a non-spatial 
 table, set the environmental variable PG_LIST_ALL_TABLES to YES before importing
 
-db.in.ogr dsn="PG:host=localhost dbname=ecad user=neteler" \
+db.in.ogr input="PG:host=localhost dbname=ecad user=neteler" \
           db_table=ecad_verona_tmean output=ecad_verona_tmean
 db.select ecad_verona_tmean
 db.describe -c ecad_verona_tmean
@@ -54,7 +54,7 @@ refers to the list within XLS file.
 
 <div class="code"><pre>
 export OGR_XLS_HEADERS='FORCE'
-db.in.ogr dsn=address.xls db_table=address_data
+db.in.ogr input=address.xls db_table=address_data
 </pre></div>
 
 <h2>SEE ALSO</h2>

+ 3 - 5
scripts/db.in.ogr/db.in.ogr.py

@@ -21,7 +21,7 @@
 #%End
 
 #%option G_OPT_F_INPUT
-#% key: dsn
+#% key: input
 #% gisprompt: old,bin,file
 #% description: Table file to be imported or DB connection string
 #% required : yes
@@ -56,7 +56,7 @@ from grass.exceptions import CalledModuleError
 
 
 def main():
-    dsn = options['dsn']
+    input = options['input']
     db_table = options['db_table']
     output = options['output']
     key = options['key']
@@ -65,8 +65,6 @@ def main():
 
     if db_table:
 	input = db_table
-    else:
-	input = dsn
 
     if not output:
 	tmpname = input.replace('.', '_')
@@ -87,7 +85,7 @@ def main():
 	layer = None
 
     try:
-        grass.run_command('v.in.ogr', flags='o', dsn=dsn, output=output,
+        grass.run_command('v.in.ogr', flags='o', input=input, output=output,
                           layer=layer, quiet=True)
     except CalledModuleError:
         if db_table:

+ 10 - 10
scripts/db.out.ogr/db.out.ogr.py

@@ -26,7 +26,7 @@
 #%end
 
 #%option G_OPT_F_OUTPUT
-#% key: dsn
+#% key: output
 #% description: Table file to be exported or DB connection string
 #% required : yes
 #%end
@@ -63,14 +63,14 @@ def main():
     input = options['input']
     layer = options['layer']
     format = options['format']
-    dsn = options['dsn']
+    output = options['output']
     table = options['table']
 
     if format.lower() == 'dbf':
 	format = "ESRI_Shapefile"
 
     if format.lower() == 'csv':
-	olayer = basename(dsn, 'csv')
+	olayer = basename(output, 'csv')
     else:
 	olayer = None
 
@@ -82,7 +82,7 @@ def main():
     if olayer:
         try:
             grass.run_command('v.out.ogr', quiet=True, input=input, layer=layer,
-                              dsn=dsn,
+                              output=output,
                               format=format, type='point,line,area',
                               olayer=olayer)
         except CalledModuleError:
@@ -91,24 +91,24 @@ def main():
     else:
         try:
             grass.run_command('v.out.ogr', quiet=True, input=input,
-                              layer=layer, dsn=dsn,
+                              layer=layer, output=output,
                               format=format, type='point,line,area')
         except CalledModuleError:
             grass.fatal(_("Module <%s> failed") % 'v.out.ogr')
 
     if format == "ESRI_Shapefile":
 	exts = ['shp', 'shx', 'prj']
-	if dsn.endswith('.dbf'):
-	    outname = basename(dsn, 'dbf')
+	if output.endswith('.dbf'):
+	    outname = basename(output, 'dbf')
 	    for ext in exts:
 		try_remove("%s.%s" % (outname, ext))
 	    outname += '.dbf'
 	else:
 	    for ext in exts:
-		try_remove(os.path.join(dsn, "%s.%s" % (input, ext)))
-	    outname = os.path.join(dsn, input + ".dbf")
+		try_remove(os.path.join(output, "%s.%s" % (input, ext)))
+	    outname = os.path.join(output, input + ".dbf")
     elif format.lower() == 'csv':
-	outname = dsn + '.csv'
+	outname = output + '.csv'
     else:
 	outname = input
 

+ 1 - 1
scripts/v.db.update/v.db.update.py

@@ -7,7 +7,7 @@
 #               Extensions by Markus Neteler
 #               Converted to Python by Glynn Clements
 # PURPOSE:      Interface to db.execute to update a column in the attribute table connected to a given map
-# COPYRIGHT:    (C) 2005,2007-2008,2011 by the GRASS Development Team
+# COPYRIGHT:    (C) 2005-2014 by the GRASS Development Team
 #
 #               This program is free software under the GNU General Public
 #               License (>=v2). Read the file COPYING that comes with GRASS

+ 2 - 2
vector/v.external.out/args.c

@@ -9,9 +9,9 @@ void parse_args(int argc, char **argv,
 		struct _options *options, struct _flags *flags)
 {
     options->dsn = G_define_option();
-    options->dsn->key = "input";
+    options->dsn->key = "directory";
     options->dsn->type = TYPE_STRING;
-    options->dsn->label = _("Name of input OGR or PostGIS data source");
+    options->dsn->label = _("Name of output directory or OGR or PostGIS data source");
     options->dsn->description = _("Examples:\n"
 				  "\t\tESRI Shapefile: directory containing a shapefile\n"
 				  "\t\tMapInfo File: directory containing a mapinfo file\n"

+ 8 - 8
vector/v.external.out/v.external.out.html

@@ -89,10 +89,10 @@ Shapefile format:
 
 <div class="code"><pre>
 # register Shapefile in GRASS mapset:
-v.external dsn=/path/to/shapefiles layer=cities
+v.external input=/path/to/shapefiles layer=cities
 
 # define output directory for GRASS calculation results:
-v.external.out dsn=$HOME/gisoutput
+v.external.out output=$HOME/gisoutput
 
 # do something (here: spatial query), write output directly as Shapefile
 v.select ainput=cities atype=point binput=forests btype=area operator=within output=fcities
@@ -103,7 +103,7 @@ Current settings can be printed using <b>-p</b> or <b>-g</b> flag.
 <div class="code"><pre>
 v.external.out -p
 
-dsn: /path/to/home/gisoutput
+output: /path/to/home/gisoutput
 format: ESRI Shapefile
 </pre></div>
 
@@ -114,10 +114,10 @@ provider</em> (GRASS must be compiled with PostgreSQL support).
 
 <div class="code"><pre>
 # register PostGIS table in GRASS mapset:
-v.external dsn=PG:dbname=gisdb layer=cities
+v.external output=PG:dbname=gisdb layer=cities
 
 # define output PostGIS database for GRASS calculation results stored as simple features:
-v.external.out dsn=PG:dbname=gisdb format=PostgreSQL
+v.external.out output=PG:dbname=gisdb format=PostgreSQL
 
 # do some processing...
 </pre></div>
@@ -131,7 +131,7 @@ PostGIS data.
 
 <div class="code"><pre>
 # define output PostGIS database for GRASS calculation results stored as topological elements:
-v.external.out dsn=PG:dbname=gisdb format=PostgreSQL options=topology=YES
+v.external.out output=PG:dbname=gisdb format=PostgreSQL options=topology=YES
 
 # do some processing...
 </pre></div>
@@ -153,7 +153,7 @@ Current settings can be stored to file by specifying <b>output</b> option.
 
 <div class="code"><pre>
 # define output PostGIS database for GRASS calculation results stored as topological elements:
-v.external.out dsn=PG:dbname=gisdb format=PostgreSQL options=topology=YES output=gisdb_topo.txt
+v.external.out output=PG:dbname=gisdb format=PostgreSQL options=topology=YES output=gisdb_topo.txt
 
 # do some processing in PostGIS Topology
 </pre></div>
@@ -169,7 +169,7 @@ v.external.out -r
 Restore previous settings from &quot;gisdb_topo.txt&quot; file by specifying <b>input</b> option.
 
 <div class="code"><pre>
-v.external.out input=gisdb_topo.txt
+v.external.out output=gisdb_topo.txt
 
 # do some processing in PostGIS Topology
 </pre></div>

+ 5 - 5
vector/v.external/v.external.html

@@ -27,13 +27,13 @@ Assuming that 'test_shape.shp' is located in directory
 '/home/user/shape_data'.
 
 <div class="code"><pre>
-v.external dsn=/home/user/shape_data layer=test_shape output=grass_map 
+v.external input=/home/user/shape_data layer=test_shape output=grass_map 
 </pre></div>
 
 <h3>MapInfo files</h3>
 
 <div class="code"><pre>
-v.external dsn=./ layer=mapinfo_test output=grass_map
+v.external input=./ layer=mapinfo_test output=grass_map
 </pre></div>
 
 <h3>SDTS files</h3>
@@ -41,13 +41,13 @@ v.external dsn=./ layer=mapinfo_test output=grass_map
 Note: you have to select the CATD file
 
 <div class="code"><pre>
-v.external dsn=CITXCATD.DDF output=cities
+v.external input=CITXCATD.DDF output=cities
 </pre></div>
 
 <h3>TIGER files</h3>
 
 <div class="code"><pre>
-v.external dsn=input/2000/56015/ layer=CompleteChain,PIP output=t56015_all
+v.external input=input/2000/56015/ layer=CompleteChain,PIP output=t56015_all
 </pre></div>
 
 <h3>PostGIS layers</h3>
@@ -59,7 +59,7 @@ without PostgreSQL support then GRASS will use OGR-PostgreSQL driver
 for creating a link.
 
 <div class="code"><pre>
-v.external dsn="PG:host=localhost user=postgres dbname=postgis" layer=polymap
+v.external input="PG:host=localhost user=postgres dbname=postgis" layer=polymap
 </pre></div>
 
 <h2>NOTES</h2>

+ 1 - 1
vector/v.in.ogr/main.c

@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
     module->description = _("Imports vector data into a GRASS vector map using OGR library.");
 
     param.dsn = G_define_option();
-    param.dsn->key = "dsn";
+    param.dsn->key = "input";
     param.dsn->type = TYPE_STRING;
     param.dsn->required =YES;
     param.dsn->label = _("OGR datasource name");

+ 9 - 9
vector/v.in.ogr/v.in.ogr.html

@@ -156,13 +156,13 @@ The command imports various vector formats:
 <h3>SHAPE files</h3>
 
 <div class="code"><pre>
-v.in.ogr dsn=/home/user/shape_data/test_shape.shp output=grass_map 
+v.in.ogr input=/home/user/shape_data/test_shape.shp output=grass_map 
 </pre></div>
 
 Alternate method:
 
 <div class="code"><pre>
-v.in.ogr dsn=/home/user/shape_data layer=test_shape output=grass_map 
+v.in.ogr input=/home/user/shape_data layer=test_shape output=grass_map 
 </pre></div>
 
 Define encoding value for attribute data (in this example we expect
@@ -172,13 +172,13 @@ encoding; ie. in Central/Eastern European languages that
 use Latin script, Microsoft Windows encoding).
 
 <div class="code"><pre>
-v.in.ogr dsn=/home/user/shape_data/test_shape.shp output=grass_map encoding=cp1250
+v.in.ogr input=/home/user/shape_data/test_shape.shp output=grass_map encoding=cp1250
 </pre></div>
 
 <h3>MapInfo files</h3>
 
 <div class="code"><pre>
-v.in.ogr dsn=./ layer=mapinfo_test output=grass_map
+v.in.ogr input=./ layer=mapinfo_test output=grass_map
 </pre></div>
 
 <h3>Arc Coverage</h3>
@@ -187,7 +187,7 @@ We import the Arcs and Label points, the module takes care to build
 areas.
 
 <div class="code"><pre>
-v.in.ogr dsn=gemeinden layer=LAB,ARC type=centroid,boundary output=mymap
+v.in.ogr input=gemeinden layer=LAB,ARC type=centroid,boundary output=mymap
 </pre></div>
 
 <h3>E00 file</h3>
@@ -203,7 +203,7 @@ fails):
 
 <div class="code"><pre>
 avcimport e00file coverage
-v.in.ogr dsn=coverage layer=LAB,ARC type=centroid,boundary output=mymap
+v.in.ogr input=coverage layer=LAB,ARC type=centroid,boundary output=mymap
 </pre></div>
 
 <h3>SDTS files</h3> 
@@ -211,13 +211,13 @@ v.in.ogr dsn=coverage layer=LAB,ARC type=centroid,boundary output=mymap
 You have to select the CATD file.
 
 <div class="code"><pre>
-v.in.ogr dsn=CITXCATD.DDF output=cities
+v.in.ogr input=CITXCATD.DDF output=cities
 </pre></div>
 
 <h3>TIGER files</h3>
 
 <div class="code"><pre>
-v.in.ogr dsn=input/2000/56015/ layer=CompleteChain,PIP output=t56015_all \
+v.in.ogr input=input/2000/56015/ layer=CompleteChain,PIP output=t56015_all \
 type=boundary,centroid snap=-1
 </pre></div>
 
@@ -226,7 +226,7 @@ type=boundary,centroid snap=-1
 Area example:
 
 <div class="code"><pre>
-v.in.ogr dsn="PG:host=localhost dbname=postgis user=postgres" layer=polymap \
+v.in.ogr input="PG:host=localhost dbname=postgis user=postgres" layer=polymap \
 output=polygons type=boundary,centroid
 </pre></div>
 

+ 1 - 1
vector/v.info/v.info.html

@@ -51,7 +51,7 @@ v.info map=geology
 <div class="code"><pre>
 v.info -h map=geology
 
-COMMAND: v.in.ogr dsn="geol.shp" output="geology" min_area=0.0001 snap=-1
+COMMAND: v.in.ogr input="geol.shp" output="geology" min_area=0.0001 snap=-1
 GISDBASE: /bigdata/grassdata05
 LOCATION: ncfromfile MAPSET: PERMANENT USER: helena DATE: Mon Nov  6 15:48:53 2006
 ---------------------------------------------------------------------------------

+ 10 - 10
vector/v.out.ogr/v.out.ogr.html

@@ -61,7 +61,7 @@ multi-features are not supported by all formats.
 Export lines from GRASS vector map to Shapefile format:
 
 <div class="code"><pre>
-v.out.ogr input=lines type=line dsn=lines.shp
+v.out.ogr input=lines type=line output=lines.shp
 </pre></div>
 
 <p>
@@ -69,34 +69,34 @@ Export areas from GRASS vector map to Shapefile format, converting
 islands (holes) to filled polygons:
 
 <div class="code"><pre>
-v.out.ogr -c input=areas_islands type=area dsn=areas_islands.shp
+v.out.ogr -c input=areas_islands type=area output=areas_islands.shp
 </pre></div>
 
 <p>
 Export 3D lines from GRASS vector map to Shapefile format:
 
 <div class="code"><pre>
-v.out.ogr input=lines_3d type=line dsn=lines_3d.shp lco="SHPT=ARCZ"
+v.out.ogr input=lines_3d type=line output=lines_3d.shp lco="SHPT=ARCZ"
 </pre></div>
 
 <p>
 Export 3D points (e.g., Lidar points) from GRASS vector map to Shapefile format
 
 <div class="code"><pre>
-v.out.ogr points_3d type=point dsn=points_3d.shp lco="SHPT=POINTZ"
+v.out.ogr points_3d type=point output=points_3d.shp lco="SHPT=POINTZ"
 </pre></div>
 
 <p>
 Export 3D faces from GRASS vector map to Shapefile format:
 <div class="code"><pre>
-v.out.ogr input=objects_3d type=face dsn=faces_3d.shp lco="SHPT=POLYGONZ"
+v.out.ogr input=objects_3d type=face output=faces_3d.shp lco="SHPT=POLYGONZ"
 </pre></div>
 
 <p>
 Export 3D faces from GRASS vector map to Shapefile format, automatic 3D setting:
 
 <div class="code"><pre>
-v.out.ogr input=objects_3d type=face dsn=faces_3d.shp"
+v.out.ogr input=objects_3d type=face output=faces_3d.shp"
 </pre></div>
 
 <h3>Export to GML</h3>
@@ -105,7 +105,7 @@ Export lines from GRASS vector map to GML format
  (generates '/tmp/testogr.gml' file with layer 'testogr'):
 
 <div class="code"><pre>
-v.out.ogr input=multi type=line dsn=/tmp/testogr.gml olayer=testogr format=GML 
+v.out.ogr input=multi type=line output=/tmp/testogr.gml olayer=testogr format=GML 
 </pre></div>
 
 <h3>Export to PostgreSQL/PostGIS</h3>
@@ -113,7 +113,7 @@ v.out.ogr input=multi type=line dsn=/tmp/testogr.gml olayer=testogr format=GML
 Export areas from GRASS vector map to PostGIS database:
 
 <div class="code"><pre>
-v.out.ogr input=polygons type=area dsn="PG:host=localhost dbname=postgis user=postgres" olayer=polymap format=PostgreSQL
+v.out.ogr input=polygons type=area output="PG:host=localhost dbname=postgis user=postgres" olayer=polymap format=PostgreSQL
 </pre></div>
 
 <i>Note:</i> For exporting GRASS vector data to PostGIS database can
@@ -127,7 +127,7 @@ simple features also topological format (PostGIS Topology).
 Export faces (3D vectors) from GRASS vector map to KML format for Google Earth:
 
 <div class="code"><pre>
-v.out.ogr input=buildings_3d dsn=buildings_3d.kml olayer=buildings_3d format=KML type=face
+v.out.ogr input=buildings_3d output=buildings_3d.kml olayer=buildings_3d format=KML type=face
 </pre></div>
 
 <p>
@@ -149,7 +149,7 @@ v.patch input=random3d_a,random3d_b output=random3d
 v.hull input=random3d output="random3d_hull"
 
 # export to KML 3D
-v.out.ogr input=random3d_hull dsn=random3d_hull.kml format=KML type=face dsco="AltitudeMode=absolute"
+v.out.ogr input=random3d_hull output=random3d_hull.kml format=KML type=face dsco="AltitudeMode=absolute"
 
 # now open KML file 'random3d_hull.kml' in Google Earth or NASA WorldWind or ...
 </pre></div>

+ 8 - 8
vector/v.out.postgis/v.out.postgis.html

@@ -4,7 +4,7 @@
 PostGIS feature table. Features without category are skipped.
 
 <p>
-By default GRASS topological features are converted into simple
+By default GRASS GIS 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
@@ -129,7 +129,7 @@ located in database &quot;grass&quot;, schema &quot;public&quot;. 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"
+v.out.postgis input=urbanarea output="PG:dbname=grass"
 </pre></div>
 
 GRASS areas are converted into polygons, isles into holes. We can
@@ -147,7 +147,7 @@ ST_Polygon|657
 by <em><a href="v.out.ogr.html">v.out.ogr</a></em> module, eg.
 
 <div class="code"><pre>
-v.out.ogr input=urbanarea dsn="PG:dbname=grass" format=PostgreSQL
+v.out.ogr input=urbanarea output="PG:dbname=grass" format=PostgreSQL
 </pre></div>
 
 In this case GRASS vector data are exported to PostGIS database using
@@ -170,7 +170,7 @@ Export vector map &quot;bridges&quot; as feature table in database
 schema &quot;grassout&quot;.
 
 <div class="code"><pre>
-v.out.postgis input=bridges dsn="PG:dbname=grass" olayer=grassout.bridges
+v.out.postgis input=bridges output="PG:dbname=grass" olayer=grassout.bridges
 </pre></div>
 
 <h3>Export data with creation options</h3>
@@ -181,7 +181,7 @@ by <tt>srid</tt> identifier which corresponds in this case with EPSG
 3358 (North Carolina dataset).
 
 <div class="code"><pre>
-v.out.postgis input=roadsmajor dsn="PG:dbname=grass" options="GEOMETRY_NAME=wkb_geometry,SPATIAL_INDEX=NO,SRID=3358"
+v.out.postgis input=roadsmajor output="PG:dbname=grass" options="GEOMETRY_NAME=wkb_geometry,SPATIAL_INDEX=NO,SRID=3358"
 </pre></div>
 
 <h3>Link exported data</h3>
@@ -194,7 +194,7 @@ 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@PERMANENT dsn="PG:dbname=grass" olink=busstopsall_pg
+v.out.postgis input=busstopsall@PERMANENT output="PG:dbname=grass" olink=busstopsall_pg
 </pre></div>
 
 Created link can be checked
@@ -225,7 +225,7 @@ Command bellow exports vector features without attributes. The feature
 will contain only two columns, the fid and geometry column.
 
 <div class="code"><pre>
-v.out.postgis -t input=railroads dsn="PG:dbname=grass"
+v.out.postgis -t input=railroads output="PG:dbname=grass"
 </pre></div>
 
 <h3>Export topological data</h3>
@@ -237,7 +237,7 @@ instead of simple features. Export topological elements is stored in
 Topology</a> schema.
 
 <div class="code"><pre>
-v.out.postgis -l input=busroutesall dsn="PG:dbname=grass"
+v.out.postgis -l input=busroutesall output="PG:dbname=grass"
 </pre></div>
 
 For more info about PostGIS Topology implementation in GRASS see