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

Nyall Dawson nyall.dawson at gmail.com
Tue Feb 19 14:35:02 PST 2019


On Mon, 18 Feb 2019 at 16:59, Richard Duivenvoorde <rdmailings at duif.net> wrote:
>
> 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:

It doesn't work on Linux for me (Fedora 29). I think Qgis.Meters is
safest, and would always use that.

Nyall

>
> 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
>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list