Skip to content

Commit

Permalink
Merge pull request #179 from GIScience/fix/#117-explicit-geometry-type
Browse files Browse the repository at this point in the history
Fix/#117 explicit geometry type
  • Loading branch information
TheGreatRefrigerator authored Mar 30, 2023
2 parents 8506ba9 + 3f3040a commit 9bc8740
Showing 1 changed file with 4 additions and 39 deletions.
43 changes: 4 additions & 39 deletions ORStools/utils/maptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -61,9 +61,10 @@ 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):
"""Add marker to canvas and shows line."""
new_point = self.toMapCoordinates(e.pos())
Expand All @@ -75,7 +76,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)
Expand All @@ -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)

0 comments on commit 9bc8740

Please sign in to comment.