The Set Start Point and Set End Point actions
The Set Start Point and Set End Point toolbar actions allow the user to set the start and end points in order to calculate the shortest path between these two points. To implement these actions, we're going to need a new map tool that lets the user click on a track vertex to select the starting or ending points.
Note
By positioning the start point and the end point on vertices, we guarantee that the points lie on a track's LineString. We could theoretically be more sophisticated and snap the starting and ending points to anywhere along a track segment, but that's more work, and we're trying to keep the implementation simple.
Go back to the mapTools.py
module and add the following class definition to this file:
class SelectVertexTool(QgsMapTool, MapToolMixin): def __init__(self, canvas, trackLayer, onVertexSelected): QgsMapTool.__init__(self, canvas) self.onVertexSelected = onVertexSelected self.setLayer(trackLayer) ...