From 86b98064fccd1ce26b1c3308afbf61543883b1ec Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Wed, 29 Mar 2023 17:49:10 +0200 Subject: [PATCH 1/2] fix: error on QGIS 3.30.0 the geometry type for the QgsRubberBand used in the routing ui dialog was previously resolved from boolean False to int 0. As the base type for the QgsWkbTypes changed from int to enum.IntEnum, the transformation failed. Now named arguments and the correct QgsWkbType are used when creating a QgsRubberBand. --- ORStools/utils/maptools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ORStools/utils/maptools.py b/ORStools/utils/maptools.py index ac3e088c..8fc7e579 100644 --- a/ORStools/utils/maptools.py +++ b/ORStools/utils/maptools.py @@ -48,7 +48,7 @@ def __init__(self, canvas): self.canvas = canvas QgsMapToolEmitPoint.__init__(self, self.canvas) - self.rubberBand = QgsRubberBand(self.canvas, False) + self.rubberBand = QgsRubberBand(mapCanvas=self.canvas, geometryType=QgsWkbTypes.LineGeometry) self.rubberBand.setStrokeColor(QColor(DEFAULT_COLOR)) self.rubberBand.setWidth(3) @@ -61,7 +61,7 @@ def reset(self): """reset rubber band and captured points.""" self.points = [] - self.rubberBand.reset(QgsWkbTypes.LineGeometry) + self.rubberBand.reset(geometryType=QgsWkbTypes.LineGeometry) pointDrawn = pyqtSignal(["QgsPointXY", "int"]) def canvasReleaseEvent(self, e): @@ -75,7 +75,7 @@ def canvasReleaseEvent(self, e): def showLine(self): """Builds rubber band from all points and adds it to the map canvas.""" - self.rubberBand.reset(QgsWkbTypes.LineGeometry) + self.rubberBand.reset(geometryType=QgsWkbTypes.LineGeometry) for point in self.points: if point == self.points[-1]: self.rubberBand.addPoint(point, True) From 3f3040af2bbf6753e39f9e4074dd258ce8ce7139 Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Wed, 29 Mar 2023 17:52:03 +0200 Subject: [PATCH 2/2] style: remove unused commented code - reformat file --- ORStools/utils/maptools.py | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/ORStools/utils/maptools.py b/ORStools/utils/maptools.py index 8fc7e579..ce9f94ef 100644 --- a/ORStools/utils/maptools.py +++ b/ORStools/utils/maptools.py @@ -64,6 +64,7 @@ def reset(self): self.rubberBand.reset(geometryType=QgsWkbTypes.LineGeometry) pointDrawn = pyqtSignal(["QgsPointXY", "int"]) + def canvasReleaseEvent(self, e): """Add marker to canvas and shows line.""" new_point = self.toMapCoordinates(e.pos()) @@ -94,39 +95,3 @@ def canvasDoubleClickEvent(self, e): def deactivate(self): super(LineTool, self).deactivate() self.deactivated.emit() - - -# class PointTool(QgsMapToolEmitPoint): -# """Point Map tool to capture mapped coordinates.""" -# -# def __init__(self, canvas, button): -# """ -# :param canvas: current map canvas -# :type: QgsMapCanvas -# -# :param button: name of 'Map!' button pressed. -# :type button: str -# """ -# -# QgsMapToolEmitPoint.__init__(self, canvas) -# self.canvas = canvas -# self.button = button -# self.cursor = QCursor(QPixmap(RESOURCE_PREFIX + 'icon_locate.png').scaledToWidth(48), 24, 24) -# -# canvasClicked = pyqtSignal(['QgsPointXY', 'QString']) -# def canvasReleaseEvent(self, event): -# #Get the click and emit a transformed point -# -# crsSrc = self.canvas.mapSettings().destinationCrs() -# -# point_oldcrs = event.mapPoint() -# -# xform = transform.transformToWGS(crsSrc) -# point_newcrs = xform.transform(point_oldcrs) -# -# QApplication.restoreOverrideCursor() -# -# self.canvasClicked.emit(point_newcrs, self.button) -# -# def activate(self): -# QApplication.setOverrideCursor(self.cursor)