summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-02-14 18:20:15 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-04-17 13:02:53 +0000
commit2782765e20ba3bc6af92375574456fd54d4243f7 (patch)
tree9a70096fdddcc7d28224d6749dd0c7b0da5bcdbb
parent05edc644337a33e3e72d993b8114efc755a4320a (diff)
downloadqtlocation-2782765e20ba3bc6af92375574456fd54d4243f7.tar.gz
Introduce map objects reference implementation
This patch introduces a reference implementation for the QGeoMapObject subclasses in the locationlabs module. If this module is built, all current plugins, with the exception of mapboxgl, will also be able to render map objects. The current reference implementation of map objects is not optimized, but it can be useful for both testing and feature parity (so that switching between plugins will give the same result). Change-Id: I830ebb3813f219e42c085f450952a2b4327361cd Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem.cpp9
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem_p.h10
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem_p.h4
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp6
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem_p.h7
-rw-r--r--src/location/declarativemaps/qgeomapitemgeometry_p.h5
-rw-r--r--src/location/declarativemaps/qgeomapobject.cpp7
-rw-r--r--src/location/declarativemaps/qgeomapobject_p_p.h1
-rw-r--r--src/location/labs/labs.pri4
-rw-r--r--src/location/labs/qgeotiledmaplabs.cpp295
-rw-r--r--src/location/labs/qgeotiledmaplabs_p.h90
-rw-r--r--src/location/labs/qsg/qmapcircleobjectqsg.cpp218
-rw-r--r--src/location/labs/qsg/qmapcircleobjectqsg_p_p.h98
-rw-r--r--src/location/labs/qsg/qmapiconobjectqsg.cpp226
-rw-r--r--src/location/labs/qsg/qmapiconobjectqsg_p_p.h94
-rw-r--r--src/location/labs/qsg/qmappolygonobjectqsg.cpp212
-rw-r--r--src/location/labs/qsg/qmappolygonobjectqsg_p_p.h100
-rw-r--r--src/location/labs/qsg/qmappolylineobjectqsg.cpp160
-rw-r--r--src/location/labs/qsg/qmappolylineobjectqsg_p_p.h96
-rw-r--r--src/location/labs/qsg/qmaprouteobjectqsg.cpp99
-rw-r--r--src/location/labs/qsg/qmaprouteobjectqsg_p_p.h87
-rw-r--r--src/location/labs/qsg/qqsgmapobject.cpp64
-rw-r--r--src/location/labs/qsg/qqsgmapobject_p.h61
-rw-r--r--src/plugins/geoservices/esri/esri.pro3
-rw-r--r--src/plugins/geoservices/esri/geotiledmap_esri.cpp2
-rw-r--r--src/plugins/geoservices/esri/geotiledmap_esri.h8
-rw-r--r--src/plugins/geoservices/itemsoverlay/itemsoverlay.pro3
-rw-r--r--src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp200
-rw-r--r--src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h4
-rw-r--r--src/plugins/geoservices/mapbox/mapbox.pro3
-rw-r--r--src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp8
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp2
-rw-r--r--src/plugins/geoservices/nokia/nokia.pro3
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmap_nokia.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmap_nokia.h8
-rw-r--r--src/plugins/geoservices/osm/osm.pro3
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmaposm.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmaposm.h8
-rw-r--r--src/positioning/qdoublevector2d_p.h6
39 files changed, 2183 insertions, 35 deletions
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
index 68e61ee5..e8b73ae5 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
@@ -501,7 +501,7 @@ void QDeclarativeCircleMapItem::updatePolish()
QList<QDoubleVector2D> circlePath = circlePath_;
int pathCount = circlePath.size();
- bool preserve = preserveCircleGeometry(circlePath, circle_.center(), circle_.radius());
+ bool preserve = preserveCircleGeometry(circlePath, circle_.center(), circle_.radius(), p);
// using leftBound_ instead of the analytically calculated circle_.boundingGeoRectangle().topLeft());
// to fix QTBUG-62154
geometry_.setPreserveGeometry(true, leftBound_); // to set the geoLeftBound_
@@ -623,11 +623,11 @@ void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const
}
bool QDeclarativeCircleMapItem::preserveCircleGeometry (QList<QDoubleVector2D> &path,
- const QGeoCoordinate &center, qreal distance)
+ const QGeoCoordinate &center, qreal distance, const QGeoProjectionWebMercator &p)
{
// if circle crosses north/south pole, then don't preserve circular shape,
if ( crossEarthPole(center, distance)) {
- updateCirclePathForRendering(path, center, distance);
+ updateCirclePathForRendering(path, center, distance, p);
return false;
}
return true;
@@ -653,9 +653,8 @@ bool QDeclarativeCircleMapItem::preserveCircleGeometry (QList<QDoubleVector2D> &
*/
void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QDoubleVector2D> &path,
const QGeoCoordinate &center,
- qreal distance)
+ qreal distance, const QGeoProjectionWebMercator &p)
{
- const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(map()->geoProjection());
const qreal poleLat = 90;
const qreal distanceToNorthPole = center.distanceTo(QGeoCoordinate(poleLat, 0));
const qreal distanceToSouthPole = center.distanceTo(QGeoCoordinate(-poleLat, 0));
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
index bb359ee3..2e8c56f8 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem_p.h
@@ -58,7 +58,7 @@
QT_BEGIN_NAMESPACE
-class QGeoMapCircleGeometry : public QGeoMapPolygonGeometry
+class Q_LOCATION_PRIVATE_EXPORT QGeoMapCircleGeometry : public QGeoMapPolygonGeometry
{
public:
QGeoMapCircleGeometry();
@@ -99,8 +99,10 @@ public:
static bool crossEarthPole(const QGeoCoordinate &center, qreal distance);
static void calculatePeripheralPoints(QList<QGeoCoordinate> &path, const QGeoCoordinate &center,
qreal distance, int steps, QGeoCoordinate &leftBound);
- bool preserveCircleGeometry(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
- qreal distance);
+ static bool preserveCircleGeometry(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
+ qreal distance, const QGeoProjectionWebMercator &p);
+ static void updateCirclePathForRendering(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
+ qreal distance, const QGeoProjectionWebMercator &p);
Q_SIGNALS:
void centerChanged(const QGeoCoordinate &center);
@@ -117,8 +119,6 @@ protected Q_SLOTS:
private:
void updateCirclePath();
- void updateCirclePathForRendering(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
- qreal distance);
private:
QGeoCircle circle_;
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
index 72bfd856..1e2a91c9 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
class MapPolygonNode;
-class QGeoMapPolygonGeometry : public QGeoMapItemGeometry
+class Q_LOCATION_PRIVATE_EXPORT QGeoMapPolygonGeometry : public QGeoMapItemGeometry
{
public:
QGeoMapPolygonGeometry();
@@ -137,7 +137,7 @@ private:
//////////////////////////////////////////////////////////////////////
-class MapPolygonNode : public QSGGeometryNode
+class Q_LOCATION_PRIVATE_EXPORT MapPolygonNode : public QSGGeometryNode
{
public:
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index 3b004dce..632f71d7 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -410,6 +410,12 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
this->translate( -1 * sourceBounds_.topLeft());
}
+void QGeoMapPolylineGeometry::clearSource()
+{
+ srcPoints_.clear();
+ srcPointTypes_.clear();
+}
+
QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent)
: QDeclarativeGeoMapItemBase(parent), line_(this), dirtyMaterial_(true), updatingGeometry_(false)
{
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
index 03fba636..61439097 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
@@ -85,7 +85,7 @@ private:
QColor color_;
};
-class QGeoMapPolylineGeometry : public QGeoMapItemGeometry
+class Q_LOCATION_PRIVATE_EXPORT QGeoMapPolylineGeometry : public QGeoMapItemGeometry
{
public:
QGeoMapPolylineGeometry();
@@ -97,7 +97,8 @@ public:
void updateScreenPoints(const QGeoMap &map,
qreal strokeWidth);
-protected:
+ void clearSource();
+
QList<QList<QDoubleVector2D> > clipPath(const QGeoMap &map,
const QList<QDoubleVector2D> &path,
QDoubleVector2D &leftBoundWrapped);
@@ -177,7 +178,7 @@ private:
//////////////////////////////////////////////////////////////////////
-class MapPolylineNode : public QSGGeometryNode
+class Q_LOCATION_PRIVATE_EXPORT MapPolylineNode : public QSGGeometryNode
{
public:
diff --git a/src/location/declarativemaps/qgeomapitemgeometry_p.h b/src/location/declarativemaps/qgeomapitemgeometry_p.h
index 595107ae..5149a7c0 100644
--- a/src/location/declarativemaps/qgeomapitemgeometry_p.h
+++ b/src/location/declarativemaps/qgeomapitemgeometry_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
class QSGGeometry;
class QGeoMap;
-class QGeoMapItemGeometry
+class Q_LOCATION_PRIVATE_EXPORT QGeoMapItemGeometry
{
public:
QGeoMapItemGeometry();
@@ -124,6 +124,9 @@ public:
static QRectF translateToCommonOrigin(const QList<QGeoMapItemGeometry *> &geoms);
+private:
+ QGeoMapItemGeometry(const QGeoMapItemGeometry &other); // Or else it may crash on copy
+ QGeoMapItemGeometry &operator= (const QGeoMapItemGeometry & other); // Or else it may crash on copy
protected:
bool sourceDirty_;
diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp
index 2e81afa9..d1d78b66 100644
--- a/src/location/declarativemaps/qgeomapobject.cpp
+++ b/src/location/declarativemaps/qgeomapobject.cpp
@@ -185,7 +185,7 @@ void QGeoMapObject::setMap(QGeoMap *map)
d_ptr->m_componentCompleted = oldCmponentCompleted;
d_ptr->setVisible(oldVisible);
}
- d_ptr->m_map = map;
+ d_ptr->setMap(map);
const QList<QGeoMapObject *> kids = geoMapObjectChildren();
for (auto kid : kids)
@@ -269,4 +269,9 @@ void QGeoMapObjectPrivate::setVisible(bool visible)
m_visible = visible;
}
+void QGeoMapObjectPrivate::setMap(QGeoMap *map)
+{
+ m_map = map;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qgeomapobject_p_p.h b/src/location/declarativemaps/qgeomapobject_p_p.h
index 000a992d..fa788b00 100644
--- a/src/location/declarativemaps/qgeomapobject_p_p.h
+++ b/src/location/declarativemaps/qgeomapobject_p_p.h
@@ -72,6 +72,7 @@ public:
virtual QGeoMapObject::Type type() const;
virtual bool visible() const;
virtual void setVisible(bool visible);
+ virtual void setMap(QGeoMap *map);
virtual QGeoMapObjectPrivate *clone() = 0; // to allow proper detaching
QGeoMapObject *q = nullptr;
diff --git a/src/location/labs/labs.pri b/src/location/labs/labs.pri
index de2fd820..2da5e90d 100644
--- a/src/location/labs/labs.pri
+++ b/src/location/labs/labs.pri
@@ -1,4 +1,4 @@
INCLUDEPATH += labs
-PRIVATE_HEADERS += $$files($$PWD/*.h)
-SOURCES += $$files($$PWD/*.cpp)
+PRIVATE_HEADERS += $$files($$PWD/*.h) $$files($$PWD/qsg/*.h)
+SOURCES += $$files($$PWD/*.cpp) $$files($$PWD/qsg/*.cpp)
diff --git a/src/location/labs/qgeotiledmaplabs.cpp b/src/location/labs/qgeotiledmaplabs.cpp
new file mode 100644
index 00000000..2e4b2c16
--- /dev/null
+++ b/src/location/labs/qgeotiledmaplabs.cpp
@@ -0,0 +1,295 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmaplabs_p.h"
+#include <QtLocation/private/qgeotiledmap_p_p.h>
+#include <QtLocation/private/qgeomapobject_p.h>
+#include <QtLocation/private/qmappolylineobjectqsg_p_p.h>
+#include <QtLocation/private/qmappolygonobjectqsg_p_p.h>
+#include <QtLocation/private/qmapcircleobjectqsg_p_p.h>
+#include <QtLocation/private/qmaprouteobjectqsg_p_p.h>
+#include <QtLocation/private/qmapiconobjectqsg_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+struct MapObject {
+ MapObject(QPointer<QGeoMapObject> &o, QQSGMapObject *sgo)
+ : object(o), sgObject(sgo) {}
+ QPointer<QGeoMapObject> object;
+ QQSGMapObject *sgObject = nullptr;
+};
+
+class QGeoTiledMapLabsPrivate : public QGeoTiledMapPrivate
+{
+ Q_DECLARE_PUBLIC(QGeoTiledMapLabs)
+public:
+ QGeoTiledMapLabsPrivate(QGeoTiledMappingManagerEngine *engine);
+ virtual ~QGeoTiledMapLabsPrivate();
+
+ QGeoMapObjectPrivate *createMapObjectImplementation(QGeoMapObject *obj) override;
+ virtual QList<QGeoMapObject *> mapObjects() const override;
+ static int findMapObject(QGeoMapObject *o, const QList<MapObject> &list);
+ void removeMapObject(QGeoMapObject *obj);
+
+ void updateMapObjects(QSGNode *root, QQuickWindow *window);
+ void updateObjectsGeometry();
+
+protected:
+ void changeViewportSize(const QSize &size) override;
+ void changeCameraData(const QGeoCameraData &oldCameraData) override;
+ void changeActiveMapType(const QGeoMapType mapType) override;
+
+ QList<MapObject> m_mapObjects;
+ QList<MapObject> m_pendingMapObjects;
+};
+
+QGeoTiledMapLabsPrivate::QGeoTiledMapLabsPrivate(QGeoTiledMappingManagerEngine *engine)
+ : QGeoTiledMapPrivate(engine)
+{
+
+}
+
+QGeoTiledMapLabsPrivate::~QGeoTiledMapLabsPrivate()
+{
+
+}
+
+QGeoMapObjectPrivate *QGeoTiledMapLabsPrivate::createMapObjectImplementation(QGeoMapObject *obj)
+{
+ switch (obj->type()) {
+ case QGeoMapObject::PolylineType: {
+ QMapPolylineObjectPrivate &oldImpl = static_cast<QMapPolylineObjectPrivate &>(*obj->implementation());
+ QMapPolylineObjectPrivateQSG *pimpl =
+ new QMapPolylineObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::PolygonType: {
+ QMapPolygonObjectPrivate &oldImpl = static_cast<QMapPolygonObjectPrivate &>(*obj->implementation());
+ QMapPolygonObjectPrivateQSG *pimpl =
+ new QMapPolygonObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::CircleType: {
+ QMapCircleObjectPrivate &oldImpl = static_cast<QMapCircleObjectPrivate &>(*obj->implementation());
+ QMapCircleObjectPrivateQSG *pimpl =
+ new QMapCircleObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::RouteType: {
+ QMapRouteObjectPrivate &oldImpl = static_cast<QMapRouteObjectPrivate &>(*obj->implementation());
+ QMapRouteObjectPrivateQSG *pimpl =
+ new QMapRouteObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::IconType: {
+ QMapIconObjectPrivate &oldImpl = static_cast<QMapIconObjectPrivate &>(*obj->implementation());
+ QMapIconObjectPrivateQSG *pimpl =
+ new QMapIconObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ default:
+ qWarning() << "Unsupported object type: " << obj->type();
+ break;
+ }
+ return nullptr;
+}
+
+QList<QGeoMapObject *> QGeoTiledMapLabsPrivate::mapObjects() const
+{
+ return QList<QGeoMapObject *>();
+}
+
+int QGeoTiledMapLabsPrivate::findMapObject(QGeoMapObject *o, const QList<MapObject> &list)
+{
+ for (int i = 0; i < list.size(); ++i)
+ {
+ if (list.at(i).object.data() == o)
+ return i;
+ }
+ return -1;
+}
+
+void QGeoTiledMapLabsPrivate::removeMapObject(QGeoMapObject *obj)
+{
+ int idx = findMapObject(obj, m_mapObjects);
+ if (idx >= 0) {
+ m_mapObjects.removeAt(idx);
+ } else {
+ idx = findMapObject(obj, m_pendingMapObjects);
+ if (idx >= 0) {
+ m_pendingMapObjects.removeAt(idx);
+ } else {
+ // obj not here.
+ }
+ }
+}
+
+void QGeoTiledMapLabsPrivate::updateMapObjects(QSGNode *root, QQuickWindow *window)
+{
+ for (int i = 0; i < m_mapObjects.size(); ++i) {
+ // already added as node
+ if (!m_mapObjects.at(i).object) {
+ qWarning() << "m_mapObjects at "<<i<< " NULLed!!";
+ continue;
+ }
+
+ QQSGMapObject *sgo = m_mapObjects.at(i).sgObject;
+ QSGNode *oldNode = sgo->node;
+ sgo->node = sgo->updateMapObjectNode(oldNode, root, window);
+ }
+
+ QList<int> toRemove;
+ for (int i = 0; i < m_pendingMapObjects.size(); ++i) {
+ // already added as node
+ QQSGMapObject *sgo = m_pendingMapObjects.at(i).sgObject;
+ QSGNode *oldNode = sgo->node;
+ sgo->updateGeometry(); // or subtree will be blocked
+ sgo->node = sgo->updateMapObjectNode(oldNode, root, window);
+ if (sgo->node) {
+ m_mapObjects << m_pendingMapObjects.at(i);
+ toRemove.push_front(i);
+ } else {
+ // leave it to be processed
+ }
+ }
+
+ for (int i: qAsConst(toRemove))
+ m_pendingMapObjects.removeAt(i);
+}
+
+void QGeoTiledMapLabsPrivate::updateObjectsGeometry()
+{
+ Q_Q(QGeoTiledMapLabs);
+ for (int i = 0; i < m_mapObjects.size(); ++i) {
+ // already added as node
+ if (!m_mapObjects.at(i).object) {
+ qWarning() << "m_mapObjects at "<<i<< " NULLed!!";
+ continue;
+ }
+
+ QQSGMapObject *sgo = m_mapObjects.at(i).sgObject;
+ sgo->updateGeometry();
+ }
+ emit q->sgNodeChanged();
+}
+
+void QGeoTiledMapLabsPrivate::changeViewportSize(const QSize &size)
+{
+ updateObjectsGeometry();
+ QGeoTiledMapPrivate::changeViewportSize(size);
+}
+
+void QGeoTiledMapLabsPrivate::changeCameraData(const QGeoCameraData &oldCameraData)
+{
+ updateObjectsGeometry();
+ QGeoTiledMapPrivate::changeCameraData(oldCameraData);
+}
+
+void QGeoTiledMapLabsPrivate::changeActiveMapType(const QGeoMapType mapType)
+{
+ updateObjectsGeometry();
+ QGeoTiledMapPrivate::changeActiveMapType(mapType);
+}
+
+
+/*
+ QGeoTiledMapLabs
+*/
+
+
+
+QGeoTiledMapLabs::QGeoTiledMapLabs(QGeoTiledMappingManagerEngine *engine, QObject *parent)
+ : QGeoTiledMap(*new QGeoTiledMapLabsPrivate(engine), engine, parent)
+{
+
+}
+
+QGeoTiledMapLabs::~QGeoTiledMapLabs()
+{
+
+}
+
+bool QGeoTiledMapLabs::createMapObjectImplementation(QGeoMapObject *obj)
+{
+ Q_D(QGeoTiledMapLabs);
+ QExplicitlySharedDataPointer<QGeoMapObjectPrivate> pimpl =
+ QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(d->createMapObjectImplementation(obj));
+ if (pimpl.constData()) {
+ bool res = obj->setImplementation(pimpl);
+ if (res)
+ emit sgNodeChanged();
+ return res;
+ }
+ return false;
+}
+
+QSGNode *QGeoTiledMapLabs::updateSceneGraph(QSGNode *node, QQuickWindow *window)
+{
+ Q_D(QGeoTiledMapLabs);
+ QSGNode *root = QGeoTiledMap::updateSceneGraph(node, window);
+ d->updateMapObjects(root, window);
+ return root;
+}
+
+void QGeoTiledMapLabs::removeMapObject(QGeoMapObject *obj)
+{
+ Q_D(QGeoTiledMapLabs);
+ d->removeMapObject(obj);
+}
+
+QGeoTiledMapLabs::QGeoTiledMapLabs(QGeoTiledMapLabsPrivate &dd, QGeoTiledMappingManagerEngine *engine, QObject *parent)
+ : QGeoTiledMap(dd, engine, parent)
+{
+
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/location/labs/qgeotiledmaplabs_p.h b/src/location/labs/qgeotiledmaplabs_p.h
new file mode 100644
index 00000000..f6499784
--- /dev/null
+++ b/src/location/labs/qgeotiledmaplabs_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPLABS_P_H
+#define QGEOTILEDMAPLABS_P_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 <QtLocation/private/qlocationglobal_p.h>
+#include <QtQml/qqml.h>
+#include <QPointer>
+#include <QtLocation/private/qgeotiledmap_p.h>
+#include <QtQuick/qsgsimplerectnode.h>
+#include <QtLocation/private/qqsgmapobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeGeoServiceProvider;
+class QDeclarativeGeoMap;
+class QMapRouteObject;
+class QNavigationManager;
+class QGeoTiledMapLabsPrivate;
+class Q_LOCATION_PRIVATE_EXPORT QGeoTiledMapLabs : public QGeoTiledMap
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QGeoTiledMapLabs)
+public:
+ QGeoTiledMapLabs(QGeoTiledMappingManagerEngine *engine, QObject *parent);
+ virtual ~QGeoTiledMapLabs();
+
+ bool createMapObjectImplementation(QGeoMapObject *obj) override;
+
+protected:
+ QSGNode *updateSceneGraph(QSGNode *node, QQuickWindow *window) override;
+ void removeMapObject(QGeoMapObject *obj) override;
+
+ QSGClipNode *m_clip = nullptr;
+ QSGSimpleRectNode *m_simpleRectNode = nullptr;
+
+ // From QGeoTiledMap
+ QGeoTiledMapLabs(QGeoTiledMapLabsPrivate &dd, QGeoTiledMappingManagerEngine *engine, QObject *parent);
+private:
+ Q_DISABLE_COPY(QGeoTiledMapLabs)
+};
+
+QT_END_NAMESPACE
+
+#endif // QGEOTILEDMAPLABS_P_H
diff --git a/src/location/labs/qsg/qmapcircleobjectqsg.cpp b/src/location/labs/qsg/qmapcircleobjectqsg.cpp
new file mode 100644
index 00000000..10110eab
--- /dev/null
+++ b/src/location/labs/qsg/qmapcircleobjectqsg.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmapcircleobjectqsg_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+static const int CircleSamples = 128;
+
+QMapCircleObjectPrivateQSG::QMapCircleObjectPrivateQSG(QGeoMapObject *q)
+ : QMapCircleObjectPrivateDefault(q)
+{
+
+}
+
+QMapCircleObjectPrivateQSG::QMapCircleObjectPrivateQSG(const QMapCircleObjectPrivate &other)
+ : QMapCircleObjectPrivateDefault(other)
+{
+ // Data already cloned by the *Default copy constructor, but necessary
+ // update operations triggered by setters overrides
+ setCenter(center());
+ setRadius(radius());
+ setColor(color());
+ setBorderColor(borderColor());
+ setBorderWidth(borderWidth());
+}
+
+QMapCircleObjectPrivateQSG::~QMapCircleObjectPrivateQSG()
+{
+
+}
+
+void QMapCircleObjectPrivateQSG::updateCirclePath()
+{
+ const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection());
+ QList<QGeoCoordinate> path;
+ QDeclarativeCircleMapItem::calculatePeripheralPoints(path, center(), radius(), CircleSamples, m_leftBound);
+ m_circlePath.clear();
+ for (const QGeoCoordinate &c : path)
+ m_circlePath << p.geoToMapProjection(c);
+}
+
+void QMapCircleObjectPrivateQSG::updateGeometry()
+{
+ if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator
+ || !qIsFinite(m_radius) || !m_center.isValid())
+ return;
+
+ const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection());
+ QScopedValueRollback<bool> rollback(m_updatingGeometry);
+ m_updatingGeometry = true;
+
+ updateCirclePath();
+ QList<QDoubleVector2D> circlePath = m_circlePath;
+
+ int pathCount = circlePath.size();
+ bool preserve = QDeclarativeCircleMapItem::preserveCircleGeometry(circlePath, center(), radius(), p);
+ // using leftBound_ instead of the analytically calculated circle_.boundingGeoRectangle().topLeft());
+ // to fix QTBUG-62154
+ m_geometry.markSourceDirty();
+ m_geometry.setPreserveGeometry(true, m_leftBound); // to set the geoLeftBound_
+ m_geometry.setPreserveGeometry(preserve, m_leftBound);
+
+ bool invertedCircle = false;
+ if (QDeclarativeCircleMapItem::crossEarthPole(center(), radius()) && circlePath.size() == pathCount) {
+ m_geometry.updateScreenPointsInvert(circlePath, *m_map); // invert fill area for really huge circles
+ invertedCircle = true;
+ } else {
+ m_geometry.updateSourcePoints(*m_map, circlePath);
+ m_geometry.updateScreenPoints(*m_map);
+ }
+
+ m_borderGeometry.clear();
+
+ //if (borderColor() != Qt::transparent && borderWidth() > 0)
+ {
+ QList<QDoubleVector2D> closedPath = circlePath;
+ closedPath << closedPath.first();
+
+ if (invertedCircle) {
+ closedPath = m_circlePath;
+ closedPath << closedPath.first();
+ std::reverse(closedPath.begin(), closedPath.end());
+ }
+
+ m_borderGeometry.markSourceDirty();
+ m_borderGeometry.setPreserveGeometry(true, m_leftBound);
+ m_borderGeometry.setPreserveGeometry(preserve, m_leftBound);
+
+ // Use srcOrigin_ from fill geometry after clipping to ensure that translateToCommonOrigin won't fail.
+ const QGeoCoordinate &geometryOrigin = m_geometry.origin();
+
+ m_borderGeometry.clearSource();
+
+ QDoubleVector2D borderLeftBoundWrapped;
+ QList<QList<QDoubleVector2D > > clippedPaths =
+ m_borderGeometry.clipPath(*m_map, closedPath, borderLeftBoundWrapped);
+ if (clippedPaths.size()) {
+ borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin);
+ m_borderGeometry.pathToScreen(*m_map, clippedPaths, borderLeftBoundWrapped);
+ m_borderGeometry.updateScreenPoints(*m_map, borderWidth());
+ } else {
+ m_borderGeometry.clear();
+ }
+ }
+
+ QPointF origin = m_map->geoProjection().coordinateToItemPosition(m_geometry.origin(), false).toPointF();
+ m_geometry.translate(origin - m_geometry.firstPointOffset());
+ m_borderGeometry.translate(origin - m_borderGeometry.firstPointOffset());
+}
+
+QGeoMapObjectPrivate *QMapCircleObjectPrivateQSG::clone()
+{
+ return new QMapCircleObjectPrivateQSG(static_cast<QMapCircleObjectPrivate &>(*this));
+}
+
+QSGNode *QMapCircleObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * /*window*/)
+{
+ MapPolygonNode *node = static_cast<MapPolygonNode *>(oldNode);
+
+ bool created = false;
+ if (!node) {
+ node = new MapPolygonNode();
+ created = true;
+ }
+
+ //TODO: update only material
+ if (m_geometry.isScreenDirty() || !m_borderGeometry.isScreenDirty() || !oldNode || created) {
+ //QMapPolygonObject *p = static_cast<QMapPolygonObject *>(q);
+ node->update(color(), borderColor(), &m_geometry, &m_borderGeometry);
+ m_geometry.setPreserveGeometry(false);
+ m_borderGeometry.setPreserveGeometry(false);
+ m_geometry.markClean();
+ m_borderGeometry.markClean();
+ }
+
+ if (created)
+ root->appendChildNode(node);
+
+ return node;
+}
+
+
+void QMapCircleObjectPrivateQSG::setCenter(const QGeoCoordinate &center)
+{
+ m_center = center;
+ updateGeometry();
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapCircleObjectPrivateQSG::setRadius(qreal radius)
+{
+ m_radius = radius;
+ updateGeometry();
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapCircleObjectPrivateQSG::setColor(const QColor &color)
+{
+ m_fillColor = color;
+ updateGeometry();
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapCircleObjectPrivateQSG::setBorderColor(const QColor &color)
+{
+ m_borderColor = color;
+ updateGeometry();
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapCircleObjectPrivateQSG::setBorderWidth(qreal width)
+{
+ m_borderWidth = width;
+ updateGeometry();
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h b/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h
new file mode 100644
index 00000000..17d8568a
--- /dev/null
+++ b/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPCIRCLEOBJECTQSG_P_H
+#define QMAPCIRCLEOBJECTQSG_P_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 <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qgeomapobject_p_p.h>
+#include <QtLocation/private/qdeclarativecirclemapitem_p.h>
+#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
+#include <QtLocation/private/qmapcircleobject_p.h>
+#include <QtLocation/private/qmapcircleobject_p_p.h>
+#include <QtLocation/private/qqsgmapobject_p.h>
+#include <QtCore/qscopedvaluerollback.h>
+#include <QGeoCoordinate>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATION_PRIVATE_EXPORT QMapCircleObjectPrivateQSG : public QMapCircleObjectPrivateDefault, public QQSGMapObject
+{
+public:
+ QMapCircleObjectPrivateQSG(QGeoMapObject *q);
+ QMapCircleObjectPrivateQSG(const QMapCircleObjectPrivate &other);
+ ~QMapCircleObjectPrivateQSG() override;
+
+ void updateCirclePath();
+
+ // QQSGMapObject
+ void updateGeometry() override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+
+ // QGeoMapCirclePrivate interface
+ void setCenter(const QGeoCoordinate &center) override;
+ void setRadius(qreal radius) override;
+ void setColor(const QColor &color) override;
+ void setBorderColor(const QColor &color) override;
+ void setBorderWidth(qreal width) override;
+
+ // QGeoMapObjectPrivate
+ QGeoMapObjectPrivate *clone() override;
+
+public:
+ // Data Members
+ QList<QDoubleVector2D> m_circlePath;
+ QGeoCoordinate m_leftBound;
+ QGeoMapCircleGeometry m_geometry;
+ QGeoMapPolylineGeometry m_borderGeometry;
+ bool m_updatingGeometry = false;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMAPCIRCLEOBJECT_P_P_H
diff --git a/src/location/labs/qsg/qmapiconobjectqsg.cpp b/src/location/labs/qsg/qmapiconobjectqsg.cpp
new file mode 100644
index 00000000..53d16179
--- /dev/null
+++ b/src/location/labs/qsg/qmapiconobjectqsg.cpp
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmapiconobjectqsg_p_p.h"
+#include <QtQuick/qsgimagenode.h>
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/private/qquickimage_p.h>
+#include <QtQuick/qquickimageprovider.h>
+#include <QtQuick/qquickwindow.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqml.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+
+QT_BEGIN_NAMESPACE
+
+class RootNode : public QSGTransformNode
+{
+public:
+ RootNode() : QSGTransformNode()
+ { }
+
+ bool isSubtreeBlocked() const override
+ {
+ return m_blocked;
+ }
+
+ void setSubtreeBlocked(bool blocked)
+ {
+ m_blocked = blocked;
+ }
+
+ bool m_blocked = false;
+};
+
+QMapIconObjectPrivateQSG::QMapIconObjectPrivateQSG(QGeoMapObject *q)
+ : QMapIconObjectPrivateDefault(q)
+{
+
+}
+
+QMapIconObjectPrivateQSG::QMapIconObjectPrivateQSG(const QMapIconObjectPrivate &other)
+ : QMapIconObjectPrivateDefault(other)
+{
+ setContent(content());
+ setCoordinate(coordinate());
+}
+
+QMapIconObjectPrivateQSG::~QMapIconObjectPrivateQSG()
+{
+
+}
+
+void QMapIconObjectPrivateQSG::updateGeometry()
+{
+ if (!m_map)
+ return;
+
+ m_geometryDirty = true;
+ const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection());
+
+ m_itemPosition = p.coordinateToItemPosition(coordinate());
+ if (m_itemPosition.isFinite()) {
+ m_transformation.setToIdentity();
+ m_transformation.translate(QVector3D(m_itemPosition.x(), m_itemPosition.y(), 0));
+ }
+
+ // TODO: support and test for zoomLevel
+}
+
+QSGNode *QMapIconObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode * root, QQuickWindow *window)
+{
+ bool created = false;
+ RootNode *node = static_cast<RootNode *>(oldNode);
+ if (!node) {
+ node = new RootNode();
+ m_imageNode = window->createImageNode();
+ m_imageNode->setOwnsTexture(true);
+ node->appendChildNode(m_imageNode);
+ created = true;
+ }
+
+ if (m_imageDirty) {
+ m_imageDirty = false;
+ m_imageNode->setTexture(window->createTextureFromImage(m_image));
+ QRect rect = m_image.rect();
+ m_imageNode->setSourceRect(rect);
+ m_imageNode->setRect(QRectF(QPointF(0,0), m_size));
+ }
+
+ if (m_geometryDirty) {
+ m_geometryDirty = false;
+ if (!m_itemPosition.isFinite()) {
+ node->setSubtreeBlocked(true);
+ } else {
+ node->setSubtreeBlocked(false);
+ node->setMatrix(m_transformation);
+ }
+ }
+
+ if (created)
+ root->appendChildNode(node);
+
+ return node;
+}
+
+void QMapIconObjectPrivateQSG::setCoordinate(const QGeoCoordinate &coordinate)
+{
+ QMapIconObjectPrivateDefault::setCoordinate(coordinate);
+ updateGeometry();
+}
+
+template<typename T>
+static T *getContent(const QVariant &content)
+{
+ QObject *obj = qvariant_cast<QObject *>(content);
+ return qobject_cast<T *>(obj);
+}
+
+static inline QString imageId(const QUrl &url)
+{
+ return url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1);
+}
+
+void QMapIconObjectPrivateQSG::clearContent()
+{
+ m_image = QImage();
+}
+
+void QMapIconObjectPrivateQSG::setContent(const QVariant &content)
+{
+ // First reset all local containers
+ clearContent();
+ QQmlEngine *engine = qmlEngine(q);
+
+ // Then pull the new content
+ QMapIconObjectPrivateDefault::setContent(content);
+ switch (content.type()) {
+ case QVariant::UserType: {
+ // TODO: Handle QObject subclasses -- first decide which ones
+ break;
+ }
+ case QVariant::String:
+ case QVariant::Url: {
+ // URL, including image/texture providers
+ // Supporting only image providers for now
+ const QUrl url = content.toUrl();
+ if (!url.isValid()) {
+ m_image = QImage(content.toString());
+ m_imageDirty = true;
+ updateGeometry();
+ } else if (url.scheme().isEmpty() || url.scheme() == QLatin1String("file")) {
+ m_image = QImage(url.toString(QUrl::RemoveScheme));
+ m_imageDirty = true;
+ updateGeometry();
+ } else if (url.scheme() == QLatin1String("image")) {
+ QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(url.host()));
+ QSize outSize;
+ m_image = provider->requestImage(imageId(url), &outSize, QSize());
+ if (outSize.isEmpty())
+ break;
+ m_imageDirty = true;
+ updateGeometry();
+ } else { // ToDo: Use QNAM
+
+ }
+
+ break;
+ }
+ case QVariant::ByteArray: {
+ // ToDo: Build the image from bytearray
+ break;
+ }
+ default:
+ qWarning() << "Unsupported parameter type: " << content.type();
+ break;
+ }
+
+ if (m_map && m_imageDirty)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapIconObjectPrivateQSG::setSize(const QSizeF &size)
+{
+ QMapIconObjectPrivateDefault::setSize(size);
+ updateGeometry();
+}
+
+QGeoMapObjectPrivate *QMapIconObjectPrivateQSG::clone()
+{
+ return new QMapIconObjectPrivateQSG(static_cast<QMapIconObjectPrivate &>(*this));
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/labs/qsg/qmapiconobjectqsg_p_p.h b/src/location/labs/qsg/qmapiconobjectqsg_p_p.h
new file mode 100644
index 00000000..a2f7cf40
--- /dev/null
+++ b/src/location/labs/qsg/qmapiconobjectqsg_p_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPICONOBJECTQSG_P_P_H
+#define QMAPICONOBJECTQSG_P_P_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 <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qmapiconobject_p.h>
+#include <QtLocation/private/qmapiconobject_p_p.h>
+#include <QtLocation/private/qqsgmapobject_p.h>
+#include <QtCore/qscopedvaluerollback.h>
+#include <QtGui/qimage.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGImageNode;
+class Q_LOCATION_PRIVATE_EXPORT QMapIconObjectPrivateQSG : public QMapIconObjectPrivateDefault, public QQSGMapObject
+{
+public:
+ QMapIconObjectPrivateQSG(QGeoMapObject *q);
+ QMapIconObjectPrivateQSG(const QMapIconObjectPrivate &other);
+ ~QMapIconObjectPrivateQSG() override;
+
+ void clearContent();
+
+ // QQSGMapObject
+ void updateGeometry() override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+
+ // QGeoMapIconPrivate interface
+ void setCoordinate(const QGeoCoordinate &coordinate) override;
+ void setContent(const QVariant &content) override;
+ void setSize(const QSizeF &size) override;
+
+ // QGeoMapObjectPrivate
+ QGeoMapObjectPrivate *clone() override;
+
+public:
+ // Data Members
+ bool m_imageDirty = false;
+ bool m_geometryDirty = false;
+ QImage m_image;
+ QSGImageNode *m_imageNode = nullptr;
+ QDoubleVector2D m_itemPosition;
+ QMatrix4x4 m_transformation;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMAPICONOBJECTQSG_P_P_H
diff --git a/src/location/labs/qsg/qmappolygonobjectqsg.cpp b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
new file mode 100644
index 00000000..4000c08f
--- /dev/null
+++ b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmappolygonobjectqsg_p_p.h"
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgsimplerectnode.h>
+
+QT_BEGIN_NAMESPACE
+
+QMapPolygonObjectPrivateQSG::QMapPolygonObjectPrivateQSG(QGeoMapObject *q)
+ : QMapPolygonObjectPrivate(q)
+{
+
+}
+
+QMapPolygonObjectPrivateQSG::QMapPolygonObjectPrivateQSG(const QMapPolygonObjectPrivate &other)
+ : QMapPolygonObjectPrivate(other.q)
+{
+ setPath(other.path());
+ setFillColor(other.fillColor());
+ setBorderColor(other.borderColor());
+ setBorderWidth(other.borderWidth());
+}
+
+QMapPolygonObjectPrivateQSG::~QMapPolygonObjectPrivateQSG()
+{
+
+}
+
+QList<QDoubleVector2D> QMapPolygonObjectPrivateQSG::projectPath()
+{
+ QList<QDoubleVector2D> geopathProjected_;
+ if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator)
+ return geopathProjected_;
+
+ const QGeoProjectionWebMercator &p =
+ static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection());
+ geopathProjected_.reserve(m_geoPath.path().size());
+ for (const QGeoCoordinate &c : m_geoPath.path())
+ geopathProjected_ << p.geoToMapProjection(c);
+ return geopathProjected_;
+}
+
+QSGNode *QMapPolygonObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * /*window*/)
+{
+ MapPolygonNode *node = static_cast<MapPolygonNode *>(oldNode);
+
+ bool created = false;
+ if (!node) {
+ node = new MapPolygonNode();
+ created = true;
+ }
+
+ //TODO: update only material
+ if (m_geometry.isScreenDirty() || !m_borderGeometry.isScreenDirty() || !oldNode || created) {
+ node->update(fillColor(), borderColor(), &m_geometry, &m_borderGeometry);
+ m_geometry.setPreserveGeometry(false);
+ m_borderGeometry.setPreserveGeometry(false);
+ m_geometry.markClean();
+ m_borderGeometry.markClean();
+ }
+
+ if (created)
+ root->appendChildNode(node);
+
+ return node;
+}
+
+QList<QGeoCoordinate> QMapPolygonObjectPrivateQSG::path() const
+{
+ return m_geoPath.path();
+}
+
+QColor QMapPolygonObjectPrivateQSG::fillColor() const
+{
+ return m_fillColor;
+}
+
+QColor QMapPolygonObjectPrivateQSG::borderColor() const
+{
+ return m_borderColor;
+}
+
+qreal QMapPolygonObjectPrivateQSG::borderWidth() const
+{
+ return m_borderWidth;
+}
+
+void QMapPolygonObjectPrivateQSG::setPath(const QList<QGeoCoordinate> &path)
+{
+ m_geoPath.setPath(path);
+ updateGeometry();
+
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapPolygonObjectPrivateQSG::setFillColor(const QColor &color)
+{
+ m_fillColor = color;
+ updateGeometry();
+
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapPolygonObjectPrivateQSG::setBorderColor(const QColor &color)
+{
+ m_borderColor = color;
+ updateGeometry();
+
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapPolygonObjectPrivateQSG::setBorderWidth(qreal width)
+{
+ m_borderWidth = width;
+ updateGeometry();
+
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+QGeoMapObjectPrivate *QMapPolygonObjectPrivateQSG::clone()
+{
+ return new QMapPolygonObjectPrivateQSG(static_cast<QMapPolygonObjectPrivate &>(*this));
+}
+
+void QMapPolygonObjectPrivateQSG::updateGeometry()
+{
+ if (!m_map || m_geoPath.path().length() == 0
+ || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator)
+ return;
+
+ QScopedValueRollback<bool> rollback(m_updatingGeometry);
+ m_updatingGeometry = true;
+
+ const QList<QDoubleVector2D> &geopathProjected = projectPath();
+
+ m_geometry.markSourceDirty();
+ m_geometry.setPreserveGeometry(true, m_geoPath.boundingGeoRectangle().topLeft());
+ m_geometry.updateSourcePoints(*m_map, geopathProjected);
+ m_geometry.updateScreenPoints(*m_map);
+
+ m_borderGeometry.clear();
+
+ //if (border_.color() != Qt::transparent && border_.width() > 0)
+ {
+ const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection());
+ QList<QDoubleVector2D> closedPath = geopathProjected;
+ closedPath << closedPath.first();
+
+ m_borderGeometry.markSourceDirty();
+ m_borderGeometry.setPreserveGeometry(true, m_geoPath.boundingGeoRectangle().topLeft());
+
+ const QGeoCoordinate &geometryOrigin = m_geometry.origin();
+
+ m_borderGeometry.clearSource();
+
+ QDoubleVector2D borderLeftBoundWrapped;
+ QList<QList<QDoubleVector2D > > clippedPaths =
+ m_borderGeometry.clipPath(*m_map.data(), closedPath, borderLeftBoundWrapped);
+
+ if (clippedPaths.size()) {
+ borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin);
+ m_borderGeometry.pathToScreen(*m_map.data(), clippedPaths, borderLeftBoundWrapped);
+ m_borderGeometry.updateScreenPoints(*m_map.data(), borderWidth());
+ } else {
+ m_borderGeometry.clear();
+ }
+ }
+
+ QPointF origin = m_map->geoProjection().coordinateToItemPosition(m_geometry.origin(), false).toPointF();
+ m_geometry.translate(origin - m_geometry.firstPointOffset());
+ m_borderGeometry.translate(origin - m_borderGeometry.firstPointOffset());
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h b/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h
new file mode 100644
index 00000000..bd5efcff
--- /dev/null
+++ b/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPPOLYGONOBJECTQSG_P_P_H
+#define QMAPPOLYGONOBJECTQSG_P_P_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 <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qmappolygonobject_p.h>
+#include <QtLocation/private/qmappolygonobject_p_p.h>
+#include <QtLocation/private/qqsgmapobject_p.h>
+#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
+#include <QtCore/qscopedvaluerollback.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATION_PRIVATE_EXPORT QMapPolygonObjectPrivateQSG : public QMapPolygonObjectPrivate, public QQSGMapObject
+{
+public:
+ QMapPolygonObjectPrivateQSG(QGeoMapObject *q);
+ QMapPolygonObjectPrivateQSG(const QMapPolygonObjectPrivate &other);
+ ~QMapPolygonObjectPrivateQSG() override;
+
+ QList<QDoubleVector2D> projectPath();
+
+ // QQSGMapObject
+ void updateGeometry() override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+
+ // QGeoMapPolylinePrivate interface
+ QList<QGeoCoordinate> path() const override;
+ QColor fillColor() const override;
+ QColor borderColor() const override;
+ qreal borderWidth() const override;
+
+ void setPath(const QList<QGeoCoordinate> &path) override;
+ void setFillColor(const QColor &color) override;
+ void setBorderColor(const QColor &color) override;
+ void setBorderWidth(qreal width) override;
+
+ // QGeoMapObjectPrivate
+ QGeoMapObjectPrivate *clone() override;
+
+ // Data Members
+ QGeoMapPolygonGeometry m_geometry;
+ QGeoMapPolylineGeometry m_borderGeometry;
+ QGeoPath m_geoPath;
+
+ QColor m_fillColor;
+ QColor m_borderColor;
+ qreal m_borderWidth = 0;
+ bool m_updatingGeometry = false;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMAPPOLYGONOBJECTQSG_P_P_H
diff --git a/src/location/labs/qsg/qmappolylineobjectqsg.cpp b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
new file mode 100644
index 00000000..fe6fbec6
--- /dev/null
+++ b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmappolylineobjectqsg_p_p.h"
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgsimplerectnode.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ Note: never use q, since this class is also used inside QMapRouteObjectPrivateQSG!
+*/
+
+QMapPolylineObjectPrivateQSG::QMapPolylineObjectPrivateQSG(QGeoMapObject *q)
+ : QMapPolylineObjectPrivate(q)
+{
+
+}
+
+QMapPolylineObjectPrivateQSG::QMapPolylineObjectPrivateQSG(const QMapPolylineObjectPrivate &other)
+ : QMapPolylineObjectPrivate(other.q)
+{
+ // do the appropriate internal update and trigger map repaint
+ setPath(other.path());
+ setColor(other.color());
+ setWidth(other.width());
+}
+
+QMapPolylineObjectPrivateQSG::~QMapPolylineObjectPrivateQSG()
+{
+
+}
+
+QList<QDoubleVector2D> QMapPolylineObjectPrivateQSG::projectPath()
+{
+ QList<QDoubleVector2D> geopathProjected_;
+ if (!m_map || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator)
+ return geopathProjected_;
+
+ const QGeoProjectionWebMercator &p =
+ static_cast<const QGeoProjectionWebMercator&>(m_map->geoProjection());
+ geopathProjected_.reserve(m_geoPath.path().size());
+ for (const QGeoCoordinate &c : m_geoPath.path())
+ geopathProjected_ << p.geoToMapProjection(c);
+ return geopathProjected_;
+}
+
+void QMapPolylineObjectPrivateQSG::updateGeometry()
+{
+ if (!m_map || m_geoPath.path().length() == 0
+ || m_map->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator)
+ return;
+
+ QScopedValueRollback<bool> rollback(m_updatingGeometry);
+ m_updatingGeometry = true;
+ m_geometry.markSourceDirty();
+ const QList<QDoubleVector2D> &geopathProjected = projectPath();
+ m_geometry.setPreserveGeometry(true, m_geoPath.boundingGeoRectangle().topLeft());
+ m_geometry.updateSourcePoints(*m_map.data(), geopathProjected, m_geoPath.boundingGeoRectangle().topLeft());
+ m_geometry.updateScreenPoints(*m_map.data(), width());
+
+ QPointF origin = m_map->geoProjection().coordinateToItemPosition(m_geometry.origin(), false).toPointF();
+ m_geometry.translate(origin - m_geometry.firstPointOffset());
+}
+
+QSGNode *QMapPolylineObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * /*window*/)
+{
+ MapPolylineNode *node = static_cast<MapPolylineNode *>(oldNode);
+
+ bool created = false;
+ if (!node) {
+ node = new MapPolylineNode();
+ created = true;
+ }
+
+ //TODO: update only material
+ if (m_geometry.isScreenDirty() || !oldNode || created) {
+ node->update(color(), &m_geometry);
+ m_geometry.setPreserveGeometry(false);
+ m_geometry.markClean();
+ }
+
+ if (created)
+ root->appendChildNode(node);
+
+ return node;
+}
+
+QList<QGeoCoordinate> QMapPolylineObjectPrivateQSG::path() const { return m_geoPath.path(); }
+
+QColor QMapPolylineObjectPrivateQSG::color() const { return m_color; }
+
+qreal QMapPolylineObjectPrivateQSG::width() const { return m_width; }
+
+void QMapPolylineObjectPrivateQSG::setPath(const QList<QGeoCoordinate> &path)
+{
+ m_geoPath.setPath(path);
+ updateGeometry();
+
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapPolylineObjectPrivateQSG::setColor(const QColor &color)
+{
+ m_color = color;
+ updateGeometry();
+
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+void QMapPolylineObjectPrivateQSG::setWidth(qreal width)
+{
+ m_width = width;
+ updateGeometry();
+
+ if (m_map)
+ emit m_map->sgNodeChanged();
+}
+
+QGeoMapObjectPrivate *QMapPolylineObjectPrivateQSG::clone()
+{
+ return new QMapPolylineObjectPrivateQSG(static_cast<QMapPolylineObjectPrivate &>(*this));
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h b/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h
new file mode 100644
index 00000000..52b5e89a
--- /dev/null
+++ b/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPPOLYLINEOBJECTOBJECTSOVERLAY_H
+#define QMAPPOLYLINEOBJECTOBJECTSOVERLAY_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 <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qmappolylineobject_p_p.h>
+#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
+#include <QtLocation/private/qmappolylineobject_p.h>
+#include <QtLocation/private/qqsgmapobject_p.h>
+#include <QtCore/qscopedvaluerollback.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATION_PRIVATE_EXPORT QMapPolylineObjectPrivateQSG : public QMapPolylineObjectPrivate, public QQSGMapObject
+{
+public:
+ QMapPolylineObjectPrivateQSG(QGeoMapObject *q);
+ QMapPolylineObjectPrivateQSG(const QMapPolylineObjectPrivate &other);
+ ~QMapPolylineObjectPrivateQSG() override;
+
+ QList<QDoubleVector2D> projectPath();
+
+ // QQSGMapObject
+ void updateGeometry() override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+
+ // QGeoMapPolylinePrivate interface
+ QList<QGeoCoordinate> path() const override;
+ QColor color() const override;
+ qreal width() const override;
+
+ void setPath(const QList<QGeoCoordinate> &path) override;
+ void setColor(const QColor &color) override;
+ void setWidth(qreal width) override;
+
+ // QGeoMapObjectPrivate
+ QGeoMapObjectPrivate *clone() override;
+
+ // Data Members
+ QGeoMapPolylineGeometry m_geometry;
+ QGeoPath m_geoPath;
+
+ QColor m_color;
+ qreal m_width = 0;
+ bool m_updatingGeometry = false;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMAPPOLYLINEOBJECTOBJECTSOVERLAY_H
diff --git a/src/location/labs/qsg/qmaprouteobjectqsg.cpp b/src/location/labs/qsg/qmaprouteobjectqsg.cpp
new file mode 100644
index 00000000..a8728e08
--- /dev/null
+++ b/src/location/labs/qsg/qmaprouteobjectqsg.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmaprouteobjectqsg_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QMapRouteObjectPrivateQSG::QMapRouteObjectPrivateQSG(QGeoMapObject *q)
+ : QMapRouteObjectPrivate(q)
+{
+ QScopedPointer<QMapPolylineObjectPrivateQSG> poly(new QMapPolylineObjectPrivateQSG(q));
+ m_polyline.swap(poly);
+ m_polyline->m_componentCompleted = true;
+}
+
+QMapRouteObjectPrivateQSG::QMapRouteObjectPrivateQSG(const QMapRouteObjectPrivate &other)
+ : QMapRouteObjectPrivate(other)
+{
+ QScopedPointer<QMapPolylineObjectPrivateQSG> poly(new QMapPolylineObjectPrivateQSG(other.q));
+ m_polyline.swap(poly);
+ m_polyline->m_componentCompleted = true;
+ setRoute(other.declarativeGeoRoute());
+}
+
+QMapRouteObjectPrivateQSG::~QMapRouteObjectPrivateQSG()
+{
+
+}
+
+void QMapRouteObjectPrivateQSG::updateGeometry()
+{
+ m_polyline->updateGeometry();
+}
+
+QSGNode *QMapRouteObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * window)
+{
+ return m_polyline->updateMapObjectNode(oldNode, root, window);
+}
+
+void QMapRouteObjectPrivateQSG::setRoute(const QDeclarativeGeoRoute *route)
+{
+ const QList<QGeoCoordinate> &path = route->route().path();
+ m_polyline->setColor(QColor("deepskyblue")); // ToDo: support MapParameters for this
+ m_polyline->setWidth(4);
+ m_polyline->setPath(path); // SGNodeChanged emitted by m_polyline
+}
+
+QGeoMapObjectPrivate *QMapRouteObjectPrivateQSG::clone()
+{
+ return new QMapRouteObjectPrivateQSG(static_cast<QMapRouteObjectPrivate &>(*this));
+}
+
+void QMapRouteObjectPrivateQSG::setMap(QGeoMap *map)
+{
+ QGeoMapObjectPrivate::setMap(map);
+ m_polyline->setMap(map);
+}
+
+
+void QMapRouteObjectPrivateQSG::setVisible(bool visible)
+{
+ m_visible = visible;
+ m_polyline->setVisible(visible);
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h b/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h
new file mode 100644
index 00000000..1c612532
--- /dev/null
+++ b/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAPROUTEOBJECTQSG_P_P_H
+#define QMAPROUTEOBJECTQSG_P_P_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 <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qmappolylineobjectqsg_p_p.h>
+#include <QtLocation/private/qmaprouteobject_p_p.h>
+#include <QtLocation/private/qdeclarativegeoroute_p.h>
+#include <QtLocation/private/qmaprouteobject_p.h>
+#include <QtLocation/private/qqsgmapobject_p.h>
+#include <QtCore/qscopedvaluerollback.h>
+#include <QtCore/qscopedpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_LOCATION_PRIVATE_EXPORT QMapRouteObjectPrivateQSG : public QMapRouteObjectPrivate, public QQSGMapObject
+{
+public:
+ QMapRouteObjectPrivateQSG(QGeoMapObject *q);
+ QMapRouteObjectPrivateQSG(const QMapRouteObjectPrivate &other);
+ ~QMapRouteObjectPrivateQSG() override;
+
+ // QQSGMapObject
+ void updateGeometry() override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+
+ // QMapRouteObjectPrivate interface
+ void setRoute(const QDeclarativeGeoRoute *route) override;
+
+ // QGeoMapObjectPrivate interface
+ QGeoMapObjectPrivate *clone() override;
+ void setMap(QGeoMap *map) override;
+ void setVisible(bool visible) override;
+
+ // Data Members
+ QScopedPointer<QMapPolylineObjectPrivateQSG> m_polyline;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMAPROUTEOBJECTQSG_P_P_H
diff --git a/src/location/labs/qsg/qqsgmapobject.cpp b/src/location/labs/qsg/qqsgmapobject.cpp
new file mode 100644
index 00000000..5b4f7dbf
--- /dev/null
+++ b/src/location/labs/qsg/qqsgmapobject.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqsgmapobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQSGMapObject::QQSGMapObject()
+{
+
+}
+
+QQSGMapObject::~QQSGMapObject()
+{
+
+}
+
+QSGNode *QQSGMapObject::updateMapObjectNode(QSGNode *oldNode, QSGNode * /*root*/, QQuickWindow * /*window*/)
+{
+ delete oldNode;
+ return 0;
+}
+
+void QQSGMapObject::updateGeometry()
+{
+
+}
+
+QT_END_NAMESPACE
+
+
diff --git a/src/location/labs/qsg/qqsgmapobject_p.h b/src/location/labs/qsg/qqsgmapobject_p.h
new file mode 100644
index 00000000..d3e54a68
--- /dev/null
+++ b/src/location/labs/qsg/qqsgmapobject_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQSGMAPOBJECT_H
+#define QQSGMAPOBJECT_H
+
+#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtQuick/QSGOpacityNode>
+#include <QtLocation/private/qgeomapobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickWindow;
+class Q_LOCATION_PRIVATE_EXPORT QQSGMapObject
+{
+public:
+ QQSGMapObject();
+ virtual ~QQSGMapObject();
+
+ virtual QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window);
+ virtual void updateGeometry();
+
+ QSGNode *node = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQSGMAPOBJECT_H
diff --git a/src/plugins/geoservices/esri/esri.pro b/src/plugins/geoservices/esri/esri.pro
index 3642ddaf..3a4da208 100644
--- a/src/plugins/geoservices/esri/esri.pro
+++ b/src/plugins/geoservices/esri/esri.pro
@@ -2,6 +2,9 @@ TARGET = qtgeoservices_esri
QT += location-private positioning-private network
+QT_FOR_CONFIG += location-private
+qtConfig(location-labs-plugin): DEFINES += LOCATIONLABS
+
HEADERS += \
geocodereply_esri.h \
geocodingmanagerengine_esri.h \
diff --git a/src/plugins/geoservices/esri/geotiledmap_esri.cpp b/src/plugins/geoservices/esri/geotiledmap_esri.cpp
index 9171fc2b..8feb9615 100644
--- a/src/plugins/geoservices/esri/geotiledmap_esri.cpp
+++ b/src/plugins/geoservices/esri/geotiledmap_esri.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
GeoTiledMapEsri::GeoTiledMapEsri(GeoTiledMappingManagerEngineEsri *engine, QObject *parent) :
- QGeoTiledMap(engine, parent), m_engine(engine), m_mapId(-1)
+ Map(engine, parent), m_engine(engine), m_mapId(-1)
{
}
diff --git a/src/plugins/geoservices/esri/geotiledmap_esri.h b/src/plugins/geoservices/esri/geotiledmap_esri.h
index e8b26152..7a21af9a 100644
--- a/src/plugins/geoservices/esri/geotiledmap_esri.h
+++ b/src/plugins/geoservices/esri/geotiledmap_esri.h
@@ -41,12 +41,18 @@
#define GEOTILEDMAPESRI_H
#include <QtLocation/private/qgeotiledmap_p.h>
+#ifdef LOCATIONLABS
+#include <QtLocation/private/qgeotiledmaplabs_p.h>
+typedef QGeoTiledMapLabs Map;
+#else
+typedef QGeoTiledMap Map;
+#endif
QT_BEGIN_NAMESPACE
class GeoTiledMappingManagerEngineEsri;
-class GeoTiledMapEsri: public QGeoTiledMap
+class GeoTiledMapEsri: public Map
{
Q_OBJECT
diff --git a/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro b/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro
index 1f45de97..486ed97a 100644
--- a/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro
+++ b/src/plugins/geoservices/itemsoverlay/itemsoverlay.pro
@@ -2,6 +2,9 @@ TARGET = qtgeoservices_itemsoverlay
QT += location-private positioning-private
+QT_FOR_CONFIG += location-private
+qtConfig(location-labs-plugin): DEFINES += LOCATIONLABS
+
HEADERS += \
qgeomapitemsoverlay.h \
qgeomappingmanagerengineitemsoverlay.h \
diff --git a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp
index 29b84408..99146801 100644
--- a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp
+++ b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp
@@ -38,6 +38,22 @@
#include "qgeomappingmanagerengineitemsoverlay.h"
#include <QtLocation/private/qgeomap_p_p.h>
#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qquickwindow.h>
+
+#ifdef LOCATIONLABS
+#include <QtLocation/private/qmappolylineobjectqsg_p_p.h>
+#include <QtLocation/private/qmappolygonobjectqsg_p_p.h>
+#include <QtLocation/private/qmapcircleobjectqsg_p_p.h>
+#include <QtLocation/private/qmaprouteobjectqsg_p_p.h>
+#include <QtLocation/private/qmapiconobjectqsg_p_p.h>
+struct MapObject {
+ MapObject(QPointer<QGeoMapObject> &o, QQSGMapObject *sgo)
+ : object(o), sgObject(sgo) {}
+ QPointer<QGeoMapObject> object;
+ QQSGMapObject *sgObject = nullptr;
+};
+#endif
QT_BEGIN_NAMESPACE
@@ -46,9 +62,20 @@ class QGeoMapItemsOverlayPrivate : public QGeoMapPrivate
Q_DECLARE_PUBLIC(QGeoMapItemsOverlay)
public:
QGeoMapItemsOverlayPrivate(QGeoMappingManagerEngineItemsOverlay *engine);
-
virtual ~QGeoMapItemsOverlayPrivate();
+#ifdef LOCATIONLABS
+ QGeoMapObjectPrivate *createMapObjectImplementation(QGeoMapObject *obj) override;
+ virtual QList<QGeoMapObject *> mapObjects() const override;
+ static int findMapObject(QGeoMapObject *o, const QList<MapObject> &list);
+ void removeMapObject(QGeoMapObject *obj);
+ void updateMapObjects(QSGNode *root, QQuickWindow *window);
+
+ QList<MapObject> m_mapObjects;
+ QList<MapObject> m_pendingMapObjects;
+#endif
+
+ void updateObjectsGeometry();
protected:
void changeViewportSize(const QSize &size) override;
void changeCameraData(const QGeoCameraData &oldCameraData) override;
@@ -65,10 +92,31 @@ QGeoMapItemsOverlay::~QGeoMapItemsOverlay()
{
}
+QGeoMap::Capabilities QGeoMapItemsOverlay::capabilities() const
+{
+ return Capabilities(SupportsVisibleRegion
+ | SupportsSetBearing
+ | SupportsAnchoringCoordinate);
+}
+
QSGNode *QGeoMapItemsOverlay::updateSceneGraph(QSGNode *node, QQuickWindow *window)
{
+#ifndef LOCATIONLABS
Q_UNUSED(window)
return node;
+#else
+ Q_D(QGeoMapItemsOverlay);
+
+ QSGRectangleNode *mapRoot = static_cast<QSGRectangleNode *>(node);
+ if (!mapRoot)
+ mapRoot = window->createRectangleNode();
+
+ mapRoot->setRect(QRect(0, 0, viewportWidth(), viewportHeight()));
+ mapRoot->setColor(QColor(0,0,0,0));
+
+ d->updateMapObjects(mapRoot, window);
+ return mapRoot;
+#endif
}
QGeoMapItemsOverlayPrivate::QGeoMapItemsOverlayPrivate(QGeoMappingManagerEngineItemsOverlay *engine)
@@ -80,19 +128,157 @@ QGeoMapItemsOverlayPrivate::~QGeoMapItemsOverlayPrivate()
{
}
-void QGeoMapItemsOverlayPrivate::changeViewportSize(const QSize &size)
+#ifdef LOCATIONLABS
+QGeoMapObjectPrivate *QGeoMapItemsOverlayPrivate::createMapObjectImplementation(QGeoMapObject *obj)
+{
+ switch (obj->type()) {
+ case QGeoMapObject::PolylineType: {
+ QMapPolylineObjectPrivate &oldImpl = static_cast<QMapPolylineObjectPrivate &>(*obj->implementation());
+ QMapPolylineObjectPrivateQSG *pimpl =
+ new QMapPolylineObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::PolygonType: {
+ QMapPolygonObjectPrivate &oldImpl = static_cast<QMapPolygonObjectPrivate &>(*obj->implementation());
+ QMapPolygonObjectPrivateQSG *pimpl =
+ new QMapPolygonObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::CircleType: {
+ QMapCircleObjectPrivate &oldImpl = static_cast<QMapCircleObjectPrivate &>(*obj->implementation());
+ QMapCircleObjectPrivateQSG *pimpl =
+ new QMapCircleObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::RouteType: {
+ QMapRouteObjectPrivate &oldImpl = static_cast<QMapRouteObjectPrivate &>(*obj->implementation());
+ QMapRouteObjectPrivateQSG *pimpl =
+ new QMapRouteObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ case QGeoMapObject::IconType: {
+ QMapIconObjectPrivate &oldImpl = static_cast<QMapIconObjectPrivate &>(*obj->implementation());
+ QMapIconObjectPrivateQSG *pimpl =
+ new QMapIconObjectPrivateQSG(oldImpl);
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, pimpl);
+ m_pendingMapObjects << mo;
+ return pimpl;
+ }
+ default:
+ qWarning() << "Unsupported object type: " << obj->type();
+ break;
+ }
+ return nullptr;
+}
+
+QList<QGeoMapObject *> QGeoMapItemsOverlayPrivate::mapObjects() const
+{
+ return QList<QGeoMapObject *>();
+}
+
+int QGeoMapItemsOverlayPrivate::findMapObject(QGeoMapObject *o, const QList<MapObject> &list)
+{
+ for (int i = 0; i < list.size(); ++i)
+ {
+ if (list.at(i).object.data() == o)
+ return i;
+ }
+ return -1;
+}
+
+void QGeoMapItemsOverlayPrivate::removeMapObject(QGeoMapObject *obj)
+{
+ int idx = findMapObject(obj, m_mapObjects);
+ if (idx >= 0) {
+ m_mapObjects.removeAt(idx);
+ } else {
+ idx = findMapObject(obj, m_pendingMapObjects);
+ if (idx >= 0) {
+ m_pendingMapObjects.removeAt(idx);
+ } else {
+ // obj not here.
+ }
+ }
+}
+
+void QGeoMapItemsOverlayPrivate::updateMapObjects(QSGNode *root, QQuickWindow *window)
+{
+ for (int i = 0; i < m_mapObjects.size(); ++i) {
+ // already added as node
+ if (!m_mapObjects.at(i).object) {
+ qWarning() << "m_mapObjects at "<<i<< " NULLed!!";
+ continue;
+ }
+
+ QQSGMapObject *sgo = m_mapObjects.at(i).sgObject;
+ QSGNode *oldNode = sgo->node;
+ sgo->node = sgo->updateMapObjectNode(oldNode, root, window);
+ }
+
+ QList<int> toRemove;
+ for (int i = 0; i < m_pendingMapObjects.size(); ++i) {
+ // already added as node
+ QQSGMapObject *sgo = m_pendingMapObjects.at(i).sgObject;
+ QSGNode *oldNode = sgo->node;
+ sgo->updateGeometry(); // or subtree will be blocked
+ sgo->node = sgo->updateMapObjectNode(oldNode, root, window);
+ if (sgo->node) {
+ m_mapObjects << m_pendingMapObjects.at(i);
+ toRemove.push_front(i);
+ } else {
+ // leave it to be processed
+ }
+ }
+
+ for (int i: qAsConst(toRemove))
+ m_pendingMapObjects.removeAt(i);
+}
+#endif
+
+void QGeoMapItemsOverlayPrivate::updateObjectsGeometry()
+{
+#ifdef LOCATIONLABS
+ Q_Q(QGeoMapItemsOverlay);
+ for (int i = 0; i < m_mapObjects.size(); ++i) {
+ // already added as node
+ if (!m_mapObjects.at(i).object) {
+ qWarning() << "m_mapObjects at "<<i<< " NULLed!!";
+ continue;
+ }
+
+ QQSGMapObject *sgo = m_mapObjects.at(i).sgObject;
+ sgo->updateGeometry();
+ }
+ emit q->sgNodeChanged();
+#endif
+}
+
+void QGeoMapItemsOverlayPrivate::changeViewportSize(const QSize &/*size*/)
{
- Q_UNUSED(size)
+ updateObjectsGeometry();
}
-void QGeoMapItemsOverlayPrivate::changeCameraData(const QGeoCameraData &oldCameraData)
+void QGeoMapItemsOverlayPrivate::changeCameraData(const QGeoCameraData &/*oldCameraData*/)
{
- Q_UNUSED(oldCameraData)
+ updateObjectsGeometry();
}
-void QGeoMapItemsOverlayPrivate::changeActiveMapType(const QGeoMapType mapType)
+void QGeoMapItemsOverlayPrivate::changeActiveMapType(const QGeoMapType /*mapType*/)
{
- Q_UNUSED(mapType)
+ updateObjectsGeometry();
}
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h
index 47249240..42a59f06 100644
--- a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h
+++ b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h
@@ -51,8 +51,10 @@ class QGeoMapItemsOverlay: public QGeoMap
Q_DECLARE_PRIVATE(QGeoMapItemsOverlay)
public:
QGeoMapItemsOverlay(QGeoMappingManagerEngineItemsOverlay *engine, QObject *parent);
-
virtual ~QGeoMapItemsOverlay();
+
+ QGeoMap::Capabilities capabilities() const override;
+
protected:
QSGNode *updateSceneGraph(QSGNode *node, QQuickWindow *window) override;
diff --git a/src/plugins/geoservices/mapbox/mapbox.pro b/src/plugins/geoservices/mapbox/mapbox.pro
index 25a12795..c4e7f671 100644
--- a/src/plugins/geoservices/mapbox/mapbox.pro
+++ b/src/plugins/geoservices/mapbox/mapbox.pro
@@ -2,6 +2,9 @@ TARGET = qtgeoservices_mapbox
QT += location-private positioning-private network
+QT_FOR_CONFIG += location-private
+qtConfig(location-labs-plugin): DEFINES += LOCATIONLABS
+
HEADERS += \
qgeoserviceproviderpluginmapbox.h \
qgeotiledmappingmanagerenginemapbox.h \
diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
index 632b2286..f2595d03 100644
--- a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
@@ -41,6 +41,12 @@
#include <QtLocation/private/qgeomaptype_p.h>
#include <QtLocation/private/qgeotiledmap_p.h>
#include "qgeofiletilecachemapbox.h"
+#ifdef LOCATIONLABS
+#include <QtLocation/private/qgeotiledmaplabs_p.h>
+typedef QGeoTiledMapLabs Map;
+#else
+typedef QGeoTiledMap Map;
+#endif
QT_BEGIN_NAMESPACE
@@ -246,7 +252,7 @@ QGeoTiledMappingManagerEngineMapbox::~QGeoTiledMappingManagerEngineMapbox()
QGeoMap *QGeoTiledMappingManagerEngineMapbox::createMap()
{
- QGeoTiledMap *map = new QGeoTiledMap(this, 0);
+ QGeoTiledMap *map = new Map(this, 0);
map->setPrefetchStyle(m_prefetchStyle);
return map;
}
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
index 4835c201..4dae6826 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
@@ -97,7 +97,7 @@ QMapbox::Feature featureFromMapCircle(QDeclarativeCircleMapItem *mapItem)
for (const QGeoCoordinate &c : qAsConst(path))
pathProjected << p.geoToMapProjection(c);
if (QDeclarativeCircleMapItem::crossEarthPole(mapItem->center(), mapItem->radius()))
- mapItem->preserveCircleGeometry(pathProjected, mapItem->center(), mapItem->radius());
+ mapItem->preserveCircleGeometry(pathProjected, mapItem->center(), mapItem->radius(), p);
path.clear();
for (const QDoubleVector2D &c : qAsConst(pathProjected))
path << p.mapProjectionToGeo(c);
diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro
index c6dadd86..86a0665c 100644
--- a/src/plugins/geoservices/nokia/nokia.pro
+++ b/src/plugins/geoservices/nokia/nokia.pro
@@ -2,6 +2,9 @@ TARGET = qtgeoservices_nokia
QT += location-private positioning-private network
+QT_FOR_CONFIG += location-private
+qtConfig(location-labs-plugin): DEFINES += LOCATIONLABS
+
HEADERS += \
qgeocodereply_nokia.h \
qgeocodejsonparser.h \
diff --git a/src/plugins/geoservices/nokia/qgeotiledmap_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmap_nokia.cpp
index 90be0ae9..a09899d3 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmap_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmap_nokia.cpp
@@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE
\a geoMap and makes use of the functionality provided by \a engine.
*/
QGeoTiledMapNokia::QGeoTiledMapNokia(QGeoTiledMappingManagerEngineNokia *engine, QObject *parent /*= 0*/) :
- QGeoTiledMap(engine, parent),
+ Map(engine, parent),
m_logo(":/nokia/logo.png"), // HERE logo image
m_engine(engine)
{}
diff --git a/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h b/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h
index 9651cc80..487f6f49 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeotiledmap_nokia.h
@@ -40,12 +40,18 @@
#include "qgeotiledmap_p.h"
#include <QtGui/QImage>
#include <QtCore/QPointer>
+#ifdef LOCATIONLABS
+#include <QtLocation/private/qgeotiledmaplabs_p.h>
+typedef QGeoTiledMapLabs Map;
+#else
+typedef QGeoTiledMap Map;
+#endif
QT_BEGIN_NAMESPACE
class QGeoTiledMappingManagerEngineNokia;
-class QGeoTiledMapNokia: public QGeoTiledMap
+class QGeoTiledMapNokia: public Map
{
Q_OBJECT
public:
diff --git a/src/plugins/geoservices/osm/osm.pro b/src/plugins/geoservices/osm/osm.pro
index 86a62744..74e27dc9 100644
--- a/src/plugins/geoservices/osm/osm.pro
+++ b/src/plugins/geoservices/osm/osm.pro
@@ -2,6 +2,9 @@ TARGET = qtgeoservices_osm
QT += location-private positioning-private network concurrent
+QT_FOR_CONFIG += location-private
+qtConfig(location-labs-plugin): DEFINES += LOCATIONLABS
+
HEADERS += \
qgeoserviceproviderpluginosm.h \
qgeotiledmappingmanagerengineosm.h \
diff --git a/src/plugins/geoservices/osm/qgeotiledmaposm.cpp b/src/plugins/geoservices/osm/qgeotiledmaposm.cpp
index 16799dc2..372d1a31 100644
--- a/src/plugins/geoservices/osm/qgeotiledmaposm.cpp
+++ b/src/plugins/geoservices/osm/qgeotiledmaposm.cpp
@@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
QGeoTiledMapOsm::QGeoTiledMapOsm(QGeoTiledMappingManagerEngineOsm *engine, QObject *parent)
-: QGeoTiledMap(engine, parent), m_mapId(-1), m_engine(engine)
+: Map(engine, parent), m_mapId(-1), m_engine(engine)
{
// Needed because evaluateCopyrights() is only triggered if visible tiles change in the map.
// It fails the first time it gets called if providers aren't resolved, and subsequent calls
diff --git a/src/plugins/geoservices/osm/qgeotiledmaposm.h b/src/plugins/geoservices/osm/qgeotiledmaposm.h
index b2af5d89..cc349793 100644
--- a/src/plugins/geoservices/osm/qgeotiledmaposm.h
+++ b/src/plugins/geoservices/osm/qgeotiledmaposm.h
@@ -43,11 +43,17 @@
#include "qgeotileproviderosm.h"
#include <QtLocation/private/qgeotiledmap_p.h>
+#ifdef LOCATIONLABS
+#include <QtLocation/private/qgeotiledmaplabs_p.h>
+typedef QGeoTiledMapLabs Map;
+#else
+typedef QGeoTiledMap Map;
+#endif
QT_BEGIN_NAMESPACE
class QGeoTiledMappingManagerEngineOsm;
-class QGeoTiledMapOsm: public QGeoTiledMap
+class QGeoTiledMapOsm: public Map
{
Q_OBJECT
diff --git a/src/positioning/qdoublevector2d_p.h b/src/positioning/qdoublevector2d_p.h
index e944d2f4..92ccfe85 100644
--- a/src/positioning/qdoublevector2d_p.h
+++ b/src/positioning/qdoublevector2d_p.h
@@ -73,6 +73,7 @@ public:
Q_DECL_CONSTEXPR inline double manhattanLength() const;
inline bool isNull() const;
+ inline bool isFinite() const;
Q_DECL_CONSTEXPR inline double x() const;
Q_DECL_CONSTEXPR inline double y() const;
@@ -136,6 +137,11 @@ inline bool QDoubleVector2D::isNull() const
return qIsNull(xp) && qIsNull(yp);
}
+inline bool QDoubleVector2D::isFinite() const
+{
+ return qIsFinite(xp) && qIsFinite(yp);
+}
+
Q_DECL_CONSTEXPR inline double QDoubleVector2D::x() const { return xp; }
Q_DECL_CONSTEXPR inline double QDoubleVector2D::y() const { return yp; }