64 changes: 0 additions & 64 deletions python/plugins/sextante/algs/SextanteAlgorithmProvider.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from sextante.outputs.OutputHTML import OutputHTML
from sextante.outputs.OutputNumber import OutputNumber

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class BasicStatisticsNumbers(GeoAlgorithm):

Expand All @@ -61,12 +61,14 @@ class BasicStatisticsNumbers(GeoAlgorithm):
UNIQUE = "UNIQUE"
STD_DEV = "STD_DEV"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/basic_statistics.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/basic_statistics.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Basic statistics for numeric fields"
self.group = "Analysis tools"
self.group = "Vector table tools"

self.addParameter(ParameterVector(self.INPUT_LAYER, "Input vector layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterTableField(self.FIELD_NAME, "Field to calculate statistics on", self.INPUT_LAYER, ParameterTableField.DATA_TYPE_NUMBER))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os.path

from PyQt4 import QtGui
from PyQt4.QtCore import *
Expand All @@ -40,7 +39,7 @@
from sextante.outputs.OutputHTML import OutputHTML
from sextante.outputs.OutputNumber import OutputNumber

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class BasicStatisticsStrings(GeoAlgorithm):

Expand All @@ -57,12 +56,14 @@ class BasicStatisticsStrings(GeoAlgorithm):
FILLED = "FILLED"
UNIQUE = "UNIQUE"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/basic_statistics.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/basic_statistics.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Basic statistics for text fields"
self.group = "Analysis tools"
self.group = "Vector table tools"

self.addParameter(ParameterVector(self.INPUT_LAYER, "Input vector layer", ParameterVector.VECTOR_TYPE_ANY, False))
self.addParameter(ParameterTableField(self.FIELD_NAME, "Field to calculate statistics on", self.INPUT_LAYER, ParameterTableField.DATA_TYPE_STRING))
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions python/plugins/sextante/algs/ftools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB OTHER_FILES copyright.txt)
FILE(GLOB ICON_FILES icons/*.png)

PLUGIN_INSTALL(sextante ./algs/ftools ${PY_FILES} ${OTHER_FILES})
PLUGIN_INSTALL(sextante ./algs/ftools/icons ${ICON_FILES})
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,22 @@ class Centroids(GeoAlgorithm):
INPUT_LAYER = "INPUT_LAYER"
OUTPUT_LAYER = "OUTPUT_LAYER"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/centroids.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/centroids.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Polygon centroids"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_POLYGON))

self.addOutput(OutputVector(self.OUTPUT_LAYER, "Output layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))

outFileName = self.getOutputValue(self.OUTPUT_LAYER)

settings = QSettings()
encoding = settings.value( "/UI/encoding", "System" ).toString()


writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(layer.pendingFields(),
QGis.WKBPoint, layer.dataProvider().crs())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from sextante.parameters.ParameterVector import ParameterVector
from sextante.core.QGisLayers import QGisLayers
from sextante.outputs.OutputVector import OutputVector
from sextante.ftools import ftools_utils
from sextante.algs.ftools import ftools_utils
from sextante.core.SextanteLog import SextanteLog
from sextante.parameters.ParameterBoolean import ParameterBoolean

Expand All @@ -44,8 +44,10 @@ class Clip(GeoAlgorithm):
USE_SELECTED = "USE_SELECTED"
USE_SELECTED2 = "USE_SELECTED2"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/clip.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/clip.png")
#===========================================================================

def processAlgorithm(self, progress):
settings = QSettings()
Expand Down Expand Up @@ -277,7 +279,7 @@ def processAlgorithm(self, progress):

def defineCharacteristics(self):
self.name = "Clip"
self.group = "Geoprocessing tools"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Clip.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Clip.INPUT2, "Clip layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterBoolean(Clip.USE_SELECTED, "Use selected features (input)", False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.outputs.OutputVector import OutputVector
from sextante.ftools import ftools_utils
from sextante.algs.ftools import ftools_utils
from sextante.core.SextanteLog import SextanteLog
from sextante.parameters.ParameterTableField import ParameterTableField
from sextante.parameters.ParameterSelection import ParameterSelection
Expand All @@ -48,8 +48,10 @@ class ConvexHull(GeoAlgorithm):
METHOD = "METHOD"
METHODS = ["Create single minimum convex hull", "Create convex hulls based on field"]

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/convex_hull.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/convex_hull.png")
#===========================================================================

def processAlgorithm(self, progress):
useSelection = self.getParameterValue(ConvexHull.USE_SELECTED)
Expand Down Expand Up @@ -208,7 +210,7 @@ def perimMeasure(self, inGeom, measure ):

def defineCharacteristics(self):
self.name = "Convex hull"
self.group = "Geoprocessing tools"
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(ConvexHull.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(ConvexHull.FIELD, "Field", ConvexHull.INPUT))
self.addParameter(ParameterSelection(ConvexHull.METHOD, "Method", ConvexHull.METHODS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@
from sextante.parameters.ParameterVector import ParameterVector
from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import voronoi
from sextante.algs.ftools import voronoi

class Delaunay(GeoAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/delaunay.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/delaunay.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Delaunay triangulation"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_POINT))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DensifyGeometries(GeoAlgorithm):

def defineCharacteristics(self):
self.name = "Densify geometries"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterNumber(self.VERTICES, "Vertices to add", 1, 10000000, 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@

class DensifyGeometriesInterval(GeoAlgorithm):

INPUT = "INPUT"
#VERTICES = "VERTICES"
INPUT = "INPUT"
INTERVAL = "INTERVAL"
USE_SELECTION = "USE_SELECTION"
OUTPUT = "OUTPUT"

def defineCharacteristics(self):
self.name = "Densify geometries given an interval"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
#self.addParameter(ParameterNumber(self.VERTICES, "Vertices to add", 1, 10000000, 1))
self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterNumber(self.INTERVAL, "Interval between Vertices to add", 1, 10000000, 1))
self.addParameter(ParameterBoolean(self.USE_SELECTION, "Use only selected features", False))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
from qgis.core import *
from sextante.parameters.ParameterVector import ParameterVector
from sextante.core.QGisLayers import QGisLayers
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.outputs.OutputVector import OutputVector
from sextante.ftools import ftools_utils
from sextante.algs.ftools import ftools_utils
from sextante.core.SextanteLog import SextanteLog
from sextante.parameters.ParameterBoolean import ParameterBoolean

Expand All @@ -45,8 +44,10 @@ class Difference(GeoAlgorithm):
USE_SELECTED = "USE_SELECTED"
USE_SELECTED2 = "USE_SELECTED2"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/difference.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/difference.png")
#===========================================================================

def processAlgorithm(self, progress):
useSelection = self.getParameterValue(Difference.USE_SELECTED)
Expand Down Expand Up @@ -210,7 +211,7 @@ def processAlgorithm(self, progress):

def defineCharacteristics(self):
self.name = "Difference"
self.group = "Geoprocessing tools"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Difference.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Difference.INPUT2, "Difference layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterBoolean(Difference.USE_SELECTED, "Use selected features (input)", False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from sextante.outputs.OutputVector import OutputVector
from sextante.parameters.ParameterBoolean import ParameterBoolean
from sextante.parameters.ParameterTableField import ParameterTableField
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.core.SextanteLog import SextanteLog

class Dissolve(GeoAlgorithm):
Expand All @@ -45,8 +44,10 @@ class Dissolve(GeoAlgorithm):
USE_SELECTED = "USE_SELECTED"
DISSOLVE_ALL = "DISSOLVE_ALL"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/dissolve.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/dissolve.png")
#===========================================================================

def processAlgorithm(self, progress):
useSelection = self.getParameterValue(Dissolve.USE_SELECTED)
Expand Down Expand Up @@ -188,7 +189,7 @@ def processAlgorithm(self, progress):

def defineCharacteristics(self):
self.name = "Dissolve"
self.group = "Geoprocessing tools"
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(Dissolve.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_POLYGON))
self.addParameter(ParameterBoolean(Dissolve.USE_SELECTED, "Use selected features", False))
self.addParameter(ParameterBoolean(Dissolve.DISSOLVE_ALL, "Dissolve all (do not use field)", True))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class ExportGeometryInfo(GeoAlgorithm):

Expand All @@ -51,12 +51,14 @@ class ExportGeometryInfo(GeoAlgorithm):
"Ellipsoidal"
]

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/export_geometry.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/export_geometry.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Export/Add geometry columns"
self.group = "Geometry tools"
self.group = "Vector table tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterSelection(self.METHOD, "Calculate using", self.CALC_METHODS, 0))
Expand All @@ -66,9 +68,7 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
method = self.getParameterValue(self.METHOD)

output = self.getOutputValue(self.OUTPUT)
method = self.getParameterValue(self.METHOD)

provider = layer.dataProvider()
geometryType = layer.geometryType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ class ExtentFromLayer(GeoAlgorithm):

OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/layer_extent.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/layer_extent.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Polygon from layer extent"
self.group = "Research tools"
self.group = "Vector general tools"

self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterBoolean(self.USE_SELECTION, "Use selection", False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,28 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class ExtractNodes(GeoAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/extract_nodes.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/extract_nodes.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Extract nodes"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))

self.addOutput(OutputVector(self.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
output = self.getOutputValue(self.OUTPUT)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

provider = layer.dataProvider()
layer.select(layer.pendingAllAttributesList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self):
]

def getDescription(self):
return "fTools (Vector analysis)"
return "QGIS native algorithms"

def getName(self):
return "ftools"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import Buffer as buff
from sextante.algs.ftools import Buffer as buff

class FixedDistanceBuffer(GeoAlgorithm):

Expand All @@ -51,12 +51,14 @@ class FixedDistanceBuffer(GeoAlgorithm):
SEGMENTS = "SEGMENTS"
DISSOLVE = "DISSOLVE"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/buffer.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/buffer.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Fixed distance buffer"
self.group = "Geoprocessing tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterBoolean(self.USE_SELECTED, "Use selected features", False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.outputs.OutputVector import OutputVector
from sextante.ftools import ftools_utils
from sextante.algs.ftools import ftools_utils
from sextante.core.SextanteLog import SextanteLog
from sextante.parameters.ParameterBoolean import ParameterBoolean

Expand All @@ -45,8 +45,10 @@ class Intersection(GeoAlgorithm):
USE_SELECTED = "USE_SELECTED"
USE_SELECTED2 = "USE_SELECTED2"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/intersect.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/intersect.png")
#===========================================================================

def processAlgorithm(self, progress):
useSelection = self.getParameterValue(Intersection.USE_SELECTED)
Expand Down Expand Up @@ -215,7 +217,7 @@ def processAlgorithm(self, progress):

def defineCharacteristics(self):
self.name = "Intersection"
self.group = "Geoprocessing tools"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Intersection.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Intersection.INPUT2, "Intersect layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterBoolean(Intersection.USE_SELECTED, "Use selected features (input)", False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
from qgis.core import *

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.core.QGisLayers import QGisLayers

from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterTableField import ParameterTableField

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class LinesIntersection(GeoAlgorithm):

Expand All @@ -50,12 +49,14 @@ class LinesIntersection(GeoAlgorithm):

OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/intersections.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/intersections.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Line intersections"
self.group = "Analysis tools"
self.group = "Vector overlay tools"

self.addParameter(ParameterVector(self.INPUT_A, "Input layer", ParameterVector.VECTOR_TYPE_LINE))
self.addParameter(ParameterVector(self.INPUT_B, "Intersect layer", ParameterVector.VECTOR_TYPE_LINE))
Expand All @@ -69,9 +70,7 @@ def processAlgorithm(self, progress):
layerB = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_B))
fieldA = self.getParameterValue(self.FIELD_A)
fieldB = self.getParameterValue(self.FIELD_B)

output = self.getOutputValue(self.OUTPUT)


providerA = layerA.dataProvider()
providerB = layerB.dataProvider()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ class LinesToPolygons(GeoAlgorithm):
INPUT = "INPUT"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/to_lines.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/to_lines.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Lines to polygons"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_LINE))
self.addOutput(OutputVector(self.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
output = self.getOutputValue(self.OUTPUT)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

provider = layer.dataProvider()
layer.select(layer.pendingAllAttributesList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils


class MeanCoords(GeoAlgorithm):
Expand All @@ -49,12 +49,14 @@ class MeanCoords(GeoAlgorithm):
UID = "UID"
WEIGHT = "WEIGHT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mean.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mean.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Mean coordinate(s)"
self.group = "Analysis tools"
self.group = "Vector analysis tools"

self.addParameter(ParameterVector(self.POINTS, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(self.WEIGHT, "Weight field", MeanCoords.POINTS, ParameterTableField.DATA_TYPE_NUMBER))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ class MultipartToSingleparts(GeoAlgorithm):
INPUT = "INPUT"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/multi_to_single.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/multi_to_single.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Multipart to singleparts"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer"))
self.addOutput(OutputVector(self.OUTPUT, "Output layer"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from sextante.outputs.OutputHTML import OutputHTML
from sextante.outputs.OutputNumber import OutputNumber

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class NearestNeighbourAnalysis(GeoAlgorithm):

Expand All @@ -52,12 +52,14 @@ class NearestNeighbourAnalysis(GeoAlgorithm):
POINT_COUNT = "POINT_COUNT"
Z_SCORE = "Z_SCORE"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/neighbour.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/neighbour.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Nearest neighbour analysis"
self.group = "Analysis tools"
self.group = "Vector analysis tools"

self.addParameter(ParameterVector(self.POINTS, "Points", ParameterVector.VECTOR_TYPE_POINT))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ class PointDistance(GeoAlgorithm):
"Summary distance matrix (mean, std. dev., min, max)"
]

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/matrix.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/matrix.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Distance matrix"
self.group = "Analysis tools"
self.group = "Vector analysis tools"

self.addParameter(ParameterVector(self.INPUT_LAYER, "Input point layer", ParameterVector.VECTOR_TYPE_POINT))
self.addParameter(ParameterTableField(self.INPUT_FIELD, "Input unique ID field", self.INPUT_LAYER, ParameterTableField.DATA_TYPE_ANY))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils


class PointsInPolygon(GeoAlgorithm):
Expand All @@ -49,12 +49,14 @@ class PointsInPolygon(GeoAlgorithm):
OUTPUT = "OUTPUT"
FIELD = "FIELD"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_points.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_points.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Count points in polygon"
self.group = "Analysis tools"
self.group = "Vector analysis tools"
self.addParameter(ParameterVector(self.POLYGONS, "Polygons", ParameterVector.VECTOR_TYPE_POLYGON))
self.addParameter(ParameterVector(self.POINTS, "Points", ParameterVector.VECTOR_TYPE_POINT))
self.addParameter(ParameterString(self.FIELD, "Count field name", "NUMPOINTS"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils


class PointsInPolygonUnique(GeoAlgorithm):
Expand All @@ -51,12 +51,14 @@ class PointsInPolygonUnique(GeoAlgorithm):
FIELD = "FIELD"
CLASSFIELD = "CLASSFIELD"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_points.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_points.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Count unique points in polygon"
self.group = "Analysis tools"
self.group = "Vector analysis tools"
self.addParameter(ParameterVector(self.POLYGONS, "Polygons", ParameterVector.VECTOR_TYPE_POLYGON))
self.addParameter(ParameterVector(self.POINTS, "Points", ParameterVector.VECTOR_TYPE_POINT))
self.addParameter(ParameterTableField(self.CLASSFIELD, "Class field", self.POINTS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils


class PointsInPolygonWeighted(GeoAlgorithm):
Expand All @@ -51,12 +51,14 @@ class PointsInPolygonWeighted(GeoAlgorithm):
FIELD = "FIELD"
WEIGHT = "WEIGHT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_points.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_points.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Count points in polygon(weighted)"
self.group = "Analysis tools"
self.group = "Vector analysis tools"

self.addParameter(ParameterVector(self.POLYGONS, "Polygons", ParameterVector.VECTOR_TYPE_POLYGON))
self.addParameter(ParameterVector(self.POINTS, "Points", ParameterVector.VECTOR_TYPE_POINT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ class PolygonsToLines(GeoAlgorithm):
INPUT = "INPUT"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/to_lines.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/to_lines.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Polygons to lines"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_POLYGON))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ class RandomSelection(GeoAlgorithm):
"Percentage of selected features"
]

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/random_selection.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/random_selection.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Random selection"
self.group = "Research tools"
self.group = "Vector selection tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterSelection(self.METHOD, "Method", self.METHODS, 0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,19 @@ class RandomSelectionWithinSubsets(GeoAlgorithm):
"Percentage of selected features"
]

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/random_selection.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/random_selection.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Random selection within subsets"
self.group = "Research tools"
self.group = "Vector selection tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(self.FIELD, "ID Field", self.INPUT))
self.addParameter(ParameterSelection(self.METHOD, "Method", self.METHODS, 0))
self.addParameter(ParameterNumber(self.NUMBER, "Number/persentage of selected features", 1, None, 10))
self.addParameter(ParameterNumber(self.NUMBER, "Number/percentage of selected features", 1, None, 10))

self.addOutput(OutputVector(self.OUTPUT, "Selection", True))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ class ReprojectLayer(GeoAlgorithm):
TARGET_CRS = "TARGET_CRS"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/reproject.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/reproject.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Reproject layer"
self.group = "Data management tools"
self.group = "Vector general tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterCrs(self.TARGET_CRS, "Target CRS", "4326"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class SelectByLocation(GeoAlgorithm):

Expand All @@ -53,12 +53,14 @@ class SelectByLocation(GeoAlgorithm):
"adding to current selection",
"removing from current selection"]

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/select_location.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/select_location.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Select by location"
self.group = "Research tools"
self.group = "Vector selection tools"

self.addParameter(ParameterVector(self.INPUT, "Layer to select from", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(self.INTERSECT, "Additional layer (intersection layer)", ParameterVector.VECTOR_TYPE_ANY))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ class SimplifyGeometries(GeoAlgorithm):
USE_SELECTION = "USE_SELECTION"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/simplify.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/simplify.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Simplify geometries"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterNumber(self.TOLERANCE, "Tolerance", 0.0, 10000000.0, 1.0))
Expand All @@ -63,8 +65,7 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
useSelection = self.getParameterValue(self.USE_SELECTION)
tolerance =self.getParameterValue(self.TOLERANCE)
output = self.getOutputValue(self.OUTPUT)
tolerance =self.getParameterValue(self.TOLERANCE)

pointsBefore = 0
pointsAfter = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ class SinglePartsToMultiparts(GeoAlgorithm):
FIELD = "FIELD"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/single_to_multi.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/single_to_multi.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Singleparts to multipart"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer"))
self.addParameter(ParameterTableField(self.FIELD, "Unique ID field", self.INPUT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from sextante.parameters.ParameterString import ParameterString
from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import FToolsUtils as utils
from sextante.algs.ftools import FToolsUtils as utils

class SumLines(GeoAlgorithm):

Expand All @@ -48,12 +48,14 @@ class SumLines(GeoAlgorithm):
COUNT_FIELD = "COUNT_FIELD"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_lines.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/sum_lines.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Sum line lengths"
self.group = "Analysis tools"
self.group = "Vector analysis tools"

self.addParameter(ParameterVector(self.LINES, "Lines", ParameterVector.VECTOR_TYPE_LINE))
self.addParameter(ParameterVector(self.POLYGONS, "Polygons", ParameterVector.VECTOR_TYPE_POLYGON))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from sextante.core.QGisLayers import QGisLayers
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.outputs.OutputVector import OutputVector
from sextante.ftools import ftools_utils
from sextante.algs.ftools import ftools_utils
from sextante.core.SextanteLog import SextanteLog

class Union(GeoAlgorithm):
Expand All @@ -42,8 +42,10 @@ class Union(GeoAlgorithm):
INPUT2 = "INPUT2"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/union.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/union.png")
#===========================================================================

def processAlgorithm(self, progress):
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(Union.INPUT))
Expand Down Expand Up @@ -217,7 +219,7 @@ def processAlgorithm(self, progress):

def defineCharacteristics(self):
self.name = "Union"
self.group = "Geoprocessing tools"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Union.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Union.INPUT2, "Input layer 2", ParameterVector.VECTOR_TYPE_ANY))
self.addOutput(OutputVector(Union.OUTPUT, "Intersection"))
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException

from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterTableField import ParameterTableField
Expand All @@ -45,12 +44,14 @@ class UniqueValues(GeoAlgorithm):
TOTAL_VALUES = "TOTAL_VALUES"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/unique.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/unique.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "List unique values"
self.group = "Analysis tools"
self.group = "Vector table tools"
self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(self.FIELD_NAME, "Targer field", self.INPUT_LAYER, ParameterTableField.DATA_TYPE_ANY))
self.addOutput(OutputHTML(self.OUTPUT, "Unique values"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import Buffer as buff
from sextante.algs.ftools import Buffer as buff

class VariableDistanceBuffer(GeoAlgorithm):

Expand All @@ -51,12 +51,14 @@ class VariableDistanceBuffer(GeoAlgorithm):
SEGMENTS = "SEGMENTS"
DISSOLVE = "DISSOLVE"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/buffer.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/buffer.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Variable distance buffer"
self.group = "Geoprocessing tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterBoolean(self.USE_SELECTED, "Use selected features", False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@

from sextante.outputs.OutputVector import OutputVector

from sextante.ftools import voronoi
from sextante.algs.ftools import voronoi

class VoronoiPolygons(GeoAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/icons/voronoi.png")
#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/voronoi.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Voronoi polygons"
self.group = "Geometry tools"
self.group = "Vector geometry tools"

self.addParameter(ParameterVector(self.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_POINT))

Expand All @@ -59,8 +61,6 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

output = self.getOutputValue(self.OUTPUT)

provider = layer.dataProvider()
layer.select(layer.pendingAllAttributesList())

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
6 changes: 6 additions & 0 deletions python/plugins/sextante/algs/mmqgisx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB OTHER_FILES copyright.txt)
FILE(GLOB ICON_FILES icons/*.png)

PLUGIN_INSTALL(sextante ./algs/mmqgisx ${PY_FILES} ${OTHER_FILES})
PLUGIN_INSTALL(sextante ./algs/mmqgisx/icons ${ICON_FILES})

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@
from sextante.modeler.Providers import Providers
from sextante.modeler.ModelerAlgorithmProvider import ModelerAlgorithmProvider
from sextante.modeler.ModelerOnlyAlgorithmProvider import ModelerOnlyAlgorithmProvider
from sextante.algs.SextanteAlgorithmProvider import SextanteAlgorithmProvider
from sextante.algs.QGISAlgorithmProvider import QGISAlgorithmProvider
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.ftools.FToolsAlgorithmProvider import FToolsAlgorithmProvider
from sextante.grass.GrassAlgorithmProvider import GrassAlgorithmProvider
from sextante.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider
from sextante.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
from sextante.mmqgisx.MMQGISXAlgorithmProvider import MMQGISXAlgorithmProvider
from sextante.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
#from sextante.pymorph.PymorphAlgorithmProvider import PymorphAlgorithmProvider
from sextante.r.RAlgorithmProvider import RAlgorithmProvider
from sextante.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
from sextante.script.ScriptAlgorithmProvider import ScriptAlgorithmProvider
Expand Down Expand Up @@ -116,12 +113,9 @@ def setInterface(iface):
@staticmethod
def initialize():
#add the basic providers
Sextante.addProvider(SextanteAlgorithmProvider())
Sextante.addProvider(MMQGISXAlgorithmProvider())
Sextante.addProvider(FToolsAlgorithmProvider())
Sextante.addProvider(QGISAlgorithmProvider())
Sextante.addProvider(ModelerOnlyAlgorithmProvider())
Sextante.addProvider(GdalOgrAlgorithmProvider())
#Sextante.addProvider(PymorphAlgorithmProvider())
Sextante.addProvider(LidarToolsAlgorithmProvider())
Sextante.addProvider(OTBAlgorithmProvider())
Sextante.addProvider(RAlgorithmProvider())
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/core/SextanteUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def userFolder():
if not QDir(userDir).exists():
QDir().mkpath(userDir)

return unicode(userDir)
return unicode(QDir.toNativeSeparators(userDir))

@staticmethod
def isWindows():
Expand All @@ -52,11 +52,11 @@ def isMac():

@staticmethod
def tempFolder():
tempDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/sextante/tempdata"
tempDir = os.path.join(unicode(QDir.tempPath()), "sextante")
if not QDir(tempDir).exists():
QDir().mkpath(tempDir)

return unicode(tempDir)
return unicode(os.path.abspath(tempDir))

@staticmethod
def setTempOutput(out, alg):
Expand Down
6 changes: 0 additions & 6 deletions python/plugins/sextante/ftools/CMakeLists.txt

This file was deleted.

25 changes: 19 additions & 6 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand Down Expand Up @@ -195,7 +196,7 @@ def processAlgorithm(self, progress):
if value in self.exportedLayers.keys():
continue
else:
self.setSessionProjection(value, commands)
self.setSessionProjectionFromLayer(value, commands)
commands.append(self.exportRasterLayer(value))
if isinstance(param, ParameterVector):
if param.value == None:
Expand All @@ -204,7 +205,7 @@ def processAlgorithm(self, progress):
if value in self.exportedLayers.keys():
continue
else:
self.setSessionProjection(value, commands)
self.setSessionProjectionFromLayer(value, commands)
commands.append(self.exportVectorLayer(value))
if isinstance(param, ParameterTable):
pass
Expand All @@ -219,16 +220,18 @@ def processAlgorithm(self, progress):
if layer in self.exportedLayers.keys():
continue
else:
self.setSessionProjection(layer, commands)
self.setSessionProjectionFromLayer(layer, commands)
commands.append(self.exportRasterLayer(layer))
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
for layer in layers:
if layer in self.exportedLayers.keys():
continue
else:
self.setSessionProjection(layer, commands)
self.setSessionProjectionFromLayer(layer, commands)
commands.append(self.exportVectorLayer(layer))

self.setSessionProjectionFromProject(commands)

region = str(self.getParameterValue(self.GRASS_REGION_EXTENT_PARAMETER))
regionCoords = region.split(",")
command = "g.region"
Expand Down Expand Up @@ -368,8 +371,18 @@ def exportVectorLayer(self, orgFilename):
command +=" --overwrite -o"
return command


def setSessionProjection(self, layer, commands):
def setSessionProjectionFromProject(self, commands):
if not GrassUtils.projectionSet:
from sextante.core.Sextante import Sextante
qgis = Sextante.getInterface()
proj4 = qgis.mapCanvas().mapRenderer().getDestinationCrs().toProj4()
command = "g.proj"
command +=" -c"
command +=" proj4=\""+proj4+"\""
commands.append(command)
GrassUtils.projectionSet = True

def setSessionProjectionFromLayer(self, layer, commands):
if not GrassUtils.projectionSet:
qGisLayer = QGisLayers.getObjectFromUri(layer)
if qGisLayer:
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/sextante/grass/description/r.grow.distance.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
r.grow.distance
r.grow.distance - Generates a raster map layer of distance to features in input layer.
r.grow.distance - Generates a raster layer of distance to features in input layer.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|input|Input input raster layer|False
ParameterSelection|metric|Metric|euclidean;squared;maximum;manhattan
OutputRaster|distance|Name for distance output map
OutputRaster|value|Name for value output map
OutputRaster|distance|Distance layer
OutputRaster|value|Output value
6 changes: 3 additions & 3 deletions python/plugins/sextante/grass/description/r.grow.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
r.grow
r.grow - Generates a raster map layer with contiguous areas grown by one cell.
r.grow - Generates a raster layer with contiguous areas grown by one cell.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|input|input raster layer|False
ParameterNumber|radius|Radius of buffer in raster cells|None|None|1.01
ParameterSelection|metric|Metric|euclidean;maximum;manhattan
ParameterNumber|old|Value to write for input cells which are non-NULL (-1 => NULL)|None|None|0
ParameterNumber|new|Value to write for "grown" cells|None|None|1
OutputRaster|output|Name for output raster map
OutputRaster|output|Output layer
14 changes: 7 additions & 7 deletions python/plugins/sextante/grass/description/r.his.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
r.his
r.his - Generates red, green and blue raster map layers combining hue, intensity and saturation (HIS) values from user-specified input raster map layers.
r.his - Generates red, green and blue raster layers combining hue, intensity and saturation (HIS) values from user-specified input raster layers.
Raster (r.*)
ParameterRaster|h_map|Name of layer to be used for HUE|False
ParameterRaster|i_map|Name of layer to be used for INTENSITY|False
ParameterRaster|s_map|Name of layer to be used for SATURATION|False
ParameterRaster|h_map|Hue|False
ParameterRaster|i_map|Intensity|False
ParameterRaster|s_map|Saturation|False
ParameterBoolean|-n|Respect NULL values while drawing|False
OutputRaster|r_map|Name of output layer to be used for RED
OutputRaster|g_map|Name of output layer to be used for GREEN
OutputRaster|b_map|Name of output layer to be used for BLUE
OutputRaster|r_map|Red
OutputRaster|g_map|Green
OutputRaster|b_map|Blue
Binary file added python/plugins/sextante/images/qgis.png
Binary file modified python/plugins/sextante/images/tool.png
6 changes: 0 additions & 6 deletions python/plugins/sextante/mmqgisx/CMakeLists.txt

This file was deleted.

64 changes: 58 additions & 6 deletions python/plugins/sextante/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,37 @@
* *
***************************************************************************
"""
from sextante.outputs.OutputString import OutputString

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import copy
import os.path
import codecs
import time
from qgis.core import *
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.parameters.ParameterFactory import ParameterFactory
from sextante.modeler.WrongModelException import WrongModelException
from sextante.modeler.ModelerUtils import ModelerUtils
import copy
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.core.QGisLayers import QGisLayers
from sextante.parameters.ParameterExtent import ParameterExtent
from PyQt4 import QtCore, QtGui
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
import os.path
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputHTML import OutputHTML
from sextante.outputs.OutputTable import OutputTable
from sextante.outputs.OutputVector import OutputVector
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputString import OutputString
from sextante.parameters.Parameter import Parameter
from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterTableField import ParameterTableField
from sextante.gui.Help2Html import Help2Html
import codecs
import time

class ModelerAlgorithm(GeoAlgorithm):

Expand Down Expand Up @@ -343,6 +346,12 @@ def prepareAlgorithm(self, alg, iAlg):
for param in alg.parameters:
aap = self.algParameters[iAlg][param.name]
if aap == None:
if isinstance(param, ParameterExtent):
value = self.getValueFromAlgorithmAndParameter(aap)
if value is None:
value = self.getMinCoveringExtent()
if not param.setValue(value):
raise GeoAlgorithmExecutionException("Wrong value: " + str(value))
continue
if isinstance(param, ParameterMultipleInput):
value = self.getValueFromAlgorithmAndParameter(aap)
Expand All @@ -356,6 +365,7 @@ def prepareAlgorithm(self, alg, iAlg):
value = ";".join(layerslist)
if not param.setValue(value):
raise GeoAlgorithmExecutionException("Wrong value: " + str(value))

else:
value = self.getValueFromAlgorithmAndParameter(aap)
if not param.setValue(value):
Expand All @@ -368,11 +378,53 @@ def prepareAlgorithm(self, alg, iAlg):
else:
out.value = None


def getMinCoveringExtent(self):
first = True
found = False
for param in self.parameters:
if param.value:
if isinstance(param, (ParameterRaster, ParameterVector)):
found = True
if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
layer = param.value
else:
layer = QGisLayers.getObjectFromUri(param.value)
self.addToRegion(layer, first)
first = False
elif isinstance(param, ParameterMultipleInput):
found = True
layers = param.value.split(";")
for layername in layers:
layer = QGisLayers.getObjectFromUri(layername)
self.addToRegion(layer, first)
first = False
if found:
return str(self.xmin) + "," + str(self.xmax) + "," + str(self.ymin) + "," + str(self.ymax)
else:
return None


def addToRegion(self, layer, first):
if first:
self.xmin = layer.extent().xMinimum()
self.xmax = layer.extent().xMaximum()
self.ymin = layer.extent().yMinimum()
self.ymax = layer.extent().yMaximum()
else:
self.xmin = min(self.xmin, layer.extent().xMinimum())
self.xmax = max(self.xmax, layer.extent().xMaximum())
self.ymin = min(self.ymin, layer.extent().yMinimum())
self.ymax = max(self.ymax, layer.extent().yMaximum())


def getSafeNameForOutput(self, ialg, out):
return out.name +"_ALG" + str(ialg)


def getValueFromAlgorithmAndParameter(self, aap):
if aap is None:
return None
if float(aap.alg) == float(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM):
for key in self.paramValues.keys():
if aap.param == key:
Expand Down
32 changes: 17 additions & 15 deletions python/plugins/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@
* *
***************************************************************************
"""
from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.outputs.OutputString import OutputString

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os.path

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui, QtWebKit

from sextante.parameters.ParameterCrs import ParameterCrs
from sextante.outputs.OutputString import OutputString
from sextante.parameters.ParameterRaster import ParameterRaster
from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterBoolean import ParameterBoolean
Expand Down Expand Up @@ -60,6 +57,7 @@ class ModelerParametersDialog(QtGui.QDialog):

ENTER_NAME = "[Enter name if this is a final result]"
NOT_SELECTED = "[Not selected]"
USE_MIN_COVERING_EXTENT = "[Use min covering extent]"

def __init__(self, alg, model, algIndex = None):
QtGui.QDialog.__init__(self)
Expand Down Expand Up @@ -257,7 +255,7 @@ def getExtents(self):
params = self.model.parameters
for param in params:
if isinstance(param, ParameterExtent):
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
extents.append(AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, param.name, "", param.description))
return extents

def getNumbers(self):
Expand Down Expand Up @@ -414,9 +412,12 @@ def getWidgetFromParameter(self, param):
item = QtGui.QComboBox()
item.setEditable(True)
extents = self.getExtents()
if self.canUseAutoExtent():
item.addItem(self.USE_MIN_COVERING_EXTENT, None)
for ex in extents:
item.addItem(ex.name(), ex)
item.setEditText(str(param.default))
item.addItem(ex.name(), ex)
if not self.canUseAutoExtent():
item.setEditText(str(param.default))
elif isinstance(param, ParameterFile):
item = QtGui.QComboBox()
item.setEditable(True)
Expand All @@ -431,6 +432,13 @@ def getWidgetFromParameter(self, param):
pass
return item

def canUseAutoExtent(self):
for param in self.alg.parameters:
if isinstance(param, (ParameterRaster, ParameterVector)):
return True
if isinstance(param, ParameterMultipleInput):
return True

def setTableContent(self):
params = self.alg.parameters
outputs = self.alg.outputs
Expand Down Expand Up @@ -549,7 +557,7 @@ def setParamValues(self):
return False
for output in outputs:
if output.hidden:
self.outputs[output.name] = None
self.outputs[output.name] = None
else:
name= unicode(self.valueItems[output.name].text())
if name.strip()!="" and name != ModelerParametersDialog.ENTER_NAME:
Expand All @@ -572,12 +580,6 @@ def setParamValueLayerOrTable(self, param, widget):
self.params[param.name] = value
return True

if widget.currentIndex() < 0:
return False
value = widget.itemData(widget.currentIndex()).toPyObject()
self.params[param.name] = value
return True

def setParamBooleanValue(self, param, widget):
if widget.currentIndex() < 2:
name = self.getSafeNameForHarcodedParameter(param)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/modeler/ModelerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class ModelerUtils:
def modelsFolder():
folder = SextanteConfig.getSetting(ModelerUtils.MODELS_FOLDER)
if folder == None:
folder = SextanteUtils.userFolder() + os.sep + "models"
folder = unicode(os.path.join(SextanteUtils.userFolder(), "models"))
mkdir(folder)

return folder
return os.path.abspath(folder)

@staticmethod
def getAlgorithm(name):
Expand Down
2 changes: 2 additions & 0 deletions python/plugins/sextante/parameters/ParameterExtent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

class ParameterExtent(Parameter):

USE_MIN_COVERING_EXTENT = "USE_MIN_COVERING_EXTENT"

def __init__(self, name="", description="", default="0,1,0,1"):
Parameter.__init__(self, name, description)
self.default = default
Expand Down
15 changes: 4 additions & 11 deletions python/plugins/sextante/r/RUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ class RUtils:
def RFolder():
folder = SextanteConfig.getSetting(RUtils.R_FOLDER)
if folder == None:
folder =""
folder = ""

return folder
return os.path.abspath(unicode(folder))

@staticmethod
def RScriptsFolder():
folder = SextanteConfig.getSetting(RUtils.RSCRIPTS_FOLDER)
if folder == None:
#folder = os.path.join(os.path.dirname(__file__), "scripts")
folder = SextanteUtils.userFolder() + os.sep + "rscripts"
folder = unicode(os.path.join(SextanteUtils.userFolder(), "rscripts"))
mkdir(folder)

return folder
return os.path.abspath(folder)

@staticmethod
def createRScriptFromRCommands(commands):
Expand All @@ -61,17 +60,14 @@ def createRScriptFromRCommands(commands):
scriptfile.write(command + "\n")
scriptfile.close()


@staticmethod
def getRScriptFilename():
return SextanteUtils.userFolder() + os.sep + "sextante_script.r"


@staticmethod
def getConsoleOutputFilename():
return RUtils.getRScriptFilename()+".Rout"


@staticmethod
def executeRAlgorithm(alg, progress):
RUtils.verboseCommands = alg.getVerboseCommands();
Expand Down Expand Up @@ -113,7 +109,6 @@ def createConsoleOutput():
RUtils.consoleResults.append("<p>" + line + "</p>\n");
RUtils.allConsoleResults.append(line);


@staticmethod
def getConsoleOutput():
s = "<font face=\"courier\">\n"
Expand All @@ -123,5 +118,3 @@ def getConsoleOutput():
s+="</font>\n"

return s


This file was deleted.

8 changes: 0 additions & 8 deletions python/plugins/sextante/saga/description/TrendAnalysis.txt

This file was deleted.

5 changes: 2 additions & 3 deletions python/plugins/sextante/script/ScriptAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
* *
***************************************************************************
"""
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputString import OutputString

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -36,6 +33,8 @@
from sextante.outputs.OutputTable import OutputTable
from sextante.outputs.OutputVector import OutputVector
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputNumber import OutputNumber
from sextante.outputs.OutputString import OutputString
from sextante.parameters.ParameterString import ParameterString
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterBoolean import ParameterBoolean
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/sextante/script/ScriptUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ScriptUtils:
def scriptsFolder():
folder = SextanteConfig.getSetting(ScriptUtils.SCRIPTS_FOLDER)
if folder == None:
folder = SextanteUtils.userFolder() + os.sep + "scripts"
folder = unicode(os.path.join(SextanteUtils.userFolder(), "scripts"))
mkdir(folder)

return folder
return os.path.abspath(folder)
2 changes: 1 addition & 1 deletion scripts/tsstat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
pl_PL => 'Robert Szczepanek, Milena Nowotarska, Borys Jurgiel, Mateusz Loskot, Tomasz Paul, Andrzej Swiader ',
pt_BR => 'Arthur Nanni',
pt_PT => 'Giovanni Manghi, Joana Simoes, Duarte Carreira, Alexandre Neto, Pedro Pereira, Pedro Palheiro, Nelson Silva',
ro => 'Lonut Losifescu-Enescu',
ro => 'Lonut Losifescu-Enescu, Bogdan Pacurar',
ru => 'Artem Popov',
sk => 'Lubos Balazovic',
sl_SI => 'Jože Detečnik, Dejan Gregor',
Expand Down
9 changes: 8 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4131,7 +4131,14 @@ void QgisApp::saveAsRasterFile()
fileWriter.setPyramidsResampling( d.pyramidsResampling() );
fileWriter.setPyramidsFormat( d.pyramidsFormat() );

fileWriter.writeRaster( pipe, d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe, d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
if ( err != QgsRasterFileWriter::NoError )
{
QMessageBox::warning( this, tr( "Error" ),
tr( "Cannot write raster error code: %1" ).arg( err ),
QMessageBox::Ok );

}
delete pipe;
}
}
Expand Down
16 changes: 5 additions & 11 deletions src/core/raster/qgscontrastenhancement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,23 @@ QgsContrastEnhancement::QgsContrastEnhancement( QgsRasterDataType theDataType )
QgsContrastEnhancement::QgsContrastEnhancement( const QgsContrastEnhancement& ce )
{
mLookupTable = 0;
mEnhancementDirty = ce.mEnhancementDirty;
mContrastEnhancementAlgorithm = ce.mContrastEnhancementAlgorithm;
mContrastEnhancementFunction = 0;
mEnhancementDirty = true;
mRasterDataType = ce.mRasterDataType;

mMinimumValue = ce.mMinimumValue;
mMaximumValue = ce.mMaximumValue;
mRasterDataTypeRange = ce.mRasterDataTypeRange;

mLookupTableOffset = ce.mLookupTableOffset;
mLookupTableOffset = mMinimumValue * -1;

mContrastEnhancementFunction = new QgsContrastEnhancementFunction( mRasterDataType, mMinimumValue, mMaximumValue );
// setContrastEnhancementAlgorithm sets also QgsContrastEnhancementFunction
setContrastEnhancementAlgorithm( ce.mContrastEnhancementAlgorithm, false );

//If the data type is larger than 16-bit do not generate a lookup table
if ( mRasterDataTypeRange <= 65535.0 )
{
mLookupTable = new int[static_cast <int>( mRasterDataTypeRange+1 )];
if ( !ce.mEnhancementDirty )
{
for ( int myIterator = 0; myIterator <= mRasterDataTypeRange; myIterator++ )
{
mLookupTable[myIterator] = ce.mLookupTable[myIterator];
}
}
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/core/raster/qgsrasterdataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* *
***************************************************************************/

#include "qgsproviderregistry.h"
#include "qgsrasterdataprovider.h"
#include "qgsrasterprojector.h"
#include "qgslogger.h"
Expand Down Expand Up @@ -475,4 +476,30 @@ void QgsRasterDataProvider::setUserNoDataValue( int bandNo, QList<QgsRasterBlock
}
}

typedef QgsRasterDataProvider * createFunction_t( const QString&,
const QString&, int,
QGis::DataType,
int, int, double*,
const QgsCoordinateReferenceSystem&,
QStringList );

QgsRasterDataProvider* QgsRasterDataProvider::create( const QString &providerKey,
const QString &uri,
const QString& format, int nBands,
QGis::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions )
{
createFunction_t *createFn = ( createFunction_t* ) cast_to_fptr( QgsProviderRegistry::instance()->function( providerKey, "create" ) );
if ( !createFn )
{
QgsDebugMsg( "Cannot resolve 'create' function in " + providerKey + " provider" );
// TODO: it would be good to return invalid QgsRasterDataProvider
// with QgsError set, but QgsRasterDataProvider has pure virtual methods
return 0;
}
return createFn( uri, format, nBands, type, width, height, geoTransform, crs, createOptions );
}

// ENDS
11 changes: 11 additions & 0 deletions src/core/raster/qgsrasterdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast

/** Creates a new dataset with mDataSourceURI
@return true in case of success*/
#if 0
virtual bool create( const QString& format, int nBands,
QGis::DataType type,
int width, int height, double* geoTransform,
Expand All @@ -419,6 +420,16 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
Q_UNUSED( createOptions );
return false;
}
#endif

static QgsRasterDataProvider* create( const QString &providerKey,
const QString &uri,
const QString& format, int nBands,
QGis::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions = QStringList() );


/** Set no data value on created dataset
* @param bandNo band number
Expand Down
331 changes: 200 additions & 131 deletions src/core/raster/qgsrasterfilewriter.cpp

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions src/core/raster/qgsrasterfilewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class QgsRasterIterator;
class CORE_EXPORT QgsRasterFileWriter
{
public:
enum Mode
{
Raw = 0, // Raw data
Image = 1 // Rendered image
};
enum WriterError
{
NoError = 0,
Expand Down Expand Up @@ -109,7 +114,7 @@ class CORE_EXPORT QgsRasterFileWriter
const QgsCoordinateReferenceSystem& crs, QProgressDialog* progressDialog = 0 );

//initialize vrt member variables
void createVRT( int xSize, int ySize, const QgsCoordinateReferenceSystem& crs, double* geoTransform );
void createVRT( int xSize, int ySize, const QgsCoordinateReferenceSystem& crs, double* geoTransform, QGis::DataType type, QList<bool> destHasNoDataValueList, QList<double> destNoDataValueList );
//write vrt document to disk
bool writeVRT( const QString& file );
//add file entry to vrt
Expand All @@ -125,12 +130,17 @@ class CORE_EXPORT QgsRasterFileWriter
const QgsCoordinateReferenceSystem& crs );

/**Init VRT (for tiled mode) or create global output provider (single-file mode)*/
QgsRasterDataProvider* initOutput( int nCols, int nRows, const QgsCoordinateReferenceSystem& crs, double* geoTransform, int nBands,
QGis::DataType type );
QgsRasterDataProvider* initOutput( int nCols, int nRows,
const QgsCoordinateReferenceSystem& crs, double* geoTransform, int nBands,
QGis::DataType type,
QList<bool> destHasNoDataValueList = QList<bool>(), QList<double> destNoDataValueList = QList<double>() );

/**Calculate nRows, geotransform and pixel size for output*/
void globalOutputParameters( const QgsRectangle& extent, int nCols, int& nRows, double* geoTransform, double& pixelSize );

QString partFileName( int fileIndex );

Mode mMode;
QString mOutputUrl;
QString mOutputProviderKey;
QString mOutputFormat;
Expand All @@ -148,12 +158,12 @@ class CORE_EXPORT QgsRasterFileWriter
QgsRasterDataProvider::RasterPyramidsFormat mPyramidsFormat;

QDomDocument mVRTDocument;
QDomElement mVRTRedBand;
QDomElement mVRTGreenBand;
QDomElement mVRTBlueBand;
QDomElement mVRTAlphaBand;
QList<QDomElement> mVRTBands;

QProgressDialog* mProgressDialog;

const QgsRasterPipe* mPipe;
const QgsRasterInterface* mInput;
};

#endif // QGSRASTERFILEWRITER_H
67 changes: 58 additions & 9 deletions src/gui/qgsrasterlayersaveasdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "qgsgenericprojectionselector.h"

#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>


QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLayer,
QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs,
Expand Down Expand Up @@ -117,10 +117,12 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
// restore checked state for most groupboxes (default is to restore collapsed state)
// create options and pyramids will be preset, if user has selected defaults in the gdal options dlg
mCreateOptionsGroupBox->setSaveCheckedState( true );
mTilesGroupBox->setSaveCheckedState( true );
//mTilesGroupBox->setSaveCheckedState( true );
// don't restore nodata, it needs user input
// pyramids are not necessarily built every time

mTilesGroupBox->hide();

updateCrsGroup();

QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );
Expand Down Expand Up @@ -153,11 +155,44 @@ void QgsRasterLayerSaveAsDialog::on_mBrowseButton_clicked()
QString fileName;
if ( mTileModeCheckBox->isChecked() )
{
fileName = QFileDialog::getExistingDirectory( this, tr( "Select output directory" ) );
while ( true )
{
// TODO: would not it be better to select .vrt file instead of directory?
fileName = QFileDialog::getExistingDirectory( this, tr( "Select output directory" ) );
//fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ), QString(), tr( "VRT" ) + " (*.vrt *.VRT)" );

if ( fileName.isEmpty() ) break; // canceled

// Check if directory is empty
QDir dir( fileName );
QString baseName = QFileInfo( fileName ).baseName();
QStringList filters;
filters << QString( "%1.*" ).arg( baseName );
QStringList files = dir.entryList( filters );
if ( !files.isEmpty() )
{
QMessageBox::StandardButton button = QMessageBox::warning( this, tr( "Warning" ),
tr( "The directory %1 contains files which will be overwritten: %2" ).arg( dir.absolutePath() ).arg( files.join( ", " ) ),
QMessageBox::Ok | QMessageBox::Cancel );

if ( button == QMessageBox::Ok )
{
break;
}
else
{
fileName = "";
}
}
else
{
break;
}
}
}
else
{
fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ) );
fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ), QString(), tr( "GeoTIFF" ) + " (*.tif *.tiff *.TIF *.TIFF)" );
}

if ( !fileName.isEmpty() )
Expand Down Expand Up @@ -667,11 +702,25 @@ void QgsRasterLayerSaveAsDialog::on_mTileModeCheckBox_toggled( bool toggled )
if ( toggled )
{
// enable pyramids
if ( ! mPyramidsGroupBox->isChecked() )
mPyramidsGroupBox->setChecked( true );
if ( mPyramidsGroupBox->isCollapsed() )
mPyramidsGroupBox->setCollapsed( false );
mPyramidsOptionsWidget->checkAllLevels( true );

// Disabled (Radim), auto enabling of pyramids was making impression that
// we (programmers) know better what you (user) want to do,
// certainly auto expaning was bad experience

//if ( ! mPyramidsGroupBox->isChecked() )
// mPyramidsGroupBox->setChecked( true );

// Auto expanding mPyramidsGroupBox is bad - it auto crolls content of dialog
//if ( mPyramidsGroupBox->isCollapsed() )
// mPyramidsGroupBox->setCollapsed( false );
//mPyramidsOptionsWidget->checkAllLevels( true );

// Show / hide tile options
mTilesGroupBox->show();
}
else
{
mTilesGroupBox->hide();
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/gui/qgsrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ QgsRubberBand::QgsRubberBand( QgsMapCanvas* mapCanvas, QGis::GeometryType geomet

QgsRubberBand::QgsRubberBand( QgsMapCanvas* mapCanvas, bool isPolygon )
: QgsMapCanvasItem( mapCanvas )
, mWidth( 1 )
, mTranslationOffsetX( 0.0 )
, mTranslationOffsetY( 0.0 )
{
QgsRubberBand( mapCanvas, isPolygon ? QGis::Polygon : QGis::Line );
reset( isPolygon ? QGis::Polygon : QGis::Line );
setColor( QColor( Qt::lightGray ) );
}

QgsRubberBand::QgsRubberBand(): QgsMapCanvasItem( 0 )
Expand Down Expand Up @@ -407,9 +411,9 @@ void QgsRubberBand::paint( QPainter* p )
mPen.setWidth( 1 );
p->setPen( mPen );
QVector<QPointF>::const_iterator ptIt = pts.constBegin();
for( ; ptIt != pts.constEnd(); ++ptIt )
for ( ; ptIt != pts.constEnd(); ++ptIt )
{
p->drawEllipse( (*ptIt).x() - mWidth/2, (*ptIt).y() - mWidth/2, mWidth, mWidth );
p->drawEllipse(( *ptIt ).x() - mWidth / 2, ( *ptIt ).y() - mWidth / 2, mWidth, mWidth );
}
}
break;
Expand Down Expand Up @@ -496,7 +500,7 @@ QgsGeometry *QgsRubberBand::asGeometry()
{
QgsGeometry *geom = NULL;

switch( mGeometryType )
switch ( mGeometryType )
{
case QGis::Polygon:
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void QgsGrassPlugin::initGui()
connect( qgis, SIGNAL( newProject() ), this, SLOT( newProject() ) );

// Create region rubber band
mRegionBand = new QgsRubberBand( mCanvas, 1 );
mRegionBand = new QgsRubberBand( mCanvas, QGis::Polygon );
mRegionBand->setZValue( 20 );

// Create the action for tool (the icons are set later by calling setCurrentTheme)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/grass/qgsgrassregion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ QgsGrassRegionEdit::QgsGrassRegionEdit( QgsMapCanvas* canvas )
: QgsMapTool( canvas )
{
mDraw = false;
mRubberBand = new QgsRubberBand( mCanvas, true );
mSrcRubberBand = new QgsRubberBand( mCanvas, true );
mRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
mSrcRubberBand = new QgsRubberBand( mCanvas, QGis::Polygon );
QString gisdbase = QgsGrass::getDefaultGisdbase();
QString location = QgsGrass::getDefaultLocation();
mCrs = QgsGrass::crs( gisdbase, location );
Expand Down
88 changes: 42 additions & 46 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,17 @@ int CPL_STDCALL progressCallback( double dfComplete,
return true;
}

QgsGdalProvider::QgsGdalProvider( QString const & uri, QgsError error )
: QgsRasterDataProvider( uri )
, mValid( false )
{
setError( error );
}

QgsGdalProvider::QgsGdalProvider( QString const & uri )
QgsGdalProvider::QgsGdalProvider( QString const & uri, bool update )
: QgsRasterDataProvider( uri )
, QgsGdalProviderBase()
, mUpdate( update )
, mValid( true )
{
QgsDebugMsg( "QgsGdalProvider: constructing with uri '" + uri + "'." );
Expand Down Expand Up @@ -126,28 +133,11 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
setDataSourceUri( vsiPrefix + uri );
QgsDebugMsg( QString( "Trying %1 syntax, uri= %2" ).arg( vsiPrefix ).arg( dataSourceUri() ) );
}
else
{
// TODO: this constructor is also called for new rasters, in that case GDAL prints error:
// "ERROR 4: `pok.tif' does not exist in the file system, and is not recognised as a supported dataset name."
// To avoid this message, we test first if the file exists at all.
// This should be done better adding static create() method or something like that
// TODO: Cannot test for file existence, for example NetCDF with sublayers
// is using URI: NETCDF:"/path/to/file.cdf":layer1
/*
if ( !QFile::exists( uri ) )
{
QString msg = QString( "File does not exist: %1" ).arg( dataSourceUri() );
appendError( ERR( msg ) );
return;
}
*/
}

QString gdalUri = dataSourceUri();

CPLErrorReset();
mGdalBaseDataset = GDALOpen( TO8F( gdalUri ), GA_ReadOnly );
mGdalBaseDataset = GDALOpen( TO8F( gdalUri ), mUpdate ? GA_Update : GA_ReadOnly );

if ( !mGdalBaseDataset )
{
Expand Down Expand Up @@ -306,21 +296,23 @@ QString QgsGdalProvider::metadata()
myMetadata += "</p>\n";

//just use the first band
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, 1 );
if ( GDALGetOverviewCount( myGdalBand ) > 0 )
if ( GDALGetRasterCount( mGdalDataset ) > 0 )
{
int myOverviewInt;
for ( myOverviewInt = 0;
myOverviewInt < GDALGetOverviewCount( myGdalBand );
myOverviewInt++ )
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, 1 );
if ( GDALGetOverviewCount( myGdalBand ) > 0 )
{
GDALRasterBandH myOverview;
myOverview = GDALGetOverview( myGdalBand, myOverviewInt );
myMetadata += "<p>X : " + QString::number( GDALGetRasterBandXSize( myOverview ) );
myMetadata += ",Y " + QString::number( GDALGetRasterBandYSize( myOverview ) ) + "</p>";
int myOverviewInt;
for ( myOverviewInt = 0;
myOverviewInt < GDALGetOverviewCount( myGdalBand );
myOverviewInt++ )
{
GDALRasterBandH myOverview;
myOverview = GDALGetOverview( myGdalBand, myOverviewInt );
myMetadata += "<p>X : " + QString::number( GDALGetRasterBandXSize( myOverview ) );
myMetadata += ",Y " + QString::number( GDALGetRasterBandYSize( myOverview ) ) + "</p>";
}
}
}
myMetadata += "</p>\n";

if ( GDALGetGeoTransform( mGdalDataset, mGeoTransform ) != CE_None )
{
Expand Down Expand Up @@ -1479,7 +1471,7 @@ QString QgsGdalProvider::buildPyramids( QList<QgsRasterPyramid> const & theRaste
//something bad happenend
//QString myString = QString (CPLGetLastError());
GDALClose( mGdalBaseDataset );
mGdalBaseDataset = GDALOpen( TO8F( dataSourceUri() ), GA_ReadOnly );
mGdalBaseDataset = GDALOpen( TO8F( dataSourceUri() ), mUpdate ? GA_Update : GA_ReadOnly );
//Since we are not a virtual warped dataset, mGdalDataSet and mGdalBaseDataset are supposed to be the same
mGdalDataset = mGdalBaseDataset;

Expand Down Expand Up @@ -1521,7 +1513,7 @@ QString QgsGdalProvider::buildPyramids( QList<QgsRasterPyramid> const & theRaste
QgsDebugMsg( "Reopening dataset ..." );
//close the gdal dataset and reopen it in read only mode
GDALClose( mGdalBaseDataset );
mGdalBaseDataset = GDALOpen( TO8F( dataSourceUri() ), GA_ReadOnly );
mGdalBaseDataset = GDALOpen( TO8F( dataSourceUri() ), mUpdate ? GA_Update : GA_ReadOnly );
//Since we are not a virtual warped dataset, mGdalDataSet and mGdalBaseDataset are supposed to be the same
mGdalDataset = mGdalBaseDataset;
}
Expand Down Expand Up @@ -2399,17 +2391,27 @@ char** papszFromStringList( const QStringList& list )
return papszRetList;
}

#if 0
bool QgsGdalProvider::create( const QString& format, int nBands,
QGis::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions )
#endif
QGISEXTERN QgsGdalProvider * create(
const QString &uri,
const QString& format, int nBands,
QGis::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions )
{
//get driver
GDALDriverH driver = GDALGetDriverByName( format.toLocal8Bit().data() );
if ( !driver )
{
return false;
QgsError error( "Cannot load GDAL driver " + format, "GDAL provider" );
return new QgsGdalProvider( uri, error );
}

QString tmpStr = "create options:";
Expand All @@ -2418,27 +2420,21 @@ bool QgsGdalProvider::create( const QString& format, int nBands,
QgsDebugMsg( tmpStr );

//create dataset
CPLErrorReset();
char **papszOptions = papszFromStringList( createOptions );
GDALDatasetH dataset = GDALCreate( driver, dataSourceUri().toLocal8Bit().data(), width, height, nBands, ( GDALDataType )type, papszOptions );
GDALDatasetH dataset = GDALCreate( driver, uri.toLocal8Bit().data(), width, height, nBands, ( GDALDataType )type, papszOptions );
CSLDestroy( papszOptions );
if ( dataset == NULL )
{
return false;
QgsError error( QString( "Cannot create new dataset %1:\n%2" ).arg( uri ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ), "GDAL provider" );
return new QgsGdalProvider( uri, error );
}

mGeoTransform[0] = geoTransform[0];
mGeoTransform[1] = geoTransform[1];
mGeoTransform[2] = geoTransform[2];
mGeoTransform[3] = geoTransform[3];
mGeoTransform[4] = geoTransform[4];
mGeoTransform[5] = geoTransform[5];

GDALSetGeoTransform( dataset, mGeoTransform );
GDALSetGeoTransform( dataset, geoTransform );
GDALSetProjection( dataset, crs.toWkt().toLocal8Bit().data() );
GDALClose( dataset );

mGdalBaseDataset = dataset;
initBaseDataset();
return mValid;
return new QgsGdalProvider( uri, true );
}

bool QgsGdalProvider::write( void* data, int band, int width, int height, int xOffset, int yOffset )
Expand Down
10 changes: 9 additions & 1 deletion src/providers/gdal/qgsgdalprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase
* otherwise we contact the host directly.
*
*/
QgsGdalProvider( QString const & uri = 0 );
QgsGdalProvider( QString const & uri = 0, bool update = false );

/** Create invalid provider with error */
QgsGdalProvider( QString const & uri, QgsError error );

//! Destructor
~QgsGdalProvider();
Expand Down Expand Up @@ -234,11 +237,13 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase

/** Creates a new dataset with mDataSourceURI
@return true in case of success*/
/*
bool create( const QString& format, int nBands,
QGis::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions = QStringList() );
*/

/**Writes into the provider datasource*/
bool write( void* data, int band, int width, int height, int xOffset, int yOffset );
Expand All @@ -257,6 +262,9 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase
void statusChanged( QString );

private:
// update mode
bool mUpdate;

// initialize CRS from wkt
bool crsFromWkt( const char *wkt );

Expand Down
54 changes: 46 additions & 8 deletions src/providers/grass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ SET ( FUNCTIONS
"G_allocate_f_raster_buf"
"G_allocate_null_buf"
"G_allocate_raster_buf"
"G_ask_any"
"G_ask_in_mapset"
"G_ask_new"
"G_ask_old"
"G__calloc"
"G_chop"
"G_chrcat"
Expand All @@ -98,6 +102,8 @@ SET ( FUNCTIONS
"G_format_easting"
"G_format_northing"
"G_format_resolution"
"G_format_timestamp"
"G__write_timestamp"
"G_free"
"G_free_cats"
"G_free_cell_stats"
Expand All @@ -109,27 +115,34 @@ SET ( FUNCTIONS
"G_free_tokens"
"G_fseek"
"G_ftell"
"G__getenv"
"G__getenv2"
"G_get_cat"
"G_get_cats_title"
"G_get_c_raster_cat"
"G_get_color"
"G_get_color_range"
"G_get_c_raster_cat"
"G_get_c_raster_color"
"G_get_d_raster_color"
"G_get_f_raster_color"
"G_get_d_color_range"
"G_get_d_raster_cat"
"G__getenv"
"G__getenv2"
"G_get_fp_range_min_max"
"G_get_f_raster_cat"
"G_get_gisrc_mode"
"G_get_histogram_cat"
"G_getl"
"G_getl2"
"G_get_next_marked_raster_cat"
"G_get_range_min_max"
"G_get_raster_cat"
"G_get_raster_cats_title"
"G_get_raster_color"
"G_get_raster_row_colors"
"G_get_raster_value_c"
"G_get_raster_value_d"
"G_get_raster_value_f"
"G_gets"
"G_get_set_window"
"G_gettext"
"G_get_window"
Expand All @@ -145,10 +158,11 @@ SET ( FUNCTIONS
"G__init_null_patterns"
"G_init_range"
"G_init_raster_cats"
"G_interp_linear"
"G__insert_color_into_lookup"
"G_interp_bicubic"
"G_interp_bilinear"
"G_interp_cubic"
"G_interp_bicubic"
"G_interp_linear"
"G_is_absolute_path"
"G_is_c_null_value"
"G_is_d_null_value"
Expand All @@ -166,11 +180,15 @@ SET ( FUNCTIONS
"G_ls"
"G_ls_format"
"G__malloc"
"G_make_fp_colors"
"G_make_gyr_fp_colors"
"G_make_random_colors"
"G_mark_colors_as_fp"
"G_mark_raster_cats"
"G_mkdir"
"G_next_cell_stat"
"G_northing_to_row"
"G_num_standard_colors"
"G_number_of_tokens"
"G__null_bitstream_size"
"G__projection_name"
Expand All @@ -185,14 +203,20 @@ SET ( FUNCTIONS
"G_quant_set_neg_infinite_rule"
"G_putenv"
"G_raster_cmp"
"G_raster_cpy"
"G_raster_size"
"G_read_key_value_file"
"G__realloc"
"G_recreate_command"
"G_rewind_cell_stats"
"G_rewind_raster_cats"
"G_rindex"
"G_row_to_northing"
"G_row_update_fp_range"
"G_row_update_range"
"G_scan_easting"
"G_scan_northing"
"G_scan_timestamp"
"G_set_cat"
"G_set_c_null_value"
"G_set_d_null_value"
Expand All @@ -201,6 +225,7 @@ SET ( FUNCTIONS
"G_set_color_range"
"G_setenv"
"G_setenv2"
"G_set_cats_fmt"
"G_set_f_null_value"
"G_set_gisrc_mode"
"G_set_key_value"
Expand All @@ -210,6 +235,7 @@ SET ( FUNCTIONS
"G_set_raster_value_d"
"G_set_window"
"G_sleep"
"G_sleep_on_error"
"G_store"
"G_strcasecmp"
"G_strcat"
Expand All @@ -230,6 +256,9 @@ SET ( FUNCTIONS
"G_system"
"G_tokenize"
"G_trim_decimal"
"G_unmark_raster_cats"
"G_unset_error_routine"
"G_update_cell_stats"
"G_update_fp_range"
"G_update_key_value_file"
"G_update_range"
Expand All @@ -243,6 +272,7 @@ SET ( FUNCTIONS
"G_window_overlap"
"G_window_rows"
"G_write_key_value_file"
"G_yes"
"G_zero"
"G_zero_cell_buf"
"G_zero_raster_buf"
Expand Down Expand Up @@ -299,14 +329,14 @@ SET ( FUNCTION_PROTOTYPES
"G_get_map_row_nomask"
"G_get_null_value_row"
"G_get_projinfo"
"G_get_projunits"
"G_get_raster_map_type"
"G_get_raster_row"
"G_get_raster_row_nomask"
"G_get_reclass"
"G__gisinit"
"G_gisdbase"
"G_important_message"
"G__insert_color_into_lookup"
"G_legal_filename"
"G_location"
"G_location_path"
Expand All @@ -315,6 +345,7 @@ SET ( FUNCTION_PROTOTYPES
"G__make_mapset_element"
"G_mapset"
"G_maskfd"
"G_mask_info"
"G_message"
"G__name_is_fully_qualified"
"G_number_of_cats"
Expand All @@ -323,6 +354,7 @@ SET ( FUNCTION_PROTOTYPES
"G_open_fp_cell_new"
"G_open_new"
"G_open_raster_new"
"G_open_update"
"G_parser"
"G_put_cell_title"
"G_put_c_raster_row"
Expand All @@ -336,6 +368,7 @@ SET ( FUNCTION_PROTOTYPES
"G_read_colors"
"G_read_fp_range"
"G_read_history"
"G_read_quant"
"G_read_range"
"G_read_raster_cats"
"G_remove"
Expand All @@ -356,10 +389,14 @@ SET ( FUNCTION_PROTOTYPES
"G_vasprintf"
"G_verbose_message"
"G_warning"
"G_write_cats"
"G__write_colors"
"G_write_colors"
"G_write_fp_range"
"G_write_history"
"G_write_range"
"G_write_raster_cats"
"G_write_cats"
"G_write_raster_units"
)

SET ( FUNCTIONS_ALL
Expand All @@ -376,10 +413,11 @@ FILE(READ "${GRASS_INCLUDE_DIR}/grass/gisdefs.h" HEADER_FILE)
STRING(REGEX REPLACE "(/\\*([^*]|[\r\n]|(\\*+([^*/]|[\r\n])))*\\*+/)" "" HEADER_FILE "${HEADER_FILE}")
STRING(REGEX REPLACE "#[^\r\n]*" "" HEADER_FILE "${HEADER_FILE}")

# Add functions defined in glocale.h and spawn.h
# Add functions defined in glocale.h, colors.h and spawn.h
SET ( HEADER_FILE
${HEADER_FILE}
"char *G_gettext(const char *, const char *);"
"int G_num_standard_colors(void);"
"int G_spawn(const char *, ...);"
"int G_spawn_ex(const char *, ...);"
"int G_wait(int);"
Expand Down
80 changes: 72 additions & 8 deletions src/providers/grass/qgsgrassgislib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
// the library (in code section) - why?
#ifdef Q_OS_WIN
#include "qgsgrassgislibfunctions.h"
extern "C"
{
// defined here because too complex for parser in CMakeLists.txt
int GRASS_LIB_EXPORT G_cell_stats_histo_eq( struct Cell_stats *statf, CELL min1, CELL max1, CELL min2, CELL max2, int zero, void ( *func )( CELL, CELL, CELL ) );
}
#endif
#include "qgsgrassgislib.h"

Expand Down Expand Up @@ -573,12 +578,6 @@ int QgsGrassGisLib::G_open_raster_new( const char *name, RASTER_MAP_TYPE wr_type
raster.name = name;
//raster.writer = new QgsRasterFileWriter( dataSource );

raster.provider = ( QgsRasterDataProvider* )QgsProviderRegistry::instance()->provider( providerKey, dataSource );
if ( !raster.provider )
{
fatal( "Cannot load raster provider with data source: " + dataSource );
}

QString outputFormat = "GTiff";
int nBands = 1;
QGis::DataType type = qgisRasterType( wr_type );
Expand All @@ -591,11 +590,13 @@ int QgsGrassGisLib::G_open_raster_new( const char *name, RASTER_MAP_TYPE wr_type
geoTransform[4] = 0.0;
geoTransform[5] = -1. * mExtent.height() / mRows;

if ( !raster.provider->create( outputFormat, nBands, type, mColumns, mRows, geoTransform, mCrs ) )
raster.provider = QgsRasterDataProvider::create( providerKey, dataSource, outputFormat, nBands, type, mColumns, mRows, geoTransform, mCrs );
if ( !raster.provider || !raster.provider->isValid() )
{
delete raster.provider;
if ( raster.provider ) delete raster.provider;
fatal( "Cannot create output data source: " + dataSource );
}

raster.band = 1;
double noDataValue = std::numeric_limits<double>::quiet_NaN();
switch ( wr_type )
Expand Down Expand Up @@ -1303,6 +1304,13 @@ int GRASS_LIB_EXPORT G_lookup_key_value_from_file( const char *file, const char
return fn( file, key, value, n );
}

typedef int G_cell_stats_histo_eq_type( struct Cell_stats *, CELL, CELL, CELL, CELL, int, void ( * )( CELL, CELL, CELL ) );

int GRASS_LIB_EXPORT G_cell_stats_histo_eq( struct Cell_stats *statf, CELL min1, CELL max1, CELL min2, CELL max2, int zero, void ( *func )( CELL, CELL, CELL ) )
{
G_cell_stats_histo_eq_type *fn = ( G_cell_stats_histo_eq_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_cell_stats_histo_eq_type" ) );
return fn( statf, min1, max1, min2, max2, zero, func );
}

int GRASS_LIB_EXPORT G__temp_element( char *element )
{
Expand All @@ -1328,6 +1336,13 @@ char GRASS_LIB_EXPORT *G_location( void )
return qstrdup( "qgis" );
}

int GRASS_LIB_EXPORT G__write_colors( FILE * fd, struct Colors *colors )
{
Q_UNUSED( fd );
Q_UNUSED( colors );
return 1; // OK
}

int GRASS_LIB_EXPORT G_write_colors( const char *name, const char *mapset, struct Colors *colors )
{
Q_UNUSED( name );
Expand Down Expand Up @@ -1560,6 +1575,11 @@ struct Key_Value GRASS_LIB_EXPORT *G_get_projinfo( void )
return NULL;
}

struct Key_Value GRASS_LIB_EXPORT *G_get_projunits( void )
{
return NULL;
}

int GRASS_LIB_EXPORT G_get_reclass( const char *name, const char *mapset, struct Reclass *reclass )
{
Q_UNUSED( name );
Expand All @@ -1584,3 +1604,47 @@ int GRASS_LIB_EXPORT G_round_fp_map( const char *name, const char *mapset )
Q_UNUSED( mapset );
return -1; // error
}

char GRASS_LIB_EXPORT *G_mask_info( void )
{
return qstrdup( "none" );
}

int GRASS_LIB_EXPORT G_read_quant( const char *name, const char *mapset, struct Quant *quant )
{
Q_UNUSED( name );
Q_UNUSED( mapset );
G_quant_init( quant );
return 0; // does not exist
}

int GRASS_LIB_EXPORT G_write_fp_range( const char *name, const struct FPRange *range )
{
Q_UNUSED( name );
Q_UNUSED( range );
return 0; // OK
}

int GRASS_LIB_EXPORT G_write_range( const char *name, const struct Range *range )
{
Q_UNUSED( name );
Q_UNUSED( range );
return 0; // OK
}

int GRASS_LIB_EXPORT G_write_raster_units( const char *name, const char *str )
{
Q_UNUSED( name );
Q_UNUSED( str );
return 0; // OK
}

int GRASS_LIB_EXPORT G_open_update( const char *element, const char *name )
{
// G_open_update is used in r.flow if parm.seg, but parm.seg doesnt seem
// to be set to 1
Q_UNUSED( element );
Q_UNUSED( name );
qFatal( "G_open_update not imlemented" );
return -1; // Cannot open
}
Loading