Skip to content

Commit

Permalink
Circumvent a qgis bug in self.parameterAsPoint method
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelegissi committed Mar 24, 2021
1 parent 49277d1 commit 872f099
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions qgis2fds_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ def processAlgorithm(self, parameters, context, model_feedback):
project_crs, wgs84_crs, QgsProject.instance()
)
if parameters["origin"] is not None:
wgs84_origin = self.parameterAsPoint(
parameters, "origin", context, crs=wgs84_crs
)
# preventing a QGIS bug when using parameterAsPoint with crs=wgs84_crs
origin = self.parameterAsPoint(parameters, "origin", context)
wgs84_origin = QgsPoint(origin.x(), origin.y())
wgs84_origin.transform(project_to_wgs84_tr)
feedback.pushInfo(f"Using user origin: <{wgs84_origin}>")
project.writeEntry("qgis2fds", "origin", parameters["origin"])
else: # no origin
Expand All @@ -321,9 +322,10 @@ def processAlgorithm(self, parameters, context, model_feedback):

# Get fire origin in WGS84 CRS
if parameters["fire_origin"] is not None:
wgs84_fire_origin = self.parameterAsPoint(
parameters, "fire_origin", context, crs=wgs84_crs
)
# preventing a QGIS bug when using parameterAsPoint with crs=wgs84_crs
fire_origin = self.parameterAsPoint(parameters, "fire_origin", context)
wgs84_fire_origin = QgsPoint(fire_origin.x(), fire_origin.y())
wgs84_fire_origin.transform(project_to_wgs84_tr)
feedback.pushInfo(f"Using user fire origin: <{wgs84_fire_origin}>")
else:
wgs84_fire_origin = QgsPoint(wgs84_origin.x(), wgs84_origin.y())
Expand Down

0 comments on commit 872f099

Please sign in to comment.