Qt image plugin for displaying Mapbox vector tiles
Go to file
2018-11-07 22:04:11 +01:00
protobuf Initial version 2018-10-29 00:11:23 +01:00
src Improved font matching logic 2018-11-07 22:04:11 +01:00
style Include default style in resources + use application specific style load path 2018-11-01 18:15:05 +01:00
LICENSE Create LICENSE 2018-10-29 01:17:35 +01:00
pbfplugin.json Initial version 2018-10-29 00:11:23 +01:00
pbfplugin.pro Added font properties handling 2018-11-06 22:35:30 +01:00
pbfplugin.qrc Include default style in resources + use application specific style load path 2018-11-01 18:15:05 +01:00
README.md Fixed copy&paste error 2018-11-06 01:45:26 +01:00

QtPBFImagePlugin

Qt image plugin for displaying Mapbox vector tiles

Description

QtPBFImagePlugin is a Qt image plugin that enables applications capable of displaying raster MBTiles maps to also display PBF vector tiles without (almost, see usage) any application modifications.

Standard Mapbox GL Styles are used for styling the maps. Most style features used by Maputnik are supported. The style is loaded from the $AppDataLocation/style/style.json file on plugin load. A default fallback style (Klokantech-basic) for OpenMapTiles is part of the plugin.

Usage

Due to a major design flaw in the Mapbox vector tiles specification - the zoom is not part of the PBF data - the plugin can not be used "as is", but passing the zoom level is necessary. This is done by exploiting the optional format parameter of the QImage constructor or the QImage::fromData() or QPixmap::loadFromData() functions. The zoom number is passed as ASCII string to the functions:

QPixmap pm;
pm.loadFromData(tileData, QString::number(zoom).toLatin1());

Build

Requirements

  • Qt 5
  • Google Protocol Buffers (protobuf-lite)
  • Zlib

Build steps

Linux

qmake pbfplugin.pro
make

Windows

qmake PROTOBUF=path/to/protobuf ZLIB=path/to/zlib pbfplugin.pro
nmake

Install

Copy the plugin to the system Qt image plugins path to make it work. You may also set the QT_PLUGIN_PATH system variable before starting the application.

Limitations

As the plugin only has isolated info about a single tile image, texts overlapping to neighbour tiles can not be displayed or their overlapping can not be avoided (the plugin uses the first approach). This is a principal constraint that can't be evaded.

Status

A picture is worth a thousand words. Data and styles from https://openmaptiles.org.

OSM-liberty

osm-liberty 2 osm-liberty 5 osm-liberty 9 osm-liberty 11 osm-liberty 14

Klokantech-basic

klokantech-basic 2 klokantech-basic 4 klokantech-basic 9 klokantech-basic 13 klokantech-basic 14