From bfcfdd2277fa2eeeefdf7aba50928f5d550bd449 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Wed, 29 Nov 2023 19:30:55 +0800 Subject: [PATCH] standartize units on send; send Degrees as None (so it can be received in Sharp connectors) --- speckle_qgis.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/speckle_qgis.py b/speckle_qgis.py index 48b27fdd..026eedc3 100644 --- a/speckle_qgis.py +++ b/speckle_qgis.py @@ -36,11 +36,12 @@ import sip from specklepy.core.api import operations -from specklepy.logging.exceptions import SpeckleException, GraphQLException +from specklepy.logging.exceptions import SpeckleException, GraphQLException, SpeckleInvalidUnitException from specklepy.core.api.models import Stream, Branch, Commit from specklepy.core.api.wrapper import StreamWrapper from specklepy.objects import Base from specklepy.objects.other import Collection +from specklepy.objects.units import get_units_from_string from specklepy.transports.server import ServerTransport from specklepy.core.api.credentials import ( Account, @@ -486,8 +487,10 @@ def onSend(self, message: str): units = str(QgsUnitTypes.encodeUnit(projectCRS.mapUnits())) self.dataStorage.latestActionUnits = units - if units is None or units == "degrees": - units = "m" + try: + units = get_units_from_string(units) + except SpeckleInvalidUnitException: + units = 'none' self.dataStorage.currentUnits = units if (