7#include <QtGui/QMatrix4x4>
8#include <QtPositioning/QGeoPolygon>
9#include <QtPositioning/QGeoRectangle>
11#include <QtPositioning/private/qwebmercator_p.h>
12#include <QtPositioning/private/qlocationutils_p.h>
13#include <QtPositioning/private/qclipperutils_p.h>
18 static const double defaultTileSize = 256.0;
31 m(1,0),
m(1,1),
m(1,2),
m(1,3),
32 m(2,0),
m(2,1),
m(2,2),
m(2,3),
33 m(3,0),
m(3,1),
m(3,2),
m(3,3));
46 QPointF diff = screenCenter - vaCenter;
54 qreal xdiffpct = diff.
x() / qMax<double>(screenSize.
width() - 1, 1);
55 qreal ydiffpct = diff.
y() / qMax<double>(screenSize.
height() - 1, 1);
57 return QPointF(-xdiffpct, -ydiffpct);
129 camera.setBearing(bearing);
144 m_cameraCenterXMercator(0),
145 m_cameraCenterYMercator(0),
148 m_1_viewportWidth(0),
149 m_1_viewportHeight(0),
150 m_sideLengthPixels(256),
156 m_minimumUnprojectableY(0.0),
157 m_verticalEstateToSkip(0.0),
158 m_visibleRegionDirty(
false)
215 double mercatorTopmost = (clampedWindowHeight * (0.5 - hpct)) / mapEdgeSize ;
230 double mercatorTopmost = (clampedWindowHeight * (0.5 + hpct)) / mapEdgeSize ;
286 const double &
x = projection.
x();
305 double x = wrappedProjection.
x();
310 return wrappedProjection;
349 if (clipToViewport) {
353 if ((
pos.x() < 0) || (
w <
pos.x()) || (
pos.y() < 0) || (
h <
pos.y()))
375 if (clipToViewport) {
406 matTranslateScale.
translate(coordAnchoredScaled.
x(), coordAnchoredScaled.
y(), 0.0);
408 scale = std::pow(0.5, (zoomLevel - std::floor(zoomLevel)) +
522 if (bottomRightPoint.
x() < topLeftPoint.
x())
523 bottomRightPoint.
setX(bottomRightPoint.
x() + 1.0);
527 center.setX(center.x() > 1.0 ? center.x() - 1.0 : center.x());
531 double bboxWidth = (bottomRightPoint.
x() - topLeftPoint.
x()) *
mapWidth();
532 double bboxHeight = (bottomRightPoint.
y() - topLeftPoint.
y()) *
mapHeight();
534 if (bboxHeight == 0.0 && bboxWidth == 0.0)
539 zoomRatio = std::log(zoomRatio) / std::log(2.0);
560void QGeoProjectionWebMercator::setupCamera()
575 double altitude =
f / (2.0 *
z);
578 double altitude_mercator =
f / (2.0 * z_mercator);
590 eye0.setZ(altitude * defaultTileSize /
m_aperture);
642 m_farPlane = (altitude + 2097152.0) * defaultTileSize;
695 const double elevationUpperBound = 90.0 - upperBoundEpsilon;
696 const double maxRayElevation =
qMin(elevationUpperBound -
m_cameraData.
tilt(), verticalHalfFOV);
697 double maxHalfAperture = 0;
699 if (maxRayElevation < verticalHalfFOV) {
708void QGeoProjectionWebMercator::updateVisibleRegion()
716 double bottom = viewportHalfHeight;
717 double left = -viewportHalfWidth;
718 double right = viewportHalfWidth;
764 Line2D nearPlaneXYIntersection = nearPlane.planeXYIntersection();
765 double squareHalfSide =
qMax(5.0, nearPlaneXYIntersection.m_point.length());
770 - squareHalfSide * nearPlaneXYIntersection.m_direction
771 + 2 * squareHalfSide * viewDirectionProjected;
773 + squareHalfSide * nearPlaneXYIntersection.m_direction
774 + 2 * squareHalfSide * viewDirectionProjected;
776 - squareHalfSide * nearPlaneXYIntersection.m_direction;
778 + squareHalfSide * nearPlaneXYIntersection.m_direction;
793 if (resProjectable.size())
830 : m_point(linePoint), m_direction(lineDirection.
normalized())
837 return (m_direction.length() > 0.5);
852 : m_point(planePoint), m_normal(planeNormal.
normalized()) { }
857 return lineIntersection(linePoint, lineDirection,
s);
865 return linePoint + lineDirection *
s;
872 lineDirection.
setZ(0.0);
884 return (m_normal.length() > 0.5);
void addClipPolygon(const QList< QDoubleVector2D > &path)
void addSubjectPath(const QList< QDoubleVector2D > &path, bool closed)
QList< QList< QDoubleVector2D > > execute(Operation op, PolyFillType subjFillType=pftNonZero, PolyFillType clipFillType=pftNonZero)
void translate(const QDoubleVector3D &vector)
void frustum(double left, double right, double bottom, double top, double nearPlane, double farPlane)
void scale(const QDoubleVector3D &vector)
void lookAt(const QDoubleVector3D &eye, const QDoubleVector3D ¢er, const QDoubleVector3D &up)
void rotate(double angle, const QDoubleVector3D &vector)
Q_DECL_CONSTEXPR QPointF toPointF() const
QDoubleVector2D normalized() const
QDoubleVector3D toVector3D() const
Q_DECL_CONSTEXPR double x() const
Q_DECL_CONSTEXPR double y() const
static Q_DECL_CONSTEXPR double dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
Q_DECL_CONSTEXPR double x() const
Q_DECL_CONSTEXPR double y() const
Q_DECL_CONSTEXPR QDoubleVector2D toVector2D() const
static QDoubleVector3D normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
QDoubleVector3D normalized() const
static Q_DECL_CONSTEXPR QDoubleVector3D crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
double fieldOfView() const
QGeoCoordinate center() const
double longitude
This property holds the longitude in decimal degrees.
double latitude
This property holds the latitude in decimal degrees.
bool isValid
This property holds the validity of this geo coordinate.
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate)
Appends coordinate to the polygon.
void setViewportSize(const QSize &size) override
QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport=true) const override
QDoubleVector3D m_viewMercator
QList< QDoubleVector2D > m_visibleRegionExpanded
QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport=true) const override
double m_cameraCenterYMercator
QGeoCameraData m_cameraData
QDoubleVector3D centerMercator() const override
QMatrix4x4 projectionTransformation_centered() const override
QDoubleVector3D m_centerNearPlane
QList< QDoubleVector2D > m_visibleRegion
double m_1_viewportHeight
QMatrix4x4 projectionTransformation() const override
double m_minimumUnprojectableY
QDoubleVector3D m_eyeMercator0
QDoubleVector3D m_sideMercator
double m_verticalEstateToSkip
QMatrix4x4 m_qsgTransform
QGeoCoordinate mapProjectionToGeo(const QDoubleVector2D &projection) const
QDoubleVector2D viewportToWrappedMapProjection(const QDoubleVector2D &itemPosition) const
bool m_visibleRegionDirty
QGeoProjection::ProjectionGroup projectionGroup() const override
QDoubleMatrix4x4 m_transformation0
QGeoProjection::ProjectionType projectionType() const override
QDoubleVector3D m_centerNearPlaneMercator
QDoubleVector2D geoToWrappedMapProjection(const QGeoCoordinate &coordinate) const
QList< QDoubleVector2D > visibleGeometryExpanded() const
QGeoProjectionWebMercator()
~QGeoProjectionWebMercator()
QDoubleVector2D unwrapMapProjection(const QDoubleVector2D &wrappedProjection) const
QPair< QGeoCoordinate, qreal > fitViewportToGeoRectangle(const QGeoRectangle &rectangle, const QMargins &margins) const
QDoubleVector3D m_upMercator
QDoubleVector2D wrapMapProjection(const QDoubleVector2D &projection) const
QDoubleMatrix4x4 m_transformation
QDoubleMatrix4x4 m_cameraMatrix
const QMatrix4x4 & qsgTransform() const override
QGeoCoordinate wrappedMapProjectionToGeo(const QDoubleVector2D &wrappedProjection) const
QDoubleMatrix4x4 m_cameraMatrix0
double minimumZoom() const override
void setVisibleArea(const QRectF &visibleArea) override
bool setBearing(qreal bearing, const QGeoCoordinate &coordinate) override
QDoubleVector3D m_centerMercator
double m_nearPlaneMercator
QGeoProjection::Datum datum() const override
double maximumCenterLatitudeAtZoom(const QGeoCameraData &cameraData) const override
double m_cameraCenterXMercator
QGeoCameraData cameraData() const override
void setCameraData(const QGeoCameraData &cameraData, bool force=true) override
QList< QDoubleVector2D > visibleGeometry() const
QDoubleVector2D itemPositionToWrappedMapProjection(const QDoubleVector2D &itemPosition) const
QList< QDoubleVector2D > projectableGeometry() const
QList< QDoubleVector2D > m_projectableRegion
int projectionWrapFactor(const QDoubleVector2D &projection) const
QDoubleMatrix4x4 m_quickItemTransformation
QDoubleVector2D geoToMapProjection(const QGeoCoordinate &coordinate) const
bool isProjectable(const QDoubleVector2D &wrappedProjection) const
double minimumCenterLatitudeAtZoom(const QGeoCameraData &cameraData) const override
double m_sideLengthPixels
QDoubleVector2D wrappedMapProjectionToItemPosition(const QDoubleVector2D &wrappedProjection) const
QGeoShape visibleRegion() const override
QDoubleVector3D m_viewNormalized
QGeoCoordinate anchorCoordinateToPoint(const QGeoCoordinate &coordinate, const QPointF &anchorPoint) const override
QDoubleVector3D m_eyeMercator
QMatrix4x4 quickItemTransformation(const QGeoCoordinate &coordinate, const QPointF &anchorPoint, qreal zoomLevel) const
virtual QTransform itemToWindowTransform() const
virtual QGeoShape visibleRegion() const
QTransform m_itemToWindowTransform
virtual bool setBearing(qreal bearing, const QGeoCoordinate &coordinate)
void setItemToWindowTransform(const QTransform &itemToWindowTransform)
virtual ~QGeoProjection()
virtual QGeoCoordinate anchorCoordinateToPoint(const QGeoCoordinate &coordinate, const QPointF &anchorPoint) const
QGeoCoordinate topLeft
This property holds the top left coordinate of this geo rectangle.
QGeoCoordinate bottomRight
This property holds the bottom right coordinate of this geo rectangle.
qsizetype size() const noexcept
void push_back(parameter_type t)
static double radians(double degrees)
static double mapRightLongitude(double centerLongitude)
static double degrees(double radians)
static double mapLeftLongitude(double centerLongitude)
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
static QDoubleVector2D coordToMercator(const QGeoCoordinate &coord)
static QGeoCoordinate mercatorToCoord(const QDoubleVector2D &mercator)
Combined button and popup list for selecting options.
std::pair< T1, T2 > QPair
bool qIsNaN(qfloat16 f) noexcept
static QPointF centerOffset(const QSizeF &screenSize, const QRectF &visibleArea)
static QPointF marginsOffset(const QSizeF &screenSize, const QRectF &visibleArea)
static QMatrix4x4 toMatrix4x4(const QDoubleMatrix4x4 &m)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qQNaN()
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLfloat GLfloat GLfloat GLfloat h
GLint GLenum GLboolean normalized
GLenum GLenum GLenum GLenum GLenum scale
static qreal dot(const QPointF &a, const QPointF &b)
Line2D planeXYIntersection() const
QDoubleVector3D lineIntersection(const QDoubleVector3D &linePoint, const QDoubleVector3D &lineDirection) const