Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
Legacy
gde_calculations_prototype
Commits
8fa07c3b
Commit
8fa07c3b
authored
May 17, 2021
by
Cecilia Nievas
Browse files
Added input parameters check of SERA_creating_industrial_cells.py
Checks added to GDE_TOOLS_read_config_file.py
parent
5b4a5c4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
GDE_TOOLS_read_config_file.py
View file @
8fa07c3b
...
...
@@ -374,6 +374,84 @@ def check_parameters(config, section_name):
else
:
if
not
config
[
section_name
][
"decimal_places_costs"
].
isnumeric
():
raise
IOError
(
"ERROR!! decimal_places_costs NEEDS TO BE A POSITIVE INTEGER!!"
)
elif
section_name
==
"SERA_creating_industrial_cells"
:
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"countries"
):
raise
IOError
(
"ERROR!! countries PARAMETER MISSING FROM CONFIG FILE!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"col_lon"
):
raise
IOError
(
"ERROR!! col_lon PARAMETER MISSING FROM CONFIG FILE!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"col_lat"
):
raise
IOError
(
"ERROR!! col_lat PARAMETER MISSING FROM CONFIG FILE!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"width_EW"
):
raise
IOError
(
"ERROR!! width_EW PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
if
not
config
[
section_name
][
"width_EW"
].
isnumeric
():
raise
IOError
(
"ERROR!! width_EW NEEDS TO BE A POSITIVE INTEGER!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"width_NS"
):
raise
IOError
(
"ERROR!! width_NS PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
if
not
config
[
section_name
][
"width_NS"
].
isnumeric
():
raise
IOError
(
"ERROR!! width_NS NEEDS TO BE A POSITIVE INTEGER!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"precision_points"
):
raise
IOError
(
"ERROR!! precision_points PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
if
not
config
[
section_name
][
"precision_points"
].
isnumeric
():
raise
IOError
(
"ERROR!! precision_points NEEDS TO BE A POSITIVE INTEGER!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"id_str"
):
raise
IOError
(
"ERROR!! id_str PARAMETER MISSING FROM CONFIG FILE!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"export_type"
):
raise
IOError
(
"ERROR!! export_type PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
if
(
config
[
section_name
][
"export_type"
].
lower
()
!=
"shp"
)
and
(
config
[
section_name
][
"export_type"
].
lower
()
!=
"gpkg"
):
raise
IOError
(
"ERROR!! export_type PARAMETER NOT RECOGNISED!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"in_crs"
):
raise
IOError
(
"ERROR!! in_crs PARAMETER MISSING FROM CONFIG FILE!!"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"consistency_checks"
):
raise
IOError
(
"ERROR!! consistency_checks PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
check_if_param_is_True_or_False
(
config
[
"SERA_creating_industrial_cells"
][
"consistency_checks"
],
"consistency_checks"
,
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"autoadjust"
):
raise
IOError
(
"ERROR!! autoadjust PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
check_if_param_is_True_or_False
(
config
[
"SERA_creating_industrial_cells"
][
"autoadjust"
],
"autoadjust"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"verbose"
):
raise
IOError
(
"ERROR!! verbose PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
check_if_param_is_True_or_False
(
config
[
"SERA_creating_industrial_cells"
][
"verbose"
],
"verbose"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"consistency_tol_dist"
):
raise
IOError
(
"ERROR!! consistency_tol_dist PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
try
:
val
=
float
(
config
[
section_name
][
"consistency_tol_dist"
])
if
val
<=
0.0
:
raise
IOError
(
"ERROR!! consistency_tol_dist PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
except
:
raise
IOError
(
"ERROR!! consistency_tol_dist PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
if
not
config
.
has_option
(
"SERA_creating_industrial_cells"
,
"consistency_tol_area"
):
raise
IOError
(
"ERROR!! consistency_tol_area PARAMETER MISSING FROM CONFIG FILE!!"
)
else
:
try
:
val
=
float
(
config
[
section_name
][
"consistency_tol_area"
])
if
val
<=
0.0
:
raise
IOError
(
"ERROR!! consistency_tol_area PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
except
:
raise
IOError
(
"ERROR!! consistency_tol_area PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
else
:
raise
IOError
(
"ERROR IN check_parameters(): "
+
section_name
+
" NOT RECOGNISED!!"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment