Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tif compat #71

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions fireanalyticstoolbox/algorithm_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ def checkParameterValues(self, parameters: dict[str, Any], context: QgsProcessin
fuels = rasters.pop("fuels")
fuels_props = get_qgs_raster_properties(fuels)
fuel_driver = get_gdal_driver_shortname(fuels)
if fuel_driver != "AAIGrid":
return False, f"fuel raster is not AAIGrid, got {fuel_driver}"
if fuel_driver not in ["AAIGrid", "GTiff"]:
return False, f"fuel raster is not AAIGrid nor GTiff, got {fuel_driver}"
for k, v in rasters.items():
if v is None:
continue
driver = get_gdal_driver_shortname(v)
if driver != "AAIGrid":
return False, f'{k} is not AAIGrid, "{v.name()}" is {driver}'
if driver not in ["AAIGrid", "GTiff"]:
return False, f'{k} is not AAIGrid nor GTiff, "{v.name()}" is {driver}'
raster_props = get_qgs_raster_properties(v)
if raster_props["units"] != QgsUnitTypes.DistanceMeters:
unit_name = Qgis.DistanceUnit(raster_props["units"]).name
Expand Down Expand Up @@ -589,7 +589,15 @@ def processAlgorithm(self, parameters, context, feedback):
or (k == "py" and ignition_mode == 1)
):
feedback.pushDebugInfo(f"copy: {k}:{v}")
copy(v.publicSource(), Path(instance_dir, f"{k}.asc"))
driver = get_gdal_driver_shortname(v)
if driver == "GTiff":
ext = ".tif"
elif driver == "AAIGrid":
ext = ".asc"
else:
# TODO create tif
feedback.reportError(f"unsupported raster format: {k}, {v}, {driver}")
copy(v.publicSource(), Path(instance_dir, f"{k}.{ext}"))
else:
feedback.pushDebugInfo(f"NO copy: {k}:{v}")
feedback.pushDebugInfo("\n")
Expand Down