summaryrefslogtreecommitdiff
path: root/src/positioning
diff options
context:
space:
mode:
Diffstat (limited to 'src/positioning')
-rw-r--r--src/positioning/positioning.pro11
-rw-r--r--src/positioning/qdoublevector2d.cpp133
-rw-r--r--src/positioning/qdoublevector2d_p.h236
-rw-r--r--src/positioning/qdoublevector3d.cpp188
-rw-r--r--src/positioning/qdoublevector3d_p.h288
-rw-r--r--src/positioning/qgeoaddress.h2
-rw-r--r--src/positioning/qgeocircle.cpp2
-rw-r--r--src/positioning/qgeocoordinate.h2
-rw-r--r--src/positioning/qgeolocation.h2
-rw-r--r--src/positioning/qgeoprojection.cpp140
-rw-r--r--src/positioning/qgeoprojection_p.h80
-rw-r--r--src/positioning/qgeosatelliteinfo.h2
-rw-r--r--src/positioning/qpositioningglobal.h8
13 files changed, 1086 insertions, 8 deletions
diff --git a/src/positioning/positioning.pro b/src/positioning/positioning.pro
index 296356d0..7ad5f480 100644
--- a/src/positioning/positioning.pro
+++ b/src/positioning/positioning.pro
@@ -34,7 +34,10 @@ PRIVATE_HEADERS += \
qgeocoordinate_p.h \
qgeopositioninfosource_p.h \
qdeclarativegeoaddress_p.h \
- qdeclarativegeolocation_p.h
+ qdeclarativegeolocation_p.h \
+ qdoublevector2d_p.h \
+ qdoublevector3d_p.h \
+ qgeoprojection_p.h
SOURCES += \
qgeoaddress.cpp \
@@ -53,8 +56,12 @@ SOURCES += \
qnmeapositioninfosource.cpp \
qgeopositioninfosourcefactory.cpp \
qdeclarativegeoaddress.cpp \
- qdeclarativegeolocation.cpp
+ qdeclarativegeolocation.cpp \
+ qdoublevector2d.cpp \
+ qdoublevector3d.cpp \
+ qgeoprojection.cpp
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
+
load(qt_module)
diff --git a/src/positioning/qdoublevector2d.cpp b/src/positioning/qdoublevector2d.cpp
new file mode 100644
index 00000000..355fbe54
--- /dev/null
+++ b/src/positioning/qdoublevector2d.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdoublevector2d_p.h"
+#include "qdoublevector3d_p.h"
+#include <QtCore/qdatastream.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+QDoubleVector2D::QDoubleVector2D(const QDoubleVector3D &vector)
+{
+ xp = vector.xp;
+ yp = vector.yp;
+}
+
+double QDoubleVector2D::length() const
+{
+ return qSqrt(xp * xp + yp * yp);
+}
+
+double QDoubleVector2D::lengthSquared() const
+{
+ return xp * xp + yp * yp;
+}
+
+QDoubleVector2D QDoubleVector2D::normalized() const
+{
+ // Need some extra precision if the length is very small.
+ double len = double(xp) * double(xp) +
+ double(yp) * double(yp);
+ if (qFuzzyIsNull(len - 1.0))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / (double)qSqrt(len);
+ else
+ return QDoubleVector2D();
+}
+
+void QDoubleVector2D::normalize()
+{
+ // Need some extra precision if the length is very small.
+ double len = double(xp) * double(xp) +
+ double(yp) * double(yp);
+ if (qFuzzyIsNull(len - 1.0) || qFuzzyIsNull(len))
+ return;
+
+ len = qSqrt(len);
+
+ xp /= len;
+ yp /= len;
+}
+
+double QDoubleVector2D::dotProduct(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+{
+ return v1.xp * v2.xp + v1.yp * v2.yp;
+}
+
+QDoubleVector3D QDoubleVector2D::toVector3D() const
+{
+ return QDoubleVector3D(xp, yp, 0.0);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+
+QDebug operator<<(QDebug dbg, const QDoubleVector2D &vector)
+{
+ dbg.nospace() << "QDoubleVector2D(" << vector.x() << ", " << vector.y() << ')';
+ return dbg.space();
+}
+
+#endif
+
+#ifndef QT_NO_DATASTREAM
+
+QDataStream &operator<<(QDataStream &stream, const QDoubleVector2D &vector)
+{
+ stream << double(vector.x()) << double(vector.y());
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QDoubleVector2D &vector)
+{
+ double x, y;
+ stream >> x;
+ stream >> y;
+ vector.setX(double(x));
+ vector.setY(double(y));
+ return stream;
+}
+
+#endif // QT_NO_DATASTREAM
+
+QT_END_NAMESPACE
diff --git a/src/positioning/qdoublevector2d_p.h b/src/positioning/qdoublevector2d_p.h
new file mode 100644
index 00000000..b3c24af6
--- /dev/null
+++ b/src/positioning/qdoublevector2d_p.h
@@ -0,0 +1,236 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDOUBLEVECTOR2D_P_H
+#define QDOUBLEVECTOR2D_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.
+//
+
+#ifdef QT_BUILD_LOCATION_LIB
+#include <QVector2D>
+#endif
+
+#include "qpositioningglobal.h"
+#include <QtCore/qmetatype.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDoubleVector3D;
+
+class Q_POSITIONING_EXPORT_PRIVATE QDoubleVector2D
+{
+public:
+ QDoubleVector2D();
+ QDoubleVector2D(double xpos, double ypos);
+ explicit QDoubleVector2D(const QDoubleVector3D &vector);
+#ifdef QT_BUILD_LOCATION_LIB
+ explicit QDoubleVector2D(const QVector2D &vector) : xp(vector.x()), yp(vector.y()) {}
+ operator QVector2D() const { return QVector2D(xp, yp); }
+#endif
+
+ bool isNull() const;
+
+ double x() const;
+ double y() const;
+
+ void setX(double x);
+ void setY(double y);
+
+ double length() const;
+ double lengthSquared() const;
+
+ QDoubleVector2D normalized() const;
+ void normalize();
+
+ QDoubleVector2D &operator+=(const QDoubleVector2D &vector);
+ QDoubleVector2D &operator-=(const QDoubleVector2D &vector);
+ QDoubleVector2D &operator*=(double factor);
+ QDoubleVector2D &operator*=(const QDoubleVector2D &vector);
+ QDoubleVector2D &operator/=(double divisor);
+
+ static double dotProduct(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+
+ friend inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector);
+ friend inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor);
+ friend inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+ friend inline const QDoubleVector2D operator-(const QDoubleVector2D &vector);
+ friend inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor);
+
+ friend inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
+
+ QDoubleVector3D toVector3D() const;
+
+private:
+ double xp, yp;
+
+ friend class QDoubleVector3D;
+};
+
+Q_DECLARE_TYPEINFO(QDoubleVector2D, Q_MOVABLE_TYPE);
+
+inline QDoubleVector2D::QDoubleVector2D() : xp(0.0), yp(0.0) {}
+
+
+
+inline QDoubleVector2D::QDoubleVector2D(double xpos, double ypos) : xp(xpos), yp(ypos) {}
+
+
+inline bool QDoubleVector2D::isNull() const
+{
+ return qIsNull(xp) && qIsNull(yp);
+}
+
+inline double QDoubleVector2D::x() const { return double(xp); }
+inline double QDoubleVector2D::y() const { return double(yp); }
+
+inline void QDoubleVector2D::setX(double aX) { xp = aX; }
+inline void QDoubleVector2D::setY(double aY) { yp = aY; }
+
+inline QDoubleVector2D &QDoubleVector2D::operator+=(const QDoubleVector2D &vector)
+{
+ xp += vector.xp;
+ yp += vector.yp;
+ return *this;
+}
+
+inline QDoubleVector2D &QDoubleVector2D::operator-=(const QDoubleVector2D &vector)
+{
+ xp -= vector.xp;
+ yp -= vector.yp;
+ return *this;
+}
+
+inline QDoubleVector2D &QDoubleVector2D::operator*=(double factor)
+{
+ xp *= factor;
+ yp *= factor;
+ return *this;
+}
+
+inline QDoubleVector2D &QDoubleVector2D::operator*=(const QDoubleVector2D &vector)
+{
+ xp *= vector.xp;
+ yp *= vector.yp;
+ return *this;
+}
+
+inline QDoubleVector2D &QDoubleVector2D::operator/=(double divisor)
+{
+ xp /= divisor;
+ yp /= divisor;
+ return *this;
+}
+
+inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+{
+ return v1.xp == v2.xp && v1.yp == v2.yp;
+}
+
+inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+{
+ return v1.xp != v2.xp || v1.yp != v2.yp;
+}
+
+inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+{
+ return QDoubleVector2D(v1.xp + v2.xp, v1.yp + v2.yp);
+}
+
+inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+{
+ return QDoubleVector2D(v1.xp - v2.xp, v1.yp - v2.yp);
+}
+
+inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector)
+{
+ return QDoubleVector2D(vector.xp * factor, vector.yp * factor);
+}
+
+inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor)
+{
+ return QDoubleVector2D(vector.xp * factor, vector.yp * factor);
+}
+
+inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+{
+ return QDoubleVector2D(v1.xp * v2.xp, v1.yp * v2.yp);
+}
+
+inline const QDoubleVector2D operator-(const QDoubleVector2D &vector)
+{
+ return QDoubleVector2D(-vector.xp, -vector.yp);
+}
+
+inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor)
+{
+ return QDoubleVector2D(vector.xp / divisor, vector.yp / divisor);
+}
+
+inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
+{
+ return qFuzzyCompare(v1.xp, v2.xp) && qFuzzyCompare(v1.yp, v2.yp);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QDoubleVector2D &vector);
+#endif
+
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &, const QDoubleVector2D &);
+QDataStream &operator>>(QDataStream &, QDoubleVector2D &);
+#endif
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/positioning/qdoublevector3d.cpp b/src/positioning/qdoublevector3d.cpp
new file mode 100644
index 00000000..c4e2cf61
--- /dev/null
+++ b/src/positioning/qdoublevector3d.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdoublevector3d_p.h"
+#include "qdoublevector2d_p.h"
+#include <QtCore/qdatastream.h>
+#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &vector)
+{
+ xp = vector.xp;
+ yp = vector.yp;
+ zp = 0.0;
+}
+
+QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &vector, double zpos)
+{
+ xp = vector.xp;
+ yp = vector.yp;
+ zp = zpos;
+}
+
+QDoubleVector3D QDoubleVector3D::normalized() const
+{
+ // Need some extra precision if the length is very small.
+ double len = double(xp) * double(xp) +
+ double(yp) * double(yp) +
+ double(zp) * double(zp);
+ if (qFuzzyIsNull(len - 1.0))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / (double)qSqrt(len);
+ else
+ return QDoubleVector3D();
+}
+
+void QDoubleVector3D::normalize()
+{
+ // Need some extra precision if the length is very small.
+ double len = double(xp) * double(xp) +
+ double(yp) * double(yp) +
+ double(zp) * double(zp);
+ if (qFuzzyIsNull(len - 1.0) || qFuzzyIsNull(len))
+ return;
+
+ len = qSqrt(len);
+
+ xp /= len;
+ yp /= len;
+ zp /= len;
+}
+
+double QDoubleVector3D::dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
+}
+
+QDoubleVector3D QDoubleVector3D::crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return QDoubleVector3D(v1.yp * v2.zp - v1.zp * v2.yp,
+ v1.zp * v2.xp - v1.xp * v2.zp,
+ v1.xp * v2.yp - v1.yp * v2.xp);
+}
+
+QDoubleVector3D QDoubleVector3D::normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return crossProduct(v1, v2).normalized();
+}
+
+QDoubleVector3D QDoubleVector3D::normal
+ (const QDoubleVector3D &v1, const QDoubleVector3D &v2, const QDoubleVector3D &v3)
+{
+ return crossProduct((v2 - v1), (v3 - v1)).normalized();
+}
+
+double QDoubleVector3D::distanceToPlane
+ (const QDoubleVector3D &plane, const QDoubleVector3D &normal) const
+{
+ return dotProduct(*this - plane, normal);
+}
+
+double QDoubleVector3D::distanceToPlane
+ (const QDoubleVector3D &plane1, const QDoubleVector3D &plane2, const QDoubleVector3D &plane3) const
+{
+ QDoubleVector3D n = normal(plane2 - plane1, plane3 - plane1);
+ return dotProduct(*this - plane1, n);
+}
+
+double QDoubleVector3D::distanceToLine
+ (const QDoubleVector3D &point, const QDoubleVector3D &direction) const
+{
+ if (direction.isNull())
+ return (*this - point).length();
+ QDoubleVector3D p = point + dotProduct(*this - point, direction) * direction;
+ return (*this - p).length();
+}
+
+QDoubleVector2D QDoubleVector3D::toVector2D() const
+{
+ return QDoubleVector2D(xp, yp);
+}
+
+double QDoubleVector3D::length() const
+{
+ return qSqrt(xp * xp + yp * yp + zp * zp);
+}
+
+double QDoubleVector3D::lengthSquared() const
+{
+ return xp * xp + yp * yp + zp * zp;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+
+QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector)
+{
+ dbg.nospace() << "QDoubleVector3D("
+ << vector.x() << ", " << vector.y() << ", " << vector.z() << ')';
+ return dbg.space();
+}
+
+#endif
+
+#ifndef QT_NO_DATASTREAM
+
+QDataStream &operator<<(QDataStream &stream, const QDoubleVector3D &vector)
+{
+ stream << double(vector.x()) << double(vector.y())
+ << double(vector.z());
+ return stream;
+}
+
+QDataStream &operator>>(QDataStream &stream, QDoubleVector3D &vector)
+{
+ double x, y, z;
+ stream >> x;
+ stream >> y;
+ stream >> z;
+ vector.setX(double(x));
+ vector.setY(double(y));
+ vector.setZ(double(z));
+ return stream;
+}
+
+#endif // QT_NO_DATASTREAM
+
+QT_END_NAMESPACE
diff --git a/src/positioning/qdoublevector3d_p.h b/src/positioning/qdoublevector3d_p.h
new file mode 100644
index 00000000..c2033d34
--- /dev/null
+++ b/src/positioning/qdoublevector3d_p.h
@@ -0,0 +1,288 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDOUBLEVECTOR3D_P_H
+#define QDOUBLEVECTOR3D_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.
+//
+
+#ifdef QT_BUILD_LOCATION_LIB
+#include <QVector3D>
+#endif
+
+#include "qpositioningglobal.h"
+#include <QtCore/qmetatype.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDoubleVector2D;
+
+class Q_POSITIONING_EXPORT_PRIVATE QDoubleVector3D
+{
+public:
+ QDoubleVector3D();
+ QDoubleVector3D(double xpos, double ypos, double zpos);
+ QDoubleVector3D(const QDoubleVector2D &vector);
+ QDoubleVector3D(const QDoubleVector2D &vector, double zpos);
+
+#ifdef QT_BUILD_LOCATION_LIB
+ explicit QDoubleVector3D(const QVector3D &vector) : xp(vector.x()), yp(vector.y()), zp(vector.z()) {}
+ operator QVector3D() const { return QVector3D(xp, yp, zp); }
+#endif
+
+ bool isNull() const;
+
+ double x() const;
+ double y() const;
+ double z() const;
+
+ void setX(double x);
+ void setY(double y);
+ void setZ(double z);
+
+ double get(int i) const;
+ void set(int i, double value);
+
+ double length() const;
+ double lengthSquared() const;
+
+ QDoubleVector3D normalized() const;
+ void normalize();
+
+ QDoubleVector3D &operator+=(const QDoubleVector3D &vector);
+ QDoubleVector3D &operator-=(const QDoubleVector3D &vector);
+ QDoubleVector3D &operator*=(double factor);
+ QDoubleVector3D &operator*=(const QDoubleVector3D &vector);
+ QDoubleVector3D &operator/=(double divisor);
+
+ static double dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ static QDoubleVector3D crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ static QDoubleVector3D normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ static QDoubleVector3D normal
+ (const QDoubleVector3D &v1, const QDoubleVector3D &v2, const QDoubleVector3D &v3);
+
+ double distanceToPlane(const QDoubleVector3D &plane, const QDoubleVector3D &normal) const;
+ double distanceToPlane(const QDoubleVector3D &plane1, const QDoubleVector3D &plane2, const QDoubleVector3D &plane3) const;
+ double distanceToLine(const QDoubleVector3D &point, const QDoubleVector3D &direction) const;
+
+ friend inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector);
+ friend inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor);
+ friend const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+ friend inline const QDoubleVector3D operator-(const QDoubleVector3D &vector);
+ friend inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor);
+
+ friend inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
+
+ QDoubleVector2D toVector2D() const;
+
+private:
+ double xp, yp, zp;
+
+ friend class QDoubleVector2D;
+};
+
+Q_DECLARE_TYPEINFO(QDoubleVector3D, Q_MOVABLE_TYPE);
+
+inline QDoubleVector3D::QDoubleVector3D() : xp(0.0), yp(0.0), zp(0.0) {}
+
+inline QDoubleVector3D::QDoubleVector3D(double xpos, double ypos, double zpos) : xp(xpos), yp(ypos), zp(zpos) {}
+
+inline bool QDoubleVector3D::isNull() const
+{
+ return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
+}
+
+inline double QDoubleVector3D::x() const { return xp; }
+inline double QDoubleVector3D::y() const { return yp; }
+inline double QDoubleVector3D::z() const { return zp; }
+
+inline void QDoubleVector3D::setX(double aX) { xp = aX; }
+inline void QDoubleVector3D::setY(double aY) { yp = aY; }
+inline void QDoubleVector3D::setZ(double aZ) { zp = aZ; }
+
+inline double QDoubleVector3D::get(int i) const
+{
+ switch (i) {
+ case 0:
+ return xp;
+ case 1:
+ return yp;
+ case 2:
+ return zp;
+ default:
+ return 0.0;
+ }
+}
+
+inline void QDoubleVector3D::set(int i, double value)
+{
+ switch (i) {
+ case 0:
+ xp = value;
+ break;
+ case 1:
+ yp = value;
+ break;
+ case 2:
+ zp = value;
+ break;
+ default:
+ break;
+ }
+}
+
+inline QDoubleVector3D &QDoubleVector3D::operator+=(const QDoubleVector3D &vector)
+{
+ xp += vector.xp;
+ yp += vector.yp;
+ zp += vector.zp;
+ return *this;
+}
+
+inline QDoubleVector3D &QDoubleVector3D::operator-=(const QDoubleVector3D &vector)
+{
+ xp -= vector.xp;
+ yp -= vector.yp;
+ zp -= vector.zp;
+ return *this;
+}
+
+inline QDoubleVector3D &QDoubleVector3D::operator*=(double factor)
+{
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ return *this;
+}
+
+inline QDoubleVector3D &QDoubleVector3D::operator*=(const QDoubleVector3D &vector)
+{
+ xp *= vector.xp;
+ yp *= vector.yp;
+ zp *= vector.zp;
+ return *this;
+}
+
+inline QDoubleVector3D &QDoubleVector3D::operator/=(double divisor)
+{
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ return *this;
+}
+
+inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp;
+}
+
+inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp;
+}
+
+inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return QDoubleVector3D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp);
+}
+
+inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return QDoubleVector3D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp);
+}
+
+inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector)
+{
+ return QDoubleVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
+}
+
+inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor)
+{
+ return QDoubleVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
+}
+
+inline const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return QDoubleVector3D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp);
+}
+
+inline const QDoubleVector3D operator-(const QDoubleVector3D &vector)
+{
+ return QDoubleVector3D(-vector.xp, -vector.yp, -vector.zp);
+}
+
+inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor)
+{
+ return QDoubleVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor);
+}
+
+inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
+{
+ return qFuzzyCompare(v1.xp, v2.xp) &&
+ qFuzzyCompare(v1.yp, v2.yp) &&
+ qFuzzyCompare(v1.zp, v2.zp);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector);
+#endif
+
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &, const QDoubleVector3D &);
+QDataStream &operator>>(QDataStream &, QDoubleVector3D &);
+#endif
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/positioning/qgeoaddress.h b/src/positioning/qgeoaddress.h
index 1aedd1a5..5d9371c5 100644
--- a/src/positioning/qgeoaddress.h
+++ b/src/positioning/qgeoaddress.h
@@ -44,7 +44,7 @@
#include <QtCore/QMetaType>
#include <QtCore/QSharedDataPointer>
-#include <QtPositioning/qpositioningglobal.h>
+#include "qpositioningglobal.h"
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qgeocircle.cpp b/src/positioning/qgeocircle.cpp
index 4a4f67aa..60dffb41 100644
--- a/src/positioning/qgeocircle.cpp
+++ b/src/positioning/qgeocircle.cpp
@@ -45,6 +45,8 @@
#include "qgeocoordinate.h"
#include "qnumeric.h"
+#include "qdoublevector2d_p.h"
+#include "qdoublevector3d_p.h"
QT_BEGIN_NAMESPACE
/*!
diff --git a/src/positioning/qgeocoordinate.h b/src/positioning/qgeocoordinate.h
index 23001ad1..a4e76906 100644
--- a/src/positioning/qgeocoordinate.h
+++ b/src/positioning/qgeocoordinate.h
@@ -45,7 +45,7 @@
#include <QtCore/QMetaType>
#include <QtCore/QString>
#include <QSharedDataPointer>
-#include <QtPositioning/qpositioningglobal.h>
+#include "qpositioningglobal.h"
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qgeolocation.h b/src/positioning/qgeolocation.h
index 395f83f1..5d1aa98c 100644
--- a/src/positioning/qgeolocation.h
+++ b/src/positioning/qgeolocation.h
@@ -44,7 +44,7 @@
#include <QtCore/QSharedDataPointer>
#include <QtCore/QMetaType>
-#include <QtPositioning/qpositioningglobal.h>
+#include "qpositioningglobal.h"
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qgeoprojection.cpp b/src/positioning/qgeoprojection.cpp
new file mode 100644
index 00000000..d2cc9243
--- /dev/null
+++ b/src/positioning/qgeoprojection.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qgeoprojection_p.h"
+
+#include "qgeocoordinate.h"
+
+#include <qnumeric.h>
+
+#include <cmath>
+
+#include "qdoublevector2d_p.h"
+#include "qdoublevector3d_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QDoubleVector2D QGeoProjection::coordToMercator(const QGeoCoordinate &coord)
+{
+ const double pi = M_PI;
+
+ double lon = coord.longitude() / 360.0 + 0.5;
+
+ double lat = coord.latitude();
+ lat = 0.5 - (std::log(std::tan((pi / 4.0) + (pi / 2.0) * lat / 180.0)) / pi) / 2.0;
+ lat = qMax(0.0, lat);
+ lat = qMin(1.0, lat);
+
+ return QDoubleVector2D(lon, lat);
+}
+
+double QGeoProjection::realmod(const double a, const double b)
+{
+ quint64 div = static_cast<quint64>(a / b);
+ return a - static_cast<double>(div) * b;
+}
+
+QGeoCoordinate QGeoProjection::mercatorToCoord(const QDoubleVector2D &mercator)
+{
+ const double pi = M_PI;
+
+ double fx = mercator.x();
+ double fy = mercator.y();
+
+ if (fy < 0.0)
+ fy = 0.0;
+ else if (fy > 1.0)
+ fy = 1.0;
+
+ double lat;
+
+ if (fy == 0.0)
+ lat = 90.0;
+ else if (fy == 1.0)
+ lat = -90.0;
+ else
+ lat = (180.0 / pi) * (2.0 * std::atan(std::exp(pi * (1.0 - 2.0 * fy))) - (pi / 2.0));
+
+ double lng;
+ if (fx >= 0) {
+ lng = realmod(fx, 1.0);
+ } else {
+ lng = realmod(1.0 - realmod(-1.0 * fx, 1.0), 1.0);
+ }
+
+ lng = lng * 360.0 - 180.0;
+
+ return QGeoCoordinate(lat, lng, 0.0);
+}
+
+QGeoCoordinate QGeoProjection::coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
+{
+ QDoubleVector2D s = QGeoProjection::coordToMercator(from);
+ QDoubleVector2D e = QGeoProjection::coordToMercator(to);
+
+ double x = s.x();
+
+ if (0.5 < qAbs(e.x() - s.x())) {
+ // handle dateline crossing
+ double ex = e.x();
+ double sx = s.x();
+ if (ex < sx)
+ sx -= 1.0;
+ else if (sx < ex)
+ ex -= 1.0;
+
+ x = (1.0 - progress) * sx + progress * ex;
+
+ if (!qFuzzyIsNull(x) && (x < 0.0))
+ x += 1.0;
+
+ } else {
+ x = (1.0 - progress) * s.x() + progress * e.x();
+ }
+
+ double y = (1.0 - progress) * s.y() + progress * e.y();
+
+ QGeoCoordinate result = QGeoProjection::mercatorToCoord(QDoubleVector2D(x, y));
+ result.setAltitude((1.0 - progress) * from.altitude() + progress * to.altitude());
+
+ return result;
+}
+
+QT_END_NAMESPACE
diff --git a/src/positioning/qgeoprojection_p.h b/src/positioning/qgeoprojection_p.h
new file mode 100644
index 00000000..d0280030
--- /dev/null
+++ b/src/positioning/qgeoprojection_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGEOPROJECTION_P_H
+#define QGEOPROJECTION_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.
+//
+
+#ifndef M_PI
+#define M_PI (3.14159265358979323846)
+#endif
+
+#include <qglobal.h>
+#include "qpositioningglobal.h"
+
+QT_BEGIN_NAMESPACE
+
+class QGeoCoordinate;
+class QDoubleVector2D;
+
+class Q_POSITIONING_EXPORT_PRIVATE QGeoProjection
+{
+public:
+ static QDoubleVector2D coordToMercator(const QGeoCoordinate &coord);
+ static QGeoCoordinate mercatorToCoord(const QDoubleVector2D &mercator);
+ static QGeoCoordinate coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress);
+
+private:
+ static double realmod(const double a, const double b);
+};
+
+QT_END_NAMESPACE
+
+#endif // QGEOPROJECTION_P_H
diff --git a/src/positioning/qgeosatelliteinfo.h b/src/positioning/qgeosatelliteinfo.h
index fb13157d..b6c70e4c 100644
--- a/src/positioning/qgeosatelliteinfo.h
+++ b/src/positioning/qgeosatelliteinfo.h
@@ -41,7 +41,7 @@
#ifndef QGEOSATELLITEINFO_H
#define QGEOSATELLITEINFO_H
-#include <QtPositioning/qpositioningglobal.h>
+#include "qpositioningglobal.h"
QT_BEGIN_NAMESPACE
diff --git a/src/positioning/qpositioningglobal.h b/src/positioning/qpositioningglobal.h
index e0de618b..5d1c3dea 100644
--- a/src/positioning/qpositioningglobal.h
+++ b/src/positioning/qpositioningglobal.h
@@ -47,14 +47,18 @@ QT_BEGIN_NAMESPACE
#ifndef QT_STATIC
# if defined(QT_BUILD_POSITIONING_LIB)
-# define Q_POSITIONING_EXPORT Q_DECL_EXPORT
+# define Q_POSITIONING_EXPORT Q_DECL_EXPORT
+# define Q_POSITIONING_EXPORT_PRIVATE Q_DECL_EXPORT
# else
-# define Q_POSITIONING_EXPORT Q_DECL_IMPORT
+# define Q_POSITIONING_EXPORT Q_DECL_IMPORT
+# define Q_POSITIONING_EXPORT_PRIVATE Q_DECL_IMPORT
# endif
#else
# define Q_POSITIONING_EXPORT
+# define Q_POSITIONING_EXPORT_PRIVATE
#endif
+
QT_END_NAMESPACE
#endif // QPOSITIONINGGLOBAL_H