21 Commits

Author SHA1 Message Date
cb86e30fab Fixed artifact path 2023-12-15 21:37:53 +01:00
407f543039 Use libpbf instead of pbf in Android target name 2023-12-15 21:35:49 +01:00
f24a8a47a9 Fix plugins path 2023-12-15 21:32:33 +01:00
ce7b3d9158 Use propper plugin target path 2023-12-15 21:25:38 +01:00
f064148a0f Use propper target name on Android 2023-12-15 21:21:10 +01:00
733375fb74 Fixed artifact file name 2023-12-15 17:11:06 +01:00
440f7f91a4 Added artifacts upload 2023-12-15 17:03:59 +01:00
dbcfd9b9d3 Added Google Protocol Buffers to Android build 2023-12-15 15:04:55 +01:00
672de3919b Fixed Android qmake step 2023-12-15 09:27:02 +01:00
0a696a6ab8 Added Android build workflow 2023-12-15 09:23:48 +01:00
d8a521623a Unify the code samples to use QImage 2023-12-11 11:40:18 +01:00
f5f006dc7b Fixed artifact name/path 2023-12-11 08:16:07 +01:00
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
38b6e2320b Example codes cleanup 2023-12-10 08:18:16 +01:00
6 changed files with 105 additions and 25 deletions

View File

@ -1,4 +1,4 @@
version: 2.6.{build}
version: 3.0.{build}
configuration:
- Release
@ -26,7 +26,7 @@ build_script:
nmake release
artifacts:
- path: release\pbf2.dll
- path: release\pbf3.dll
cache:
- C:\tools\vcpkg\installed\

54
.github/workflows/android.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Android
on:
push:
branches:
- master
jobs:
build:
name: QtPBFImagePlugin
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install protobuf compiler
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler
- name: set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Run sdkmanager update
run: ${ANDROID_HOME}/tools/bin/sdkmanager --update
- name: Install android platform, platform-tools, build-tools and ndk
run: ${ANDROID_HOME}/tools/bin/sdkmanager --install "cmdline-tools;latest" "platform-tools" "platforms;android-33" "build-tools;33.0.0" "ndk;23.1.7779620"
- name: Setup NDK path
run: echo "ANDROID_NDK_ROOT=${ANDROID_HOME}/ndk/23.1.7779620/" >> $GITHUB_ENV
- name: Install Qt (Desktop)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '6.4.0'
- name: Install Qt (Android)
uses: jurplel/install-qt-action@v3
with:
aqtversion: '==3.1.*'
version: '6.4.0'
target: 'android'
arch: 'android_arm64_v8a'
- name: Install Android Google Protocol Buffers
run: git clone https://github.com/tumic0/android_protobuf.git
- name: Configure build
run: qmake pbfplugin.pro PROTOBUF=android_protobuf
- name: Build project
run: make -j2
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: libplugins_imageformats_libpbf_arm64-v8a.so
path: plugins/libpbf/libplugins_imageformats_libpbf_arm64-v8a.so

View File

@ -18,24 +18,39 @@ to fit the styles and available data (OpenMapTiles, Mapbox tiles).
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
parameter of the QImage constructor or the *QImage::loadFromData()* or
*QPixmap::loadFromData()* functions. The zoom number is passed as ASCII string
to the functions:
```cpp
QPixmap pm;
pm.loadFromData(tileData, QString::number(zoom).toLatin1());
QImage img;
img.loadFromData(data, QByteArray::number(zoom));
```
The plugin supports vector scaling using QImageReader's setScaledSize() method,
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
QImageReader reader(file, QString::number(zoom).toLatin1());
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
QImage img;
QByteArray fmt(QByteArray::number(zoom) + ';' + QByteArray::number(overzoom));
img.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)
@ -39,9 +39,12 @@ RESOURCES += pbfplugin.qrc
DEFINES += QT_NO_DEPRECATED_WARNINGS
unix:!macx{
unix:!macx:!android {
LIBS += -lprotobuf-lite \
-lz
target.path += $$[QT_INSTALL_PLUGINS]/imageformats
INSTALLS += target
}
win32 {
INCLUDEPATH += $$PROTOBUF/include \
@ -58,6 +61,12 @@ macx {
LIBS += $$PROTOBUF/lib/libprotobuf-lite.a \
-lz
}
android {
INCLUDEPATH += $$PROTOBUF/include
LIBS += $$PROTOBUF/$$ANDROID_TARGET_ARCH/libprotobuf-lite.a \
-lz
target.path += $$[QT_INSTALL_PLUGINS]/imageformats
INSTALLS += target
top_builddir=$$shadowed($$PWD)
DESTDIR = $$top_builddir/plugins/libpbf
TARGET = $$qt5LibraryTarget(libpbf, "plugins/imageformats/")
}

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"
},
@ -4059,4 +4058,4 @@
}
],
"id": "osm-liberty"
}
}