2012-10-05 23:28:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2012-10-05 23:37:02 +02:00
|
|
|
# ------------------------------------------------------------------------
|
2012-08-04 19:48:25 +02:00
|
|
|
# MMQGISX - MMQGIS Wrapper for Sextante
|
|
|
|
#
|
|
|
|
# begin : 18 May 2010
|
|
|
|
# copyright : (c) 2012 by Michael Minn
|
|
|
|
# email : See michaelminn.com
|
|
|
|
#
|
2012-10-05 23:37:02 +02:00
|
|
|
# MMQGIS program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
# ------------------------------------------------------------------------
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
from PyQt4 import QtGui
|
|
|
|
from PyQt4.QtCore import *
|
|
|
|
from PyQt4.QtGui import *
|
|
|
|
from sextante.core.GeoAlgorithm import GeoAlgorithm
|
|
|
|
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
|
|
|
from sextante.parameters.ParameterNumber import ParameterNumber
|
|
|
|
from sextante.parameters.ParameterSelection import ParameterSelection
|
|
|
|
from sextante.parameters.ParameterString import ParameterString
|
|
|
|
from sextante.parameters.ParameterTable import ParameterTable
|
|
|
|
from sextante.parameters.ParameterTableField import ParameterTableField
|
|
|
|
from sextante.parameters.ParameterVector import ParameterVector
|
|
|
|
from sextante.outputs.OutputTable import OutputTable
|
|
|
|
from sextante.outputs.OutputVector import OutputVector
|
2012-12-20 00:16:05 +01:00
|
|
|
from sextante.algs.mmqgisx.mmqgisx_library import *
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_attribute_export_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
OUTFILENAME = "OUTFILENAME"
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
FIELDDELIMITER = "FIELDDELIMITER"
|
|
|
|
LINETERMINATOR = "LINETERMINATOR"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Attribute export"
|
|
|
|
self.group = "Vector general tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "SourceLayer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
|
|
|
|
self.delimiters = ["Comma", "Bar", "Space"]
|
|
|
|
self.addParameter(ParameterSelection(self.FIELDDELIMITER, "Delimiter", self.delimiters, default = 0))
|
|
|
|
|
|
|
|
self.terminators = ["CRLF", "LF"]
|
|
|
|
self.addParameter(ParameterSelection(self.LINETERMINATOR, "Delimiter", self.terminators, default = 0))
|
|
|
|
|
|
|
|
self.addOutput(OutputTable(self.OUTFILENAME, "Output CSV File"))
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_export.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
def processAlgorithm(self, progress):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
outfilename = self.getOutputValue(self.OUTFILENAME)
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if self.getParameterValue(self.FIELDDELIMITER) == 1:
|
|
|
|
field_delimiter = "|"
|
|
|
|
elif self.getParameterValue(self.FIELDDELIMITER) == 2:
|
|
|
|
field_delimiter = " "
|
|
|
|
else:
|
|
|
|
field_delimiter = ","
|
|
|
|
|
|
|
|
if self.getParameterValue(self.LINETERMINATOR) == 1:
|
|
|
|
line_terminator = "\n"
|
|
|
|
else:
|
|
|
|
line_terminator = "\r\n"
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_attribute_export(progress, outfilename, layer, None,
|
2012-08-04 19:48:25 +02:00
|
|
|
field_delimiter, line_terminator)
|
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_attribute_join_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
INFILENAME = "INFILENAME"
|
|
|
|
JOINFIELD = "JOINFIELD"
|
|
|
|
JOINATTRIBUTE = "JOINATTRIBUTE"
|
|
|
|
OUTFILENAME = "OUTFILENAME"
|
|
|
|
NOTFOUNDNAME = "NOTFOUNDNAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Attribute join"
|
|
|
|
self.group = "Vector table tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.addParameter(ParameterTableField(self.JOINATTRIBUTE,
|
2012-12-20 00:16:05 +01:00
|
|
|
"Layer attribute field", mmqgisx_attribute_join_algorithm.LAYERNAME))
|
2013-01-12 23:36:00 +01:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterTable(self.INFILENAME, "Table to join", False))
|
|
|
|
self.addParameter(ParameterTableField(self.JOINFIELD, "Table field", self.INFILENAME))
|
2013-01-12 23:36:00 +01:00
|
|
|
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.OUTFILENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.addOutput(OutputTable(self.NOTFOUNDNAME, "Not Found CSV Output List"))
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_join.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
|
|
|
layername = layer.name()
|
|
|
|
|
|
|
|
table = QGisLayers.getObjectFromUri(self.getParameterValue(self.INFILENAME))
|
|
|
|
infilename = table.name()
|
|
|
|
|
|
|
|
joinfield = self.getParameterValue(self.JOINFIELD)
|
|
|
|
joinattribute = self.getParameterValue(self.JOINATTRIBUTE)
|
|
|
|
|
|
|
|
outfilename = self.getOutputValue(self.OUTFILENAME)
|
|
|
|
notfoundname = self.getOutputValue(self.NOTFOUNDNAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_attribute_join(progress, layername, infilename, joinfield,
|
2012-08-04 19:48:25 +02:00
|
|
|
joinattribute, outfilename, notfoundname, False)
|
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_delete_columns_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
COLUMN = "COLUMN"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Delete column"
|
|
|
|
self.group = "Vector table tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.COLUMN, "Fields to delete", self.LAYERNAME))
|
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_join.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
column = self.getParameterValue(self.COLUMN)
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_delete_columns(progress, layer, [ column ], savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_delete_duplicate_geometries_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Delete duplicate geometries"
|
|
|
|
self.group = "Vector general tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_join.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
# Include must be done here to avoid cyclic import
|
|
|
|
from sextante.core.Sextante import Sextante
|
|
|
|
qgis = Sextante.getInterface()
|
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-11-08 00:40:27 +01:00
|
|
|
message = mmqgisx_delete_duplicate_geometries(qgis, layer, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_geocode_google_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
CSVNAME = "CSVNAME"
|
|
|
|
ADDRESS = "ADDRESS"
|
|
|
|
CITY = "CITY"
|
|
|
|
STATE = "STATE"
|
|
|
|
COUNTRY = "COUNTRY"
|
|
|
|
SHAPEFILENAME = "SHAPEFILENAME"
|
|
|
|
NOTFOUNDFILE = "NOTFOUNDFILE"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Geocode using Google"
|
|
|
|
self.group = "Vector general tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterTable(self.CSVNAME, "Input table", False))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.addParameter(ParameterTableField(self.ADDRESS, "Address", self.CSVNAME))
|
|
|
|
self.addParameter(ParameterTableField(self.CITY, "City", self.CSVNAME))
|
|
|
|
self.addParameter(ParameterTableField(self.STATE, "State", self.CSVNAME))
|
|
|
|
self.addParameter(ParameterTableField(self.COUNTRY, "Country", self.CSVNAME))
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.SHAPEFILENAME, "Output"))
|
|
|
|
self.addOutput(OutputTable(self.NOTFOUNDFILE, "Not found output list"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_geocode_google.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
# Include must be done here to avoid cyclic import
|
|
|
|
from sextante.core.Sextante import Sextante
|
|
|
|
qgis = Sextante.getInterface()
|
|
|
|
|
|
|
|
table = QGisLayers.getObjectFromUri(self.getParameterValue(self.CSVNAME))
|
|
|
|
csvname = table.name()
|
|
|
|
|
|
|
|
params = [ self.getParameterValue(self.ADDRESS), self.getParameterValue(self.CITY),
|
|
|
|
self.getParameterValue(self.STATE), self.getParameterValue(self.COUNTRY) ]
|
|
|
|
|
|
|
|
keys = []
|
|
|
|
for param in params:
|
|
|
|
if not (param in keys):
|
|
|
|
keys.append(param)
|
|
|
|
|
|
|
|
shapefilename = self.getOutputValue(self.SHAPEFILENAME)
|
|
|
|
notfoundfile = self.getOutputValue(self.NOTFOUNDFILE)
|
|
|
|
|
|
|
|
message = mmqgisx_geocode_google(qgis, csvname, shapefilename, notfoundfile, keys, False)
|
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_geometry_convert_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
NEWTYPE = "NEWTYPE"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Convert geometry type"
|
|
|
|
self.group = "Vector geometry tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
self.newtypes = ["Centroids", "Nodes", "Linestrings", "Multilinestrings", "Polygons"]
|
|
|
|
self.addParameter(ParameterSelection(self.NEWTYPE, "New Geometry Type", self.newtypes, default = 0))
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_export.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
|
|
|
index = self.getParameterValue(self.NEWTYPE)
|
|
|
|
|
|
|
|
splitnodes = 0
|
|
|
|
if index == 0:
|
|
|
|
newtype = QGis.WKBPoint
|
|
|
|
elif index == 1:
|
|
|
|
newtype = QGis.WKBPoint
|
|
|
|
splitnodes = 1
|
|
|
|
elif index == 2:
|
|
|
|
newtype = QGis.WKBLineString
|
|
|
|
elif index == 3:
|
|
|
|
newtype = QGis.WKBMultiLineString
|
|
|
|
elif index == 4:
|
|
|
|
newtype = QGis.WKBPolygon
|
|
|
|
else:
|
|
|
|
newtype = QGis.WKBPoint
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_geometry_convert(progress, layer, newtype, splitnodes, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
|
|
|
|
|
|
|
# Has bug when no attribute file with points
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_geometry_export_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
NODEFILENAME = "NODEFILENAME"
|
|
|
|
ATTRIBUTEFILENAME = "ATTRIBUTEFILENAME"
|
|
|
|
FIELDDELIMITER = "FIELDDELIMITER"
|
|
|
|
LINETERMINATOR = "LINETERMINATOR"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Geometry export"
|
|
|
|
self.group = "Vector general tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-24 00:03:30 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-24 00:03:30 +01:00
|
|
|
self.addOutput(OutputTable(self.NODEFILENAME, "Node output file"))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.addOutput(OutputTable(self.ATTRIBUTEFILENAME, "Attribute CSV Output File Name (non-points only)"))
|
|
|
|
|
|
|
|
self.delimiters = ["Comma", "Bar", "Space"]
|
|
|
|
self.addParameter(ParameterSelection(self.FIELDDELIMITER, "Delimiter", self.delimiters, default = 0))
|
|
|
|
|
|
|
|
self.terminators = ["CRLF", "LF"]
|
|
|
|
self.addParameter(ParameterSelection(self.LINETERMINATOR, "Delimiter", self.terminators, default = 0))
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_export.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
# Include must be done here to avoid cyclic import
|
|
|
|
from sextante.core.Sextante import Sextante
|
|
|
|
qgis = Sextante.getInterface()
|
|
|
|
|
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
|
|
|
layername = layer.name()
|
|
|
|
|
|
|
|
node_filename = self.getOutputValue(self.NODEFILENAME)
|
|
|
|
attribute_filename = self.getOutputValue(self.ATTRIBUTEFILENAME)
|
|
|
|
print "Layer: " + str(layername)
|
|
|
|
print "Nodes: " + str(node_filename)
|
|
|
|
print "Attributes: " + str(attribute_filename)
|
|
|
|
|
|
|
|
if self.getParameterValue(self.FIELDDELIMITER) == 1:
|
|
|
|
field_delimiter = "|"
|
|
|
|
elif self.getParameterValue(self.FIELDDELIMITER) == 2:
|
|
|
|
field_delimiter = " "
|
|
|
|
else:
|
|
|
|
field_delimiter = ","
|
|
|
|
|
|
|
|
if self.getParameterValue(self.LINETERMINATOR) == 1:
|
|
|
|
line_terminator = "\n"
|
|
|
|
else:
|
|
|
|
line_terminator = "\r\n"
|
|
|
|
|
2012-12-10 00:12:07 +01:00
|
|
|
message = mmqgisx_geometry_export_to_csv(qgis, layername, node_filename, attribute_filename,
|
2012-08-04 19:48:25 +02:00
|
|
|
field_delimiter, line_terminator)
|
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_geometry_import_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
NODEFILENAME = "NODEFILENAME"
|
|
|
|
LONGITUDE = "LONGITUDE"
|
|
|
|
LATITUDE = "LATITUDE"
|
|
|
|
SHAPEID = "SHAPEID"
|
|
|
|
GEOMETRYTYPE = "GEOMETRYTYPE"
|
|
|
|
SHAPEFILENAME = "SHAPEFILENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Create from table"
|
|
|
|
self.group = "Vector creation tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterTable(self.NODEFILENAME, "Input table", False))
|
|
|
|
self.addParameter(ParameterTableField(self.LONGITUDE, "Longitude column", self.NODEFILENAME))
|
|
|
|
self.addParameter(ParameterTableField(self.LATITUDE, "Latitude column", self.NODEFILENAME))
|
|
|
|
self.addParameter(ParameterTableField(self.SHAPEID, "Shape ID column", self.NODEFILENAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.geotypes = ['Point', 'Polyline', 'Polygon']
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterSelection(self.GEOMETRYTYPE, "Geometry type", self.geotypes, default = 0))
|
|
|
|
self.addOutput(OutputVector(self.SHAPEFILENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_geometry_import.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
|
|
|
table = QGisLayers.getObjectFromUri(self.getParameterValue(self.NODEFILENAME))
|
|
|
|
node_filename = table.name()
|
|
|
|
|
|
|
|
longitude = self.getParameterValue(self.LONGITUDE)
|
|
|
|
latitude = self.getParameterValue(self.LATITUDE)
|
|
|
|
shapeid = self.getParameterValue(self.SHAPEID)
|
|
|
|
geometrytype = self.geotypes[self.getParameterValue(self.GEOMETRYTYPE)]
|
|
|
|
shapefilename = self.getOutputValue(self.SHAPEFILENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_geometry_import_from_csv(progress, node_filename, longitude, latitude,
|
2012-08-04 19:48:25 +02:00
|
|
|
shapeid, geometrytype, shapefilename, False)
|
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_grid_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
HSPACING = "HSPACING"
|
|
|
|
VSPACING = "VSPACING"
|
|
|
|
WIDTH = "WIDTH"
|
|
|
|
HEIGHT = "HEIGHT"
|
|
|
|
CENTERX = "CENTERX"
|
|
|
|
CENTERY = "CENTERY"
|
|
|
|
GRIDTYPE = "GRIDTYPE"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Create grid"
|
|
|
|
self.group = "Vector creation tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterNumber(self.HSPACING, "Horizontal spacing", default = 10))
|
|
|
|
self.addParameter(ParameterNumber(self.VSPACING, "Vertical spacing", default = 10))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.addParameter(ParameterNumber(self.WIDTH, "Width", default = 360))
|
|
|
|
self.addParameter(ParameterNumber(self.HEIGHT, "Height", default = 180))
|
|
|
|
self.addParameter(ParameterNumber(self.CENTERX, "Center X", default = 0))
|
|
|
|
self.addParameter(ParameterNumber(self.CENTERY, "Center Y", default = 0))
|
|
|
|
self.gridtype_options = ["Rectangle (line)","Rectangle (polygon)","Diamond (polygon)","Hexagon (polygon)"]
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterSelection(self.GRIDTYPE, "Grid type",
|
2012-08-04 19:48:25 +02:00
|
|
|
self.gridtype_options, default = 0))
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2013-01-12 23:36:00 +01:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_grid.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
hspacing = self.getParameterValue(self.HSPACING)
|
|
|
|
vspacing = self.getParameterValue(self.VSPACING)
|
|
|
|
width = self.getParameterValue(self.WIDTH)
|
|
|
|
height = self.getParameterValue(self.HEIGHT)
|
|
|
|
centerx = self.getParameterValue(self.CENTERX)
|
|
|
|
centery = self.getParameterValue(self.CENTERY)
|
|
|
|
originx = centerx - (width / 2.0)
|
|
|
|
originy = centery - (height / 2.0)
|
|
|
|
gridtype = self.gridtype_options[self.getParameterValue(self.GRIDTYPE)]
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_grid(progress, savename, hspacing, vspacing, width,
|
2012-08-04 19:48:25 +02:00
|
|
|
height, originx, originy, gridtype, 0)
|
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_gridify_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
HSPACING = "HSPACING"
|
|
|
|
VSPACING = "VSPACING"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Snap points to grid"
|
|
|
|
self.group = "Vector general tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input Layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterNumber(self.HSPACING, "Horizontal spacing", default = 0.1))
|
|
|
|
self.addParameter(ParameterNumber(self.VSPACING, "Vertical spacing", default = 0.1))
|
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_gridify.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
hspacing = self.getParameterValue(self.HSPACING)
|
|
|
|
vspacing = self.getParameterValue(self.VSPACING)
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_gridify_layer(progress, layer, hspacing, vspacing, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_hub_distance_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
SOURCENAME = "SOURCENAME"
|
|
|
|
DESTNAME = "DESTNAME"
|
|
|
|
NAMEATTRIBUTE = "NAMEATTRIBUTE"
|
|
|
|
SHAPETYPE = "SHAPETYPE"
|
|
|
|
UNITS = "UNITS"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Distance to nearest hub"
|
|
|
|
self.group = "Vector analysis tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
self.addParameter(ParameterVector(self.SOURCENAME, "Source Points Layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterVector(self.DESTNAME, "Destination Hubs Layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.NAMEATTRIBUTE, "Hub Layer Name Attribute", self.DESTNAME))
|
|
|
|
|
|
|
|
self.shapetypes = ["Point", "Line to Hub"]
|
|
|
|
self.addParameter(ParameterSelection(self.SHAPETYPE, "Output Shape Type", self.shapetypes, default = 0))
|
|
|
|
self.unitlist = ["Meters", "Feet", "Miles", "Kilometers", "Layer Units"]
|
|
|
|
self.addParameter(ParameterSelection(self.UNITS, "Measurement Unit", self.unitlist, default = 0))
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_hub_distance.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
2012-12-10 00:12:07 +01:00
|
|
|
layersource = QGisLayers.getObjectFromUri(self.getParameterValue(self.SOURCENAME))
|
|
|
|
layerdest = QGisLayers.getObjectFromUri(self.getParameterValue(self.DESTNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
nameattribute = self.getParameterValue(self.NAMEATTRIBUTE)
|
|
|
|
units = self.unitlist[self.getParameterValue(self.UNITS)]
|
|
|
|
addlines = self.getParameterValue(self.SHAPETYPE)
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_hub_distance(progress, layersource, layerdest, nameattribute, units, addlines, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_hub_lines_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
HUBNAME = "HUBNAME"
|
|
|
|
HUBATTRIBUTE = "HUBATTRIBUTE"
|
|
|
|
SPOKENAME = "SPOKENAME"
|
|
|
|
SPOKEATTRIBUTE = "SPOKEATTRIBUTE"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Hub lines"
|
|
|
|
self.group = "Vector analysis tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
self.addParameter(ParameterVector(self.HUBNAME, "Hub Point Layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.HUBATTRIBUTE, "Hub ID Attribute", self.HUBNAME))
|
|
|
|
self.addParameter(ParameterVector(self.SPOKENAME, "Spoke Point Layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.SPOKEATTRIBUTE, "Spoke Hub ID Attribute", self.SPOKENAME))
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_hub_distance.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
2012-12-10 00:12:07 +01:00
|
|
|
hublayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.HUBNAME))
|
2012-11-08 00:40:27 +01:00
|
|
|
spokelayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.SPOKENAME))
|
2012-12-10 00:12:07 +01:00
|
|
|
|
2012-08-04 19:48:25 +02:00
|
|
|
hubattribute = self.getParameterValue(self.HUBATTRIBUTE)
|
|
|
|
spokeattribute = self.getParameterValue(self.SPOKEATTRIBUTE)
|
|
|
|
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_hub_lines(progress, hublayer, hubattribute, spokelayer, spokeattribute, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_label_point_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
LABELATTRIBUTE = "LABELATTRIBUTE"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Create label layer"
|
|
|
|
self.group = "Vector creation tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.LABELATTRIBUTE, "Label attribute", self.LAYERNAME))
|
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_label.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
labelattribute = self.getParameterValue(self.LABELATTRIBUTE)
|
|
|
|
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_label_point(progress, layer, labelattribute, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_merge_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYER1 = "LAYER1"
|
|
|
|
LAYER2 = "LAYER2"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Merge vector layers"
|
|
|
|
self.group = "Vector general tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYER1, "Input layer 1", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterVector(self.LAYER2, "Source layer 2", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_merge.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
2012-12-10 00:12:07 +01:00
|
|
|
layer1 = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYER1))
|
|
|
|
layer2 = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYER2))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_merge(progress, [ layer1, layer2 ], savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_select_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
ATTRIBUTE = "ATTRIBUTE"
|
|
|
|
COMPARISONVALUE = "COMPARISONVALUE"
|
|
|
|
COMPARISON = "COMPARISON"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Select by attribute"
|
|
|
|
self.group = "Vector selection tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input Layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.ATTRIBUTE, "Selection attribute", self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.comparisons = ['==', '!=', '>', '>=', '<', '<=', 'begins with', 'contains']
|
|
|
|
self.addParameter(ParameterSelection(self.COMPARISON, "Comparison", self.comparisons, default = 0))
|
|
|
|
self.addParameter(ParameterString(self.COMPARISONVALUE, "Value", default = "0"))
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_attribute_export.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
def processAlgorithm(self, progress):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
attribute = self.getParameterValue(self.ATTRIBUTE)
|
2013-01-12 23:36:00 +01:00
|
|
|
comparison = self.comparisons [ self.getParameterValue(self.COMPARISON) ]
|
2012-08-04 19:48:25 +02:00
|
|
|
comparisonvalue = self.getParameterValue(self.COMPARISONVALUE)
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_select(progress, layer, attribute, comparisonvalue, comparison, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_sort_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
ATTRIBUTE = "ATTRIBUTE"
|
|
|
|
DIRECTION = "DIRECTION"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Sort by attribute"
|
|
|
|
self.group = "Vector table tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.ATTRIBUTE, "Selection attribute", self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
self.directions = ['Ascending', 'Descending']
|
|
|
|
self.addParameter(ParameterSelection(self.DIRECTION, "Direction", self.directions, default = 0))
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_sort.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
2013-01-12 23:36:00 +01:00
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
attribute = self.getParameterValue(self.ATTRIBUTE)
|
|
|
|
direction = self.directions [ self.getParameterValue(self.DIRECTION) ]
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_sort(progress, layer, attribute, savename, direction, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
|
|
|
# Too complex for Sextante GUI
|
|
|
|
# def mmqgisx_geocode_street_layer(GeoAlgorithm):
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_text_to_float_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
ATTRIBUTE = "ATTRIBUTE"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Text to float"
|
|
|
|
self.group = "Vector table tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Input Layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addParameter(ParameterTableField(self.ATTRIBUTE, "Text attribute to convert to float", self.LAYERNAME))
|
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_text_to_float.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
|
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
|
|
|
|
|
|
|
attribute = self.getParameterValue(self.ATTRIBUTE)
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
message = mmqgisx_text_to_float(progress, layer, [ attribute ], savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
class mmqgisx_voronoi_algorithm(GeoAlgorithm):
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
LAYERNAME = "LAYERNAME"
|
|
|
|
SAVENAME = "SAVENAME"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2012-12-20 00:16:05 +01:00
|
|
|
self.name = "Voronoi diagram"
|
|
|
|
self.group = "Vector geometry tools"
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
self.addParameter(ParameterVector(self.LAYERNAME, "Points layer", ParameterVector.VECTOR_TYPE_ANY))
|
|
|
|
self.addOutput(OutputVector(self.SAVENAME, "Output"))
|
2012-08-04 19:48:25 +02:00
|
|
|
|
2012-12-20 00:16:05 +01:00
|
|
|
#===========================================================================
|
|
|
|
# def getIcon(self):
|
|
|
|
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/mmqgis_voronoi.png")
|
|
|
|
#===========================================================================
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
|
|
|
# Include must be done here to avoid cyclic import
|
|
|
|
from sextante.core.Sextante import Sextante
|
|
|
|
qgis = Sextante.getInterface()
|
|
|
|
|
|
|
|
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.LAYERNAME))
|
|
|
|
|
|
|
|
savename = self.getOutputValue(self.SAVENAME)
|
|
|
|
|
2012-11-08 00:40:27 +01:00
|
|
|
message = mmqgisx_voronoi_diagram(qgis, layer, savename, False)
|
2012-08-04 19:48:25 +02:00
|
|
|
|
|
|
|
if message:
|
|
|
|
raise GeoAlgorithmExecutionException(message)
|
|
|
|
|