[GRASS-SVN] r69869 - grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Nov 22 09:02:05 PST 2016
Author: Giulia
Date: 2016-11-22 09:02:05 -0800 (Tue, 22 Nov 2016)
New Revision: 69869
Modified:
grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py
Log:
r.green: add structure from inputfile
Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py 2016-11-22 15:56:49 UTC (rev 69868)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py 2016-11-22 17:02:05 UTC (rev 69869)
@@ -96,8 +96,12 @@
#%option G_OPT_V_OUTPUT
#% key: output_struct
#% label: Name of output vector with potential plants and their structure
-#% required: yes
#%end
+#%option G_OPT_V_INPUT
+#% key: input_struct
+#% label: Name of input vector with potential plants and their structure
+#% required: no
+#%end
#%option G_OPT_V_OUTPUT
#% key: output_plant
#% label: Name of output vector map with segments of potential plants
@@ -202,6 +206,10 @@
#% guisection: Contour
#%end
+#%rules
+#% exclusive: input_struct,output_struct
+#%end
+
# import system libraries
from __future__ import print_function
import os
@@ -243,6 +251,7 @@
print("You must be in GRASS GIS to run this program.")
sys.exit(1)
+
def add_columns(vector, cols):
"""Add new column if not already present in the vector table.
columns is a list of tuple with the column name and the column type."""
@@ -671,17 +680,11 @@
elevation = options['elevation']
plant = options['plant']
output_struct = options['output_struct']
+ input_struct = options['input_struct']
output_plant = options['output_plant']
percentage_losses = float(options['percentage_losses'])
roughness_penstock = float(options['roughness_penstock'])
ks_derivation = float(options['ks_derivation'])
- plant_layer = float(options['plant_layer'])
- plant_column_discharge = options['plant_column_discharge']
- plant_column_plant_id = options['plant_column_plant_id']
- plant_column_point_id = options['plant_column_point_id']
- plant_column_elevup = options['plant_column_elevup']
- plant_column_elevdown = options['plant_column_elevdown']
- plant_column_power = options['plant_column_power']
turbine_folder = (options['turbine_folder'] if options['turbine_folder']
else os.path.join(os.path.abspath('.'), 'turbines'))
turbine_list = (options['turbine_list'] if options['turbine_list'] else
@@ -714,11 +717,14 @@
contour=options['contour'], overwrite=gcore.overwrite())
if options['resolution']:
struct_opts['resolution'] = options['resolution']
-## --------------------------------------------------------------------------
- gcore.run_command('r.green.hydro.structure', **struct_opts)
-
- gcore.run_command('v.build', map=output_struct)
## --------------------------------------------------------------------------
+ if output_struct:
+ gcore.run_command('r.green.hydro.structure', **struct_opts)
+ gcore.run_command('v.build', map=output_struct)
+ else:
+ output_struct = input_struct
+ # FIXME: check the structure of the input file
+## --------------------------------------------------------------------------
gcore.run_command('g.copy', vector=(plant, output_plant))
with VectorTopo(output_struct, mode='rw') as struct:
list_intakeid = compute_losses(struct, options,
More information about the grass-commit
mailing list