Skip to content

Commit

Permalink
Some minor improvements + stop downloading file styles
Browse files Browse the repository at this point in the history
  • Loading branch information
BERNARD Jeremy committed Jun 26, 2024
1 parent 4ce0106 commit a684c55
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
Binary file not shown.
4 changes: 2 additions & 2 deletions functions/globalVariables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
import pandas as pd

GEOCLIMATE_VERSION = "1.0.0"
GEOCLIMATE_VERSION = "1.0.1-20240624"

GEOCLIMATE_JAR_URL = f"https://github.com/orbisgis/geoclimate/releases/download/v{GEOCLIMATE_VERSION}/geoclimate-{GEOCLIMATE_VERSION}.jar"

Expand Down Expand Up @@ -63,4 +63,4 @@
OSM: [4326, "osm"],
BDT_V2: [2154, "bdtopo_2"],
BDT_V3: [2154, "bdtopo_3"]},
index = ['srid', 'folder_prefix'])
index = ['srid', 'folder_prefix'])
44 changes: 33 additions & 11 deletions processing_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ def processAlgorithm(self, parameters, context, feedback):
styleLanguage = self.parameterAsInt(parameters, self.STYLE_LANGUAGE, context)

#prefix = unidecode.unidecode(weatherScenario).replace(" ", "_")

# Log some errors is some combinations of parameters are not valid
if location and not bbox.isNull():
raise QgsProcessingException("You should fill a location OR select an extent, not both !!")
Expand All @@ -231,9 +230,9 @@ def processAlgorithm(self, parameters, context, feedback):
feedback = feedback)

# Check that the last sld style has been downloaded
downloadLastStyles(plugin_directory = plugin_directory,
feedback = feedback,
language = styleLanguage)
# downloadLastStyles(plugin_directory = plugin_directory,
# feedback = feedback,
# language = styleLanguage)

# Recover the bbox coordinates if exists
if not bbox.isNull():
Expand Down Expand Up @@ -264,8 +263,31 @@ def processAlgorithm(self, parameters, context, feedback):

# The location argument in the GeoClimate config file is replaced by
# the bbox coordinates
location = bbox_coord

location_conf = bbox_coord
# If location is a bbox or list of bbox, convert string to list
elif location[0] == "[":
list_loc = []
list_str = location.split("], [")
if len(list_str) > 1:
for i, ls_str in enumerate(list_str):
if i == 0:
list_loc.append([float(v) for v in ls_str[1:].split(",")])
elif i == len(list_str)-1:
list_loc.append([float(v) for v in ls_str[:-1].split(",")])
else:
list_loc.append([float(v) for v in ls_str.split(",")])
else:
ls_str = list_str[0]
if ls_str[1:2].isdigit():
list_loc.append([float(v) for v in ls_str[1:-1].split(",")])
else:
list_loc = ls_str[1:-1].split(",")

location_conf = list_loc
else:
location_conf = location


if feedback:
feedback.setProgressText("Start GeoClimate calculations")
if feedback.isCanceled():
Expand All @@ -279,7 +301,7 @@ def processAlgorithm(self, parameters, context, feedback):
else:
raise QgsProcessingException('The output directory does not exist, neither its parent directory')
config_file_path = os.path.join(outputDirectory,
CONFIG_FILENAME.format(str(location).replace(',','_')))
CONFIG_FILENAME.format(str(location).replace(',','_').replace(' ','')[0:100]))

# Fill in the indicator use list
estimateHeight = False
Expand All @@ -298,9 +320,7 @@ def processAlgorithm(self, parameters, context, feedback):
config_file_content = {
"description": "GeoClimate configuration file created using the QGIS plug-in GeoClimateTool",
"input": {
"locations": [
location
],
"locations": location_conf,
"area": 10000
},
"output": {
Expand All @@ -317,8 +337,9 @@ def processAlgorithm(self, parameters, context, feedback):
}

# Add the informations that are only needed for BDT data
if inputDirectory:
if inputDataset == "BDTOPO_V3" or inputDataset == "BDTOPO_V2":
config_file_content["input"]["folder"] = inputDirectory
config_file_content["input"]["srid"] = 2154

# Serializing json
json_object = json.dumps(config_file_content, indent=4)
Expand All @@ -333,6 +354,7 @@ def processAlgorithm(self, parameters, context, feedback):
# Execute the GeoClimate workflow and log informations
try:
for line in runProcess(java_cmd.split()):
print(line.decode("utf8"))
feedback.setProgressText(line.decode("utf8"))
executed = True
except:
Expand Down

0 comments on commit a684c55

Please sign in to comment.