Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickgeocoordinateanimation.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6#include <QtQuick/private/qquickanimation_p_p.h>
7#include <QtPositioning/private/qdoublevector2d_p.h>
8#include <QtPositioning/private/qwebmercator_p.h>
9#include <QtPositioning/private/qgeocoordinate_p.h>
10
12
37{
38 if (from == to) {
39 if (progress < 0.5) {
40 return QVariant::fromValue(from);
41 } else {
42 return QVariant::fromValue(to);
43 }
44 }
45
47
49}
50
52{
53 const QGeoMercatorCoordinatePrivate* fromMercator =
55 const QGeoMercatorCoordinatePrivate* toMercator =
57
58 double toX = toMercator->m_mercatorX;
59 double toY = toMercator->m_mercatorY;
60 double fromX = fromMercator->m_mercatorX;
61 double fromY = fromMercator->m_mercatorY;
62 double x;
63 if (0.5 < qAbs(toX - fromX)) {
64 // handle dateline crossing
65 double ex = toX;
66 double sx = fromX;
67 if (ex < sx)
68 sx -= 1.0;
69 else if (sx < ex)
70 ex -= 1.0;
71
72 x = sx + (ex - sx) * progress;
73
74 if (x < 0.0)
75 x += 1.0;
76
77 } else {
78 x = fromX + (toX - fromX) * progress;
79 }
80
81 double y = fromY + (toY - fromY) * progress;
82
84 result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress);
86}
87
89{
90 const QGeoMercatorCoordinatePrivate* fromMercator =
92 const QGeoMercatorCoordinatePrivate* toMercator =
94
95 double toX = toMercator->m_mercatorX;
96 double toY = toMercator->m_mercatorY;
97 double fromX = fromMercator->m_mercatorX;
98 double fromY = fromMercator->m_mercatorY;
99 double diff = toX - fromX;
100
101 while (diff < 0.0) {
102 toX += 1.0;
103 diff += 1.0;
104 }
105
106 double x = fromX + (toX - fromX) * progress;
107 double y = fromY + (toY - fromY) * progress;
108
109 while (x > 1.0)
110 x -= 1.0;
111
113 result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress);
114
116}
117
119{
120 const QGeoMercatorCoordinatePrivate* fromMercator =
122 const QGeoMercatorCoordinatePrivate* toMercator =
124
125 double toX = toMercator->m_mercatorX;
126 double toY = toMercator->m_mercatorY;
127 double fromX = fromMercator->m_mercatorX;
128 double fromY = fromMercator->m_mercatorY;
129 double diff = toX - fromX;
130
131 while (diff > 0.0) {
132 toX -= 1.0;
133 diff -= 1.0;
134 }
135
136 double x = fromX + (toX - fromX) * progress;
137 double y = fromY + (toY - fromY) * progress;
138
139 while (x < 0.0)
140 x += 1.0;
141
143 result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress);
144
146}
147
150
151{
153 d->interpolatorType = qMetaTypeId<QGeoCoordinate>();
154 d->defaultToInterpolatorType = true;
155 d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
156}
157
161
167{
169 return d->from.value<QGeoCoordinate>();
170}
171
173{
176 mercator->lat = f.latitude();
177 mercator->lng = f.longitude();
178 mercator->alt = f.altitude();
179 mercator->m_mercatorX = fromVector.x();
180 mercator->m_mercatorY = fromVector.y();
181 QGeoCoordinate from(*mercator);
183}
184
190{
192 return d->to.value<QGeoCoordinate>();
193}
194
196{
199 mercator->lat = t.latitude();
200 mercator->lng = t.longitude();
201 mercator->alt = t.altitude();
202 mercator->m_mercatorX = toVector.x();
203 mercator->m_mercatorY = toVector.y();
204 QGeoCoordinate to(*mercator);
206}
207
231
233{
235 d->m_direction.removeBindingUnlessInWrapper();
236 if (d->m_direction.valueBypassingBindings() == direction)
237 return;
238
239 d->m_direction.setValueBypassingBindings(direction);
240 switch (direction) {
241 case West:
242 d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateWestInterpolator));
243 break;
244 case East:
245 d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateEastInterpolator));
246 break;
247 case Shortest:
248 default:
249 d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateShortestInterpolator));
250 break;
251 }
252 d->m_direction.notify();
253}
254
255QBindable<QQuickGeoCoordinateAnimation::Direction> QQuickGeoCoordinateAnimation::bindableDirection()
256{
258 return QBindable<Direction>(&d->m_direction);
259}
260
262
263#include "moc_qquickgeocoordinateanimation_p.cpp"
Q_DECL_CONSTEXPR double x() const
Q_DECL_CONSTEXPR double y() const
static const QGeoCoordinatePrivate * get(const QGeoCoordinate *c)
\inmodule QtPositioning
double altitude
This property holds the altitude in meters above sea level.
\inmodule QtCore
Definition qobject.h:103
void setFrom(const QVariant &)
void setTo(const QVariant &)
static Q_CORE_EXPORT QVariantAnimation::Interpolator getInterpolator(int interpolationType)
QVariant(* Interpolator)(const void *from, const void *to, qreal progress)
\inmodule QtCore
Definition qvariant.h:65
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:536
constexpr float y() const noexcept
Returns the y coordinate of this point.
Definition qvectornd.h:671
constexpr float x() const noexcept
Returns the x coordinate of this point.
Definition qvectornd.h:670
static QDoubleVector2D coordToMercator(const QGeoCoordinate &coord)
static QGeoCoordinate coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
static QGeoCoordinate mercatorToCoord(const QDoubleVector2D &mercator)
direction
Combined button and popup list for selecting options.
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat f
GLint y
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
QVariant q_coordinateShortestInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
QVariant q_coordinateWestInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
QVariant q_coordinateEastInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
QT_BEGIN_NAMESPACE QVariant q_coordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
\qmltype CoordinateAnimation \inherits PropertyAnimation \inqmlmodule QtPositioning
double qreal
Definition qtypes.h:187