summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeoprojection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/maps/qgeoprojection.cpp')
-rw-r--r--src/location/maps/qgeoprojection.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp
index 218d806b..1df174fb 100644
--- a/src/location/maps/qgeoprojection.cpp
+++ b/src/location/maps/qgeoprojection.cpp
@@ -236,6 +236,9 @@ QDoubleVector2D QGeoProjectionWebMercator::itemPositionToWrappedMapProjection(co
/* Default implementations */
QGeoCoordinate QGeoProjectionWebMercator::itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
{
+ if (qIsNaN(pos.x()) || qIsNaN(pos.y()))
+ return QGeoCoordinate();
+
if (clipToViewport) {
int w = m_viewportWidth;
int h = m_viewportHeight;
@@ -253,7 +256,14 @@ QGeoCoordinate QGeoProjectionWebMercator::itemPositionToCoordinate(const QDouble
QDoubleVector2D QGeoProjectionWebMercator::coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
{
- QDoubleVector2D pos = wrappedMapProjectionToItemPosition(wrapMapProjection(geoToMapProjection(coordinate)));
+ if (!coordinate.isValid())
+ return QDoubleVector2D(qQNaN(), qQNaN());
+
+ QDoubleVector2D wrappedProjection = wrapMapProjection(geoToMapProjection(coordinate));
+ if (!isProjectable(wrappedProjection))
+ return QDoubleVector2D(qQNaN(), qQNaN());
+
+ QDoubleVector2D pos = wrappedMapProjectionToItemPosition(wrappedProjection);
if (clipToViewport) {
int w = m_viewportWidth;
@@ -350,10 +360,10 @@ QDoubleVector2D QGeoProjectionWebMercator::viewportToWrappedMapProjection(const
pos *= QDoubleVector2D(m_halfWidth, m_halfHeight);
QDoubleVector3D p = m_centerNearPlane;
- p -= m_up * pos.y();
- p -= m_side * pos.x();
+ p += m_up * pos.y();
+ p += m_side * pos.x();
- QDoubleVector3D ray = p - m_eye;
+ QDoubleVector3D ray = m_eye - p;
ray.normalize();
return (xyPlane.lineIntersection(m_eye, ray, s) / m_sideLength).toVector2D();
@@ -472,7 +482,7 @@ void QGeoProjectionWebMercator::setupCamera()
m_quickItemTransformation = m_transformation;
m_transformation.scale(m_sideLength, m_sideLength, 1.0);
- m_centerNearPlane = m_eye + m_viewNormalized;
+ m_centerNearPlane = m_eye - m_viewNormalized;
m_centerNearPlaneMercator = m_eyeMercator - m_viewNormalized * m_nearPlaneMercator;
// The method does not support tilting angles >= 90.0 or < 0.