O'Reilly logo

Building Mapping Applications with QGIS by Erik Westra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Edit Track map tool

Our next task is to implement the Edit Track action. To do this, we'll take EditTool we defined in Chapter 7, Selecting and Editing Features in a PyQGIS Application, and modify it to work specifically with tracks. Fortunately, we only need to support LineString geometries and can make use of our mixin class, which will simplify the implementation of this new map tool.

Let's start by adding our new class definition to the mapTools.py module, along with the __init__() method:

class EditTrackTool(QgsMapTool, MapToolMixin): def __init__(self, canvas, layer, onTrackEdited): QgsMapTool.__init__(self, canvas) self.onTrackEdited = onTrackEdited self.dragging = False self.feature = None self.vertex = None self.setLayer(layer) self.setCursor(Qt.CrossCursor) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required