[processing]fixed issue with temporal filename

(was previously solved but reverted)
This commit is contained in:
Victor Olaya 2013-09-14 14:34:21 +02:00
parent 4987f4ab4e
commit 1882bbc301
3 changed files with 30 additions and 24 deletions

View File

@ -95,6 +95,29 @@ def getTables():
tables.append(layer)
return tables
def extent(layers):
first = True
for layer in layers:
if not isinstance(layer, (QgsRasterLayer, QgsVectorLayer)):
layer = getObjectFromUri(layer)
if layer is None:
continue
if first:
xmin = layer.extent().xMinimum()
xmax = layer.extent().xMaximum()
ymin = layer.extent().yMinimum()
ymax = layer.extent().yMaximum()
else:
xmin = min(xmin, layer.extent().xMinimum())
xmax = max(xmax, layer.extent().xMaximum())
ymin = min(ymin, layer.extent().yMinimum())
ymax = max(ymax, layer.extent().yMaximum())
first = False
if first:
return "0,0,0,0"
else:
return str(xmin) + "," + str(xmax) + "," + str(ymin) + "," + str(ymax)
def loadList(layers):
for layer in layers:

View File

@ -25,7 +25,6 @@ __copyright__ = '(C) 2013, Victor Olaya'
__revision__ = '$Format:%H$'
from qgis.core import *
from processing.tools import dataobjects
from processing.core.Processing import Processing
from processing.parameters.ParameterSelection import ParameterSelection
from processing.gui.Postprocessing import Postprocessing
@ -70,28 +69,5 @@ def runalg(algOrName, *args):
def runandload(name, *args):
return Processing.runAlgorithm(name, Postprocessing.handleAlgorithmResults, *args)
def extent(layers):
first = True
for layer in layers:
if not isinstance(layer, (QgsRasterLayer, QgsVectorLayer)):
layer = dataobjects.getObjectFromUri(layer)
if layer is None:
continue
if first:
xmin = layer.extent().xMinimum()
xmax = layer.extent().xMaximum()
ymin = layer.extent().yMinimum()
ymax = layer.extent().yMaximum()
else:
xmin = min(xmin, layer.extent().xMinimum())
xmax = max(xmax, layer.extent().xMaximum())
ymin = min(ymin, layer.extent().yMinimum())
ymax = max(ymax, layer.extent().yMaximum())
first = False
if first:
return "0,0,0,0"
else:
return str(xmin) + "," + str(xmax) + "," + str(ymin) + "," + str(ymax)

View File

@ -68,9 +68,16 @@ def getTempFilenameInTempFolder(basename):
path = tempFolder()
path = os.path.join(path, str(uuid.uuid4()).replace("-",""))
mkdir(path)
basename = removeInvalidChars(basename)
filename = os.path.join(path, basename)
return filename
def removeInvalidChars(string):
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
string = ''.join(c for c in string if c in validChars)
return string
NUM_EXPORTED = 1
def getNumExportedLayers():