mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
parent
fda41e3b02
commit
76d9ab8283
@ -27,6 +27,7 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import importlib
|
||||
from qgis.core import (Qgis,
|
||||
QgsApplication,
|
||||
@ -305,10 +306,19 @@ class SagaAlgorithm(SagaAlgorithmBase):
|
||||
|
||||
output_layers = []
|
||||
output_files = {}
|
||||
#If the user has entered an output file that has non-ascii chars, we use a different path with only ascii chars
|
||||
output_files_nonascii = {}
|
||||
for out in self.destinationParameterDefinitions():
|
||||
filePath = self.parameterAsOutputLayer(parameters, out.name(), context)
|
||||
if isinstance(out, (QgsProcessingParameterRasterDestination, QgsProcessingParameterVectorDestination)):
|
||||
output_layers.append(filePath)
|
||||
try:
|
||||
filePath.encode('ascii')
|
||||
except UnicodeEncodeError:
|
||||
nonAsciiFilePath = filePath
|
||||
filePath = QgsProcessingUtils.generateTempFilename(out.name() + os.path.splitext(filePath)[1])
|
||||
output_files_nonascii[filePath] = nonAsciiFilePath
|
||||
|
||||
output_files[out.name()] = filePath
|
||||
command += ' -{} "{}"'.format(out.name(), filePath)
|
||||
|
||||
@ -339,7 +349,18 @@ class SagaAlgorithm(SagaAlgorithmBase):
|
||||
for out in output_layers:
|
||||
prjFile = os.path.splitext(out)[0] + '.prj'
|
||||
with open(prjFile, 'w') as f:
|
||||
f.write(crs.toWkt())
|
||||
f.write(crs.toWkt())
|
||||
|
||||
for old, new in output_files_nonascii.items():
|
||||
oldFolder = os.path.dirname(old)
|
||||
newFolder = os.path.dirname(new)
|
||||
newName = os.path.splitext(os.path.basename(new))[0]
|
||||
files = [f for f in os.listdir(oldFolder)]
|
||||
for f in files:
|
||||
ext = os.path.splitext(f)[1]
|
||||
newPath = os.path.join(newFolder, newName + ext)
|
||||
oldPath = os.path.join(oldFolder, f)
|
||||
shutil.move(oldPath, newPath)
|
||||
|
||||
result = {}
|
||||
for o in self.outputDefinitions():
|
||||
|
Loading…
x
Reference in New Issue
Block a user