Compare commits

..

No commits in common. "c86eb7bac2b8a77b858045e3a7bb07b8398a30d6" and "38b6e2320b3403b32c90e651ea36204bdf13b739" have entirely different histories.

5 changed files with 16 additions and 33 deletions

View File

@ -1,4 +1,4 @@
version: 3.0.{build} version: 2.6.{build}
configuration: configuration:
- Release - Release

View File

@ -23,34 +23,19 @@ QPixmap::loadFromData() functions. The zoom number is passed as ASCII string
to the functions: to the functions:
```cpp ```cpp
QPixmap pm; QPixmap pm;
pm.loadFromData(data, QByteArray::number(zoom)); pm.loadFromData(tileData, QByteArray::number(zoom));
``` ```
For a complete code sample see the [pbf2png](https://github.com/tumic0/pbf2png)
conversion utility.
### HiDPI
The plugin supports vector scaling using QImageReader's setScaledSize() method, The plugin supports vector scaling using QImageReader's setScaledSize() method,
so when used like in the following example: so when used like in the following example:
```cpp ```cpp
QImage img;
QImageReader reader(file, QByteArray::number(zoom)); QImageReader reader(file, QByteArray::number(zoom));
reader.setScaledSize(QSize(1024, 1024)); reader.setScaledSize(QSize(1024, 1024));
reader.read(&img); reader.read(&image);
``` ```
you will get 1024x1024px tiles with a pixel ratio of 2 (= HiDPI tiles). you will get 1024x1024px tiles with a pixel ratio of 2 (= HiDPI tiles).
### Overzoom For a sample code see the [pbf2png](https://github.com/tumic0/pbf2png)
Since version 3 of the plugin tile overzoom is supported. If you set *format* conversion utility.
to `$zoom;$overzoom`:
```cpp
QPixmap pm;
QByteArray fmt(QByteArray::number(zoom) + ';' + QByteArray::number(overzoom));
pm.loadFromData(data, fmt);
```
you will get (512<<overzoom)x(512<<overzoom)px tiles with a pixel ratio of 1.
When overzoom is combined with setScaledSize(), the base size is the overzoomed
tile size.
## Styles ## Styles
The map style is loaded from the The map style is loaded from the

View File

@ -2,7 +2,7 @@ TARGET = pbf
TEMPLATE = lib TEMPLATE = lib
CONFIG += plugin CONFIG += plugin
QT += gui QT += gui
VERSION = 3.0 VERSION = 2.6
PROTOS = protobuf/vector_tile.proto PROTOS = protobuf/vector_tile.proto
include(protobuf/vector_tile.pri) include(protobuf/vector_tile.pri)

View File

@ -79,19 +79,16 @@ bool PBFHandler::read(QImage *image)
return false; return false;
} }
QList<QByteArray> list(format().split(';')); bool ok;
int zoom = list.size() ? list.first().toInt() : 0; int zoom = format().toInt(&ok);
int overzoom = (list.size() > 1) ? list.at(1).toInt() : 0;
QSize scaledSize(_scaledSize.isValid()
? _scaledSize : QSize(TILE_SIZE, TILE_SIZE));
QSize size(scaledSize.width()<<overzoom,
scaledSize.height()<<overzoom);
QPointF scale((qreal)scaledSize.width() / TILE_SIZE,
(qreal)scaledSize.height() / TILE_SIZE);
QSize size = _scaledSize.isValid()
? _scaledSize : QSize(TILE_SIZE, TILE_SIZE);
QPointF scale = _scaledSize.isValid()
? QPointF((qreal)_scaledSize.width() / TILE_SIZE,
(qreal)_scaledSize.height() / TILE_SIZE) : QPointF(1.0, 1.0);
*image = QImage(size, QImage::Format_ARGB32_Premultiplied); *image = QImage(size, QImage::Format_ARGB32_Premultiplied);
Tile tile(image, zoom, scale); Tile tile(image, ok ? zoom : -1, scale);
_style->render(data, tile); _style->render(data, tile);

View File

@ -2265,6 +2265,7 @@
"source": "openmaptiles", "source": "openmaptiles",
"source-layer": "building", "source-layer": "building",
"minzoom": 13, "minzoom": 13,
"maxzoom": 14,
"layout": { "layout": {
"visibility": "visible" "visibility": "visible"
}, },
@ -4058,4 +4059,4 @@
} }
], ],
"id": "osm-liberty" "id": "osm-liberty"
} }