Skip to content

Commit

Permalink
Adding back fire_layer param, fix WindFile param
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelegissi committed Aug 17, 2023
1 parent 58d813a commit 5b0895e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
6 changes: 4 additions & 2 deletions qgis2fds_export_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def initAlgorithm(self, config=None):
DEMLayerParam.set(**kwargs)
LanduseLayerParam.set(**kwargs)
LanduseTypeFilepathParam.set(**kwargs)
FireLayer.set(**kwargs)
TextFilepathParam.set(**kwargs)
TexLayerParam.set(**kwargs)
TexPixelSizeParam.set(**kwargs)
Expand All @@ -64,7 +65,7 @@ def initAlgorithm(self, config=None):
ExportOBSTParam.set(**kwargs)
StartTimeParam.set(**kwargs)
EndTimeParam.set(**kwargs)
wind_filepath = WindFilepathParam.set(**kwargs)
WindFilepathParam.set(**kwargs)

# Define destination layers

Expand Down Expand Up @@ -123,6 +124,7 @@ def processAlgorithm(self, parameters, context, model_feedback):
dem_layer = DEMLayerParam.get(**kwargs)
landuse_layer = LanduseLayerParam.get(**kwargs)
landuse_type_filepath = LanduseTypeFilepathParam.get(**kwargs)
fire_layer = FireLayer.get(**kwargs)
text_filepath = TextFilepathParam.get(**kwargs)
tex_layer = TexLayerParam.get(**kwargs)
tex_pixel_size = TexPixelSizeParam.get(**kwargs)
Expand Down Expand Up @@ -514,7 +516,7 @@ def processAlgorithm(self, parameters, context, model_feedback):
utm_origin=utm_origin,
landuse_layer=landuse_layer,
landuse_type=landuse_type,
fire_layer=None,
fire_layer=fire_layer,
path=fds_path,
name=chid,
)
Expand Down
47 changes: 44 additions & 3 deletions qgis2fds_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,45 @@ def get(cls, algo, parameters, context, feedback, project):
return value


class FireLayer:
label = "fire_layer"
desc = "Fire layer (if not set, fire is not exported)"
default = None
optional = True

@classmethod
def set(cls, algo, config, project):
defaultValue, _ = project.readEntry("qgis2fds", cls.label, cls.default)
param = QgsProcessingParameterVectorLayer(
cls.label,
cls.desc,
defaultValue=defaultValue,
optional=cls.optional,
)
algo.addParameter(param)

@classmethod
def get(cls, algo, parameters, context, feedback, project):
value = None
if parameters.get(cls.label):
value = algo.parameterAsVectorLayer(parameters, cls.label, context)
if value:
# Check local
url = value.source()
if not os.path.isfile(url):
raise QgsProcessingException(
"Fire layer data is not saved locally, cannot proceed."
)
# Check valid
if not value.crs().isValid():
raise QgsProcessingException(
f"Fire layer CRS <{value.crs().description()}> not valid, cannot proceed."
)
project.writeEntry("qgis2fds", cls.label, parameters.get(cls.label)) # protect
feedback.setProgressText(f"{cls.desc}: <{value}>")
return value


class TextFilepathParam:
label = "text_filepath"
desc = "Free text file"
Expand Down Expand Up @@ -477,7 +516,7 @@ def get(cls, algo, parameters, context, feedback, project):

class StartTimeParam:
label = "t_begin"
desc = "FDS start time"
desc = "FDS start time" # FIXME
default = 0.0
optional = True

Expand All @@ -499,10 +538,11 @@ def get(cls, algo, parameters, context, feedback, project):
project.writeEntry("qgis2fds", cls.label, value)
feedback.setProgressText(f"{cls.desc}: <{value}>")
return value



class EndTimeParam:
label = "t_end"
desc = "FDS end time"
desc = "FDS end time" # FIXME
default = 0.0
optional = True

Expand All @@ -525,6 +565,7 @@ def get(cls, algo, parameters, context, feedback, project):
feedback.setProgressText(f"{cls.desc}: <{value}>")
return value


class WindFilepathParam:
label = "wind_filepath"
desc = "Wind text file"
Expand Down

0 comments on commit 5b0895e

Please sign in to comment.