diff options
author | Liang Qi <liang.qi@qt.io> | 2017-10-26 12:22:00 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-10-26 12:22:38 +0200 |
commit | d340bf2be1738f3d47bc455ea122aef9a9e1c11d (patch) | |
tree | 34d060b00cf14924d50c6419e9678804d9f62e58 /src/location/maps/qgeoprojection.cpp | |
parent | 66a6e238876cc1201c5fe331c165ceba458dc56a (diff) | |
parent | 592c381564e3f12b79a3d5e9fec5aec2b8045742 (diff) | |
download | qtlocation-d340bf2be1738f3d47bc455ea122aef9a9e1c11d.tar.gz |
Merge remote-tracking branch 'origin/5.9' into 5.10v5.10.0-beta3
Conflicts:
.qmake.conf
Change-Id: I9a3d7ec0bb203ac8b5bd483af3973510ca33c4a9
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 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. |