maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [SFOS] Mapbox GL Native QML plugin (https://talk.maemo.org/showthread.php?t=99953)

rinigus 2017-10-12 16:52

Mapbox GL Native QML plugin
 
2 Attachment(s)
This is an announcement of Mapbox GL Native (https://github.com/mapbox/mapbox-gl-native) QML plugin that can be used to display and interact with the maps in QML application. This is a fast, OpenGL accelerated, high-quality rendering-providing map component that should be easy to use for app developers.

It is recommended to use this as QML plugin and use it through QML interface. It is possible to use the developed plugin by incorporating it on C++ source level, but then you will need newer gcc (>=4.9). When using QML interface, older gcc provided with SFOS is sufficient.

I am starting this thread to provide simple to find information on this QML plugin and to mark the readiness of the plugin for general development of map applications. This thread could be considered as a continuation of "brainstorm" thread https://talk.maemo.org/showthread.php?t=93358 and the step towards implementation of the original brainstorm request.

Project GitHub page: https://github.com/rinigus/mapbox-gl-qml

Documentation: https://github.com/rinigus/mapbox-gl.../master/api.md

License: LGPL3. For the gesture area interaction component, MIT.

Requirements: Qt >= 5.6

SFOS packaging:

OBS: https://build.merproject.org/package...s/mapboxgl-qml

OpenRepos: https://openrepos.net/content/rinigu...indings-qt-qml

C++ development library

QMapboxGL for C++ development is packaged using https://github.com/rinigus/pkg-mapbox-gl-native and available at https://build.merproject.org/package...maps/qmapboxgl.

Example code

As an example, see a QML item that would show a map that can be zoomed and panned

Code:

import QtQuick 2.0
import Sailfish.Silica 1.0
import MapboxMap 1.0
import QtPositioning 5.3

Page
{
    id: page

    MapboxMap {
        id: map
        anchors.fill: parent

        center: QtPositioning.coordinate(60.170448, 24.942046)
        zoomLevel: 4.0
        minimumZoomLevel: 0
        maximumZoomLevel: 20
        pixelRatio: 3.0

        accessToken: "INSERT_MAPBOX_ACCESS_TOKEN_HERE"
        cacheDatabaseMaximalSize: 20*1024*1024
        cacheDatabasePath: "/tmp/mbgl-cache.db"

        styleUrl: "mapbox://styles/mapbox/outdoors-v10"

        MapboxMapGestureArea {
            map: map
        }
    }
}

Donations: https://liberapay.com/rinigus

Current issues

Issues are followed on GitHub project page at https://github.com/rinigus/mapbox-gl-qml/issues

Current main issue is crashes on Jolla 1 and Photon Q.

Obligatory screenshots

Poor Maps prototype showing
  • a road found by routing component incorporated into the map under the layer with the labels
  • POIs drawn on the map with the labels and interactive QML dialog following geographical location of POI
.

rinigus 2017-10-13 10:04

Re: Mapbox GL Native QML plugin
 
To test whether very primitive style helps against crashes on Jolla 1, maybe someone could test QML-only app? For that:

* Install https://build.merproject.org/package...s/mapboxgl-qml (download from http://repo.merproject.org/obs/home:...mv7hl/armv7hl/)

* Get QML-only demo at https://github.com/rinigus/mapbox-de...aster/qml-only . You would need the both QML files in this directory

* run
Code:

qmlscene mapbox-gl-qml.qml
Zeta has reported absence of crashes in C++ compiled app with dynamically linked libstdc++ (https://talk.maemo.org/showpost.php?...&postcount=125) and crashing on start with the statically linked libstdc++ (https://talk.maemo.org/showpost.php?...&postcount=123).

At present, QML plugin is statically linked with newer stdc++. So, I wonder if that would work on J1. On other devices I don't expect any problems (except Photon Q).

Zeta 2017-10-13 20:25

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1536658)
To test whether very primitive style helps against crashes on Jolla 1, maybe someone could test QML-only app? For that:

* Install https://build.merproject.org/package...s/mapboxgl-qml (download from http://repo.merproject.org/obs/home:...mv7hl/armv7hl/)

* Get QML-only demo at https://github.com/rinigus/mapbox-de...aster/qml-only . You would need the both QML files in this directory

* run
Code:

qmlscene mapbox-gl-qml.qml
Zeta has reported absence of crashes in C++ compiled app with dynamically linked libstdc++ (https://talk.maemo.org/showpost.php?...&postcount=125) and crashing on start with the statically linked libstdc++ (https://talk.maemo.org/showpost.php?...&postcount=123).

At present, QML plugin is statically linked with newer stdc++. So, I wonder if that would work on J1. On other devices I don't expect any problems (except Photon Q).

I tested with this new simple QML app, and first comment is that it looks great ! It is fast (no visible lags, adapts quite well to the zoom level), so a big applause once more to have been able to provide something like this to the Sailfish community.

Now for the tests itself:
* Played with it for quite some time with this basic red theme, and didn't notice anything wrong. I moved/zoomed around as fast as possible (in the range of "normal use" to "crazy as hell") without any crash.
* Seeing at it looks like it was working well, I edited the QML to remove the "jsonStyle" part, to get back to the standard map (it is really easy to do, good job!), and I got it working for quite some time. As a lot is now displayed, it is fun to zoom/move/unzoom/move somewhere else. At the end, I got another crash (segmentation fault). it can work from 10 to 30 seconds before the crash when torturing it (from world to street level and back to another country streets in seconds). Using it a bit less fast (looking around a single city), it can last close to 1 minutes. And if only zooming in a park and not touching it, except to keep it from shutting screen, then it seems to run forever (I stopped after 7 minutes, by moving around as fast as possible and it then crashed).

So at this end, the way it is used impacts the time it takes to crash, and the simple red theme, if it could finally crash, does it after a long time of torturing it.
Likely some resources exhaustion (network, ram, gpu, handles of something ?), some timing issues (the more it is to do, the more likely a collision can occur), memory/stack corruption, or a specific program path that leads to the crash when a specific item has to be computed/drawn ? Nothing easy to find so...
The main differences between the Jolla1 and the other are mainly the gpu driver, and some more limited hardware. There are also different kernel and the like.

With full map, the crash can appear anywhere it seems. gdb output is:
Code:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x4816e3a0 (LWP 5624)]
0x4553db2c in mbgl::VectorTileLayer::getFeature(unsigned int) const () from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
(gdb) bt full
#0  0x4553db2c in mbgl::VectorTileLayer::getFeature(unsigned int) const () from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
No symbol table info available.
#1  0x454b0290 in mbgl::GeometryTileWorker::redoLayout() () from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
No symbol table info available.
#2  0x4acb1b60 in ?? ()
Cannot access memory at address 0x0
No symbol table info available.
#3  0x4acb1b60 in ?? ()
Cannot access memory at address 0x0
No symbol table info available.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Or :
Code:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x481643a0 (LWP 5759)]
0x40edb734 in malloc_consolidate (av=av@entry=0x44d00010) at malloc.c:4165
4165        malloc.c: No such file or directory.
(gdb) bt
#0  0x40edb734 in malloc_consolidate (av=av@entry=0x44d00010) at malloc.c:4165
#1  0x40edd13e in _int_malloc (av=av@entry=0x44d00010, bytes=bytes@entry=512) at malloc.c:3423
#2  0x40ede77c in __GI___libc_malloc (bytes=512) at malloc.c:2891
#3  0x40d8d7a8 in operator new(unsigned int) () from /usr/lib/libstdc++.so.6
#4  0x456d0716 in void std::vector<protozero::data_view, std::allocator<protozero::data_view> >::_M_emplace_back_aux<protozero::data_view>(protozero::data_view&&) ()
  from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
#5  0x456d0a3a in mapbox::vector_tile::layer::layer(protozero::data_view const&) () from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
#6  0x456cedf6 in mbgl::VectorTileLayer::VectorTileLayer(std::shared_ptr<std::string const>, protozero::data_view const&) () from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
#7  0x456cef50 in mbgl::VectorTileData::getLayer(std::string const&) const () from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
#8  0x4563eeea in mbgl::GeometryTileWorker::redoLayout() () from /usr/lib/qt5/qml/MapboxMap/libqmlmapboxglplugin.so
#9  0x482973c0 in ?? ()
Cannot access memory at address 0x0


tmi 2017-10-13 21:12

Re: Mapbox GL Native QML plugin
 
Zeta's testing was way more complete than mine. I only played with the red theme a couple of minutes and it seemed fluent until exit

The output:
Code:

[nemo@Sailfish mapbox]$ qmlscene mapbox-gl-qml.qml
[D] unknown:0 - Using Wayland-EGL
[D] onCompleted:334 - Warning: specifying an object instance for initialPage is sub-optimal - prefer to use a Component
[ERROR] {QSGRenderThread}[Style]: Failed to load sprite: HTTP status code 404
[ERROR] {QSGRenderThread}[Style]: Failed to load sprite: HTTP status code 404
[nemo@Sailfish mapbox]$


rinigus 2017-10-14 07:03

Re: Mapbox GL Native QML plugin
 
@Zeta and @tmi: thank you very much for testing!

Its indeed seems to be hard to debug this one. Since there were stability issues with earlier tests using static stdc++, I'll look into how to provide dynamic build for the plugin. Maybe it will help, although hard to tell. After testing dynamic builds (if I manage to make them), we could ask give a proper feedback to Mapbox GL developers for further tips.

Meanwhile I tested the MapboxMap using raster tile sources and it worked quite well. The small blurring that I saw on the desktop was much harder to spot on hiDPI device (you have to really look for it). While I am sure that vector tiles would be preferred, already now the MapboxMap should allow you to mix the sources as you wish.

rinigus 2017-10-14 20:06

Re: Mapbox GL Native QML plugin
 
Zeta, just in case if the shared stdc++ is better, please try to run with QML plugin from https://build.merproject.org/package...g/mapboxgl-qml

This version is compiled with shared libstdc++ with the corresponding library installed at /usr/lib/qt5/qml/MapboxMap . Now before I'll be breaking my neck and figuring out how to explain to qmlscene that the libs from that directory have a preference, please run with

Code:

LD_LIBRARY_PATH=/usr/lib/qt5/qml/MapboxMap qmlscene mapbox-gl-qml.qml
Try to see if you could make it crash with the red and full styles, please.

If its the same result as with the statically linked stdc++, I'll prefer to use that version. Then, before moving back to the statically linked plugin, please uninstall plugin first. Otherwise you'll leave libstdc++ in the plugin directory.

Zeta 2017-10-15 14:22

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1536813)
Zeta, just in case if the shared stdc++ is better, please try to run with QML plugin from https://build.merproject.org/package...g/mapboxgl-qml

This version is compiled with shared libstdc++ with the corresponding library installed at /usr/lib/qt5/qml/MapboxMap . Now before I'll be breaking my neck and figuring out how to explain to qmlscene that the libs from that directory have a preference, please run with

Code:

LD_LIBRARY_PATH=/usr/lib/qt5/qml/MapboxMap qmlscene mapbox-gl-qml.qml
Try to see if you could make it crash with the red and full styles, please.

If its the same result as with the statically linked stdc++, I'll prefer to use that version. Then, before moving back to the statically linked plugin, please uninstall plugin first. Otherwise you'll leave libstdc++ in the plugin directory.

It is like the previous tests:
* Works perfectly with red map
* Crash when zooming in/moving fast the normal map

However, that must be the first useful error message I got since the start of those tests:
Code:

[nemo@Sailfish test]$ LD_LIBRARY_PATH=/usr/lib/qt5/qml/MapboxMap /usr/lib/qt5/bin/qmlscene mapbox-gl-qml.qml
[D] unknown:0 - Using Wayland-EGL
[W] unknown:0 - Could not find any zN.M subdirs!
[W] unknown:0 - Theme dir "/usr/share/themes/jolla-ambient/meegotouch/z1.0/" does not exist
[D] onCompleted:334 - Warning: specifying an object instance for initialPage is sub-optimal - prefer to use a Component
terminate called after throwing an instance of 'mbgl::gl::Error'
  what():  glDrawElements( static_cast<GLenum>(primitiveType), static_cast<GLsizei>(indexLength), GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(sizeof(uint16_t) * indexOffset)): Error GL_OUT_OF_MEMORY at src/mbgl/gl/context.cpp:681
Aborted

So, it looks like we got it right from the beginning : error is related to the GPU, probably because it is too weak to handle everything in its memory (GL_OUT_OF_MEMORY)...

Anyone knows a command to follow GPU memory available/used ?

rinigus 2017-10-15 14:51

Re: Mapbox GL Native QML plugin
 
Zeta, great catch!!!! At least, we could ask for advice now from Mapbox GL developers. Do you want to submit your findings into the issue https://github.com/mapbox/mapbox-gl-native/issues/10029 ?

But would be great to know how to follow GPU memory state, indeed...

Zeta 2017-10-15 15:43

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1536876)
Do you want to submit your findings into the issue https://github.com/mapbox/mapbox-gl-native/issues/10029 ?

It's done !

rinigus 2017-10-15 20:18

Re: Mapbox GL Native QML plugin
 
I have extended cache database handling API to support the expected scenario:
  • cache stored in application .cache folder
  • cache size limit set by user in settings

In practice, when defining MapboxMap, its sufficient to set

Code:

    cacheDatabaseStoreSettings: true
    cacheDatabaseDefaultPath: true

and define cacheDatabaseMaximalSize during a run of an application to the value you would want to. This value will be applied on the next start of the application (cache settings are applied only on start by QMapboxGL).

API documentation has been updated accordingly.

I am planning to start working on offline support for these vector tiles via OSM Scout Server. When issues/requests/ideas will come, I'll work on them as well.

Let me know in advance if you wish to use the plugin in practice, I'll upload it into OpenRepos when needed. There is no point in uploading it too early - there were changes almost daily so far in plugin code :)

rinigus 2017-10-17 09:29

Re: Mapbox GL Native QML plugin
 
As you can see at the end of https://github.com/mapbox/mapbox-gl-native/issues/10029 , Mapbox GL developer suggested that MapboxGL hits memory bottleneck on Jolla 1.

Unfortunately, the callbacks designed to help with the debugging of openGL errors were introduced only in the latest standard, not available for J1 either.

So, if you needed an excuse to go out and get a newer device for SFOS - here it is.

Zeta 2017-10-17 21:24

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1537068)
As you can see at the end of https://github.com/mapbox/mapbox-gl-native/issues/10029 , Mapbox GL developer suggested that MapboxGL hits memory bottleneck on Jolla 1.

Alright. At least we tried ! Thanks for the time you spent on this.

Quote:

Originally Posted by rinigus (Post 1537068)
Unfortunately, the callbacks designed to help with the debugging of openGL errors were introduced only in the latest standard, not available for J1 either.

Just to understand, what do you call a "standard" in this context ? A version of the mapbox GL renderer ? Of the Qt API for Mapbox GL ? Something else ?

rinigus 2017-10-18 05:45

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by Zeta (Post 1537133)
Alright. At least we tried ! Thanks for the time you spent on this.

Just to understand, what do you call a "standard" in this context ? A version of the mapbox GL renderer ? Of the Qt API for Mapbox GL ? Something else ?

I looked a bit into it and this is a what I found regarding opnGL debugging https://blog.nobel-joergensen.com/20...ng-glgeterror/

To debug properly, we need OpenGL ES API Version 3.2 and use https://www.khronos.org/registry/Ope...Callback.xhtml (blog post continuation)

Alternatively, you could use glGetError, as explained in the blog post.

As for API versions, OpenGL ES 3.0 corresponds to Android 4.3 (https://en.wikipedia.org/wiki/OpenGL_ES)

So, out of luck here as well on older devices like J1

Zeta 2017-10-18 21:59

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1537162)
I looked a bit into it and this is a what I found regarding opnGL debugging https://blog.nobel-joergensen.com/20...ng-glgeterror/

To debug properly, we need OpenGL ES API Version 3.2 and use https://www.khronos.org/registry/Ope...Callback.xhtml (blog post continuation)

Alternatively, you could use glGetError, as explained in the blog post.

As for API versions, OpenGL ES 3.0 corresponds to Android 4.3 (https://en.wikipedia.org/wiki/OpenGL_ES)

So, out of luck here as well on older devices like J1

Thanks for the answer, I understand now that you were talking of the OpenGL standard.
Interesting to see that debugging is a first class citizen on the newer versions.

rinigus 2017-11-27 07:39

Re: Mapbox GL Native QML plugin
 
Short update after 1.5 month of silence:

I have been working all this time on importing the planet into Mapbox GL format to offer offline support for this widget. Turned out to be a major undertaking due to the lack or scattered documentation, rather sub-optimal import tools and large CPU requirements. After struggling with the available tools/scripts, I ended up writing my own on the basis of OpenMapTiles schema: https://github.com/rinigus/mapbox-gl-importer

As it is, the planet got imported yesterday night and I can confidently say that the offline support for Mapbox GL tiles is coming as well via OSM Scout Server. There is still some code to be written, but I don't foresee any blocking issues on the way.

As for vector tile schema, it will probably change in time. Already now there are slight deviations from OpenMapTiles schema to optimize import and I can see that few POIs are missing on the maps. I will document all the differences in due time. Most probably we will optimize the schema in time for our needs.

m4r0v3r 2017-11-28 21:11

Re: Mapbox GL Native QML plugin
 
Would following https://github.com/rinigus/mapbox-demo-sfos as an example be okay for a project? trying to make a uber port atm

rinigus 2017-11-29 04:37

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by m4r0v3r (Post 1538881)
Would following https://github.com/rinigus/mapbox-demo-sfos as an example be okay for a project? trying to make a uber port atm

Yes, you could use that demo for something very simple, just map display. I would suggest to install plugin from OBS and use the map widget in its QML form, without plugging in it to the project via C++. This would allow you to benefit from bug fixes in future (if there are any bugs).

Simplest demo at https://github.com/rinigus/mapbox-de...y/MainPage.qml

Some other demos to consider:

Shows how to add your own data to the map (roads, points), add interactive elements:

https://github.com/rinigus/mapbox-gl...p/qml/main.qml


Full Poor Maps port to Mapbox GL is at https://github.com/rinigus/poor-maps/tree/gl . This is an application that I am using and may have some additional tips on how to make things in practice.

Please don't hesitate to ask, I'll try to reply within a day.

m4r0v3r 2017-11-29 21:18

Re: Mapbox GL Native QML plugin
 
ill try it out tomorrow ta :)

m4r0v3r 2017-11-29 22:45

Re: Mapbox GL Native QML plugin
 
hmmm ive installed both opt-gcc6 and qmapboxgl but it still refuses to find the packages, for i486

Quote:

22:41:31: Running steps for project harbour-uber...
22:41:31: Start Build Engine: The "Sailfish OS Build Engine" virtual machine is already running. Nothing to do.
22:41:31: Starting: "/home/mgh01/.config/SailfishOS-SDK/mer-sdk-tools/Sailfish OS Build Engine/SailfishOS-2.1.3.7-i486/qmake" /home/mgh01/Projects/harbour-uber/harbour-uber.pro -spec linux-g++-32 CONFIG+=debug CONFIG+=qml_debug
No provider of 'opt-gcc6' found.
No provider of 'qmapboxgl' found.
Building target platforms: i486-meego-linux-gnu
Building for target i486-meego-linux-gnu
error: Failed build dependencies:
opt-gcc6 is needed by harbour-uber-0.1-1.i486
qmapboxgl is needed by harbour-uber-0.1-1.i486
22:41:32: The process "/home/mgh01/.config/SailfishOS-SDK/mer-sdk-tools/Sailfish OS Build Engine/SailfishOS-2.1.3.7-i486/qmake" exited with code 1.
Error while building/deploying project harbour-uber (kit: SailfishOS-2.1.3.7-i486 (in Sailfish OS Build Engine))
When executing step "qmake"
22:41:32: Elapsed time: 00:01.
]

not sure if ive missed anything

project is here

https://github.com/ghosalmartin/harbour-uber

ah ignore me I wasnt installing with

Quote:

sb2 -t SailfishOS-2.1.3.7-i486 -m sdk-install -R zypper in
but directly onto mersdk :P

m4r0v3r 2017-11-29 23:29

Re: Mapbox GL Native QML plugin
 
Quote:

Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.OzqhiF
/opt/gcc6/bin/g++ -c -m32 -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -m32 -msse -msse2 -march=i686 -mfpmath=sse -mtune=generic -fno-omit-frame-pointer -fasynchronous-unwind-tables -std=gnu++0x -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_LOCATION_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_POSITIONING_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../harbour-uber -I. -I../harbour-uber/o2/src -I../harbour-uber/mapbox-gl-qml/include -I../harbour-uber/mapbox-gl-qml/src -isystem /usr/include/sailfishapp -isystem /usr/include/mdeclarativecache5 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtLocation -isystem /usr/include/qt5/QtQuick -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtPositioning -isystem /usr/include/qt5/QtQml -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtCore -I. -I/usr/share/qt5/mkspecs/linux-g++-32 -o qquickitemmapboxgl.o ../harbour-uber/mapbox-gl-qml/src/qquickitemmapboxgl.cpp
In file included from /usr/include/qt5/mbgl/util/constants.hpp:3:0,
from ../harbour-uber/mapbox-gl-qml/src/qquickitemmapboxgl.cpp:47:
/usr/include/qt5/mbgl/util/chrono.hpp:36:49: error: 'enable_if_t' in namespace 'std' does not name a template type
template <class Rep, class Period, class = std::enable_if_t<
^~~~~~~~~~~
/usr/include/qt5/mbgl/util/chrono.hpp:36:60: error: expected '>' before '<' token
template <class Rep, class Period, class = std::enable_if_t<
^
/usr/include/qt5/mbgl/util/chrono.hpp:39:1: error: expected unqualified-id before '{' token
{
^


RPM build errors:
make: *** [qquickitemmapboxgl.o] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.OzqhiF (%build)
Bad exit status from /var/tmp/rpm-tmp.OzqhiF (%build)
23:28:57: The process "/home/mgh01/.config/SailfishOS-SDK/mer-sdk-tools/Sailfish OS Build Engine/SailfishOS-2.1.3.7-i486/make" exited with code 1.
Error while building/deploying project harbour-uber (kit: SailfishOS-2.1.3.7-i486 (in Sailfish OS Build Engine))
When executing step "Make"
23:28:57: Elapsed time: 00:05.
And another one :P

not quite sure whats wrong there, maybe something wrong in gcc6 setup. ill take another look tomorrow morning

rinigus 2017-11-30 07:06

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by m4r0v3r (Post 1538927)
And another one :P

not quite sure whats wrong there, maybe something wrong in gcc6 setup. ill take another look tomorrow morning

I see that you went C++ route and not simple QML way.

I would suggest to install
https://build.merproject.org/package...s/mapboxgl-qml and just use MapboxMap together with the gesture area as in https://github.com/rinigus/mapbox-de...y/MainPage.qml . Then you don't even need to include MapboxGL as a submodule, can use regular gcc, and its all very simple. mapboxgl-qml would register the module in the system and all should just work. Please report bugs if it doesn't.

C++ way, as you did, is also possible, but more complicated and will lead to all apps having different versions of the plugin (since you are compiling it in) and would end up having larger requirements in the root partition (everyone installing plugin under their /usr/share/harbour... folder). Note that QMaboxGL (which plugin interfaces), requires QLocation. So, there is no-go into Jolla Harbour until its allowed (Jolla's soon^TM comes into mind). So, I would suggest to go via QML plugin installation, enjoy programming and using it!

As for the error that you get, I think you are very close. You seem to miss c++14 in PRO configuration file, as I can deduce from compile messages. See https://github.com/rinigus/mapbox-de...x-sfos.pro#L15

m4r0v3r 2017-11-30 08:55

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1538938)
I see that you went C++ route and not simple QML way.

I would suggest to install
https://build.merproject.org/package...s/mapboxgl-qml and just use MapboxMap together with the gesture area as in https://github.com/rinigus/mapbox-de...y/MainPage.qml . Then you don't even need to include MapboxGL as a submodule, can use regular gcc, and its all very simple. mapboxgl-qml would register the module in the system and all should just work. Please report bugs if it doesn't.

C++ way, as you did, is also possible, but more complicated and will lead to all apps having different versions of the plugin (since you are compiling it in) and would end up having larger requirements in the root partition (everyone installing plugin under their /usr/share/harbour... folder). Note that QMaboxGL (which plugin interfaces), requires QLocation. So, there is no-go into Jolla Harbour until its allowed (Jolla's soon^TM comes into mind). So, I would suggest to go via QML plugin installation, enjoy programming and using it!

As for the error that you get, I think you are very close. You seem to miss c++14 in PRO configuration file, as I can deduce from compile messages. See https://github.com/rinigus/mapbox-de...x-sfos.pro#L15

Oh I see, bit of a noob with qt and qml atm :P Ill stick with the qml since I don't think I'll need any c++ :)

I just realised thanks to your gcc6 work I can use Slacks c++ library as well :P

hmmm so I've done what you said but the qml component still can't be found :/

m4r0v3r 2017-11-30 09:36

Re: Mapbox GL Native QML plugin
 
hmm was missing the import and added it so MapboxMapGestureArea is recognised but not MapboxMap

rinigus 2017-11-30 10:26

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by m4r0v3r (Post 1538948)
hmm was missing the import and added it so MapboxMapGestureArea is recognised but not MapboxMap

Don't know why the gesture area is recognized, but you seem to be missing run requirements for mapboxgl-qml in

https://github.com/ghosalmartin/harb...-uber.yaml#L38

Namely, you need to have this package installed on device (or emulator) where you run the code, not just build.

Looking into it, I am missing it as well in Poor Maps port to MapboxGL. I just happened to have this package installed on my device...

m4r0v3r 2017-12-03 14:50

Re: Mapbox GL Native QML plugin
 
yep working well ta :) theres a ide error but map loads fine :D

rinigus 2017-12-03 15:53

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by m4r0v3r (Post 1539097)
yep working well ta :) theres a ide error but map loads fine :D

Great to hear. An update from me as well regarding offline maps:

* as mentioned earlier, planet imported

* added support for Mapbox GL styles, fonts (glyphs), and icons (sprite).

* added support for distribution of tiles, fonts, styles, and icons

This means that all the main parts are in place, now I need to hook it all to GUI and test on device. After that, testing and releases with increased amount of polish :)

m4r0v3r 2017-12-03 16:15

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1539099)
Great to hear. An update from me as well regarding offline maps:

* as mentioned earlier, plane imported

* added support for Mapbox GL styles, fonts (glyphs), and icons (sprite).

* added support for distribution of tiles, fonts, styles, and icons

This means that all the main parts are in place, now I need to hook it all to GUI and test on device. After that, testing and releases with increased amount of polish :)

nicee, think am going to start dedicating more time to this project

rinigus 2017-12-10 20:55

Re: Mapbox GL Native QML plugin
 
As of today, offline support for Mapbox GL vector tiles has been released as a part of OSM Scout Server and the first full-blown application using the widget has been released as a temporary fork of Poor Maps. So, it should be possible to use it daily and the infrastructure for this maps widget is all in place.

m4r0v3r 2017-12-11 09:14

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1539266)
As of today, offline support for Mapbox GL vector tiles has been released as a part of OSM Scout Server and the first full-blown application using the widget has been released as a temporary fork of Poor Maps. So, it should be possible to use it daily and the infrastructure for this maps widget is all in place.

I've been quietly ripping off your poor-maps code :P Very handy. One thing I was confused about is the GPS itself, is there anyway to reliable check if it has lock since most flags come back as valid when lock hasn't actually been achieved yet

rinigus 2017-12-11 09:22

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by m4r0v3r (Post 1539273)
I've been quietly ripping off your poor-maps code :P Very handy. One thing I was confused about is the GPS itself, is there anyway to reliable check if it has lock since most flags come back as valid when lock hasn't actually been achieved yet

I actually don't know how to query status of GPS. In Poor Maps, GPS uncertainty is used and shown. Maybe its sufficient for you as well?

From my understanding, location can be provided by many different sources and its up to Qt configuration to deal with such details as GPS lock. We can just use the data as given and not worry whether it was obtained via GPS or some other technique.

MartinK 2017-12-11 15:36

Re: Mapbox GL Native QML plugin
 
Looking on how modRana does it (warning: modRana does some extra stuff there so the code is ore complex than necessarily needed) & trying to remember how I programmed it:
  • the PositionSource element has a coordinate property, which holds the current coordinate
  • the coordinate has a isValid property, which is used by modRana to decide if the coordinate is valid and should be used
  • to differentiate between 2D and 3D fix, modRana uses the altitudeValid property of the PositionSource instance

That seems to work reasonably well.

But it also depend how you define "has a fix" as by default the location backend on Sailfish OS first uses data from the mobile network and WiFi to get a rough position estimate while getting and actual GPS lock.

This is why you might see you position jump every 30 seconds for tens or hundreds of meters before it actually starts to track you position. It's the location backend sending data about local WiFi access points every 30 seconds to estimate your position while GPS is still acquiring the GPS lock.

The Info -> Location page in modRana displays detailed location data and you can nicely see the location converge from WiFi estimation to GPS fix there. :)

m4r0v3r 2017-12-11 21:58

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by MartinK (Post 1539290)
Looking on how modRana does it (warning: modRana does some extra stuff there so the code is ore complex than necessarily needed) & trying to remember how I programmed it:
  • the PositionSource element has a coordinate property, which holds the current coordinate
  • the coordinate has a isValid property, which is used by modRana to decide if the coordinate is valid and should be used
  • to differentiate between 2D and 3D fix, modRana uses the altitudeValid property of the PositionSource instance

That seems to work reasonably well.

But it also depend how you define "has a fix" as by default the location backend on Sailfish OS first uses data from the mobile network and WiFi to get a rough position estimate while getting and actual GPS lock.

This is why you might see you position jump every 30 seconds for tens or hundreds of meters before it actually starts to track you position. It's the location backend sending data about local WiFi access points every 30 seconds to estimate your position while GPS is still acquiring the GPS lock.

The Info -> Location page in modRana displays detailed location data and you can nicely see the location converge from WiFi estimation to GPS fix there. :)

it works so and so tbh since am doing the same but i guess the user will just have to realise its nowhere near there location :P

jdrescher 2017-12-15 13:15

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1538938)
I would suggest to install
https://build.merproject.org/package...s/mapboxgl-qml and just use MapboxMap together with the gesture area as in https://github.com/rinigus/mapbox-de...y/MainPage.qml . Then you don't even need to include MapboxGL as a submodule, can use regular gcc, and its all very simple. mapboxgl-qml would register the module in the system and all should just work. Please report bugs if it doesn't.

HI rinigus!
I am following your instructions but there is an error when opening the map page:
Code:

[ERROR] {QSGRenderThread}[Setup]: loading style failed: Problem with the SSL CA cert (path? access rights?): error setting certificate verify locations:
  CAfile: ca-bundle.crt
  CApath: none

This is what I did:
- installed mapboxgl-qml-1.1.0-10.27.1.jolla.armv7hl.rpm on the device (Oneplus X)
- took your basic example from here

Maybe there is a problem with the access token?

rinigus 2017-12-15 13:32

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by jdrescher (Post 1539361)
HI rinigus!
I am following your instructions but there is an error when opening the map page:
Code:

[ERROR] {QSGRenderThread}[Setup]: loading style failed: Problem with the SSL CA cert (path? access rights?): error setting certificate verify locations:
  CAfile: ca-bundle.crt
  CApath: none

This is what I did:
- installed mapboxgl-qml-1.1.0-10.27.1.jolla.armv7hl.rpm on the device (Oneplus X)
- took your basic example from here

Maybe there is a problem with the access token?

No, access token is still fine. However, I get the same error on this simple example as well as when using Poor Maps GL and trying to access Mapbox maps. Sounds like some HTTPS certificate bug that prevents us from getting the style downloaded. Hopefully, its mis-configuration of their servers and will be resolved. I'll look into it from here later

For now, you could use OSM Scout Server. For that, install it, configure for use of Mapbox GL tiles by selecting a profile with the vector tiles, download the region of interest and replace style URL in the simple example by

http://localhost:8553/v1/mbgl/style?style=osmbright

That should make it possible to use and test the widget. The access key is not required then, but you could just keep it as it is.

rinigus 2017-12-15 14:31

Re: Mapbox GL Native QML plugin
 
Looks like an issue is in HTTPS certs. Namely, it seems not to find the certificates needed for HTTPS access to Mapbox. I don't know whether they just now switched to HTTPS or not, but I can get Poor Maps GL working by

* download https://raw.githubusercontent.com/ba.../ca-bundle.crt

* in the directory where ca-bundle.crt is stored, run sailfish-qml harbour-poor-maps-gl

Now I wonder, whether it happened when I moved QMapboxGL plugin to libcurl or was anyone able to access Mapbox online maps AFTER updating mapbox-qml plugin to 1.1.0?

The simple example QML that I posted seems still need some additional Silica wrapper. While it nicely downloads all required maps/fonts when started from directory with the certificates (as shown using urlDebug switch), map is not displayed and it complains about the absence of __silica_applicationwindow_instance. So, don't forget to wrap it into some Silica app QMLs.

PS I will look into the certificate problem and resolve it within few days

jdrescher 2017-12-15 19:51

Re: Mapbox GL Native QML plugin
 
OK thanks, I will try to make it work with OSM Scout server. Just a few more questions:
- Jolla 1 won't work with MapBox, right?
- OSM Scout Server: user has to decide if he wants to keep the classic map or a vector map for MapBox. Is it possible to keep both maps on the phone (although that would need very much space on the SD card)?
- if I want to release my app with the MapBox QML component, the users also need mapboxgl-qml-1.1.0-10.27.1.jolla.armv7hl.rpm on their devices. How can I deliver it to them? Do they have to install it manually?
- does a user of my app need to enter his own token for MapBox?

rinigus 2017-12-15 20:25

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by jdrescher (Post 1539365)
OK thanks, I will try to make it work with OSM Scout server. Just a few more questions:
- Jolla 1 won't work with MapBox, right?

Right, Mapbox GL is not working on J1. Unless someone will come out and manage to fix it.

Quote:

Originally Posted by jdrescher (Post 1539365)
- OSM Scout Server: user has to decide if he wants to keep the classic map or a vector map for MapBox. Is it possible to keep both maps on the phone (although that would need very much space on the SD card)?

No, user can choose all possible backends by choosing corresponding settings. As a shortcuts, there are two options - just vector maps (Mapbox GL) or vector (Mapbox GL) and raster-generated on device (Mapnik). It would require larger space on the storage (SD Card).

Quote:

Originally Posted by jdrescher (Post 1539365)
- if I want to release my app with the MapBox QML component, the users also need mapboxgl-qml-1.1.0-10.27.1.jolla.armv7hl.rpm on their devices. How can I deliver it to them? Do they have to install it manually?

Its packaged at OpenRepos: https://openrepos.net/content/rinigu...indings-qt-qml

So, you could ask them to add my repository into their list of repositories and add mapboxgl-qml (name of the package) as dependency. This is probably the best way since it allows them to get the latest version with the bugs fixed (as the one I am fixing now).

The package is built at OBS, so they or you can take it from there (https://build.merproject.org/package...s/mapboxgl-qml).

You could also add this package into your repository. But that would require that you would be updating it as well.

Quote:

Originally Posted by jdrescher (Post 1539365)
- does a user of my app need to enter his own token for MapBox?

No, it doesn't have to be. Usually, its expected that you will put your API token. Right now, it allows you to get 50000 map tile downloads for free (see mapbox pricing) and then the developer would have to pay. I would suggest to keep an eye and if you start approaching that limit (wouldn't come overnight), cut it off or ask users for money.

However, there are alternatives. In addition to OSM Scout Server, @otsaloma setup his own server as a part of Poor Maps package. You could ask him for access key and suggest users to donate to him for this service. In addition, there are also other providers for map tiles which have free tier as well (Mapzen, for example).

And an update regarding the SSL bug. Looks like I missed testing online sources when we were searching for solution for localhost connection in offline mode. When switched to CURL-based downloads, the online sources broke if they use HTTPS. Its caused by adding hard-coded certificate file by Mapbox GL (https://github.com/mapbox/mapbox-gl-...ource.cpp#L249). In our phones (and on my Linux PC), the file with such name is missing. Now I am testing a patch without this hard-coded filename and checking if the default libcurl settings are good enough. On PC, it fixed an issue. On phone, I'll learn later tonight.

piggz 2017-12-15 20:28

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by rinigus (Post 1539266)
As of today, offline support for Mapbox GL vector tiles has been released as a part of OSM Scout Server and the first full-blown application using the widget has been released as a temporary fork of Poor Maps. So, it should be possible to use it daily and the infrastructure for this maps widget is all in place.

Does the widget have an api for drawing on the map, using, eg QGeoPath/QGeoShape etc ?

rinigus 2017-12-15 20:44

Re: Mapbox GL Native QML plugin
 
Quote:

Originally Posted by piggz (Post 1539367)
Does the widget have an api for drawing on the map, using, eg QGeoPath/QGeoShape etc ?

Sure. It doesn't use QtLocation-based approach, but keeps it close to the original Mapbox GL sources. So, you add objects using GeoJSON usually, but you could also add images and maybe even videos on the map.

If you take Poor Maps GL as an example, I can add POIs (dots with text), route as a line, and widgets that will follow geo-location of the point of interest.

I'll copy-and-paste description of it from OSM Scout Server thread:

Example codes:

Vector maps are different from raster in the interactivity with them, you can insert/remove/modify your objects. So, API has to be richer than before.

To learn, I would suggest to
  • Make an account at Mapbox, go to Mapbox Studio and try to edit one of their styles. Just play a little bit with it (10-15 min) to get the feeling of interaction between sources/layers/properties
  • Take a brief look into https://www.mapbox.com/mapbox-gl-js/style-spec (10-15 min); later you will need to read sections on the need basis
  • API for the widget is documented at https://github.com/rinigus/mapbox-gl.../master/api.md . Look through, you don't need every property/signal, just get a feeling
  • Start hacking on the basis of examples
  • Don't hesitate to ask for help.

How well does the learning process go, I don't know. I am pretty sure @jdrescher and maybe others can tell better from their experience. In particular, where do we have to document more or better.

rinigus 2017-12-16 05:56

Re: Mapbox GL Native QML plugin
 
Bugfix release published, please update on OpenRepos (https://openrepos.net/content/rinigu...indings-qt-qml). Online and offline servers should work now, as intended. Please let me know if it fixed for you as well and surely report issues that you have with the widget.


All times are GMT. The time now is 21:39.

vBulletin® Version 3.8.8