diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-09-25 18:55:20 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-09-25 18:55:20 +0200 |
commit | d919f47308b209c798e50d8ca1b9abd48ba94718 (patch) | |
tree | c62566331b35659e46439cb2531f70e5ccc43739 /src/location/maps/qgeoprojection.cpp | |
parent | b6f174ebfdc32110dab495217481481dbff5670d (diff) | |
parent | 6ba14c6d2a6b7eb325cd975393306c4fe6809acd (diff) | |
download | qtlocation-d919f47308b209c798e50d8ca1b9abd48ba94718.tar.gz |
Change-Id: I69598f5f4c5c7c8fec58c6ff41f353fe4e042762
Diffstat (limited to 'src/location/maps/qgeoprojection.cpp')
-rw-r--r-- | src/location/maps/qgeoprojection.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp index 013a8c33..fcf9a350 100644 --- a/src/location/maps/qgeoprojection.cpp +++ b/src/location/maps/qgeoprojection.cpp @@ -225,6 +225,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; @@ -242,7 +245,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; @@ -339,10 +349,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(); @@ -461,7 +471,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. |