-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using QVariant.Type enum instead of numbers for readability.
(cherry picked from commit 6df926d)
- Loading branch information
1 parent
a7092ca
commit dbf6169
Showing
1 changed file
with
16 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,9 @@ | |
|
||
__revision__ = '$Format:%H$' | ||
|
||
from PyQt4.QtCore import QLocale, QDate | ||
from PyQt4.QtCore import QLocale, QDate, QVariant | ||
from qgis.core import QgsFeatureRequest, QgsFeature, QgsGeometry | ||
|
||
from processing.core.GeoAlgorithm import GeoAlgorithm | ||
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException | ||
from processing.core.ProcessingLog import ProcessingLog | ||
|
@@ -53,6 +54,9 @@ class Eliminate(GeoAlgorithm): | |
MODE_SMALLEST_AREA = 1 | ||
MODE_BOUNDARY = 2 | ||
|
||
def getIcon(self): | ||
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'eliminate.png')) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
def defineCharacteristics(self): | ||
self.name, self.i18n_name = self.trAlgorithm('Eliminate sliver polygons') | ||
self.group, self.i18n_group = self.trAlgorithm('Vector geometry tools') | ||
|
@@ -91,6 +95,7 @@ def processAlgorithm(self, progress): | |
boundary = self.getParameterValue(self.MODE) == self.MODE_BOUNDARY | ||
smallestArea = self.getParameterValue(self.MODE) == self.MODE_SMALLEST_AREA | ||
keepSelection = self.getParameterValue(self.KEEPSELECTION) | ||
processLayer = vector.duplicateInMemory(inLayer) | ||
This comment has been minimized.
Sorry, something went wrong.
bstroebl
|
||
|
||
if not keepSelection: | ||
# Make a selection with the values provided | ||
|
@@ -102,26 +107,26 @@ def processAlgorithm(self, progress): | |
selectType = inLayer.fields()[selectindex].type() | ||
selectionError = False | ||
|
||
if selectType == 2 or selectType == 4: | ||
if selectType == QVariant.Int or selectType == QVariant.LongLong: | ||
try: | ||
y = int(comparisonvalue) | ||
except ValueError: | ||
selectionError = True | ||
msg = self.tr('Cannot convert "%s" to integer' % unicode(comparisonvalue)) | ||
elif selectType == 6: | ||
elif selectType == QVariant.Double: | ||
try: | ||
y = float(comparisonvalue) | ||
except ValueError: | ||
selectionError = True | ||
msg = self.tr('Cannot convert "%s" to float' % unicode(comparisonvalue)) | ||
elif selectType == 10: | ||
# 10: string, boolean | ||
elif selectType == QVariant.String: | ||
# 10: string, boolean | ||
try: | ||
y = unicode(comparisonvalue) | ||
except ValueError: | ||
selectionError = True | ||
msg = self.tr('Cannot convert "%s" to unicode' % unicode(comparisonvalue)) | ||
elif selectType == 14: | ||
elif selectType == QVariant.Date: | ||
# date | ||
dateAndFormat = comparisonvalue.split(' ') | ||
|
||
|
@@ -146,7 +151,7 @@ def processAlgorithm(self, progress): | |
msg += self.tr('Enter the date and the date format, e.g. "07.26.2011" "MM.dd.yyyy".') | ||
|
||
if (comparison == 'begins with' or comparison == 'contains') \ | ||
and selectType != 10: | ||
and selectType != QVariant.String: | ||
selectionError = True | ||
msg = self.tr('"%s" can only be used with string fields' % comparison) | ||
|
||
|
@@ -162,14 +167,14 @@ def processAlgorithm(self, progress): | |
if aValue is None: | ||
continue | ||
|
||
if selectType == 2 or selectType == 4: | ||
if selectType == QVariant.Int or selectType == QVariant.LongLong: | ||
x = int(aValue) | ||
elif selectType == 6: | ||
elif selectType == QVariant.Double: | ||
x = float(aValue) | ||
elif selectType == 10: | ||
elif selectType == QVariant.String: | ||
# 10: string, boolean | ||
x = unicode(aValue) | ||
elif selectType == 14: | ||
elif selectType == QVariant.Date: | ||
# date | ||
x = aValue # should be date | ||
|
||
|
Hi,
QIcon is throwing a stack trace, I think you need to include QtGui module.
Regards
Paul