summaryrefslogtreecommitdiff
path: root/src/positioning
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-11-06 16:21:58 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-11-30 16:20:12 +0000
commit74e0f7b414432688858ce9d82a05384b4f883688 (patch)
tree8829ceb8bca000db8383f991240832e5c1e72835 /src/positioning
parent3e107c6d2933b4b924100d1aab18f52f7ca40edc (diff)
downloadqtlocation-74e0f7b414432688858ce9d82a05384b4f883688.tar.gz
Introduce Waypoint
This patch replaces QGeoCoordinate with Waypoint as mean to specify waypoints in a RouteQuery. This patch also adds a new invokable to RouteQuery, waypointObjects, to return QDeclarativeGeoWaypoints instead of QGeoCooordinates. NOTE: If, by 5.11, support to perform implicit conversions in method invocations based on converters registered in the metatype system will be added, this method could/should be removed, and QDeclarativeGeoWaypoint objects should be return as QVariants from the waypoints() getter, as they could be used in place of QGeoCoordinate when passing them as arguments. Task-number: QTBUG-64066 Change-Id: I77747f53cdcbabe6430580b60fa59d4afe8c650a Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/positioning')
-rw-r--r--src/positioning/positioning.pro5
-rw-r--r--src/positioning/qgeocoordinate.cpp36
-rw-r--r--src/positioning/qgeocoordinate.h13
-rw-r--r--src/positioning/qgeocoordinateobject.cpp92
-rw-r--r--src/positioning/qgeocoordinateobject_p.h83
5 files changed, 228 insertions, 1 deletions
diff --git a/src/positioning/positioning.pro b/src/positioning/positioning.pro
index 37491319..666e9b1a 100644
--- a/src/positioning/positioning.pro
+++ b/src/positioning/positioning.pro
@@ -58,6 +58,8 @@ PRIVATE_HEADERS += \
qlocationdata_simulator_p.h \
qdoublematrix4x4_p.h \
qgeopath_p.h \
+ qgeopolygon_p.h \
+ qgeocoordinateobject_p.h \
qclipperutils_p.h
SOURCES += \
@@ -85,7 +87,8 @@ SOURCES += \
qlocationdata_simulator.cpp \
qwebmercator.cpp \
qdoublematrix4x4.cpp \
- qclipperutils.cpp
+ qclipperutils.cpp \
+ qgeocoordinateobject.cpp
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
diff --git a/src/positioning/qgeocoordinate.cpp b/src/positioning/qgeocoordinate.cpp
index 7a286f8a..12f5ad52 100644
--- a/src/positioning/qgeocoordinate.cpp
+++ b/src/positioning/qgeocoordinate.cpp
@@ -39,6 +39,7 @@
#include "qgeocoordinate.h"
#include "qgeocoordinate_p.h"
#include "qlocationutils_p.h"
+#include "qgeocoordinateobject_p.h"
#include <QDateTime>
#include <QHash>
@@ -250,6 +251,16 @@ QGeoCoordinate::QGeoCoordinate(const QGeoCoordinate &other)
: d(other.d)
{}
+QGeoCoordinate::QGeoCoordinate(const QGeoCoordinateObject &coordinateoObject) : d(coordinateoObject.coordinate().d)
+{
+}
+
+QGeoCoordinate::QGeoCoordinate(const QGeoCoordinateObject *coordinateObject) : d(new QGeoCoordinatePrivate)
+{
+ if (coordinateObject)
+ d = coordinateObject->coordinate().d;
+}
+
/*!
Assigns \a other to this coordinate and returns a reference to this coordinate.
*/
@@ -262,6 +273,18 @@ QGeoCoordinate &QGeoCoordinate::operator=(const QGeoCoordinate &other)
return (*this);
}
+QGeoCoordinate &QGeoCoordinate::operator=(const QGeoCoordinateObject &coordinateoObject)
+{
+ d = coordinateoObject.coordinate().d;
+ return (*this);
+}
+
+QGeoCoordinate &QGeoCoordinate::operator=(const QGeoCoordinateObject *coordinateoObject)
+{
+ d = coordinateoObject->coordinate().d;
+ return (*this);
+}
+
/*!
Destroys the coordinate object.
*/
@@ -291,6 +314,19 @@ bool QGeoCoordinate::operator==(const QGeoCoordinate &other) const
}
/*!
+
+*/
+bool QGeoCoordinate::operator==(const QGeoCoordinateObject &other) const
+{
+ return (*this == other.coordinate());
+}
+
+bool QGeoCoordinate::operator==(const QGeoCoordinateObject *other) const
+{
+ return (*this == other->coordinate());
+}
+
+/*!
\fn bool QGeoCoordinate::operator!=(const QGeoCoordinate &other) const;
Returns true if the latitude, longitude or altitude of this
diff --git a/src/positioning/qgeocoordinate.h b/src/positioning/qgeocoordinate.h
index ddb6274e..c5497dae 100644
--- a/src/positioning/qgeocoordinate.h
+++ b/src/positioning/qgeocoordinate.h
@@ -51,6 +51,7 @@ class QDebug;
class QDataStream;
class QGeoCoordinatePrivate;
+class QGeoCoordinateObject;
class Q_POSITIONING_EXPORT QGeoCoordinate
{
Q_GADGET
@@ -81,14 +82,26 @@ public:
QGeoCoordinate(double latitude, double longitude);
QGeoCoordinate(double latitude, double longitude, double altitude);
QGeoCoordinate(const QGeoCoordinate &other);
+ QGeoCoordinate(const QGeoCoordinateObject &coordinateoObject);
+ QGeoCoordinate(const QGeoCoordinateObject *coordinateObject);
~QGeoCoordinate();
QGeoCoordinate &operator=(const QGeoCoordinate &other);
+ QGeoCoordinate &operator=(const QGeoCoordinateObject &coordinateObject);
+ QGeoCoordinate &operator=(const QGeoCoordinateObject *coordinateoObject);
bool operator==(const QGeoCoordinate &other) const;
+ bool operator==(const QGeoCoordinateObject &other) const;
+ bool operator==(const QGeoCoordinateObject *other) const;
inline bool operator!=(const QGeoCoordinate &other) const {
return !operator==(other);
}
+ inline bool operator!=(const QGeoCoordinateObject &other) const {
+ return !operator==(other);
+ }
+ inline bool operator!=(const QGeoCoordinateObject *other) const {
+ return !operator==(*other);
+ }
bool isValid() const;
CoordinateType type() const;
diff --git a/src/positioning/qgeocoordinateobject.cpp b/src/positioning/qgeocoordinateobject.cpp
new file mode 100644
index 00000000..7900e578
--- /dev/null
+++ b/src/positioning/qgeocoordinateobject.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeocoordinateobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*
+
+ Note: This class only purpose is to enable conversion between QGeoCoordinate and QDeclarativeGeoWaypoint.
+ Since QGeoCoordinate lives in the QtPositioning module, this class acts as a base for QDeclarativeGeoWaypoint,
+ and contains the bare minimum to convert/compare to a QGeoCoordinate
+
+*/
+
+QGeoCoordinateObject::QGeoCoordinateObject(QObject *parent) : QObject(parent)
+{
+}
+
+QGeoCoordinateObject::QGeoCoordinateObject(const QGeoCoordinate &c, QObject *parent) : QObject(parent)
+{
+ setCoordinate(c);
+}
+
+QGeoCoordinateObject::~QGeoCoordinateObject()
+{
+
+}
+
+bool QGeoCoordinateObject::operator==(const QGeoCoordinateObject &other) const
+{
+ return m_coordinate == other.m_coordinate;
+}
+
+bool QGeoCoordinateObject::operator==(const QGeoCoordinate &other) const
+{
+ return m_coordinate == other;
+}
+
+QGeoCoordinate QGeoCoordinateObject::coordinate() const
+{
+ return m_coordinate;
+}
+
+void QGeoCoordinateObject::setCoordinate(const QGeoCoordinate &c)
+{
+ if (c == m_coordinate)
+ return;
+
+ m_coordinate = c;
+ emit coordinateChanged();
+}
+
+QT_END_NAMESPACE
+
+
diff --git a/src/positioning/qgeocoordinateobject_p.h b/src/positioning/qgeocoordinateobject_p.h
new file mode 100644
index 00000000..7061c28f
--- /dev/null
+++ b/src/positioning/qgeocoordinateobject_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOCOORDINATEOBJECT_P_H
+#define QGEOCOORDINATEOBJECT_P_H
+
+#include <QtPositioning/private/qpositioningglobal_p.h>
+#include <QObject>
+#include <QGeoCoordinate>
+#include <QVariantMap>
+
+QT_BEGIN_NAMESPACE
+
+class Q_POSITIONING_PRIVATE_EXPORT QGeoCoordinateObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
+
+public:
+ QGeoCoordinateObject(QObject *parent = 0);
+ QGeoCoordinateObject(const QGeoCoordinate &c, QObject *parent = 0);
+ virtual ~QGeoCoordinateObject();
+
+ bool operator==(const QGeoCoordinate &other) const;
+ bool operator==(const QGeoCoordinateObject &other) const;
+ inline bool operator!=(const QGeoCoordinate &other) const {
+ return !operator==(other);
+ }
+ inline bool operator!=(const QGeoCoordinateObject &other) const {
+ return !operator==(other);
+ }
+
+ QGeoCoordinate coordinate() const;
+ void setCoordinate(const QGeoCoordinate &c);
+
+Q_SIGNALS:
+ void coordinateChanged();
+
+protected:
+ QGeoCoordinate m_coordinate;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QGeoCoordinateObject*)
+
+#endif // QGEOCOORDINATEOBJECT_P_H