Defining the map layers
We know that we want to have a total of five map layers in our application. The basemap layer will display the basemap.tif
file we just downloaded, while the track layer will use a SpatiaLite database to store and display the track data entered by the user. The remaining map layers will display temporary features held in memory.
Let's start by defining a new method in our forestTrails.py
module to initialize the SpatiaLite database we will use for the track layer:
def setupDatabase(self): cur_dir = os.path.dirname(os.path.realpath(__file__)) dbName = os.path.join(cur_dir, "data", "tracks.sqlite") if not os.path.exists(dbName): fields = QgsFields() fields.append(QgsField("id", QVariant.Int)) fields.append(QgsField("type", QVariant.String)) fields.append(QgsField("name", QVariant.String)) fields.append(QgsField("direction", QVariant.String)) fields.append(QgsField("status...