summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-10-25 12:47:39 +0200
committerIvan Solovev <ivan.solovev@qt.io>2021-10-27 11:24:58 +0200
commite7bc51e4c5c07389c1d028e7a42c238688ca43ee (patch)
treec3f861e22b32f90e017b168a1b2a3ac0fccf17f1
parent23f32792ad53e23bbafbff6d7667f0bb0f69fc53 (diff)
downloadqtlocation-e7bc51e4c5c07389c1d028e7a42c238688ca43ee.tar.gz
QtLocation: adapt to build with external QtPositioning
This includes fixing some includes to use the full path to QtPositioing/private/header_name_p.h and also fixes related to the reworked clipper wrapper. Task-number: QTBUG-97084 Change-Id: I15ce8d739beb2f190df9f5af01a7cb1642a6b2a2 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativecirclemapitem.cpp31
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemutils.cpp10
-rw-r--r--src/location/declarativemaps/qdeclarativepolygonmapitem.cpp13
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp27
-rw-r--r--src/location/declarativemaps/qdeclarativerectanglemapitem.cpp2
-rw-r--r--src/location/declarativemaps/qgeomapitemgeometry.cpp4
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea.cpp4
-rw-r--r--src/location/location.pro7
-rw-r--r--src/location/maps/qgeoprojection.cpp30
9 files changed, 50 insertions, 78 deletions
diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
index 955de2c0..156fd376 100644
--- a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp
@@ -37,7 +37,7 @@
#include "qdeclarativecirclemapitem_p.h"
#include "qdeclarativepolygonmapitem_p.h"
-#include "qwebmercator_p.h"
+#include <QtPositioning/private/qwebmercator_p.h>
#include <QtLocation/private/qgeomap_p.h>
#include <qmath.h>
@@ -48,13 +48,9 @@
#include <QPainter>
#include <QtGui/private/qtriangulator_p.h>
-#include "qdoublevector2d_p.h"
-#include "qlocationutils_p.h"
-#include "qgeocircle.h"
-
-/* poly2tri triangulator includes */
-#include <common/shapes.h>
-#include <sweep/cdt.h>
+#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtPositioning/private/qlocationutils_p.h>
+#include <qgeocircle.h>
#include <QtPositioning/private/qclipperutils_p.h>
#include "qdeclarativecirclemapitem_p_p.h"
@@ -189,10 +185,11 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QDoubleVector2D
for (const QDoubleVector2D &c: circlePath)
hole << p.wrapMapProjection(c);
- c2t::clip2tri clipper;
- clipper.addSubjectPath(QClipperUtils::qListToPath(fill), true);
- clipper.addClipPolygon(QClipperUtils::qListToPath(hole));
- Paths difference = clipper.execute(c2t::clip2tri::Difference, QtClipperLib::pftEvenOdd, QtClipperLib::pftEvenOdd);
+ QClipperUtils clipper;
+ clipper.addSubjectPath(fill, true);
+ clipper.addClipPolygon(hole);
+ auto difference = clipper.execute(QClipperUtils::Difference, QClipperUtils::pftEvenOdd,
+ QClipperUtils::pftEvenOdd);
// 2)
QDoubleVector2D lb = p.geoToWrappedMapProjection(srcOrigin_);
@@ -200,11 +197,11 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QDoubleVector2D
const QList<QDoubleVector2D> &visibleRegion = p.visibleGeometry();
if (visibleRegion.size()) {
clipper.clearClipper();
- for (const Path &p: difference)
+ for (const auto &p: difference)
clipper.addSubjectPath(p, true);
- clipper.addClipPolygon(QClipperUtils::qListToPath(visibleRegion));
- Paths res = clipper.execute(c2t::clip2tri::Intersection, QtClipperLib::pftEvenOdd, QtClipperLib::pftEvenOdd);
- clippedPaths = QClipperUtils::pathsToQList(res);
+ clipper.addClipPolygon(visibleRegion);
+ clippedPaths = clipper.execute(QClipperUtils::Intersection, QClipperUtils::pftEvenOdd,
+ QClipperUtils::pftEvenOdd);
// 2.1) update srcOrigin_ with the point with minimum X/Y
lb = QDoubleVector2D(qInf(), qInf());
@@ -223,7 +220,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QList<QDoubleVector2D
lb.setX(qMax(tl.x(), lb.x()));
srcOrigin_ = p.mapProjectionToGeo(p.unwrapMapProjection(lb));
} else {
- clippedPaths = QClipperUtils::pathsToQList(difference);
+ clippedPaths = difference;
}
//3)
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemutils.cpp b/src/location/declarativemaps/qdeclarativegeomapitemutils.cpp
index e2774559..e9fed2ec 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemutils.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitemutils.cpp
@@ -134,11 +134,11 @@ void QDeclarativeGeoMapItemUtils::clipPolygon(const QList<QDoubleVector2D> &wrap
clippedPaths.clear();
const QList<QDoubleVector2D> &visibleRegion = p.projectableGeometry();
if (visibleRegion.size()) {
- c2t::clip2tri clipper;
- clipper.addSubjectPath(QClipperUtils::qListToPath(wrappedPath), closed);
- clipper.addClipPolygon(QClipperUtils::qListToPath(visibleRegion));
- Paths res = clipper.execute(c2t::clip2tri::Intersection, QtClipperLib::pftEvenOdd, QtClipperLib::pftEvenOdd);
- clippedPaths = QClipperUtils::pathsToQList(res);
+ QClipperUtils clipper;
+ clipper.addSubjectPath(wrappedPath, closed);
+ clipper.addClipPolygon(visibleRegion);
+ clippedPaths = clipper.execute(QClipperUtils::Intersection, QClipperUtils::pftEvenOdd,
+ QClipperUtils::pftEvenOdd);
if (leftBoundWrapped) {
// 2.1) update srcOrigin_ and leftBoundWrapped with the point with minimum X
diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
index 4275d696..8917dedb 100644
--- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp
@@ -39,7 +39,7 @@
#include "qdeclarativepolylinemapitem_p_p.h"
#include "qdeclarativepolygonmapitem_p_p.h"
#include "qdeclarativerectanglemapitem_p_p.h"
-#include "qlocationutils_p.h"
+#include <QtPositioning/private/qlocationutils_p.h>
#include "error_messages_p.h"
#include "locationvaluetypehelper_p.h"
#include <QtLocation/private/qgeomap_p.h>
@@ -61,7 +61,6 @@
#include <QtQuick/qsgnode.h>
/* poly2tri triangulator includes */
-#include <clip2tri.h>
#include <earcut.hpp>
#include <array>
@@ -209,11 +208,11 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
QList<QList<QDoubleVector2D> > clippedPaths;
const QList<QDoubleVector2D> &visibleRegion = p.projectableGeometry();
if (visibleRegion.size()) {
- c2t::clip2tri clipper;
- clipper.addSubjectPath(QClipperUtils::qListToPath(wrappedPath), true);
- clipper.addClipPolygon(QClipperUtils::qListToPath(visibleRegion));
- Paths res = clipper.execute(c2t::clip2tri::Intersection, QtClipperLib::pftEvenOdd, QtClipperLib::pftEvenOdd);
- clippedPaths = QClipperUtils::pathsToQList(res);
+ QClipperUtils clipper;
+ clipper.addSubjectPath(wrappedPath, true);
+ clipper.addClipPolygon(visibleRegion);
+ clippedPaths = clipper.execute(QClipperUtils::Intersection, QClipperUtils::pftEvenOdd,
+ QClipperUtils::pftEvenOdd);
// 2.1) update srcOrigin_ and leftBoundWrapped with the point with minimum X
QDoubleVector2D lb(qInf(), qInf());
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
index 9d5472ab..88ebef25 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp
@@ -38,11 +38,11 @@
#include "qdeclarativepolylinemapitem_p_p.h"
#include "qdeclarativerectanglemapitem_p_p.h"
#include "qdeclarativecirclemapitem_p_p.h"
-#include "qlocationutils_p.h"
+#include <QtPositioning/private/qlocationutils_p.h>
#include "qdeclarativegeomapitemutils_p.h"
#include "error_messages_p.h"
#include "locationvaluetypehelper_p.h"
-#include "qdoublevector2d_p.h"
+#include <QtPositioning/private/qdoublevector2d_p.h>
#include <QtLocation/private/qgeomap_p.h>
#include <QtPositioning/private/qwebmercator_p.h>
@@ -87,18 +87,6 @@ struct ThreadPool // to have a thread pool with max 1 thread for geometry proces
Q_GLOBAL_STATIC(ThreadPool, threadPool)
-static const double kClipperScaleFactor = 281474976710656.0; // 48 bits of precision
-
-static inline IntPoint toIntPoint(const double x, const double y)
-{
- return IntPoint(cInt(x * kClipperScaleFactor), cInt(y * kClipperScaleFactor));
-}
-
-static IntPoint toIntPoint(const QDoubleVector2D &p)
-{
- return toIntPoint(p.x(), p.y());
-}
-
static bool get_line_intersection(const double p0_x,
const double p0_y,
const double p1_x,
@@ -161,13 +149,6 @@ static QList<QList<QDoubleVector2D> > clipLine(
edges.push_back({ { poly.at(i-1).x(), poly.at(i-1).y(), poly.at(i).x(), poly.at(i).y() } });
edges.push_back({ { poly.at(poly.size()-1).x(), poly.at(poly.size()-1).y(), poly.at(0).x(), poly.at(0).y() } });
- // Build Path to check for containment, for edges not intersecting
- // This step could be speeded up by forcing the orientation of the polygon, and testing the cross products in the step
- // below, thus avoiding to resort to clipper.
- Path clip;
- for (const auto &v: poly)
- clip.push_back(toIntPoint(v));
-
// Step 2: check each segment against each edge
QList<QDoubleVector2D> subLine;
std::array<double, 4> intersections = { { 0.0, 0.0, 0.0, 0.0 } };
@@ -178,8 +159,8 @@ static QList<QList<QDoubleVector2D> > clipLine(
double previousT = t;
double i_x, i_y;
- const int firstContained = c2t::clip2tri::pointInPolygon(toIntPoint(l.at(i).x(), l.at(i).y()), clip);
- const int secondContained = c2t::clip2tri::pointInPolygon(toIntPoint(l.at(i+1).x(), l.at(i+1).y()), clip);
+ const int firstContained = QClipperUtils::pointInPolygon(l.at(i), poly);
+ const int secondContained = QClipperUtils::pointInPolygon(l.at(i+1), poly);
if (firstContained && secondContained) { // Second most common condition, test early and skip inner loop if possible
if (!subLine.size())
diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
index 6192be08..3028d4cc 100644
--- a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
+++ b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp
@@ -37,7 +37,7 @@
#include "qdeclarativerectanglemapitem_p.h"
#include "qdeclarativerectanglemapitem_p_p.h"
#include "qdeclarativepolygonmapitem_p.h"
-#include "qlocationutils_p.h"
+#include <QtPositioning/private/qlocationutils_p.h>
#include <QPainterPath>
#include <qnumeric.h>
#include <QRectF>
diff --git a/src/location/declarativemaps/qgeomapitemgeometry.cpp b/src/location/declarativemaps/qgeomapitemgeometry.cpp
index f7feec5c..69d52358 100644
--- a/src/location/declarativemaps/qgeomapitemgeometry.cpp
+++ b/src/location/declarativemaps/qgeomapitemgeometry.cpp
@@ -36,9 +36,9 @@
#include "qgeomapitemgeometry_p.h"
#include "qdeclarativegeomap_p.h"
-#include "qlocationutils_p.h"
+#include <QtPositioning/private/qlocationutils_p.h>
#include <QtQuick/QSGGeometry>
-#include "qdoublevector2d_p.h"
+#include <QtPositioning/private/qdoublevector2d_p.h>
#include <QtLocation/private/qgeomap_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
index 158bf588..44f67469 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp
+++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
@@ -52,8 +52,8 @@
#include "math.h"
#include <cmath>
#include "qgeomap_p.h"
-#include "qdoublevector2d_p.h"
-#include "qlocationutils_p.h"
+#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtPositioning/private/qlocationutils_p.h>
#include <QtGui/QMatrix4x4>
diff --git a/src/location/location.pro b/src/location/location.pro
index ae202718..d32cec53 100644
--- a/src/location/location.pro
+++ b/src/location/location.pro
@@ -12,11 +12,6 @@ QT_FOR_CONFIG += location-private
msvc: CONFIG -= warning_clean
INCLUDEPATH += ../3rdparty/earcut
-INCLUDEPATH += ../3rdparty/poly2tri
-INCLUDEPATH += ../3rdparty/clipper
-INCLUDEPATH += ../3rdparty/clip2tri
-INCLUDEPATH += ../positioning
-INCLUDEPATH += ../imports/positioning
INCLUDEPATH *= $$PWD
MODULE_PLUGIN_TYPES = \
@@ -52,4 +47,4 @@ HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
load(qt_module)
-LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lqt_clip2tri$$qtPlatformTargetSuffix()
+LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp
index ff6a0b77..60b64790 100644
--- a/src/location/maps/qgeoprojection.cpp
+++ b/src/location/maps/qgeoprojection.cpp
@@ -770,15 +770,15 @@ void QGeoProjectionWebMercator::updateVisibleRegion()
viewportRect.push_back(tr);
viewportRect.push_back(tl);
- c2t::clip2tri clipper;
+ QClipperUtils clipper;
clipper.clearClipper();
- clipper.addSubjectPath(QClipperUtils::qListToPath(mapRect), true);
- clipper.addClipPolygon(QClipperUtils::qListToPath(viewportRect));
+ clipper.addSubjectPath(mapRect, true);
+ clipper.addClipPolygon(viewportRect);
- Paths res = clipper.execute(c2t::clip2tri::Intersection);
+ const auto res = clipper.execute(QClipperUtils::Intersection);
m_visibleRegion.clear();
if (res.size())
- m_visibleRegion = QClipperUtils::pathToQList(res[0]); // Intersection between two convex quadrilaterals should always be a single polygon
+ m_visibleRegion = res[0]; // Intersection between two convex quadrilaterals should always be a single polygon
m_projectableRegion.clear();
mapRect.clear();
@@ -814,14 +814,14 @@ void QGeoProjectionWebMercator::updateVisibleRegion()
projectableRect.push_back(tl);
- c2t::clip2tri clipperProjectable;
+ QClipperUtils clipperProjectable;
clipperProjectable.clearClipper();
- clipperProjectable.addSubjectPath(QClipperUtils::qListToPath(mapRect), true);
- clipperProjectable.addClipPolygon(QClipperUtils::qListToPath(projectableRect));
+ clipperProjectable.addSubjectPath(mapRect, true);
+ clipperProjectable.addClipPolygon(projectableRect);
- Paths resProjectable = clipperProjectable.execute(c2t::clip2tri::Intersection);
+ const auto resProjectable = clipperProjectable.execute(QClipperUtils::Intersection);
if (resProjectable.size())
- m_projectableRegion = QClipperUtils::pathToQList(resProjectable[0]); // Intersection between two convex quadrilaterals should always be a single polygon
+ m_projectableRegion = resProjectable[0]; // Intersection between two convex quadrilaterals should always be a single polygon
else
m_projectableRegion = viewportRect;
}
@@ -838,13 +838,13 @@ void QGeoProjectionWebMercator::updateVisibleRegion()
m_visibleRegionExpanded.push_back(centroid + vc * 1.2); // fixing expansion factor to 1.2
}
- c2t::clip2tri clipperExpanded;
+ QClipperUtils clipperExpanded;
clipperExpanded.clearClipper();
- clipperExpanded.addSubjectPath(QClipperUtils::qListToPath(m_visibleRegionExpanded), true);
- clipperExpanded.addClipPolygon(QClipperUtils::qListToPath(m_projectableRegion));
- Paths resVisibleExpanded = clipperExpanded.execute(c2t::clip2tri::Intersection);
+ clipperExpanded.addSubjectPath(m_visibleRegionExpanded, true);
+ clipperExpanded.addClipPolygon(m_projectableRegion);
+ const auto resVisibleExpanded = clipperExpanded.execute(QClipperUtils::Intersection);
if (resVisibleExpanded.size())
- m_visibleRegionExpanded = QClipperUtils::pathToQList(resVisibleExpanded[0]); // Intersection between two convex quadrilaterals should always be a single polygon
+ m_visibleRegionExpanded = resVisibleExpanded[0]; // Intersection between two convex quadrilaterals should always be a single polygon
else
m_visibleRegionExpanded = m_visibleRegion;
}