Compare commits

...

8 Commits

Author SHA1 Message Date
c86eb7bac2 Increase major version due to the API change
The API should be backward compatible but the overzoom extension should rather
be promoted with a major version number change.
2023-12-10 18:14:54 +01:00
3ef6c55d20
Code samples cleanup 2023-12-10 17:46:39 +01:00
98933deb0e
Added HiDPI and Overzoom sections 2023-12-10 15:53:19 +01:00
6e1bc09d62
Cosmetics 2023-12-10 15:19:35 +01:00
ea98da4a74 Added overzoom description 2023-12-10 15:16:23 +01:00
8261ee2e79 Keep the overzoom and scaled size separated 2023-12-10 15:12:13 +01:00
d5c315efbe Version++ 2023-12-10 14:44:36 +01:00
39ffdaf616 Added support for overzoom 2023-12-10 14:43:07 +01:00
5 changed files with 33 additions and 16 deletions

View File

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

View File

@ -23,19 +23,34 @@ QPixmap::loadFromData() functions. The zoom number is passed as ASCII string
to the functions:
```cpp
QPixmap pm;
pm.loadFromData(tileData, QByteArray::number(zoom));
pm.loadFromData(data, 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,
so when used like in the following example:
```cpp
QImage img;
QImageReader reader(file, QByteArray::number(zoom));
reader.setScaledSize(QSize(1024, 1024));
reader.read(&image);
reader.read(&img);
```
you will get 1024x1024px tiles with a pixel ratio of 2 (= HiDPI tiles).
For a sample code see the [pbf2png](https://github.com/tumic0/pbf2png)
conversion utility.
### Overzoom
Since version 3 of the plugin tile overzoom is supported. If you set *format*
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
The map style is loaded from the

View File

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

View File

@ -79,16 +79,19 @@ bool PBFHandler::read(QImage *image)
return false;
}
bool ok;
int zoom = format().toInt(&ok);
QList<QByteArray> list(format().split(';'));
int zoom = list.size() ? list.first().toInt() : 0;
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);
Tile tile(image, ok ? zoom : -1, scale);
Tile tile(image, zoom, scale);
_style->render(data, tile);

View File

@ -2265,7 +2265,6 @@
"source": "openmaptiles",
"source-layer": "building",
"minzoom": 13,
"maxzoom": 14,
"layout": {
"visibility": "visible"
},