Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing]fixed issue with temporal filename
(was previously solved but reverted)
  • Loading branch information
volaya committed Sep 14, 2013
1 parent 4987f4a commit 1882bbc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
23 changes: 23 additions & 0 deletions python/plugins/processing/tools/dataobjects.py
Expand Up @@ -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:
Expand Down
24 changes: 0 additions & 24 deletions python/plugins/processing/tools/general.py
Expand Up @@ -25,7 +25,6 @@
__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
Expand Down Expand Up @@ -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)



7 changes: 7 additions & 0 deletions python/plugins/processing/tools/system.py
Expand Up @@ -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():
Expand Down

0 comments on commit 1882bbc

Please sign in to comment.