[QGIS-Developer] PyQGIS: QGis.Meters or QGis.UnitType.Meters ??

Richard Duivenvoorde rdmailings at duif.net
Sun Feb 17 22:59:07 PST 2019


Hi, (sorry earlier version was encrypted)

for a (2.18) plugin which would only work on a crs in meters I did a check:

if layer.crs().mapUnits() != QGis.UnitType.Meters:
  return
	
Which worked in Linux. Then somebody reported an issue:

https://github.com/rduivenvoorde/featuregridcreator/issues/8

Where it appears that there seems to be a different behaviour in Linux
vs Windows:

On Linux these:
QGis.Meters
QGis.UnitType.Meters
both work
But on Windows
QGis.UnitType.Meters
throws an 'no attribute' exception??

Off course to fix it for me, I can just go use 'QGIs.Meters', but I
think that it would be better if the UnitType one worked?

Anybody an idea about this? Or how to make this work?

Am I correct that for QGIS3 I should use:
qgis.core.QgsUnitTypes.DistanceMeters ?

Regards,

Richard Duivenvoorde




More information about the QGIS-Developer mailing list