1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2020 Paolo Angelelli <paolo.angelelli@gmail.com> 4 ** Copyright (C) 2020 The Qt Company Ltd. 5 ** Contact: http://www.qt.io/licensing/ 6 ** 7 ** This file is part of the QtLocation module of the Qt Toolkit. 8 ** 9 ** $QT_BEGIN_LICENSE:LGPL3$ 10 ** Commercial License Usage 11 ** Licensees holding valid commercial Qt licenses may use this file in 12 ** accordance with the commercial license agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and The Qt Company. For licensing terms 15 ** and conditions see http://www.qt.io/terms-conditions. For further 16 ** information use the contact form at http://www.qt.io/contact-us. 17 ** 18 ** GNU Lesser General Public License Usage 19 ** Alternatively, this file may be used under the terms of the GNU Lesser 20 ** General Public License version 3 as published by the Free Software 21 ** Foundation and appearing in the file LICENSE.LGPLv3 included in the 22 ** packaging of this file. Please review the following information to 23 ** ensure the GNU Lesser General Public License version 3 requirements 24 ** will be met: https://www.gnu.org/licenses/lgpl.html. 25 ** 26 ** GNU General Public License Usage 27 ** Alternatively, this file may be used under the terms of the GNU 28 ** General Public License version 2.0 or later as published by the Free 29 ** Software Foundation and appearing in the file LICENSE.GPL included in 30 ** the packaging of this file. Please review the following information to 31 ** ensure the GNU General Public License version 2.0 requirements will be 32 ** met: http://www.gnu.org/licenses/gpl-2.0.html. 33 ** 34 ** $QT_END_LICENSE$ 35 ** 36 ****************************************************************************/ 37 38 #ifndef QDECLARATIVEGEOMAPITEMUTILS_P_H 39 #define QDECLARATIVEGEOMAPITEMUTILS_P_H 40 41 // 42 // W A R N I N G 43 // ------------- 44 // 45 // This file is not part of the Qt API. It exists purely as an 46 // implementation detail. This header file may change from version to 47 // version without notice, or even be removed. 48 // 49 // We mean it. 50 // 51 52 #include <QtLocation/private/qlocationglobal_p.h> 53 #include <QtLocation/private/qgeoprojection_p.h> 54 #include <QtPositioning/private/qdoublevector2d_p.h> 55 56 57 QT_BEGIN_NAMESPACE 58 59 class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMapItemUtils 60 { 61 public: 62 struct vec2 { 63 float x; 64 float y; vec2vec265 vec2(const QDoubleVector2D &p) 66 { 67 x = float(p.x()); 68 y = float(p.y()); 69 } 70 vec2() = default; 71 vec2 &operator=(const QPointF &p) 72 { 73 x = float(p.x()); 74 y = float(p.y()); 75 return *this; 76 } 77 vec2 &operator=(const QDoubleVector2D &p) 78 { 79 x = float(p.x()); 80 y = float(p.y()); 81 return *this; 82 } toDoubleVector2Dvec283 QDoubleVector2D toDoubleVector2D() const 84 { 85 return QDoubleVector2D(double(x), double(y)); 86 } 87 }; 88 89 static void wrapPath(const QList<QGeoCoordinate> &perimeter 90 ,const QGeoCoordinate &geoLeftBound 91 ,const QGeoProjectionWebMercator &p 92 ,QList<QDoubleVector2D> &wrappedPath 93 ,QList<QDoubleVector2D> &wrappedPathMinus1 94 ,QList<QDoubleVector2D> &wrappedPathPlus1 95 ,QDoubleVector2D *leftBoundWrapped = nullptr); 96 97 static void wrapPath(const QList<QGeoCoordinate> &perimeter 98 ,const QGeoCoordinate &geoLeftBound 99 ,const QGeoProjectionWebMercator &p 100 ,QList<QDoubleVector2D> &wrappedPath 101 ,QDoubleVector2D *leftBoundWrapped = nullptr); 102 103 static void wrapPath(const QList<QDoubleVector2D> &path 104 , const QDoubleVector2D &geoLeftBound 105 , QList<QDoubleVector2D> &wrappedPath); 106 107 108 static void clipPolygon(const QList<QDoubleVector2D> &wrappedPath 109 ,const QGeoProjectionWebMercator &p 110 ,QList<QList<QDoubleVector2D> > &clippedPaths 111 ,QDoubleVector2D *leftBoundWrapped = nullptr 112 ,const bool closed = true); 113 114 static void projectBbox(const QList<QDoubleVector2D> &clippedBbox 115 ,const QGeoProjectionWebMercator &p 116 ,QPainterPath &projectedBbox); 117 118 }; 119 120 QT_END_NAMESPACE 121 122 #endif // QDECLARATIVEGEOMAPITEMUTILS_P_H 123