mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-30 22:51:17 +01:00
Compare commits
8 Commits
38b6e2320b
...
c86eb7bac2
Author | SHA1 | Date | |
---|---|---|---|
c86eb7bac2 | |||
3ef6c55d20 | |||
98933deb0e | |||
6e1bc09d62 | |||
ea98da4a74 | |||
8261ee2e79 | |||
d5c315efbe | |||
39ffdaf616 |
@ -1,4 +1,4 @@
|
|||||||
version: 2.6.{build}
|
version: 3.0.{build}
|
||||||
|
|
||||||
configuration:
|
configuration:
|
||||||
- Release
|
- Release
|
||||||
|
23
README.md
23
README.md
@ -23,19 +23,34 @@ 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(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,
|
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(&image);
|
reader.read(&img);
|
||||||
```
|
```
|
||||||
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).
|
||||||
|
|
||||||
For a sample code see the [pbf2png](https://github.com/tumic0/pbf2png)
|
### Overzoom
|
||||||
conversion utility.
|
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
|
## Styles
|
||||||
The map style is loaded from the
|
The map style is loaded from the
|
||||||
|
@ -2,7 +2,7 @@ TARGET = pbf
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += plugin
|
CONFIG += plugin
|
||||||
QT += gui
|
QT += gui
|
||||||
VERSION = 2.6
|
VERSION = 3.0
|
||||||
|
|
||||||
PROTOS = protobuf/vector_tile.proto
|
PROTOS = protobuf/vector_tile.proto
|
||||||
include(protobuf/vector_tile.pri)
|
include(protobuf/vector_tile.pri)
|
||||||
|
@ -79,16 +79,19 @@ bool PBFHandler::read(QImage *image)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok;
|
QList<QByteArray> list(format().split(';'));
|
||||||
int zoom = format().toInt(&ok);
|
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);
|
*image = QImage(size, QImage::Format_ARGB32_Premultiplied);
|
||||||
Tile tile(image, ok ? zoom : -1, scale);
|
Tile tile(image, zoom, scale);
|
||||||
|
|
||||||
_style->render(data, tile);
|
_style->render(data, tile);
|
||||||
|
|
||||||
|
@ -2265,7 +2265,6 @@
|
|||||||
"source": "openmaptiles",
|
"source": "openmaptiles",
|
||||||
"source-layer": "building",
|
"source-layer": "building",
|
||||||
"minzoom": 13,
|
"minzoom": 13,
|
||||||
"maxzoom": 14,
|
|
||||||
"layout": {
|
"layout": {
|
||||||
"visibility": "visible"
|
"visibility": "visible"
|
||||||
},
|
},
|
||||||
@ -4059,4 +4058,4 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"id": "osm-liberty"
|
"id": "osm-liberty"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user