10#include <QPainterPathStroker>
11#include <QtPositioning/QGeoCoordinate>
13#include <QtPositioning/private/qclipperutils_p.h>
26 const double t_x = p2_x - p1_x;
27 const double t_y = p2_y - p1_y;
28 const double p_x = p0_x - p1_x;
29 const double p_y = p0_y - p1_y;
30 const double tsqr = t_x * t_x + t_y * t_y;
35 double alpha = (p_x * t_x + p_y * t_y) / tsqr;
38 const double dx = p_x - t_x *
alpha;
39 const double dy = p_y - t_y *
alpha;
41 return dx * dx + dy * dy;
44void wrapPath(
const QList<QGeoCoordinate> &perimeter,
47 QList<QDoubleVector2D> &wrappedPath,
48 QList<QDoubleVector2D> &wrappedPathMinus1,
49 QList<QDoubleVector2D> &wrappedPathPlus1,
52 QList<QDoubleVector2D>
path;
54 path <<
p.geoToMapProjection(
c);
57 wrappedPathPlus1.clear();
58 wrappedPathMinus1.clear();
66 const bool isPointLessThanUnwrapBelowX = (
coord.x() < leftBound.x());
68 if (isPointLessThanUnwrapBelowX)
74 wrappedPath.append(
coord);
75 wrappedPathPlus1.append(coordP1);
76 wrappedPathMinus1.append(coordM1);
79 *leftBoundWrapped = leftBound;
82void wrapPath(
const QList<QGeoCoordinate> &perimeter,
85 QList<QDoubleVector2D> &wrappedPath,
88 QList<QDoubleVector2D>
path;
90 path <<
p.geoToMapProjection(
c);
94 *leftBoundWrapped = leftBound;
99 QList<QDoubleVector2D> &wrappedPath)
109 const bool isPointLessThanUnwrapBelowX = (
coord.x() < geoLeftBound.
x());
111 if (isPointLessThanUnwrapBelowX)
114 wrappedPath.append(
coord);
120 QList<QList<QDoubleVector2D>> &clippedPaths,
125 clippedPaths.clear();
126 const QList<QDoubleVector2D> &visibleRegion =
p.projectableGeometry();
127 if (visibleRegion.size()) {
130 clipper.addClipPolygon(visibleRegion);
134 if (leftBoundWrapped) {
137 for (
const QList<QDoubleVector2D> &
path : clippedPaths) {
139 if (
p.x() < lb.x() || (
p.x() == lb.x() &&
p.y() < lb.y()))
150 lb.setX(
qMax(leftBoundWrapped->x(), lb.x()));
152 *leftBoundWrapped = lb;
156 clippedPaths.append(wrappedPath);
164 projectedBbox.clear();
166 for (
const auto &
coord : clippedBbox) {
170 projectedBbox.moveTo(point.
toPointF());
172 projectedBbox.lineTo(point.
toPointF());
175 projectedBbox.closeSubpath();
181 double xMin =
qInf();
182 double xMax = -
qInf();
183 double yMin =
qInf();
184 double yMax = -
qInf();
191 return QRectF(xMin, yMin, xMax - xMin, yMax - yMin);
197 QList<QGeoCoordinate>
path;
202 path.append(cornerPoints.at(
i));
203 const double p_lat = cornerPoints.at(
i).latitude() / 180.0 *
M_PI;
204 const double p_lon = cornerPoints.at(
i).longitude() / 180.0 *
M_PI;
205 const double q_lat = cornerPoints.at((
i + 1) % cornerPoints.size()).latitude() / 180.0 *
M_PI;
206 const double q_lon = cornerPoints.at((
i + 1) % cornerPoints.size()).longitude() / 180.0 *
M_PI;
208 const double c_p_lat = cos(p_lat);
209 const double c_p_lon = cos(p_lon);
210 const double s_p_lat = sin(p_lat);
211 const double s_p_lon = sin(p_lon);
212 const double c_q_lat = cos(q_lat);
213 const double c_q_lon = cos(q_lon);
214 const double s_q_lat = sin(q_lat);
215 const double s_q_lon = sin(q_lon);
225 if (qp <= -1.0 || qp >= 1.0)
236 const double paramMax = sqrt(1 / (1 - qp * qp));
240 for (; t <= paramMax && t >= 0.0;
t +=
sign * paramMax / N / 2) {
243 const double s = -
t * qp +
sign * sqrt(
t *
t * (qp * qp - 1.0) + 1.0);
246 const double lat = asin(
s * s_p_lat +
t * s_q_lat);
247 const double lon = atan2(
s * c_p_lat * s_p_lon +
t * c_q_lat * s_q_lon,
248 s * c_p_lat * c_p_lon +
t * c_q_lat * c_q_lon);
251 t -= paramMax / N / 2;
255 path.append(cornerPoints.last());
void addSubjectPath(const QList< QDoubleVector2D > &path, bool closed)
Q_DECL_CONSTEXPR QPointF toPointF() const
Q_DECL_CONSTEXPR double x() const
static Q_DECL_CONSTEXPR double dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
\inmodule QtCore\reentrant
void wrapPath(const QList< QGeoCoordinate > &perimeter, const QGeoCoordinate &geoLeftBound, const QGeoProjectionWebMercator &p, QList< QDoubleVector2D > &wrappedPath, QList< QDoubleVector2D > &wrappedPathMinus1, QList< QDoubleVector2D > &wrappedPathPlus1, QDoubleVector2D *leftBoundWrapped)
QList< QGeoCoordinate > greaterCirclePath(const QList< QGeoCoordinate > &cornerPoints, greaterCirclePathForm form, int N)
QRectF boundingRectangleFromList(const QList< QDoubleVector2D > &list)
void clipPolygon(const QList< QDoubleVector2D > &wrappedPath, const QGeoProjectionWebMercator &p, QList< QList< QDoubleVector2D > > &clippedPaths, QDoubleVector2D *leftBoundWrapped, bool closed)
double distanceSqrPointLine(double p0_x, double p0_y, double p1_x, double p1_y, double p2_x, double p2_y)
void projectBbox(const QList< QDoubleVector2D > &clippedBbox, const QGeoProjectionWebMercator &p, QPainterPath &projectedBbox)
Combined button and popup list for selecting options.
bool qIsFinite(qfloat16 f) noexcept
bool qIsInf(qfloat16 f) noexcept
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qInf()
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLfloat GLfloat GLfloat alpha