Provisioning OpenStreetMap providers in QtLocation
This post is to provide some clarification on a behavioral change we had to introduce with Qt 5.6.2 to the QtLocation's OpenStreetMap plug-in. The related change seems to have generated some confusion, so here's the full story.
The OSM plug-in used to work with hard-coded tile server URLs for the various map types offered therein. The tiles for the main (street) map type and the satellite map type, which are possibly the two most used maps, were previously sourced from open.mapquest.com. In July 2016, MapQuest discontinued this service. As a result, all deployed QtLocation OSM plug-ins for the Qt versions up to 5.6.1 and 5.7.0 suddenly began to provide tiles without map content. Instead the tiles contained an invitation to visit the MapQuest website and buy some services as shown below.
Clearly not being able to afford another such situation, we decided to fix this by adding one level of indirection. Now the OSM plug-in will fetch, for each map type, a provider definition file hosted at maps-redirect.qt.io. The format of this file is fairly similar to what others solutions use (e.g. TileJSON), with small differences needed for our specific use case. The format is documented in this file (starting from line 195). This solution makes it possible to change the tile source for specific map types, if this becomes necessary again, without the need to upgrade Qt or to rebuild the application.
These providers can also be temporarily disabled on the server side, by setting the property Enabled to false. This might happen in cases like the above mentioned where the service delivers bogus tiles and a replacement hasn't been found yet. The plug-in also ships with a hard-coded backup for connectivity reasons.
Unfortunately, at this stage we haven't been able to find an open access satellite imagery provider that would provide sufficiently high resolution data. As a result, the OSM plug-ins initially still offers seven map types (the satellite map type is still there) but, at the present, they become six as soon as the map provider definition file for the satellite type is parsed since it currently contains Enabled = false.
The screenshots below demonstrate the difference:
While this approach solves the encountered problem, it might be an undesirable behavior for some. Therefore, we added two options to disable this behavior. The first option is to set the plug-in parameter osm.mapping.providersrepository.disabled to true. This instructs the plug-in to not attempt any remote provider file fetching, but to just use the hard-coded values. Since this alone would bring the initial problem back, there is also another plug-in parameter that may come in handy. The osm.mapping.providersrepository.address can be used to override the default value of http://maps-redirect.qt.io/osm/5.6/, for 5.6.2 and 5.7.1, and http://maps-redirect.qt.io/osm/5.8/ for 5.8.0 and later releases. Developers can point the plug-in to an alternative URL containing the provider definition files for street, satellite, cycle, transit, night-transit, terrain and hiking. Even local URLs starting with file:/// or qrc:/ are possible, which means that the provider definition files can be shipped with the application.
As a last note, please bear in mind that this solution is still not 100% fail safe. The mapping service is still offered by third parties with whom The Qt Company has no contractual relationship. If a robust solution is needed, using one of the commercial services that we support through one of the other shipped plug-ins should be considered.
Subscribe to our newsletter
Try Qt 6.2 Now!
Download the latest release here: www.qt.io/download.
Qt 6 was created to be the productivity platform for the future, with next-gen 2D & 3D UX and limitless scalability.
Explore Qt World
Check our Qt demos and case studies in the virtual Qt World
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.
Näytä tämä julkaisu Instagramissa.
Want to build something for tomorrow, join #QtPeople today! We have loads of cool jobs you don’t want to miss! http://qt.io/careers #builtwithQt #software #developers #coding #framework #tool #tooling #C++ #QML #engineers #sales #tech #technology #UI #UX #CX #Qt #Qtdev #global #openpositions #careers #job
Henkilön Qt (@theqtcompany) jakama julkaisu