I'm trying to update the Using Custom Functions tutorial to QGis 3 and Python 3 and I've run into an interesting issue. With the following code I can create an expression
GetUtmZone()='33N' and it works in the Output preview, it works to zoom to the features but if I try to select features it says no features are found!
There seems to be no issue with the function code as it works fine as a label and a map tip.
import math from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom', usesGeometry=True) def GetUtmZone(feature, parent): centroid = feature.geometry() longitude = centroid.asPoint().x() latitude = centroid.asPoint().y() zone_number = math.floor(((longitude + 180) / 6) % 60) + 1 if latitude >= 0: zone_letter = 'N' else: zone_letter = 'S' return '%d%s' % (int(zone_number), zone_letter)
The zoom to's are clearly working but each select returns the warning: No matching features found.
QGIS version 3.4.4-Madeira
QGIS code revision f6ddc62
Compiled against Qt 5.9.5
Running against Qt 5.9.5
Compiled against GDAL/OGR 2.2.3
Running against GDAL/OGR 2.2.3
Compiled against GEOS 3.6.2-CAPI-1.10.2
Running against GEOS 3.6.2-CAPI-1.10.2 4d2925d6
PostgreSQL Client Version 10.6 (Ubuntu 10.6-0ubuntu0.18.04.1)
SpatiaLite Version 4.3.0a
QWT Version 6.1.3
QScintilla2 Version 2.10.2 PROJ.4 Version 493
Linux astun-desktop 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux