QGIS plugin integration
The QGIS plugin adds support for opening MapLibre Tile (MLT) files as QGIS vector layers. It connects QGIS file selection and map menus to the MLT decoder, then places decoded features in the project with either tile-local coordinates or map coordinates derived from a tile address.
Plugin entry points
The plugin entry point gives QGIS a factory that creates the plugin object for the active QGIS interface. QGIS then calls the plugin lifecycle methods to add or remove its user interface action. qgis/…/__init__.py and qgis/…/plugin.py
The plugin presents one action named Open MLT File(s)…. The action is available from the toolbar and from the Vector → MLT Provider menu. Its metadata declares the plugin name, its QGIS version floor, and its role as an MLT vector-file provider. qgis/…/metadata.txt
The loading lifecycle follows this path:
flowchart LR
A[QGIS loads plugin] --> B[classFactory]
B --> C[MltPlugin]
C --> D[initGui]
D --> E[Open MLT File(s)]
E --> F[Select one or more files]
F --> G[Coordinate and merge choices]
G --> H[MLT decoder]
H --> I[QGIS project layers]
C --> J[unload]
J --> K[Remove menu and toolbar action]
File loading flows
The file action sends one selected file through the single-tile flow and several selected files through the multi-tile flow. Both flows let the user cancel or skip coordinate placement before decoding starts. qgis/…/plugin.py
Single-tile loading
The single-tile flow tries to read a z/x/y tile address from the file path. The user can confirm or change the address, choose the y-axis convention, or skip geo-reference and inspect the raw tile coordinates instead. The decoded MLT layers then become QGIS project layers. qgis/…/tile_coords.py, qgis/…/plugin.py
Multi-tile loading
The multi-tile flow shows the detected address for each file in one editable table. The user can set one y-axis convention for the selection and choose whether layers with the same name should form one combined view. This supports a seamless view across a group of adjacent tiles while still allowing separate loading when needed. qgis/…/tile_coords.py, qgis/…/plugin.py
The system reports an empty result as a warning. Decode errors go to the QGIS message log and the message bar so that both the user and the QGIS log have a failure record. qgis/…/plugin.py
Tile coordinate handling
MLT vector features can use coordinates local to their tile. The plugin uses a z/x/y tile address to turn those local values into map positions when the user requests geo-referencing. qgis/…/tile_coords.py, qgis/…/loader.py
The address parser supports common file naming and directory forms:
14_8297_10749.mlt14-8297-10749.mlt14/8297/10749.mlt
The user can correct any detected value before loading. The zoom value is limited to the supported range, while the column and row values cover the tile grid at that zoom. qgis/…/tile_coords.py, qgis/…/tile_coords.py
The y-axis choice matters because TMS and XYZ use opposite origins. TMS places y=0 at the south and is the default for OpenMapTiles, MBTiles, and TileJSON sources. XYZ places y=0 at the north. The selected convention is passed into decoding so features do not appear in the wrong map location. qgis/…/tile_coords.py, qgis/…/loader.py
Skipping coordinates keeps the feature positions in raw tile space. When coordinates are supplied, the resulting QGIS layers use Web Mercator (EPSG:3857); without them, the layers have no map CRS assigned. qgis/…/loader.py
QGIS layer integration
The loader maps decoded MLT content to QGIS memory layers. Each layer keeps the MLT layer identity and its attributes, while geometry types are grouped so that a QGIS layer has one compatible geometry family. qgis/…/loader.py, qgis/…/loader.py
For one file, the plugin creates a QGIS layer for each decoded MLT layer and geometry group. For several files, the merge mode groups features by MLT layer name and geometry type before creating the project layers. This turns a tile set into a small set of continuous thematic layers instead of one layer per file. qgis/…/loader.py, qgis/…/loader.py
Change checklist
When these files or sections are changed, remember to consider these:
- Keep
classFactory, the plugin class name, and the metadata plugin name aligned so QGIS can discover the plugin and remove its menu action. - Keep the coordinate dialog's TMS choice aligned with the decoder's y-axis argument.
- Keep the multi-file coordinate map aligned with the merge path so each tile receives its own address.
- Keep the geo-referenced layer CRS decision aligned with whether coordinates were supplied.
- Keep the layer grouping rule aligned with the geometry types accepted by QGIS memory layers.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
The native mlt module is not available to QGIS's Python | No file can be decoded | Install the module for the same Python runtime that runs QGIS. |
| The file has no usable tile address and the user skips coordinates | Features load in raw tile-local space | Supply or correct z/x/y when the layer must align with a map. |
| The y-axis convention does not match the source | Features are placed at the wrong map locations | Select TMS for TMS sources and XYZ for north-origin sources. |
| The plugin metadata or plugin path is not visible to QGIS | The plugin does not appear in the plugin manager | Keep metadata.txt in the plugin directory and install that directory in the active QGIS profile. |
Key files
| File | Why to read it |
|---|---|
| qgis/…/__init__.py | Defines the QGIS plugin factory entry point. |
| qgis/…/plugin.py | Connects QGIS actions to single-file and multi-file loading flows. |
| qgis/…/tile_coords.py | Defines tile address detection and the user's coordinate choices. |
| qgis/…/loader.py | Defines how decoded MLT content becomes QGIS project layers. |
| qgis/…/metadata.txt | Declares the plugin to QGIS and states its supported product scope. |