21
21
from cplus_api .models .scenario import ScenarioTask
22
22
from cplus_api .models .layer import BaseLayer , OutputLayer , InputLayer
23
23
from cplus_api .utils .api_helper import convert_size , todict , CustomJsonEncoder
24
+ from cplus_api .utils .default import DEFAULT_VALUES
24
25
25
26
logger = logging .getLogger (__name__ )
26
27
@@ -34,15 +35,15 @@ class TaskConfig(object):
34
35
priority_layers : typing .List = []
35
36
priority_layer_groups : typing .List = []
36
37
analysis_extent : SpatialExtent = None
37
- snapping_enabled : bool = False
38
+ snapping_enabled : bool = DEFAULT_VALUES . snapping_enabled
38
39
snap_layer = ''
39
40
snap_layer_uuid = ''
40
- pathway_suitability_index = 0
41
- carbon_coefficient = 0.0
42
- snap_rescale = False
43
- snap_method = 0
44
- sieve_enabled = False
45
- sieve_threshold = 10.0
41
+ pathway_suitability_index = DEFAULT_VALUES . pathway_suitability_index
42
+ carbon_coefficient = DEFAULT_VALUES . carbon_coefficient
43
+ snap_rescale = DEFAULT_VALUES . snap_rescale
44
+ snap_method = DEFAULT_VALUES . snap_method
45
+ sieve_enabled = DEFAULT_VALUES . sieve_enabled
46
+ sieve_threshold = DEFAULT_VALUES . sieve_threshold
46
47
sieve_mask_uuid = ''
47
48
mask_path = ''
48
49
mask_layers_paths = ''
@@ -52,16 +53,31 @@ class TaskConfig(object):
52
53
carbon_uuid_layers = {}
53
54
priority_uuid_layers = {}
54
55
total_input_layers = 0
56
+ # output selections
57
+ ncs_with_carbon = DEFAULT_VALUES .ncs_with_carbon
58
+ landuse_project = DEFAULT_VALUES .landuse_project
59
+ landuse_normalized = DEFAULT_VALUES .landuse_normalized
60
+ landuse_weighted = DEFAULT_VALUES .landuse_weighted
61
+ highest_position = DEFAULT_VALUES .highest_position
55
62
56
63
def __init__ (self , scenario_name , scenario_desc , extent ,
57
64
analysis_activities , priority_layers ,
58
65
priority_layer_groups ,
59
66
snapping_enabled = False , snap_layer_uuid = '' ,
60
- pathway_suitability_index = 0 ,
61
- carbon_coefficient = 0.0 , snap_rescale = False ,
62
- snap_method = 0 , sieve_enabled = False ,
63
- sieve_threshold = 10.0 , sieve_mask_uuid = '' ,
64
- mask_layer_uuids = '' , scenario_uuid = None ) -> None :
67
+ pathway_suitability_index =
68
+ DEFAULT_VALUES .pathway_suitability_index ,
69
+ carbon_coefficient = DEFAULT_VALUES .carbon_coefficient ,
70
+ snap_rescale = DEFAULT_VALUES .snap_rescale ,
71
+ snap_method = DEFAULT_VALUES .snap_method ,
72
+ sieve_enabled = DEFAULT_VALUES .sieve_enabled ,
73
+ sieve_threshold = DEFAULT_VALUES .sieve_threshold ,
74
+ sieve_mask_uuid = '' ,
75
+ mask_layer_uuids = '' , scenario_uuid = None ,
76
+ ncs_with_carbon = DEFAULT_VALUES .ncs_with_carbon ,
77
+ landuse_project = DEFAULT_VALUES .landuse_project ,
78
+ landuse_normalized = DEFAULT_VALUES .landuse_normalized ,
79
+ landuse_weighted = DEFAULT_VALUES .landuse_weighted ,
80
+ highest_position = DEFAULT_VALUES .highest_position ) -> None :
65
81
self .scenario_name = scenario_name
66
82
self .scenario_desc = scenario_desc
67
83
if scenario_uuid :
@@ -89,6 +105,12 @@ def __init__(self, scenario_name, scenario_desc, extent,
89
105
weighted_activities = [],
90
106
priority_layer_groups = self .priority_layer_groups
91
107
)
108
+ # output selections
109
+ self .ncs_with_carbon = ncs_with_carbon
110
+ self .landuse_project = landuse_project
111
+ self .landuse_normalized = landuse_normalized
112
+ self .landuse_weighted = landuse_weighted
113
+ self .highest_position = highest_position
92
114
93
115
def get_activity (
94
116
self , activity_uuid : str
@@ -137,7 +159,12 @@ def to_dict(self):
137
159
'pathway_uuid_layers' : self .pathway_uuid_layers ,
138
160
'carbon_uuid_layers' : self .carbon_uuid_layers ,
139
161
'priority_uuid_layers' : self .priority_uuid_layers ,
140
- 'total_input_layers' : self .total_input_layers
162
+ 'total_input_layers' : self .total_input_layers ,
163
+ 'ncs_with_carbon' : self .ncs_with_carbon ,
164
+ 'landuse_project' : self .landuse_project ,
165
+ 'landuse_normalized' : self .landuse_normalized ,
166
+ 'landuse_weighted' : self .landuse_weighted ,
167
+ 'highest_position' : self .highest_position
141
168
}
142
169
for activity in self .analysis_activities :
143
170
activity_dict = {
@@ -171,17 +198,34 @@ def from_dict(cls, data: dict) -> typing.Self:
171
198
)
172
199
config .priority_layers = data .get ('priority_layers' , [])
173
200
config .priority_layer_groups = data .get ('priority_layer_groups' , [])
174
- config .snapping_enabled = data .get ('snapping_enabled' , False )
201
+ config .snapping_enabled = data .get (
202
+ 'snapping_enabled' , DEFAULT_VALUES .snapping_enabled )
175
203
config .snap_layer_uuid = data .get ('snap_layer_uuid' , '' )
176
204
config .pathway_suitability_index = data .get (
177
- 'pathway_suitability_index' , 0 )
178
- config .carbon_coefficient = data .get ('carbon_coefficient' , 0.0 )
179
- config .snap_rescale = data .get ('snap_rescale' , False )
180
- config .snap_method = data .get ('snap_method' , 0 )
181
- config .sieve_enabled = data .get ('sieve_enabled' , False )
182
- config .sieve_threshold = data .get ('sieve_threshold' , 10.0 )
205
+ 'pathway_suitability_index' ,
206
+ DEFAULT_VALUES .pathway_suitability_index )
207
+ config .carbon_coefficient = data .get (
208
+ 'carbon_coefficient' , DEFAULT_VALUES .carbon_coefficient )
209
+ config .snap_rescale = data .get (
210
+ 'snap_rescale' , DEFAULT_VALUES .snap_rescale )
211
+ config .snap_method = data .get (
212
+ 'snap_method' , DEFAULT_VALUES .snap_method )
213
+ config .sieve_enabled = data .get (
214
+ 'sieve_enabled' , DEFAULT_VALUES .sieve_enabled )
215
+ config .sieve_threshold = data .get (
216
+ 'sieve_threshold' , DEFAULT_VALUES .sieve_threshold )
183
217
config .sieve_mask_uuid = data .get ('sieve_mask_uuid' , '' )
184
218
config .mask_layer_uuids = data .get ('mask_layer_uuids' , '' )
219
+ config .ncs_with_carbon = data .get (
220
+ 'ncs_with_carbon' , DEFAULT_VALUES .ncs_with_carbon )
221
+ config .landuse_project = data .get (
222
+ 'landuse_project' , DEFAULT_VALUES .landuse_project )
223
+ config .landuse_normalized = data .get (
224
+ 'landuse_normalized' , DEFAULT_VALUES .landuse_normalized )
225
+ config .landuse_weighted = data .get (
226
+ 'landuse_weighted' , DEFAULT_VALUES .landuse_weighted )
227
+ config .highest_position = data .get (
228
+ 'highest_position' , DEFAULT_VALUES .highest_position )
185
229
# store dict of <layer_uuid, list of obj identifier>
186
230
config .priority_uuid_layers = {}
187
231
config .pathway_uuid_layers = {}
0 commit comments