summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-06-07 11:06:28 +0200
committerLiang Qi <liang.qi@qt.io>2017-06-07 11:06:28 +0200
commitf55629245259ba7364e258f92408823024423caa (patch)
treef73063cf02dc175fbe9f0bfb48b3ddd686ea0f72
parent22d980c8124026eb712f563326d5a5c1b180c671 (diff)
parentd89701c5c8646dedb0ebb2e011c4da796a6ae8a1 (diff)
downloadqtlocation-f55629245259ba7364e258f92408823024423caa.tar.gz
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: .qmake.conf src/plugins/geoservices/geoservices.pro Change-Id: Ie82dd22c588e5cba409fc1ef31a65968ce9f719b
-rw-r--r--.gitmodules1
-rw-r--r--.qmake.conf1
-rw-r--r--dist/changes-5.9.0131
-rw-r--r--examples/location/mapviewer/doc/images/mapviewer.pngbin359712 -> 176944 bytes
-rw-r--r--examples/location/mapviewer/doc/src/mapviewer.qdoc4
-rw-r--r--examples/location/mapviewer/map/MapComponent.qml4
-rw-r--r--examples/location/mapviewer/mapviewer.pro1
-rw-r--r--examples/location/minimal_map/doc/images/minimal_map.pngbin156053 -> 229975 bytes
-rw-r--r--examples/location/minimal_map/main.qml8
-rw-r--r--examples/location/places/doc/images/places.pngbin151611 -> 233430 bytes
-rw-r--r--examples/location/places_map/doc/images/places_map.pngbin167995 -> 157761 bytes
-rw-r--r--examples/location/places_map/places_map.qml2
-rw-r--r--examples/location/planespotter/doc/images/planespotter.pngbin139390 -> 135872 bytes
-rw-r--r--examples/location/planespotter/planespotter.qml2
-rw-r--r--src/3rdparty/clip2tri/clip2tri.cpp18
-rw-r--r--src/3rdparty/clip2tri/clip2tri.h2
-rw-r--r--src/3rdparty/clip2tri/clip2tri.pro7
-rw-r--r--src/3rdparty/clipper/clipper.cpp4
-rw-r--r--src/3rdparty/clipper/clipper.h4
-rw-r--r--src/3rdparty/clipper/clipper.pro9
m---------src/3rdparty/mapbox-gl-native0
-rw-r--r--src/3rdparty/poly2tri/poly2tri.pro7
-rw-r--r--src/imports/location/location.cpp1
-rw-r--r--src/imports/location/plugins.qmltypes166
-rw-r--r--src/imports/positioning/locationsingleton.cpp42
-rw-r--r--src/imports/positioning/locationsingleton.h2
-rw-r--r--src/imports/positioning/positioning.cpp34
-rw-r--r--src/imports/positioning/qdeclarativepositionsource.cpp2
-rw-r--r--src/location/declarativemaps/declarativemaps.pri5
-rw-r--r--src/location/declarativemaps/error_messages.cpp2
-rw-r--r--src/location/declarativemaps/error_messages_p.h (renamed from src/location/declarativemaps/error_messages.h)12
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem.cpp87
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem_p.h9
-rw-r--r--src/location/declarativemaps/qdeclarativegeocodemodel.cpp2
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp147
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap_p.h8
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp18
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapquickitem.cpp34
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapquickitem_p.h2
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroute.cpp2
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutemodel.cpp6
-rw-r--r--src/location/declarativemaps/qdeclarativegeoroutesegment.cpp2
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp51
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem_p.h6
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp52
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem_p.h8
-rw-r--r--src/location/declarativemaps/qdeclarativerectanglemapitem.cpp37
-rw-r--r--src/location/declarativemaps/qdeclarativerectanglemapitem_p.h3
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea.cpp227
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea_p.h26
-rw-r--r--src/location/declarativeplaces/qdeclarativecategory.cpp2
-rw-r--r--src/location/declarativeplaces/qdeclarativeplace.cpp2
-rw-r--r--src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp2
-rw-r--r--src/location/declarativeplaces/qdeclarativeplaceicon.cpp2
-rw-r--r--src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp2
-rw-r--r--src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp1
-rw-r--r--src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp2
-rw-r--r--src/location/doc/src/plugins/esri.qdoc8
-rw-r--r--src/location/doc/src/plugins/mapbox.qdoc8
-rw-r--r--src/location/doc/src/plugins/mapboxgl.qdoc147
-rw-r--r--src/location/doc/src/plugins/nokia.qdoc10
-rw-r--r--src/location/doc/src/plugins/osm.qdoc8
-rw-r--r--src/location/doc/src/qml-maps.qdoc4
-rw-r--r--src/location/doc/src/qtlocation-examples.qdoc4
-rw-r--r--src/location/location.pro3
-rw-r--r--src/location/maps/qgeocameracapabilities.cpp44
-rw-r--r--src/location/maps/qgeocameracapabilities_p.h7
-rw-r--r--src/location/maps/qgeocameratiles.cpp17
-rw-r--r--src/location/maps/qgeofiletilecache.cpp159
-rw-r--r--src/location/maps/qgeofiletilecache_p.h6
-rw-r--r--src/location/maps/qgeomap.cpp4
-rw-r--r--src/location/maps/qgeomappingmanagerengine.cpp4
-rw-r--r--src/location/maps/qgeomappingmanagerengine_p.h2
-rw-r--r--src/location/maps/qgeomaptype.cpp20
-rw-r--r--src/location/maps/qgeomaptype_p.h3
-rw-r--r--src/location/maps/qgeomaptype_p_p.h5
-rw-r--r--src/location/maps/qgeoprojection.cpp54
-rw-r--r--src/location/maps/qgeoprojection_p.h3
-rw-r--r--src/location/maps/qgeotiledmap.cpp22
-rw-r--r--src/location/maps/qgeotiledmap_p.h2
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine.cpp1
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine_p.h2
-rw-r--r--src/location/maps/qgeotiledmapscene.cpp124
-rw-r--r--src/location/maps/qgeotiledmapscene_p.h2
-rw-r--r--src/location/maps/qgeotilefetcher.cpp15
-rw-r--r--src/location/maps/qgeotilefetcher_p.h6
-rw-r--r--src/location/maps/qgeotilefetcher_p_p.h4
-rw-r--r--src/location/maps/qgeotilerequestmanager.cpp26
-rw-r--r--src/location/maps/qgeotilerequestmanager_p.h2
-rw-r--r--src/plugins/geoservices/esri/esri.qrc2
-rw-r--r--src/plugins/geoservices/esri/geomapsource.cpp2
-rw-r--r--src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp20
-rw-r--r--src/plugins/geoservices/esri/geotilefetcher_esri.cpp2
-rw-r--r--src/plugins/geoservices/esri/geotilefetcher_esri.h2
-rw-r--r--src/plugins/geoservices/geoservices.pro8
-rw-r--r--src/plugins/geoservices/itemsoverlay/itemsoverlay.pro5
-rw-r--r--src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp52
-rw-r--r--src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h2
-rw-r--r--src/plugins/geoservices/mapboxgl/logo.pngbin3620 -> 2749 bytes
-rw-r--r--src/plugins/geoservices/mapboxgl/mapboxgl.pro17
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp47
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h1
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h3
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp34
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h1
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp20
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h2
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp12
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h5
-rw-r--r--src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp13
-rw-r--r--src/plugins/geoservices/nokia/nokia.pro2
-rw-r--r--src/plugins/geoservices/nokia/nokia.qrc (renamed from src/plugins/geoservices/nokia/resource.qrc)0
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp10
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h2
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp61
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp9
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp42
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h4
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.h2
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl.mm16
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp2
-rw-r--r--src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp2
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp26
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h1
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp7
-rw-r--r--src/positioning/qclipperutils.cpp4
-rw-r--r--src/positioning/qdeclarativegeolocation_p.h2
-rw-r--r--src/positioning/qdoublematrix4x4.cpp1
-rw-r--r--src/positioning/qdoublematrix4x4_p.h4
-rw-r--r--src/positioning/qgeocircle.h2
-rw-r--r--src/positioning/qgeopath.cpp5
-rw-r--r--src/positioning/qgeorectangle.h85
-rw-r--r--src/positioning/qgeoshape.cpp5
-rw-r--r--src/positioning/qgeoshape.h82
-rw-r--r--src/positioning/qgeoshape_p.h2
-rw-r--r--src/positioning/qlocationutils.cpp2
-rw-r--r--tests/auto/auto.pro3
-rw-r--r--tests/auto/declarative_geoshape/tst_locationsingleton.qml29
-rw-r--r--tests/auto/declarative_ui/tst_map.qml10
-rw-r--r--tests/auto/declarative_ui/tst_map_coordinateanimation.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_flick.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_itemview.qml7
-rw-r--r--tests/auto/declarative_ui/tst_map_keepgrab.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_mouse.qml2
-rw-r--r--tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-479702
-rw-r--r--tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h17
-rw-r--r--tests/auto/geotestplugin/qgeotilefetcher_test.h3
-rw-r--r--tests/auto/maptype/tst_maptype.cpp41
-rw-r--r--tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp6
-rw-r--r--tests/auto/qgeopath/tst_qgeopath.cpp6
-rw-r--r--tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp1
157 files changed, 1983 insertions, 729 deletions
diff --git a/.gitmodules b/.gitmodules
index 29caa86d..a5343bfd 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,4 @@
[submodule "src/3rdparty/mapbox-gl-native"]
path = src/3rdparty/mapbox-gl-native
url = ../qtlocation-mapboxgl.git
+ branch = upstream/qt-staging
diff --git a/.qmake.conf b/.qmake.conf
index 138038d5..4afd972d 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,3 +1,4 @@
load(qt_build_config)
+CONFIG += warning_clean
MODULE_VERSION = 5.10.0
diff --git a/dist/changes-5.9.0 b/dist/changes-5.9.0
new file mode 100644
index 00000000..46faf68d
--- /dev/null
+++ b/dist/changes-5.9.0
@@ -0,0 +1,131 @@
+Qt 5.9 introduces many new features and improvements as well as bugfixes
+over the 5.8.x series. For more details, refer to the online documentation
+included in this distribution. The documentation is also available online:
+
+http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.9 series is binary compatible with the 5.8.x series.
+Applications compiled for 5.8 will continue to run with 5.9.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* General *
+****************************************************************************
+
+Third-Party Code
+----------------
+
+ - Added Mapbox GL Native as a third-party component to
+ src/3rdparty/mapbox-gl-native.
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+QtLocation
+-----------
+
+ - Added boundingGeoRectangle to QGeoShape to return a geographical bounding
+ box in form of a QGeoRectangle.
+ - Added QGeoPath as a new geo shape.
+ - Added a new QML type, MapParameter, to control plugin-specific map features
+ at runtime.
+ - Deprecated QGeoShape::extendShape.
+ - Renamed the QGeoProjection class into QWebMercator.
+ - Added new private API, QGeoProjection, for the coordinate <-> screen projection
+ conversion, removing it from QGeoTiledMapScene.
+ - Moved CacheAreas enum from QGeoFileTileCache into QAbstractGeoTileCache.
+ - Map.zoomLevel now always refers to a normalized tile size of 256x256 pixels.
+ Conversions to/from different tile sizes are performed internally by QGeoMap.
+ - Added clipping support to Clip2Tri 3rd party library through clipper, to protect Qt from
+ clipper invocations that throw.
+ - Updated clipper lib to version 6.4.
+ - QGeoProjectionWebMercator now uses a projection matrix to project to item position.
+ - [QTBUG-58124] Fixed a bug on destruction of the OSM plugin causing segfault.
+ - Added rotation, tilt and field of view properties to QDeclarativeGeoMap.
+ - Changed map items to be always positioned/wrapped based on their geo left bound.
+ - Changed the Map items opacity ramp values from 2.0 -> 3.0 to 1.5 -> 2.5.
+ - QDeclarativeGeoMap::setVisibleRegion now handles QGeoPath as well.
+ - Map Items geo data is now managed by a contained QGeoShape, which also handles geographical
+ transformations such as translations.
+ - Moved the declarative implementation from imports/ into location/declarativemaps and
+ location/declarativeplaces, privately exporting the classes.
+ - QQuickGeoMapGestureArea now correctly works with tilted/rotated maps.
+ - Added two new gestures to QQuickGeoMapGestureArea, two fingers rotation and two fingers tilting.
+ - Added the infrastructure to allow a QGeoMap to be responsible for drawing map items.
+ - Added a new QML type, MapCopyrightNotice, backed by the now exposed QDeclarativeGeoMapCopyrightNotice.
+ - MapCopyrightNotice can now be styled using CSS.
+ - Added a new plugin, MapboxGL, based on the mapbox-gl-native 3rd party library.
+ - The MapboxGL plugin now ships with a built-in development token.
+ - Added a new QML type, MapItemGroup, to group multiple map items in a new meta map item.
+ - Added the new mapItemOpacity method to QGeoMapItemBase, to account for the opacity of a MapItemGroup too.
+ - Added the new fitViewportToVisibleMapItems method to QDeclarativeGeoMap.
+ - Adapted mapviewer example to enable changing tilting/rotation/FoV.
+ - QGeoTiledMap now uses anisotropic filtering when available.
+ - Unblacklisted some previously blacklisted autotests now fixed in qtdeclarative.
+ - Blacklisted flick autotests on windows due to platform-induced flakiness.
+ - Added support to the MapboxGL plugin to natively renders map polylines, polygons and rectangles.
+ - Added support to the MapboxGL plugin to render both via FBO and via QSGRenderNode.
+ - QGeoCameraCapabilities are now specific to a QGeoMapType, and not any longer fixed to a plugin.
+ - DevicePixelRatio is now considered before enabling mipmapping so that mipmapping remains off if
+ tiles do not need to be minificated.
+ - Changed QGeoTiledMap default FoV from 90 to 45 degrees.
+ - [QTBUG-59417] Fixed QGeoTiledMapScene viewing frustum calculation.
+ - Added a new mapReady signal to QDeclarativeGeoMap to notify when the map becomes ready.
+ - Added ICU support to MapboxGL plugin, depending on its availability.
+ - [QTBUG-58821] Removed dependency on QtWidgets.
+ - Added a new plugin, itemsoverlay, to provide a transparent canvas to add only map items.
+ - MapQuickItem now correctly tilts and rotates when the zoomLevel property is set.
+ - [QTBUG-59259] Increased QGeoCoordinate debug operator precision.
+ - Improved the mapviewer example, also using QtQuick.Controls2 sliders.
+ - QtPositioning now also compiler-optimized when building in release.
+ - [QTBUG-59503] Flick autotests skipped on windows.
+ - [QTBUG-59479] Mercator-projected qgeocoordinates in map items are now cached.
+ - Removed pathPropertyChanged() from Polyline,Polygon.
+ - [QTBUG-23659] Enabled overzooming tiles in qgeotiledmapscene.
+ - [QTBUG-59416] keepTouchGrab now considered when handing mouse events in QDeclarativeGeoMap.
+ - Tile formats now proactively converted to ARGB32_Premultiplied.
+ - Added possibility to disable prefetching.
+ - Added parameter to control prefetching in tile-based geoservice plugins.
+ - Disabled warnings in third-party code.
+ - Improved flicking behavior of QQuickGeoMapGestureArea.
+ - [QTBUG-60021] Map update now triggered after initialization.
+ - QGeoMap pointers now protected with QPointer.
+ - QtLocation now marked as warning-free.
+ - [QTBUG-58801] Fixed copyright notice not showing before map type is changed.
+ - Added overzoomEnabled to QGeoCameraCapabilities.
+ - Various fixes for building with various QtLite configurations.
+ - QGeoTileFetcher::handleReply now virtual.
+ - [QTBUG-60266] declarative_ui autotests disabled for boot2qt.
+
+
+****************************************************************************
+* Platform Specific Changes *
+****************************************************************************
+
+iOS
+---
+
+ - [QTBUG-52014][QTBUG-59275] Allow background updates if such capability
+ is present in infoDict.
+
+
+WinRT
+-----
+
+ - [QTBUG-57288] Remove support for WinRT 8.1 and Windows Phone 8.1.
+ - [QTBUG-60299] Added error handling for GeoPositionInfoSource creation.
+
+
+Android
+-------
+
+ - [QTBUG-59010] Added guard against unprotected javaVM pointer usage.
+ - [QTBUG-59158] UTC flag for Android position timestamps now set.
diff --git a/examples/location/mapviewer/doc/images/mapviewer.png b/examples/location/mapviewer/doc/images/mapviewer.png
index 4dc13f72..b55d7ff3 100644
--- a/examples/location/mapviewer/doc/images/mapviewer.png
+++ b/examples/location/mapviewer/doc/images/mapviewer.png
Binary files differ
diff --git a/examples/location/mapviewer/doc/src/mapviewer.qdoc b/examples/location/mapviewer/doc/src/mapviewer.qdoc
index 1fe0411c..2836ae0e 100644
--- a/examples/location/mapviewer/doc/src/mapviewer.qdoc
+++ b/examples/location/mapviewer/doc/src/mapviewer.qdoc
@@ -155,8 +155,8 @@
This is all that is required to display a Route on the Map. However, it is
also useful to be able to retrieve the written directions and explanation
of the travel route. In the example, these are displayed in a \l {ListView} element.
- To create this content, we use a standard \l {Models and Views in Qt Quick#ListModel}{ListModel} and
- \l {ListView} pair. The data in the \l {Models and Views in Qt Quick#ListModel}{ListModel} is
+ To create this content, we use a standard \l {Models and Views in Qt Quick#Models}{ListModel} and
+ \l {ListView} pair. The data in the \l {Models and Views in Qt Quick#Models}{ListModel} is
built from the routeModel's output:
\snippet mapviewer/forms/RouteList.qml routeinfomodel0
diff --git a/examples/location/mapviewer/map/MapComponent.qml b/examples/location/mapviewer/map/MapComponent.qml
index c450a150..570505a0 100644
--- a/examples/location/mapviewer/map/MapComponent.qml
+++ b/examples/location/mapviewer/map/MapComponent.qml
@@ -604,9 +604,9 @@ Map {
var mouseGeoPos = map.toCoordinate(Qt.point(mouse.x, mouse.y));
var preZoomPoint = map.fromCoordinate(mouseGeoPos, false);
if (mouse.button === Qt.LeftButton) {
- map.zoomLevel++;
+ map.zoomLevel = Math.floor(map.zoomLevel + 1)
} else if (mouse.button === Qt.RightButton) {
- map.zoomLevel--;
+ map.zoomLevel = Math.floor(map.zoomLevel - 1)
}
var postZoomPoint = map.fromCoordinate(mouseGeoPos, false);
var dx = postZoomPoint.x - preZoomPoint.x;
diff --git a/examples/location/mapviewer/mapviewer.pro b/examples/location/mapviewer/mapviewer.pro
index 0dc4a705..90d85e62 100644
--- a/examples/location/mapviewer/mapviewer.pro
+++ b/examples/location/mapviewer/mapviewer.pro
@@ -2,6 +2,7 @@ TARGET = qml_location_mapviewer
TEMPLATE = app
QT += qml network quick positioning location
+CONFIG += qtquickcompiler
SOURCES += main.cpp
RESOURCES += \
diff --git a/examples/location/minimal_map/doc/images/minimal_map.png b/examples/location/minimal_map/doc/images/minimal_map.png
index 31ad0f8b..73a16fd5 100644
--- a/examples/location/minimal_map/doc/images/minimal_map.png
+++ b/examples/location/minimal_map/doc/images/minimal_map.png
Binary files differ
diff --git a/examples/location/minimal_map/main.qml b/examples/location/minimal_map/main.qml
index 26f24986..58b1c54f 100644
--- a/examples/location/minimal_map/main.qml
+++ b/examples/location/minimal_map/main.qml
@@ -49,8 +49,8 @@ Window {
visible: true
Plugin {
- id: osmPlugin
- name: "osm"
+ id: mapPlugin
+ name: "osm" // "mapboxgl", "esri", ...
// specify plugin parameters if necessary
// PluginParameter {
// name:
@@ -60,8 +60,8 @@ Window {
Map {
anchors.fill: parent
- plugin: osmPlugin
+ plugin: mapPlugin
center: QtPositioning.coordinate(59.91, 10.75) // Oslo
- zoomLevel: 10
+ zoomLevel: 14
}
}
diff --git a/examples/location/places/doc/images/places.png b/examples/location/places/doc/images/places.png
index 0b1ac8b7..c8ada27d 100644
--- a/examples/location/places/doc/images/places.png
+++ b/examples/location/places/doc/images/places.png
Binary files differ
diff --git a/examples/location/places_map/doc/images/places_map.png b/examples/location/places_map/doc/images/places_map.png
index 4982df23..72317e2d 100644
--- a/examples/location/places_map/doc/images/places_map.png
+++ b/examples/location/places_map/doc/images/places_map.png
Binary files differ
diff --git a/examples/location/places_map/places_map.qml b/examples/location/places_map/places_map.qml
index e7d20e7b..467a31de 100644
--- a/examples/location/places_map/places_map.qml
+++ b/examples/location/places_map/places_map.qml
@@ -51,7 +51,7 @@ Rectangle {
//! [Initialize Plugin]
Plugin {
id: myPlugin
- name: "osm"
+ name: "osm" // "mapboxgl", "esri", ...
//specify plugin parameters if necessary
//PluginParameter {...}
//PluginParameter {...}
diff --git a/examples/location/planespotter/doc/images/planespotter.png b/examples/location/planespotter/doc/images/planespotter.png
index dcfd55fe..f68f6f22 100644
--- a/examples/location/planespotter/doc/images/planespotter.png
+++ b/examples/location/planespotter/doc/images/planespotter.png
Binary files differ
diff --git a/examples/location/planespotter/planespotter.qml b/examples/location/planespotter/planespotter.qml
index 624a015e..62930ba7 100644
--- a/examples/location/planespotter/planespotter.qml
+++ b/examples/location/planespotter/planespotter.qml
@@ -62,7 +62,7 @@ Window {
anchors.centerIn: parent;
anchors.fill: parent
plugin: Plugin {
- name: "osm"
+ name: "osm" // "mapboxgl", "esri", ...
}
Plane {
diff --git a/src/3rdparty/clip2tri/clip2tri.cpp b/src/3rdparty/clip2tri/clip2tri.cpp
index 2f502667..e715d1c7 100644
--- a/src/3rdparty/clip2tri/clip2tri.cpp
+++ b/src/3rdparty/clip2tri/clip2tri.cpp
@@ -90,7 +90,7 @@ void clip2tri::addClipPolygon(const Path &path)
{
clipper.AddPath(path, ptClip, true);
}
- catch(ClipperLib::clipperException &e)
+ catch(QtClipperLib::clipperException &e)
{
printf("addClipPolygon: %s\n", e.what());
}
@@ -102,7 +102,7 @@ void clip2tri::addSubjectPath(const Path &path, bool closed)
{
clipper.AddPath(path, ptSubject, closed);
}
- catch(ClipperLib::clipperException &e)
+ catch(QtClipperLib::clipperException &e)
{
printf("addSubjectPath: %s\n", e.what());
return;
@@ -118,17 +118,17 @@ void clip2tri::clearClipper()
openSubject = false;
}
-static ClipperLib::ClipType operation(const clip2tri::Operation &op)
+static QtClipperLib::ClipType operation(const clip2tri::Operation &op)
{
switch (op) {
case clip2tri::Intersection:
- return ClipperLib::ctIntersection;
+ return QtClipperLib::ctIntersection;
case clip2tri::Union:
- return ClipperLib::ctUnion;
+ return QtClipperLib::ctUnion;
case clip2tri::Difference:
- return ClipperLib::ctDifference;
+ return QtClipperLib::ctDifference;
case clip2tri::Xor:
- return ClipperLib::ctXor;
+ return QtClipperLib::ctXor;
}
return ctIntersection;
}
@@ -166,7 +166,7 @@ Paths clip2tri::execute(const clip2tri::Operation op, const PolyFillType subjFil
}
}
}
- catch(ClipperLib::clipperException &e)
+ catch(QtClipperLib::clipperException &e)
{
printf("executing %s: %s\n", operationName(op).c_str(), e.what());
}
@@ -237,7 +237,7 @@ bool clip2tri::mergePolysToPolyTree(const vector<vector<Point> > &inputPolygons,
{
clipper.AddPaths(input, ptSubject, true);
}
- catch(ClipperLib::clipperException &e)
+ catch(QtClipperLib::clipperException &e)
{
printf("mergePolysToPolyTree: %s\n", e.what());
}
diff --git a/src/3rdparty/clip2tri/clip2tri.h b/src/3rdparty/clip2tri/clip2tri.h
index 37b563bb..61c8a0f5 100644
--- a/src/3rdparty/clip2tri/clip2tri.h
+++ b/src/3rdparty/clip2tri/clip2tri.h
@@ -33,7 +33,7 @@
#include <clipper.h>
using namespace std;
-using namespace ClipperLib;
+using namespace QtClipperLib;
namespace c2t
{
diff --git a/src/3rdparty/clip2tri/clip2tri.pro b/src/3rdparty/clip2tri/clip2tri.pro
index 4ae7a799..802c0409 100644
--- a/src/3rdparty/clip2tri/clip2tri.pro
+++ b/src/3rdparty/clip2tri/clip2tri.pro
@@ -1,6 +1,6 @@
TARGET = clip2tri
-CONFIG += staticlib exceptions
+CONFIG += staticlib exceptions warn_off optimize_full
INCLUDEPATH += ../poly2tri
INCLUDEPATH += ../clipper
@@ -10,8 +10,9 @@ load(qt_helper_lib)
# workaround for QTBUG-31586
contains(QT_CONFIG, c++11): CONFIG += c++11
-*-g++* {
- QMAKE_CXXFLAGS += -O3 -ftree-vectorize -ffast-math -funsafe-math-optimizations -Wno-error=return-type
+gcc {
+ QMAKE_CFLAGS_OPTIMIZE_FULL += -ffast-math
+ !clang:!intel_icc:!rim_qcc: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=return-type
}
HEADERS += clip2tri.h
diff --git a/src/3rdparty/clipper/clipper.cpp b/src/3rdparty/clipper/clipper.cpp
index d4c82344..53ac4d82 100644
--- a/src/3rdparty/clipper/clipper.cpp
+++ b/src/3rdparty/clipper/clipper.cpp
@@ -48,7 +48,7 @@
#include <ostream>
#include <functional>
-namespace ClipperLib {
+namespace QtClipperLib {
static double const pi = 3.141592653589793238;
static double const two_pi = pi *2;
@@ -4619,4 +4619,4 @@ std::ostream& operator <<(std::ostream &s, const Paths &p)
}
//------------------------------------------------------------------------------
-} //ClipperLib namespace
+} //QtClipperLib namespace
diff --git a/src/3rdparty/clipper/clipper.h b/src/3rdparty/clipper/clipper.h
index 2472ac77..78013afc 100644
--- a/src/3rdparty/clipper/clipper.h
+++ b/src/3rdparty/clipper/clipper.h
@@ -59,7 +59,7 @@
#include <functional>
#include <queue>
-namespace ClipperLib {
+namespace QtClipperLib {
enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
enum PolyType { ptSubject, ptClip };
@@ -397,7 +397,7 @@ class clipperException : public std::exception
};
//------------------------------------------------------------------------------
-} //ClipperLib namespace
+} //QtClipperLib namespace
#endif //clipper_hpp
diff --git a/src/3rdparty/clipper/clipper.pro b/src/3rdparty/clipper/clipper.pro
index 233874e5..874d55c5 100644
--- a/src/3rdparty/clipper/clipper.pro
+++ b/src/3rdparty/clipper/clipper.pro
@@ -1,16 +1,15 @@
TARGET = clipper
-CONFIG += staticlib
-CONFIG += exceptions
-
+CONFIG += staticlib exceptions warn_off optimize_full
load(qt_helper_lib)
# workaround for QTBUG-31586
contains(QT_CONFIG, c++11): CONFIG += c++11
-*-g++* {
- QMAKE_CXXFLAGS += -O3 -ftree-vectorize -ffast-math -funsafe-math-optimizations -Wno-error=return-type
+gcc {
+ QMAKE_CFLAGS_OPTIMIZE_FULL += -ffast-math
+ !clang:!intel_icc:!rim_qcc: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=return-type
}
HEADERS += clipper.h
diff --git a/src/3rdparty/mapbox-gl-native b/src/3rdparty/mapbox-gl-native
-Subproject edd127ee7658ceb7f5f2f740bce75db1cbf25c0
+Subproject 9ecbe3642fb4a53b558598239b59bf1d0224c25
diff --git a/src/3rdparty/poly2tri/poly2tri.pro b/src/3rdparty/poly2tri/poly2tri.pro
index d4ae9cd8..76f2779e 100644
--- a/src/3rdparty/poly2tri/poly2tri.pro
+++ b/src/3rdparty/poly2tri/poly2tri.pro
@@ -1,14 +1,15 @@
TARGET = poly2tri
-CONFIG += staticlib
+CONFIG += staticlib warn_off optimize_full
load(qt_helper_lib)
# workaround for QTBUG-31586
contains(QT_CONFIG, c++11): CONFIG += c++11
-*-g++* {
- QMAKE_CXXFLAGS += -O3 -ftree-vectorize -ffast-math -funsafe-math-optimizations -Wno-error=return-type
+gcc {
+ QMAKE_CFLAGS_OPTIMIZE_FULL += -ffast-math
+ !clang:!intel_icc:!rim_qcc: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=return-type
}
HEADERS += poly2tri.h \
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index a0b61d6e..0a20e5ad 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -67,7 +67,6 @@
#include <QtLocation/private/qdeclarativesupportedcategoriesmodel_p.h>
#include <QtLocation/private/qdeclarativesearchresultmodel_p.h>
#include <QtLocation/private/qdeclarativesearchsuggestionmodel_p.h>
-#include <QtLocation/error_messages.h>
#include <QtQml/qqmlextensionplugin.h>
diff --git a/src/imports/location/plugins.qmltypes b/src/imports/location/plugins.qmltypes
index b89963ad..e866cac7 100644
--- a/src/imports/location/plugins.qmltypes
+++ b/src/imports/location/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtLocation 5.8'
+// 'qmlplugindump -nonrelocatable QtLocation 5.9'
Module {
dependencies: ["QtQuick 2.8"]
@@ -135,6 +135,13 @@ Module {
Property { name: "minimumZoomLevel"; type: "double" }
Property { name: "maximumZoomLevel"; type: "double" }
Property { name: "zoomLevel"; type: "double" }
+ Property { name: "tilt"; type: "double" }
+ Property { name: "minimumTilt"; type: "double" }
+ Property { name: "maximumTilt"; type: "double" }
+ Property { name: "bearing"; type: "double" }
+ Property { name: "fieldOfView"; type: "double" }
+ Property { name: "minimumFieldOfView"; type: "double" }
+ Property { name: "maximumFieldOfView"; type: "double" }
Property { name: "activeMapType"; type: "QDeclarativeGeoMapType"; isPointer: true }
Property {
name: "supportedMapTypes"
@@ -144,11 +151,13 @@ Module {
}
Property { name: "center"; type: "QGeoCoordinate" }
Property { name: "mapItems"; type: "QList<QObject*>"; isReadonly: true }
+ Property { name: "mapParameters"; type: "QList<QObject*>"; isReadonly: true }
Property { name: "error"; type: "QGeoServiceProvider::Error"; isReadonly: true }
Property { name: "errorString"; type: "string"; isReadonly: true }
Property { name: "visibleRegion"; type: "QGeoShape" }
Property { name: "copyrightsVisible"; type: "bool" }
Property { name: "color"; type: "QColor" }
+ Property { name: "mapReady"; type: "bool"; isReadonly: true }
Signal {
name: "pluginChanged"
Parameter { name: "plugin"; type: "QDeclarativeGeoServiceProvider"; isPointer: true }
@@ -173,6 +182,46 @@ Module {
name: "colorChanged"
Parameter { name: "color"; type: "QColor" }
}
+ Signal {
+ name: "bearingChanged"
+ Parameter { name: "bearing"; type: "double" }
+ }
+ Signal {
+ name: "tiltChanged"
+ Parameter { name: "tilt"; type: "double" }
+ }
+ Signal {
+ name: "fieldOfViewChanged"
+ Parameter { name: "fieldOfView"; type: "double" }
+ }
+ Signal {
+ name: "minimumTiltChanged"
+ Parameter { name: "minimumTilt"; type: "double" }
+ }
+ Signal {
+ name: "maximumTiltChanged"
+ Parameter { name: "maximumTilt"; type: "double" }
+ }
+ Signal {
+ name: "minimumFieldOfViewChanged"
+ Parameter { name: "minimumFieldOfView"; type: "double" }
+ }
+ Signal {
+ name: "maximumFieldOfViewChanged"
+ Parameter { name: "maximumFieldOfView"; type: "double" }
+ }
+ Signal {
+ name: "copyrightsChanged"
+ Parameter { name: "copyrightsImage"; type: "QImage" }
+ }
+ Signal {
+ name: "copyrightsChanged"
+ Parameter { name: "copyrightsHtml"; type: "string" }
+ }
+ Signal {
+ name: "mapReadyChanged"
+ Parameter { name: "ready"; type: "bool" }
+ }
Method {
name: "removeMapItem"
Parameter { name: "item"; type: "QDeclarativeGeoMapItemBase"; isPointer: true }
@@ -181,8 +230,25 @@ Module {
name: "addMapItem"
Parameter { name: "item"; type: "QDeclarativeGeoMapItemBase"; isPointer: true }
}
+ Method {
+ name: "addMapItemGroup"
+ Parameter { name: "itemGroup"; type: "QDeclarativeGeoMapItemGroup"; isPointer: true }
+ }
+ Method {
+ name: "removeMapItemGroup"
+ Parameter { name: "itemGroup"; type: "QDeclarativeGeoMapItemGroup"; isPointer: true }
+ }
Method { name: "clearMapItems" }
Method {
+ name: "addMapParameter"
+ Parameter { name: "parameter"; type: "QDeclarativeGeoMapParameter"; isPointer: true }
+ }
+ Method {
+ name: "removeMapParameter"
+ Parameter { name: "parameter"; type: "QDeclarativeGeoMapParameter"; isPointer: true }
+ }
+ Method { name: "clearMapParameters" }
+ Method {
name: "toCoordinate"
type: "QGeoCoordinate"
Parameter { name: "position"; type: "QPointF" }
@@ -205,6 +271,7 @@ Module {
Parameter { name: "coordinate"; type: "QGeoCoordinate" }
}
Method { name: "fitViewportToMapItems" }
+ Method { name: "fitViewportToVisibleMapItems" }
Method {
name: "pan"
Parameter { name: "dx"; type: "int" }
@@ -214,12 +281,54 @@ Module {
Method { name: "clearData" }
}
Component {
+ name: "QDeclarativeGeoMapCopyrightNotice"
+ defaultProperty: "data"
+ prototype: "QQuickPaintedItem"
+ exports: ["QtLocation/MapCopyrightNotice 5.9"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "mapSource"; type: "QDeclarativeGeoMap"; isPointer: true }
+ Property { name: "styleSheet"; type: "string" }
+ Signal {
+ name: "linkActivated"
+ Parameter { name: "link"; type: "string" }
+ }
+ Signal {
+ name: "backgroundColorChanged"
+ Parameter { name: "color"; type: "QColor" }
+ }
+ Signal {
+ name: "styleSheetChanged"
+ Parameter { name: "styleSheet"; type: "string" }
+ }
+ Method {
+ name: "copyrightsChanged"
+ Parameter { name: "copyrightsImage"; type: "QImage" }
+ }
+ Method {
+ name: "copyrightsChanged"
+ Parameter { name: "copyrightsHtml"; type: "string" }
+ }
+ Method {
+ name: "onCopyrightsStyleSheetChanged"
+ Parameter { name: "styleSheet"; type: "string" }
+ }
+ }
+ Component {
name: "QDeclarativeGeoMapItemBase"
defaultProperty: "data"
prototype: "QQuickItem"
exports: ["QtLocation/GeoMapItemBase 5.0"]
isCreatable: false
exportMetaObjectRevisions: [0]
+ Property { name: "geoShape"; type: "QGeoShape"; isReadonly: true }
+ Signal { name: "mapItemOpacityChanged" }
+ }
+ Component {
+ name: "QDeclarativeGeoMapItemGroup"
+ defaultProperty: "data"
+ prototype: "QQuickItem"
+ exports: ["QtLocation/MapItemGroup 5.9"]
+ exportMetaObjectRevisions: [0]
}
Component {
name: "QDeclarativeGeoMapItemView"
@@ -231,6 +340,16 @@ Module {
Property { name: "autoFitViewport"; type: "bool" }
}
Component {
+ name: "QDeclarativeGeoMapParameter"
+ prototype: "QGeoMapParameter"
+ exports: ["QtLocation/MapParameter 5.9"]
+ exportMetaObjectRevisions: [0]
+ Signal {
+ name: "completed"
+ Parameter { type: "QDeclarativeGeoMapParameter"; isPointer: true }
+ }
+ }
+ Component {
name: "QDeclarativeGeoMapQuickItem"
defaultProperty: "data"
prototype: "QDeclarativeGeoMapItemBase"
@@ -317,6 +436,7 @@ Module {
Property { name: "error"; type: "RouteError"; isReadonly: true }
Property { name: "measurementSystem"; type: "QLocale::MeasurementSystem" }
Signal { name: "routesChanged" }
+ Signal { name: "abortRequested" }
Method { name: "update" }
Method {
name: "get"
@@ -1125,6 +1245,16 @@ Module {
Method { name: "errorString"; type: "string" }
}
Component {
+ name: "QGeoMapParameter"
+ prototype: "QObject"
+ Property { name: "type"; type: "string" }
+ Signal {
+ name: "propertyUpdated"
+ Parameter { name: "param"; type: "QGeoMapParameter"; isPointer: true }
+ Parameter { name: "propertyName"; type: "const char"; isPointer: true }
+ }
+ }
+ Component {
name: "QGeoMapPinchEvent"
prototype: "QObject"
exports: ["QtLocation/MapPinchEvent 5.0"]
@@ -1166,7 +1296,9 @@ Module {
"NoGesture": 0,
"PinchGesture": 1,
"PanGesture": 2,
- "FlickGesture": 4
+ "FlickGesture": 4,
+ "RotationGesture": 8,
+ "TiltGesture": 16
}
}
Enum {
@@ -1175,12 +1307,16 @@ Module {
"NoGesture": 0,
"PinchGesture": 1,
"PanGesture": 2,
- "FlickGesture": 4
+ "FlickGesture": 4,
+ "RotationGesture": 8,
+ "TiltGesture": 16
}
}
Property { name: "enabled"; type: "bool" }
Property { name: "pinchActive"; type: "bool"; isReadonly: true }
Property { name: "panActive"; type: "bool"; isReadonly: true }
+ Property { name: "rotationActive"; type: "bool"; isReadonly: true }
+ Property { name: "tiltActive"; type: "bool"; isReadonly: true }
Property { name: "acceptedGestures"; type: "AcceptedGestures" }
Property { name: "maximumZoomLevelChange"; type: "double" }
Property { name: "flickDeceleration"; type: "double" }
@@ -1201,5 +1337,29 @@ Module {
Signal { name: "panFinished" }
Signal { name: "flickStarted" }
Signal { name: "flickFinished" }
+ Signal {
+ name: "rotationStarted"
+ Parameter { name: "pinch"; type: "QGeoMapPinchEvent"; isPointer: true }
+ }
+ Signal {
+ name: "rotationUpdated"
+ Parameter { name: "pinch"; type: "QGeoMapPinchEvent"; isPointer: true }
+ }
+ Signal {
+ name: "rotationFinished"
+ Parameter { name: "pinch"; type: "QGeoMapPinchEvent"; isPointer: true }
+ }
+ Signal {
+ name: "tiltStarted"
+ Parameter { name: "pinch"; type: "QGeoMapPinchEvent"; isPointer: true }
+ }
+ Signal {
+ name: "tiltUpdated"
+ Parameter { name: "pinch"; type: "QGeoMapPinchEvent"; isPointer: true }
+ }
+ Signal {
+ name: "tiltFinished"
+ Parameter { name: "pinch"; type: "QGeoMapPinchEvent"; isPointer: true }
+ }
}
}
diff --git a/src/imports/positioning/locationsingleton.cpp b/src/imports/positioning/locationsingleton.cpp
index a48c1a96..19b05761 100644
--- a/src/imports/positioning/locationsingleton.cpp
+++ b/src/imports/positioning/locationsingleton.cpp
@@ -39,6 +39,26 @@
#include "locationsingleton.h"
+static QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok)
+{
+ QGeoCoordinate c;
+
+ if (value.isObject()) {
+ if (value.hasProperty(QStringLiteral("latitude")))
+ c.setLatitude(value.property(QStringLiteral("latitude")).toNumber());
+ if (value.hasProperty(QStringLiteral("longitude")))
+ c.setLongitude(value.property(QStringLiteral("longitude")).toNumber());
+ if (value.hasProperty(QStringLiteral("altitude")))
+ c.setAltitude(value.property(QStringLiteral("altitude")).toNumber());
+
+ if (ok)
+ *ok = true;
+ }
+
+ return c;
+}
+
+
/*!
\qmltype QtPositioning
\instantiates LocationSingleton
@@ -191,6 +211,28 @@ QGeoPath LocationSingleton::path() const
return QGeoPath();
}
+QGeoPath LocationSingleton::path(const QJSValue &value, qreal width) const
+{
+ QList<QGeoCoordinate> pathList;
+
+ if (value.isArray()) {
+ quint32 length = value.property(QStringLiteral("length")).toUInt();
+ for (quint32 i = 0; i < length; ++i) {
+ bool ok;
+ QGeoCoordinate c = parseCoordinate(value.property(i), &ok);
+
+ if (!ok || !c.isValid()) {
+ pathList.clear(); // aborting
+ break;
+ }
+
+ pathList.append(c);
+ }
+ }
+
+ return QGeoPath(pathList, width);
+}
+
/*!
\qmlmethod geocircle QtPositioning::shapeToCircle(geoshape shape) const
diff --git a/src/imports/positioning/locationsingleton.h b/src/imports/positioning/locationsingleton.h
index 9a5320e0..4faf2738 100644
--- a/src/imports/positioning/locationsingleton.h
+++ b/src/imports/positioning/locationsingleton.h
@@ -47,6 +47,7 @@
#include <QtPositioning/QGeoRectangle>
#include <QtPositioning/QGeoCircle>
#include <QtPositioning/QGeoPath>
+#include <QtQml/QJSValue>
#include <QVariant>
class LocationSingleton : public QObject
@@ -73,6 +74,7 @@ public:
Q_INVOKABLE QGeoCircle circle(const QGeoCoordinate &center, qreal radius = -1.0) const;
Q_INVOKABLE QGeoPath path() const;
+ Q_INVOKABLE QGeoPath path(const QJSValue &value, qreal width = 0.0) const;
Q_INVOKABLE QGeoCircle shapeToCircle(const QGeoShape &shape) const;
Q_INVOKABLE QGeoRectangle shapeToRectangle(const QGeoShape &shape) const;
diff --git a/src/imports/positioning/positioning.cpp b/src/imports/positioning/positioning.cpp
index f00a4ae6..b1576e3c 100644
--- a/src/imports/positioning/positioning.cpp
+++ b/src/imports/positioning/positioning.cpp
@@ -244,7 +244,7 @@ QT_BEGIN_NAMESPACE
The \l isEmpty attribute can be used to test if the geoshape represents a region with a
geometrical area of 0.
- The \l {contains}{contains()} method can be used to test if a \l {coordinate} is
+ The \l {contains}() method can be used to test if a \l {coordinate} is
within the geoshape.
\section1 Example Usage
@@ -495,6 +495,38 @@ QT_BEGIN_NAMESPACE
The default value for the radius is -1 indicating an invalid geocircle area.
*/
+/*!
+ \qmlbasictype geopath
+ \inqmlmodule QtPositioning
+ \ingroup qml-QtPositioning5-basictypes
+ \since 5.9
+
+ \brief The geopath type represents a geographic path.
+
+ The \c geopath type is a \l {geoshape} that represents a geographic
+ path. It is a direct representation of a \l QGeoPath and is defined
+ in terms of a \l {path} which holds the list of geo coordinates in the
+ path.
+
+ The path is considered invalid if it is empty.
+
+ When integrating with C++, note that any QGeoPath value passed into QML from C++ is
+ automatically converted into a \c geopath value, and vice versa.
+
+ \section1 Properties
+
+ \section2 path
+
+ This property holds the list of coordinates defining the path.
+
+ \section2 width
+
+ This property holds the width of the path in meters. This is currently only used
+ when calling the \l {contains}() method.
+
+ The default value for the width is 0.
+*/
+
static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine)
{
Q_UNUSED(engine)
diff --git a/src/imports/positioning/qdeclarativepositionsource.cpp b/src/imports/positioning/qdeclarativepositionsource.cpp
index 8c90e312..b0e990da 100644
--- a/src/imports/positioning/qdeclarativepositionsource.cpp
+++ b/src/imports/positioning/qdeclarativepositionsource.cpp
@@ -45,7 +45,7 @@
#include <QtQml/qqml.h>
#include <qnmeapositioninfosource.h>
#include <QFile>
-#include <QTcpSocket>
+#include <QtNetwork/QTcpSocket>
#include <QTimer>
QT_BEGIN_NAMESPACE
diff --git a/src/location/declarativemaps/declarativemaps.pri b/src/location/declarativemaps/declarativemaps.pri
index e1054001..34c9f588 100644
--- a/src/location/declarativemaps/declarativemaps.pri
+++ b/src/location/declarativemaps/declarativemaps.pri
@@ -2,10 +2,8 @@ QT += quick-private network positioning-private qml-private core-private gui-pri
INCLUDEPATH += declarativemaps
-PUBLIC_HEADERS += \
- declarativemaps/error_messages.h
-
PRIVATE_HEADERS += \
+ declarativemaps/error_messages_p.h \
declarativemaps/qdeclarativegeomapitemview_p.h \
declarativemaps/qdeclarativegeomapitemview_p_p.h \
declarativemaps/qdeclarativegeoserviceprovider_p.h \
@@ -59,6 +57,7 @@ SOURCES += \
../imports/positioning/qquickgeocoordinateanimation.cpp \
declarativemaps/mapitemviewdelegateincubator.cpp
+load(qt_build_paths)
LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lpoly2tri$$qtPlatformTargetSuffix() -lclip2tri$$qtPlatformTargetSuffix()
diff --git a/src/location/declarativemaps/error_messages.cpp b/src/location/declarativemaps/error_messages.cpp
index a2557f79..7b51b7ad 100644
--- a/src/location/declarativemaps/error_messages.cpp
+++ b/src/location/declarativemaps/error_messages.cpp
@@ -33,7 +33,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "error_messages.h"
+#include "error_messages_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/location/declarativemaps/error_messages.h b/src/location/declarativemaps/error_messages_p.h
index 81c43b34..cdd531d1 100644
--- a/src/location/declarativemaps/error_messages.h
+++ b/src/location/declarativemaps/error_messages_p.h
@@ -37,6 +37,18 @@
#ifndef ERROR_MESSAGES_H
#define ERROR_MESSAGES_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
index a4eee272..274225c0 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
@@ -142,7 +142,7 @@ QGeoMapCircleGeometry::QGeoMapCircleGeometry()
/*!
\internal
*/
-void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QGeoCoordinate> &circlePath, const QGeoMap &map)
+void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QDoubleVector2D> &circlePath, const QGeoMap &map)
{
// Not checking for !screenDirty anymore, as everything is now recalculated.
clear();
@@ -175,13 +175,13 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QGeoCoordinate>
fill << tl << tr << br << bl;
QList<QDoubleVector2D> hole;
- for (const QGeoCoordinate &c: circlePath)
- hole << map.geoProjection().geoToWrappedMapProjection(c);
+ for (const QDoubleVector2D &c: circlePath)
+ hole << map.geoProjection().wrapMapProjection(c);
c2t::clip2tri clipper;
clipper.addSubjectPath(QClipperUtils::qListToPath(fill), true);
clipper.addClipPolygon(QClipperUtils::qListToPath(hole));
- Paths difference = clipper.execute(c2t::clip2tri::Difference, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
+ Paths difference = clipper.execute(c2t::clip2tri::Difference, QtClipperLib::pftEvenOdd, QtClipperLib::pftEvenOdd);
// 2)
QDoubleVector2D lb = map.geoProjection().geoToWrappedMapProjection(srcOrigin_);
@@ -192,7 +192,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QGeoCoordinate>
for (const Path &p: difference)
clipper.addSubjectPath(p, true);
clipper.addClipPolygon(QClipperUtils::qListToPath(visibleRegion));
- Paths res = clipper.execute(c2t::clip2tri::Intersection, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
+ Paths res = clipper.execute(c2t::clip2tri::Intersection, QtClipperLib::pftEvenOdd, QtClipperLib::pftEvenOdd);
clippedPaths = QClipperUtils::pathsToQList(res);
// 2.1) update srcOrigin_ with the point with minimum X/Y
@@ -358,8 +358,10 @@ void QDeclarativeCircleMapItem::markSourceDirtyAndUpdate()
void QDeclarativeCircleMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
- if (map)
- markSourceDirtyAndUpdate();
+ if (!map)
+ return;
+ updateCirclePath();
+ markSourceDirtyAndUpdate();
}
/*!
@@ -375,6 +377,7 @@ void QDeclarativeCircleMapItem::setCenter(const QGeoCoordinate &center)
return;
circle_.setCenter(center);
+ updateCirclePath();
markSourceDirtyAndUpdate();
emit centerChanged(center);
}
@@ -418,6 +421,7 @@ void QDeclarativeCircleMapItem::setRadius(qreal radius)
return;
circle_.setRadius(radius);
+ updateCirclePath();
markSourceDirtyAndUpdate();
emit radiusChanged(radius);
}
@@ -472,24 +476,19 @@ void QDeclarativeCircleMapItem::updatePolish()
QScopedValueRollback<bool> rollback(updatingGeometry_);
updatingGeometry_ = true;
- if (geometry_.isSourceDirty()) {
- circlePath_.clear();
- calculatePeripheralPoints(circlePath_, circle_.center(), circle_.radius(), CircleSamples);
- }
-
- QList<QGeoCoordinate> originalCirclePath = circlePath_;
+ QList<QDoubleVector2D> circlePath = circlePath_;
- int pathCount = circlePath_.size();
- bool preserve = preserveCircleGeometry(circlePath_, circle_.center(), circle_.radius());
+ int pathCount = circlePath.size();
+ bool preserve = preserveCircleGeometry(circlePath, circle_.center(), circle_.radius());
geometry_.setPreserveGeometry(true, circle_.boundingGeoRectangle().topLeft()); // to set the geoLeftBound_
geometry_.setPreserveGeometry(preserve, circle_.boundingGeoRectangle().topLeft());
bool invertedCircle = false;
- if (crossEarthPole(circle_.center(), circle_.radius()) && circlePath_.size() == pathCount) {
- geometry_.updateScreenPointsInvert(circlePath_, *map()); // invert fill area for really huge circles
+ if (crossEarthPole(circle_.center(), circle_.radius()) && circlePath.size() == pathCount) {
+ geometry_.updateScreenPointsInvert(circlePath, *map()); // invert fill area for really huge circles
invertedCircle = true;
} else {
- geometry_.updateSourcePoints(*map(), circlePath_);
+ geometry_.updateSourcePoints(*map(), circlePath);
geometry_.updateScreenPoints(*map());
}
@@ -498,11 +497,11 @@ void QDeclarativeCircleMapItem::updatePolish()
geoms << &geometry_;
if (border_.color() != Qt::transparent && border_.width() > 0) {
- QList<QGeoCoordinate> closedPath = circlePath_;
+ QList<QDoubleVector2D> closedPath = circlePath;
closedPath << closedPath.first();
if (invertedCircle) {
- closedPath = originalCirclePath;
+ closedPath = circlePath_;
closedPath << closedPath.first();
std::reverse(closedPath.begin(), closedPath.end());
}
@@ -549,6 +548,20 @@ void QDeclarativeCircleMapItem::afterViewportChanged(const QGeoMapViewportChange
/*!
\internal
*/
+void QDeclarativeCircleMapItem::updateCirclePath()
+{
+ if (!map())
+ return;
+ QList<QGeoCoordinate> path;
+ calculatePeripheralPoints(path, circle_.center(), circle_.radius(), CircleSamples);
+ circlePath_.clear();
+ for (const QGeoCoordinate &c : path)
+ circlePath_ << map()->geoProjection().geoToMapProjection(c);
+}
+
+/*!
+ \internal
+*/
bool QDeclarativeCircleMapItem::contains(const QPointF &point) const
{
return (geometry_.contains(point) || borderGeometry_.contains(point));
@@ -569,7 +582,7 @@ QGeoMap::ItemType QDeclarativeCircleMapItem::itemType() const
*/
void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- if (updatingGeometry_ || newGeometry == oldGeometry) {
+ if (!map() || !circle_.isValid() || updatingGeometry_ || newGeometry == oldGeometry) {
QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
return;
}
@@ -583,7 +596,7 @@ void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const
// call to this function.
}
-bool QDeclarativeCircleMapItem::preserveCircleGeometry (QList<QGeoCoordinate> &path,
+bool QDeclarativeCircleMapItem::preserveCircleGeometry (QList<QDoubleVector2D> &path,
const QGeoCoordinate &center, qreal distance)
{
// if circle crosses north/south pole, then don't preserve circular shape,
@@ -612,7 +625,7 @@ bool QDeclarativeCircleMapItem::preserveCircleGeometry (QList<QGeoCoordinate> &p
* | ____ |
* \__/ \__/
*/
-void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinate> &path,
+void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QDoubleVector2D> &path,
const QGeoCoordinate &center,
qreal distance)
{
@@ -623,11 +636,11 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinat
bool crossSouthPole = distanceToSouthPole < distance;
QList<int> wrapPathIndex;
- QDoubleVector2D prev = map()->geoProjection().wrapMapProjection(map()->geoProjection().geoToMapProjection(path.at(0)));
+ QDoubleVector2D prev = map()->geoProjection().wrapMapProjection(path.at(0));
for (int i = 1; i <= path.count(); ++i) {
int index = i % path.count();
- QDoubleVector2D point = map()->geoProjection().wrapMapProjection(map()->geoProjection().geoToMapProjection(path.at(index)));
+ QDoubleVector2D point = map()->geoProjection().wrapMapProjection(path.at(index));
double diff = qAbs(point.x() - prev.x());
if (diff > 0.5) {
continue;
@@ -637,7 +650,7 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinat
// find the points in path where wrapping occurs
for (int i = 1; i <= path.count(); ++i) {
int index = i % path.count();
- QDoubleVector2D point = map()->geoProjection().wrapMapProjection(map()->geoProjection().geoToMapProjection(path.at(index)));
+ QDoubleVector2D point = map()->geoProjection().wrapMapProjection(path.at(index));
if ( (qAbs(point.x() - prev.x())) >= 0.5 ) {
wrapPathIndex << index;
if (wrapPathIndex.size() == 2 || !(crossNorthPole && crossSouthPole))
@@ -648,25 +661,25 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinat
// insert two additional coords at top/bottom map corners of the map for shape
// to be drawn correctly
if (wrapPathIndex.size() > 0) {
- qreal newPoleLat = 90;
- QGeoCoordinate wrapCoord = path.at(wrapPathIndex[0]);
+ qreal newPoleLat = 0; // 90 latitude
+ QDoubleVector2D wrapCoord = path.at(wrapPathIndex[0]);
if (wrapPathIndex.size() == 2) {
- QGeoCoordinate wrapCoord2 = path.at(wrapPathIndex[1]);
- if (wrapCoord2.latitude() > wrapCoord.latitude())
- newPoleLat = -90;
+ QDoubleVector2D wrapCoord2 = path.at(wrapPathIndex[1]);
+ if (wrapCoord2.y() < wrapCoord.y())
+ newPoleLat = 1; // -90 latitude
} else if (center.latitude() < 0) {
- newPoleLat = -90;
+ newPoleLat = 1; // -90 latitude
}
for (int i = 0; i < wrapPathIndex.size(); ++i) {
int index = wrapPathIndex[i] == 0 ? 0 : wrapPathIndex[i] + i*2;
int prevIndex = (index - 1) < 0 ? (path.count() - 1): index - 1;
- QGeoCoordinate coord0 = path.at(prevIndex);
- QGeoCoordinate coord1 = path.at(index);
- coord0.setLatitude(newPoleLat);
- coord1.setLatitude(newPoleLat);
+ QDoubleVector2D coord0 = path.at(prevIndex);
+ QDoubleVector2D coord1 = path.at(index);
+ coord0.setY(newPoleLat);
+ coord1.setY(newPoleLat);
path.insert(index ,coord1);
path.insert(index, coord0);
- newPoleLat = -newPoleLat;
+ newPoleLat = 1.0 - newPoleLat;
}
}
}
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
index bcbd67d8..511e3b17 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
@@ -63,7 +63,7 @@ class QGeoMapCircleGeometry : public QGeoMapPolygonGeometry
public:
QGeoMapCircleGeometry();
- void updateScreenPointsInvert(const QList<QGeoCoordinate> &circlePath, const QGeoMap &map);
+ void updateScreenPointsInvert(const QList<QDoubleVector2D> &circlePath, const QGeoMap &map);
};
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeCircleMapItem : public QDeclarativeGeoMapItemBase
@@ -110,16 +110,17 @@ protected Q_SLOTS:
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
private:
- bool preserveCircleGeometry(QList<QGeoCoordinate> &path, const QGeoCoordinate &center,
+ void updateCirclePath();
+ bool preserveCircleGeometry(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
qreal distance);
- void updateCirclePathForRendering(QList<QGeoCoordinate> &path, const QGeoCoordinate &center,
+ void updateCirclePathForRendering(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
qreal distance);
private:
QGeoCircle circle_;
QDeclarativeMapLineProperties border_;
QColor color_;
- QList<QGeoCoordinate> circlePath_;
+ QList<QDoubleVector2D> circlePath_;
bool dirtyMaterial_;
QGeoMapCircleGeometry geometry_;
QGeoMapPolylineGeometry borderGeometry_;
diff --git a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
index f7422ec2..d874f9a2 100644
--- a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp
@@ -35,7 +35,7 @@
****************************************************************************/
#include "qdeclarativegeocodemodel_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QtCore/QCoreApplication>
#include <QtQml/QQmlInfo>
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 8ab29c1a..9f4dae3f 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -45,6 +45,7 @@
#include "qdeclarativegeomapparameter_p.h"
#include <QtPositioning/QGeoCircle>
#include <QtPositioning/QGeoRectangle>
+#include <QtPositioning/QGeoPath>
#include <QtQuick/QQuickWindow>
#include <QtQuick/QSGRectangleNode>
#include <QtQuick/private/qquickwindow_p.h>
@@ -139,7 +140,7 @@ QT_BEGIN_NAMESPACE
\section2 Example Usage
The following snippet shows a simple Map and the necessary Plugin type
- to use it. The map is centered over Oslo, Norway, with zoom level 10.
+ to use it. The map is centered over Oslo, Norway, with zoom level 14.
\quotefromfile minimal_map/main.qml
\skipto import
@@ -189,7 +190,7 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
m_activeMapType = new QDeclarativeGeoMapType(QGeoMapType(QGeoMapType::NoMap,
tr("No Map"),
- tr("No Map"), false, false, 0), this);
+ tr("No Map"), false, false, 0, QByteArrayLiteral("")), this);
m_cameraData.setCenter(QGeoCoordinate(51.5073,-0.1277)); //London city center
m_cameraData.setZoomLevel(8.0);
@@ -278,17 +279,17 @@ void QDeclarativeGeoMap::onMapChildrenChanged()
copyrights = m_copyrights.data();
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QImage)),
copyrights, SLOT(copyrightsChanged(QImage)));
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QImage)),
this, SIGNAL(copyrightsChanged(QImage)));
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QString)),
copyrights, SLOT(copyrightsChanged(QString)));
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QString)),
this, SIGNAL(copyrightsChanged(QString)));
- connect(m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
+ connect(m_map.data(), SIGNAL(copyrightsStyleSheetChanged(QString)),
copyrights, SLOT(onCopyrightsStyleSheetChanged(QString)));
connect(copyrights, SIGNAL(linkActivated(QString)),
@@ -419,6 +420,9 @@ void QDeclarativeGeoMap::initialize()
emit fieldOfViewChanged(m_cameraData.fieldOfView());
emit mapReadyChanged(true);
+
+ if (m_copyrights)
+ update();
}
/*!
@@ -721,7 +725,7 @@ void QDeclarativeGeoMap::onCameraCapabilitiesChanged(const QGeoCameraCapabilitie
*/
void QDeclarativeGeoMap::mappingManagerInitialized()
{
- m_map = m_mappingManager->createMap(this);
+ m_map = QPointer<QGeoMap>(m_mappingManager->createMap(this));
if (!m_map)
return;
@@ -734,12 +738,20 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
m_supportedMapTypes.append(type);
}
- if (!m_supportedMapTypes.isEmpty()) {
- QDeclarativeGeoMapType *type = m_supportedMapTypes.at(0);
- m_activeMapType = type;
- m_map->setActiveMapType(type->mapType());
- } else {
+ if (m_activeMapType && m_plugin->name().toLatin1() == m_activeMapType->mapType().pluginName()) {
m_map->setActiveMapType(m_activeMapType->mapType());
+ } else {
+ if (m_activeMapType)
+ m_activeMapType->deleteLater();
+
+ if (!m_supportedMapTypes.isEmpty()) {
+ m_activeMapType = m_supportedMapTypes.at(0);
+ m_map->setActiveMapType(m_activeMapType->mapType());
+ } else {
+ m_activeMapType = new QDeclarativeGeoMapType(QGeoMapType(QGeoMapType::NoMap,
+ tr("No Map"),
+ tr("No Map"), false, false, 0, QByteArrayLiteral("")), this);
+ }
}
// Update camera capabilities
@@ -747,32 +759,50 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
// Map tiles are built in this call. m_map->minimumZoom() becomes operational
// after this has been called at least once, after creation.
-
+ // However, getting into the following block may fire a copyrightsChanged that would get lost,
+ // as the connections are set up after.
+ QString copyrightString;
+ QImage copyrightImage;
if (!m_initialized && width() > 0 && height() > 0) {
+ QMetaObject::Connection copyrightStringCatcherConnection =
+ connect(m_map.data(),
+ QOverload<const QString &>::of(&QGeoMap::copyrightsChanged),
+ [&copyrightString](const QString &copy){ copyrightString = copy; });
+ QMetaObject::Connection copyrightImageCatcherConnection =
+ connect(m_map.data(),
+ QOverload<const QImage &>::of(&QGeoMap::copyrightsChanged),
+ [&copyrightImage](const QImage &copy){ copyrightImage = copy; });
m_map->setViewportSize(QSize(width(), height()));
initialize();
+ QObject::disconnect(copyrightStringCatcherConnection);
+ QObject::disconnect(copyrightImageCatcherConnection);
}
m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this);
m_copyrights->onCopyrightsStyleSheetChanged(m_map->copyrightsStyleSheet());
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QImage)),
m_copyrights.data(), SLOT(copyrightsChanged(QImage)));
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QImage)),
this, SIGNAL(copyrightsChanged(QImage)));
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QString)),
m_copyrights.data(), SLOT(copyrightsChanged(QString)));
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
+ connect(m_map.data(), SIGNAL(copyrightsChanged(QString)),
this, SIGNAL(copyrightsChanged(QString)));
- connect(m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
+ if (!copyrightString.isEmpty())
+ emit m_map.data()->copyrightsChanged(copyrightString);
+ else if (!copyrightImage.isNull())
+ emit m_map.data()->copyrightsChanged(copyrightImage);
+
+ connect(m_map.data(), SIGNAL(copyrightsStyleSheetChanged(QString)),
m_copyrights.data(), SLOT(onCopyrightsStyleSheetChanged(QString)));
connect(m_copyrights.data(), SIGNAL(linkActivated(QString)),
this, SIGNAL(copyrightLinkActivated(QString)));
- connect(m_map, &QGeoMap::sgNodeChanged, this, &QQuickItem::update);
- connect(m_map, &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged);
+ connect(m_map.data(), &QGeoMap::sgNodeChanged, this, &QQuickItem::update);
+ connect(m_map.data(), &QGeoMap::cameraCapabilitiesChanged, this, &QDeclarativeGeoMap::onCameraCapabilitiesChanged);
// set visibility of copyright notice
m_copyrights->setCopyrightsVisible(m_copyrightsVisible);
@@ -788,7 +818,7 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
// Any map items that were added before the plugin was ready
// need to have setMap called again
- foreach (const QPointer<QDeclarativeGeoMapItemBase> &item, m_mapItems) {
+ for (const QPointer<QDeclarativeGeoMapItemBase> &item : qAsConst(m_mapItems)) {
if (item) {
item->setMap(this, m_map);
m_map->addMapItem(item.data()); // m_map filters out what is not supported.
@@ -808,8 +838,11 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
// All map parameters that were added before the plugin was ready
// need to be added to m_map
- for (QDeclarativeGeoMapParameter *p : m_mapParameters)
+ for (QDeclarativeGeoMapParameter *p : qAsConst(m_mapParameters))
m_map->addParameter(p);
+
+ if (m_initialized)
+ update();
}
/*!
@@ -841,7 +874,7 @@ void QDeclarativeGeoMap::setMinimumZoomLevel(qreal minimumZoomLevel, bool userSe
m_gestureArea->setMinimumZoomLevel(minimumZoomLevel);
- if (zoomLevel() < minimumZoomLevel)
+ if (zoomLevel() < minimumZoomLevel && (m_gestureArea->enabled() || !m_cameraCapabilities.overzoomEnabled()))
setZoomLevel(minimumZoomLevel);
if (oldMinimumZoomLevel != minimumZoomLevel)
@@ -884,7 +917,7 @@ void QDeclarativeGeoMap::setMaximumZoomLevel(qreal maximumZoomLevel, bool userSe
m_gestureArea->setMaximumZoomLevel(maximumZoomLevel);
- if (zoomLevel() > maximumZoomLevel)
+ if (zoomLevel() > maximumZoomLevel && (m_gestureArea->enabled() || !m_cameraCapabilities.overzoomEnabled()))
setZoomLevel(maximumZoomLevel);
if (oldMaximumZoomLevel != maximumZoomLevel)
@@ -912,10 +945,27 @@ qreal QDeclarativeGeoMap::maximumZoomLevel() const
This property holds the zoom level for the map.
Larger values for the zoom level provide more detail. Zoom levels
- are always non-negative. The default value is 8.0.
+ are always non-negative. The default value is 8.0. Depending on the plugin in use,
+ values outside the [minimumZoomLevel, maximumZoomLevel] range, which represent the range for which
+ tiles are available, may be accepted, or clamped.
*/
void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel)
{
+ return setZoomLevel(zoomLevel, m_cameraCapabilities.overzoomEnabled());
+}
+
+/*!
+ \internal
+
+ Sets the zoom level.
+ Larger values for the zoom level provide more detail. Zoom levels
+ are always non-negative. The default value is 8.0. Values outside the
+ [minimumZoomLevel, maximumZoomLevel] range, which represent the range for which
+ tiles are available, can be accepted or clamped by setting the overzoom argument
+ to true or false respectively.
+*/
+void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel, bool overzoom)
+{
if (m_cameraData.zoomLevel() == zoomLevel || zoomLevel < 0)
return;
@@ -923,7 +973,9 @@ void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel)
bool centerHasChanged = false;
if (m_initialized) {
- m_cameraData.setZoomLevel(qBound(minimumZoomLevel(), zoomLevel, maximumZoomLevel()));
+ m_cameraData.setZoomLevel(qBound<qreal>(overzoom ? m_map->minimumZoom() : minimumZoomLevel(),
+ zoomLevel,
+ overzoom ? 30 : maximumZoomLevel()));
m_maximumViewportLatitude = m_map->maximumCenterLatitudeAtZoom(m_cameraData);
QGeoCoordinate coord = m_cameraData.center();
coord.setLatitude(qBound(-m_maximumViewportLatitude, coord.latitude(), m_maximumViewportLatitude));
@@ -1267,10 +1319,12 @@ QGeoShape QDeclarativeGeoMap::visibleRegion() const
if (!m_map || !width() || !height())
return m_visibleRegion;
- QGeoCoordinate tl = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(0, 0));
- QGeoCoordinate br = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(width(), height()));
+ const QList<QDoubleVector2D> &visibleRegion = m_map->geoProjection().visibleRegion();
+ QGeoPath path;
+ for (const QDoubleVector2D &c: visibleRegion)
+ path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(c));
- return QGeoRectangle(tl, br);
+ return path.boundingGeoRectangle();
}
/*!
@@ -1330,7 +1384,7 @@ QColor QDeclarativeGeoMap::color() const
This property holds whether the map has been successfully initialized and is ready to be used.
Some methods, such as \l fromCoordinate and \l toCoordinate, will not work before the map is ready.
Due to the architecture of the \l Map, it's advised to use the signal emitted for this property
- in place of \l Component.onCompleted, to make sure that everything behaves as expected.
+ in place of \l {QtQml::Component::completed()}{Component.onCompleted}, to make sure that everything behaves as expected.
\since 5.9
*/
@@ -1518,6 +1572,7 @@ void QDeclarativeGeoMap::touchEvent(QTouchEvent *event)
}
}
+#if QT_CONFIG(wheelevent)
/*!
\internal
*/
@@ -1529,6 +1584,7 @@ void QDeclarativeGeoMap::wheelEvent(QWheelEvent *event)
QQuickItem::wheelEvent(event);
}
+#endif
bool QDeclarativeGeoMap::isInteractive()
{
@@ -1696,7 +1752,7 @@ void QDeclarativeGeoMap::clearMapParameters()
QList<QObject *> QDeclarativeGeoMap::mapParameters()
{
QList<QObject *> ret;
- for (QDeclarativeGeoMapParameter *p : m_mapParameters)
+ for (QDeclarativeGeoMapParameter *p : qAsConst(m_mapParameters))
ret << p;
return ret;
}
@@ -1842,10 +1898,16 @@ void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGro
void QDeclarativeGeoMap::setActiveMapType(QDeclarativeGeoMapType *mapType)
{
if (m_activeMapType->mapType() != mapType->mapType()) {
- m_activeMapType = mapType;
- if (m_map)
- m_map->setActiveMapType(mapType->mapType());
- emit activeMapTypeChanged();
+ if (m_map) {
+ if (mapType->mapType().pluginName() == m_plugin->name().toLatin1()) {
+ m_map->setActiveMapType(mapType->mapType());
+ m_activeMapType = mapType;
+ emit activeMapTypeChanged();
+ }
+ } else {
+ m_activeMapType = mapType;
+ emit activeMapTypeChanged();
+ }
}
}
@@ -1862,7 +1924,7 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF
m_gestureArea->setSize(newGeometry.size());
QQuickItem::geometryChanged(newGeometry, oldGeometry);
- if (!m_map || !newGeometry.size().isValid())
+ if (!m_map || newGeometry.size().isEmpty())
return;
m_map->setViewportSize(newGeometry.size().toSize());
@@ -2039,7 +2101,7 @@ bool QDeclarativeGeoMap::sendMouseEvent(QMouseEvent *event)
QQuickItem *grabber = win ? win->mouseGrabberItem() : 0;
bool stealEvent = m_gestureArea->isActive();
- if ((stealEvent || contains(localPos)) && (!grabber || !grabber->keepMouseGrab())) {
+ if ((stealEvent || contains(localPos)) && (!grabber || (!grabber->keepMouseGrab() && !grabber->keepTouchGrab()))) {
QScopedPointer<QMouseEvent> mouseEvent(QQuickWindowPrivate::cloneMouseEvent(event, &localPos));
mouseEvent->setAccepted(false);
@@ -2060,7 +2122,7 @@ bool QDeclarativeGeoMap::sendMouseEvent(QMouseEvent *event)
stealEvent = m_gestureArea->isActive();
grabber = win ? win->mouseGrabberItem() : 0;
- if (grabber && stealEvent && !grabber->keepMouseGrab() && grabber != this)
+ if (grabber && stealEvent && !grabber->keepMouseGrab() && !grabber->keepTouchGrab() && grabber != this)
grabMouse();
if (stealEvent) {
@@ -2077,11 +2139,12 @@ bool QDeclarativeGeoMap::sendMouseEvent(QMouseEvent *event)
bool QDeclarativeGeoMap::sendTouchEvent(QTouchEvent *event)
{
- const QQuickPointerDevice *touchDevice = QQuickPointerDevice::touchDevice(event->device());
+ QQuickPointerDevice *touchDevice = QQuickPointerDevice::touchDevice(event->device());
const QTouchEvent::TouchPoint &point = event->touchPoints().first();
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window());
- auto touchPointGrabberItem = [touchDevice](const QTouchEvent::TouchPoint &point) -> QQuickItem* {
- if (QQuickEventPoint *eventPointer = touchDevice->pointerEvent()->pointById(point.id()))
+ auto touchPointGrabberItem = [touchDevice, windowPriv](const QTouchEvent::TouchPoint &point) -> QQuickItem* {
+ if (QQuickEventPoint *eventPointer = windowPriv->pointerEventInstance(touchDevice)->pointById(point.id()))
return eventPointer->grabber();
return nullptr;
};
diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h
index da430ce5..f07a2e7f 100644
--- a/src/location/declarativemaps/qdeclarativegeomap_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomap_p.h
@@ -59,7 +59,7 @@
#include <QtCore/QList>
#include <QtCore/QPointer>
#include <QtGui/QColor>
-#include <QtPositioning/qgeoshape.h>
+#include <QtPositioning/qgeorectangle.h>
#include <QtLocation/private/qgeomap_p.h>
QT_BEGIN_NAMESPACE
@@ -214,7 +214,9 @@ protected:
void mouseUngrabEvent() Q_DECL_OVERRIDE ;
void touchUngrabEvent() Q_DECL_OVERRIDE;
void touchEvent(QTouchEvent *event) Q_DECL_OVERRIDE ;
+#if QT_CONFIG(wheelevent)
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE ;
+#endif
bool childMouseEventFilter(QQuickItem *item, QEvent *event) Q_DECL_OVERRIDE;
bool sendMouseEvent(QMouseEvent *event);
@@ -226,6 +228,8 @@ protected:
void setError(QGeoServiceProvider::Error error, const QString &errorString);
void initialize();
+ void setZoomLevel(qreal zoomLevel, bool overzoom);
+
private Q_SLOTS:
void mappingManagerInitialized();
void pluginReady();
@@ -248,7 +252,7 @@ private:
QList<QDeclarativeGeoMapType *> m_supportedMapTypes;
QList<QDeclarativeGeoMapItemView *> m_mapViews;
QQuickGeoMapGestureArea *m_gestureArea;
- QGeoMap *m_map;
+ QPointer<QGeoMap> m_map;
QPointer<QDeclarativeGeoMapCopyrightNotice> m_copyrights;
QList<QPointer<QDeclarativeGeoMapItemBase> > m_mapItems;
QList<QPointer<QDeclarativeGeoMapItemGroup> > m_mapItemGroups;
diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
index fdfb645a..1101eb18 100644
--- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
@@ -169,7 +169,11 @@ void QDeclarativeGeoMapCopyrightNotice::setStyleSheet(const QString &styleSheet)
if (!m_html.isEmpty() && m_copyrightsHtml) {
delete m_copyrightsHtml;
createCopyright();
+#if QT_CONFIG(texthtmlparser)
m_copyrightsHtml->setHtml(m_html);
+#else
+ m_copyrightsHtml->setPlainText(m_html);
+#endif
}
rasterizeHtmlAndUpdate();
emit styleSheetChanged(m_styleSheet);
@@ -231,8 +235,10 @@ void QDeclarativeGeoMapCopyrightNotice::rasterizeHtmlAndUpdate()
void QDeclarativeGeoMapCopyrightNotice::createCopyright()
{
m_copyrightsHtml = new QTextDocument(this);
+#if QT_CONFIG(cssparser)
if (!m_styleSheet.isEmpty())
m_copyrightsHtml->setDefaultStyleSheet(m_styleSheet);
+#endif
// The default 4 makes the copyright too wide and tall.
m_copyrightsHtml->setDocumentMargin(0);
@@ -289,12 +295,20 @@ void QDeclarativeGeoMapCopyrightNotice::copyrightsChanged(const QString &copyrig
// Divfy, so we can style the background. The extra <span> is a
// workaround to QTBUG-58838 and should be removed when it gets fixed.
+#if QT_CONFIG(texthtmlparser)
m_html = QStringLiteral("<div id='copyright-root'><span>") + copyrightsHtml + QStringLiteral("</span></div>");
+#else
+ m_html = copyrightsHtml;
+#endif
if (!m_copyrightsHtml)
createCopyright();
+#if QT_CONFIG(texthtmlparser)
m_copyrightsHtml->setHtml(m_html);
+#else
+ m_copyrightsHtml->setPlainText(m_html);
+#endif
rasterizeHtmlAndUpdate();
}
@@ -307,7 +321,11 @@ void QDeclarativeGeoMapCopyrightNotice::onCopyrightsStyleSheetChanged(const QStr
if (!m_html.isEmpty() && m_copyrightsHtml) {
delete m_copyrightsHtml;
createCopyright();
+#if QT_CONFIG(texthtmlparser)
m_copyrightsHtml->setHtml(m_html);
+#else
+ m_copyrightsHtml->setPlainText(m_html);
+#endif
}
rasterizeHtmlAndUpdate();
emit styleSheetChanged(m_styleSheet);
diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
index 5a10f39f..cb5cce9a 100644
--- a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp
@@ -139,6 +139,7 @@ QDeclarativeGeoMapQuickItem::QDeclarativeGeoMapQuickItem(QQuickItem *parent)
opacityContainer_ = new QQuickItem(this);
opacityContainer_->setParentItem(this);
opacityContainer_->setFlag(ItemHasContents, true);
+ setFiltersChildMouseEvents(true);
}
QDeclarativeGeoMapQuickItem::~QDeclarativeGeoMapQuickItem() {}
@@ -158,7 +159,7 @@ QDeclarativeGeoMapQuickItem::~QDeclarativeGeoMapQuickItem() {}
*/
void QDeclarativeGeoMapQuickItem::setCoordinate(const QGeoCoordinate &coordinate)
{
- if (coordinate_ == coordinate)
+ if (coordinate_ == coordinate || !coordinate.isValid())
return;
coordinate_ = coordinate;
@@ -181,6 +182,20 @@ void QDeclarativeGeoMapQuickItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
polishAndUpdate();
}
}
+// See QQuickMultiPointTouchArea::childMouseEventFilter for reference
+bool QDeclarativeGeoMapQuickItem::childMouseEventFilter(QQuickItem *receiver, QEvent *event)
+{
+ if (isEnabled() && isVisible()) {
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::TouchBegin:
+ dragStartCoordinate_ = coordinate_;
+ default:
+ break;
+ }
+ }
+ return QQuickItem::childMouseEventFilter(receiver, event);
+}
/*!
\internal
@@ -195,10 +210,19 @@ void QDeclarativeGeoMapQuickItem::geometryChanged(const QRectF &newGeometry, con
QGeoCoordinate newCoordinate;
// with zoomLevel set the anchorPoint has to be factored into the transformation to properly transform around it.
- if (zoomLevel_ != 0.0)
- newCoordinate = map()->geoProjection().itemPositionToCoordinate(QDoubleVector2D(x(), y()), false);
- else
+ if (zoomLevel_ != 0.0) {
+ // When dragStartCoordinate_ can't be projected to screen, dragging must be disabled.
+ if (!map()->geoProjection().isProjectable(map()->geoProjection().geoToWrappedMapProjection(dragStartCoordinate_)))
+ return;
+
+ QDoubleVector2D pos = map()->geoProjection().coordinateToItemPosition(dragStartCoordinate_, false);
+ // oldGeometry.topLeft() is always intended to be (0,0), even when for some reason it's not.
+ pos.setX(pos.x() + newGeometry.topLeft().x());
+ pos.setY(pos.y() + newGeometry.topLeft().y());
+ newCoordinate = map()->geoProjection().itemPositionToCoordinate(pos, false);
+ } else {
newCoordinate = map()->geoProjection().itemPositionToCoordinate(QDoubleVector2D(x(), y()) + QDoubleVector2D(anchorPoint_), false);
+ }
if (newCoordinate.isValid())
setCoordinate(newCoordinate);
@@ -367,7 +391,7 @@ void QDeclarativeGeoMapQuickItem::updatePolish()
matrix_->appendToItem(opacityContainer_);
}
matrix_->setMatrix(map()->geoProjection().quickItemTransformation(coordinate(), anchorPoint_, zoomLevel_));
- setPositionOnMap(coordinate(), QPointF(0,0));
+ setPosition(QPointF(0,0));
} else {
if (matrix_)
matrix_->setMatrix(QMatrix4x4());
diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
index cce94d85..2035a997 100644
--- a/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapquickitem_p.h
@@ -108,6 +108,7 @@ Q_SIGNALS:
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void updatePolish() Q_DECL_OVERRIDE;
+ bool childMouseEventFilter(QQuickItem *item, QEvent *event) Q_DECL_OVERRIDE;
protected Q_SLOTS:
virtual void afterChildrenChanged() Q_DECL_OVERRIDE;
@@ -115,6 +116,7 @@ protected Q_SLOTS:
private:
qreal scaleFactor();
+ QGeoCoordinate dragStartCoordinate_;
QGeoCoordinate coordinate_;
QGeoRectangle geoshape_;
QPointer<QQuickItem> sourceItem_;
diff --git a/src/location/declarativemaps/qdeclarativegeoroute.cpp b/src/location/declarativemaps/qdeclarativegeoroute.cpp
index bce0af80..039b1297 100644
--- a/src/location/declarativemaps/qdeclarativegeoroute.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroute.cpp
@@ -147,7 +147,7 @@ qreal QDeclarativeGeoRoute::distance() const
}
/*!
- \qmlproperty QJSValue QtLocation::Route::path
+ \qmlproperty list<coordinate> QtLocation::Route::path
Read-only property which holds the geographical coordinates of this route.
Coordinates are listed in the order in which they would be traversed by someone
diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
index 8787271e..94bd63c8 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp
@@ -36,7 +36,7 @@
#include "qdeclarativegeoroutemodel_p.h"
#include "qdeclarativegeoroute_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include "locationvaluetypehelper_p.h"
#include <QtCore/QCoreApplication>
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
geographic routes from a backend provider. Routes include data about driving
directions between two points, walking directions with multiple waypoints,
and various other similar concepts. It functions much like other Model
- types in QML (see for example \l {Models and Views in Qt Quick#ListModel}{ListModel} and
+ types in QML (see for example \l {Models and Views in Qt Quick#Models}{ListModel} and
\l XmlListModel), and interacts with views such as \l MapItemView, and \l{ListView}.
Like \l Map and \l GeocodeModel, all the data for a RouteModel to work comes
@@ -764,7 +764,7 @@ void QDeclarativeGeoRouteQuery::setNumberAlternativeRoutes(int numberAlternative
}
/*!
- \qmlproperty QJSValue RouteQuery::waypoints
+ \qmlproperty list<coordinate> RouteQuery::waypoints
The waypoint coordinates of the desired route.
diff --git a/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp b/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp
index 77a8a41a..dbeaa62c 100644
--- a/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp
+++ b/src/location/declarativemaps/qdeclarativegeoroutesegment.cpp
@@ -128,7 +128,7 @@ QDeclarativeGeoManeuver *QDeclarativeGeoRouteSegment::maneuver() const
}
/*!
- \qmlproperty QJSValue QtLocation::RouteSegment::path
+ \qmlproperty list<coordinate> QtLocation::RouteSegment::path
Read-only property which holds the geographical coordinates of this segment.
Coordinates are listed in the order in which they would be traversed by someone
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index 857aec41..daa1a9fc 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -36,7 +36,7 @@
#include "qdeclarativepolygonmapitem_p.h"
#include "qlocationutils_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include "locationvaluetypehelper_p.h"
#include <QtLocation/private/qgeomap_p.h>
@@ -141,7 +141,7 @@ QGeoMapPolygonGeometry::QGeoMapPolygonGeometry()
\internal
*/
void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
- const QList<QGeoCoordinate> &path)
+ const QList<QDoubleVector2D> &path)
{
if (!sourceDirty_)
return;
@@ -161,11 +161,8 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
QDoubleVector2D wrappedLeftBound(qInf(), qInf());
// 1)
for (int i = 0; i < path.size(); ++i) {
- const QGeoCoordinate &coord = path.at(i);
- if (!coord.isValid())
- continue;
-
- QDoubleVector2D wrappedProjection = map.geoProjection().wrapMapProjection(map.geoProjection().geoToMapProjection(coord));
+ const QDoubleVector2D &coord = path.at(i);
+ QDoubleVector2D wrappedProjection = map.geoProjection().wrapMapProjection(coord);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -193,7 +190,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
c2t::clip2tri clipper;
clipper.addSubjectPath(QClipperUtils::qListToPath(wrappedPath), true);
clipper.addClipPolygon(QClipperUtils::qListToPath(visibleRegion));
- Paths res = clipper.execute(c2t::clip2tri::Intersection, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
+ Paths res = clipper.execute(c2t::clip2tri::Intersection, QtClipperLib::pftEvenOdd, QtClipperLib::pftEvenOdd);
clippedPaths = QClipperUtils::pathsToQList(res);
// 2.1) update srcOrigin_ and leftBoundWrapped with the point with minimum X
@@ -380,6 +377,7 @@ void QDeclarativePolygonMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *m
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
if (map) {
+ regenerateCache();
geometry_.markSourceDirty();
borderGeometry_.markSourceDirty();
polishAndUpdate();
@@ -437,6 +435,7 @@ void QDeclarativePolygonMapItem::setPath(const QJSValue &value)
geopath_.setPath(pathList);
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
@@ -453,8 +452,11 @@ void QDeclarativePolygonMapItem::setPath(const QJSValue &value)
void QDeclarativePolygonMapItem::addCoordinate(const QGeoCoordinate &coordinate)
{
- geopath_.addCoordinate(coordinate);
+ if (!coordinate.isValid())
+ return;
+ geopath_.addCoordinate(coordinate);
+ updateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
@@ -478,6 +480,7 @@ void QDeclarativePolygonMapItem::removeCoordinate(const QGeoCoordinate &coordina
if (geopath_.path().length() == length)
return;
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
@@ -542,7 +545,7 @@ void QDeclarativePolygonMapItem::updatePolish()
QScopedValueRollback<bool> rollback(updatingGeometry_);
updatingGeometry_ = true;
- geometry_.updateSourcePoints(*map(), geopath_.path());
+ geometry_.updateSourcePoints(*map(), geopathProjected_);
geometry_.updateScreenPoints(*map());
QList<QGeoMapItemGeometry *> geoms;
@@ -550,7 +553,7 @@ void QDeclarativePolygonMapItem::updatePolish()
borderGeometry_.clear();
if (border_.color() != Qt::transparent && border_.width() > 0) {
- QList<QGeoCoordinate> closedPath = geopath_.path();
+ QList<QDoubleVector2D> closedPath = geopathProjected_;
closedPath << closedPath.first();
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
@@ -605,6 +608,29 @@ void QDeclarativePolygonMapItem::afterViewportChanged(const QGeoMapViewportChang
/*!
\internal
*/
+void QDeclarativePolygonMapItem::regenerateCache()
+{
+ if (!map())
+ return;
+ geopathProjected_.clear();
+ geopathProjected_.reserve(geopath_.path().size());
+ for (const QGeoCoordinate &c : geopath_.path())
+ geopathProjected_ << map()->geoProjection().geoToMapProjection(c);
+}
+
+/*!
+ \internal
+*/
+void QDeclarativePolygonMapItem::updateCache()
+{
+ if (!map())
+ return;
+ geopathProjected_ << map()->geoProjection().geoToMapProjection(geopath_.path().last());
+}
+
+/*!
+ \internal
+*/
bool QDeclarativePolygonMapItem::contains(const QPointF &point) const
{
return (geometry_.contains(point) || borderGeometry_.contains(point));
@@ -625,7 +651,7 @@ QGeoMap::ItemType QDeclarativePolygonMapItem::itemType() const
*/
void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- if (updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
+ if (!map() || !geopath_.isValid() || updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
return;
}
@@ -640,6 +666,7 @@ void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, cons
return;
geopath_.translate(offsetLati, offsetLongi);
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
borderGeometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
index 9a46bb2c..a928ae39 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
@@ -68,7 +68,7 @@ public:
inline void setAssumeSimple(bool value) { assumeSimple_ = value; }
void updateSourcePoints(const QGeoMap &map,
- const QList<QGeoCoordinate> &path);
+ const QList<QDoubleVector2D> &path);
void updateScreenPoints(const QGeoMap &map);
@@ -122,9 +122,11 @@ protected Q_SLOTS:
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
private:
- void pathPropertyChanged();
+ void regenerateCache();
+ void updateCache();
QGeoPath geopath_;
+ QList<QDoubleVector2D> geopathProjected_;
QDeclarativeMapLineProperties border_;
QColor color_;
bool dirtyMaterial_;
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index cdc0175e..aedb9811 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -36,7 +36,7 @@
#include "qdeclarativepolylinemapitem_p.h"
#include "qlocationutils_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include "locationvaluetypehelper_p.h"
#include "qdoublevector2d_p.h"
#include <QtLocation/private/qgeomap_p.h>
@@ -179,7 +179,7 @@ QGeoMapPolylineGeometry::QGeoMapPolylineGeometry()
}
QList<QList<QDoubleVector2D> > QGeoMapPolylineGeometry::clipPath(const QGeoMap &map,
- const QList<QGeoCoordinate> &path,
+ const QList<QDoubleVector2D> &path,
QDoubleVector2D &leftBoundWrapped)
{
/*
@@ -202,11 +202,8 @@ QList<QList<QDoubleVector2D> > QGeoMapPolylineGeometry::clipPath(const QGeoMap &
QDoubleVector2D wrappedLeftBound(qInf(), qInf());
// 1)
for (int i = 0; i < path.size(); ++i) {
- const QGeoCoordinate &coord = path.at(i);
- if (!coord.isValid())
- continue;
-
- QDoubleVector2D wrappedProjection = map.geoProjection().wrapMapProjection(map.geoProjection().geoToMapProjection(coord));
+ const QDoubleVector2D &coord = path.at(i);
+ QDoubleVector2D wrappedProjection = map.geoProjection().wrapMapProjection(coord);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -310,7 +307,7 @@ void QGeoMapPolylineGeometry::pathToScreen(const QGeoMap &map,
\internal
*/
void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
- const QList<QGeoCoordinate> &path,
+ const QList<QDoubleVector2D> &path,
const QGeoCoordinate geoLeftBound)
{
if (!sourceDirty_)
@@ -556,6 +553,7 @@ void QDeclarativePolylineMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
if (map) {
+ regenerateCache();
geometry_.markSourceDirty();
polishAndUpdate();
}
@@ -618,6 +616,7 @@ void QDeclarativePolylineMapItem::setPathFromGeoList(const QList<QGeoCoordinate>
geopath_.setPath(path);
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
emit pathChanged();
@@ -646,8 +645,12 @@ int QDeclarativePolylineMapItem::pathLength() const
*/
void QDeclarativePolylineMapItem::addCoordinate(const QGeoCoordinate &coordinate)
{
+ if (!coordinate.isValid())
+ return;
+
geopath_.addCoordinate(coordinate);
+ updateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
emit pathChanged();
@@ -669,6 +672,7 @@ void QDeclarativePolylineMapItem::insertCoordinate(int index, const QGeoCoordina
geopath_.insertCoordinate(index, coordinate);
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
emit pathChanged();
@@ -691,6 +695,7 @@ void QDeclarativePolylineMapItem::replaceCoordinate(int index, const QGeoCoordin
geopath_.replaceCoordinate(index, coordinate);
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
emit pathChanged();
@@ -741,6 +746,8 @@ void QDeclarativePolylineMapItem::removeCoordinate(const QGeoCoordinate &coordin
geopath_.removeCoordinate(coordinate);
if (geopath_.path().length() == length)
return;
+
+ regenerateCache();
markSourceDirtyAndUpdate();
emit pathChanged();
}
@@ -763,6 +770,7 @@ void QDeclarativePolylineMapItem::removeCoordinate(int index)
geopath_.removeCoordinate(index);
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
emit pathChanged();
@@ -792,7 +800,7 @@ QDeclarativeMapLineProperties *QDeclarativePolylineMapItem::line()
*/
void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- if (updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
+ if (!map() || !geopath_.isValid() || updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
return;
}
@@ -807,6 +815,7 @@ void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, con
return;
geopath_.translate(offsetLati, offsetLongi);
+ regenerateCache();
geometry_.setPreserveGeometry(true, geopath_.boundingGeoRectangle().topLeft());
markSourceDirtyAndUpdate();
emit pathChanged();
@@ -830,6 +839,29 @@ void QDeclarativePolylineMapItem::afterViewportChanged(const QGeoMapViewportChan
/*!
\internal
*/
+void QDeclarativePolylineMapItem::regenerateCache()
+{
+ if (!map())
+ return;
+ geopathProjected_.clear();
+ geopathProjected_.reserve(geopath_.path().size());
+ for (const QGeoCoordinate &c : geopath_.path())
+ geopathProjected_ << map()->geoProjection().geoToMapProjection(c);
+}
+
+/*!
+ \internal
+*/
+void QDeclarativePolylineMapItem::updateCache()
+{
+ if (!map())
+ return;
+ geopathProjected_ << map()->geoProjection().geoToMapProjection(geopath_.path().last());
+}
+
+/*!
+ \internal
+*/
void QDeclarativePolylineMapItem::updatePolish()
{
if (!map() || geopath_.path().length() == 0)
@@ -838,7 +870,7 @@ void QDeclarativePolylineMapItem::updatePolish()
QScopedValueRollback<bool> rollback(updatingGeometry_);
updatingGeometry_ = true;
- geometry_.updateSourcePoints(*map(), geopath_.path(), geopath_.boundingGeoRectangle().topLeft());
+ geometry_.updateSourcePoints(*map(), geopathProjected_, geopath_.boundingGeoRectangle().topLeft());
geometry_.updateScreenPoints(*map(), line_.width());
setWidth(geometry_.sourceBoundingBox().width());
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
index 55703258..ec57c980 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
@@ -91,7 +91,7 @@ public:
QGeoMapPolylineGeometry();
void updateSourcePoints(const QGeoMap &map,
- const QList<QGeoCoordinate> &path,
+ const QList<QDoubleVector2D> &path,
const QGeoCoordinate geoLeftBound);
void updateScreenPoints(const QGeoMap &map,
@@ -99,7 +99,7 @@ public:
protected:
QList<QList<QDoubleVector2D> > clipPath(const QGeoMap &map,
- const QList<QGeoCoordinate> &path,
+ const QList<QDoubleVector2D> &path,
QDoubleVector2D &leftBoundWrapped);
void pathToScreen(const QGeoMap &map,
@@ -162,9 +162,11 @@ protected Q_SLOTS:
virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) Q_DECL_OVERRIDE;
private:
- void pathPropertyChanged();
+ void regenerateCache();
+ void updateCache();
QGeoPath geopath_;
+ QList<QDoubleVector2D> geopathProjected_;
QDeclarativeMapLineProperties line_;
QColor color_;
bool dirtyMaterial_;
diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
index 1bfbf1fd..79750416 100644
--- a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
@@ -134,8 +134,10 @@ QDeclarativeRectangleMapItem::~QDeclarativeRectangleMapItem()
void QDeclarativeRectangleMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
{
QDeclarativeGeoMapItemBase::setMap(quickMap,map);
- if (map)
- markSourceDirtyAndUpdate();
+ if (!map)
+ return;
+ updatePath();
+ markSourceDirtyAndUpdate();
}
/*!
@@ -167,6 +169,7 @@ void QDeclarativeRectangleMapItem::setTopLeft(const QGeoCoordinate &topLeft)
return;
rectangle_.setTopLeft(topLeft);
+ updatePath();
markSourceDirtyAndUpdate();
emit topLeftChanged(topLeft);
}
@@ -198,6 +201,7 @@ void QDeclarativeRectangleMapItem::setBottomRight(const QGeoCoordinate &bottomRi
return;
rectangle_.setBottomRight(bottomRight);
+ updatePath();
markSourceDirtyAndUpdate();
emit bottomRightChanged(bottomRight);
}
@@ -274,14 +278,8 @@ void QDeclarativeRectangleMapItem::updatePolish()
QScopedValueRollback<bool> rollback(updatingGeometry_);
updatingGeometry_ = true;
- QList<QGeoCoordinate> path;
- path << rectangle_.topLeft();
- path << QGeoCoordinate(rectangle_.topLeft().latitude(), rectangle_.bottomRight().longitude());
- path << rectangle_.bottomRight();
- path << QGeoCoordinate(rectangle_.bottomRight().latitude(), rectangle_.topLeft().longitude());
-
geometry_.setPreserveGeometry(true, rectangle_.topLeft());
- geometry_.updateSourcePoints(*map(), path);
+ geometry_.updateSourcePoints(*map(), pathMercator_);
geometry_.updateScreenPoints(*map());
QList<QGeoMapItemGeometry *> geoms;
@@ -289,7 +287,7 @@ void QDeclarativeRectangleMapItem::updatePolish()
borderGeometry_.clear();
if (border_.color() != Qt::transparent && border_.width() > 0) {
- QList<QGeoCoordinate> closedPath = path;
+ QList<QDoubleVector2D> closedPath = pathMercator_;
closedPath << closedPath.first();
borderGeometry_.setPreserveGeometry(true, rectangle_.topLeft());
@@ -352,9 +350,25 @@ QGeoMap::ItemType QDeclarativeRectangleMapItem::itemType() const
/*!
\internal
*/
+void QDeclarativeRectangleMapItem::updatePath()
+{
+ if (!map())
+ return;
+ pathMercator_.clear();
+ pathMercator_ << map()->geoProjection().geoToMapProjection(rectangle_.topLeft());
+ pathMercator_ << map()->geoProjection().geoToMapProjection(
+ QGeoCoordinate(rectangle_.topLeft().latitude(), rectangle_.bottomRight().longitude()));
+ pathMercator_ << map()->geoProjection().geoToMapProjection(rectangle_.bottomRight());
+ pathMercator_ << map()->geoProjection().geoToMapProjection(
+ QGeoCoordinate(rectangle_.bottomRight().latitude(), rectangle_.topLeft().longitude()));
+}
+
+/*!
+ \internal
+*/
void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
- if (updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
+ if (!map() || !rectangle_.isValid() || updatingGeometry_ || newGeometry.topLeft() == oldGeometry.topLeft()) {
QDeclarativeGeoMapItemBase::geometryChanged(newGeometry, oldGeometry);
return;
}
@@ -369,6 +383,7 @@ void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, co
return;
rectangle_.translate(offsetLati, offsetLongi);
+ updatePath();
geometry_.setPreserveGeometry(true, rectangle_.topLeft());
borderGeometry_.setPreserveGeometry(true, rectangle_.topLeft());
markSourceDirtyAndUpdate();
diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h b/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h
index b65db813..ca7ca9b7 100644
--- a/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativerectanglemapitem_p.h
@@ -53,6 +53,7 @@
#include <QtLocation/private/qgeomapitemgeometry_p.h>
#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
#include <QSGGeometryNode>
#include <QSGFlatColorMaterial>
@@ -97,6 +98,7 @@ Q_SIGNALS:
void colorChanged(const QColor &color);
protected:
+ void updatePath();
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void updatePolish() Q_DECL_OVERRIDE;
@@ -112,6 +114,7 @@ private:
QGeoMapPolygonGeometry geometry_;
QGeoMapPolylineGeometry borderGeometry_;
bool updatingGeometry_;
+ QList<QDoubleVector2D> pathMercator_;
};
//////////////////////////////////////////////////////////////////////
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
index c0dbe0ad..a40afd68 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp
+++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
@@ -37,11 +37,13 @@
#include "qquickgeomapgesturearea_p.h"
#include "qquickgeocoordinateanimation_p.h"
#include "qdeclarativegeomap_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QtGui/QGuiApplication>
#include <QtGui/qevent.h>
+#if QT_CONFIG(wheelevent)
#include <QtGui/QWheelEvent>
+#endif
#include <QtGui/QStyleHints>
#include <QtQml/qqmlinfo.h>
#include <QtQuick/QQuickWindow>
@@ -60,7 +62,7 @@
#define QML_MAP_FLICK_DEFAULTDECELERATION 2500
#define QML_MAP_FLICK_MAXIMUMDECELERATION 10000
-#define QML_MAP_FLICK_VELOCITY_SAMPLE_PERIOD 50
+#define QML_MAP_FLICK_VELOCITY_SAMPLE_PERIOD 38
// FlickThreshold determines how far the "mouse" must have moved
// before we perform a flick.
static const int FlickThreshold = 20;
@@ -69,9 +71,18 @@ static const qreal MinimumFlickVelocity = 75.0;
// Tolerance for detecting two finger sliding start
static const qreal MaximumParallelPosition = 40.0; // in degrees
// Tolerance for detecting parallel sliding
-static const qreal MaximumParallelSlidingAngle = 5.0; // in degrees
+static const qreal MaximumParallelSlidingAngle = 4.0; // in degrees
// Tolerance for starting rotation
static const qreal MinimumRotationStartingAngle = 15.0; // in degrees
+// Tolerance for starting pinch
+static const qreal MinimumPinchDelta = 40; // in pixels
+// Tolerance for starting tilt when sliding vertical
+static const qreal MinimumPanToTiltDelta = 80; // in pixels;
+
+static qreal distanceBetweenTouchPoints(const QPointF &p1, const QPointF &p2)
+{
+ return QLineF(p1, p2).length();
+}
// Returns the new map center after anchoring coordinate to anchorPoint on the screen
// Approach: find the displacement in (wrapped) mercator space, and apply that to the center
@@ -85,10 +96,15 @@ static QGeoCoordinate anchorCoordinateToPoint(QGeoMap &map, const QGeoCoordinate
return map.geoProjection().wrappedMapProjectionToGeo(centerProj + coordProj - anchorProj);
}
+static qreal angleFromPoints(const QPointF &p1, const QPointF &p2)
+{
+ return QLineF(p1, p2).angle();
+}
+
// Keeps it in +- 180
static qreal touchAngle(const QPointF &p1, const QPointF &p2)
{
- qreal angle = QLineF(p1, p2).angle();
+ qreal angle = angleFromPoints(p1, p2);
if (angle > 180)
angle -= 360;
return angle;
@@ -118,7 +134,17 @@ static qreal vectorSize(const QPointF &vector)
return std::sqrt(vector.x() * vector.x() + vector.y() * vector.y());
}
-static bool movingParallel(const QPointF &p1old, const QPointF &p1new, const QPointF &p2old, const QPointF &p2new)
+// This linearizes the angles around 0, and keep it linear around 180, allowing to differentiate
+// touch angles that are supposed to be parallel (0 or 180 depending on what finger goes first)
+static qreal touchAngleTilting(const QPointF &p1, const QPointF &p2)
+{
+ qreal angle = angleFromPoints(p1, p2);
+ if (angle > 270)
+ angle -= 360;
+ return angle;
+}
+
+static bool movingParallelVertical(const QPointF &p1old, const QPointF &p1new, const QPointF &p2old, const QPointF &p2new)
{
if (!pointDragged(p1old, p1new) || !pointDragged(p2old, p2new))
return false;
@@ -130,8 +156,8 @@ static bool movingParallel(const QPointF &p1old, const QPointF &p1new, const QPo
if (v1v2size < vectorSize(v1) || v1v2size < vectorSize(v2)) // going in opposite directions
return false;
- const qreal newAngle = touchAngle(p1new, p2new);
- const qreal oldAngle = touchAngle(p1old, p2old);
+ const qreal newAngle = touchAngleTilting(p1new, p2new);
+ const qreal oldAngle = touchAngleTilting(p1old, p2old);
const qreal angleDiff = angleDelta(newAngle, oldAngle);
if (qAbs(angleDiff) > MaximumParallelSlidingAngle)
@@ -482,7 +508,7 @@ QQuickGeoMapGestureArea::QQuickGeoMapGestureArea(QDeclarativeGeoMap *map)
/*!
\internal
*/
-void QQuickGeoMapGestureArea::setMap(QGeoMap *map)
+void QQuickGeoMapGestureArea::setMap(QPointer<QGeoMap> map)
{
if (m_map || !map)
return;
@@ -916,6 +942,7 @@ void QQuickGeoMapGestureArea::handleTouchEvent(QTouchEvent *event)
update();
}
+#if QT_CONFIG(wheelevent)
void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event)
{
if (!m_map)
@@ -925,7 +952,9 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event)
const QPointF &preZoomPoint = event->posF();
const double zoomLevelDelta = event->angleDelta().y() * qreal(0.001);
- m_declarativeMap->setZoomLevel(m_declarativeMap->zoomLevel() + zoomLevelDelta);
+ // Gesture area should always honor maxZL, but Map might not.
+ m_declarativeMap->setZoomLevel(qMin<qreal>(m_declarativeMap->zoomLevel() + zoomLevelDelta, maximumZoomLevel()),
+ false);
const QPointF &postZoomPoint = m_map->geoProjection().coordinateToItemPosition(wheelGeoPos, false).toPointF();
if (preZoomPoint != postZoomPoint) // need to re-anchor the wheel geoPos to the event position
@@ -933,14 +962,14 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event)
event->accept();
}
+#endif
/*!
\internal
*/
void QQuickGeoMapGestureArea::clearTouchData()
{
- m_velocityX = 0;
- m_velocityY = 0;
+ m_flickVector = QVector2D();
m_touchPointsCentroid.setX(0);
m_touchPointsCentroid.setY(0);
m_touchCenterCoord.setLongitude(0);
@@ -953,7 +982,7 @@ void QQuickGeoMapGestureArea::clearTouchData()
/*!
\internal
*/
-void QQuickGeoMapGestureArea::updateVelocityList(const QPointF &pos)
+void QQuickGeoMapGestureArea::updateFlickParameters(const QPointF &pos)
{
// Take velocity samples every sufficient period of time, used later to determine the flick
// duration and speed (when mouse is released).
@@ -961,17 +990,40 @@ void QQuickGeoMapGestureArea::updateVelocityList(const QPointF &pos)
if (elapsed >= QML_MAP_FLICK_VELOCITY_SAMPLE_PERIOD) {
elapsed /= 1000.;
- int dyFromLastPos = pos.y() - m_lastPos.y();
- int dxFromLastPos = pos.x() - m_lastPos.x();
+ qreal vel = distanceBetweenTouchPoints(pos, m_lastPos) / elapsed;
+ m_flickVector = (QVector2D(pos) - QVector2D(m_lastPos)).normalized();
+ m_flickVector *= qBound<qreal>(-m_flick.m_maxVelocity, vel, m_flick.m_maxVelocity);
+
m_lastPos = pos;
m_lastPosTime.restart();
- qreal velX = qreal(dxFromLastPos) / elapsed;
- qreal velY = qreal(dyFromLastPos) / elapsed;
- m_velocityX = qBound<qreal>(-m_flick.m_maxVelocity, velX, m_flick.m_maxVelocity);
- m_velocityY = qBound<qreal>(-m_flick.m_maxVelocity, velY, m_flick.m_maxVelocity);
}
}
+void QQuickGeoMapGestureArea::setTouchPointState(const QQuickGeoMapGestureArea::TouchPointState state)
+{
+ m_touchPointState = state;
+}
+
+void QQuickGeoMapGestureArea::setFlickState(const QQuickGeoMapGestureArea::FlickState state)
+{
+ m_flickState = state;
+}
+
+void QQuickGeoMapGestureArea::setTiltState(const QQuickGeoMapGestureArea::TiltState state)
+{
+ m_tiltState = state;
+}
+
+void QQuickGeoMapGestureArea::setRotationState(const QQuickGeoMapGestureArea::RotationState state)
+{
+ m_rotationState = state;
+}
+
+void QQuickGeoMapGestureArea::setPinchState(const QQuickGeoMapGestureArea::PinchState state)
+{
+ m_pinchState = state;
+}
+
/*!
\internal
*/
@@ -1033,29 +1085,29 @@ void QQuickGeoMapGestureArea::touchPointStateMachine()
if (m_allPoints.count() == 1) {
clearTouchData();
startOneTouchPoint();
- m_touchPointState = touchPoints1;
+ setTouchPointState(touchPoints1);
} else if (m_allPoints.count() >= 2) {
clearTouchData();
startTwoTouchPoints();
- m_touchPointState = touchPoints2;
+ setTouchPointState(touchPoints2);
}
break;
case touchPoints1:
if (m_allPoints.count() == 0) {
- m_touchPointState = touchPoints0;
+ setTouchPointState(touchPoints0);
} else if (m_allPoints.count() == 2) {
m_touchCenterCoord = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(m_touchPointsCentroid), false);
startTwoTouchPoints();
- m_touchPointState = touchPoints2;
+ setTouchPointState(touchPoints2);
}
break;
case touchPoints2:
if (m_allPoints.count() == 0) {
- m_touchPointState = touchPoints0;
+ setTouchPointState(touchPoints0);
} else if (m_allPoints.count() == 1) {
m_touchCenterCoord = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(m_touchPointsCentroid), false);
startOneTouchPoint();
- m_touchPointState = touchPoints1;
+ setTouchPointState(touchPoints1);
}
break;
};
@@ -1095,7 +1147,7 @@ void QQuickGeoMapGestureArea::startOneTouchPoint()
void QQuickGeoMapGestureArea::updateOneTouchPoint()
{
m_touchPointsCentroid = mapFromScene(m_allPoints.at(0).scenePos());
- updateVelocityList(m_touchPointsCentroid);
+ updateFlickParameters(m_touchPointsCentroid);
}
/*!
@@ -1114,6 +1166,8 @@ void QQuickGeoMapGestureArea::startTwoTouchPoints()
m_startCoord.setLatitude(m_startCoord.latitude() + startCoord.latitude() -
m_touchCenterCoord.latitude());
m_twoTouchAngleStart = touchAngle(m_sceneStartPoint1, m_sceneStartPoint2); // Initial angle used for calculating rotation
+ m_distanceBetweenTouchPointsStart = distanceBetweenTouchPoints(m_sceneStartPoint1, m_sceneStartPoint2);
+ m_twoTouchPointsCentroidStart = (m_sceneStartPoint1 + m_sceneStartPoint2) / 2;
}
/*!
@@ -1123,11 +1177,9 @@ void QQuickGeoMapGestureArea::updateTwoTouchPoints()
{
QPointF p1 = mapFromScene(m_allPoints.at(0).scenePos());
QPointF p2 = mapFromScene(m_allPoints.at(1).scenePos());
- qreal dx = p1.x() - p2.x();
- qreal dy = p1.y() - p2.y();
- m_distanceBetweenTouchPoints = sqrt(dx * dx + dy * dy);
+ m_distanceBetweenTouchPoints = distanceBetweenTouchPoints(p1, p2);
m_touchPointsCentroid = (p1 + p2) / 2;
- updateVelocityList(m_touchPointsCentroid);
+ updateFlickParameters(m_touchPointsCentroid);
m_twoTouchAngle = touchAngle(p1, p2);
}
@@ -1142,31 +1194,31 @@ void QQuickGeoMapGestureArea::tiltStateMachine()
switch (m_tiltState) {
case tiltInactive:
if (m_allPoints.count() >= 2) {
- if (!isRotationActive() && !isPanActive() && !isPinchActive() && canStartTilt()) {
+ if (!isRotationActive() && !isPinchActive() && canStartTilt()) { // only gesture that can be overridden: pan/flick
m_declarativeMap->setKeepMouseGrab(true);
m_declarativeMap->setKeepTouchGrab(true);
startTilt();
- m_tiltState = tiltActive;
+ setTiltState(tiltActive);
} else {
- m_tiltState = tiltInactiveTwoPoints;
+ setTiltState(tiltInactiveTwoPoints);
}
}
break;
case tiltInactiveTwoPoints:
if (m_allPoints.count() <= 1) {
- m_tiltState = tiltInactive;
+ setTiltState(tiltInactive);
} else {
- if (!isRotationActive() && !isPanActive() && !isPinchActive() && canStartTilt()) {
+ if (!isRotationActive() && !isPinchActive() && canStartTilt()) { // only gesture that can be overridden: pan/flick
m_declarativeMap->setKeepMouseGrab(true);
m_declarativeMap->setKeepTouchGrab(true);
startTilt();
- m_tiltState = tiltActive;
+ setTiltState(tiltActive);
}
}
break;
case tiltActive:
if (m_allPoints.count() <= 1) {
- m_tiltState = tiltInactive;
+ setTiltState(tiltInactive);
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
m_declarativeMap->setKeepTouchGrab(m_preventStealing);
endTilt();
@@ -1191,6 +1243,11 @@ void QQuickGeoMapGestureArea::tiltStateMachine()
}
}
+bool validateTouchAngleForTilting(const qreal angle)
+{
+ return ((qAbs(angle) - 180.0) < MaximumParallelPosition) || (qAbs(angle) < MaximumParallelPosition);
+}
+
/*!
\internal
*/
@@ -1199,8 +1256,9 @@ bool QQuickGeoMapGestureArea::canStartTilt()
if (m_allPoints.count() >= 2) {
QPointF p1 = mapFromScene(m_allPoints.at(0).scenePos());
QPointF p2 = mapFromScene(m_allPoints.at(1).scenePos());
- if (qAbs(m_twoTouchAngle) < MaximumParallelPosition
- && movingParallel(m_sceneStartPoint1, p1, m_sceneStartPoint2, p2)) {
+ if (validateTouchAngleForTilting(m_twoTouchAngle)
+ && movingParallelVertical(m_sceneStartPoint1, p1, m_sceneStartPoint2, p2)
+ && qAbs(m_twoTouchPointsCentroidStart.y() - m_touchPointsCentroid.y()) > MinimumPanToTiltDelta) {
m_pinch.m_event.setCenter(mapFromScene(m_touchPointsCentroid));
m_pinch.m_event.setAngle(m_twoTouchAngle);
m_pinch.m_event.setPoint1(p1);
@@ -1208,7 +1266,7 @@ bool QQuickGeoMapGestureArea::canStartTilt()
m_pinch.m_event.setPointCount(m_allPoints.count());
m_pinch.m_event.setAccepted(true);
emit tiltStarted(&m_pinch.m_event);
- return m_pinch.m_event.accepted();
+ return true;
}
}
return false;
@@ -1219,6 +1277,11 @@ bool QQuickGeoMapGestureArea::canStartTilt()
*/
void QQuickGeoMapGestureArea::startTilt()
{
+ if (isPanActive()) {
+ stopPan();
+ setFlickState(flickInactive);
+ }
+
m_pinch.m_tilt.m_startTouchCentroid = m_touchPointsCentroid;
m_pinch.m_tilt.m_startTilt = m_declarativeMap->tilt();
}
@@ -1278,27 +1341,27 @@ void QQuickGeoMapGestureArea::rotationStateMachine()
m_declarativeMap->setKeepMouseGrab(true);
m_declarativeMap->setKeepTouchGrab(true);
startRotation();
- m_rotationState = rotationActive;
+ setRotationState(rotationActive);
} else {
- m_rotationState = rotationInactiveTwoPoints;
+ setRotationState(rotationInactiveTwoPoints);
}
}
break;
case rotationInactiveTwoPoints:
if (m_allPoints.count() <= 1) {
- m_rotationState = rotationInactive;
+ setRotationState(rotationInactive);
} else {
if (!isTiltActive() && canStartRotation()) {
m_declarativeMap->setKeepMouseGrab(true);
m_declarativeMap->setKeepTouchGrab(true);
startRotation();
- m_rotationState = rotationActive;
+ setRotationState(rotationActive);
}
}
break;
case rotationActive:
if (m_allPoints.count() <= 1) {
- m_rotationState = rotationInactive;
+ setRotationState(rotationInactive);
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
m_declarativeMap->setKeepTouchGrab(m_preventStealing);
endRotation();
@@ -1355,7 +1418,7 @@ bool QQuickGeoMapGestureArea::canStartRotation()
void QQuickGeoMapGestureArea::startRotation()
{
m_pinch.m_rotation.m_startBearing = m_declarativeMap->bearing();
- m_pinch.m_rotation.m_previousTouchAngle = m_twoTouchAngleStart;
+ m_pinch.m_rotation.m_previousTouchAngle = m_twoTouchAngle;
m_pinch.m_rotation.m_totalAngle = 0.0;
}
@@ -1416,27 +1479,27 @@ void QQuickGeoMapGestureArea::pinchStateMachine()
m_declarativeMap->setKeepMouseGrab(true);
m_declarativeMap->setKeepTouchGrab(true);
startPinch();
- m_pinchState = pinchActive;
+ setPinchState(pinchActive);
} else {
- m_pinchState = pinchInactiveTwoPoints;
+ setPinchState(pinchInactiveTwoPoints);
}
}
break;
case pinchInactiveTwoPoints:
if (m_allPoints.count() <= 1) {
- m_pinchState = pinchInactive;
+ setPinchState(pinchInactive);
} else {
if (!isTiltActive() && canStartPinch()) {
m_declarativeMap->setKeepMouseGrab(true);
m_declarativeMap->setKeepTouchGrab(true);
startPinch();
- m_pinchState = pinchActive;
+ setPinchState(pinchActive);
}
}
break;
case pinchActive:
if (m_allPoints.count() <= 1) { // Once started, pinch goes off only when finger(s) are release
- m_pinchState = pinchInactive;
+ setPinchState(pinchInactive);
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
m_declarativeMap->setKeepTouchGrab(m_preventStealing);
endPinch();
@@ -1469,8 +1532,7 @@ bool QQuickGeoMapGestureArea::canStartPinch()
if (m_allPoints.count() >= 2) {
QPointF p1 = mapFromScene(m_allPoints.at(0).scenePos());
QPointF p2 = mapFromScene(m_allPoints.at(1).scenePos());
- if (pointDragged(m_sceneStartPoint1, p1)
- || pointDragged(m_sceneStartPoint2, p2)) {
+ if (qAbs(m_distanceBetweenTouchPoints - m_distanceBetweenTouchPointsStart) > MinimumPinchDelta) {
m_pinch.m_event.setCenter(mapFromScene(m_touchPointsCentroid));
m_pinch.m_event.setAngle(m_twoTouchAngle);
m_pinch.m_event.setPoint1(p1);
@@ -1534,7 +1596,7 @@ void QQuickGeoMapGestureArea::updatePinch()
qreal perPinchMinimumZoomLevel = qMax(m_pinch.m_zoom.m_start - m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_minimum);
qreal perPinchMaximumZoomLevel = qMin(m_pinch.m_zoom.m_start + m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_maximum);
newZoomLevel = qMin(qMax(perPinchMinimumZoomLevel, newZoomLevel), perPinchMaximumZoomLevel);
- m_declarativeMap->setZoomLevel(newZoomLevel);
+ m_declarativeMap->setZoomLevel(qMin<qreal>(newZoomLevel, maximumZoomLevel()), false);
m_pinch.m_zoom.m_previous = newZoomLevel;
}
}
@@ -1572,14 +1634,14 @@ void QQuickGeoMapGestureArea::panStateMachine()
m_startCoord.setLongitude(newStartCoord.longitude());
m_startCoord.setLatitude(newStartCoord.latitude());
m_declarativeMap->setKeepMouseGrab(true);
- m_flickState = panActive;
+ setFlickState(panActive);
}
break;
case panActive:
if (m_allPoints.count() == 0) {
if (!tryStartFlick())
{
- m_flickState = flickInactive;
+ setFlickState(flickInactive);
// mark as inactive for use by camera
if (m_pinchState == pinchInactive && m_rotationState == rotationInactive && m_tiltState == tiltInactive) {
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
@@ -1587,7 +1649,7 @@ void QQuickGeoMapGestureArea::panStateMachine()
}
emit panFinished();
} else {
- m_flickState = flickActive;
+ setFlickState(flickActive);
emit panFinished();
emit flickStarted();
}
@@ -1597,7 +1659,7 @@ void QQuickGeoMapGestureArea::panStateMachine()
if (m_allPoints.count() > 0) { // re touched before movement ended
stopFlick();
m_declarativeMap->setKeepMouseGrab(true);
- m_flickState = panActive;
+ setFlickState(panActive);
}
break;
}
@@ -1655,35 +1717,26 @@ bool QQuickGeoMapGestureArea::tryStartFlick()
if ((m_acceptedGestures & FlickGesture) == 0)
return false;
// if we drag then pause before release we should not cause a flick.
- qreal velocityX = 0.0;
- qreal velocityY = 0.0;
- if (m_lastPosTime.elapsed() < QML_MAP_FLICK_VELOCITY_SAMPLE_PERIOD) {
- velocityY = m_velocityY;
- velocityX = m_velocityX;
- }
- int flickTimeY = 0;
- int flickTimeX = 0;
- int flickPixelsX = 0;
- int flickPixelsY = 0;
- if (qAbs(velocityY) > MinimumFlickVelocity && qAbs(m_touchPointsCentroid.y() - m_sceneStartPoint1.y()) > FlickThreshold) {
- // calculate Y flick animation values
- qreal acceleration = m_flick.m_deceleration;
- if ((velocityY > 0.0f) == (m_flick.m_deceleration > 0.0f))
- acceleration = acceleration * -1.0f;
- flickTimeY = static_cast<int>(-1000 * velocityY / acceleration);
- flickPixelsY = (flickTimeY * velocityY) / (1000.0 * 2);
- }
- if (qAbs(velocityX) > MinimumFlickVelocity && qAbs(m_touchPointsCentroid.x() - m_sceneStartPoint1.x()) > FlickThreshold) {
- // calculate X flick animation values
+ qreal flickSpeed = 0.0;
+ if (m_lastPosTime.elapsed() < QML_MAP_FLICK_VELOCITY_SAMPLE_PERIOD)
+ flickSpeed = m_flickVector.length();
+
+ int flickTime = 0;
+ int flickPixels = 0;
+ QVector2D flickVector;
+
+ if (qAbs(flickSpeed) > MinimumFlickVelocity
+ && distanceBetweenTouchPoints(m_touchPointsCentroid, m_sceneStartPoint1) > FlickThreshold) {
qreal acceleration = m_flick.m_deceleration;
- if ((velocityX > 0.0f) == (m_flick.m_deceleration > 0.0f))
+ if ((flickSpeed > 0.0f) == (m_flick.m_deceleration > 0.0f))
acceleration = acceleration * -1.0f;
- flickTimeX = static_cast<int>(-1000 * velocityX / acceleration);
- flickPixelsX = (flickTimeX * velocityX) / (1000.0 * 2);
+ flickTime = static_cast<int>(-1000 * flickSpeed / acceleration);
+ flickPixels = (flickTime * flickSpeed) / 2000.0;
+ flickVector = m_flickVector.normalized() * flickPixels;
}
- int flickTime = qMax(flickTimeY, flickTimeX);
+
if (flickTime > 0) {
- startFlick(flickPixelsX, flickPixelsY, flickTime);
+ startFlick(flickVector.x(), flickVector.y(), flickTime);
return true;
}
return false;
@@ -1734,9 +1787,8 @@ void QQuickGeoMapGestureArea::stopPan()
if (m_flickState == flickActive) {
stopFlick();
} else if (m_flickState == panActive) {
- m_velocityX = 0;
- m_velocityY = 0;
- m_flickState = flickInactive;
+ m_flickVector = QVector2D();
+ setFlickState(flickInactive);
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
emit panFinished();
emit panActiveChanged();
@@ -1751,8 +1803,7 @@ void QQuickGeoMapGestureArea::stopFlick()
{
if (!m_flick.m_animation)
return;
- m_velocityX = 0;
- m_velocityY = 0;
+ m_flickVector = QVector2D();
if (m_flick.m_animation->isRunning())
m_flick.m_animation->stop();
else
@@ -1763,7 +1814,7 @@ void QQuickGeoMapGestureArea::handleFlickAnimationStopped()
{
m_declarativeMap->setKeepMouseGrab(m_preventStealing);
if (m_flickState == flickActive) {
- m_flickState = flickInactive;
+ setFlickState(flickInactive);
emit flickFinished();
emit panActiveChanged();
m_map->prefetchData();
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea_p.h b/src/location/declarativemaps/qquickgeomapgesturearea_p.h
index 5cafec0d..5daa39cf 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea_p.h
+++ b/src/location/declarativemaps/qquickgeomapgesturearea_p.h
@@ -50,11 +50,13 @@
#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtCore/QPointer>
#include <QtQuick/QQuickItem>
#include <QTouchEvent>
#include <QDebug>
#include <QElapsedTimer>
#include <QtPositioning/qgeocoordinate.h>
+#include <QtGui/QVector2D>
QT_BEGIN_NAMESPACE
@@ -161,7 +163,9 @@ public:
void setFlickDeceleration(qreal deceleration);
void handleTouchEvent(QTouchEvent *event);
+#if QT_CONFIG(wheelevent)
void handleWheelEvent(QWheelEvent *event);
+#endif
void handleMousePressEvent(QMouseEvent *event);
void handleMouseMoveEvent(QMouseEvent *event);
void handleMouseReleaseEvent(QMouseEvent *event);
@@ -174,7 +178,7 @@ public:
void setMaximumZoomLevel(qreal max);
qreal maximumZoomLevel() const;
- void setMap(QGeoMap *map);
+ void setMap(QPointer<QGeoMap> map);
bool preventStealing() const;
void setPreventStealing(bool prevent);
@@ -260,10 +264,10 @@ private Q_SLOTS:
private:
void stopPan();
void clearTouchData();
- void updateVelocityList(const QPointF &pos);
+ void updateFlickParameters(const QPointF &pos);
private:
- QGeoMap *m_map;
+ QPointer<QGeoMap> m_map;
QDeclarativeGeoMap *m_declarativeMap;
bool m_enabled;
@@ -324,12 +328,11 @@ private:
// these are calculated regardless of gesture or number of touch points
- qreal m_velocityX;
- qreal m_velocityY;
+ QVector2D m_flickVector;
QElapsedTimer m_lastPosTime;
QPointF m_lastPos;
- QList<QTouchEvent::TouchPoint> m_allPoints;
- QList<QTouchEvent::TouchPoint> m_touchPoints;
+ QVector<QTouchEvent::TouchPoint> m_allPoints;
+ QVector<QTouchEvent::TouchPoint> m_touchPoints;
QScopedPointer<QTouchEvent::TouchPoint> m_mousePoint;
QPointF m_sceneStartPoint1;
@@ -340,10 +343,13 @@ private:
qreal m_twoTouchAngle;
qreal m_twoTouchAngleStart;
qreal m_distanceBetweenTouchPoints;
+ qreal m_distanceBetweenTouchPointsStart;
+ QPointF m_twoTouchPointsCentroidStart;
QPointF m_touchPointsCentroid;
bool m_preventStealing;
bool m_panEnabled;
+private:
// prototype state machine...
enum TouchPointState
{
@@ -379,6 +385,12 @@ private:
panActive,
flickActive
} m_flickState;
+
+ inline void setTouchPointState(const TouchPointState state);
+ inline void setFlickState(const FlickState state);
+ inline void setTiltState(const TiltState state);
+ inline void setRotationState(const RotationState state);
+ inline void setPinchState(const PinchState state);
};
QT_END_NAMESPACE
diff --git a/src/location/declarativeplaces/qdeclarativecategory.cpp b/src/location/declarativeplaces/qdeclarativecategory.cpp
index c58ec3a2..4161c1a1 100644
--- a/src/location/declarativeplaces/qdeclarativecategory.cpp
+++ b/src/location/declarativeplaces/qdeclarativecategory.cpp
@@ -37,7 +37,7 @@
#include "qdeclarativecategory_p.h"
#include "qdeclarativeplaceicon_p.h"
#include "qdeclarativegeoserviceprovider_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QtQml/QQmlInfo>
#include <QtLocation/QGeoServiceProvider>
diff --git a/src/location/declarativeplaces/qdeclarativeplace.cpp b/src/location/declarativeplaces/qdeclarativeplace.cpp
index 91ef2026..0e1a19aa 100644
--- a/src/location/declarativeplaces/qdeclarativeplace.cpp
+++ b/src/location/declarativeplaces/qdeclarativeplace.cpp
@@ -39,7 +39,7 @@
#include "qdeclarativegeoserviceprovider_p.h"
#include "qdeclarativeplaceattribute_p.h"
#include "qdeclarativeplaceicon_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QMetaObject>
diff --git a/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp b/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
index faf7e418..1920583b 100644
--- a/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
@@ -38,7 +38,7 @@
#include "qdeclarativeplace_p.h"
#include "qdeclarativegeoserviceprovider_p.h"
#include "qdeclarativeplaceuser_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QtQml/QQmlInfo>
#include <QtLocation/QGeoServiceProvider>
diff --git a/src/location/declarativeplaces/qdeclarativeplaceicon.cpp b/src/location/declarativeplaces/qdeclarativeplaceicon.cpp
index 24891138..ba542792 100644
--- a/src/location/declarativeplaces/qdeclarativeplaceicon.cpp
+++ b/src/location/declarativeplaces/qdeclarativeplaceicon.cpp
@@ -35,7 +35,7 @@
****************************************************************************/
#include "qdeclarativeplaceicon_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/QPlaceManager>
diff --git a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
index 3a3faa56..4dfdd25d 100644
--- a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
+++ b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp
@@ -36,7 +36,7 @@
#include "qdeclarativesearchmodelbase_p.h"
#include "qdeclarativeplace_p.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QtCore/QCoreApplication>
#include <QtQml/QQmlInfo>
diff --git a/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
index 31d152db..3450e3ea 100644
--- a/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
@@ -631,6 +631,7 @@ QVariant QDeclarativeSearchResultModel::data(const QModelIndex &index, int role)
case PlaceRole:
if (result.type() == QPlaceSearchResult::PlaceResult)
return QVariant::fromValue(static_cast<QObject *>(m_places.at(index.row())));
+ break;
case SponsoredRole:
if (result.type() == QPlaceSearchResult::PlaceResult) {
QPlaceResult placeResult = result;
diff --git a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
index d832ff40..780eb98a 100644
--- a/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
+++ b/src/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
@@ -38,7 +38,7 @@
#include "qdeclarativesupportedcategoriesmodel_p.h"
#include "qdeclarativeplaceicon_p.h"
#include "qgeoserviceprovider.h"
-#include "error_messages.h"
+#include "error_messages_p.h"
#include <QCoreApplication>
#include <QtQml/QQmlInfo>
diff --git a/src/location/doc/src/plugins/esri.qdoc b/src/location/doc/src/plugins/esri.qdoc
index c19f19dd..7a80d385 100644
--- a/src/location/doc/src/plugins/esri.qdoc
+++ b/src/location/doc/src/plugins/esri.qdoc
@@ -150,6 +150,14 @@ or you can sign up for an \l {http://www.arcgis.com/features/plans/pricing.html}
Note that the texture cache has a hard minimum size which depends on the size of the map viewport
(it must contain enough data to display the tiles currently visible on the display).
This value is the amount of cache to be used in addition to the bare minimum.
+\row
+ \li esri.mapping.prefetching_style
+ \li This parameter allows to provide a hint how tile prefetching is to be performed by the engine. The default value,
+ \tt{TwoNeighbourLayers}, makes the engine prefetch tiles for the layer above and the one below the current tile
+ layer, providing ready tiles when zooming in or out from the current zoom level.
+ \tt{OneNeighbourLayer} only prefetches the one layer closest to the current zoom level.
+ Finally, \tt{NoPrefetching} allows to disable the prefetching, so only tiles that are visible will be fetched.
+ Note that, depending on the active map type, this hint might be ignored.
\endtable
\section2 Directions language
diff --git a/src/location/doc/src/plugins/mapbox.qdoc b/src/location/doc/src/plugins/mapbox.qdoc
index 12c29aee..e962bead 100644
--- a/src/location/doc/src/plugins/mapbox.qdoc
+++ b/src/location/doc/src/plugins/mapbox.qdoc
@@ -138,5 +138,13 @@ The following table lists optional parameters that can be passed to the Mapbox p
viewport (it must contain enough data to display the tiles currently visible on the
display).
This value is the amount of tiles to be cached in addition to the bare minimum.
+\row
+ \li mapbox.mapping.prefetching_style
+ \li This parameter allows to provide a hint how tile prefetching is to be performed by the engine. The default value,
+ \tt{TwoNeighbourLayers}, makes the engine prefetch tiles for the layer above and the one below the current tile
+ layer, providing ready tiles when zooming in or out from the current zoom level.
+ \tt{OneNeighbourLayer} only prefetches the one layer closest to the current zoom level.
+ Finally, \tt{NoPrefetching} allows to disable the prefetching, so only tiles that are visible will be fetched.
+ Note that, depending on the active map type, this hint might be ignored.
\endtable
*/
diff --git a/src/location/doc/src/plugins/mapboxgl.qdoc b/src/location/doc/src/plugins/mapboxgl.qdoc
index 21222792..4084e4c6 100644
--- a/src/location/doc/src/plugins/mapboxgl.qdoc
+++ b/src/location/doc/src/plugins/mapboxgl.qdoc
@@ -53,7 +53,25 @@ The Mapbox GL geo services plugin can be loaded by using the plugin key "mapboxg
Both Mapbox geo services plugins require an access token to access map styles
and tiles hosted by Mapbox. To create a Mapbox account visit \l{https://www.mapbox.com/pricing}.
-\section2 Optional parameters
+\b {Note:} the API for this plugin is introduced in Qt 5.9 as \e {technology preview}.
+
+\section1 Platform Support
+
+Qt Location Mapbox GL Plugin has the following support for platforms:
+
+\list
+ \li Microsoft Windows (win32) - Supported, requires MinGW 5.0+ and ANGLE as OpenGL backend
+ \li Linux X11 - Supported, requires GCC 4.9+
+ \li macOS - Supported
+ \li Android - Supported
+ \li Embedded Linux - Supported, requires GCC 4.9+
+ \li iOS - Supported
+ \li WinRT - Not supported
+\endlist
+
+\section1 Parameters
+
+\section2 Optional plugin parameters
The following table lists optional parameters that can be passed to the Mapbox plugin.
@@ -110,6 +128,133 @@ The following table lists optional parameters that can be passed to the Mapbox p
experimental, and it does not support QQuickItem transformations nor stencil
clipping. It might be also produce rendering artifacts e.g. when adding it
inside a \l{QtQuick::Flipable}{Flipable} item.
+\row
+ \li mapboxgl.mapping.items.insert_before
+ \li Some map items such as \l{QtLocation::MapPolyline}{MapPolyline},
+ \l{QtLocation::MapPolygon}{MapPolygon} and \l{QtLocation::MapRectangle}{MapRectangle}
+ will be rendered after the topmost \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#layers}{layer}
+ of the style. With this parameter set, the map items will be rendered \b before the layer ID
+ specified, unless the layer is not present on the current style, which will fallback
+ to the default behavior. This parameter can be used to display route lines under labels.
+\endtable
+
+\section2 Optional map parameters
+
+The \l{QtLocation::Map}{Map} item using this plugin, can also be customized using \l{QtLocation::MapParameter}{MapParameters},
+allowing runtime changes to the map style and data.
+
+Examples of what can be currently controlled using \l{QtLocation::MapParameter}{MapParameter} are:
+\list
+ \li Hide and show parts of the map, like roads and buildings.
+ \li Change paint properties like color and opacity of various parts of the map.
+ \li Change layout properties like thickness and line joints.
+ \li Add data to the map.
+ \li Add sprites to the map.
+\endlist
+
+With the exception of extrusion and data driven style properties, every property described at the
+\l {https://www.mapbox.com/mapbox-gl-js/style-spec/}{Mapbox Style Specification} can be changed at runtime.
+
+The \l{QtLocation::MapParameter}{MapParameters}, used to control the style of the map at runtime, always
+have a \b type property, followed by user defined properties that try to match the
+\l {https://www.mapbox.com/mapbox-gl-js/style-spec/}{Mapbox Style Specification} naming as much as possible,
+replacing the dash with camel case for technical reasons (i.e. \b line-cap will be translated to \b lineCap).
+
+\table
+\header
+ \li Parameter type
+ \li Description
+\row
+ \li source
+ \li A style data \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#sources}{source}. When using a source
+ of \b sourceType \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#sources-geojson}{geojson}, the
+ \b data property can be both inlined or sourced from qrc.
+\row
+ \li layer
+ \li Adds a new \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#layers}{style layer} to the map. On a Mapbox GL map,
+ layers are used in styles for adding styling rules to specific subsets of data. A layer will contain a reference to the
+ data for which they are defining a style. Use the \b before attribute to insert a layer before an existing layer.
+\row
+ \li paint
+ \li Defines how a layer will be painted. \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#layer-paint}{Paint} properties
+ can be used for changing the color and opacity of roads in the map or the land color, among other things.
+\row
+ \li layout
+ \li Defines how a layer will be layouted. \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#layer-layout}{Layout} properties
+ can be used for setting a layer's visibility, and for defining the spacing between dashes in a dashed line, among other things.
+\row
+ \li image
+ \li Adds a \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#root-sprite}{sprite} to the map to be used by a style layer.
+ This property is required if any style layer uses the properties such as \b backgroundPattern, \b fillPattern, \b linePattern,
+ or \b iconImage.
+\row
+ \li filter
+ \li A \l {https://www.mapbox.com/mapbox-gl-js/style-spec/#types-filter}{filter} selects specific features from a layer. This can
+ be used for adding a layer from a GeoJSON source based on specific parts of the data source, like by using only the points
+ in the GeoJSON.
\endtable
+
+\section1 Example usage
+
+This example adds inline GeoJSON data to the map. Simply adding a \b source is not enough to get the data
+visible. It is also necessary to create a \b layer based on this source. After the layer is added, we also need
+to style its \b paint and \b layout properties. In this case we are changing the line color to blue, and the line
+width to 8 pixels, as well as also setting round line joints and caps.
+
+\code
+Map {
+ plugin: Plugin { name: "mapboxgl" }
+
+ center: QtPositioning.coordinate(60.170448, 24.942046) // Helsinki
+ zoomLevel: 12
+
+ MapParameter {
+ type: "source"
+
+ property var name: "routeSource"
+ property var sourceType: "geojson"
+ property var data: '{ "type": "FeatureCollection", "features": \
+ [{ "type": "Feature", "properties": {}, "geometry": { \
+ "type": "LineString", "coordinates": [[ 24.934938848018646, \
+ 60.16830257086771 ], [ 24.943315386772156, 60.16227776476442 ]]}}]}'
+ }
+
+ MapParameter {
+ type: "layer"
+
+ property var name: "route"
+ property var layerType: "line"
+ property var source: "routeSource"
+
+ // Draw under the first road label layer
+ // of the mapbox-streets style.
+ property var before: "road-label-small"
+ }
+
+ MapParameter {
+ type: "paint"
+
+ property var layer: "route"
+ property var lineColor: "blue"
+ property var lineWidth: 8.0
+ }
+
+ MapParameter {
+ type: "layout"
+
+ property var layer: "route"
+ property var lineJoin: "round"
+ property var lineCap: "round"
+ }
+}
+\endcode
+
+Note that the order we add the parameters is important, because there is dependency between the
+parameters. Adding a layer before adding a source will create an invalid layer, same goes for
+adding a paint property for a layer that doesn't exist.
+
+Paint and layout properties can also be used for styling existing layers of the current style, and
+not only layers created at runtime. \l {https://www.mapbox.com/studio/}{Mapbox Studio} can be used
+for inspecting layers of a given style.
*/
diff --git a/src/location/doc/src/plugins/nokia.qdoc b/src/location/doc/src/plugins/nokia.qdoc
index 4e46a18d..30fd43f1 100644
--- a/src/location/doc/src/plugins/nokia.qdoc
+++ b/src/location/doc/src/plugins/nokia.qdoc
@@ -129,13 +129,21 @@ a prefix.
Using \b unitary, they will be interpreted as number of tiles.
The default value for this parameter is \b bytesize.
\row
- \li osm.mapping.cache.texture.size
+ \li here.mapping.cache.texture.size
\li Texture cache size for map tiles. The default size of the cache is 6 MiB when \b bytesize is the cost
strategy for this cache, or 30 tiles, when \b unitary is the cost strategy.
Note that the texture cache has a hard minimum size which depends on the size of the map viewport
(it must contain enough data to display the tiles currently visible on the display).
This value is the amount of cache to be used in addition to the bare minimum.
\row
+ \li here.mapping.prefetching_style
+ \li This parameter allows to provide a hint how tile prefetching is to be performed by the engine. The default value,
+ \tt{TwoNeighbourLayers}, makes the engine prefetch tiles for the layer above and the one below the current tile
+ layer, providing ready tiles when zooming in or out from the current zoom level.
+ \tt{OneNeighbourLayer} only prefetches the one layer closest to the current zoom level.
+ Finally, \tt{NoPrefetching} allows to disable the prefetching, so only tiles that are visible will be fetched.
+ Note that, depending on the active map type, this hint might be ignored.
+\row
\li here.mapping.highdpi_tiles
\li Whether or not to request high dpi tiles. Valid values are \b true and \b false. The default value is \b false.
\row
diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc
index 01efa021..c65c4abb 100644
--- a/src/location/doc/src/plugins/osm.qdoc
+++ b/src/location/doc/src/plugins/osm.qdoc
@@ -101,6 +101,14 @@ a prefix.
\tt{street-hires}, \tt{satellite-hires}, \tt{cycle-hires}, \tt{transit-hires}, \tt{night-transit-hires}, \tt{terrain-hires} and \tt{hiking-hires}.
These are fetched from the same location used for the low dpi counterparts.
\row
+ \li osm.mapping.prefetching_style
+ \li This parameter allows to provide a hint how tile prefetching is to be performed by the engine. The default value,
+ \tt{TwoNeighbourLayers}, makes the engine prefetch tiles for the layer above and the one below the current tile
+ layer, providing ready tiles when zooming in or out from the current zoom level.
+ \tt{OneNeighbourLayer} only prefetches the one layer closest to the current zoom level.
+ Finally, \tt{NoPrefetching} allows to disable the prefetching, so only tiles that are visible will be fetched.
+ Note that, depending on the active map type, this hint might be ignored.
+\row
\li osm.routing.host
\li Url string set when making network requests to the routing server. This parameter should be set to a
valid server url with the correct osrm API. If not specified the default \l {http://router.project-osrm.org/route/v1/driving/}{url} will be used.
diff --git a/src/location/doc/src/qml-maps.qdoc b/src/location/doc/src/qml-maps.qdoc
index ecc21672..72cf6ee9 100644
--- a/src/location/doc/src/qml-maps.qdoc
+++ b/src/location/doc/src/qml-maps.qdoc
@@ -177,13 +177,13 @@ this trip.
\snippet mapviewer/map/MapComponent.qml routerequest0
\snippet mapviewer/map/MapComponent.qml routerequest1
-The \c routeInfoModel \l {Models and Views in Qt Quick#ListModel}{ListModel} is used to grab the
+The \c routeInfoModel \l {Models and Views in Qt Quick#Models}{ListModel} is used to grab the
results of the query and construct a suitable list for display.
\snippet mapviewer/forms/RouteList.qml routeinfomodel0
\snippet mapviewer/forms/RouteList.qml routeinfomodel1
\snippet mapviewer/forms/RouteList.qml routeinfomodel3
-The \l {Models and Views in Qt Quick#ListModel}{ListModel} \c routeInfoModel can be filled
+The \l {Models and Views in Qt Quick#Models}{ListModel} \c routeInfoModel can be filled
with values using a code, that loops through the segments extracting the segment length,
instruction text and distance to the next instruction. The extracted data is formatted
for display as it is retrieved.
diff --git a/src/location/doc/src/qtlocation-examples.qdoc b/src/location/doc/src/qtlocation-examples.qdoc
index 6155a6fd..052db15b 100644
--- a/src/location/doc/src/qtlocation-examples.qdoc
+++ b/src/location/doc/src/qtlocation-examples.qdoc
@@ -39,7 +39,7 @@
These examples can work with any of the available geo services plugins. However, some plugins may
require additional \l {QtLocation::PluginParameter}{plugin parameters} in order to function correctly.
The default plugin used by these examples is \l {Qt Location Open Street Map Plugin}, which does not
- require any parameters.
-
+ require any parameters. The \l {Qt Location Mapbox GL Plugin} was used for the screenshots and can also
+ be used without any parameters, for development purposes, on the platforms it is available.
*/
diff --git a/src/location/location.pro b/src/location/location.pro
index b43d626a..5dc89a63 100644
--- a/src/location/location.pro
+++ b/src/location/location.pro
@@ -7,6 +7,9 @@ android {
CONFIG += simd optimize_full
+# 3rdparty headers produce warnings with MSVC
+msvc: CONFIG -= warning_clean
+
INCLUDEPATH += ../3rdparty/poly2tri
INCLUDEPATH += ../3rdparty/clipper
INCLUDEPATH += ../3rdparty/clip2tri
diff --git a/src/location/maps/qgeocameracapabilities.cpp b/src/location/maps/qgeocameracapabilities.cpp
index 6426b058..bb6ec4d3 100644
--- a/src/location/maps/qgeocameracapabilities.cpp
+++ b/src/location/maps/qgeocameracapabilities.cpp
@@ -74,6 +74,7 @@ public:
int tileSize_;
double minimumFieldOfView_;
double maximumFieldOfView_;
+ bool overzoomEnabled_;
};
QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate()
@@ -87,7 +88,8 @@ QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate()
maxTilt_(0.0),
tileSize_(256),
minimumFieldOfView_(45.0), // Defaulting to a fixed FOV of 45 degrees. Too large FOVs cause the loading of too many tiles
- maximumFieldOfView_(45.0) {}
+ maximumFieldOfView_(45.0),
+ overzoomEnabled_(false) {}
QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate(const QGeoCameraCapabilitiesPrivate &other)
@@ -102,7 +104,8 @@ QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate(const QGeoCameraCap
maxTilt_(other.maxTilt_),
tileSize_(other.tileSize_),
minimumFieldOfView_(other.minimumFieldOfView_),
- maximumFieldOfView_(other.maximumFieldOfView_) {}
+ maximumFieldOfView_(other.maximumFieldOfView_),
+ overzoomEnabled_(other.overzoomEnabled_){}
QGeoCameraCapabilitiesPrivate::~QGeoCameraCapabilitiesPrivate() {}
@@ -123,6 +126,7 @@ QGeoCameraCapabilitiesPrivate &QGeoCameraCapabilitiesPrivate::operator = (const
tileSize_ = other.tileSize_;
minimumFieldOfView_ = other.minimumFieldOfView_;
maximumFieldOfView_ = other.maximumFieldOfView_;
+ overzoomEnabled_ = other.overzoomEnabled_;
return *this;
}
@@ -139,7 +143,8 @@ bool QGeoCameraCapabilitiesPrivate::operator == (const QGeoCameraCapabilitiesPri
&& (maxTilt_ == rhs.maxTilt_)
&& (tileSize_ == rhs.tileSize_)
&& (minimumFieldOfView_ == rhs.minimumFieldOfView_)
- && (maximumFieldOfView_ == rhs.maximumFieldOfView_));
+ && (maximumFieldOfView_ == rhs.maximumFieldOfView_)
+ && (overzoomEnabled_ == rhs.overzoomEnabled_));
}
/*!
@@ -248,7 +253,7 @@ double QGeoCameraCapabilities::minimumZoomLevelAt256() const
{
if (d->tileSize_ == 256)
return d->minZoom_;
- return zoomLevelTo256(d->minZoom_, d->tileSize_);
+ return qMax<double>(0, zoomLevelTo256(d->minZoom_, d->tileSize_));
}
/*!
@@ -278,7 +283,7 @@ double QGeoCameraCapabilities::maximumZoomLevelAt256() const
{
if (d->tileSize_ == 256)
return d->maxZoom_;
- return zoomLevelTo256(d->maxZoom_, d->tileSize_);
+ return qMax<double>(0, zoomLevelTo256(d->maxZoom_, d->tileSize_));
}
/*!
@@ -430,5 +435,34 @@ double QGeoCameraCapabilities::maximumFieldOfView() const
return d->maximumFieldOfView_;
}
+/*!
+ Sets whether overzooming is supported by the associated plugin.
+
+ Overzooming means that zoom levels outside the [minimumZL, maximumZL] range can be set,
+ and if tiles aren't available for those zoom levels, either tiles from other zoom levels
+ will be used, or nothing will be shown.
+
+ Set this value to false if the plugin is not capable of that. For example if using
+ a mapping engine that always clamp the zoomLevel value, which may cause misalignment in case
+ of stacked map elements.
+
+ \since 5.9
+*/
+void QGeoCameraCapabilities::setOverzoomEnabled(bool overzoomEnabled)
+{
+ d->overzoomEnabled_ = overzoomEnabled;
+ d->valid_ = true;
+}
+
+/*!
+ Returns whether overzooming is supported by the associated plugin.
+
+ \since 5.9
+*/
+bool QGeoCameraCapabilities::overzoomEnabled() const
+{
+ return d->overzoomEnabled_;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeocameracapabilities_p.h b/src/location/maps/qgeocameracapabilities_p.h
index 099ad76d..9be0384d 100644
--- a/src/location/maps/qgeocameracapabilities_p.h
+++ b/src/location/maps/qgeocameracapabilities_p.h
@@ -50,13 +50,13 @@
#include <QSharedDataPointer>
-#include <QtLocation/qlocationglobal.h>
+#include <QtLocation/private/qlocationglobal_p.h>
QT_BEGIN_NAMESPACE
class QGeoCameraCapabilitiesPrivate;
-class Q_LOCATION_EXPORT QGeoCameraCapabilities
+class Q_LOCATION_PRIVATE_EXPORT QGeoCameraCapabilities
{
public:
QGeoCameraCapabilities();
@@ -100,6 +100,9 @@ public:
void setMaximumFieldOfView(double maximumFieldOfView);
double maximumFieldOfView() const;
+ void setOverzoomEnabled(bool overzoomEnabled);
+ bool overzoomEnabled() const;
+
bool isValid() const;
private:
diff --git a/src/location/maps/qgeocameratiles.cpp b/src/location/maps/qgeocameratiles.cpp
index 75d4512e..327d54b3 100644
--- a/src/location/maps/qgeocameratiles.cpp
+++ b/src/location/maps/qgeocameratiles.cpp
@@ -297,7 +297,7 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const
apertureSize = tan(QLocationUtils::radians(m_camera.fieldOfView()) * 0.5);
QDoubleVector3D center = m_sideLength * QWebMercator::coordToMercator(m_camera.center());
- double f = qMin(m_screenSize.width(), m_screenSize.height());
+ double f = m_screenSize.height();
double z = std::pow(2.0, m_camera.zoomLevel() - m_intZoomLevel) * m_tileSize; // between 1 and 2 * m_tileSize
@@ -339,19 +339,12 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const
// This used to fix the (half) field of view at 45 degrees
// half because this assumed that viewSize = 2*nearPlane x 2*nearPlane
viewExpansion *= apertureSize;
- if (aspectRatio > 1.0) {
- hhn = viewExpansion * nearPlane;
- hwn = hhn * aspectRatio;
- hhf = viewExpansion * farPlane;
- hwf = hhf * aspectRatio;
- } else {
- hwn = viewExpansion * nearPlane;
- hhn = hwn / aspectRatio;
+ hhn = viewExpansion * nearPlane;
+ hwn = hhn * aspectRatio;
- hwf = viewExpansion * farPlane;
- hhf = hwf / aspectRatio;
- }
+ hhf = viewExpansion * farPlane;
+ hwf = hhf * aspectRatio;
QDoubleVector3D d = center - eye;
d.normalize();
diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp
index f080c7f9..d40ad825 100644
--- a/src/location/maps/qgeofiletilecache.cpp
+++ b/src/location/maps/qgeofiletilecache.cpp
@@ -151,7 +151,7 @@ void QGeoFileTileCache::loadTiles()
QDir dir(directory_);
QStringList files = dir.entryList(formats, QDir::Files);
-
+#if 0 // workaround for QTBUG-60581
// Method:
// 1. read each queue file then, if each file exists, deserialize the data into the appropriate
// cache queue.
@@ -189,7 +189,7 @@ void QGeoFileTileCache::loadTiles()
diskCache_.deserializeQueue(i, specs, queue, costs);
file.close();
}
-
+#endif
// 2. remaining tiles that aren't registered in a queue get pushed into cache here
// this is a backup, in case the queue manifest files get deleted or out of sync due to
// the application not closing down properly
@@ -204,6 +204,7 @@ void QGeoFileTileCache::loadTiles()
QGeoFileTileCache::~QGeoFileTileCache()
{
+#if 0 // workaround for QTBUG-60581
// write disk cache queues to disk
QDir dir(directory_);
for (int i = 1; i<=4; i++) {
@@ -226,6 +227,7 @@ QGeoFileTileCache::~QGeoFileTileCache()
}
file.close();
}
+#endif
}
void QGeoFileTileCache::printStats()
@@ -399,6 +401,71 @@ void QGeoFileTileCache::insert(const QGeoTileSpec &spec,
* and act as a poison */
}
+QString QGeoFileTileCache::tileSpecToFilenameDefault(const QGeoTileSpec &spec, const QString &format, const QString &directory)
+{
+ QString filename = spec.plugin();
+ filename += QLatin1String("-");
+ filename += QString::number(spec.mapId());
+ filename += QLatin1String("-");
+ filename += QString::number(spec.zoom());
+ filename += QLatin1String("-");
+ filename += QString::number(spec.x());
+ filename += QLatin1String("-");
+ filename += QString::number(spec.y());
+
+ //Append version if real version number to ensure backwards compatibility and eviction of old tiles
+ if (spec.version() != -1) {
+ filename += QLatin1String("-");
+ filename += QString::number(spec.version());
+ }
+
+ filename += QLatin1String(".");
+ filename += format;
+
+ QDir dir = QDir(directory);
+
+ return dir.filePath(filename);
+}
+
+QGeoTileSpec QGeoFileTileCache::filenameToTileSpecDefault(const QString &filename)
+{
+ QGeoTileSpec emptySpec;
+
+ QStringList parts = filename.split('.');
+
+ if (parts.length() != 2)
+ return emptySpec;
+
+ QString name = parts.at(0);
+ QStringList fields = name.split('-');
+
+ int length = fields.length();
+ if (length != 5 && length != 6)
+ return emptySpec;
+
+ QList<int> numbers;
+
+ bool ok = false;
+ for (int i = 1; i < length; ++i) {
+ ok = false;
+ int value = fields.at(i).toInt(&ok);
+ if (!ok)
+ return emptySpec;
+ numbers.append(value);
+ }
+
+ //File name without version, append default
+ if (numbers.length() < 5)
+ numbers.append(-1);
+
+ return QGeoTileSpec(fields.at(0),
+ numbers.at(0),
+ numbers.at(1),
+ numbers.at(2),
+ numbers.at(3),
+ numbers.at(4));
+}
+
void QGeoFileTileCache::evictFromDiskCache(QGeoCachedTileDisk *td)
{
QFile::remove(td->filename);
@@ -424,8 +491,11 @@ QSharedPointer<QGeoCachedTileDisk> QGeoFileTileCache::addToDiskCache(const QGeoT
return td;
}
-QSharedPointer<QGeoCachedTileMemory> QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format)
+void QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format)
{
+ if (isTileBogus(bytes))
+ return;
+
QSharedPointer<QGeoCachedTileMemory> tm(new QGeoCachedTileMemory);
tm->spec = spec;
tm->cache = this;
@@ -436,8 +506,6 @@ QSharedPointer<QGeoCachedTileMemory> QGeoFileTileCache::addToMemoryCache(const Q
if (costStrategyMemory_ == ByteSize)
cost = bytes.size();
memoryCache_.insert(spec, tm, cost);
-
- return tm;
}
QSharedPointer<QGeoTileTexture> QGeoFileTileCache::addToTextureCache(const QGeoTileSpec &spec, const QImage &image)
@@ -485,11 +553,26 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCache::getFromDisk(const QGeoTileSpe
file.close();
QImage image;
+ // Some tiles from the servers could be valid images but the tile fetcher
+ // might be able to recognize them as tiles that should not be shown.
+ // If that's the case, the tile fetcher should write "NoRetry" inside the file.
+ if (isTileBogus(bytes)) {
+ QSharedPointer<QGeoTileTexture> tt(new QGeoTileTexture);
+ tt->spec = spec;
+ tt->image = image;
+ return tt;
+ }
+
+ // This is a truly invalid image. The fetcher should try again.
if (!image.loadFromData(bytes)) {
handleError(spec, QLatin1String("Problem with tile image"));
return QSharedPointer<QGeoTileTexture>(0);
}
+ // Converting it here, instead of in each QSGTexture::bind()
+ if (image.format() != QImage::Format_RGB32 && image.format() != QImage::Format_ARGB32_Premultiplied)
+ image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+
addToMemoryCache(spec, bytes, format);
QSharedPointer<QGeoTileTexture> tt = addToTextureCache(td->spec, image);
if (tt)
@@ -499,69 +582,21 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCache::getFromDisk(const QGeoTileSpe
return QSharedPointer<QGeoTileTexture>();
}
-QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const
+bool QGeoFileTileCache::isTileBogus(const QByteArray &bytes) const
{
- QString filename = spec.plugin();
- filename += QLatin1String("-");
- filename += QString::number(spec.mapId());
- filename += QLatin1String("-");
- filename += QString::number(spec.zoom());
- filename += QLatin1String("-");
- filename += QString::number(spec.x());
- filename += QLatin1String("-");
- filename += QString::number(spec.y());
-
- //Append version if real version number to ensure backwards compatibility and eviction of old tiles
- if (spec.version() != -1) {
- filename += QLatin1String("-");
- filename += QString::number(spec.version());
- }
-
- filename += QLatin1String(".");
- filename += format;
-
- QDir dir = QDir(directory);
+ if (bytes.size() == 7 && bytes == QByteArrayLiteral("NoRetry"))
+ return true;
+ return false;
+}
- return dir.filePath(filename);
+QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const
+{
+ return tileSpecToFilenameDefault(spec, format, directory);
}
QGeoTileSpec QGeoFileTileCache::filenameToTileSpec(const QString &filename) const
{
- QGeoTileSpec emptySpec;
-
- QStringList parts = filename.split('.');
-
- if (parts.length() != 2)
- return emptySpec;
-
- QString name = parts.at(0);
- QStringList fields = name.split('-');
-
- int length = fields.length();
- if (length != 5 && length != 6)
- return emptySpec;
-
- QList<int> numbers;
-
- bool ok = false;
- for (int i = 1; i < length; ++i) {
- ok = false;
- int value = fields.at(i).toInt(&ok);
- if (!ok)
- return emptySpec;
- numbers.append(value);
- }
-
- //File name without version, append default
- if (numbers.length() < 5)
- numbers.append(-1);
-
- return QGeoTileSpec(fields.at(0),
- numbers.at(0),
- numbers.at(1),
- numbers.at(2),
- numbers.at(3),
- numbers.at(4));
+ return filenameToTileSpecDefault(filename);
}
QString QGeoFileTileCache::directory() const
diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h
index 2da7c95f..e319e2a2 100644
--- a/src/location/maps/qgeofiletilecache_p.h
+++ b/src/location/maps/qgeofiletilecache_p.h
@@ -136,6 +136,9 @@ public:
const QString &format,
QAbstractGeoTileCache::CacheAreas areas = QAbstractGeoTileCache::AllCaches) Q_DECL_OVERRIDE;
+ static QString tileSpecToFilenameDefault(const QGeoTileSpec &spec, const QString &format, const QString &directory);
+ static QGeoTileSpec filenameToTileSpecDefault(const QString &filename);
+
protected:
void init() Q_DECL_OVERRIDE;
void printStats() Q_DECL_OVERRIDE;
@@ -144,11 +147,12 @@ protected:
QString directory() const;
QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename);
- QSharedPointer<QGeoCachedTileMemory> addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format);
+ void addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format);
QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image);
QSharedPointer<QGeoTileTexture> getFromMemory(const QGeoTileSpec &spec);
QSharedPointer<QGeoTileTexture> getFromDisk(const QGeoTileSpec &spec);
+ virtual bool isTileBogus(const QByteArray &bytes) const;
virtual QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const;
virtual QGeoTileSpec filenameToTileSpec(const QString &filename) const;
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 2419b79a..0c6ce0a7 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -110,7 +110,7 @@ void QGeoMap::setActiveMapType(const QGeoMapType type)
if (type == d->m_activeMapType)
return;
d->m_activeMapType = type;
- d->setCameraCapabilities(d->m_engine->cameraCapabilities(type)); // emits
+ d->setCameraCapabilities(d->m_engine->cameraCapabilities(type.mapId())); // emits
d->changeActiveMapType(type);
emit activeMapTypeChanged();
}
@@ -238,7 +238,7 @@ QGeoMapPrivate::QGeoMapPrivate(QGeoMappingManagerEngine *engine, QGeoProjection
{
// Setting the default camera caps without emitting anything
if (engine)
- m_cameraCapabilities = m_engine->cameraCapabilities(m_activeMapType);
+ m_cameraCapabilities = m_engine->cameraCapabilities(m_activeMapType.mapId());
}
QGeoMapPrivate::~QGeoMapPrivate()
diff --git a/src/location/maps/qgeomappingmanagerengine.cpp b/src/location/maps/qgeomappingmanagerengine.cpp
index a385f8ce..ffc0f065 100644
--- a/src/location/maps/qgeomappingmanagerengine.cpp
+++ b/src/location/maps/qgeomappingmanagerengine.cpp
@@ -150,9 +150,9 @@ void QGeoMappingManagerEngine::setSupportedMapTypes(const QList<QGeoMapType> &su
emit supportedMapTypesChanged();
}
-QGeoCameraCapabilities QGeoMappingManagerEngine::cameraCapabilities(const QGeoMapType &mapType) const
+QGeoCameraCapabilities QGeoMappingManagerEngine::cameraCapabilities(int mapId) const
{
- Q_UNUSED(mapType)
+ Q_UNUSED(mapId)
Q_D(const QGeoMappingManagerEngine);
return d->capabilities_;
}
diff --git a/src/location/maps/qgeomappingmanagerengine_p.h b/src/location/maps/qgeomappingmanagerengine_p.h
index b8ebb1ec..0f347d73 100644
--- a/src/location/maps/qgeomappingmanagerengine_p.h
+++ b/src/location/maps/qgeomappingmanagerengine_p.h
@@ -90,7 +90,7 @@ public:
QList<QGeoMapType> supportedMapTypes() const;
// the class is private, so this can be virtual here for now.
- virtual QGeoCameraCapabilities cameraCapabilities(const QGeoMapType &mapType) const;
+ virtual QGeoCameraCapabilities cameraCapabilities(int mapId = 0) const;
void setLocale(const QLocale &locale);
QLocale locale() const;
diff --git a/src/location/maps/qgeomaptype.cpp b/src/location/maps/qgeomaptype.cpp
index b4efa1d9..34781451 100644
--- a/src/location/maps/qgeomaptype.cpp
+++ b/src/location/maps/qgeomaptype.cpp
@@ -46,8 +46,8 @@ QGeoMapType::QGeoMapType(const QGeoMapType &other)
: d_ptr(other.d_ptr) {}
QGeoMapType::QGeoMapType(QGeoMapType::MapStyle style, const QString &name,
- const QString &description, bool mobile, bool night, int mapId)
-: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId))
+ const QString &description, bool mobile, bool night, int mapId, QByteArray pluginName)
+: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId, pluginName))
{
}
@@ -102,6 +102,11 @@ int QGeoMapType::mapId() const
return d_ptr->mapId_;
}
+QByteArray QGeoMapType::pluginName() const
+{
+ return d_ptr->pluginName_;
+}
+
QGeoMapTypePrivate::QGeoMapTypePrivate()
: style_(QGeoMapType::NoMap), mobile_(false), night_(false), mapId_(0)
{
@@ -109,15 +114,15 @@ QGeoMapTypePrivate::QGeoMapTypePrivate()
QGeoMapTypePrivate::QGeoMapTypePrivate(const QGeoMapTypePrivate &other)
: QSharedData(other), style_(other.style_), name_(other.name_), description_(other.description_),
- mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_)
+ mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_), pluginName_(other.pluginName_)
{
}
QGeoMapTypePrivate::QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name,
const QString &description, bool mobile, bool night,
- int mapId)
+ int mapId, QByteArray pluginName)
: style_(style), name_(name), description_(description), mobile_(mobile), night_(night),
- mapId_(mapId)
+ mapId_(mapId), pluginName_(pluginName)
{
}
@@ -127,8 +132,9 @@ QGeoMapTypePrivate::~QGeoMapTypePrivate()
bool QGeoMapTypePrivate::operator==(const QGeoMapTypePrivate &other) const
{
- return style_ == other.style_ && name_ == other.name_ && description_ == other.description_ &&
- mobile_ == other.mobile_ && night_ == other.night_ && mapId_ == other.mapId_;
+ return pluginName_ == other.pluginName_ && style_ == other.style_ && name_ == other.name_ &&
+ description_ == other.description_ && mobile_ == other.mobile_ && night_ == other.night_ &&
+ mapId_ == other.mapId_;
}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomaptype_p.h b/src/location/maps/qgeomaptype_p.h
index f26471f4..4b5cb0d0 100644
--- a/src/location/maps/qgeomaptype_p.h
+++ b/src/location/maps/qgeomaptype_p.h
@@ -77,7 +77,7 @@ public:
QGeoMapType();
QGeoMapType(const QGeoMapType &other);
QGeoMapType(MapStyle style, const QString &name, const QString &description, bool mobile,
- bool night, int mapId);
+ bool night, int mapId, QByteArray pluginName);
~QGeoMapType();
QGeoMapType &operator = (const QGeoMapType &other);
@@ -91,6 +91,7 @@ public:
bool mobile() const;
bool night() const;
int mapId() const;
+ QByteArray pluginName() const;
private:
QSharedDataPointer<QGeoMapTypePrivate> d_ptr;
diff --git a/src/location/maps/qgeomaptype_p_p.h b/src/location/maps/qgeomaptype_p_p.h
index 2aafd37b..039c0962 100644
--- a/src/location/maps/qgeomaptype_p_p.h
+++ b/src/location/maps/qgeomaptype_p_p.h
@@ -50,6 +50,7 @@
#include <QMetaType>
#include <QString>
+#include <QByteArray>
#include <QSharedData>
#include "qgeomaptype_p.h"
@@ -60,7 +61,8 @@ class QGeoMapTypePrivate : public QSharedData
{
public:
QGeoMapTypePrivate();
- QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile, bool night, int mapId);
+ QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile,
+ bool night, int mapId, QByteArray pluginName);
QGeoMapTypePrivate(const QGeoMapTypePrivate &other);
~QGeoMapTypePrivate();
@@ -74,6 +76,7 @@ public:
bool mobile_;
bool night_;
int mapId_;
+ QByteArray pluginName_;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp
index cd7e5114..319bf906 100644
--- a/src/location/maps/qgeoprojection.cpp
+++ b/src/location/maps/qgeoprojection.cpp
@@ -39,12 +39,12 @@
#include <QtPositioning/private/qlocationutils_p.h>
#include <QtPositioning/private/qclipperutils_p.h>
#include <QSize>
+#include <QtGui/QMatrix4x4>
#include <cmath>
namespace {
static const double defaultTileSize = 256.0;
static const QDoubleVector3D xyNormal(0.0, 0.0, 1.0);
- static const QDoubleVector3D xyPoint(0.0, 0.0, 0.0);
static const QGeoProjectionWebMercator::Plane xyPlane(QDoubleVector3D(0,0,0), QDoubleVector3D(0,0,1));
static const QList<QDoubleVector2D> mercatorGeometry = {
QDoubleVector2D(-1.0,0.0),
@@ -93,7 +93,9 @@ QGeoProjectionWebMercator::QGeoProjectionWebMercator()
m_farPlane(0.0),
m_halfWidth(0.0),
m_halfHeight(0.0),
- m_minimumUnprojectableY(0.0)
+ m_minimumUnprojectableY(0.0),
+ m_verticalEstateToSkip(0.0),
+ m_visibleRegionDirty(false)
{
}
@@ -259,11 +261,6 @@ QMatrix4x4 QGeoProjectionWebMercator::quickItemTransformation(const QGeoCoordina
const QDoubleVector2D anchorScaled = QDoubleVector2D(anchorPoint.x(), anchorPoint.y()) * scale;
const QDoubleVector2D anchorMercator = anchorScaled / mapWidth();
- // Check for coord OOB, only coordinate is going to be projected to item position, so
- // testing also coordAnchored might be superfluous
- if (!isProjectable(coordWrapped))
- return QMatrix4x4();
-
const QDoubleVector2D coordAnchored = coordWrapped - anchorMercator;
const QDoubleVector2D coordAnchoredScaled = coordAnchored * m_sideLength;
QDoubleMatrix4x4 matTranslateScale;
@@ -273,21 +270,18 @@ QMatrix4x4 QGeoProjectionWebMercator::quickItemTransformation(const QGeoCoordina
(std::floor(zoomLevel) - std::floor(m_cameraData.zoomLevel())));
matTranslateScale.scale(scale);
- const QDoubleVector2D coordOnScreen = wrappedMapProjectionToItemPosition(coordWrapped);
- QDoubleMatrix4x4 matTransformation;
- matTransformation.translate(-coordOnScreen.x(), -coordOnScreen.y(), 0);
- matTransformation *= m_quickItemTransformation;
-
/*
- * The full transformation chain for quickItemTransformation() is:
+ * The full transformation chain for quickItemTransformation() would be:
* matScreenShift * m_quickItemTransformation * matTranslate * matScale
* where:
* matScreenShift = translate(-coordOnScreen.x(), -coordOnScreen.y(), 0)
* matTranslate = translate(coordAnchoredScaled.x(), coordAnchoredScaled.y(), 0.0)
* matScale = scale(scale)
+ *
+ * However, matScreenShift is removed, as setPosition(0,0) is used in place of setPositionOnScreen.
*/
- return toMatrix4x4(matTransformation * matTranslateScale);
+ return toMatrix4x4(m_quickItemTransformation * matTranslateScale);
}
bool QGeoProjectionWebMercator::isProjectable(const QDoubleVector2D &wrappedProjection) const
@@ -307,6 +301,8 @@ bool QGeoProjectionWebMercator::isProjectable(const QDoubleVector2D &wrappedProj
QList<QDoubleVector2D> QGeoProjectionWebMercator::visibleRegion() const
{
+ if (m_visibleRegionDirty)
+ const_cast<QGeoProjectionWebMercator *>(this)->updateVisibleRegion();
return m_visibleRegion;
}
@@ -338,7 +334,7 @@ void QGeoProjectionWebMercator::setupCamera()
m_sideLength = (1 << intZoomLevel) * defaultTileSize;
m_center = m_centerMercator * m_sideLength;
- double f = 1.0 * qMin(m_viewportWidth, m_viewportHeight);
+ double f = m_viewportHeight;
double z = std::pow(2.0, m_cameraData.zoomLevel() - intZoomLevel) * defaultTileSize;
double altitude = f / (2.0 * z);
// Also in mercator space
@@ -411,16 +407,10 @@ void QGeoProjectionWebMercator::setupCamera()
double aspectRatio = 1.0 * m_viewportWidth / m_viewportHeight;
- m_halfWidth = m_aperture;
+ m_halfWidth = m_aperture * aspectRatio;
m_halfHeight = m_aperture;
- double verticalAperture = m_aperture;
- if (aspectRatio > 1.0) {
- m_halfWidth *= aspectRatio;
- } else if (aspectRatio > 0.0 && aspectRatio < 1.0) {
- m_halfHeight /= aspectRatio;
- verticalAperture /= aspectRatio;
- }
- double verticalHalfFOV = QLocationUtils::degrees(atan(verticalAperture));
+
+ double verticalHalfFOV = QLocationUtils::degrees(atan(m_aperture));
QDoubleMatrix4x4 cameraMatrix;
cameraMatrix.lookAt(m_eye, m_center, m_up);
@@ -458,16 +448,22 @@ void QGeoProjectionWebMercator::setupCamera()
const double elevationUpperBound = 90.0 - upperBoundEpsilon;
const double maxRayElevation = qMin(elevationUpperBound - m_cameraData.tilt(), verticalHalfFOV);
double maxHalfAperture = 0;
- double verticalEstateToSkip = 0;
+ m_verticalEstateToSkip = 0;
if (maxRayElevation < verticalHalfFOV) {
maxHalfAperture = tan(QLocationUtils::radians(maxRayElevation));
- verticalEstateToSkip = 1.0 - maxHalfAperture / verticalAperture;
+ m_verticalEstateToSkip = 1.0 - maxHalfAperture / m_aperture;
}
- m_minimumUnprojectableY = verticalEstateToSkip * 0.5 * m_viewportHeight; // verticalEstateToSkip is relative to half aperture
+ m_minimumUnprojectableY = m_verticalEstateToSkip * 0.5 * m_viewportHeight; // m_verticalEstateToSkip is relative to half aperture
+ m_visibleRegionDirty = true;
+}
+
+void QGeoProjectionWebMercator::updateVisibleRegion()
+{
+ m_visibleRegionDirty = false;
- QDoubleVector2D tl = viewportToWrappedMapProjection(QDoubleVector2D(-1, -1 + verticalEstateToSkip ));
- QDoubleVector2D tr = viewportToWrappedMapProjection(QDoubleVector2D( 1, -1 + verticalEstateToSkip ));
+ QDoubleVector2D tl = viewportToWrappedMapProjection(QDoubleVector2D(-1, -1 + m_verticalEstateToSkip ));
+ QDoubleVector2D tr = viewportToWrappedMapProjection(QDoubleVector2D( 1, -1 + m_verticalEstateToSkip ));
QDoubleVector2D bl = viewportToWrappedMapProjection(QDoubleVector2D(-1, 1 ));
QDoubleVector2D br = viewportToWrappedMapProjection(QDoubleVector2D( 1, 1 ));
diff --git a/src/location/maps/qgeoprojection_p.h b/src/location/maps/qgeoprojection_p.h
index b17392b1..3a0dec1d 100644
--- a/src/location/maps/qgeoprojection_p.h
+++ b/src/location/maps/qgeoprojection_p.h
@@ -131,6 +131,7 @@ public:
private:
void setupCamera();
+ void updateVisibleRegion();
public:
struct Line2D
@@ -187,6 +188,7 @@ private:
double m_halfWidth;
double m_halfHeight;
double m_minimumUnprojectableY;
+ double m_verticalEstateToSkip;
// For the clipping region
QDoubleVector3D m_centerMercator;
@@ -199,6 +201,7 @@ private:
Line2D m_nearPlaneMapIntersection;
QList<QDoubleVector2D> m_visibleRegion;
+ bool m_visibleRegionDirty;
Q_DISABLE_COPY(QGeoProjectionWebMercator)
};
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp
index 68f150db..0eeb189d 100644
--- a/src/location/maps/qgeotiledmap.cpp
+++ b/src/location/maps/qgeotiledmap.cpp
@@ -199,7 +199,7 @@ QGeoTiledMapPrivate::~QGeoTiledMapPrivate()
void QGeoTiledMapPrivate::prefetchTiles()
{
- if (m_tileRequests) {
+ if (m_tileRequests && m_prefetchStyle != QGeoTiledMap::NoPrefetching) {
QSet<QGeoTileSpec> tiles;
QGeoCameraData camera = m_visibleTiles->cameraData();
@@ -242,8 +242,11 @@ void QGeoTiledMapPrivate::prefetchTiles()
m_prefetchTiles->setViewExpansion(1.0);
tiles += m_prefetchTiles->createTiles();
}
-
}
+ break;
+
+ default:
+ break;
}
m_tileRequests->requestTiles(tiles - m_mapScene->texturedTiles());
@@ -320,12 +323,11 @@ void QGeoTiledMapPrivate::updateScene()
q->evaluateCopyrights(tiles);
// don't request tiles that are already built and textured
- QList<QSharedPointer<QGeoTileTexture> > cachedTiles =
+ QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > cachedTiles =
m_tileRequests->requestTiles(m_visibleTiles->createTiles() - m_mapScene->texturedTiles());
- foreach (const QSharedPointer<QGeoTileTexture> &tex, cachedTiles) {
- m_mapScene->addTile(tex->spec, tex);
- }
+ for (auto it = cachedTiles.cbegin(); it != cachedTiles.cend(); ++it)
+ m_mapScene->addTile(it.key(), it.value());
if (!cachedTiles.isEmpty())
emit q->sgNodeChanged();
@@ -333,9 +335,13 @@ void QGeoTiledMapPrivate::updateScene()
void QGeoTiledMapPrivate::changeActiveMapType(const QGeoMapType mapType)
{
+ m_visibleTiles->setTileSize(m_cameraCapabilities.tileSize());
+ m_prefetchTiles->setTileSize(m_cameraCapabilities.tileSize());
+ m_mapScene->setTileSize(m_cameraCapabilities.tileSize());
m_visibleTiles->setMapType(mapType);
m_prefetchTiles->setMapType(mapType);
- updateScene();
+ changeCameraData(m_cameraData); // Updates the zoom level to the possibly new tile size
+ // updateScene called in changeCameraData()
}
void QGeoTiledMapPrivate::changeTileVersion(int version)
@@ -385,7 +391,7 @@ void QGeoTiledMapPrivate::updateTile(const QGeoTileSpec &spec)
// Only promote the texture up to GPU if it is visible
if (m_visibleTiles->createTiles().contains(spec)){
QSharedPointer<QGeoTileTexture> tex = m_tileRequests->tileTexture(spec);
- if (!tex.isNull()) {
+ if (!tex.isNull() && !tex->image.isNull()) {
m_mapScene->addTile(spec, tex);
emit q->sgNodeChanged();
}
diff --git a/src/location/maps/qgeotiledmap_p.h b/src/location/maps/qgeotiledmap_p.h
index 9c9b819f..b709cb57 100644
--- a/src/location/maps/qgeotiledmap_p.h
+++ b/src/location/maps/qgeotiledmap_p.h
@@ -75,7 +75,7 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoTiledMap : public QGeoMap
Q_OBJECT
Q_DECLARE_PRIVATE(QGeoTiledMap)
public:
- enum PrefetchStyle { PrefetchNeighbourLayer, PrefetchTwoNeighbourLayers };
+ enum PrefetchStyle { NoPrefetching, PrefetchNeighbourLayer, PrefetchTwoNeighbourLayers };
QGeoTiledMap(QGeoTiledMappingManagerEngine *engine, QObject *parent);
virtual ~QGeoTiledMap();
diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp
index 84938c61..c17f7ffd 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine.cpp
+++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp
@@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
QGeoTiledMappingManagerEngine::QGeoTiledMappingManagerEngine(QObject *parent)
: QGeoMappingManagerEngine(parent),
+ m_prefetchStyle(QGeoTiledMap::PrefetchTwoNeighbourLayers),
d_ptr(new QGeoTiledMappingManagerEnginePrivate)
{
}
diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p.h
index 956c4852..929e92f8 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine_p.h
+++ b/src/location/maps/qgeotiledmappingmanagerengine_p.h
@@ -55,6 +55,7 @@
#include <QtLocation/private/qabstractgeotilecache_p.h>
#include <QtLocation/private/qgeomaptype_p.h>
#include <QtLocation/private/qgeomappingmanagerengine_p.h>
+#include <QtLocation/private/qgeotiledmap_p.h>
QT_BEGIN_NAMESPACE
@@ -106,6 +107,7 @@ protected:
void setCacheHint(QAbstractGeoTileCache::CacheAreas cacheHint);
void setTileCache(QAbstractGeoTileCache *cache);
+ QGeoTiledMap::PrefetchStyle m_prefetchStyle;
private:
QGeoTiledMappingManagerEnginePrivate *d_ptr;
diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp
index 3711841d..422082fc 100644
--- a/src/location/maps/qgeotiledmapscene.cpp
+++ b/src/location/maps/qgeotiledmapscene.cpp
@@ -88,6 +88,7 @@ public:
double m_mapEdgeSize;
QHash<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > m_textures;
+ QVector<QGeoTileSpec> m_updatedTextures;
// tilesToGrid transform
int m_minTileX; // the minimum tile index, i.e. 0 to sideLength which is 1<< zoomLevel
@@ -104,7 +105,7 @@ public:
void setVisibleTiles(const QSet<QGeoTileSpec> &visibleTiles);
void removeTiles(const QSet<QGeoTileSpec> &oldTiles);
- bool buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode);
+ bool buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode, bool &overzooming);
void updateTileBounds(const QSet<QGeoTileSpec> &tiles);
void setupCamera();
inline bool isTiltedOrRotated() { return (m_cameraData.tilt() > 0.0) || (m_cameraData.bearing() > 0.0); }
@@ -125,21 +126,31 @@ void QGeoTiledMapScene::setScreenSize(const QSize &size)
d->m_screenSize = size;
}
+void QGeoTiledMapScene::updateSceneParameters()
+{
+ Q_D(QGeoTiledMapScene);
+ d->m_intZoomLevel = static_cast<int>(std::floor(d->m_cameraData.zoomLevel()));
+ const float delta = d->m_cameraData.zoomLevel() - d->m_intZoomLevel;
+ d->m_linearScaling = qAbs(delta) > 0.05 || d->isTiltedOrRotated();
+ d->m_sideLength = 1 << d->m_intZoomLevel;
+ d->m_mapEdgeSize = std::pow(2.0, d->m_cameraData.zoomLevel()) * d->m_tileSize;
+}
+
void QGeoTiledMapScene::setTileSize(int tileSize)
{
Q_D(QGeoTiledMapScene);
+ if (d->m_tileSize == tileSize)
+ return;
+
d->m_tileSize = tileSize;
+ updateSceneParameters();
}
void QGeoTiledMapScene::setCameraData(const QGeoCameraData &cameraData)
{
Q_D(QGeoTiledMapScene);
d->m_cameraData = cameraData;
- d->m_intZoomLevel = static_cast<int>(std::floor(d->m_cameraData.zoomLevel()));
- float delta = cameraData.zoomLevel() - d->m_intZoomLevel;
- d->m_linearScaling = qAbs(delta) > 0.05 || d->isTiltedOrRotated();
- d->m_sideLength = 1 << d->m_intZoomLevel;
- d->m_mapEdgeSize = std::pow(2.0, cameraData.zoomLevel()) * d->m_tileSize;
+ updateSceneParameters();
}
void QGeoTiledMapScene::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
@@ -164,9 +175,9 @@ QSet<QGeoTileSpec> QGeoTiledMapScene::texturedTiles()
{
Q_D(QGeoTiledMapScene);
QSet<QGeoTileSpec> textured;
- foreach (const QGeoTileSpec &tile, d->m_textures.keys()) {
- textured += tile;
- }
+ for (auto it = d->m_textures.cbegin(); it != d->m_textures.cend(); ++it)
+ textured += it.value()->spec;
+
return textured;
}
@@ -197,8 +208,9 @@ QGeoTiledMapScenePrivate::~QGeoTiledMapScenePrivate()
{
}
-bool QGeoTiledMapScenePrivate::buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode)
+bool QGeoTiledMapScenePrivate::buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode, bool &overzooming)
{
+ overzooming = false;
int x = spec.x();
if (x < m_tileXWrapsBelow)
@@ -227,7 +239,25 @@ bool QGeoTiledMapScenePrivate::buildGeometry(const QGeoTileSpec &spec, QSGImageN
imageNode->setRect(QRectF(QPointF(x1, y2), QPointF(x2, y1)));
imageNode->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
- imageNode->setSourceRect(QRectF(QPointF(0,0), imageNode->texture()->textureSize()));
+
+ // Calculate the texture mapping, in case we are magnifying some lower ZL tile
+ const auto it = m_textures.find(spec); // This should be always found, but apparently sometimes it isn't, possibly due to memory shortage
+ if (it != m_textures.end()) {
+ if (it.value()->spec.zoom() < spec.zoom()) {
+ // Currently only using lower ZL tiles for the overzoom.
+ const int tilesPerTexture = 1 << (spec.zoom() - it.value()->spec.zoom());
+ const int mappedSize = imageNode->texture()->textureSize().width() / tilesPerTexture;
+ const int x = (spec.x() % tilesPerTexture) * mappedSize;
+ const int y = (spec.y() % tilesPerTexture) * mappedSize;
+ imageNode->setSourceRect(QRectF(x, y, mappedSize, mappedSize));
+ overzooming = true;
+ } else {
+ imageNode->setSourceRect(QRectF(QPointF(0,0), imageNode->texture()->textureSize()));
+ }
+ } else {
+ qWarning() << "!! buildGeometry: tileSpec not present in m_textures !!";
+ imageNode->setSourceRect(QRectF(QPointF(0,0), imageNode->texture()->textureSize()));
+ }
return true;
}
@@ -237,6 +267,8 @@ void QGeoTiledMapScenePrivate::addTile(const QGeoTileSpec &spec, QSharedPointer<
if (!m_visibleTiles.contains(spec)) // Don't add the geometry if it isn't visible
return;
+ if (m_textures.contains(spec))
+ m_updatedTextures.append(spec);
m_textures.insert(spec, texture);
}
@@ -350,7 +382,7 @@ void QGeoTiledMapScenePrivate::updateTileBounds(const QSet<QGeoTileSpec> &tiles)
void QGeoTiledMapScenePrivate::setupCamera()
{
// NOTE: The following instruction is correct only because WebMercator is a square projection!
- double f = 1.0 * qMin(m_screenSize.width(), m_screenSize.height());
+ double f = m_screenSize.height();
// Using fraction of zoom level, z varies between [ m_tileSize , 2 * m_tileSize [
double z = std::pow(2.0, m_cameraData.zoomLevel() - m_intZoomLevel) * m_tileSize;
@@ -431,11 +463,8 @@ void QGeoTiledMapScenePrivate::setupCamera()
double aspectRatio = 1.0 * m_screenSize.width() / m_screenSize.height();
float halfWidth = 1 * apertureSize;
float halfHeight = 1 * apertureSize;
- if (aspectRatio > 1.0) {
- halfWidth *= aspectRatio;
- } else if (aspectRatio > 0.0f && aspectRatio < 1.0f) {
- halfHeight /= aspectRatio;
- }
+ halfWidth *= aspectRatio;
+
m_projectionMatrix.setToIdentity();
m_projectionMatrix.frustum(-halfWidth, halfWidth, -halfHeight, halfHeight, nearPlane, farPlane);
}
@@ -549,19 +578,19 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root,
cameraMatrix.lookAt(toVector3D(eye), toVector3D(center), toVector3D(d->m_cameraUp));
root->setMatrix(d->m_projectionMatrix * cameraMatrix);
- QSet<QGeoTileSpec> tilesInSG = QSet<QGeoTileSpec>::fromList(root->tiles.keys());
- QSet<QGeoTileSpec> toRemove = tilesInSG - d->m_visibleTiles;
- QSet<QGeoTileSpec> toAdd = d->m_visibleTiles - tilesInSG;
+ const QSet<QGeoTileSpec> tilesInSG = QSet<QGeoTileSpec>::fromList(root->tiles.keys());
+ const QSet<QGeoTileSpec> toRemove = tilesInSG - d->m_visibleTiles;
+ const QSet<QGeoTileSpec> toAdd = d->m_visibleTiles - tilesInSG;
- foreach (const QGeoTileSpec &s, toRemove)
+ for (const QGeoTileSpec &s : toRemove)
delete root->tiles.take(s);
bool straight = !d->isTiltedOrRotated();
-
+ bool overzooming;
qreal pixelRatio = window->effectiveDevicePixelRatio();
for (QHash<QGeoTileSpec, QSGImageNode *>::iterator it = root->tiles.begin();
it != root->tiles.end(); ) {
QSGImageNode *node = it.value();
- bool ok = d->buildGeometry(it.key(), node)
+ bool ok = d->buildGeometry(it.key(), node, overzooming)
&& qgeotiledmapscene_isTileInViewport(node->rect(), root->matrix(), straight);
QSGNode::DirtyState dirtyBits = 0;
@@ -575,10 +604,12 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root,
node->setFiltering(QSGTexture::Linear); // With mipmapping QSGTexture::Nearest generates artifacts
node->setMipmapFiltering(QSGTexture::Linear);
} else {
- node->setFiltering(d->m_linearScaling ? QSGTexture::Linear : QSGTexture::Nearest);
+ node->setFiltering((d->m_linearScaling || overzooming) ? QSGTexture::Linear : QSGTexture::Nearest);
}
+#if QT_CONFIG(opengl)
if (ogl)
static_cast<QSGDefaultImageNode *>(node)->setAnisotropyLevel(QSGTexture::Anisotropy16x);
+#endif
dirtyBits |= QSGNode::DirtyMaterial;
}
if (dirtyBits != 0)
@@ -587,23 +618,25 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root,
}
}
- foreach (const QGeoTileSpec &s, toAdd) {
+ for (const QGeoTileSpec &s : toAdd) {
QGeoTileTexture *tileTexture = d->m_textures.value(s).data();
if (!tileTexture || tileTexture->image.isNull())
continue;
QSGImageNode *tileNode = window->createImageNode();
// note: setTexture will update coordinates so do it here, before we buildGeometry
tileNode->setTexture(textures.value(s));
- if (d->buildGeometry(s, tileNode)
+ if (d->buildGeometry(s, tileNode, overzooming)
&& qgeotiledmapscene_isTileInViewport(tileNode->rect(), root->matrix(), straight)) {
if (tileNode->texture()->textureSize().width() > d->m_tileSize * pixelRatio) {
tileNode->setFiltering(QSGTexture::Linear); // with mipmapping QSGTexture::Nearest generates artifacts
tileNode->setMipmapFiltering(QSGTexture::Linear);
} else {
- tileNode->setFiltering(d->m_linearScaling ? QSGTexture::Linear : QSGTexture::Nearest);
+ tileNode->setFiltering((d->m_linearScaling || overzooming) ? QSGTexture::Linear : QSGTexture::Nearest);
}
+#if QT_CONFIG(opengl)
if (ogl)
static_cast<QSGDefaultImageNode *>(tileNode)->setAnisotropyLevel(QSGTexture::Anisotropy16x);
+#endif
root->addChild(s, tileNode);
} else {
delete tileNode;
@@ -636,24 +669,43 @@ QSGNode *QGeoTiledMapScene::updateSceneGraph(QSGNode *oldNode, QQuickWindow *win
mapRoot->root->setMatrix(itemSpaceMatrix);
if (d->m_dropTextures) {
- foreach (const QGeoTileSpec &s, mapRoot->tiles->tiles.keys())
+ for (const QGeoTileSpec &s : mapRoot->tiles->tiles.keys())
delete mapRoot->tiles->tiles.take(s);
- foreach (const QGeoTileSpec &s, mapRoot->wrapLeft->tiles.keys())
+ for (const QGeoTileSpec &s : mapRoot->wrapLeft->tiles.keys())
delete mapRoot->wrapLeft->tiles.take(s);
- foreach (const QGeoTileSpec &s, mapRoot->wrapRight->tiles.keys())
+ for (const QGeoTileSpec &s : mapRoot->wrapRight->tiles.keys())
delete mapRoot->wrapRight->tiles.take(s);
- foreach (const QGeoTileSpec &spec, mapRoot->textures.keys())
+ for (const QGeoTileSpec &spec : mapRoot->textures.keys())
mapRoot->textures.take(spec)->deleteLater();
d->m_dropTextures = false;
}
- QSet<QGeoTileSpec> textures = QSet<QGeoTileSpec>::fromList(mapRoot->textures.keys());
- QSet<QGeoTileSpec> toRemove = textures - d->m_visibleTiles;
- QSet<QGeoTileSpec> toAdd = d->m_visibleTiles - textures;
+ // Evicting loZL tiles temporarily used in place of hiZL ones
+ if (d->m_updatedTextures.size()) {
+ const QVector<QGeoTileSpec> &toRemove = d->m_updatedTextures;
+ for (const QGeoTileSpec &s : toRemove) {
+ if (mapRoot->tiles->tiles.contains(s))
+ delete mapRoot->tiles->tiles.take(s);
+
+ if (mapRoot->wrapLeft->tiles.contains(s))
+ delete mapRoot->wrapLeft->tiles.take(s);
+
+ if (mapRoot->wrapRight->tiles.contains(s))
+ delete mapRoot->wrapRight->tiles.take(s);
+
+ if (mapRoot->textures.contains(s))
+ mapRoot->textures.take(s)->deleteLater();
+ }
+ d->m_updatedTextures.clear();
+ }
+
+ const QSet<QGeoTileSpec> textures = QSet<QGeoTileSpec>::fromList(mapRoot->textures.keys());
+ const QSet<QGeoTileSpec> toRemove = textures - d->m_visibleTiles;
+ const QSet<QGeoTileSpec> toAdd = d->m_visibleTiles - textures;
- foreach (const QGeoTileSpec &spec, toRemove)
+ for (const QGeoTileSpec &spec : toRemove)
mapRoot->textures.take(spec)->deleteLater();
- foreach (const QGeoTileSpec &spec, toAdd) {
+ for (const QGeoTileSpec &spec : toAdd) {
QGeoTileTexture *tileTexture = d->m_textures.value(spec).data();
if (!tileTexture || tileTexture->image.isNull())
continue;
diff --git a/src/location/maps/qgeotiledmapscene_p.h b/src/location/maps/qgeotiledmapscene_p.h
index 62e90791..f6a8f714 100644
--- a/src/location/maps/qgeotiledmapscene_p.h
+++ b/src/location/maps/qgeotiledmapscene_p.h
@@ -88,6 +88,8 @@ Q_SIGNALS:
void newTilesVisible(const QSet<QGeoTileSpec> &newTiles);
private:
+ void updateSceneParameters();
+
Q_DISABLE_COPY(QGeoTiledMapScene)
};
diff --git a/src/location/maps/qgeotilefetcher.cpp b/src/location/maps/qgeotilefetcher.cpp
index 34bf686c..70ebbcd1 100644
--- a/src/location/maps/qgeotilefetcher.cpp
+++ b/src/location/maps/qgeotilefetcher.cpp
@@ -45,22 +45,24 @@
QT_BEGIN_NAMESPACE
-QGeoTileFetcher::QGeoTileFetcher(QObject *parent)
+QGeoTileFetcher::QGeoTileFetcher(QGeoMappingManagerEngine *parent)
: QObject(*new QGeoTileFetcherPrivate(), parent)
{
Q_D(QGeoTileFetcher);
d->enabled_ = true;
+ d->engine_ = parent;
// if (!d->queue_.isEmpty())
// d->timer_.start(0, this);
}
-QGeoTileFetcher::QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QObject *parent)
+QGeoTileFetcher::QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QGeoMappingManagerEngine *parent)
: QObject(dd,parent)
{
Q_D(QGeoTileFetcher);
d->enabled_ = true;
+ d->engine_ = parent;
// if (!d->queue_.isEmpty())
// d->timer_.start(0, this);
@@ -120,6 +122,13 @@ void QGeoTileFetcher::requestNextTile()
if (d->queue_.isEmpty())
d->timer_.stop();
+ // Check against min/max zoom to prevent sending requests for not existing objects
+ const QGeoCameraCapabilities & cameraCaps = d->engine_->cameraCapabilities(ts.mapId());
+ // the ZL in QGeoTileSpec is relative to the native tile size of the provider.
+ // It gets denormalized in QGeoTiledMap.
+ if (ts.zoom() < cameraCaps.minimumZoomLevel() || ts.zoom() > cameraCaps.maximumZoomLevel())
+ return;
+
QGeoTiledMapReply *reply = getTileImage(ts);
if (!reply)
return;
@@ -202,7 +211,7 @@ void QGeoTileFetcher::handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &
*******************************************************************************/
QGeoTileFetcherPrivate::QGeoTileFetcherPrivate()
-: QObjectPrivate(), enabled_(false)
+: QObjectPrivate(), enabled_(false), engine_(0)
{
}
diff --git a/src/location/maps/qgeotilefetcher_p.h b/src/location/maps/qgeotilefetcher_p.h
index f9a84209..d052a8a8 100644
--- a/src/location/maps/qgeotilefetcher_p.h
+++ b/src/location/maps/qgeotilefetcher_p.h
@@ -68,7 +68,7 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoTileFetcher : public QObject
Q_DECLARE_PRIVATE(QGeoTileFetcher)
public:
- QGeoTileFetcher(QObject *parent = 0);
+ QGeoTileFetcher(QGeoMappingManagerEngine *parent);
virtual ~QGeoTileFetcher();
public Q_SLOTS:
@@ -84,7 +84,7 @@ Q_SIGNALS:
void tileError(const QGeoTileSpec &spec, const QString &errorString);
protected:
- QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QObject *parent = 0);
+ QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QGeoMappingManagerEngine *parent);
void timerEvent(QTimerEvent *event);
QAbstractGeoTileCache::CacheAreas cacheHint() const;
@@ -93,7 +93,7 @@ protected:
private:
virtual QGeoTiledMapReply *getTileImage(const QGeoTileSpec &spec) = 0;
- void handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &spec);
+ virtual void handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &spec);
Q_DISABLE_COPY(QGeoTileFetcher)
friend class QGeoTiledMappingManagerEngine;
diff --git a/src/location/maps/qgeotilefetcher_p_p.h b/src/location/maps/qgeotilefetcher_p_p.h
index 7e9db527..8e955563 100644
--- a/src/location/maps/qgeotilefetcher_p_p.h
+++ b/src/location/maps/qgeotilefetcher_p_p.h
@@ -50,6 +50,7 @@
#include <QtCore/private/qobject_p.h>
#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
#include <QSize>
#include <QList>
#include <QMap>
@@ -64,7 +65,7 @@ QT_BEGIN_NAMESPACE
class QGeoTileSpec;
class QGeoTiledMapReply;
-class QGeoTiledMappingManagerEngine;
+class QGeoMappingManagerEngine;
class Q_LOCATION_PRIVATE_EXPORT QGeoTileFetcherPrivate : public QObjectPrivate
{
@@ -78,6 +79,7 @@ public:
QMutex queueMutex_;
QList<QGeoTileSpec> queue_;
QHash<QGeoTileSpec, QGeoTiledMapReply *> invmap_;
+ QGeoMappingManagerEngine *engine_;
private:
Q_DISABLE_COPY(QGeoTileFetcherPrivate)
diff --git a/src/location/maps/qgeotilerequestmanager.cpp b/src/location/maps/qgeotilerequestmanager.cpp
index 1409856a..d4d94ad0 100644
--- a/src/location/maps/qgeotilerequestmanager.cpp
+++ b/src/location/maps/qgeotilerequestmanager.cpp
@@ -53,7 +53,7 @@ public:
QGeoTiledMap *m_map;
QPointer<QGeoTiledMappingManagerEngine> m_engine;
- QList<QSharedPointer<QGeoTileTexture> > requestTiles(const QSet<QGeoTileSpec> &tiles);
+ QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > requestTiles(const QSet<QGeoTileSpec> &tiles);
void tileError(const QGeoTileSpec &tile, const QString &errorString);
QHash<QGeoTileSpec, int> m_retries;
@@ -74,7 +74,7 @@ QGeoTileRequestManager::~QGeoTileRequestManager()
}
-QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManager::requestTiles(const QSet<QGeoTileSpec> &tiles)
+QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > QGeoTileRequestManager::requestTiles(const QSet<QGeoTileSpec> &tiles)
{
return d_ptr->requestTiles(tiles);
}
@@ -107,7 +107,7 @@ QGeoTileRequestManagerPrivate::~QGeoTileRequestManagerPrivate()
{
}
-QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTiles(const QSet<QGeoTileSpec> &tiles)
+QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTiles(const QSet<QGeoTileSpec> &tiles)
{
QSet<QGeoTileSpec> cancelTiles = m_requested - tiles;
QSet<QGeoTileSpec> requestTiles = tiles - m_requested;
@@ -117,7 +117,7 @@ QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTi
typedef QSet<QGeoTileSpec>::const_iterator iter;
- QList<QSharedPointer<QGeoTileTexture> > cachedTex;
+ QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > cachedTex;
// remove tiles in cache from request tiles
if (!m_engine.isNull()) {
@@ -127,8 +127,24 @@ QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTi
QGeoTileSpec tile = *i;
QSharedPointer<QGeoTileTexture> tex = m_engine->getTileTexture(tile);
if (tex) {
- cachedTex << tex;
+ if (!tex->image.isNull())
+ cachedTex.insert(tile, tex);
cached.insert(tile);
+ } else {
+ // Try to use textures from lower zoom levels, but still request the proper tile
+ QGeoTileSpec spec = tile;
+ const int endRange = qMax(0, tile.zoom() - 4); // Using up to 4 zoom levels up. 4 is arbitrary.
+ for (int z = tile.zoom() - 1; z >= endRange; z--) {
+ int denominator = 1 << (tile.zoom() - z);
+ spec.setZoom(z);
+ spec.setX(tile.x() / denominator);
+ spec.setY(tile.y() / denominator);
+ QSharedPointer<QGeoTileTexture> t = m_engine->getTileTexture(spec);
+ if (t && !t->image.isNull()) {
+ cachedTex.insert(tile, t);
+ break;
+ }
+ }
}
}
}
diff --git a/src/location/maps/qgeotilerequestmanager_p.h b/src/location/maps/qgeotilerequestmanager_p.h
index 66d2251e..f8ea4814 100644
--- a/src/location/maps/qgeotilerequestmanager_p.h
+++ b/src/location/maps/qgeotilerequestmanager_p.h
@@ -64,7 +64,7 @@ public:
explicit QGeoTileRequestManager(QGeoTiledMap *map, QGeoTiledMappingManagerEngine *engine);
~QGeoTileRequestManager();
- QList<QSharedPointer<QGeoTileTexture> > requestTiles(const QSet<QGeoTileSpec> &tiles);
+ QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > requestTiles(const QSet<QGeoTileSpec> &tiles);
void tileError(const QGeoTileSpec &tile, const QString &errorString);
void tileFetched(const QGeoTileSpec &spec);
diff --git a/src/plugins/geoservices/esri/esri.qrc b/src/plugins/geoservices/esri/esri.qrc
index 43b0857f..d085b09f 100644
--- a/src/plugins/geoservices/esri/esri.qrc
+++ b/src/plugins/geoservices/esri/esri.qrc
@@ -1,5 +1,5 @@
<RCC>
- <qresource prefix="/">
+ <qresource prefix="/esri">
<file>maps.json</file>
</qresource>
</RCC>
diff --git a/src/plugins/geoservices/esri/geomapsource.cpp b/src/plugins/geoservices/esri/geomapsource.cpp
index 32fe1899..19f284e6 100644
--- a/src/plugins/geoservices/esri/geomapsource.cpp
+++ b/src/plugins/geoservices/esri/geomapsource.cpp
@@ -68,7 +68,7 @@ static const MapStyleData mapStyles[] =
GeoMapSource::GeoMapSource(QGeoMapType::MapStyle style, const QString &name,
const QString &description, bool mobile, bool night, int mapId,
const QString &url, const QString &copyright) :
- QGeoMapType(style, name, description, mobile, night, mapId),
+ QGeoMapType(style, name, description, mobile, night, mapId, "esri"),
m_url(url), m_copyright(copyright)
{
}
diff --git a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
index a0f00615..23783d7e 100644
--- a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+++ b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
@@ -101,6 +101,7 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian
cameraCaps.setMaximumTilt(80);
cameraCaps.setMinimumFieldOfView(20.0);
cameraCaps.setMaximumFieldOfView(120.0);
+ cameraCaps.setOverzoomEnabled(true);
setCameraCapabilities(cameraCaps);
setTileSize(QSize(256, 256));
@@ -117,7 +118,8 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian
mapSource->description(),
mapSource->mobile(),
mapSource->night(),
- mapSource->mapId());
+ mapSource->mapId(),
+ "esri");
}
setSupportedMapTypes(mapTypes);
@@ -199,6 +201,16 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian
tileCache->setExtraTextureUsage(cacheSize);
}
+ /* PREFETCHING */
+ if (parameters.contains(QStringLiteral("esri.mapping.prefetching_style"))) {
+ const QString prefetchingMode = parameters.value(QStringLiteral("esri.mapping.prefetching_style")).toString();
+ if (prefetchingMode == QStringLiteral("TwoNeighbourLayers"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers;
+ else if (prefetchingMode == QStringLiteral("OneNeighbourLayer"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer;
+ else if (prefetchingMode == QStringLiteral("NoPrefetching"))
+ m_prefetchStyle = QGeoTiledMap::NoPrefetching;
+ }
setTileCache(tileCache);
*error = QGeoServiceProvider::NoError;
@@ -212,7 +224,9 @@ GeoTiledMappingManagerEngineEsri::~GeoTiledMappingManagerEngineEsri()
QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
{
- return new GeoTiledMapEsri(this);
+ QGeoTiledMap *map = new GeoTiledMapEsri(this);
+ map->setPrefetchStyle(m_prefetchStyle);
+ return map;
}
// ${z} = Zoom
@@ -226,7 +240,7 @@ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider:
QString *errorString)
{
initResources();
- QFile mapsFile(":/maps.json");
+ QFile mapsFile(":/esri/maps.json");
if (!mapsFile.open(QIODevice::ReadOnly)) {
*error = QGeoServiceProvider::NotSupportedError;
diff --git a/src/plugins/geoservices/esri/geotilefetcher_esri.cpp b/src/plugins/geoservices/esri/geotilefetcher_esri.cpp
index 62484bbb..8ceba374 100644
--- a/src/plugins/geoservices/esri/geotilefetcher_esri.cpp
+++ b/src/plugins/geoservices/esri/geotilefetcher_esri.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-GeoTileFetcherEsri::GeoTileFetcherEsri(QObject *parent) :
+GeoTileFetcherEsri::GeoTileFetcherEsri(QGeoTiledMappingManagerEngine *parent) :
QGeoTileFetcher(parent), m_networkManager(new QNetworkAccessManager(this)),
m_userAgent(QByteArrayLiteral("Qt Location based application"))
{
diff --git a/src/plugins/geoservices/esri/geotilefetcher_esri.h b/src/plugins/geoservices/esri/geotilefetcher_esri.h
index 43dcfdfa..be948af1 100644
--- a/src/plugins/geoservices/esri/geotilefetcher_esri.h
+++ b/src/plugins/geoservices/esri/geotilefetcher_esri.h
@@ -52,7 +52,7 @@ class GeoTileFetcherEsri : public QGeoTileFetcher
Q_OBJECT
public:
- explicit GeoTileFetcherEsri(QObject *parent = Q_NULLPTR);
+ explicit GeoTileFetcherEsri(QGeoTiledMappingManagerEngine *parent);
inline const QByteArray &userAgent() const;
inline void setUserAgent(const QByteArray &userAgent);
diff --git a/src/plugins/geoservices/geoservices.pro b/src/plugins/geoservices/geoservices.pro
index 11ef7c1e..459897a8 100644
--- a/src/plugins/geoservices/geoservices.pro
+++ b/src/plugins/geoservices/geoservices.pro
@@ -1,8 +1,12 @@
TEMPLATE = subdirs
-SUBDIRS = nokia osm mapbox esri itemsoverlay
+SUBDIRS = nokia mapbox esri itemsoverlay
-qtConfig(c++14):qtConfig(opengl):!win32 {
+qtConfig(concurrent) {
+ SUBDIRS += osm
+}
+
+qtConfig(opengl):qtConfig(c++14):!win32|mingw:!qnx {
!exists(../../3rdparty/mapbox-gl-native/CMakeLists.txt) {
warning("Submodule mapbox-gl-native does not exist. Run 'git submodule update --init' on qtlocation.")
} else {
diff --git a/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro b/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro
index 2a09a994..1f45de97 100644
--- a/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro
+++ b/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro
@@ -12,9 +12,10 @@ SOURCES += \
qgeomappingmanagerengineitemsoverlay.cpp \
qgeomapitemsoverlay.cpp
+OTHER_FILES += \
+ itemsoverlay_plugin.json
+
PLUGIN_TYPE = geoservices
PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryItemsOverlay
load(qt_plugin)
-DISTFILES += \
- itemsoverlay_plugin.json
diff --git a/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp b/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp
index bbb30164..955fbcae 100644
--- a/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp
+++ b/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp
@@ -62,7 +62,7 @@ QGeoMappingManagerEngineItemsOverlay::QGeoMappingManagerEngineItemsOverlay(const
setCameraCapabilities(cameraCaps);
QList<QGeoMapType> mapTypes;
- mapTypes << QGeoMapType(QGeoMapType::NoMap, tr("Empty Map"), tr("Empty Map"), false, false, 1);
+ mapTypes << QGeoMapType(QGeoMapType::NoMap, tr("Empty Map"), tr("Empty Map"), false, false, 1, "itemsoverlay");
setSupportedMapTypes(mapTypes);
engineInitialized();
diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
index 4b62aece..3177b6c4 100644
--- a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
@@ -56,49 +56,51 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q
cameraCaps.setMaximumTilt(80);
cameraCaps.setMinimumFieldOfView(20.0);
cameraCaps.setMaximumFieldOfView(120.0);
+ cameraCaps.setOverzoomEnabled(true);
setCameraCapabilities(cameraCaps);
setTileSize(QSize(256, 256));
+ const QByteArray pluginName = "mapbox";
QList<QGeoMapType> mapTypes;
// as index 0 to retain compatibility with the current API, that expects the passed map_id to be on by default.
if (parameters.contains(QStringLiteral("mapbox.mapping.map_id"))) {
const QString name = parameters.value(QStringLiteral("mapbox.mapping.map_id")).toString();
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size(), pluginName);
} else if (parameters.contains(QStringLiteral("mapbox.map_id"))) { //deprecated
const QString name = parameters.value(QStringLiteral("mapbox.map_id")).toString();
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size(), pluginName);
}
// As of 2016.06.15, valid mapbox map_ids are documented at https://www.mapbox.com/api-documentation/#maps
//: Noun describing map type 'Street map'
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets"), tr("Street"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets"), tr("Street"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map using light colors (weak contrast)
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.light"), tr("Light"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.light"), tr("Light"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map using dark colors
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.dark"), tr("Dark"), false, true, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.dark"), tr("Dark"), false, true, mapTypes.size(), pluginName);
//: Noun describing type of a map created by satellite
- mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, QStringLiteral("mapbox.satellite"), tr("Satellite"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, QStringLiteral("mapbox.satellite"), tr("Satellite"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a street map created by satellite
- mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox.streets-satellite"), tr("Streets Satellite"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox.streets-satellite"), tr("Streets Satellite"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map using wheat paste colors
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.wheatpaste"), tr("Wheatpaste"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.wheatpaste"), tr("Wheatpaste"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a basic street map
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets-basic"), tr("Streets Basic"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox.streets-basic"), tr("Streets Basic"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map using cartoon-style fonts
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.comic"), tr("Comic"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.comic"), tr("Comic"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map for outdoor activities
- mapTypes << QGeoMapType(QGeoMapType::PedestrianMap, QStringLiteral("mapbox.outdoors"), tr("Outdoors"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::PedestrianMap, QStringLiteral("mapbox.outdoors"), tr("Outdoors"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map for sports
- mapTypes << QGeoMapType(QGeoMapType::CycleMap, QStringLiteral("mapbox.run-bike-hike"), tr("Run Bike Hike"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CycleMap, QStringLiteral("mapbox.run-bike-hike"), tr("Run Bike Hike"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map drawn by pencil
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pencil"), tr("Pencil"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pencil"), tr("Pencil"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a treasure map with pirate boat watermark
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pirates"), tr("Pirates"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.pirates"), tr("Pirates"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map using emerald colors
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.emerald"), tr("Emerald"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.emerald"), tr("Emerald"), false, false, mapTypes.size(), pluginName);
//: Noun describing type of a map with high contrast
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.high-contrast"), tr("High Contrast"), false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, QStringLiteral("mapbox.high-contrast"), tr("High Contrast"), false, false, mapTypes.size(), pluginName);
// New way to specify multiple customized map_ids via additional_map_ids
if (parameters.contains(QStringLiteral("mapbox.mapping.additional_map_ids"))) {
@@ -107,7 +109,7 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q
for (const QString &name: idList) {
if (!name.isEmpty())
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size());
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, name, name, false, false, mapTypes.size(), pluginName);
}
}
@@ -152,7 +154,7 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q
m_cacheDirectory = parameters.value(QStringLiteral("mapbox.mapping.cache.directory")).toString();
} else {
// managerName() is not yet set, we have to hardcode the plugin name below
- m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("mapbox");
+ m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String(pluginName);
}
QGeoFileTileCache *tileCache = new QGeoFileTileCacheMapbox(mapTypes, scaleFactor, m_cacheDirectory);
@@ -221,6 +223,16 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q
tileCache->setExtraTextureUsage(cacheSize);
}
+ /* PREFETCHING */
+ if (parameters.contains(QStringLiteral("mapbox.mapping.prefetching_style"))) {
+ const QString prefetchingMode = parameters.value(QStringLiteral("mapbox.mapping.prefetching_style")).toString();
+ if (prefetchingMode == QStringLiteral("TwoNeighbourLayers"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers;
+ else if (prefetchingMode == QStringLiteral("OneNeighbourLayer"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer;
+ else if (prefetchingMode == QStringLiteral("NoPrefetching"))
+ m_prefetchStyle = QGeoTiledMap::NoPrefetching;
+ }
setTileCache(tileCache);
@@ -234,7 +246,9 @@ QGeoTiledMappingManagerEngineMapbox::~QGeoTiledMappingManagerEngineMapbox()
QGeoMap *QGeoTiledMappingManagerEngineMapbox::createMap()
{
- return new QGeoTiledMap(this, 0);
+ QGeoTiledMap *map = new QGeoTiledMap(this, 0);
+ map->setPrefetchStyle(m_prefetchStyle);
+ return map;
}
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
index 062b4f89..732d04e9 100644
--- a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
@@ -44,7 +44,7 @@
QT_BEGIN_NAMESPACE
-QGeoTileFetcherMapbox::QGeoTileFetcherMapbox(int scaleFactor, QObject *parent)
+QGeoTileFetcherMapbox::QGeoTileFetcherMapbox(int scaleFactor, QGeoTiledMappingManagerEngine *parent)
: QGeoTileFetcher(parent), m_networkManager(new QNetworkAccessManager(this)),
m_userAgent("Qt Location based application"),
m_format("png"),
diff --git a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
index e52651e1..47f3a8aa 100644
--- a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
+++ b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
@@ -50,7 +50,7 @@ class QGeoTileFetcherMapbox : public QGeoTileFetcher
Q_OBJECT
public:
- QGeoTileFetcherMapbox(int scaleFactor = 2, QObject *parent = 0);
+ QGeoTileFetcherMapbox(int scaleFactor, QGeoTiledMappingManagerEngine *parent);
void setUserAgent(const QByteArray &userAgent);
void setMapIds(const QVector<QString> &mapIds);
diff --git a/src/plugins/geoservices/mapboxgl/logo.png b/src/plugins/geoservices/mapboxgl/logo.png
index 57410f79..9d6e90ef 100644
--- a/src/plugins/geoservices/mapboxgl/logo.png
+++ b/src/plugins/geoservices/mapboxgl/logo.png
Binary files differ
diff --git a/src/plugins/geoservices/mapboxgl/mapboxgl.pro b/src/plugins/geoservices/mapboxgl/mapboxgl.pro
index 37dd383c..f35f26dc 100644
--- a/src/plugins/geoservices/mapboxgl/mapboxgl.pro
+++ b/src/plugins/geoservices/mapboxgl/mapboxgl.pro
@@ -29,14 +29,23 @@ OTHER_FILES += \
INCLUDEPATH += ../../../3rdparty/mapbox-gl-native/platform/qt/include
+include(../../../3rdparty/zlib_dependency.pri)
+
+load(qt_build_paths)
+LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lqmapboxgl$$qtPlatformTargetSuffix()
+
qtConfig(icu) {
include(../../../3rdparty/icu_dependency.pri)
}
-include(../../../3rdparty/zlib_dependency.pri)
-
-load(qt_build_paths)
-LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lqmapboxgl
+# When building for Windows with dynamic OpenGL, this plugin
+# can only run with ANGLE because Mapbox GL requires at least
+# OpenGL ES and does not use QOpenGLFunctions for resolving
+# the OpenGL symbols. -lopengl32 only gives OpenGL 1.1.
+win32:qtConfig(dynamicgl) {
+ qtConfig(combined-angle-lib): LIBS_PRIVATE += -l$${LIBQTANGLE_NAME}
+ else: LIBS_PRIVATE += -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME}
+}
PLUGIN_TYPE = geoservices
PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryMapboxGL
diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
index d76d5e7a..ad3ab375 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
+++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
@@ -91,13 +91,9 @@ QSGNode *QGeoMapMapboxGLPrivate::updateSceneGraph(QSGNode *node, QQuickWindow *w
{
Q_Q(QGeoMapMapboxGL);
- if (!m_warned) {
- if (window->openglContext()->thread() != QCoreApplication::instance()->thread()) {
- qWarning() << "Threaded rendering is not supported by Mapbox GL plugin.";
- QMetaObject::invokeMethod(&m_refresh, "start", Qt::QueuedConnection);
- }
-
- m_warned = true;
+ if (m_viewportSize.isEmpty()) {
+ delete node;
+ return 0;
}
QMapboxGL *map = 0;
@@ -151,6 +147,8 @@ QSGNode *QGeoMapMapboxGLPrivate::updateSceneGraph(QSGNode *node, QQuickWindow *w
static_cast<QSGMapboxGLTextureNode *>(node)->render(window);
}
+ threadedRenderingHack(window, map);
+
m_syncState = NoSync;
return node;
@@ -212,7 +210,7 @@ void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item)
QObject::connect(item, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
- m_styleChanges << QMapboxGLStyleChange::addMapItem(item);
+ m_styleChanges << QMapboxGLStyleChange::addMapItem(item, m_mapItemsBefore);
emit q->sgNodeChanged();
}
@@ -278,6 +276,31 @@ void QGeoMapMapboxGLPrivate::syncStyleChanges(QMapboxGL *map)
m_styleChanges.clear();
}
+void QGeoMapMapboxGLPrivate::threadedRenderingHack(QQuickWindow *window, QMapboxGL *map)
+{
+ // FIXME: Optimal support for threaded rendering needs core changes
+ // in Mapbox GL Native. Meanwhile we need to set a timer to update
+ // the map until all the resources are loaded, which is not exactly
+ // battery friendly, because might trigger more paints than we need.
+ if (!m_warned) {
+ m_threadedRendering = window->openglContext()->thread() != QCoreApplication::instance()->thread();
+
+ if (m_threadedRendering) {
+ qWarning() << "Threaded rendering is not optimal in the Mapbox GL plugin.";
+ }
+
+ m_warned = true;
+ }
+
+ if (m_threadedRendering) {
+ if (!map->isFullyLoaded()) {
+ QMetaObject::invokeMethod(&m_refresh, "start", Qt::QueuedConnection);
+ } else {
+ QMetaObject::invokeMethod(&m_refresh, "stop", Qt::QueuedConnection);
+ }
+ }
+}
+
/*
* QGeoMapMapboxGL implementation
*/
@@ -319,6 +342,12 @@ void QGeoMapMapboxGL::setUseFBO(bool useFBO)
d->m_useFBO = useFBO;
}
+void QGeoMapMapboxGL::setMapItemsBefore(const QString &before)
+{
+ Q_D(QGeoMapMapboxGL);
+ d->m_mapItemsBefore = before;
+}
+
QSGNode *QGeoMapMapboxGL::updateSceneGraph(QSGNode *oldNode, QQuickWindow *window)
{
Q_D(QGeoMapMapboxGL);
@@ -339,7 +368,7 @@ void QGeoMapMapboxGL::onMapChanged(QMapboxGL::MapChange change)
d->m_styleChanges << QMapboxGLStyleChange::addMapParameter(param);
for (QDeclarativeGeoMapItemBase *item : d->m_mapItems)
- d->m_styleChanges << QMapboxGLStyleChange::addMapItem(item);
+ d->m_styleChanges << QMapboxGLStyleChange::addMapItem(item, d->m_mapItemsBefore);
}
}
diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h
index 56b97e99..73cfd75a 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h
+++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h
@@ -56,6 +56,7 @@ public:
QString copyrightsStyleSheet() const Q_DECL_OVERRIDE;
void setMapboxGLSettings(const QMapboxGLSettings &);
void setUseFBO(bool);
+ void setMapItemsBefore(const QString &);
private Q_SLOTS:
// QMapboxGL
diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h
index b6527c01..598c9078 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h
+++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl_p.h
@@ -79,10 +79,12 @@ public:
QMapboxGLSettings m_settings;
bool m_useFBO = true;
bool m_developmentMode = false;
+ QString m_mapItemsBefore;
QTimer m_refresh;
bool m_shouldRefresh = true;
bool m_warned = false;
+ bool m_threadedRendering = false;
bool m_styleLoaded = false;
SyncStates m_syncState = NoSync;
@@ -98,6 +100,7 @@ private:
Q_DISABLE_COPY(QGeoMapMapboxGLPrivate);
void syncStyleChanges(QMapboxGL *map);
+ void threadedRenderingHack(QQuickWindow *window, QMapboxGL *map);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoMapMapboxGLPrivate::SyncStates)
diff --git a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp
index c87b458d..211c0bba 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp
+++ b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.cpp
@@ -67,27 +67,28 @@ QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(const QVarian
QList<QGeoMapType> mapTypes;
int mapId = 0;
+ const QByteArray pluginName = "mapboxgl";
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/streets-v9"),
- tr("Streets"), false, false, ++mapId);
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/streets-v10"),
+ tr("Streets"), false, false, ++mapId, pluginName);
mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/basic-v9"),
- tr("Basic"), false, false, ++mapId);
+ tr("Basic"), false, false, ++mapId, pluginName);
mapTypes << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("mapbox://styles/mapbox/bright-v9"),
- tr("Bright"), false, false, ++mapId);
- mapTypes << QGeoMapType(QGeoMapType::TerrainMap, QStringLiteral("mapbox://styles/mapbox/outdoors-v9"),
- tr("Outdoors"), false, false, ++mapId);
+ tr("Bright"), false, false, ++mapId, pluginName);
+ mapTypes << QGeoMapType(QGeoMapType::TerrainMap, QStringLiteral("mapbox://styles/mapbox/outdoors-v10"),
+ tr("Outdoors"), false, false, ++mapId, pluginName);
mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, QStringLiteral("mapbox://styles/mapbox/satellite-v9"),
- tr("Satellite"), false, false, ++mapId);
- mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox://styles/mapbox/satellite-streets-v9"),
- tr("Satellite Streets"), false, false, ++mapId);
+ tr("Satellite"), false, false, ++mapId, pluginName);
+ mapTypes << QGeoMapType(QGeoMapType::HybridMap, QStringLiteral("mapbox://styles/mapbox/satellite-streets-v10"),
+ tr("Satellite Streets"), false, false, ++mapId, pluginName);
mapTypes << QGeoMapType(QGeoMapType::GrayStreetMap, QStringLiteral("mapbox://styles/mapbox/light-v9"),
- tr("Light"), false, false, ++mapId);
+ tr("Light"), false, false, ++mapId, pluginName);
mapTypes << QGeoMapType(QGeoMapType::GrayStreetMap, QStringLiteral("mapbox://styles/mapbox/dark-v9"),
- tr("Dark"), false, false, ++mapId);
+ tr("Dark"), false, false, ++mapId, pluginName);
mapTypes << QGeoMapType(QGeoMapType::TransitMap, QStringLiteral("mapbox://styles/mapbox/traffic-day-v1"),
- tr("Streets Traffic Day"), false, false, ++mapId);
+ tr("Streets Traffic Day"), false, false, ++mapId, pluginName);
mapTypes << QGeoMapType(QGeoMapType::TransitMap, QStringLiteral("mapbox://styles/mapbox/traffic-night-v1"),
- tr("Streets Traffic Night"), false, true, ++mapId);
+ tr("Streets Traffic Night"), false, true, ++mapId, pluginName);
if (parameters.contains(QStringLiteral("mapboxgl.mapping.additional_style_urls"))) {
const QString ids = parameters.value(QStringLiteral("mapboxgl.mapping.additional_style_urls")).toString();
@@ -98,7 +99,7 @@ QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(const QVarian
continue;
mapTypes.prepend(QGeoMapType(QGeoMapType::CustomMap, *it,
- tr("User provided style"), false, false, ++mapId));
+ tr("User provided style"), false, false, ++mapId, pluginName));
}
}
@@ -137,6 +138,10 @@ QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(const QVarian
m_useFBO = parameters.value(QStringLiteral("mapboxgl.mapping.use_fbo")).toBool();
}
+ if (parameters.contains(QStringLiteral("mapboxgl.mapping.items.insert_before"))) {
+ m_mapItemsBefore = parameters.value(QStringLiteral("mapboxgl.mapping.items.insert_before")).toString();
+ }
+
engineInitialized();
}
@@ -149,6 +154,7 @@ QGeoMap *QGeoMappingManagerEngineMapboxGL::createMap()
QGeoMapMapboxGL* map = new QGeoMapMapboxGL(this, 0);
map->setMapboxGLSettings(m_settings);
map->setUseFBO(m_useFBO);
+ map->setMapItemsBefore(m_mapItemsBefore);
return map;
}
diff --git a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h
index c5923cda..44096e60 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h
+++ b/src/plugins/geoservices/mapboxgl/qgeomappingmanagerenginemapboxgl.h
@@ -59,6 +59,7 @@ public:
private:
QMapboxGLSettings m_settings;
bool m_useFBO = true;
+ QString m_mapItemsBefore;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp
index 30c01f8c..c7d5d3ee 100644
--- a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp
+++ b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp
@@ -38,9 +38,20 @@
#include "qgeoserviceproviderpluginmapboxgl.h"
#include "qgeomappingmanagerenginemapboxgl.h"
+#include <QtGui/QOpenGLContext>
+
+static void initResources()
+{
+ Q_INIT_RESOURCE(mapboxgl);
+}
QT_BEGIN_NAMESPACE
+QGeoServiceProviderFactoryMapboxGL::QGeoServiceProviderFactoryMapboxGL()
+{
+ initResources();
+}
+
QGeoCodingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createGeocodingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
@@ -54,6 +65,15 @@ QGeoCodingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createGeocodingMana
QGeoMappingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createMappingManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
+#ifdef Q_OS_WIN
+ if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGLES) {
+ qWarning("The Mapbox GL plugin only supports OpenGL ES on Windows. \
+ Try setting the environment variable QT_OPENGL to 'angle'.");
+
+ return 0;
+ }
+#endif
+
return new QGeoMappingManagerEngineMapboxGL(parameters, error, errorString);
}
diff --git a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h
index 2bba96f1..b9c0098a 100644
--- a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h
+++ b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.h
@@ -51,6 +51,8 @@ class QGeoServiceProviderFactoryMapboxGL: public QObject, public QGeoServiceProv
FILE "mapboxgl_plugin.json")
public:
+ QGeoServiceProviderFactoryMapboxGL();
+
QGeoCodingManagerEngine *createGeocodingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
index eccc64b8..8229b784 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
@@ -175,7 +175,7 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapParamete
return changes;
}
-QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDeclarativeGeoMapItemBase *item)
+QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDeclarativeGeoMapItemBase *item, const QString &before)
{
QList<QSharedPointer<QMapboxGLStyleChange>> changes;
@@ -191,7 +191,7 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDe
QMapbox::Feature feature = featureFromMapItem(item);
- changes << QMapboxGLStyleAddLayer::fromFeature(feature);
+ changes << QMapboxGLStyleAddLayer::fromFeature(feature, before);
changes << QMapboxGLStyleAddSource::fromFeature(feature);
changes << QMapboxGLStyleSetPaintProperty::fromMapItem(item);
changes << QMapboxGLStyleSetLayoutProperty::fromMapItem(item);
@@ -390,7 +390,7 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::from
void QMapboxGLStyleAddLayer::apply(QMapboxGL *map)
{
- map->addLayer(m_params);
+ map->addLayer(m_params, m_before);
}
QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromMapParameter(QGeoMapParameter *param)
@@ -406,10 +406,12 @@ QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromMapParameter(QG
layer->m_params[QStringLiteral("source-layer")] = param->property("sourceLayer");
}
+ layer->m_before = param->property("before").toString();
+
return QSharedPointer<QMapboxGLStyleChange>(layer);
}
-QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromFeature(const QMapbox::Feature &feature)
+QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromFeature(const QMapbox::Feature &feature, const QString &before)
{
auto layer = new QMapboxGLStyleAddLayer();
layer->m_params[QStringLiteral("id")] = feature.id;
@@ -427,6 +429,8 @@ QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromFeature(const Q
break;
}
+ layer->m_before = before;
+
return QSharedPointer<QMapboxGLStyleChange>(layer);
}
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
index a380660b..9164591a 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
@@ -58,7 +58,7 @@ public:
virtual ~QMapboxGLStyleChange() = default;
static QList<QSharedPointer<QMapboxGLStyleChange>> addMapParameter(QGeoMapParameter *);
- static QList<QSharedPointer<QMapboxGLStyleChange>> addMapItem(QDeclarativeGeoMapItemBase *);
+ static QList<QSharedPointer<QMapboxGLStyleChange>> addMapItem(QDeclarativeGeoMapItemBase *, const QString &before);
static QList<QSharedPointer<QMapboxGLStyleChange>> removeMapItem(QDeclarativeGeoMapItemBase *);
virtual void apply(QMapboxGL *map) = 0;
@@ -109,7 +109,7 @@ class QMapboxGLStyleAddLayer : public QMapboxGLStyleChange
{
public:
static QSharedPointer<QMapboxGLStyleChange> fromMapParameter(QGeoMapParameter *);
- static QSharedPointer<QMapboxGLStyleChange> fromFeature(const QMapbox::Feature &feature);
+ static QSharedPointer<QMapboxGLStyleChange> fromFeature(const QMapbox::Feature &feature, const QString &before);
void apply(QMapboxGL *map) Q_DECL_OVERRIDE;
@@ -117,6 +117,7 @@ private:
QMapboxGLStyleAddLayer() = default;
QVariantMap m_params;
+ QString m_before;
};
class QMapboxGLStyleRemoveLayer : public QMapboxGLStyleChange
diff --git a/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp b/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp
index 4a76ac29..d338a51a 100644
--- a/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp
+++ b/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp
@@ -43,13 +43,15 @@
// QSGMapboxGLTextureNode
+static const QSize minTextureSize = QSize(64, 64);
+
QSGMapboxGLTextureNode::QSGMapboxGLTextureNode(const QMapboxGLSettings &settings, const QSize &size, qreal pixelRatio, QGeoMapMapboxGL *geoMap)
: QSGSimpleTextureNode()
{
setTextureCoordinatesTransform(QSGSimpleTextureNode::MirrorVertically);
setFiltering(QSGTexture::Linear);
- m_map.reset(new QMapboxGL(nullptr, settings, size, pixelRatio));
+ m_map.reset(new QMapboxGL(nullptr, settings, size.expandedTo(minTextureSize), pixelRatio));
QObject::connect(m_map.data(), &QMapboxGL::needsRendering, geoMap, &QGeoMap::sgNodeChanged);
QObject::connect(m_map.data(), &QMapboxGL::copyrightsChanged, geoMap,
@@ -58,8 +60,9 @@ QSGMapboxGLTextureNode::QSGMapboxGLTextureNode(const QMapboxGLSettings &settings
void QSGMapboxGLTextureNode::resize(const QSize &size, qreal pixelRatio)
{
- const QSize fbSize = size * pixelRatio;
- m_map->resize(size, fbSize);
+ const QSize& minSize = size.expandedTo(minTextureSize);
+ const QSize fbSize = minSize * pixelRatio;
+ m_map->resize(minSize, fbSize);
m_fbo.reset(new QOpenGLFramebufferObject(fbSize, QOpenGLFramebufferObject::CombinedDepthStencil));
@@ -75,14 +78,12 @@ void QSGMapboxGLTextureNode::resize(const QSize &size, qreal pixelRatio)
setOwnsTexture(true);
}
- setRect(QRectF(QPointF(), size));
+ setRect(QRectF(QPointF(), minSize));
markDirty(QSGNode::DirtyGeometry);
}
void QSGMapboxGLTextureNode::render(QQuickWindow *window)
{
- window->setClearBeforeRendering(false);
-
QOpenGLFunctions *f = window->openglContext()->functions();
f->glViewport(0, 0, m_fbo->width(), m_fbo->height());
diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro
index c60bc7af..c6dadd86 100644
--- a/src/plugins/geoservices/nokia/nokia.pro
+++ b/src/plugins/geoservices/nokia/nokia.pro
@@ -45,7 +45,7 @@ SOURCES += \
include(placesv2/placesv2.pri)
-RESOURCES += resource.qrc
+RESOURCES += nokia.qrc
INCLUDEPATH += ../../../location/maps
diff --git a/src/plugins/geoservices/nokia/resource.qrc b/src/plugins/geoservices/nokia/nokia.qrc
index 41d973c5..41d973c5 100644
--- a/src/plugins/geoservices/nokia/resource.qrc
+++ b/src/plugins/geoservices/nokia/nokia.qrc
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
index 4deac4ee..f68a0d99 100644
--- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
@@ -47,6 +47,11 @@
#include <QNetworkProxy>
#include <QCoreApplication>
+static void initResources()
+{
+ Q_INIT_RESOURCE(nokia);
+}
+
QT_BEGIN_NAMESPACE
namespace
@@ -110,6 +115,11 @@ namespace
}
}
+QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia()
+{
+ initResources();
+}
+
QGeoCodingManagerEngine *QGeoServiceProviderFactoryNokia::createGeocodingManagerEngine(
const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
index bce65cbf..5ed2645e 100644
--- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
@@ -52,6 +52,8 @@ class QGeoServiceProviderFactoryNokia : public QObject, public QGeoServiceProvid
FILE "nokia_plugin.json")
public:
+ QGeoServiceProviderFactoryNokia();
+
QGeoCodingManagerEngine *createGeocodingManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
index ab6cd7ea..146071f7 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
@@ -85,32 +85,34 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
capabilities.setMaximumTilt(80);
capabilities.setMinimumFieldOfView(20.0);
capabilities.setMaximumFieldOfView(120.0);
+ capabilities.setOverzoomEnabled(true);
setCameraCapabilities(capabilities);
setTileSize(QSize(256, 256));
+ const QByteArray pluginName = "here";
QList<QGeoMapType> types;
- types << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Normal map view in daylight mode"), false, false, 1);
- types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2);
- types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view in daylight mode"), false, false, 3);
- types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Satellite map view with streets in daylight mode"), false, false, 4);
- types << QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Color-reduced map view with public transport scheme in daylight mode"), false, false, 5);
- types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Street Map"), tr("Color-reduced map view in daylight mode"), false, false, 6);
- types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Street Map"), tr("Mobile normal map view in daylight mode"), true, false, 7);
- types << QGeoMapType(QGeoMapType::TerrainMap, tr("Mobile Terrain Map"), tr("Mobile terrain map view in daylight mode"), true, false, 8);
- types << QGeoMapType(QGeoMapType::HybridMap, tr("Mobile Hybrid Map"), tr("Mobile satellite map view with streets in daylight mode"), true, false, 9);
- types << QGeoMapType(QGeoMapType::TransitMap, tr("Mobile Transit Map"), tr("Mobile color-reduced map view with public transport scheme in daylight mode"), true, false, 10);
- types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Street Map"), tr("Mobile color-reduced map view in daylight mode"), true, false, 11);
- types << QGeoMapType(QGeoMapType::StreetMap, tr("Custom Street Map"), tr("Normal map view in daylight mode"), false, false, 12);
- types << QGeoMapType(QGeoMapType::StreetMap, tr("Night Street Map"), tr("Normal map view in night mode"), false, true, 13);
- types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Night Street Map"), tr("Mobile normal map view in night mode"), true, true, 14);
- types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Night Street Map"), tr("Color-reduced map view in night mode (especially used for background maps)"), false, true, 15);
- types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Night Street Map"), tr("Mobile color-reduced map view in night mode (especially used for background maps)"), true, true, 16);
- types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Street Map"), tr("Pedestrian map view in daylight mode"), false, false, 17);
- types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Street Map"), tr("Mobile pedestrian map view in daylight mode for mobile usage"), true, false, 18);
- types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Night Street Map"), tr("Pedestrian map view in night mode"), false, true, 19);
- types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Night Street Map"), tr("Mobile pedestrian map view in night mode for mobile usage"), true, true, 20);
- types << QGeoMapType(QGeoMapType::CarNavigationMap, tr("Car Navigation Map"), tr("Normal map view in daylight mode for car navigation"), false, false, 21);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Normal map view in daylight mode"), false, false, 1, pluginName);
+ types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2, pluginName);
+ types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view in daylight mode"), false, false, 3, pluginName);
+ types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Satellite map view with streets in daylight mode"), false, false, 4, pluginName);
+ types << QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Color-reduced map view with public transport scheme in daylight mode"), false, false, 5, pluginName);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Street Map"), tr("Color-reduced map view in daylight mode"), false, false, 6, pluginName);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Street Map"), tr("Mobile normal map view in daylight mode"), true, false, 7, pluginName);
+ types << QGeoMapType(QGeoMapType::TerrainMap, tr("Mobile Terrain Map"), tr("Mobile terrain map view in daylight mode"), true, false, 8, pluginName);
+ types << QGeoMapType(QGeoMapType::HybridMap, tr("Mobile Hybrid Map"), tr("Mobile satellite map view with streets in daylight mode"), true, false, 9, pluginName);
+ types << QGeoMapType(QGeoMapType::TransitMap, tr("Mobile Transit Map"), tr("Mobile color-reduced map view with public transport scheme in daylight mode"), true, false, 10, pluginName);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Street Map"), tr("Mobile color-reduced map view in daylight mode"), true, false, 11, pluginName);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Custom Street Map"), tr("Normal map view in daylight mode"), false, false, 12, pluginName);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Night Street Map"), tr("Normal map view in night mode"), false, true, 13, pluginName);
+ types << QGeoMapType(QGeoMapType::StreetMap, tr("Mobile Night Street Map"), tr("Mobile normal map view in night mode"), true, true, 14, pluginName);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Gray Night Street Map"), tr("Color-reduced map view in night mode (especially used for background maps)"), false, true, 15, pluginName);
+ types << QGeoMapType(QGeoMapType::GrayStreetMap, tr("Mobile Gray Night Street Map"), tr("Mobile color-reduced map view in night mode (especially used for background maps)"), true, true, 16, pluginName);
+ types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Street Map"), tr("Pedestrian map view in daylight mode"), false, false, 17, pluginName);
+ types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Street Map"), tr("Mobile pedestrian map view in daylight mode for mobile usage"), true, false, 18, pluginName);
+ types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Pedestrian Night Street Map"), tr("Pedestrian map view in night mode"), false, true, 19, pluginName);
+ types << QGeoMapType(QGeoMapType::PedestrianMap, tr("Mobile Pedestrian Night Street Map"), tr("Mobile pedestrian map view in night mode for mobile usage"), true, true, 20, pluginName);
+ types << QGeoMapType(QGeoMapType::CarNavigationMap, tr("Car Navigation Map"), tr("Normal map view in daylight mode for car navigation"), false, false, 21, pluginName);
setSupportedMapTypes(types);
QGeoTileFetcherNokia *fetcher = new QGeoTileFetcherNokia(parameters, networkManager, this, tileSize(), ppi);
@@ -123,7 +125,7 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
m_cacheDirectory = parameters.value(QStringLiteral("here.mapping.cache.directory")).toString();
} else {
// managerName() is not yet set, we have to hardcode the plugin name below
- m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("here");
+ m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String(pluginName);
}
QGeoFileTileCache *tileCache = new QGeoFileTileCacheNokia(ppi, m_cacheDirectory);
@@ -185,6 +187,17 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
tileCache->setExtraTextureUsage(cacheSize);
}
+ /* PREFETCHING */
+ if (parameters.contains(QStringLiteral("here.mapping.prefetching_style"))) {
+ const QString prefetchingMode = parameters.value(QStringLiteral("here.mapping.prefetching_style")).toString();
+ if (prefetchingMode == QStringLiteral("TwoNeighbourLayers"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers;
+ else if (prefetchingMode == QStringLiteral("OneNeighbourLayer"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer;
+ else if (prefetchingMode == QStringLiteral("NoPrefetching"))
+ m_prefetchStyle = QGeoTiledMap::NoPrefetching;
+ }
+
setTileCache(tileCache);
populateMapSchemes();
loadMapVersion();
@@ -431,7 +444,9 @@ QString QGeoTiledMappingManagerEngineNokia::evaluateCopyrightsText(const QGeoMap
QGeoMap *QGeoTiledMappingManagerEngineNokia::createMap()
{
- return new QGeoTiledMapNokia(this);
+ QGeoTiledMap *map = new QGeoTiledMapNokia(this);
+ map->setPrefetchStyle(m_prefetchStyle);
+ return map;
}
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
index a55f71c0..d07a93ba 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
@@ -96,8 +96,15 @@ QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec)
{
// TODO add error detection for if request.connectivityMode() != QGraphicsGeoMap::OnlineMode
int ppi = m_ppi;
- if ((spec.mapId() == 2) || (spec.mapId() == 12) || (spec.mapId() == 21))
+ if ((spec.mapId() == 2) || (spec.mapId() == 12) || (spec.mapId() == 21)) {
ppi = 72; // HiDpi apparently not supported for these maps
+ } else if ((spec.mapId() >= 7 && spec.mapId() <= 11)
+ || (spec.mapId() == 14)
+ || (spec.mapId() == 16)
+ || (spec.mapId() == 18)
+ || (spec.mapId() == 20)) {
+ ppi = 250; // LoDpi apparently not supported for these maps
+ }
QString rawRequest = getRequestString(spec, ppi);
if (rawRequest.isEmpty()) {
diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
index 0e1fb356..da7b61d2 100644
--- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
@@ -63,6 +63,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
cameraCaps.setMaximumTilt(80);
cameraCaps.setMinimumFieldOfView(20.0);
cameraCaps.setMaximumFieldOfView(120.0);
+ cameraCaps.setOverzoomEnabled(true);
setCameraCapabilities(cameraCaps);
setTileSize(QSize(256, 256));
@@ -161,26 +162,27 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
/* QGeoTileProviderOsms setup */
+ const QByteArray pluginName = "osm";
m_providers.push_back( new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Street map view in daylight mode"), false, false, 1),
+ QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Street map view in daylight mode"), false, false, 1, pluginName),
providers_street, cameraCaps ));
m_providers.push_back( new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2),
+ QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2, pluginName),
providers_satellite, cameraCaps ));
m_providers.push_back( new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::CycleMap, tr("Cycle Map"), tr("Cycle map view in daylight mode"), false, false, 3),
+ QGeoMapType(QGeoMapType::CycleMap, tr("Cycle Map"), tr("Cycle map view in daylight mode"), false, false, 3, pluginName),
providers_cycle, cameraCaps ));
m_providers.push_back( new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Public transit map view in daylight mode"), false, false, 4),
+ QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Public transit map view in daylight mode"), false, false, 4, pluginName),
providers_transit, cameraCaps ));
m_providers.push_back( new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::TransitMap, tr("Night Transit Map"), tr("Public transit map view in night mode"), false, true, 5),
+ QGeoMapType(QGeoMapType::TransitMap, tr("Night Transit Map"), tr("Public transit map view in night mode"), false, true, 5, pluginName),
providers_nighttransit, cameraCaps ));
m_providers.push_back( new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view"), false, false, 6),
+ QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view"), false, false, 6, pluginName),
providers_terrain, cameraCaps ));
m_providers.push_back( new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::PedestrianMap, tr("Hiking Map"), tr("Hiking map view"), false, false, 7),
+ QGeoMapType(QGeoMapType::PedestrianMap, tr("Hiking Map"), tr("Hiking map view"), false, false, 7, pluginName),
providers_hiking, cameraCaps ));
if (parameters.contains(QStringLiteral("osm.mapping.custom.host"))
@@ -204,7 +206,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
m_providers.push_back(
new QGeoTileProviderOsm( nm,
- QGeoMapType(QGeoMapType::CustomMap, tr("Custom URL Map"), tr("Custom url map view set via urlprefix parameter"), false, false, 8),
+ QGeoMapType(QGeoMapType::CustomMap, tr("Custom URL Map"), tr("Custom url map view set via urlprefix parameter"), false, false, 8, pluginName),
{ new TileProvider(tmsServer + QStringLiteral("%z/%x/%y.png"),
QStringLiteral("png"),
mapCopyright,
@@ -236,7 +238,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
m_cacheDirectory = parameters.value(QStringLiteral("osm.mapping.cache.directory")).toString();
} else {
// managerName() is not yet set, we have to hardcode the plugin name below
- m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String("osm");
+ m_cacheDirectory = QAbstractGeoTileCache::baseLocationCacheDirectory() + QLatin1String(pluginName);
}
if (parameters.contains(QStringLiteral("osm.mapping.offline.directory")))
m_offlineDirectory = parameters.value(QStringLiteral("osm.mapping.offline.directory")).toString();
@@ -311,6 +313,17 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
}
setTileFetcher(tileFetcher);
+ /* PREFETCHING */
+ if (parameters.contains(QStringLiteral("osm.mapping.prefetching_style"))) {
+ const QString prefetchingMode = parameters.value(QStringLiteral("osm.mapping.prefetching_style")).toString();
+ if (prefetchingMode == QStringLiteral("TwoNeighbourLayers"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchTwoNeighbourLayers;
+ else if (prefetchingMode == QStringLiteral("OneNeighbourLayer"))
+ m_prefetchStyle = QGeoTiledMap::PrefetchNeighbourLayer;
+ else if (prefetchingMode == QStringLiteral("NoPrefetching"))
+ m_prefetchStyle = QGeoTiledMap::NoPrefetching;
+ }
+
*error = QGeoServiceProvider::NoError;
errorString->clear();
}
@@ -324,6 +337,7 @@ QGeoMap *QGeoTiledMappingManagerEngineOsm::createMap()
QGeoTiledMap *map = new QGeoTiledMapOsm(this);
connect(qobject_cast<QGeoFileTileCacheOsm *>(tileCache()), &QGeoFileTileCacheOsm::mapDataUpdated
, map, &QGeoTiledMap::clearScene);
+ map->setPrefetchStyle(m_prefetchStyle);
return map;
}
@@ -337,13 +351,13 @@ QString QGeoTiledMappingManagerEngineOsm::customCopyright() const
return m_customCopyright;
}
-QGeoCameraCapabilities QGeoTiledMappingManagerEngineOsm::cameraCapabilities(const QGeoMapType &mapType) const
+QGeoCameraCapabilities QGeoTiledMappingManagerEngineOsm::cameraCapabilities(int mapId) const
{
- if (mapType.mapId() == 0)
- return QGeoMappingManagerEngine::cameraCapabilities(mapType);
- int idx = mapType.mapId() - 1;
+ if (mapId == 0)
+ return QGeoMappingManagerEngine::cameraCapabilities(mapId);
+ int idx = mapId - 1;
if (idx >= m_providers.size())
- return QGeoMappingManagerEngine::cameraCapabilities(QGeoMapType());
+ return QGeoMappingManagerEngine::cameraCapabilities(mapId);
return m_providers[idx]->cameraCapabilities();
}
diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h
index db8b230c..c5f16c2b 100644
--- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h
+++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.h
@@ -59,10 +59,10 @@ public:
QGeoServiceProvider::Error *error, QString *errorString);
~QGeoTiledMappingManagerEngineOsm();
- QGeoMap *createMap();
+ QGeoMap *createMap() override;
const QVector<QGeoTileProviderOsm *> &providers();
QString customCopyright() const;
- QGeoCameraCapabilities cameraCapabilities(const QGeoMapType &mapType) const Q_DECL_OVERRIDE;
+ QGeoCameraCapabilities cameraCapabilities(int mapId) const override;
protected Q_SLOTS:
void onProviderResolutionFinished(const QGeoTileProviderOsm *provider);
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
index f7c25d61..8c5778d1 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
@@ -78,7 +78,7 @@ QGeoTileFetcherOsmPrivate::~QGeoTileFetcherOsmPrivate()
QGeoTileFetcherOsm::QGeoTileFetcherOsm(const QVector<QGeoTileProviderOsm *> &providers,
QNetworkAccessManager *nm,
- QObject *parent)
+ QGeoMappingManagerEngine *parent)
: QGeoTileFetcher(*new QGeoTileFetcherOsmPrivate(), parent), m_userAgent("Qt Location based application"),
m_providers(providers), m_nm(nm), m_ready(true)
{
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.h b/src/plugins/geoservices/osm/qgeotilefetcherosm.h
index a7b89bad..859033cc 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.h
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.h
@@ -59,7 +59,7 @@ class QGeoTileFetcherOsm : public QGeoTileFetcher
public:
QGeoTileFetcherOsm(const QVector<QGeoTileProviderOsm *> &providers,
QNetworkAccessManager *nm,
- QObject *parent = 0);
+ QGeoMappingManagerEngine *parent);
void setUserAgent(const QByteArray &userAgent);
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
index 54a079a2..3fac056e 100644
--- a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
+++ b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
@@ -140,6 +140,22 @@ bool QGeoPositionInfoSourceCL::enableLocationManager()
{
if (!m_locationManager) {
m_locationManager = [[CLLocationManager alloc] init];
+
+#ifdef Q_OS_IOS
+ NSDictionary<NSString *, id> *infoDict = [[NSBundle mainBundle] infoDictionary];
+ if (id value = [infoDict objectForKey:@"UIBackgroundModes"]) {
+ if ([value isKindOfClass:[NSArray class]]) {
+ NSArray *modes = static_cast<NSArray *>(value);
+ for (id mode in modes) {
+ if ([@"location" isEqualToString:mode]) {
+ m_locationManager.allowsBackgroundLocationUpdates = YES;
+ break;
+ }
+ }
+ }
+ }
+#endif
+
m_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
m_locationManager.delegate = [[PositionLocationDelegate alloc] initWithInfoSource:this];
diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
index 4df6ae81..6dfdc377 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
+++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
@@ -104,7 +104,7 @@ QGeoPositionInfoSourceGeoclueMaster::QGeoPositionInfoSourceGeoclueMaster(QObject
QGeoPositionInfoSourceGeoclueMaster::~QGeoPositionInfoSourceGeoclueMaster()
{
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) && QT_CONFIG(temporaryfile)
if (m_lastPosition.isValid()) {
QSaveFile file(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
QStringLiteral("/qtposition-geoclue"));
diff --git a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp
index c3152014..1694fd30 100644
--- a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp
+++ b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp
@@ -141,7 +141,7 @@ gchar *SatelliteGypsyEngine::eng_gconf_client_get_string(GConfClient *client, co
}
QGeoSatelliteInfoSourceGypsy::QGeoSatelliteInfoSourceGypsy(QObject *parent) : QGeoSatelliteInfoSource(parent),
- m_engine(0), m_satellite(0), m_device(0), m_updatesOngoing(false), m_requestOngoing(false), m_requestTimer(this)
+ m_engine(0), m_satellite(0), m_device(0), m_requestTimer(this), m_updatesOngoing(false), m_requestOngoing(false)
{
m_requestTimer.setSingleShot(true);
QObject::connect(&m_requestTimer, SIGNAL(timeout()), this, SLOT(requestUpdateTimeout()));
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
index 32a20a16..87e350dd 100644
--- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
+++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
@@ -97,8 +97,19 @@ QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent)
d->updatesOngoing = false;
qRegisterMetaType<QGeoPositionInfo>();
+}
+
+QGeoPositionInfoSourceWinRT::~QGeoPositionInfoSourceWinRT()
+{
+}
- requestAccess();
+int QGeoPositionInfoSourceWinRT::init()
+{
+ Q_D(QGeoPositionInfoSourceWinRT);
+ if (!requestAccess()) {
+ qWarning ("Location access failed.");
+ return -1;
+ }
HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, d]() {
HRESULT hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Devices_Geolocation_Geolocator).Get(),
&d->locator);
@@ -114,13 +125,17 @@ QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent)
return hr;
});
- Q_ASSERT_SUCCEEDED(hr);
+ if (FAILED(hr)) {
+ setError(QGeoPositionInfoSource::UnknownSourceError);
+ qErrnoWarning(hr, "Could not register status changed callback");
+ return -1;
+ }
hr = d->locator->put_DesiredAccuracy(PositionAccuracy::PositionAccuracy_Default);
if (FAILED(hr)) {
setError(QGeoPositionInfoSource::UnknownSourceError);
qErrnoWarning(hr, "Could not initialize desired accuracy.");
- return;
+ return -1;
}
d->positionToken.value = 0;
@@ -135,10 +150,7 @@ QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent)
setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
connect(this, &QGeoPositionInfoSourceWinRT::nativePositionUpdate, this, &QGeoPositionInfoSourceWinRT::updateSynchronized);
-}
-
-QGeoPositionInfoSourceWinRT::~QGeoPositionInfoSourceWinRT()
-{
+ return 0;
}
QGeoPositionInfo QGeoPositionInfoSourceWinRT::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h
index b8820dd2..9f3a1c7f 100644
--- a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h
+++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h
@@ -78,6 +78,7 @@ class QGeoPositionInfoSourceWinRT : public QGeoPositionInfoSource
public:
QGeoPositionInfoSourceWinRT(QObject *parent = 0);
~QGeoPositionInfoSourceWinRT();
+ int init();
QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
PositioningMethods supportedPositioningMethods() const;
diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp
index 81656c21..e58744a0 100644
--- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp
+++ b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp
@@ -39,7 +39,12 @@
QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryWinRT::positionInfoSource(QObject *parent)
{
- return new QGeoPositionInfoSourceWinRT(parent);
+ QGeoPositionInfoSourceWinRT *src = new QGeoPositionInfoSourceWinRT(parent);
+ if (src->init() < 0) {
+ delete src;
+ src = 0;
+ }
+ return src;
}
QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryWinRT::satelliteInfoSource(QObject *parent)
diff --git a/src/positioning/qclipperutils.cpp b/src/positioning/qclipperutils.cpp
index 08e65712..2f69d984 100644
--- a/src/positioning/qclipperutils.cpp
+++ b/src/positioning/qclipperutils.cpp
@@ -62,7 +62,7 @@ IntPoint QClipperUtils::toIntPoint(const QDoubleVector2D &p)
QList<QDoubleVector2D> QClipperUtils::pathToQList(const Path &path)
{
QList<QDoubleVector2D> res;
- res.reserve(path.size());
+ res.reserve(int(path.size()));
for (const IntPoint &ip: path)
res.append(toVector2D(ip));
return res;
@@ -71,7 +71,7 @@ QList<QDoubleVector2D> QClipperUtils::pathToQList(const Path &path)
QList<QList<QDoubleVector2D> > QClipperUtils::pathsToQList(const Paths &paths)
{
QList<QList<QDoubleVector2D> > res;
- res.reserve(paths.size());
+ res.reserve(int(paths.size()));
for (const Path &p: paths) {
res.append(pathToQList(p));
}
diff --git a/src/positioning/qdeclarativegeolocation_p.h b/src/positioning/qdeclarativegeolocation_p.h
index b208e503..a02d7b45 100644
--- a/src/positioning/qdeclarativegeolocation_p.h
+++ b/src/positioning/qdeclarativegeolocation_p.h
@@ -53,7 +53,7 @@
#include <QtCore/QObject>
#include <QtPositioning/QGeoLocation>
-#include <QtPositioning/QGeoRectangle>
+#include <QtPositioning/qgeorectangle.h>
#include <QtPositioning/private/qdeclarativegeoaddress_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qdoublematrix4x4.cpp b/src/positioning/qdoublematrix4x4.cpp
index 76e1252b..32cc7f1f 100644
--- a/src/positioning/qdoublematrix4x4.cpp
+++ b/src/positioning/qdoublematrix4x4.cpp
@@ -40,6 +40,7 @@
#include "qdoublematrix4x4_p.h"
#include <QtCore/qmath.h>
//#include <QtCore/qvariant.h>
+#include <QtCore/qdatastream.h>
#include <cmath>
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qdoublematrix4x4_p.h b/src/positioning/qdoublematrix4x4_p.h
index 3ce7b312..77b3e5b9 100644
--- a/src/positioning/qdoublematrix4x4_p.h
+++ b/src/positioning/qdoublematrix4x4_p.h
@@ -53,9 +53,9 @@
#include <QtPositioning/private/qpositioningglobal_p.h>
#include <QtPositioning/private/qdoublevector3d_p.h>
+#include <QtCore/QDebug>
#include <QtCore/qmetatype.h>
#include <QtCore/QRectF>
-#include <QtGui/qmatrix4x4.h>
QT_BEGIN_NAMESPACE
@@ -936,7 +936,7 @@ Q_POSITIONING_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QDoubleMatrix4x
#ifndef QT_NO_DATASTREAM
Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDoubleMatrix4x4 &);
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QDoubleMatrix4x4 &);
+Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDoubleMatrix4x4 &);
#endif
diff --git a/src/positioning/qgeocircle.h b/src/positioning/qgeocircle.h
index dc10ccf9..b41fe26c 100644
--- a/src/positioning/qgeocircle.h
+++ b/src/positioning/qgeocircle.h
@@ -40,7 +40,7 @@
#ifndef QGEOCIRCLE_H
#define QGEOCIRCLE_H
-#include <QtPositioning/QGeoShape>
+#include <QtPositioning/QGeoRectangle>
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index 87f4a9d4..ad3536af 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -115,7 +115,8 @@ QGeoPath::QGeoPath()
}
/*!
- Constructs a new geo path from a list of coordinates.
+ Constructs a new geo path from a list of coordinates
+ (\a path and \a width).
*/
QGeoPath::QGeoPath(const QList<QGeoCoordinate> &path, const qreal &width)
: QGeoShape(new QGeoPathPrivate(path, width))
@@ -463,7 +464,7 @@ bool QGeoPathPrivate::contains(const QGeoCoordinate &coordinate) const
QDoubleVector2D candidate = ( (p-a).length() < (p-b).length() ) ? a : b;
- if (u < (b - a).length()
+ if (u > 0 && u < 1
&& (p-intersection).length() < (p-candidate).length() ) // And it falls in the segment
candidate = intersection;
diff --git a/src/positioning/qgeorectangle.h b/src/positioning/qgeorectangle.h
index 9e9acf91..82afd725 100644
--- a/src/positioning/qgeorectangle.h
+++ b/src/positioning/qgeorectangle.h
@@ -42,7 +42,88 @@
#include <QtPositioning/QGeoShape>
-// QGeoRectangle declaration now in qgeoshape.h.
-// This file remains for compatibility.
+QT_BEGIN_NAMESPACE
+
+class QGeoRectanglePrivate;
+
+class Q_POSITIONING_EXPORT QGeoRectangle : public QGeoShape
+{
+ Q_GADGET
+ Q_PROPERTY(QGeoCoordinate bottomLeft READ bottomLeft WRITE setBottomLeft)
+ Q_PROPERTY(QGeoCoordinate bottomRight READ bottomRight WRITE setBottomRight)
+ Q_PROPERTY(QGeoCoordinate topLeft READ topLeft WRITE setTopLeft)
+ Q_PROPERTY(QGeoCoordinate topRight READ topRight WRITE setTopRight)
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
+ Q_PROPERTY(double height READ height WRITE setHeight)
+ Q_PROPERTY(double width READ width WRITE setWidth)
+
+public:
+ QGeoRectangle();
+ QGeoRectangle(const QGeoCoordinate &center, double degreesWidth, double degreesHeight);
+ QGeoRectangle(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
+ QGeoRectangle(const QList<QGeoCoordinate> &coordinates);
+ QGeoRectangle(const QGeoRectangle &other);
+ QGeoRectangle(const QGeoShape &other);
+
+ ~QGeoRectangle();
+
+ QGeoRectangle &operator=(const QGeoRectangle &other);
+
+ using QGeoShape::operator==;
+ bool operator==(const QGeoRectangle &other) const;
+
+ using QGeoShape::operator!=;
+ bool operator!=(const QGeoRectangle &other) const;
+
+ void setTopLeft(const QGeoCoordinate &topLeft);
+ QGeoCoordinate topLeft() const;
+
+ void setTopRight(const QGeoCoordinate &topRight);
+ QGeoCoordinate topRight() const;
+
+ void setBottomLeft(const QGeoCoordinate &bottomLeft);
+ QGeoCoordinate bottomLeft() const;
+
+ void setBottomRight(const QGeoCoordinate &bottomRight);
+ QGeoCoordinate bottomRight() const;
+
+ void setCenter(const QGeoCoordinate &center);
+ QGeoCoordinate center() const;
+
+ void setWidth(double degreesWidth);
+ double width() const;
+
+ void setHeight(double degreesHeight);
+ double height() const;
+
+ using QGeoShape::contains;
+ bool contains(const QGeoRectangle &rectangle) const;
+ Q_INVOKABLE bool intersects(const QGeoRectangle &rectangle) const;
+
+ Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
+ Q_INVOKABLE QGeoRectangle translated(double degreesLatitude, double degreesLongitude) const;
+ Q_INVOKABLE void extendRectangle(const QGeoCoordinate &coordinate);
+
+ Q_INVOKABLE QGeoRectangle united(const QGeoRectangle &rectangle) const;
+ QGeoRectangle operator|(const QGeoRectangle &rectangle) const;
+ QGeoRectangle &operator|=(const QGeoRectangle &rectangle);
+
+ Q_INVOKABLE QString toString() const;
+
+private:
+ inline QGeoRectanglePrivate *d_func();
+ inline const QGeoRectanglePrivate *d_func() const;
+};
+
+Q_DECLARE_TYPEINFO(QGeoRectangle, Q_MOVABLE_TYPE);
+
+inline QGeoRectangle QGeoRectangle::operator|(const QGeoRectangle &rectangle) const
+{
+ return united(rectangle);
+}
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QGeoRectangle)
#endif
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp
index 60ef18a4..ad7b0c58 100644
--- a/src/positioning/qgeoshape.cpp
+++ b/src/positioning/qgeoshape.cpp
@@ -95,6 +95,7 @@ bool QGeoShapePrivate::operator==(const QGeoShapePrivate &other) const
\value UnknownType A shape of unknown type.
\value RectangleType A rectangular shape.
\value CircleType A circular shape.
+ \value PathType A path type.
*/
/*!
@@ -229,7 +230,7 @@ bool QGeoShape::contains(const QGeoCoordinate &coordinate) const
}
/*!
- Returns a \a QGeoRectangle representing the geographical bounding rectangle of the
+ Returns a QGeoRectangle representing the geographical bounding rectangle of the
geo shape, that defines the latitudinal/longitudinal bounds of the geo shape.
\since 5.9
@@ -424,4 +425,6 @@ QDataStream &operator>>(QDataStream &stream, QGeoShape &shape)
}
#endif
+#include "moc_qgeoshape.cpp"
+
QT_END_NAMESPACE
diff --git a/src/positioning/qgeoshape.h b/src/positioning/qgeoshape.h
index 441c9ebb..defd0eec 100644
--- a/src/positioning/qgeoshape.h
+++ b/src/positioning/qgeoshape.h
@@ -106,90 +106,8 @@ Q_POSITIONING_EXPORT QDataStream &operator<<(QDataStream &stream, const QGeoShap
Q_POSITIONING_EXPORT QDataStream &operator>>(QDataStream &stream, QGeoShape &shape);
#endif
-
-
-// QGeoRectangle is declared here because of QGeoShape::boundingGeoRectangle
-class QGeoRectanglePrivate;
-
-class Q_POSITIONING_EXPORT QGeoRectangle : public QGeoShape
-{
- Q_GADGET
- Q_PROPERTY(QGeoCoordinate bottomLeft READ bottomLeft WRITE setBottomLeft)
- Q_PROPERTY(QGeoCoordinate bottomRight READ bottomRight WRITE setBottomRight)
- Q_PROPERTY(QGeoCoordinate topLeft READ topLeft WRITE setTopLeft)
- Q_PROPERTY(QGeoCoordinate topRight READ topRight WRITE setTopRight)
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
- Q_PROPERTY(double height READ height WRITE setHeight)
- Q_PROPERTY(double width READ width WRITE setWidth)
-
-public:
- QGeoRectangle();
- QGeoRectangle(const QGeoCoordinate &center, double degreesWidth, double degreesHeight);
- QGeoRectangle(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
- QGeoRectangle(const QList<QGeoCoordinate> &coordinates);
- QGeoRectangle(const QGeoRectangle &other);
- QGeoRectangle(const QGeoShape &other);
-
- ~QGeoRectangle();
-
- QGeoRectangle &operator=(const QGeoRectangle &other);
-
- using QGeoShape::operator==;
- bool operator==(const QGeoRectangle &other) const;
-
- using QGeoShape::operator!=;
- bool operator!=(const QGeoRectangle &other) const;
-
- void setTopLeft(const QGeoCoordinate &topLeft);
- QGeoCoordinate topLeft() const;
-
- void setTopRight(const QGeoCoordinate &topRight);
- QGeoCoordinate topRight() const;
-
- void setBottomLeft(const QGeoCoordinate &bottomLeft);
- QGeoCoordinate bottomLeft() const;
-
- void setBottomRight(const QGeoCoordinate &bottomRight);
- QGeoCoordinate bottomRight() const;
-
- void setCenter(const QGeoCoordinate &center);
- QGeoCoordinate center() const;
-
- void setWidth(double degreesWidth);
- double width() const;
-
- void setHeight(double degreesHeight);
- double height() const;
-
- using QGeoShape::contains;
- bool contains(const QGeoRectangle &rectangle) const;
- Q_INVOKABLE bool intersects(const QGeoRectangle &rectangle) const;
-
- Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
- Q_INVOKABLE QGeoRectangle translated(double degreesLatitude, double degreesLongitude) const;
- Q_INVOKABLE void extendRectangle(const QGeoCoordinate &coordinate);
-
- Q_INVOKABLE QGeoRectangle united(const QGeoRectangle &rectangle) const;
- QGeoRectangle operator|(const QGeoRectangle &rectangle) const;
- QGeoRectangle &operator|=(const QGeoRectangle &rectangle);
-
- Q_INVOKABLE QString toString() const;
-
-private:
- inline QGeoRectanglePrivate *d_func();
- inline const QGeoRectanglePrivate *d_func() const;
-};
-
-Q_DECLARE_TYPEINFO(QGeoRectangle, Q_MOVABLE_TYPE);
-
-inline QGeoRectangle QGeoRectangle::operator|(const QGeoRectangle &rectangle) const
-{
- return united(rectangle);
-}
-
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QGeoShape)
-Q_DECLARE_METATYPE(QGeoRectangle)
#endif
diff --git a/src/positioning/qgeoshape_p.h b/src/positioning/qgeoshape_p.h
index 251e872c..f8380654 100644
--- a/src/positioning/qgeoshape_p.h
+++ b/src/positioning/qgeoshape_p.h
@@ -53,7 +53,7 @@
#include <QtCore/QSharedData>
-#include "qgeoshape.h"
+#include "qgeorectangle.h"
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qlocationutils.cpp b/src/positioning/qlocationutils.cpp
index 829f1bbf..5304392b 100644
--- a/src/positioning/qlocationutils.cpp
+++ b/src/positioning/qlocationutils.cpp
@@ -361,7 +361,7 @@ bool QLocationUtils::getNmeaTime(const QByteArray &bytes, QTime *time)
int midLen = qMin(3, bytes.size() - dotIndex - 1);
int msecs = bytes.mid(dotIndex + 1, midLen).toUInt(&hasMsecs);
if (hasMsecs)
- tempTime = tempTime.addMSecs(msecs);
+ tempTime = tempTime.addMSecs(msecs*(midLen == 3 ? 1 : midLen == 2 ? 10 : 100));
}
if (tempTime.isValid()) {
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index ba7dc523..5594b8b0 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -62,6 +62,9 @@ qtHaveModule(location) {
declarative_geoshape
!mac: SUBDIRS += declarative_ui
+
+ # QTBUG-60268
+ boot2qt: SUBDIRS -= declarative_ui
}
}
diff --git a/tests/auto/declarative_geoshape/tst_locationsingleton.qml b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
index e38e4ec7..6ebee62a 100644
--- a/tests/auto/declarative_geoshape/tst_locationsingleton.qml
+++ b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
@@ -71,6 +71,13 @@ Item {
}
}
+ property variant trace1 : [ QtPositioning.coordinate(43.773175, 11.255386),
+ QtPositioning.coordinate(43.773546 , 11.255372) ]
+ property variant trace2 : [ QtPositioning.coordinate(43.773175, 11.255386),
+ QtPositioning.coordinate(43.773546 , 11.255372),
+ QtPositioning.coordinate(43.77453 , 11.255734)]
+
+
// coordinate unit square
property variant bl: QtPositioning.coordinate(0, 0)
property variant tl: QtPositioning.coordinate(1, 0)
@@ -186,6 +193,28 @@ Item {
rectangle = QtPositioning.shapeToRectangle(listBox)
verify(rectangle.isValid)
}
+
+ function test_shape_path_conversions() {
+ var path = QtPositioning.shapeToPath(QtPositioning.shape())
+ verify(!path.isValid)
+ path = QtPositioning.shapeToPath(QtPositioning.circle())
+ verify(!path.isValid)
+ path = QtPositioning.shapeToPath(QtPositioning.circle(tl, 10000))
+ verify(!path.isValid)
+ path = QtPositioning.shapeToPath(QtPositioning.rectangle())
+ verify(!path.isValid)
+ path = QtPositioning.shapeToPath(QtPositioning.rectangle(tl, br))
+ verify(!path.isValid)
+
+ path = QtPositioning.shapeToPath(QtPositioning.path())
+ verify(!path.isValid)
+ path = QtPositioning.shapeToPath(QtPositioning.path(trace1, 1))
+ verify(path.isValid)
+ path = QtPositioning.shapeToPath(QtPositioning.path(trace2, 2))
+ verify(path.isValid)
+ verify(path !== QtPositioning.shapeToPath(QtPositioning.path(trace1, 1)))
+ compare(path, QtPositioning.shapeToPath(QtPositioning.path(trace2, 2)))
+ }
}
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 6691580e..846a621f 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -57,6 +57,14 @@ Item {
property variant coordinate5: QtPositioning.coordinate(20, 180)
property variant invalidCoordinate: QtPositioning.coordinate()
property variant altitudelessCoordinate: QtPositioning.coordinate(50, 50)
+ property bool allMapsReady: mapZoomOnCompleted.mapReady
+ && mapZoomDefault.mapReady
+ && mapZoomUserInit.mapReady
+ && map.mapReady
+ && mapPar.mapReady
+ && coordinateMap.mapReady
+ && mapTiltBearing.mapReady
+ && mapTiltBearingHere.mapReady
Map { id: mapZoomOnCompleted; width: 200; height: 200;
zoomLevel: 3; center: coordinate1; plugin: testPlugin;
@@ -98,7 +106,7 @@ Item {
TestCase {
- when: windowShown
+ when: windowShown && allMapsReady
name: "MapProperties"
function fuzzy_compare(val, ref) {
diff --git a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
index d9b71edd..20477509 100644
--- a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
+++ b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
@@ -79,7 +79,7 @@ Item {
}
TestCase {
- when: windowShown
+ when: windowShown && map.mapReady
name: "CoordinateAnimation"
function test_coordinate_animation() {
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index 8da712b2..84ffa429 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -94,7 +94,7 @@ Item {
SignalSpy {id: mouseAreaBottomSpy; target: mouseAreaBottom; signalName: 'onPressed'}
TestCase {
- when: windowShown
+ when: windowShown && map.mapReady
name: "MapFlick"
function init()
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index b75daf38..1646fdba 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -216,7 +216,7 @@ Item {
}
TestCase {
name: "MapItems"
- when: windowShown
+ when: windowShown && map.mapReady
function initTestCase()
{
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index 0c5f5c0b..80225c16 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -278,7 +278,7 @@ Item {
TestCase {
name: "MapItemDetails"
- when: windowShown
+ when: windowShown && map.mapReady
/*
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index 92b0bb6e..8d1ee42b 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -217,7 +217,7 @@ Item {
TestCase {
name: "MapItemsFitViewport"
- when: windowShown
+ when: windowShown && map.mapReady
function initTestCase()
{
diff --git a/tests/auto/declarative_ui/tst_map_itemview.qml b/tests/auto/declarative_ui/tst_map_itemview.qml
index db788ace..bbd70c8e 100644
--- a/tests/auto/declarative_ui/tst_map_itemview.qml
+++ b/tests/auto/declarative_ui/tst_map_itemview.qml
@@ -40,6 +40,11 @@ Item {
Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true }
property variant mapDefaultCenter: QtPositioning.coordinate(10, 30)
+ property bool allMapsReady: map.mapReady
+ && map3.mapReady
+ && mapForView.mapReady
+ && mapForTestingListModel.mapReady
+ && mapForTestingRouteModel.mapReady
Map {
id: map
@@ -259,7 +264,7 @@ Item {
TestCase {
name: "MapItem"
- when: windowShown
+ when: windowShown && allMapsReady
function clear_data() {
mapItemSpy.clear()
}
diff --git a/tests/auto/declarative_ui/tst_map_keepgrab.qml b/tests/auto/declarative_ui/tst_map_keepgrab.qml
index fa47eec8..7690b78d 100644
--- a/tests/auto/declarative_ui/tst_map_keepgrab.qml
+++ b/tests/auto/declarative_ui/tst_map_keepgrab.qml
@@ -61,7 +61,7 @@ Item {
TestCase {
- when: windowShown
+ when: windowShown && map.mapReady
name: "MapKeepGrabAndPreventSteal"
function initTestCase()
diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml
index 99aff03d..dd9de73a 100644
--- a/tests/auto/declarative_ui/tst_map_mouse.qml
+++ b/tests/auto/declarative_ui/tst_map_mouse.qml
@@ -161,7 +161,7 @@ Item {
TestCase {
name: "MouseArea"
- when: windowShown
+ when: windowShown && map.mapReady
SignalSpy {id: mouseUpperClickedSpy; target: mouseUpper; signalName: "clicked"}
SignalSpy {id: mouseLowerClickedSpy; target: mouseLower; signalName: "clicked"}
SignalSpy {id: mouseOverlapperClickedSpy; target: mouseOverlapper; signalName: "clicked"}
diff --git a/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970 b/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970
index f80e44a1..6d913eab 100644
--- a/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970
+++ b/tests/auto/declarative_ui/tst_map_pinch.qml.QTBUG-47970
@@ -102,7 +102,7 @@ Item {
SignalSpy {id: mouseAreaBottomSpy; target: mouseAreaBottom; signalName: 'onPressed'}
TestCase {
- when: windowShown
+ when: windowShown && map.mapReady
name: "MapPinch"
function init()
diff --git a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
index df729392..5f6f0116 100644
--- a/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeotiledmappingmanagerengine_test.h
@@ -62,11 +62,12 @@ public:
capabilities.setMaximumTilt(60);
setTileSize(QSize(256, 256));
+ const QByteArray pluginName = "qmlgeo.test.plugin";
QList<QGeoMapType> mapTypes;
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("StreetMap"), tr("StreetMap"), false, false, 1);
- mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("SatelliteMapDay"), tr("SatelliteMapDay"), false, false, 2);
- mapTypes << QGeoMapType(QGeoMapType::CycleMap, tr("CycleMap"), tr("CycleMap"), false, false, 3);
- mapTypes << QGeoMapType(QGeoMapType::CustomMap, tr("AlternateCameraCapabilities"), tr("AlternateCameraCapabilities"), false, false, 4);
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("StreetMap"), tr("StreetMap"), false, false, 1, pluginName);
+ mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("SatelliteMapDay"), tr("SatelliteMapDay"), false, false, 2, pluginName);
+ mapTypes << QGeoMapType(QGeoMapType::CycleMap, tr("CycleMap"), tr("CycleMap"), false, false, 3, pluginName);
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, tr("AlternateCameraCapabilities"), tr("AlternateCameraCapabilities"), false, false, 4, pluginName);
setSupportedMapTypes(mapTypes);
QGeoTileFetcherTest *fetcher = new QGeoTileFetcherTest(this);
@@ -86,14 +87,14 @@ public:
setTileFetcher(fetcher);
}
- QGeoMap *createMap()
+ QGeoMap *createMap() override
{
return new QGeoTiledMapTest(this);
}
- QGeoCameraCapabilities cameraCapabilities(const QGeoMapType &mapType) const Q_DECL_OVERRIDE
+ QGeoCameraCapabilities cameraCapabilities(int mapId) const Q_DECL_OVERRIDE
{
- switch (mapType.mapId()) {
+ switch (mapId) {
case 4:
{
QGeoCameraCapabilities capabilities;
@@ -108,7 +109,7 @@ public:
return capabilities;
}
default:
- return QGeoMappingManagerEngine::cameraCapabilities(mapType);
+ return QGeoMappingManagerEngine::cameraCapabilities(mapId);
}
}
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h
index a25b0119..e108f484 100644
--- a/tests/auto/geotestplugin/qgeotilefetcher_test.h
+++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h
@@ -32,6 +32,7 @@
#include <QtLocation/private/qgeotiledmapreply_p.h>
#include <QtLocation/private/qgeotilefetcher_p.h>
#include <QtLocation/private/qgeotilespec_p.h>
+#include <QtLocation/private/qgeomappingmanagerengine_p.h>
#include <QLocale>
#include <QPainter>
@@ -65,7 +66,7 @@ class QGeoTileFetcherTest: public QGeoTileFetcher
{
Q_OBJECT
public:
- QGeoTileFetcherTest(QObject *parent = 0)
+ QGeoTileFetcherTest(QGeoMappingManagerEngine *parent)
: QGeoTileFetcher(parent), finishRequestImmediately_(false), errorCode_(QGeoTiledMapReply::NoError)
{
}
diff --git a/tests/auto/maptype/tst_maptype.cpp b/tests/auto/maptype/tst_maptype.cpp
index 9b7956fd..43d3175c 100644
--- a/tests/auto/maptype/tst_maptype.cpp
+++ b/tests/auto/maptype/tst_maptype.cpp
@@ -52,8 +52,9 @@ tst_MapType::tst_MapType() {}
void tst_MapType::constructorTest()
{
+ const QByteArray pluginName = "tst_MapType";
QGeoMapType *testObjPtr = new QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street map"),
- QStringLiteral("map description"), true, true, 1);
+ QStringLiteral("map description"), true, true, 1, pluginName);
QVERIFY(testObjPtr);
QCOMPARE(testObjPtr->style(), QGeoMapType::StreetMap);
QCOMPARE(testObjPtr->name(), QStringLiteral("street map"));
@@ -61,6 +62,7 @@ void tst_MapType::constructorTest()
QVERIFY(testObjPtr->mobile());
QVERIFY(testObjPtr->night());
QCOMPARE(testObjPtr->mapId(), 1);
+ QCOMPARE(testObjPtr->pluginName(), pluginName);
delete testObjPtr;
testObjPtr = new QGeoMapType();
@@ -70,6 +72,7 @@ void tst_MapType::constructorTest()
QVERIFY2(!testObjPtr->mobile(), "Wrong default value");
QVERIFY2(!testObjPtr->night(), "Wrong default value");
QCOMPARE(testObjPtr->mapId(), 0);
+ QCOMPARE(testObjPtr->pluginName(), QByteArrayLiteral(""));
delete testObjPtr;
}
@@ -79,50 +82,58 @@ void tst_MapType::comparison_data()
QTest::addColumn<QGeoMapType>("type2");
QTest::addColumn<bool>("expected");
+ const QByteArray pluginName = "tst_MapType";
+
QTest::newRow("null") << QGeoMapType() << QGeoMapType() << true;
QTest::newRow("equal") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< true;
QTest::newRow("style") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< QGeoMapType(QGeoMapType::TerrainMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< false;
QTest::newRow("name") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("different name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< false;
QTest::newRow("description") << QGeoMapType(QGeoMapType::StreetMap,
QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< QGeoMapType(QGeoMapType::StreetMap,
QStringLiteral("street name"),
- QStringLiteral("different desc"), false, false, 42)
+ QStringLiteral("different desc"), false, false, 42, pluginName)
<< false;
QTest::newRow("mobile") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), true, false, 42)
+ QStringLiteral("street desc"), true, false, 42, pluginName)
<< false;
QTest::newRow("night") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, true, 42)
+ QStringLiteral("street desc"), false, true, 42, pluginName)
<< false;
QTest::newRow("id") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 42)
+ QStringLiteral("street desc"), false, false, 42, pluginName)
+ << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
+ QStringLiteral("street desc"), false, false, 99, pluginName)
+ << false;
+
+ QTest::newRow("plugin_name") << QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
+ QStringLiteral("street desc"), false, false, 42, pluginName)
<< QGeoMapType(QGeoMapType::StreetMap, QStringLiteral("street name"),
- QStringLiteral("street desc"), false, false, 99)
+ QStringLiteral("street desc"), false, false, 42, QByteArrayLiteral("abc"))
<< false;
}
diff --git a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
index 1ac0abfa..0c664ba6 100644
--- a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
+++ b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
@@ -150,7 +150,7 @@ void tst_QGeoCameraTiles::tilesPlugin()
ct.setTileSize(16);
ct.setCameraData(camera);
ct.setScreenSize(QSize(32, 32));
- ct.setMapType(QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1));
+ ct.setMapType(QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1, QByteArrayLiteral("")));
QSet<QGeoTileSpec> tiles1 = ct.createTiles();
@@ -202,7 +202,7 @@ void tst_QGeoCameraTiles::tilesMapType()
QSet<QGeoTileSpec> tiles1 = ct.createTiles();
- QGeoMapType mapType1 = QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1);
+ QGeoMapType mapType1 = QGeoMapType(QGeoMapType::StreetMap, "street map", "street map", false, false, 1, QByteArrayLiteral(""));
ct.setMapType(mapType1);
QSet<QGeoTileSpec> tiles2 = ct.createTiles();
@@ -220,7 +220,7 @@ void tst_QGeoCameraTiles::tilesMapType()
QCOMPARE(tiles2, tiles2_check);
- QGeoMapType mapType2 = QGeoMapType(QGeoMapType::StreetMap, "satellite map", "satellite map", false, false, 2);
+ QGeoMapType mapType2 = QGeoMapType(QGeoMapType::StreetMap, "satellite map", "satellite map", false, false, 2, QByteArrayLiteral(""));
ct.setMapType(mapType2);
QSet<QGeoTileSpec> tiles3 = ct.createTiles();
diff --git a/tests/auto/qgeopath/tst_qgeopath.cpp b/tests/auto/qgeopath/tst_qgeopath.cpp
index 8c4ac767..9244394a 100644
--- a/tests/auto/qgeopath/tst_qgeopath.cpp
+++ b/tests/auto/qgeopath/tst_qgeopath.cpp
@@ -275,8 +275,8 @@ void tst_QGeoPath::contains_data()
c.append(QGeoCoordinate(3,0));
QTest::newRow("One of the points") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(2, 2) << true;
- QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0, 0) << false;
- QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0, 0) << true;
+ QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0.8, 0.8) << false;
+ QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0.8, 0.8) << true;
}
void tst_QGeoPath::contains()
@@ -378,7 +378,7 @@ void tst_QGeoPath::extendShape_data()
QTest::newRow("One of the points") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(2, 2) << true << true;
QTest::newRow("Not so far away") << c[0] << c[1] << c[2] << 0.0 << QGeoCoordinate(0, 0) << false << true;
- QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0, 0) << true << true;
+ QTest::newRow("Not so far away and large line") << c[0] << c[1] << c[2] << 100000.0 << QGeoCoordinate(0.8, 0.8) << true << true;
}
QTEST_MAIN(tst_QGeoPath)
diff --git a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp
index 3026cd92..b8866b48 100644
--- a/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp
+++ b/tests/plugins/declarativetestplugin/qdeclarativepinchgenerator.cpp
@@ -218,6 +218,7 @@ void QDeclarativePinchGenerator::itemChange(ItemChange change, const ItemChangeD
void QDeclarativePinchGenerator::timerEvent(QTimerEvent *event)
{
Q_ASSERT(replayTimer_ == event->timerId());
+ Q_UNUSED(event);
Q_ASSERT(state_ == Replaying);
int slaveSwipe = masterSwipe_ ^ 1;