En raison du déménagement des baies serveurs, les services gitlab.irstea.fr et mattermost.irstea.fr seront interrompus le samedi 2 octobre 2021 au matin. Ils devraient revenir à la normale dans la journée.

Commit fc6be731 authored by Rabotin Michael's avatar Rabotin Michael
Browse files

Added null value in col_name for gauge input file tested

parent 08542286
......@@ -36,6 +36,8 @@ except Exception as e:
#import grass.script as grass
from grass.script.utils import decode, encode
from osgeo import ogr
MY_ABS_PATH=os.path.abspath(__file__)
MY_DIR=os.path.dirname(MY_ABS_PATH)
DATA_PATH=os.path.join(MY_DIR, '..', 'data')
......@@ -158,12 +160,35 @@ def main(parms_file):
sys.exit('------------> ERROR : Input Gauges not found')
## Test if gauges is point or multipoint
ds=ogr.Open(gauges)
layer=ds.GetLayer()
layer_defn=layer.GetLayerDefn()
if ogr.GeometryTypeToName(layer_defn.GetGeomType()) != 'Point':
GaugesDs=ogr.Open(gauges)
GaugesLayer=GaugesDs.GetLayer()
GaugesLayer_defn=GaugesLayer.GetLayerDefn()
if ogr.GeometryTypeToName(GaugesLayer_defn.GetGeomType()) != 'Point':
sys.exit('------------> ERROR : Input Gauges is not Point Geometry (multi Point not allowed)')
## Test col_name
col_name = parms.get('for_watershed_id', 'col_name')
if col_name == '':
sys.exit('------------> ERROR : CHECK col_name PARAMETER')
## In gauges, test if col_name exist and if no null value
NoColName=False
for n in range(GaugesLayer_defn.GetFieldCount()):
fdefn=GaugesLayer_defn.GetFieldDefn(n)
if fdefn.name == col_name:
NoColName=True
if NoColName == False:
sys.exit('------------> ERROR : col_name PARAMETER not found in gauges input file')
listvalue= [ feature.GetField(col_name) for feature in GaugesLayer ]
if None in listvalue:
sys.exit('------------> ERROR : in col_name in gauges file, null value detected')
if min(listvalue) == 0:
sys.exit('------------> ERROR : in col_name in gauges file, zero value detected')
## if hgeon, landuse and soil provided, test if exist
for data in parms.items('data'):
data = os.path.join(directory, data[1])
......
gauge code;area;rule;horiz shift;horiz dir;vertic shift;vertic dir
224.0;224.0; no better place found;;;;
197.0;197.0; no better place found;;;;
0.0:45.0:1:1
45.0:135.0:2:2
135.0:225.0:3:3
225.0:315.0:4:4
315.0:360.0:1:1
200.0:300.0:1:1
300.0:400.0:2:2
400.0:500.0:3:3
500.0:600.0:4:4
0.0:1.0:1:1
1.0:3.0:3:3
3.0:5.0:5:5
5.0:10.0:10:10
10.0:20.0:20:20
20.0:30.0:30:30
30.0:26.8698:27:27
PROJCS["RGF_1993_Lambert_93",GEOGCS["GCS_RGF_1993",DATUM["D_RGF_1993",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",700000.0],PARAMETER["False_Northing",6600000.0],PARAMETER["Central_Meridian",3.0],PARAMETER["Standard_Parallel_1",49.0],PARAMETER["Standard_Parallel_2",44.0],PARAMETER["Latitude_Of_Origin",46.5],UNIT["Meter",1.0]]
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment