summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-10-21 17:27:08 +0200
committerIvan Solovev <ivan.solovev@qt.io>2021-11-02 09:46:33 +0200
commit6db775f6d9d72cf8ee9d66333b8424e74be1e352 (patch)
tree0a293756b61619a91970d9368a0449b7bf922728 /src
parent5a1f44c3d41febca8480c077bd4c34e5a3332cdc (diff)
downloadqtlocation-6.2.2.tar.gz
Remove QtPositioning module from qtlocation.git6.2.46.2.36.2.26.2
Turns out that our CI does not support repos without any tests. This is treated like an error and leads to integration failure. This patch fixes it by disabling tests in coin/module_config.yaml. This config should be fixed when QtLocation tests are enabled Task-number: QTBUG-97084 Change-Id: Ib06e865fe2836806bbbee34345f06b471dd48660 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 23f32792ad53e23bbafbff6d7667f0bb0f69fc53)
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/clip2tri/CMakeLists.txt31
-rw-r--r--src/3rdparty/clip2tri/LICENSE21
-rw-r--r--src/3rdparty/clip2tri/clip2tri.cpp406
-rw-r--r--src/3rdparty/clip2tri/clip2tri.h102
-rw-r--r--src/3rdparty/clip2tri/clip2tri.pro22
-rw-r--r--src/3rdparty/clip2tri/qt_attribution.json13
-rw-r--r--src/3rdparty/clipper/CMakeLists.txt25
-rw-r--r--src/3rdparty/clipper/LICENSE48
-rw-r--r--src/3rdparty/clipper/clipper.cpp4629
-rw-r--r--src/3rdparty/clipper/clipper.h404
-rw-r--r--src/3rdparty/clipper/clipper.pro16
-rw-r--r--src/3rdparty/clipper/qt_attribution.json13
-rw-r--r--src/3rdparty/poly2tri/AUTHORS8
-rw-r--r--src/3rdparty/poly2tri/CMakeLists.txt30
-rw-r--r--src/3rdparty/poly2tri/LICENSE27
-rw-r--r--src/3rdparty/poly2tri/common/shapes.cpp363
-rw-r--r--src/3rdparty/poly2tri/common/shapes.h325
-rw-r--r--src/3rdparty/poly2tri/common/utils.h127
-rw-r--r--src/3rdparty/poly2tri/poly2tri.h39
-rw-r--r--src/3rdparty/poly2tri/poly2tri.pro27
-rw-r--r--src/3rdparty/poly2tri/qt_attribution.json13
-rw-r--r--src/3rdparty/poly2tri/sweep/advancing_front.cpp109
-rw-r--r--src/3rdparty/poly2tri/sweep/advancing_front.h118
-rw-r--r--src/3rdparty/poly2tri/sweep/cdt.cpp72
-rw-r--r--src/3rdparty/poly2tri/sweep/cdt.h105
-rw-r--r--src/3rdparty/poly2tri/sweep/sweep.cpp814
-rw-r--r--src/3rdparty/poly2tri/sweep/sweep.h285
-rw-r--r--src/3rdparty/poly2tri/sweep/sweep_context.cpp216
-rw-r--r--src/3rdparty/poly2tri/sweep/sweep_context.h186
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/plugins/CMakeLists.txt8
-rw-r--r--src/plugins/plugins.pro1
-rw-r--r--src/plugins/position/CMakeLists.txt21
-rw-r--r--src/plugins/position/android/CMakeLists.txt4
-rw-r--r--src/plugins/position/android/android.pro2
-rw-r--r--src/plugins/position/android/jar/AndroidManifest.xml6
-rw-r--r--src/plugins/position/android/jar/CMakeLists.txt17
-rw-r--r--src/plugins/position/android/jar/jar.pro16
-rw-r--r--src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java658
-rw-r--r--src/plugins/position/android/src/CMakeLists.txt23
-rw-r--r--src/plugins/position/android/src/jnipositioning.cpp741
-rw-r--r--src/plugins/position/android/src/jnipositioning.h64
-rw-r--r--src/plugins/position/android/src/plugin.json9
-rw-r--r--src/plugins/position/android/src/positionfactory_android.cpp63
-rw-r--r--src/plugins/position/android/src/positionfactory_android.h58
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android.cpp296
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android_p.h102
-rw-r--r--src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp223
-rw-r--r--src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h98
-rw-r--r--src/plugins/position/android/src/src.pro21
-rw-r--r--src/plugins/position/corelocation/CMakeLists.txt36
-rw-r--r--src/plugins/position/corelocation/corelocation.pro24
-rw-r--r--src/plugins/position/corelocation/plugin.json9
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl.mm336
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h106
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h58
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm61
-rw-r--r--src/plugins/position/geoclue2/CMakeLists.txt31
-rw-r--r--src/plugins/position/geoclue2/geoclue2.pro30
-rw-r--r--src/plugins/position/geoclue2/geocluetypes.cpp62
-rw-r--r--src/plugins/position/geoclue2/geocluetypes.h63
-rw-r--r--src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml122
-rw-r--r--src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml96
-rw-r--r--src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml60
-rw-r--r--src/plugins/position/geoclue2/plugin.json9
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp458
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h100
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp69
-rw-r--r--src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h68
-rw-r--r--src/plugins/position/gypsy/CMakeLists.txt24
-rw-r--r--src/plugins/position/gypsy/gypsy.pro20
-rw-r--r--src/plugins/position/gypsy/plugin.json9
-rw-r--r--src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp66
-rw-r--r--src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h59
-rw-r--r--src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp442
-rw-r--r--src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h143
-rw-r--r--src/plugins/position/nmea/CMakeLists.txt22
-rw-r--r--src/plugins/position/nmea/nmea.pro16
-rw-r--r--src/plugins/position/nmea/plugin.json9
-rw-r--r--src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp505
-rw-r--r--src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h63
-rw-r--r--src/plugins/position/nmea/qiopipe.cpp207
-rw-r--r--src/plugins/position/nmea/qiopipe_p.h114
-rw-r--r--src/plugins/position/position.pro13
-rw-r--r--src/plugins/position/positionpoll/CMakeLists.txt20
-rw-r--r--src/plugins/position/positionpoll/plugin.json9
-rw-r--r--src/plugins/position/positionpoll/positionpoll.pro18
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.cpp65
-rw-r--r--src/plugins/position/positionpoll/positionpollfactory.h58
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp508
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.h100
-rw-r--r--src/plugins/position/winrt/CMakeLists.txt29
-rw-r--r--src/plugins/position/winrt/plugin.json9
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp675
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h124
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp70
-rw-r--r--src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h59
-rw-r--r--src/plugins/position/winrt/winrt.pro16
-rw-r--r--src/positioning/CMakeLists.txt66
-rw-r--r--src/positioning/configure.cmake28
-rw-r--r--src/positioning/configure.json48
-rw-r--r--src/positioning/doc/images/permissions.pngbin19306 -> 0 bytes
-rw-r--r--src/positioning/doc/qtpositioning.qdocconf56
-rw-r--r--src/positioning/doc/snippets/cpp/cpp.pro8
-rw-r--r--src/positioning/doc/snippets/cpp/cppqml.cpp118
-rw-r--r--src/positioning/doc/snippets/cpp/main.cpp55
-rw-r--r--src/positioning/doc/snippets/doc_src_qtpositioning.qml57
-rw-r--r--src/positioning/doc/snippets/snippets.pro2
-rw-r--r--src/positioning/doc/src/cpp-position.qdoc194
-rw-r--r--src/positioning/doc/src/cpp-qml-positioning.qdoc114
-rw-r--r--src/positioning/doc/src/external-resources.qdoc61
-rw-r--r--src/positioning/doc/src/plugins/geoclue2.qdoc86
-rw-r--r--src/positioning/doc/src/plugins/gypsy.qdoc115
-rw-r--r--src/positioning/doc/src/plugins/nmea.qdoc201
-rw-r--r--src/positioning/doc/src/qml-position.qdoc112
-rw-r--r--src/positioning/doc/src/qt6-changes.qdoc233
-rw-r--r--src/positioning/doc/src/qtpositioning-android.qdoc82
-rw-r--r--src/positioning/doc/src/qtpositioning-examples.qdoc38
-rw-r--r--src/positioning/doc/src/qtpositioning-plugins.qdoc114
-rw-r--r--src/positioning/doc/src/qtpositioning-qml.qdoc71
-rw-r--r--src/positioning/doc/src/qtpositioning.qdoc153
-rw-r--r--src/positioning/positioning.pro96
-rw-r--r--src/positioning/qclipperutils.cpp100
-rw-r--r--src/positioning/qclipperutils_p.h86
-rw-r--r--src/positioning/qdoublematrix4x4.cpp1112
-rw-r--r--src/positioning/qdoublematrix4x4_p.h946
-rw-r--r--src/positioning/qdoublevector2d.cpp121
-rw-r--r--src/positioning/qdoublevector2d_p.h262
-rw-r--r--src/positioning/qdoublevector3d.cpp144
-rw-r--r--src/positioning/qdoublevector3d_p.h302
-rw-r--r--src/positioning/qgeoaddress.cpp776
-rw-r--r--src/positioning/qgeoaddress.h123
-rw-r--r--src/positioning/qgeoaddress_p.h85
-rw-r--r--src/positioning/qgeoareamonitorinfo.cpp440
-rw-r--r--src/positioning/qgeoareamonitorinfo.h139
-rw-r--r--src/positioning/qgeoareamonitorsource.cpp432
-rw-r--r--src/positioning/qgeoareamonitorsource.h111
-rw-r--r--src/positioning/qgeocircle.cpp477
-rw-r--r--src/positioning/qgeocircle.h90
-rw-r--r--src/positioning/qgeocircle_p.h96
-rw-r--r--src/positioning/qgeocoordinate.cpp792
-rw-r--r--src/positioning/qgeocoordinate.h161
-rw-r--r--src/positioning/qgeocoordinate_p.h92
-rw-r--r--src/positioning/qgeocoordinateobject.cpp93
-rw-r--r--src/positioning/qgeocoordinateobject_p.h97
-rw-r--r--src/positioning/qgeolocation.cpp282
-rw-r--r--src/positioning/qgeolocation.h101
-rw-r--r--src/positioning/qgeolocation_p.h82
-rw-r--r--src/positioning/qgeopath.cpp774
-rw-r--r--src/positioning/qgeopath.h101
-rw-r--r--src/positioning/qgeopath_p.h260
-rw-r--r--src/positioning/qgeopolygon.cpp719
-rw-r--r--src/positioning/qgeopolygon.h100
-rw-r--r--src/positioning/qgeopolygon_p.h137
-rw-r--r--src/positioning/qgeopositioninfo.cpp445
-rw-r--r--src/positioning/qgeopositioninfo.h157
-rw-r--r--src/positioning/qgeopositioninfo_p.h78
-rw-r--r--src/positioning/qgeopositioninfosource.cpp634
-rw-r--r--src/positioning/qgeopositioninfosource.h129
-rw-r--r--src/positioning/qgeopositioninfosource_p.h96
-rw-r--r--src/positioning/qgeopositioninfosourcefactory.cpp90
-rw-r--r--src/positioning/qgeopositioninfosourcefactory.h66
-rw-r--r--src/positioning/qgeorectangle.cpp1031
-rw-r--r--src/positioning/qgeorectangle.h123
-rw-r--r--src/positioning/qgeorectangle_p.h89
-rw-r--r--src/positioning/qgeosatelliteinfo.cpp435
-rw-r--r--src/positioning/qgeosatelliteinfo.h154
-rw-r--r--src/positioning/qgeosatelliteinfo_p.h77
-rw-r--r--src/positioning/qgeosatelliteinfosource.cpp424
-rw-r--r--src/positioning/qgeosatelliteinfosource.h109
-rw-r--r--src/positioning/qgeosatelliteinfosource_p.h73
-rw-r--r--src/positioning/qgeoshape.cpp449
-rw-r--r--src/positioning/qgeoshape.h133
-rw-r--r--src/positioning/qgeoshape_p.h93
-rw-r--r--src/positioning/qlocationutils.cpp635
-rw-r--r--src/positioning/qlocationutils_p.h350
-rw-r--r--src/positioning/qnmeapositioninfosource.cpp962
-rw-r--r--src/positioning/qnmeapositioninfosource.h97
-rw-r--r--src/positioning/qnmeapositioninfosource_p.h188
-rw-r--r--src/positioning/qnmeasatelliteinfosource.cpp909
-rw-r--r--src/positioning/qnmeasatelliteinfosource.h104
-rw-r--r--src/positioning/qnmeasatelliteinfosource_p.h181
-rw-r--r--src/positioning/qpositioningglobal.h60
-rw-r--r--src/positioning/qpositioningglobal_p.h62
-rw-r--r--src/positioning/qwebmercator.cpp136
-rw-r--r--src/positioning/qwebmercator_p.h75
-rw-r--r--src/positioningquick/CMakeLists.txt46
-rw-r--r--src/positioningquick/locationsingleton.cpp387
-rw-r--r--src/positioningquick/locationsingleton_p.h110
-rw-r--r--src/positioningquick/positioningplugin.cpp555
-rw-r--r--src/positioningquick/positioningquick.pro10
-rw-r--r--src/positioningquick/qdeclarativegeoaddress.cpp380
-rw-r--r--src/positioningquick/qdeclarativegeoaddress_p.h129
-rw-r--r--src/positioningquick/qdeclarativegeolocation.cpp244
-rw-r--r--src/positioningquick/qdeclarativegeolocation_p.h114
-rw-r--r--src/positioningquick/qdeclarativepluginparameter.cpp145
-rw-r--r--src/positioningquick/qdeclarativepluginparameter_p.h96
-rw-r--r--src/positioningquick/qdeclarativeposition.cpp621
-rw-r--r--src/positioningquick/qdeclarativeposition_p.h204
-rw-r--r--src/positioningquick/qdeclarativepositionsource.cpp913
-rw-r--r--src/positioningquick/qdeclarativepositionsource_p.h222
-rw-r--r--src/positioningquick/qpositioningquickglobal.h69
-rw-r--r--src/positioningquick/qpositioningquickglobal_p.h63
-rw-r--r--src/positioningquick/qpositioningquickmodule_p.h151
-rw-r--r--src/positioningquick/qquickgeocoordinateanimation.cpp297
-rw-r--r--src/positioningquick/qquickgeocoordinateanimation_p.h104
-rw-r--r--src/positioningquick/qquickgeocoordinateanimation_p_p.h82
207 files changed, 4 insertions, 41628 deletions
diff --git a/src/3rdparty/clip2tri/CMakeLists.txt b/src/3rdparty/clip2tri/CMakeLists.txt
deleted file mode 100644
index 9b5a56b3..00000000
--- a/src/3rdparty/clip2tri/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Generated from clip2tri.pro.
-
-#####################################################################
-## Bundled_Clip2Tri Generic Library:
-#####################################################################
-
-qt_internal_add_3rdparty_library(Bundled_Clip2Tri
- QMAKE_LIB_NAME _clip2tri
- STATIC
- SKIP_AUTOMOC # special case
- EXCEPTIONS
- SOURCES
- clip2tri.cpp clip2tri.h
- INCLUDE_DIRECTORIES
- ../clipper
- ../poly2tri
- LIBRARIES
- Qt::Bundled_Clipper # special case
- Qt::Bundled_Poly2Tri # special case
-)
-qt_disable_warnings(Bundled_Clip2Tri)
-qt_set_symbol_visibility_hidden(Bundled_Clip2Tri)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 3:.:.:clip2tri.pro:GCC:
-# QMAKE_CFLAGS_OPTIMIZE_FULL = "-ffast-math"
-
-#### Keys ignored in scope 4:.:.:clip2tri.pro:NOT CLANG AND NOT ICC AND NOT rim_qcc:
-# QMAKE_CXXFLAGS_WARN_ON = "-Wno-error=return-type"
diff --git a/src/3rdparty/clip2tri/LICENSE b/src/3rdparty/clip2tri/LICENSE
deleted file mode 100644
index 9d99b888..00000000
--- a/src/3rdparty/clip2tri/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 Bitfighter developers
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/src/3rdparty/clip2tri/clip2tri.cpp b/src/3rdparty/clip2tri/clip2tri.cpp
deleted file mode 100644
index db4911c1..00000000
--- a/src/3rdparty/clip2tri/clip2tri.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Authors: kaen, raptor, sam686, watusimoto
- *
- * Originally from the bitfighter source code
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Bitfighter developers
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "clip2tri.h"
-#include <poly2tri.h>
-
-#include <cstdio>
-
-static const double clipperScaleFactor = 1073741822.0;
-static const double clipperScaleFactorInv = 1.0 / 1073741822.0;
-
-using namespace p2t;
-
-namespace c2t
-{
-
-
-static const F32 CLIPPER_SCALE_FACT = 1000.0f;
-static const F32 CLIPPER_SCALE_FACT_INVERSE = 0.001f;
-
-/////////////////////////////////
-
-Point::Point()
-{
- x = 0;
- y = 0;
-}
-
-Point::Point(const Point& pt)
-{
- x = pt.x;
- y = pt.y;
-}
-
-
-/////////////////////////////////
-
-clip2tri::clip2tri() : openSubject(false)
-{
- // Do nothing!
-}
-
-clip2tri::~clip2tri()
-{
- // Do nothing!
-}
-
-
-void clip2tri::triangulate(const vector<vector<Point> > &inputPolygons, vector<Point> &outputTriangles,
- const vector<Point> &boundingPolygon)
-{
- // Use clipper to clean. This upscales the floating point input
- PolyTree solution;
- mergePolysToPolyTree(inputPolygons, solution);
-
- Path bounds = upscaleClipperPoints(boundingPolygon);
-
- // This will downscale the Clipper output and use poly2tri to triangulate
- triangulateComplex(outputTriangles, bounds, solution);
-}
-
-void clip2tri::addClipPolygon(const Path &path)
-{
- try // prevent any exception to spill into Qt
- {
- clipper.AddPath(path, ptClip, true);
- }
- catch(QtClipperLib::clipperException &e)
- {
- printf("addClipPolygon: %s\n", e.what());
- }
-}
-
-void clip2tri::addSubjectPath(const Path &path, bool closed)
-{
- try // prevent any exception to spill into Qt
- {
- clipper.AddPath(path, ptSubject, closed);
- }
- catch(QtClipperLib::clipperException &e)
- {
- printf("addSubjectPath: %s\n", e.what());
- return;
- }
- if (!closed)
- openSubject = true;
-}
-
-void clip2tri::clearClipper()
-{
- // clear doesn't throw
- clipper.Clear();
- openSubject = false;
-}
-
-static QtClipperLib::ClipType operation(const clip2tri::Operation &op)
-{
- switch (op) {
- case clip2tri::Intersection:
- return QtClipperLib::ctIntersection;
- case clip2tri::Union:
- return QtClipperLib::ctUnion;
- case clip2tri::Difference:
- return QtClipperLib::ctDifference;
- case clip2tri::Xor:
- return QtClipperLib::ctXor;
- }
- return ctIntersection;
-}
-
-static std::string operationName(const clip2tri::Operation &op)
-{
- switch (op) {
- case clip2tri::Intersection:
- return std::string("Intersection");
- case clip2tri::Union:
- return std::string("Union");
- case clip2tri::Difference:
- return std::string("Difference");
- case clip2tri::Xor:
- return std::string("Xor");
- }
- return std::string("Intersection");
-}
-
-Paths clip2tri::execute(const clip2tri::Operation op, const PolyFillType subjFillType, const PolyFillType clipFillType)
-{
- Paths solution;
- try // prevent any exception from spilling into Qt
- {
- if (!openSubject) {
- clipper.Execute(operation(op), solution, subjFillType, clipFillType);
- } else {
- PolyTree res;
- clipper.Execute(operation(op), res, subjFillType, clipFillType);
- PolyNode *n = res.GetFirst();
- if (n) {
- solution.push_back(n->Contour);
- while ((n = n->GetNext()))
- solution.push_back(n->Contour);
- }
- }
- }
- catch(QtClipperLib::clipperException &e)
- {
- printf("executing %s: %s\n", operationName(op).c_str(), e.what());
- }
- return solution;
-}
-
-int clip2tri::pointInPolygon(const IntPoint &pt, const Path &path)
-{
- return PointInPolygon(pt, path);
-}
-
-Path clip2tri::upscaleClipperPoints(const vector<Point> &inputPolygon)
-{
- Path outputPolygon;
- outputPolygon.resize(inputPolygon.size());
-
- for(S32 i = 0; i < inputPolygon.size(); i++)
- outputPolygon[i] = IntPoint(S64(inputPolygon[i].x * CLIPPER_SCALE_FACT), S64(inputPolygon[i].y * CLIPPER_SCALE_FACT));
-
- return outputPolygon;
-}
-
-
-Paths clip2tri::upscaleClipperPoints(const vector<vector<Point> > &inputPolygons)
-{
- Paths outputPolygons;
-
- outputPolygons.resize(inputPolygons.size());
-
- for(S32 i = 0; i < inputPolygons.size(); i++)
- {
- outputPolygons[i].resize(inputPolygons[i].size());
-
- for(S32 j = 0; j < inputPolygons[i].size(); j++)
- outputPolygons[i][j] = IntPoint(S64(inputPolygons[i][j].x * CLIPPER_SCALE_FACT), S64(inputPolygons[i][j].y * CLIPPER_SCALE_FACT));
- }
-
- return outputPolygons;
-}
-
-
-vector<vector<Point> > clip2tri::downscaleClipperPoints(const Paths &inputPolygons)
-{
- vector<vector<Point> > outputPolygons;
-
- outputPolygons.resize(inputPolygons.size());
-
- for(U32 i = 0; i < inputPolygons.size(); i++)
- {
- outputPolygons[i].resize(inputPolygons[i].size());
-
- for(U32 j = 0; j < inputPolygons[i].size(); j++)
- outputPolygons[i][j] = Point(F32(inputPolygons[i][j].X) * CLIPPER_SCALE_FACT_INVERSE, F32(inputPolygons[i][j].Y) * CLIPPER_SCALE_FACT_INVERSE);
- }
-
- return outputPolygons;
-}
-
-
-// Use Clipper to merge inputPolygons, placing the result in a Polytree
-// NOTE: this does NOT downscale the Clipper points. You must do this afterwards
-//
-// Here you add all your non-navigatable objects (e.g. walls, barriers, etc.)
-bool clip2tri::mergePolysToPolyTree(const vector<vector<Point> > &inputPolygons, PolyTree &solution)
-{
- Paths input = upscaleClipperPoints(inputPolygons);
-
- // Fire up clipper and union!
- Clipper clipper;
- clipper.StrictlySimple(true);
-
- try // there is a "throw" in AddPolygon
- {
- clipper.AddPaths(input, ptSubject, true);
- }
- catch(QtClipperLib::clipperException &e)
- {
- printf("mergePolysToPolyTree: %s\n", e.what());
- }
-
- return clipper.Execute(ctUnion, solution, pftNonZero, pftNonZero);
-}
-
-
-// Delete all poly2tri points from a vector and clear the vector
-static void deleteAndClear(vector<p2t::Point*> &vec)
-{
- for(U32 i = 0; i < vec.size(); i++)
- delete vec[i];
-
- vec.clear();
-}
-
-
-// Shrink large polygons by reducing each coordinate by 1 in the
-// general direction of the last point as we wind around
-//
-// This normally wouldn't work in every case, but our upscaled-by-1000 polygons
-// have little chance to create new duplicate points with this method.
-//
-// For information on why this was needed, see:
-//
-// https://code.google.com/p/poly2tri/issues/detail?id=90
-//
-static void edgeShrink(Path &path)
-{
- U32 prev = path.size() - 1;
- for(U32 i = 0; i < path.size(); i++)
- {
- // Adjust coordinate by 1 depending on the direction
- path[i].X - path[prev].X > 0 ? path[i].X-- : path[i].X++;
- path[i].Y - path[prev].Y > 0 ? path[i].Y-- : path[i].Y++;
-
- prev = i;
- }
-}
-
-
-// This uses poly2tri to triangulate. poly2tri isn't very robust so clipper needs to do
-// the cleaning of points before getting here.
-//
-// A tree structure of polygons is required for doing complex polygons-within-polygons.
-// For reference discussion on how this started to be developed, see here:
-//
-// https://code.google.com/p/poly2tri/issues/detail?id=74
-//
-// For assistance with a special case crash, see this utility:
-// http://javascript.poly2tri.googlecode.com/hg/index.html
-//
-// FIXME: what is ignoreFills and ignoreHoles for? kaen?
-bool clip2tri::triangulateComplex(vector<Point> &outputTriangles, const Path &outline,
- const PolyTree &polyTree, bool ignoreFills, bool ignoreHoles)
-{
- // Keep track of memory for all the poly2tri objects we create
- vector<p2t::CDT*> cdtRegistry;
- vector<vector<p2t::Point*> > holesRegistry;
- vector<vector<p2t::Point*> > polylinesRegistry;
-
-
- // Let's be tricky and add our outline to the root node (it should have none), it'll be
- // our first Clipper hole
- PolyNode *rootNode = NULL;
-
- PolyNode tempNode;
- if(polyTree.Total() == 0) // Polytree is empty with no root node, e.g. on an empty level
- rootNode = &tempNode;
- else
- rootNode = polyTree.GetFirst()->Parent;
-
- rootNode->Contour = outline;
-
- // Now traverse our polyline nodes and triangulate them with only their children holes
- PolyNode *currentNode = rootNode;
- while(currentNode != NULL)
- {
- // A Clipper hole is actually what we want to build zones for; they become our bounding
- // polylines. poly2tri holes are therefore the inverse
- if((!ignoreHoles && currentNode->IsHole()) ||
- (!ignoreFills && !currentNode->IsHole()))
- {
- // Build up this polyline in poly2tri's format (downscale Clipper points)
- vector<p2t::Point*> polyline;
- for(U32 j = 0; j < currentNode->Contour.size(); j++)
- polyline.push_back(new p2t::Point(F64(currentNode->Contour[j].X), F64(currentNode->Contour[j].Y)));
-
- polylinesRegistry.push_back(polyline); // Memory
-
- // Set our polyline in poly2tri
- p2t::CDT* cdt = new p2t::CDT(polyline);
- cdtRegistry.push_back(cdt);
-
- for(U32 j = 0; j < currentNode->Childs.size(); j++)
- {
- PolyNode *childNode = currentNode->Childs[j];
-
- // Slightly modify the polygon to guarantee no duplicate points
- edgeShrink(childNode->Contour);
-
- vector<p2t::Point*> hole;
- for(U32 k = 0; k < childNode->Contour.size(); k++)
- hole.push_back(new p2t::Point(F64(childNode->Contour[k].X), F64(childNode->Contour[k].Y)));
-
- holesRegistry.push_back(hole); // Memory
-
- // Add the holes for this polyline
- cdt->AddHole(hole);
- }
-
- cdt->Triangulate();
-
- // Add current output triangles to our total
- vector<p2t::Triangle*> currentOutput = cdt->GetTriangles();
-
- // Copy our data to TNL::Point and to our output Vector
- p2t::Triangle *currentTriangle;
- for(U32 j = 0; j < currentOutput.size(); j++)
- {
- currentTriangle = currentOutput[j];
- outputTriangles.push_back(Point(currentTriangle->GetPoint(0)->x * CLIPPER_SCALE_FACT_INVERSE, currentTriangle->GetPoint(0)->y * CLIPPER_SCALE_FACT_INVERSE));
- outputTriangles.push_back(Point(currentTriangle->GetPoint(1)->x * CLIPPER_SCALE_FACT_INVERSE, currentTriangle->GetPoint(1)->y * CLIPPER_SCALE_FACT_INVERSE));
- outputTriangles.push_back(Point(currentTriangle->GetPoint(2)->x * CLIPPER_SCALE_FACT_INVERSE, currentTriangle->GetPoint(2)->y * CLIPPER_SCALE_FACT_INVERSE));
- }
- }
-
- currentNode = currentNode->GetNext();
- }
-
-
- // Clean up memory used with poly2tri
- //
- // Clean-up workers
- for(S32 i = 0; i < cdtRegistry.size(); i++)
- delete cdtRegistry[i];
-
- // Free the polylines
- for(S32 i = 0; i < polylinesRegistry.size(); i++)
- {
- vector<p2t::Point*> polyline = polylinesRegistry[i];
- deleteAndClear(polyline);
- }
-
- // Free the holes
- for(S32 i = 0; i < holesRegistry.size(); i++)
- {
- vector<p2t::Point*> hole = holesRegistry[i];
- deleteAndClear(hole);
- }
-
- // Make sure we have output data
- if(outputTriangles.size() == 0)
- return false;
-
- return true;
-}
-
-
-} /* namespace c2t */
diff --git a/src/3rdparty/clip2tri/clip2tri.h b/src/3rdparty/clip2tri/clip2tri.h
deleted file mode 100644
index 3848d009..00000000
--- a/src/3rdparty/clip2tri/clip2tri.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Authors: kaen, raptor, sam686, watusimoto
- *
- * Originally from the bitfighter source code
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Bitfighter developers
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef CLIP2TRI_H_
-#define CLIP2TRI_H_
-
-#include <vector>
-#include <clipper.h>
-
-using namespace std;
-using namespace QtClipperLib;
-
-namespace c2t
-{
-
-typedef signed int S32;
-typedef signed long long S64;
-typedef unsigned int U32;
-typedef float F32;
-typedef double F64;
-
-
-struct Point
-{
- F32 x;
- F32 y;
-
- Point();
- Point(const Point &pt);
-
- template<class T, class U>
- Point(T in_x, U in_y) { x = static_cast<F32>(in_x); y = static_cast<F32>(in_y); }
-};
-
-class clip2tri
-{
-private:
- //
- Path upscaleClipperPoints(const vector<Point> &inputPolygon);
-
- // These operate on a vector of polygons
- Paths upscaleClipperPoints(const vector<vector<Point> > &inputPolygons);
- vector<vector<Point> > downscaleClipperPoints(const Paths &inputPolygons);
-
- bool mergePolysToPolyTree(const vector<vector<Point> > &inputPolygons, PolyTree &solution);
-
- bool triangulateComplex(vector<Point> &outputTriangles, const Path &outline,
- const PolyTree &polyTree, bool ignoreFills = true, bool ignoreHoles = false);
-
-public:
- enum Operation { Union, Intersection, Difference, Xor };
- clip2tri();
- virtual ~clip2tri();
-
- void triangulate(const vector<vector<Point> > &inputPolygons, vector<Point> &outputTriangles,
- const vector<Point> &boundingPolygon);
-
- // Clip polygons are intended as closed, even if the first and last vertex aren't the same.
- void addClipPolygon(const Path &path);
- // Closed means the path has to be effectively closed. Meaning path[0] == path[path.size()-1]
- void addSubjectPath(const Path &path, bool closed);
-
- void clearClipper();
-
- Paths execute(const Operation op,
- const PolyFillType subjFillType = pftNonZero,
- const PolyFillType clipFillType = pftNonZero);
-
- static int pointInPolygon(const IntPoint &pt, const Path &path);
-
- Clipper clipper;
- bool openSubject;
-};
-
-} /* namespace c2t */
-
-#endif /* CLIP2TRI_H_ */
diff --git a/src/3rdparty/clip2tri/clip2tri.pro b/src/3rdparty/clip2tri/clip2tri.pro
deleted file mode 100644
index 4059a63a..00000000
--- a/src/3rdparty/clip2tri/clip2tri.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TARGET = qt_clip2tri
-
-CONFIG += staticlib exceptions warn_off optimize_full
-
-INCLUDEPATH += ../poly2tri
-INCLUDEPATH += ../clipper
-
-load(qt_helper_lib)
-
-# workaround for QTBUG-31586
-contains(QT_CONFIG, c++11): CONFIG += c++11
-
-gcc {
- QMAKE_CFLAGS_OPTIMIZE_FULL += -ffast-math
- !clang:!intel_icc:!rim_qcc: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=return-type
-}
-
-HEADERS += clip2tri.h
-SOURCES += clip2tri.cpp
-
-LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lqt_poly2tri$$qtPlatformTargetSuffix() -lqt_clipper$$qtPlatformTargetSuffix()
-
diff --git a/src/3rdparty/clip2tri/qt_attribution.json b/src/3rdparty/clip2tri/qt_attribution.json
deleted file mode 100644
index a4a1f183..00000000
--- a/src/3rdparty/clip2tri/qt_attribution.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Id": "clip2tri",
- "Name": "Clip2Tri Polygon Triangulation Library",
- "QDocModule": "qtpositioning",
- "QtUsage": "Used in the QML plugin of Qt Location and in Qt Positioning.",
-
- "Description": "Clip2Tri can be used together with Clipper for robust triangulation.",
- "Homepage": "https://github.com/raptor/clip2tri",
- "LicenseId": "MIT",
- "License": "MIT License",
- "LicenseFile": "LICENSE",
- "Copyright": "Copyright (c) 2014 Bitfighter developers"
-}
diff --git a/src/3rdparty/clipper/CMakeLists.txt b/src/3rdparty/clipper/CMakeLists.txt
deleted file mode 100644
index 08f2fada..00000000
--- a/src/3rdparty/clipper/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-# Generated from clipper.pro.
-
-#####################################################################
-## Bundled_Clipper Generic Library:
-#####################################################################
-
-qt_internal_add_3rdparty_library(Bundled_Clipper
- QMAKE_LIB_NAME _clipper
- STATIC
- SKIP_AUTOMOC # special case
- EXCEPTIONS
- SOURCES
- clipper.cpp clipper.h
-)
-qt_disable_warnings(Bundled_Clipper)
-qt_set_symbol_visibility_hidden(Bundled_Clipper)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 3:.:.:clipper.pro:GCC:
-# QMAKE_CFLAGS_OPTIMIZE_FULL = "-ffast-math"
-
-#### Keys ignored in scope 4:.:.:clipper.pro:NOT CLANG AND NOT ICC AND NOT rim_qcc:
-# QMAKE_CXXFLAGS_WARN_ON = "-Wno-error=return-type"
diff --git a/src/3rdparty/clipper/LICENSE b/src/3rdparty/clipper/LICENSE
deleted file mode 100644
index 2213e374..00000000
--- a/src/3rdparty/clipper/LICENSE
+++ /dev/null
@@ -1,48 +0,0 @@
-Use, modification & distribution is subject to Boost Software License Ver 1.
-http://www.boost.org/LICENSE_1_0.txt
-
-Attributions:
-The code in this library is an extension of Bala Vatti's clipping algorithm:
-"A generic solution to polygon clipping"
-Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63.
-http://portal.acm.org/citation.cfm?id=129906
-
-Computer graphics and geometric modeling: implementation and algorithms
-By Max K. Agoston
-Springer; 1 edition (January 4, 2005)
-http://books.google.com/books?q=vatti+clipping+agoston
-
-See also:
-"Polygon Offsetting by Computing Winding Numbers"
-Paper no. DETC2005-85513 pp. 565-575
-ASME 2005 International Design Engineering Technical Conferences
-and Computers and Information in Engineering Conference (IDETC/CIE2005)
-September 24-28, 2005 , Long Beach, California, USA
-http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf
-
-
-
-Boost Software License - Version 1.0 - August 17th, 2003
-http://www.boost.org/LICENSE_1_0.txt
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/src/3rdparty/clipper/clipper.cpp b/src/3rdparty/clipper/clipper.cpp
deleted file mode 100644
index d9735649..00000000
--- a/src/3rdparty/clipper/clipper.cpp
+++ /dev/null
@@ -1,4629 +0,0 @@
-/*******************************************************************************
-* *
-* Author : Angus Johnson *
-* Version : 6.4.2 *
-* Date : 27 February 2017 *
-* Website : http://www.angusj.com *
-* Copyright : Angus Johnson 2010-2017 *
-* *
-* License: *
-* Use, modification & distribution is subject to Boost Software License Ver 1. *
-* http://www.boost.org/LICENSE_1_0.txt *
-* *
-* Attributions: *
-* The code in this library is an extension of Bala Vatti's clipping algorithm: *
-* "A generic solution to polygon clipping" *
-* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
-* http://portal.acm.org/citation.cfm?id=129906 *
-* *
-* Computer graphics and geometric modeling: implementation and algorithms *
-* By Max K. Agoston *
-* Springer; 1 edition (January 4, 2005) *
-* http://books.google.com/books?q=vatti+clipping+agoston *
-* *
-* See also: *
-* "Polygon Offsetting by Computing Winding Numbers" *
-* Paper no. DETC2005-85513 pp. 565-575 *
-* ASME 2005 International Design Engineering Technical Conferences *
-* and Computers and Information in Engineering Conference (IDETC/CIE2005) *
-* September 24-28, 2005 , Long Beach, California, USA *
-* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
-* *
-*******************************************************************************/
-
-/*******************************************************************************
-* *
-* This is a translation of the Delphi Clipper library and the naming style *
-* used has retained a Delphi flavour. *
-* *
-*******************************************************************************/
-
-#include "clipper.h"
-#include <cmath>
-#include <vector>
-#include <algorithm>
-#include <stdexcept>
-#include <cstring>
-#include <cstdlib>
-#include <ostream>
-#include <functional>
-
-namespace QtClipperLib {
-
-static double const pi = 3.141592653589793238;
-static double const two_pi = pi *2;
-static double const def_arc_tolerance = 0.25;
-
-enum Direction { dRightToLeft, dLeftToRight };
-
-static int const Unassigned = -1; //edge not currently 'owning' a solution
-static int const Skip = -2; //edge that would otherwise close a path
-
-#define HORIZONTAL (-1.0E+40)
-#define TOLERANCE (1.0e-20)
-#define NEAR_ZERO(val) (((val) > -TOLERANCE) && ((val) < TOLERANCE))
-
-struct TEdge {
- IntPoint Bot;
- IntPoint Curr; //current (updated for every new scanbeam)
- IntPoint Top;
- double Dx;
- PolyType PolyTyp;
- EdgeSide Side; //side only refers to current side of solution poly
- int WindDelta; //1 or -1 depending on winding direction
- int WindCnt;
- int WindCnt2; //winding count of the opposite polytype
- int OutIdx;
- TEdge *Next;
- TEdge *Prev;
- TEdge *NextInLML;
- TEdge *NextInAEL;
- TEdge *PrevInAEL;
- TEdge *NextInSEL;
- TEdge *PrevInSEL;
-};
-
-struct IntersectNode {
- TEdge *Edge1;
- TEdge *Edge2;
- IntPoint Pt;
-};
-
-struct LocalMinimum {
- cInt Y;
- TEdge *LeftBound;
- TEdge *RightBound;
-};
-
-struct OutPt;
-
-//OutRec: contains a path in the clipping solution. Edges in the AEL will
-//carry a pointer to an OutRec when they are part of the clipping solution.
-struct OutRec {
- int Idx;
- bool IsHole;
- bool IsOpen;
- OutRec *FirstLeft; //see comments in clipper.pas
- PolyNode *PolyNd;
- OutPt *Pts;
- OutPt *BottomPt;
-};
-
-struct OutPt {
- int Idx;
- IntPoint Pt;
- OutPt *Next;
- OutPt *Prev;
-};
-
-struct Join {
- OutPt *OutPt1;
- OutPt *OutPt2;
- IntPoint OffPt;
-};
-
-struct LocMinSorter
-{
- inline bool operator()(const LocalMinimum& locMin1, const LocalMinimum& locMin2)
- {
- return locMin2.Y < locMin1.Y;
- }
-};
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-inline cInt Round(double val)
-{
- if ((val < 0)) return static_cast<cInt>(val - 0.5);
- else return static_cast<cInt>(val + 0.5);
-}
-//------------------------------------------------------------------------------
-
-inline cInt Abs(cInt val)
-{
- return val < 0 ? -val : val;
-}
-
-//------------------------------------------------------------------------------
-// PolyTree methods ...
-//------------------------------------------------------------------------------
-
-void PolyTree::Clear()
-{
- for (PolyNodes::size_type i = 0; i < AllNodes.size(); ++i)
- delete AllNodes[i];
- AllNodes.resize(0);
- Childs.resize(0);
-}
-//------------------------------------------------------------------------------
-
-PolyNode* PolyTree::GetFirst() const
-{
- if (!Childs.empty())
- return Childs[0];
- else
- return 0;
-}
-//------------------------------------------------------------------------------
-
-int PolyTree::Total() const
-{
- int result = (int)AllNodes.size();
- //with negative offsets, ignore the hidden outer polygon ...
- if (result > 0 && Childs[0] != AllNodes[0]) result--;
- return result;
-}
-
-//------------------------------------------------------------------------------
-// PolyNode methods ...
-//------------------------------------------------------------------------------
-
-PolyNode::PolyNode(): Parent(0), Index(0), m_IsOpen(false)
-{
-}
-//------------------------------------------------------------------------------
-
-int PolyNode::ChildCount() const
-{
- return (int)Childs.size();
-}
-//------------------------------------------------------------------------------
-
-void PolyNode::AddChild(PolyNode& child)
-{
- unsigned cnt = (unsigned)Childs.size();
- Childs.push_back(&child);
- child.Parent = this;
- child.Index = cnt;
-}
-//------------------------------------------------------------------------------
-
-PolyNode* PolyNode::GetNext() const
-{
- if (!Childs.empty())
- return Childs[0];
- else
- return GetNextSiblingUp();
-}
-//------------------------------------------------------------------------------
-
-PolyNode* PolyNode::GetNextSiblingUp() const
-{
- if (!Parent) //protects against PolyTree.GetNextSiblingUp()
- return 0;
- else if (Index == Parent->Childs.size() - 1)
- return Parent->GetNextSiblingUp();
- else
- return Parent->Childs[Index + 1];
-}
-//------------------------------------------------------------------------------
-
-bool PolyNode::IsHole() const
-{
- bool result = true;
- PolyNode* node = Parent;
- while (node)
- {
- result = !result;
- node = node->Parent;
- }
- return result;
-}
-//------------------------------------------------------------------------------
-
-bool PolyNode::IsOpen() const
-{
- return m_IsOpen;
-}
-//------------------------------------------------------------------------------
-
-#ifndef use_int32
-
-//------------------------------------------------------------------------------
-// Int128 class (enables safe math on signed 64bit integers)
-// eg Int128 val1((long64)9223372036854775807); //ie 2^63 -1
-// Int128 val2((long64)9223372036854775807);
-// Int128 val3 = val1 * val2;
-// val3.AsString => "85070591730234615847396907784232501249" (8.5e+37)
-//------------------------------------------------------------------------------
-
-class Int128
-{
- public:
- ulong64 lo;
- long64 hi;
-
- Int128(long64 _lo = 0)
- {
- lo = (ulong64)_lo;
- if (_lo < 0) hi = -1; else hi = 0;
- }
-
-
- Int128(const Int128 &val): lo(val.lo), hi(val.hi){}
-
- Int128(const long64& _hi, const ulong64& _lo): lo(_lo), hi(_hi){}
-
- Int128& operator = (const long64 &val)
- {
- lo = (ulong64)val;
- if (val < 0) hi = -1; else hi = 0;
- return *this;
- }
-
- bool operator == (const Int128 &val) const
- {return (hi == val.hi && lo == val.lo);}
-
- bool operator != (const Int128 &val) const
- { return !(*this == val);}
-
- bool operator > (const Int128 &val) const
- {
- if (hi != val.hi)
- return hi > val.hi;
- else
- return lo > val.lo;
- }
-
- bool operator < (const Int128 &val) const
- {
- if (hi != val.hi)
- return hi < val.hi;
- else
- return lo < val.lo;
- }
-
- bool operator >= (const Int128 &val) const
- { return !(*this < val);}
-
- bool operator <= (const Int128 &val) const
- { return !(*this > val);}
-
- Int128& operator += (const Int128 &rhs)
- {
- hi += rhs.hi;
- lo += rhs.lo;
- if (lo < rhs.lo) hi++;
- return *this;
- }
-
- Int128 operator + (const Int128 &rhs) const
- {
- Int128 result(*this);
- result+= rhs;
- return result;
- }
-
- Int128& operator -= (const Int128 &rhs)
- {
- *this += -rhs;
- return *this;
- }
-
- Int128 operator - (const Int128 &rhs) const
- {
- Int128 result(*this);
- result -= rhs;
- return result;
- }
-
- Int128 operator-() const //unary negation
- {
- if (lo == 0)
- return Int128(-hi, 0);
- else
- return Int128(~hi, ~lo + 1);
- }
-
- operator double() const
- {
- const double shift64 = 18446744073709551616.0; //2^64
- if (hi < 0)
- {
- if (lo == 0) return (double)hi * shift64;
- else return -(double)(~lo + ~hi * shift64);
- }
- else
- return (double)(lo + hi * shift64);
- }
-
-};
-//------------------------------------------------------------------------------
-
-Int128 Int128Mul (long64 lhs, long64 rhs)
-{
- bool negate = (lhs < 0) != (rhs < 0);
-
- if (lhs < 0) lhs = -lhs;
- ulong64 int1Hi = ulong64(lhs) >> 32;
- ulong64 int1Lo = ulong64(lhs & 0xFFFFFFFF);
-
- if (rhs < 0) rhs = -rhs;
- ulong64 int2Hi = ulong64(rhs) >> 32;
- ulong64 int2Lo = ulong64(rhs & 0xFFFFFFFF);
-
- //nb: see comments in clipper.pas
- ulong64 a = int1Hi * int2Hi;
- ulong64 b = int1Lo * int2Lo;
- ulong64 c = int1Hi * int2Lo + int1Lo * int2Hi;
-
- Int128 tmp;
- tmp.hi = long64(a + (c >> 32));
- tmp.lo = long64(c << 32);
- tmp.lo += long64(b);
- if (tmp.lo < b) tmp.hi++;
- if (negate) tmp = -tmp;
- return tmp;
-};
-#endif
-
-//------------------------------------------------------------------------------
-// Miscellaneous global functions
-//------------------------------------------------------------------------------
-
-bool Orientation(const Path &poly)
-{
- return Area(poly) >= 0;
-}
-//------------------------------------------------------------------------------
-
-double Area(const Path &poly)
-{
- int size = (int)poly.size();
- if (size < 3) return 0;
-
- double a = 0;
- for (int i = 0, j = size -1; i < size; ++i)
- {
- a += ((double)poly[j].X + poly[i].X) * ((double)poly[j].Y - poly[i].Y);
- j = i;
- }
- return -a * 0.5;
-}
-//------------------------------------------------------------------------------
-
-double Area(const OutPt *op)
-{
- const OutPt *startOp = op;
- if (!op) return 0;
- double a = 0;
- do {
- a += (double)(op->Prev->Pt.X + op->Pt.X) * (double)(op->Prev->Pt.Y - op->Pt.Y);
- op = op->Next;
- } while (op != startOp);
- return a * 0.5;
-}
-//------------------------------------------------------------------------------
-
-double Area(const OutRec &outRec)
-{
- return Area(outRec.Pts);
-}
-//------------------------------------------------------------------------------
-
-bool PointIsVertex(const IntPoint &Pt, OutPt *pp)
-{
- OutPt *pp2 = pp;
- do
- {
- if (pp2->Pt == Pt) return true;
- pp2 = pp2->Next;
- }
- while (pp2 != pp);
- return false;
-}
-//------------------------------------------------------------------------------
-
-//See "The Point in Polygon Problem for Arbitrary Polygons" by Hormann & Agathos
-//http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf
-int PointInPolygon(const IntPoint &pt, const Path &path)
-{
- //returns 0 if false, +1 if true, -1 if pt ON polygon boundary
- int result = 0;
- size_t cnt = path.size();
- if (cnt < 3) return 0;
- IntPoint ip = path[0];
- for(size_t i = 1; i <= cnt; ++i)
- {
- IntPoint ipNext = (i == cnt ? path[0] : path[i]);
- if (ipNext.Y == pt.Y)
- {
- if ((ipNext.X == pt.X) || (ip.Y == pt.Y &&
- ((ipNext.X > pt.X) == (ip.X < pt.X)))) return -1;
- }
- if ((ip.Y < pt.Y) != (ipNext.Y < pt.Y))
- {
- if (ip.X >= pt.X)
- {
- if (ipNext.X > pt.X) result = 1 - result;
- else
- {
- double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) -
- (double)(ipNext.X - pt.X) * (ip.Y - pt.Y);
- if (!d) return -1;
- if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result;
- }
- } else
- {
- if (ipNext.X > pt.X)
- {
- double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) -
- (double)(ipNext.X - pt.X) * (ip.Y - pt.Y);
- if (!d) return -1;
- if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result;
- }
- }
- }
- ip = ipNext;
- }
- return result;
-}
-//------------------------------------------------------------------------------
-
-int PointInPolygon (const IntPoint &pt, OutPt *op)
-{
- //returns 0 if false, +1 if true, -1 if pt ON polygon boundary
- int result = 0;
- OutPt* startOp = op;
- for(;;)
- {
- if (op->Next->Pt.Y == pt.Y)
- {
- if ((op->Next->Pt.X == pt.X) || (op->Pt.Y == pt.Y &&
- ((op->Next->Pt.X > pt.X) == (op->Pt.X < pt.X)))) return -1;
- }
- if ((op->Pt.Y < pt.Y) != (op->Next->Pt.Y < pt.Y))
- {
- if (op->Pt.X >= pt.X)
- {
- if (op->Next->Pt.X > pt.X) result = 1 - result;
- else
- {
- double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) -
- (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y);
- if (!d) return -1;
- if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result;
- }
- } else
- {
- if (op->Next->Pt.X > pt.X)
- {
- double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) -
- (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y);
- if (!d) return -1;
- if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result;
- }
- }
- }
- op = op->Next;
- if (startOp == op) break;
- }
- return result;
-}
-//------------------------------------------------------------------------------
-
-bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2)
-{
- OutPt* op = OutPt1;
- do
- {
- //nb: PointInPolygon returns 0 if false, +1 if true, -1 if pt on polygon
- int res = PointInPolygon(op->Pt, OutPt2);
- if (res >= 0) return res > 0;
- op = op->Next;
- }
- while (op != OutPt1);
- return true;
-}
-//----------------------------------------------------------------------
-
-bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range)
-{
-#ifndef use_int32
- if (UseFullInt64Range)
- return Int128Mul(e1.Top.Y - e1.Bot.Y, e2.Top.X - e2.Bot.X) ==
- Int128Mul(e1.Top.X - e1.Bot.X, e2.Top.Y - e2.Bot.Y);
- else
-#endif
- return (e1.Top.Y - e1.Bot.Y) * (e2.Top.X - e2.Bot.X) ==
- (e1.Top.X - e1.Bot.X) * (e2.Top.Y - e2.Bot.Y);
-}
-//------------------------------------------------------------------------------
-
-bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
- const IntPoint pt3, bool UseFullInt64Range)
-{
-#ifndef use_int32
- if (UseFullInt64Range)
- return Int128Mul(pt1.Y-pt2.Y, pt2.X-pt3.X) == Int128Mul(pt1.X-pt2.X, pt2.Y-pt3.Y);
- else
-#endif
- return (pt1.Y-pt2.Y)*(pt2.X-pt3.X) == (pt1.X-pt2.X)*(pt2.Y-pt3.Y);
-}
-//------------------------------------------------------------------------------
-
-bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
- const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range)
-{
-#ifndef use_int32
- if (UseFullInt64Range)
- return Int128Mul(pt1.Y-pt2.Y, pt3.X-pt4.X) == Int128Mul(pt1.X-pt2.X, pt3.Y-pt4.Y);
- else
-#endif
- return (pt1.Y-pt2.Y)*(pt3.X-pt4.X) == (pt1.X-pt2.X)*(pt3.Y-pt4.Y);
-}
-//------------------------------------------------------------------------------
-
-inline bool IsHorizontal(TEdge &e)
-{
- return e.Dx == HORIZONTAL;
-}
-//------------------------------------------------------------------------------
-
-inline double GetDx(const IntPoint pt1, const IntPoint pt2)
-{
- return (pt1.Y == pt2.Y) ?
- HORIZONTAL : (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y);
-}
-//---------------------------------------------------------------------------
-
-inline void SetDx(TEdge &e)
-{
- cInt dy = (e.Top.Y - e.Bot.Y);
- if (dy == 0) e.Dx = HORIZONTAL;
- else e.Dx = (double)(e.Top.X - e.Bot.X) / dy;
-}
-//---------------------------------------------------------------------------
-
-inline void SwapSides(TEdge &Edge1, TEdge &Edge2)
-{
- EdgeSide Side = Edge1.Side;
- Edge1.Side = Edge2.Side;
- Edge2.Side = Side;
-}
-//------------------------------------------------------------------------------
-
-inline void SwapPolyIndexes(TEdge &Edge1, TEdge &Edge2)
-{
- int OutIdx = Edge1.OutIdx;
- Edge1.OutIdx = Edge2.OutIdx;
- Edge2.OutIdx = OutIdx;
-}
-//------------------------------------------------------------------------------
-
-inline cInt TopX(TEdge &edge, const cInt currentY)
-{
- return ( currentY == edge.Top.Y ) ?
- edge.Top.X : edge.Bot.X + Round(edge.Dx *(currentY - edge.Bot.Y));
-}
-//------------------------------------------------------------------------------
-
-void IntersectPoint(TEdge &Edge1, TEdge &Edge2, IntPoint &ip)
-{
-#ifdef use_xyz
- ip.Z = 0;
-#endif
-
- double b1, b2;
- if (Edge1.Dx == Edge2.Dx)
- {
- ip.Y = Edge1.Curr.Y;
- ip.X = TopX(Edge1, ip.Y);
- return;
- }
- else if (Edge1.Dx == 0)
- {
- ip.X = Edge1.Bot.X;
- if (IsHorizontal(Edge2))
- ip.Y = Edge2.Bot.Y;
- else
- {
- b2 = Edge2.Bot.Y - (Edge2.Bot.X / Edge2.Dx);
- ip.Y = Round(ip.X / Edge2.Dx + b2);
- }
- }
- else if (Edge2.Dx == 0)
- {
- ip.X = Edge2.Bot.X;
- if (IsHorizontal(Edge1))
- ip.Y = Edge1.Bot.Y;
- else
- {
- b1 = Edge1.Bot.Y - (Edge1.Bot.X / Edge1.Dx);
- ip.Y = Round(ip.X / Edge1.Dx + b1);
- }
- }
- else
- {
- b1 = Edge1.Bot.X - Edge1.Bot.Y * Edge1.Dx;
- b2 = Edge2.Bot.X - Edge2.Bot.Y * Edge2.Dx;
- double q = (b2-b1) / (Edge1.Dx - Edge2.Dx);
- ip.Y = Round(q);
- if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
- ip.X = Round(Edge1.Dx * q + b1);
- else
- ip.X = Round(Edge2.Dx * q + b2);
- }
-
- if (ip.Y < Edge1.Top.Y || ip.Y < Edge2.Top.Y)
- {
- if (Edge1.Top.Y > Edge2.Top.Y)
- ip.Y = Edge1.Top.Y;
- else
- ip.Y = Edge2.Top.Y;
- if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
- ip.X = TopX(Edge1, ip.Y);
- else
- ip.X = TopX(Edge2, ip.Y);
- }
- //finally, don't allow 'ip' to be BELOW curr.Y (ie bottom of scanbeam) ...
- if (ip.Y > Edge1.Curr.Y)
- {
- ip.Y = Edge1.Curr.Y;
- //use the more vertical edge to derive X ...
- if (std::fabs(Edge1.Dx) > std::fabs(Edge2.Dx))
- ip.X = TopX(Edge2, ip.Y); else
- ip.X = TopX(Edge1, ip.Y);
- }
-}
-//------------------------------------------------------------------------------
-
-void ReversePolyPtLinks(OutPt *pp)
-{
- if (!pp) return;
- OutPt *pp1, *pp2;
- pp1 = pp;
- do {
- pp2 = pp1->Next;
- pp1->Next = pp1->Prev;
- pp1->Prev = pp2;
- pp1 = pp2;
- } while( pp1 != pp );
-}
-//------------------------------------------------------------------------------
-
-void DisposeOutPts(OutPt*& pp)
-{
- if (pp == 0) return;
- pp->Prev->Next = 0;
- while( pp )
- {
- OutPt *tmpPp = pp;
- pp = pp->Next;
- delete tmpPp;
- }
-}
-//------------------------------------------------------------------------------
-
-inline void InitEdge(TEdge* e, TEdge* eNext, TEdge* ePrev, const IntPoint& Pt)
-{
- std::memset(e, 0, sizeof(TEdge));
- e->Next = eNext;
- e->Prev = ePrev;
- e->Curr = Pt;
- e->OutIdx = Unassigned;
-}
-//------------------------------------------------------------------------------
-
-void InitEdge2(TEdge& e, PolyType Pt)
-{
- if (e.Curr.Y >= e.Next->Curr.Y)
- {
- e.Bot = e.Curr;
- e.Top = e.Next->Curr;
- } else
- {
- e.Top = e.Curr;
- e.Bot = e.Next->Curr;
- }
- SetDx(e);
- e.PolyTyp = Pt;
-}
-//------------------------------------------------------------------------------
-
-TEdge* RemoveEdge(TEdge* e)
-{
- //removes e from double_linked_list (but without removing from memory)
- e->Prev->Next = e->Next;
- e->Next->Prev = e->Prev;
- TEdge* result = e->Next;
- e->Prev = 0; //flag as removed (see ClipperBase.Clear)
- return result;
-}
-//------------------------------------------------------------------------------
-
-inline void ReverseHorizontal(TEdge &e)
-{
- //swap horizontal edges' Top and Bottom x's so they follow the natural
- //progression of the bounds - ie so their xbots will align with the
- //adjoining lower edge. [Helpful in the ProcessHorizontal() method.]
- std::swap(e.Top.X, e.Bot.X);
-#ifdef use_xyz
- std::swap(e.Top.Z, e.Bot.Z);
-#endif
-}
-//------------------------------------------------------------------------------
-
-void SwapPoints(IntPoint &pt1, IntPoint &pt2)
-{
- IntPoint tmp = pt1;
- pt1 = pt2;
- pt2 = tmp;
-}
-//------------------------------------------------------------------------------
-
-bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a,
- IntPoint pt2b, IntPoint &pt1, IntPoint &pt2)
-{
- //precondition: segments are Collinear.
- if (Abs(pt1a.X - pt1b.X) > Abs(pt1a.Y - pt1b.Y))
- {
- if (pt1a.X > pt1b.X) SwapPoints(pt1a, pt1b);
- if (pt2a.X > pt2b.X) SwapPoints(pt2a, pt2b);
- if (pt1a.X > pt2a.X) pt1 = pt1a; else pt1 = pt2a;
- if (pt1b.X < pt2b.X) pt2 = pt1b; else pt2 = pt2b;
- return pt1.X < pt2.X;
- } else
- {
- if (pt1a.Y < pt1b.Y) SwapPoints(pt1a, pt1b);
- if (pt2a.Y < pt2b.Y) SwapPoints(pt2a, pt2b);
- if (pt1a.Y < pt2a.Y) pt1 = pt1a; else pt1 = pt2a;
- if (pt1b.Y > pt2b.Y) pt2 = pt1b; else pt2 = pt2b;
- return pt1.Y > pt2.Y;
- }
-}
-//------------------------------------------------------------------------------
-
-bool FirstIsBottomPt(const OutPt* btmPt1, const OutPt* btmPt2)
-{
- OutPt *p = btmPt1->Prev;
- while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Prev;
- double dx1p = std::fabs(GetDx(btmPt1->Pt, p->Pt));
- p = btmPt1->Next;
- while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Next;
- double dx1n = std::fabs(GetDx(btmPt1->Pt, p->Pt));
-
- p = btmPt2->Prev;
- while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Prev;
- double dx2p = std::fabs(GetDx(btmPt2->Pt, p->Pt));
- p = btmPt2->Next;
- while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Next;
- double dx2n = std::fabs(GetDx(btmPt2->Pt, p->Pt));
-
- if (std::max(dx1p, dx1n) == std::max(dx2p, dx2n) &&
- std::min(dx1p, dx1n) == std::min(dx2p, dx2n))
- return Area(btmPt1) > 0; //if otherwise identical use orientation
- else
- return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n);
-}
-//------------------------------------------------------------------------------
-
-OutPt* GetBottomPt(OutPt *pp)
-{
- OutPt* dups = 0;
- OutPt* p = pp->Next;
- while (p != pp)
- {
- if (p->Pt.Y > pp->Pt.Y)
- {
- pp = p;
- dups = 0;
- }
- else if (p->Pt.Y == pp->Pt.Y && p->Pt.X <= pp->Pt.X)
- {
- if (p->Pt.X < pp->Pt.X)
- {
- dups = 0;
- pp = p;
- } else
- {
- if (p->Next != pp && p->Prev != pp) dups = p;
- }
- }
- p = p->Next;
- }
- if (dups)
- {
- //there appears to be at least 2 vertices at BottomPt so ...
- while (dups != p)
- {
- if (!FirstIsBottomPt(p, dups)) pp = dups;
- dups = dups->Next;
- while (dups->Pt != pp->Pt) dups = dups->Next;
- }
- }
- return pp;
-}
-//------------------------------------------------------------------------------
-
-bool Pt2IsBetweenPt1AndPt3(const IntPoint pt1,
- const IntPoint pt2, const IntPoint pt3)
-{
- if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2))
- return false;
- else if (pt1.X != pt3.X)
- return (pt2.X > pt1.X) == (pt2.X < pt3.X);
- else
- return (pt2.Y > pt1.Y) == (pt2.Y < pt3.Y);
-}
-//------------------------------------------------------------------------------
-
-bool HorzSegmentsOverlap(cInt seg1a, cInt seg1b, cInt seg2a, cInt seg2b)
-{
- if (seg1a > seg1b) std::swap(seg1a, seg1b);
- if (seg2a > seg2b) std::swap(seg2a, seg2b);
- return (seg1a < seg2b) && (seg2a < seg1b);
-}
-
-//------------------------------------------------------------------------------
-// ClipperBase class methods ...
-//------------------------------------------------------------------------------
-
-ClipperBase::ClipperBase() //constructor
-{
- m_CurrentLM = m_MinimaList.begin(); //begin() == end() here
- m_UseFullRange = false;
-}
-//------------------------------------------------------------------------------
-
-ClipperBase::~ClipperBase() //destructor
-{
- Clear();
-}
-//------------------------------------------------------------------------------
-
-void RangeTest(const IntPoint& Pt, bool& useFullRange)
-{
- if (useFullRange)
- {
- if (Pt.X > hiRange || Pt.Y > hiRange || -Pt.X > hiRange || -Pt.Y > hiRange)
- throw clipperException("Coordinate outside allowed range");
- }
- else if (Pt.X > loRange|| Pt.Y > loRange || -Pt.X > loRange || -Pt.Y > loRange)
- {
- useFullRange = true;
- RangeTest(Pt, useFullRange);
- }
-}
-//------------------------------------------------------------------------------
-
-TEdge* FindNextLocMin(TEdge* E)
-{
- for (;;)
- {
- while (E->Bot != E->Prev->Bot || E->Curr == E->Top) E = E->Next;
- if (!IsHorizontal(*E) && !IsHorizontal(*E->Prev)) break;
- while (IsHorizontal(*E->Prev)) E = E->Prev;
- TEdge* E2 = E;
- while (IsHorizontal(*E)) E = E->Next;
- if (E->Top.Y == E->Prev->Bot.Y) continue; //ie just an intermediate horz.
- if (E2->Prev->Bot.X < E->Bot.X) E = E2;
- break;
- }
- return E;
-}
-//------------------------------------------------------------------------------
-
-TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward)
-{
- TEdge *Result = E;
- TEdge *Horz = 0;
-
- if (E->OutIdx == Skip)
- {
- //if edges still remain in the current bound beyond the skip edge then
- //create another LocMin and call ProcessBound once more
- if (NextIsForward)
- {
- while (E->Top.Y == E->Next->Bot.Y) E = E->Next;
- //don't include top horizontals when parsing a bound a second time,
- //they will be contained in the opposite bound ...
- while (E != Result && IsHorizontal(*E)) E = E->Prev;
- }
- else
- {
- while (E->Top.Y == E->Prev->Bot.Y) E = E->Prev;
- while (E != Result && IsHorizontal(*E)) E = E->Next;
- }
-
- if (E == Result)
- {
- if (NextIsForward) Result = E->Next;
- else Result = E->Prev;
- }
- else
- {
- //there are more edges in the bound beyond result starting with E
- if (NextIsForward)
- E = Result->Next;
- else
- E = Result->Prev;
- MinimaList::value_type locMin;
- locMin.Y = E->Bot.Y;
- locMin.LeftBound = 0;
- locMin.RightBound = E;
- E->WindDelta = 0;
- Result = ProcessBound(E, NextIsForward);
- m_MinimaList.push_back(locMin);
- }
- return Result;
- }
-
- TEdge *EStart;
-
- if (IsHorizontal(*E))
- {
- //We need to be careful with open paths because this may not be a
- //true local minima (ie E may be following a skip edge).
- //Also, consecutive horz. edges may start heading left before going right.
- if (NextIsForward)
- EStart = E->Prev;
- else
- EStart = E->Next;
- if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge
- {
- if (EStart->Bot.X != E->Bot.X && EStart->Top.X != E->Bot.X)
- ReverseHorizontal(*E);
- }
- else if (EStart->Bot.X != E->Bot.X)
- ReverseHorizontal(*E);
- }
-
- EStart = E;
- if (NextIsForward)
- {
- while (Result->Top.Y == Result->Next->Bot.Y && Result->Next->OutIdx != Skip)
- Result = Result->Next;
- if (IsHorizontal(*Result) && Result->Next->OutIdx != Skip)
- {
- //nb: at the top of a bound, horizontals are added to the bound
- //only when the preceding edge attaches to the horizontal's left vertex
- //unless a Skip edge is encountered when that becomes the top divide
- Horz = Result;
- while (IsHorizontal(*Horz->Prev)) Horz = Horz->Prev;
- if (Horz->Prev->Top.X > Result->Next->Top.X) Result = Horz->Prev;
- }
- while (E != Result)
- {
- E->NextInLML = E->Next;
- if (IsHorizontal(*E) && E != EStart &&
- E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E);
- E = E->Next;
- }
- if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Prev->Top.X)
- ReverseHorizontal(*E);
- Result = Result->Next; //move to the edge just beyond current bound
- } else
- {
- while (Result->Top.Y == Result->Prev->Bot.Y && Result->Prev->OutIdx != Skip)
- Result = Result->Prev;
- if (IsHorizontal(*Result) && Result->Prev->OutIdx != Skip)
- {
- Horz = Result;
- while (IsHorizontal(*Horz->Next)) Horz = Horz->Next;
- if (Horz->Next->Top.X == Result->Prev->Top.X ||
- Horz->Next->Top.X > Result->Prev->Top.X) Result = Horz->Next;
- }
-
- while (E != Result)
- {
- E->NextInLML = E->Prev;
- if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X)
- ReverseHorizontal(*E);
- E = E->Prev;
- }
- if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X)
- ReverseHorizontal(*E);
- Result = Result->Prev; //move to the edge just beyond current bound
- }
-
- return Result;
-}
-//------------------------------------------------------------------------------
-
-bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed)
-{
-#ifdef use_lines
- if (!Closed && PolyTyp == ptClip)
- throw clipperException("AddPath: Open paths must be subject.");
-#else
- if (!Closed)
- throw clipperException("AddPath: Open paths have been disabled.");
-#endif
-
- int highI = (int)pg.size() -1;
- if (Closed) while (highI > 0 && (pg[highI] == pg[0])) --highI;
- while (highI > 0 && (pg[highI] == pg[highI -1])) --highI;
- if ((Closed && highI < 2) || (!Closed && highI < 1)) return false;
-
- //create a new edge array ...
- TEdge *edges = new TEdge [highI +1];
-
- bool IsFlat = true;
- //1. Basic (first) edge initialization ...
- try
- {
- edges[1].Curr = pg[1];
- RangeTest(pg[0], m_UseFullRange);
- RangeTest(pg[highI], m_UseFullRange);
- InitEdge(&edges[0], &edges[1], &edges[highI], pg[0]);
- InitEdge(&edges[highI], &edges[0], &edges[highI-1], pg[highI]);
- for (int i = highI - 1; i >= 1; --i)
- {
- RangeTest(pg[i], m_UseFullRange);
- InitEdge(&edges[i], &edges[i+1], &edges[i-1], pg[i]);
- }
- }
- catch(...)
- {
- delete [] edges;
- throw; //range test fails
- }
- TEdge *eStart = &edges[0];
-
- //2. Remove duplicate vertices, and (when closed) collinear edges ...
- TEdge *E = eStart, *eLoopStop = eStart;
- for (;;)
- {
- //nb: allows matching start and end points when not Closed ...
- if (E->Curr == E->Next->Curr && (Closed || E->Next != eStart))
- {
- if (E == E->Next) break;
- if (E == eStart) eStart = E->Next;
- E = RemoveEdge(E);
- eLoopStop = E;
- continue;
- }
- if (E->Prev == E->Next)
- break; //only two vertices
- else if (Closed &&
- SlopesEqual(E->Prev->Curr, E->Curr, E->Next->Curr, m_UseFullRange) &&
- (!m_PreserveCollinear ||
- !Pt2IsBetweenPt1AndPt3(E->Prev->Curr, E->Curr, E->Next->Curr)))
- {
- //Collinear edges are allowed for open paths but in closed paths
- //the default is to merge adjacent collinear edges into a single edge.
- //However, if the PreserveCollinear property is enabled, only overlapping
- //collinear edges (ie spikes) will be removed from closed paths.
- if (E == eStart) eStart = E->Next;
- E = RemoveEdge(E);
- E = E->Prev;
- eLoopStop = E;
- continue;
- }
- E = E->Next;
- if ((E == eLoopStop) || (!Closed && E->Next == eStart)) break;
- }
-
- if ((!Closed && (E == E->Next)) || (Closed && (E->Prev == E->Next)))
- {
- delete [] edges;
- return false;
- }
-
- if (!Closed)
- {
- m_HasOpenPaths = true;
- eStart->Prev->OutIdx = Skip;
- }
-
- //3. Do second stage of edge initialization ...
- E = eStart;
- do
- {
- InitEdge2(*E, PolyTyp);
- E = E->Next;
- if (IsFlat && E->Curr.Y != eStart->Curr.Y) IsFlat = false;
- }
- while (E != eStart);
-
- //4. Finally, add edge bounds to LocalMinima list ...
-
- //Totally flat paths must be handled differently when adding them
- //to LocalMinima list to avoid endless loops etc ...
- if (IsFlat)
- {
- if (Closed)
- {
- delete [] edges;
- return false;
- }
- E->Prev->OutIdx = Skip;
- MinimaList::value_type locMin;
- locMin.Y = E->Bot.Y;
- locMin.LeftBound = 0;
- locMin.RightBound = E;
- locMin.RightBound->Side = esRight;
- locMin.RightBound->WindDelta = 0;
- for (;;)
- {
- if (E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E);
- if (E->Next->OutIdx == Skip) break;
- E->NextInLML = E->Next;
- E = E->Next;
- }
- m_MinimaList.push_back(locMin);
- m_edges.push_back(edges);
- return true;
- }
-
- m_edges.push_back(edges);
- bool leftBoundIsForward;
- TEdge* EMin = 0;
-
- //workaround to avoid an endless loop in the while loop below when
- //open paths have matching start and end points ...
- if (E->Prev->Bot == E->Prev->Top) E = E->Next;
-
- for (;;)
- {
- E = FindNextLocMin(E);
- if (E == EMin) break;
- else if (!EMin) EMin = E;
-
- //E and E.Prev now share a local minima (left aligned if horizontal).
- //Compare their slopes to find which starts which bound ...
- MinimaList::value_type locMin;
- locMin.Y = E->Bot.Y;
- if (E->Dx < E->Prev->Dx)
- {
- locMin.LeftBound = E->Prev;
- locMin.RightBound = E;
- leftBoundIsForward = false; //Q.nextInLML = Q.prev
- } else
- {
- locMin.LeftBound = E;
- locMin.RightBound = E->Prev;
- leftBoundIsForward = true; //Q.nextInLML = Q.next
- }
-
- if (!Closed) locMin.LeftBound->WindDelta = 0;
- else if (locMin.LeftBound->Next == locMin.RightBound)
- locMin.LeftBound->WindDelta = -1;
- else locMin.LeftBound->WindDelta = 1;
- locMin.RightBound->WindDelta = -locMin.LeftBound->WindDelta;
-
- E = ProcessBound(locMin.LeftBound, leftBoundIsForward);
- if (E->OutIdx == Skip) E = ProcessBound(E, leftBoundIsForward);
-
- TEdge* E2 = ProcessBound(locMin.RightBound, !leftBoundIsForward);
- if (E2->OutIdx == Skip) E2 = ProcessBound(E2, !leftBoundIsForward);
-
- if (locMin.LeftBound->OutIdx == Skip)
- locMin.LeftBound = 0;
- else if (locMin.RightBound->OutIdx == Skip)
- locMin.RightBound = 0;
- m_MinimaList.push_back(locMin);
- if (!leftBoundIsForward) E = E2;
- }
- return true;
-}
-//------------------------------------------------------------------------------
-
-bool ClipperBase::AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed)
-{
- bool result = false;
- for (Paths::size_type i = 0; i < ppg.size(); ++i)
- if (AddPath(ppg[i], PolyTyp, Closed)) result = true;
- return result;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::Clear()
-{
- DisposeLocalMinimaList();
- for (EdgeList::size_type i = 0; i < m_edges.size(); ++i)
- {
- TEdge* edges = m_edges[i];
- delete [] edges;
- }
- m_edges.clear();
- m_UseFullRange = false;
- m_HasOpenPaths = false;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::Reset()
-{
- m_CurrentLM = m_MinimaList.begin();
- if (m_CurrentLM == m_MinimaList.end()) return; //ie nothing to process
- std::sort(m_MinimaList.begin(), m_MinimaList.end(), LocMinSorter());
-
- m_Scanbeam = ScanbeamList(); //clears/resets priority_queue
- //reset all edges ...
- for (MinimaList::iterator lm = m_MinimaList.begin(); lm != m_MinimaList.end(); ++lm)
- {
- InsertScanbeam(lm->Y);
- TEdge* e = lm->LeftBound;
- if (e)
- {
- e->Curr = e->Bot;
- e->Side = esLeft;
- e->OutIdx = Unassigned;
- }
-
- e = lm->RightBound;
- if (e)
- {
- e->Curr = e->Bot;
- e->Side = esRight;
- e->OutIdx = Unassigned;
- }
- }
- m_ActiveEdges = 0;
- m_CurrentLM = m_MinimaList.begin();
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::DisposeLocalMinimaList()
-{
- m_MinimaList.clear();
- m_CurrentLM = m_MinimaList.begin();
-}
-//------------------------------------------------------------------------------
-
-bool ClipperBase::PopLocalMinima(cInt Y, const LocalMinimum *&locMin)
-{
- if (m_CurrentLM == m_MinimaList.end() || (*m_CurrentLM).Y != Y) return false;
- locMin = &(*m_CurrentLM);
- ++m_CurrentLM;
- return true;
-}
-//------------------------------------------------------------------------------
-
-IntRect ClipperBase::GetBounds()
-{
- IntRect result;
- MinimaList::iterator lm = m_MinimaList.begin();
- if (lm == m_MinimaList.end())
- {
- result.left = result.top = result.right = result.bottom = 0;
- return result;
- }
- result.left = lm->LeftBound->Bot.X;
- result.top = lm->LeftBound->Bot.Y;
- result.right = lm->LeftBound->Bot.X;
- result.bottom = lm->LeftBound->Bot.Y;
- while (lm != m_MinimaList.end())
- {
- //todo - needs fixing for open paths
- result.bottom = std::max(result.bottom, lm->LeftBound->Bot.Y);
- TEdge* e = lm->LeftBound;
- for (;;) {
- TEdge* bottomE = e;
- while (e->NextInLML)
- {
- if (e->Bot.X < result.left) result.left = e->Bot.X;
- if (e->Bot.X > result.right) result.right = e->Bot.X;
- e = e->NextInLML;
- }
- result.left = std::min(result.left, e->Bot.X);
- result.right = std::max(result.right, e->Bot.X);
- result.left = std::min(result.left, e->Top.X);
- result.right = std::max(result.right, e->Top.X);
- result.top = std::min(result.top, e->Top.Y);
- if (bottomE == lm->LeftBound) e = lm->RightBound;
- else break;
- }
- ++lm;
- }
- return result;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::InsertScanbeam(const cInt Y)
-{
- m_Scanbeam.push(Y);
-}
-//------------------------------------------------------------------------------
-
-bool ClipperBase::PopScanbeam(cInt &Y)
-{
- if (m_Scanbeam.empty()) return false;
- Y = m_Scanbeam.top();
- m_Scanbeam.pop();
- while (!m_Scanbeam.empty() && Y == m_Scanbeam.top()) { m_Scanbeam.pop(); } // Pop duplicates.
- return true;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::DisposeAllOutRecs(){
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
- DisposeOutRec(i);
- m_PolyOuts.clear();
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::DisposeOutRec(PolyOutList::size_type index)
-{
- OutRec *outRec = m_PolyOuts[index];
- if (outRec->Pts) DisposeOutPts(outRec->Pts);
- delete outRec;
- m_PolyOuts[index] = 0;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::DeleteFromAEL(TEdge *e)
-{
- TEdge* AelPrev = e->PrevInAEL;
- TEdge* AelNext = e->NextInAEL;
- if (!AelPrev && !AelNext && (e != m_ActiveEdges)) return; //already deleted
- if (AelPrev) AelPrev->NextInAEL = AelNext;
- else m_ActiveEdges = AelNext;
- if (AelNext) AelNext->PrevInAEL = AelPrev;
- e->NextInAEL = 0;
- e->PrevInAEL = 0;
-}
-//------------------------------------------------------------------------------
-
-OutRec* ClipperBase::CreateOutRec()
-{
- OutRec* result = new OutRec;
- result->IsHole = false;
- result->IsOpen = false;
- result->FirstLeft = 0;
- result->Pts = 0;
- result->BottomPt = 0;
- result->PolyNd = 0;
- m_PolyOuts.push_back(result);
- result->Idx = (int)m_PolyOuts.size() - 1;
- return result;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::SwapPositionsInAEL(TEdge *Edge1, TEdge *Edge2)
-{
- //check that one or other edge hasn't already been removed from AEL ...
- if (Edge1->NextInAEL == Edge1->PrevInAEL ||
- Edge2->NextInAEL == Edge2->PrevInAEL) return;
-
- if (Edge1->NextInAEL == Edge2)
- {
- TEdge* Next = Edge2->NextInAEL;
- if (Next) Next->PrevInAEL = Edge1;
- TEdge* Prev = Edge1->PrevInAEL;
- if (Prev) Prev->NextInAEL = Edge2;
- Edge2->PrevInAEL = Prev;
- Edge2->NextInAEL = Edge1;
- Edge1->PrevInAEL = Edge2;
- Edge1->NextInAEL = Next;
- }
- else if (Edge2->NextInAEL == Edge1)
- {
- TEdge* Next = Edge1->NextInAEL;
- if (Next) Next->PrevInAEL = Edge2;
- TEdge* Prev = Edge2->PrevInAEL;
- if (Prev) Prev->NextInAEL = Edge1;
- Edge1->PrevInAEL = Prev;
- Edge1->NextInAEL = Edge2;
- Edge2->PrevInAEL = Edge1;
- Edge2->NextInAEL = Next;
- }
- else
- {
- TEdge* Next = Edge1->NextInAEL;
- TEdge* Prev = Edge1->PrevInAEL;
- Edge1->NextInAEL = Edge2->NextInAEL;
- if (Edge1->NextInAEL) Edge1->NextInAEL->PrevInAEL = Edge1;
- Edge1->PrevInAEL = Edge2->PrevInAEL;
- if (Edge1->PrevInAEL) Edge1->PrevInAEL->NextInAEL = Edge1;
- Edge2->NextInAEL = Next;
- if (Edge2->NextInAEL) Edge2->NextInAEL->PrevInAEL = Edge2;
- Edge2->PrevInAEL = Prev;
- if (Edge2->PrevInAEL) Edge2->PrevInAEL->NextInAEL = Edge2;
- }
-
- if (!Edge1->PrevInAEL) m_ActiveEdges = Edge1;
- else if (!Edge2->PrevInAEL) m_ActiveEdges = Edge2;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::UpdateEdgeIntoAEL(TEdge *&e)
-{
- if (!e->NextInLML)
- throw clipperException("UpdateEdgeIntoAEL: invalid call");
-
- e->NextInLML->OutIdx = e->OutIdx;
- TEdge* AelPrev = e->PrevInAEL;
- TEdge* AelNext = e->NextInAEL;
- if (AelPrev) AelPrev->NextInAEL = e->NextInLML;
- else m_ActiveEdges = e->NextInLML;
- if (AelNext) AelNext->PrevInAEL = e->NextInLML;
- e->NextInLML->Side = e->Side;
- e->NextInLML->WindDelta = e->WindDelta;
- e->NextInLML->WindCnt = e->WindCnt;
- e->NextInLML->WindCnt2 = e->WindCnt2;
- e = e->NextInLML;
- e->Curr = e->Bot;
- e->PrevInAEL = AelPrev;
- e->NextInAEL = AelNext;
- if (!IsHorizontal(*e)) InsertScanbeam(e->Top.Y);
-}
-//------------------------------------------------------------------------------
-
-bool ClipperBase::LocalMinimaPending()
-{
- return (m_CurrentLM != m_MinimaList.end());
-}
-
-//------------------------------------------------------------------------------
-// TClipper methods ...
-//------------------------------------------------------------------------------
-
-Clipper::Clipper(int initOptions) : ClipperBase() //constructor
-{
- m_ExecuteLocked = false;
- m_UseFullRange = false;
- m_ReverseOutput = ((initOptions & ioReverseSolution) != 0);
- m_StrictSimple = ((initOptions & ioStrictlySimple) != 0);
- m_PreserveCollinear = ((initOptions & ioPreserveCollinear) != 0);
- m_HasOpenPaths = false;
-#ifdef use_xyz
- m_ZFill = 0;
-#endif
-}
-//------------------------------------------------------------------------------
-
-#ifdef use_xyz
-void Clipper::ZFillFunction(ZFillCallback zFillFunc)
-{
- m_ZFill = zFillFunc;
-}
-//------------------------------------------------------------------------------
-#endif
-
-bool Clipper::Execute(ClipType clipType, Paths &solution, PolyFillType fillType)
-{
- return Execute(clipType, solution, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::Execute(ClipType clipType, PolyTree &polytree, PolyFillType fillType)
-{
- return Execute(clipType, polytree, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::Execute(ClipType clipType, Paths &solution,
- PolyFillType subjFillType, PolyFillType clipFillType)
-{
- if( m_ExecuteLocked ) return false;
- if (m_HasOpenPaths)
- throw clipperException("Error: PolyTree struct is needed for open path clipping.");
- m_ExecuteLocked = true;
- solution.resize(0);
- m_SubjFillType = subjFillType;
- m_ClipFillType = clipFillType;
- m_ClipType = clipType;
- m_UsingPolyTree = false;
- bool succeeded = ExecuteInternal();
- if (succeeded) BuildResult(solution);
- DisposeAllOutRecs();
- m_ExecuteLocked = false;
- return succeeded;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::Execute(ClipType clipType, PolyTree& polytree,
- PolyFillType subjFillType, PolyFillType clipFillType)
-{
- if( m_ExecuteLocked ) return false;
- m_ExecuteLocked = true;
- m_SubjFillType = subjFillType;
- m_ClipFillType = clipFillType;
- m_ClipType = clipType;
- m_UsingPolyTree = true;
- bool succeeded = ExecuteInternal();
- if (succeeded) BuildResult2(polytree);
- DisposeAllOutRecs();
- m_ExecuteLocked = false;
- return succeeded;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixHoleLinkage(OutRec &outrec)
-{
- //skip OutRecs that (a) contain outermost polygons or
- //(b) already have the correct owner/child linkage ...
- if (!outrec.FirstLeft ||
- (outrec.IsHole != outrec.FirstLeft->IsHole &&
- outrec.FirstLeft->Pts)) return;
-
- OutRec* orfl = outrec.FirstLeft;
- while (orfl && ((orfl->IsHole == outrec.IsHole) || !orfl->Pts))
- orfl = orfl->FirstLeft;
- outrec.FirstLeft = orfl;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::ExecuteInternal()
-{
- bool succeeded = true;
- try {
- Reset();
- m_Maxima = MaximaList();
- m_SortedEdges = 0;
-
- succeeded = true;
- cInt botY, topY;
- if (!PopScanbeam(botY)) return false;
- InsertLocalMinimaIntoAEL(botY);
- while (PopScanbeam(topY) || LocalMinimaPending())
- {
- ProcessHorizontals();
- ClearGhostJoins();
- if (!ProcessIntersections(topY))
- {
- succeeded = false;
- break;
- }
- ProcessEdgesAtTopOfScanbeam(topY);
- botY = topY;
- InsertLocalMinimaIntoAEL(botY);
- }
- }
- catch(...)
- {
- succeeded = false;
- }
-
- if (succeeded)
- {
- //fix orientations ...
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
- {
- OutRec *outRec = m_PolyOuts[i];
- if (!outRec->Pts || outRec->IsOpen) continue;
- if ((outRec->IsHole ^ m_ReverseOutput) == (Area(*outRec) > 0))
- ReversePolyPtLinks(outRec->Pts);
- }
-
- if (!m_Joins.empty()) JoinCommonEdges();
-
- //unfortunately FixupOutPolygon() must be done after JoinCommonEdges()
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
- {
- OutRec *outRec = m_PolyOuts[i];
- if (!outRec->Pts) continue;
- if (outRec->IsOpen)
- FixupOutPolyline(*outRec);
- else
- FixupOutPolygon(*outRec);
- }
-
- if (m_StrictSimple) DoSimplePolygons();
- }
-
- ClearJoins();
- ClearGhostJoins();
- return succeeded;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::SetWindingCount(TEdge &edge)
-{
- TEdge *e = edge.PrevInAEL;
- //find the edge of the same polytype that immediately preceeds 'edge' in AEL
- while (e && ((e->PolyTyp != edge.PolyTyp) || (e->WindDelta == 0))) e = e->PrevInAEL;
- if (!e)
- {
- if (edge.WindDelta == 0)
- {
- PolyFillType pft = (edge.PolyTyp == ptSubject ? m_SubjFillType : m_ClipFillType);
- edge.WindCnt = (pft == pftNegative ? -1 : 1);
- }
- else
- edge.WindCnt = edge.WindDelta;
- edge.WindCnt2 = 0;
- e = m_ActiveEdges; //ie get ready to calc WindCnt2
- }
- else if (edge.WindDelta == 0 && m_ClipType != ctUnion)
- {
- edge.WindCnt = 1;
- edge.WindCnt2 = e->WindCnt2;
- e = e->NextInAEL; //ie get ready to calc WindCnt2
- }
- else if (IsEvenOddFillType(edge))
- {
- //EvenOdd filling ...
- if (edge.WindDelta == 0)
- {
- //are we inside a subj polygon ...
- bool Inside = true;
- TEdge *e2 = e->PrevInAEL;
- while (e2)
- {
- if (e2->PolyTyp == e->PolyTyp && e2->WindDelta != 0)
- Inside = !Inside;
- e2 = e2->PrevInAEL;
- }
- edge.WindCnt = (Inside ? 0 : 1);
- }
- else
- {
- edge.WindCnt = edge.WindDelta;
- }
- edge.WindCnt2 = e->WindCnt2;
- e = e->NextInAEL; //ie get ready to calc WindCnt2
- }
- else
- {
- //nonZero, Positive or Negative filling ...
- if (e->WindCnt * e->WindDelta < 0)
- {
- //prev edge is 'decreasing' WindCount (WC) toward zero
- //so we're outside the previous polygon ...
- if (Abs(e->WindCnt) > 1)
- {
- //outside prev poly but still inside another.
- //when reversing direction of prev poly use the same WC
- if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt;
- //otherwise continue to 'decrease' WC ...
- else edge.WindCnt = e->WindCnt + edge.WindDelta;
- }
- else
- //now outside all polys of same polytype so set own WC ...
- edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta);
- } else
- {
- //prev edge is 'increasing' WindCount (WC) away from zero
- //so we're inside the previous polygon ...
- if (edge.WindDelta == 0)
- edge.WindCnt = (e->WindCnt < 0 ? e->WindCnt - 1 : e->WindCnt + 1);
- //if wind direction is reversing prev then use same WC
- else if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt;
- //otherwise add to WC ...
- else edge.WindCnt = e->WindCnt + edge.WindDelta;
- }
- edge.WindCnt2 = e->WindCnt2;
- e = e->NextInAEL; //ie get ready to calc WindCnt2
- }
-
- //update WindCnt2 ...
- if (IsEvenOddAltFillType(edge))
- {
- //EvenOdd filling ...
- while (e != &edge)
- {
- if (e->WindDelta != 0)
- edge.WindCnt2 = (edge.WindCnt2 == 0 ? 1 : 0);
- e = e->NextInAEL;
- }
- } else
- {
- //nonZero, Positive or Negative filling ...
- while ( e != &edge )
- {
- edge.WindCnt2 += e->WindDelta;
- e = e->NextInAEL;
- }
- }
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::IsEvenOddFillType(const TEdge& edge) const
-{
- if (edge.PolyTyp == ptSubject)
- return m_SubjFillType == pftEvenOdd; else
- return m_ClipFillType == pftEvenOdd;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::IsEvenOddAltFillType(const TEdge& edge) const
-{
- if (edge.PolyTyp == ptSubject)
- return m_ClipFillType == pftEvenOdd; else
- return m_SubjFillType == pftEvenOdd;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::IsContributing(const TEdge& edge) const
-{
- PolyFillType pft, pft2;
- if (edge.PolyTyp == ptSubject)
- {
- pft = m_SubjFillType;
- pft2 = m_ClipFillType;
- } else
- {
- pft = m_ClipFillType;
- pft2 = m_SubjFillType;
- }
-
- switch(pft)
- {
- case pftEvenOdd:
- //return false if a subj line has been flagged as inside a subj polygon
- if (edge.WindDelta == 0 && edge.WindCnt != 1) return false;
- break;
- case pftNonZero:
- if (Abs(edge.WindCnt) != 1) return false;
- break;
- case pftPositive:
- if (edge.WindCnt != 1) return false;
- break;
- default: //pftNegative
- if (edge.WindCnt != -1) return false;
- }
-
- switch(m_ClipType)
- {
- case ctIntersection:
- switch(pft2)
- {
- case pftEvenOdd:
- case pftNonZero:
- return (edge.WindCnt2 != 0);
- case pftPositive:
- return (edge.WindCnt2 > 0);
- default:
- return (edge.WindCnt2 < 0);
- }
- break;
- case ctUnion:
- switch(pft2)
- {
- case pftEvenOdd:
- case pftNonZero:
- return (edge.WindCnt2 == 0);
- case pftPositive:
- return (edge.WindCnt2 <= 0);
- default:
- return (edge.WindCnt2 >= 0);
- }
- break;
- case ctDifference:
- if (edge.PolyTyp == ptSubject)
- switch(pft2)
- {
- case pftEvenOdd:
- case pftNonZero:
- return (edge.WindCnt2 == 0);
- case pftPositive:
- return (edge.WindCnt2 <= 0);
- default:
- return (edge.WindCnt2 >= 0);
- }
- else
- switch(pft2)
- {
- case pftEvenOdd:
- case pftNonZero:
- return (edge.WindCnt2 != 0);
- case pftPositive:
- return (edge.WindCnt2 > 0);
- default:
- return (edge.WindCnt2 < 0);
- }
- break;
- case ctXor:
- if (edge.WindDelta == 0) //XOr always contributing unless open
- switch(pft2)
- {
- case pftEvenOdd:
- case pftNonZero:
- return (edge.WindCnt2 == 0);
- case pftPositive:
- return (edge.WindCnt2 <= 0);
- default:
- return (edge.WindCnt2 >= 0);
- }
- else
- return true;
- break;
- default:
- return true;
- }
-}
-//------------------------------------------------------------------------------
-
-OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
-{
- OutPt* result;
- TEdge *e, *prevE;
- if (IsHorizontal(*e2) || ( e1->Dx > e2->Dx ))
- {
- result = AddOutPt(e1, Pt);
- e2->OutIdx = e1->OutIdx;
- e1->Side = esLeft;
- e2->Side = esRight;
- e = e1;
- if (e->PrevInAEL == e2)
- prevE = e2->PrevInAEL;
- else
- prevE = e->PrevInAEL;
- } else
- {
- result = AddOutPt(e2, Pt);
- e1->OutIdx = e2->OutIdx;
- e1->Side = esRight;
- e2->Side = esLeft;
- e = e2;
- if (e->PrevInAEL == e1)
- prevE = e1->PrevInAEL;
- else
- prevE = e->PrevInAEL;
- }
-
- if (prevE && prevE->OutIdx >= 0 && prevE->Top.Y < Pt.Y && e->Top.Y < Pt.Y)
- {
- cInt xPrev = TopX(*prevE, Pt.Y);
- cInt xE = TopX(*e, Pt.Y);
- if (xPrev == xE && (e->WindDelta != 0) && (prevE->WindDelta != 0) &&
- SlopesEqual(IntPoint(xPrev, Pt.Y), prevE->Top, IntPoint(xE, Pt.Y), e->Top, m_UseFullRange))
- {
- OutPt* outPt = AddOutPt(prevE, Pt);
- AddJoin(result, outPt, e->Top);
- }
- }
- return result;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
-{
- AddOutPt( e1, Pt );
- if (e2->WindDelta == 0) AddOutPt(e2, Pt);
- if( e1->OutIdx == e2->OutIdx )
- {
- e1->OutIdx = Unassigned;
- e2->OutIdx = Unassigned;
- }
- else if (e1->OutIdx < e2->OutIdx)
- AppendPolygon(e1, e2);
- else
- AppendPolygon(e2, e1);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddEdgeToSEL(TEdge *edge)
-{
- //SEL pointers in PEdge are reused to build a list of horizontal edges.
- //However, we don't need to worry about order with horizontal edge processing.
- if( !m_SortedEdges )
- {
- m_SortedEdges = edge;
- edge->PrevInSEL = 0;
- edge->NextInSEL = 0;
- }
- else
- {
- edge->NextInSEL = m_SortedEdges;
- edge->PrevInSEL = 0;
- m_SortedEdges->PrevInSEL = edge;
- m_SortedEdges = edge;
- }
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::PopEdgeFromSEL(TEdge *&edge)
-{
- if (!m_SortedEdges) return false;
- edge = m_SortedEdges;
- DeleteFromSEL(m_SortedEdges);
- return true;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::CopyAELToSEL()
-{
- TEdge* e = m_ActiveEdges;
- m_SortedEdges = e;
- while ( e )
- {
- e->PrevInSEL = e->PrevInAEL;
- e->NextInSEL = e->NextInAEL;
- e = e->NextInAEL;
- }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint OffPt)
-{
- Join* j = new Join;
- j->OutPt1 = op1;
- j->OutPt2 = op2;
- j->OffPt = OffPt;
- m_Joins.push_back(j);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ClearJoins()
-{
- for (JoinList::size_type i = 0; i < m_Joins.size(); i++)
- delete m_Joins[i];
- m_Joins.resize(0);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ClearGhostJoins()
-{
- for (JoinList::size_type i = 0; i < m_GhostJoins.size(); i++)
- delete m_GhostJoins[i];
- m_GhostJoins.resize(0);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddGhostJoin(OutPt *op, const IntPoint OffPt)
-{
- Join* j = new Join;
- j->OutPt1 = op;
- j->OutPt2 = 0;
- j->OffPt = OffPt;
- m_GhostJoins.push_back(j);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::InsertLocalMinimaIntoAEL(const cInt botY)
-{
- const LocalMinimum *lm;
- while (PopLocalMinima(botY, lm))
- {
- TEdge* lb = lm->LeftBound;
- TEdge* rb = lm->RightBound;
-
- OutPt *Op1 = 0;
- if (!lb)
- {
- //nb: don't insert LB into either AEL or SEL
- InsertEdgeIntoAEL(rb, 0);
- SetWindingCount(*rb);
- if (IsContributing(*rb))
- Op1 = AddOutPt(rb, rb->Bot);
- }
- else if (!rb)
- {
- InsertEdgeIntoAEL(lb, 0);
- SetWindingCount(*lb);
- if (IsContributing(*lb))
- Op1 = AddOutPt(lb, lb->Bot);
- InsertScanbeam(lb->Top.Y);
- }
- else
- {
- InsertEdgeIntoAEL(lb, 0);
- InsertEdgeIntoAEL(rb, lb);
- SetWindingCount( *lb );
- rb->WindCnt = lb->WindCnt;
- rb->WindCnt2 = lb->WindCnt2;
- if (IsContributing(*lb))
- Op1 = AddLocalMinPoly(lb, rb, lb->Bot);
- InsertScanbeam(lb->Top.Y);
- }
-
- if (rb)
- {
- if (IsHorizontal(*rb))
- {
- AddEdgeToSEL(rb);
- if (rb->NextInLML)
- InsertScanbeam(rb->NextInLML->Top.Y);
- }
- else InsertScanbeam( rb->Top.Y );
- }
-
- if (!lb || !rb) continue;
-
- //if any output polygons share an edge, they'll need joining later ...
- if (Op1 && IsHorizontal(*rb) &&
- m_GhostJoins.size() > 0 && (rb->WindDelta != 0))
- {
- for (JoinList::size_type i = 0; i < m_GhostJoins.size(); ++i)
- {
- Join* jr = m_GhostJoins[i];
- //if the horizontal Rb and a 'ghost' horizontal overlap, then convert
- //the 'ghost' join to a real join ready for later ...
- if (HorzSegmentsOverlap(jr->OutPt1->Pt.X, jr->OffPt.X, rb->Bot.X, rb->Top.X))
- AddJoin(jr->OutPt1, Op1, jr->OffPt);
- }
- }
-
- if (lb->OutIdx >= 0 && lb->PrevInAEL &&
- lb->PrevInAEL->Curr.X == lb->Bot.X &&
- lb->PrevInAEL->OutIdx >= 0 &&
- SlopesEqual(lb->PrevInAEL->Bot, lb->PrevInAEL->Top, lb->Curr, lb->Top, m_UseFullRange) &&
- (lb->WindDelta != 0) && (lb->PrevInAEL->WindDelta != 0))
- {
- OutPt *Op2 = AddOutPt(lb->PrevInAEL, lb->Bot);
- AddJoin(Op1, Op2, lb->Top);
- }
-
- if(lb->NextInAEL != rb)
- {
-
- if (rb->OutIdx >= 0 && rb->PrevInAEL->OutIdx >= 0 &&
- SlopesEqual(rb->PrevInAEL->Curr, rb->PrevInAEL->Top, rb->Curr, rb->Top, m_UseFullRange) &&
- (rb->WindDelta != 0) && (rb->PrevInAEL->WindDelta != 0))
- {
- OutPt *Op2 = AddOutPt(rb->PrevInAEL, rb->Bot);
- AddJoin(Op1, Op2, rb->Top);
- }
-
- TEdge* e = lb->NextInAEL;
- if (e)
- {
- while( e != rb )
- {
- //nb: For calculating winding counts etc, IntersectEdges() assumes
- //that param1 will be to the Right of param2 ABOVE the intersection ...
- IntersectEdges(rb , e , lb->Curr); //order important here
- e = e->NextInAEL;
- }
- }
- }
-
- }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DeleteFromSEL(TEdge *e)
-{
- TEdge* SelPrev = e->PrevInSEL;
- TEdge* SelNext = e->NextInSEL;
- if( !SelPrev && !SelNext && (e != m_SortedEdges) ) return; //already deleted
- if( SelPrev ) SelPrev->NextInSEL = SelNext;
- else m_SortedEdges = SelNext;
- if( SelNext ) SelNext->PrevInSEL = SelPrev;
- e->NextInSEL = 0;
- e->PrevInSEL = 0;
-}
-//------------------------------------------------------------------------------
-
-#ifdef use_xyz
-void Clipper::SetZ(IntPoint& pt, TEdge& e1, TEdge& e2)
-{
- if (pt.Z != 0 || !m_ZFill) return;
- else if (pt == e1.Bot) pt.Z = e1.Bot.Z;
- else if (pt == e1.Top) pt.Z = e1.Top.Z;
- else if (pt == e2.Bot) pt.Z = e2.Bot.Z;
- else if (pt == e2.Top) pt.Z = e2.Top.Z;
- else (*m_ZFill)(e1.Bot, e1.Top, e2.Bot, e2.Top, pt);
-}
-//------------------------------------------------------------------------------
-#endif
-
-void Clipper::IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &Pt)
-{
- bool e1Contributing = ( e1->OutIdx >= 0 );
- bool e2Contributing = ( e2->OutIdx >= 0 );
-
-#ifdef use_xyz
- SetZ(Pt, *e1, *e2);
-#endif
-
-#ifdef use_lines
- //if either edge is on an OPEN path ...
- if (e1->WindDelta == 0 || e2->WindDelta == 0)
- {
- //ignore subject-subject open path intersections UNLESS they
- //are both open paths, AND they are both 'contributing maximas' ...
- if (e1->WindDelta == 0 && e2->WindDelta == 0) return;
-
- //if intersecting a subj line with a subj poly ...
- else if (e1->PolyTyp == e2->PolyTyp &&
- e1->WindDelta != e2->WindDelta && m_ClipType == ctUnion)
- {
- if (e1->WindDelta == 0)
- {
- if (e2Contributing)
- {
- AddOutPt(e1, Pt);
- if (e1Contributing) e1->OutIdx = Unassigned;
- }
- }
- else
- {
- if (e1Contributing)
- {
- AddOutPt(e2, Pt);
- if (e2Contributing) e2->OutIdx = Unassigned;
- }
- }
- }
- else if (e1->PolyTyp != e2->PolyTyp)
- {
- //toggle subj open path OutIdx on/off when Abs(clip.WndCnt) == 1 ...
- if ((e1->WindDelta == 0) && abs(e2->WindCnt) == 1 &&
- (m_ClipType != ctUnion || e2->WindCnt2 == 0))
- {
- AddOutPt(e1, Pt);
- if (e1Contributing) e1->OutIdx = Unassigned;
- }
- else if ((e2->WindDelta == 0) && (abs(e1->WindCnt) == 1) &&
- (m_ClipType != ctUnion || e1->WindCnt2 == 0))
- {
- AddOutPt(e2, Pt);
- if (e2Contributing) e2->OutIdx = Unassigned;
- }
- }
- return;
- }
-#endif
-
- //update winding counts...
- //assumes that e1 will be to the Right of e2 ABOVE the intersection
- if ( e1->PolyTyp == e2->PolyTyp )
- {
- if ( IsEvenOddFillType( *e1) )
- {
- int oldE1WindCnt = e1->WindCnt;
- e1->WindCnt = e2->WindCnt;
- e2->WindCnt = oldE1WindCnt;
- } else
- {
- if (e1->WindCnt + e2->WindDelta == 0 ) e1->WindCnt = -e1->WindCnt;
- else e1->WindCnt += e2->WindDelta;
- if ( e2->WindCnt - e1->WindDelta == 0 ) e2->WindCnt = -e2->WindCnt;
- else e2->WindCnt -= e1->WindDelta;
- }
- } else
- {
- if (!IsEvenOddFillType(*e2)) e1->WindCnt2 += e2->WindDelta;
- else e1->WindCnt2 = ( e1->WindCnt2 == 0 ) ? 1 : 0;
- if (!IsEvenOddFillType(*e1)) e2->WindCnt2 -= e1->WindDelta;
- else e2->WindCnt2 = ( e2->WindCnt2 == 0 ) ? 1 : 0;
- }
-
- PolyFillType e1FillType, e2FillType, e1FillType2, e2FillType2;
- if (e1->PolyTyp == ptSubject)
- {
- e1FillType = m_SubjFillType;
- e1FillType2 = m_ClipFillType;
- } else
- {
- e1FillType = m_ClipFillType;
- e1FillType2 = m_SubjFillType;
- }
- if (e2->PolyTyp == ptSubject)
- {
- e2FillType = m_SubjFillType;
- e2FillType2 = m_ClipFillType;
- } else
- {
- e2FillType = m_ClipFillType;
- e2FillType2 = m_SubjFillType;
- }
-
- cInt e1Wc, e2Wc;
- switch (e1FillType)
- {
- case pftPositive: e1Wc = e1->WindCnt; break;
- case pftNegative: e1Wc = -e1->WindCnt; break;
- default: e1Wc = Abs(e1->WindCnt);
- }
- switch(e2FillType)
- {
- case pftPositive: e2Wc = e2->WindCnt; break;
- case pftNegative: e2Wc = -e2->WindCnt; break;
- default: e2Wc = Abs(e2->WindCnt);
- }
-
- if ( e1Contributing && e2Contributing )
- {
- if ((e1Wc != 0 && e1Wc != 1) || (e2Wc != 0 && e2Wc != 1) ||
- (e1->PolyTyp != e2->PolyTyp && m_ClipType != ctXor) )
- {
- AddLocalMaxPoly(e1, e2, Pt);
- }
- else
- {
- AddOutPt(e1, Pt);
- AddOutPt(e2, Pt);
- SwapSides( *e1 , *e2 );
- SwapPolyIndexes( *e1 , *e2 );
- }
- }
- else if ( e1Contributing )
- {
- if (e2Wc == 0 || e2Wc == 1)
- {
- AddOutPt(e1, Pt);
- SwapSides(*e1, *e2);
- SwapPolyIndexes(*e1, *e2);
- }
- }
- else if ( e2Contributing )
- {
- if (e1Wc == 0 || e1Wc == 1)
- {
- AddOutPt(e2, Pt);
- SwapSides(*e1, *e2);
- SwapPolyIndexes(*e1, *e2);
- }
- }
- else if ( (e1Wc == 0 || e1Wc == 1) && (e2Wc == 0 || e2Wc == 1))
- {
- //neither edge is currently contributing ...
-
- cInt e1Wc2, e2Wc2;
- switch (e1FillType2)
- {
- case pftPositive: e1Wc2 = e1->WindCnt2; break;
- case pftNegative : e1Wc2 = -e1->WindCnt2; break;
- default: e1Wc2 = Abs(e1->WindCnt2);
- }
- switch (e2FillType2)
- {
- case pftPositive: e2Wc2 = e2->WindCnt2; break;
- case pftNegative: e2Wc2 = -e2->WindCnt2; break;
- default: e2Wc2 = Abs(e2->WindCnt2);
- }
-
- if (e1->PolyTyp != e2->PolyTyp)
- {
- AddLocalMinPoly(e1, e2, Pt);
- }
- else if (e1Wc == 1 && e2Wc == 1)
- switch( m_ClipType ) {
- case ctIntersection:
- if (e1Wc2 > 0 && e2Wc2 > 0)
- AddLocalMinPoly(e1, e2, Pt);
- break;
- case ctUnion:
- if ( e1Wc2 <= 0 && e2Wc2 <= 0 )
- AddLocalMinPoly(e1, e2, Pt);
- break;
- case ctDifference:
- if (((e1->PolyTyp == ptClip) && (e1Wc2 > 0) && (e2Wc2 > 0)) ||
- ((e1->PolyTyp == ptSubject) && (e1Wc2 <= 0) && (e2Wc2 <= 0)))
- AddLocalMinPoly(e1, e2, Pt);
- break;
- case ctXor:
- AddLocalMinPoly(e1, e2, Pt);
- }
- else
- SwapSides( *e1, *e2 );
- }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::SetHoleState(TEdge *e, OutRec *outrec)
-{
- TEdge *e2 = e->PrevInAEL;
- TEdge *eTmp = 0;
- while (e2)
- {
- if (e2->OutIdx >= 0 && e2->WindDelta != 0)
- {
- if (!eTmp) eTmp = e2;
- else if (eTmp->OutIdx == e2->OutIdx) eTmp = 0;
- }
- e2 = e2->PrevInAEL;
- }
- if (!eTmp)
- {
- outrec->FirstLeft = 0;
- outrec->IsHole = false;
- }
- else
- {
- outrec->FirstLeft = m_PolyOuts[eTmp->OutIdx];
- outrec->IsHole = !outrec->FirstLeft->IsHole;
- }
-}
-//------------------------------------------------------------------------------
-
-OutRec* GetLowermostRec(OutRec *outRec1, OutRec *outRec2)
-{
- //work out which polygon fragment has the correct hole state ...
- if (!outRec1->BottomPt)
- outRec1->BottomPt = GetBottomPt(outRec1->Pts);
- if (!outRec2->BottomPt)
- outRec2->BottomPt = GetBottomPt(outRec2->Pts);
- OutPt *OutPt1 = outRec1->BottomPt;
- OutPt *OutPt2 = outRec2->BottomPt;
- if (OutPt1->Pt.Y > OutPt2->Pt.Y) return outRec1;
- else if (OutPt1->Pt.Y < OutPt2->Pt.Y) return outRec2;
- else if (OutPt1->Pt.X < OutPt2->Pt.X) return outRec1;
- else if (OutPt1->Pt.X > OutPt2->Pt.X) return outRec2;
- else if (OutPt1->Next == OutPt1) return outRec2;
- else if (OutPt2->Next == OutPt2) return outRec1;
- else if (FirstIsBottomPt(OutPt1, OutPt2)) return outRec1;
- else return outRec2;
-}
-//------------------------------------------------------------------------------
-
-bool OutRec1RightOfOutRec2(OutRec* outRec1, OutRec* outRec2)
-{
- do
- {
- outRec1 = outRec1->FirstLeft;
- if (outRec1 == outRec2) return true;
- } while (outRec1);
- return false;
-}
-//------------------------------------------------------------------------------
-
-OutRec* Clipper::GetOutRec(int Idx)
-{
- OutRec* outrec = m_PolyOuts[Idx];
- while (outrec != m_PolyOuts[outrec->Idx])
- outrec = m_PolyOuts[outrec->Idx];
- return outrec;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AppendPolygon(TEdge *e1, TEdge *e2)
-{
- //get the start and ends of both output polygons ...
- OutRec *outRec1 = m_PolyOuts[e1->OutIdx];
- OutRec *outRec2 = m_PolyOuts[e2->OutIdx];
-
- OutRec *holeStateRec;
- if (OutRec1RightOfOutRec2(outRec1, outRec2))
- holeStateRec = outRec2;
- else if (OutRec1RightOfOutRec2(outRec2, outRec1))
- holeStateRec = outRec1;
- else
- holeStateRec = GetLowermostRec(outRec1, outRec2);
-
- //get the start and ends of both output polygons and
- //join e2 poly onto e1 poly and delete pointers to e2 ...
-
- OutPt* p1_lft = outRec1->Pts;
- OutPt* p1_rt = p1_lft->Prev;
- OutPt* p2_lft = outRec2->Pts;
- OutPt* p2_rt = p2_lft->Prev;
-
- //join e2 poly onto e1 poly and delete pointers to e2 ...
- if( e1->Side == esLeft )
- {
- if( e2->Side == esLeft )
- {
- //z y x a b c
- ReversePolyPtLinks(p2_lft);
- p2_lft->Next = p1_lft;
- p1_lft->Prev = p2_lft;
- p1_rt->Next = p2_rt;
- p2_rt->Prev = p1_rt;
- outRec1->Pts = p2_rt;
- } else
- {
- //x y z a b c
- p2_rt->Next = p1_lft;
- p1_lft->Prev = p2_rt;
- p2_lft->Prev = p1_rt;
- p1_rt->Next = p2_lft;
- outRec1->Pts = p2_lft;
- }
- } else
- {
- if( e2->Side == esRight )
- {
- //a b c z y x
- ReversePolyPtLinks(p2_lft);
- p1_rt->Next = p2_rt;
- p2_rt->Prev = p1_rt;
- p2_lft->Next = p1_lft;
- p1_lft->Prev = p2_lft;
- } else
- {
- //a b c x y z
- p1_rt->Next = p2_lft;
- p2_lft->Prev = p1_rt;
- p1_lft->Prev = p2_rt;
- p2_rt->Next = p1_lft;
- }
- }
-
- outRec1->BottomPt = 0;
- if (holeStateRec == outRec2)
- {
- if (outRec2->FirstLeft != outRec1)
- outRec1->FirstLeft = outRec2->FirstLeft;
- outRec1->IsHole = outRec2->IsHole;
- }
- outRec2->Pts = 0;
- outRec2->BottomPt = 0;
- outRec2->FirstLeft = outRec1;
-
- int OKIdx = e1->OutIdx;
- int ObsoleteIdx = e2->OutIdx;
-
- e1->OutIdx = Unassigned; //nb: safe because we only get here via AddLocalMaxPoly
- e2->OutIdx = Unassigned;
-
- TEdge* e = m_ActiveEdges;
- while( e )
- {
- if( e->OutIdx == ObsoleteIdx )
- {
- e->OutIdx = OKIdx;
- e->Side = e1->Side;
- break;
- }
- e = e->NextInAEL;
- }
-
- outRec2->Idx = outRec1->Idx;
-}
-//------------------------------------------------------------------------------
-
-OutPt* Clipper::AddOutPt(TEdge *e, const IntPoint &pt)
-{
- if( e->OutIdx < 0 )
- {
- OutRec *outRec = CreateOutRec();
- outRec->IsOpen = (e->WindDelta == 0);
- OutPt* newOp = new OutPt;
- outRec->Pts = newOp;
- newOp->Idx = outRec->Idx;
- newOp->Pt = pt;
- newOp->Next = newOp;
- newOp->Prev = newOp;
- if (!outRec->IsOpen)
- SetHoleState(e, outRec);
- e->OutIdx = outRec->Idx;
- return newOp;
- } else
- {
- OutRec *outRec = m_PolyOuts[e->OutIdx];
- //OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most'
- OutPt* op = outRec->Pts;
-
- bool ToFront = (e->Side == esLeft);
- if (ToFront && (pt == op->Pt)) return op;
- else if (!ToFront && (pt == op->Prev->Pt)) return op->Prev;
-
- OutPt* newOp = new OutPt;
- newOp->Idx = outRec->Idx;
- newOp->Pt = pt;
- newOp->Next = op;
- newOp->Prev = op->Prev;
- newOp->Prev->Next = newOp;
- op->Prev = newOp;
- if (ToFront) outRec->Pts = newOp;
- return newOp;
- }
-}
-//------------------------------------------------------------------------------
-
-OutPt* Clipper::GetLastOutPt(TEdge *e)
-{
- OutRec *outRec = m_PolyOuts[e->OutIdx];
- if (e->Side == esLeft)
- return outRec->Pts;
- else
- return outRec->Pts->Prev;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ProcessHorizontals()
-{
- TEdge* horzEdge;
- while (PopEdgeFromSEL(horzEdge))
- ProcessHorizontal(horzEdge);
-}
-//------------------------------------------------------------------------------
-
-inline bool IsMinima(TEdge *e)
-{
- return e && (e->Prev->NextInLML != e) && (e->Next->NextInLML != e);
-}
-//------------------------------------------------------------------------------
-
-inline bool IsMaxima(TEdge *e, const cInt Y)
-{
- return e && e->Top.Y == Y && !e->NextInLML;
-}
-//------------------------------------------------------------------------------
-
-inline bool IsIntermediate(TEdge *e, const cInt Y)
-{
- return e->Top.Y == Y && e->NextInLML;
-}
-//------------------------------------------------------------------------------
-
-TEdge *GetMaximaPair(TEdge *e)
-{
- if ((e->Next->Top == e->Top) && !e->Next->NextInLML)
- return e->Next;
- else if ((e->Prev->Top == e->Top) && !e->Prev->NextInLML)
- return e->Prev;
- else return 0;
-}
-//------------------------------------------------------------------------------
-
-TEdge *GetMaximaPairEx(TEdge *e)
-{
- //as GetMaximaPair() but returns 0 if MaxPair isn't in AEL (unless it's horizontal)
- TEdge* result = GetMaximaPair(e);
- if (result && (result->OutIdx == Skip ||
- (result->NextInAEL == result->PrevInAEL && !IsHorizontal(*result)))) return 0;
- return result;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::SwapPositionsInSEL(TEdge *Edge1, TEdge *Edge2)
-{
- if( !( Edge1->NextInSEL ) && !( Edge1->PrevInSEL ) ) return;
- if( !( Edge2->NextInSEL ) && !( Edge2->PrevInSEL ) ) return;
-
- if( Edge1->NextInSEL == Edge2 )
- {
- TEdge* Next = Edge2->NextInSEL;
- if( Next ) Next->PrevInSEL = Edge1;
- TEdge* Prev = Edge1->PrevInSEL;
- if( Prev ) Prev->NextInSEL = Edge2;
- Edge2->PrevInSEL = Prev;
- Edge2->NextInSEL = Edge1;
- Edge1->PrevInSEL = Edge2;
- Edge1->NextInSEL = Next;
- }
- else if( Edge2->NextInSEL == Edge1 )
- {
- TEdge* Next = Edge1->NextInSEL;
- if( Next ) Next->PrevInSEL = Edge2;
- TEdge* Prev = Edge2->PrevInSEL;
- if( Prev ) Prev->NextInSEL = Edge1;
- Edge1->PrevInSEL = Prev;
- Edge1->NextInSEL = Edge2;
- Edge2->PrevInSEL = Edge1;
- Edge2->NextInSEL = Next;
- }
- else
- {
- TEdge* Next = Edge1->NextInSEL;
- TEdge* Prev = Edge1->PrevInSEL;
- Edge1->NextInSEL = Edge2->NextInSEL;
- if( Edge1->NextInSEL ) Edge1->NextInSEL->PrevInSEL = Edge1;
- Edge1->PrevInSEL = Edge2->PrevInSEL;
- if( Edge1->PrevInSEL ) Edge1->PrevInSEL->NextInSEL = Edge1;
- Edge2->NextInSEL = Next;
- if( Edge2->NextInSEL ) Edge2->NextInSEL->PrevInSEL = Edge2;
- Edge2->PrevInSEL = Prev;
- if( Edge2->PrevInSEL ) Edge2->PrevInSEL->NextInSEL = Edge2;
- }
-
- if( !Edge1->PrevInSEL ) m_SortedEdges = Edge1;
- else if( !Edge2->PrevInSEL ) m_SortedEdges = Edge2;
-}
-//------------------------------------------------------------------------------
-
-TEdge* GetNextInAEL(TEdge *e, Direction dir)
-{
- return dir == dLeftToRight ? e->NextInAEL : e->PrevInAEL;
-}
-//------------------------------------------------------------------------------
-
-void GetHorzDirection(TEdge& HorzEdge, Direction& Dir, cInt& Left, cInt& Right)
-{
- if (HorzEdge.Bot.X < HorzEdge.Top.X)
- {
- Left = HorzEdge.Bot.X;
- Right = HorzEdge.Top.X;
- Dir = dLeftToRight;
- } else
- {
- Left = HorzEdge.Top.X;
- Right = HorzEdge.Bot.X;
- Dir = dRightToLeft;
- }
-}
-//------------------------------------------------------------------------
-
-/*******************************************************************************
-* Notes: Horizontal edges (HEs) at scanline intersections (ie at the Top or *
-* Bottom of a scanbeam) are processed as if layered. The order in which HEs *
-* are processed doesn't matter. HEs intersect with other HE Bot.Xs only [#] *
-* (or they could intersect with Top.Xs only, ie EITHER Bot.Xs OR Top.Xs), *
-* and with other non-horizontal edges [*]. Once these intersections are *
-* processed, intermediate HEs then 'promote' the Edge above (NextInLML) into *
-* the AEL. These 'promoted' edges may in turn intersect [%] with other HEs. *
-*******************************************************************************/
-
-void Clipper::ProcessHorizontal(TEdge *horzEdge)
-{
- Direction dir;
- cInt horzLeft, horzRight;
- bool IsOpen = (horzEdge->WindDelta == 0);
-
- GetHorzDirection(*horzEdge, dir, horzLeft, horzRight);
-
- TEdge* eLastHorz = horzEdge, *eMaxPair = 0;
- while (eLastHorz->NextInLML && IsHorizontal(*eLastHorz->NextInLML))
- eLastHorz = eLastHorz->NextInLML;
- if (!eLastHorz->NextInLML)
- eMaxPair = GetMaximaPair(eLastHorz);
-
- MaximaList::const_iterator maxIt;
- MaximaList::const_reverse_iterator maxRit;
- if (m_Maxima.size() > 0)
- {
- //get the first maxima in range (X) ...
- if (dir == dLeftToRight)
- {
- maxIt = m_Maxima.begin();
- while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) maxIt++;
- if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.X)
- maxIt = m_Maxima.end();
- }
- else
- {
- maxRit = m_Maxima.rbegin();
- while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.X) maxRit++;
- if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.X)
- maxRit = m_Maxima.rend();
- }
- }
-
- OutPt* op1 = 0;
-
- for (;;) //loop through consec. horizontal edges
- {
-
- bool IsLastHorz = (horzEdge == eLastHorz);
- TEdge* e = GetNextInAEL(horzEdge, dir);
- while(e)
- {
-
- //this code block inserts extra coords into horizontal edges (in output
- //polygons) whereever maxima touch these horizontal edges. This helps
- //'simplifying' polygons (ie if the Simplify property is set).
- if (m_Maxima.size() > 0)
- {
- if (dir == dLeftToRight)
- {
- while (maxIt != m_Maxima.end() && *maxIt < e->Curr.X)
- {
- if (horzEdge->OutIdx >= 0 && !IsOpen)
- AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.Y));
- maxIt++;
- }
- }
- else
- {
- while (maxRit != m_Maxima.rend() && *maxRit > e->Curr.X)
- {
- if (horzEdge->OutIdx >= 0 && !IsOpen)
- AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.Y));
- maxRit++;
- }
- }
- };
-
- if ((dir == dLeftToRight && e->Curr.X > horzRight) ||
- (dir == dRightToLeft && e->Curr.X < horzLeft)) break;
-
- //Also break if we've got to the end of an intermediate horizontal edge ...
- //nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal.
- if (e->Curr.X == horzEdge->Top.X && horzEdge->NextInLML &&
- e->Dx < horzEdge->NextInLML->Dx) break;
-
- if (horzEdge->OutIdx >= 0 && !IsOpen) //note: may be done multiple times
- {
-#ifdef use_xyz
- if (dir == dLeftToRight) SetZ(e->Curr, *horzEdge, *e);
- else SetZ(e->Curr, *e, *horzEdge);
-#endif
- op1 = AddOutPt(horzEdge, e->Curr);
- TEdge* eNextHorz = m_SortedEdges;
- while (eNextHorz)
- {
- if (eNextHorz->OutIdx >= 0 &&
- HorzSegmentsOverlap(horzEdge->Bot.X,
- horzEdge->Top.X, eNextHorz->Bot.X, eNextHorz->Top.X))
- {
- OutPt* op2 = GetLastOutPt(eNextHorz);
- AddJoin(op2, op1, eNextHorz->Top);
- }
- eNextHorz = eNextHorz->NextInSEL;
- }
- AddGhostJoin(op1, horzEdge->Bot);
- }
-
- //OK, so far we're still in range of the horizontal Edge but make sure
- //we're at the last of consec. horizontals when matching with eMaxPair
- if(e == eMaxPair && IsLastHorz)
- {
- if (horzEdge->OutIdx >= 0)
- AddLocalMaxPoly(horzEdge, eMaxPair, horzEdge->Top);
- DeleteFromAEL(horzEdge);
- DeleteFromAEL(eMaxPair);
- return;
- }
-
- if(dir == dLeftToRight)
- {
- IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y);
- IntersectEdges(horzEdge, e, Pt);
- }
- else
- {
- IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y);
- IntersectEdges( e, horzEdge, Pt);
- }
- TEdge* eNext = GetNextInAEL(e, dir);
- SwapPositionsInAEL( horzEdge, e );
- e = eNext;
- } //end while(e)
-
- //Break out of loop if HorzEdge.NextInLML is not also horizontal ...
- if (!horzEdge->NextInLML || !IsHorizontal(*horzEdge->NextInLML)) break;
-
- UpdateEdgeIntoAEL(horzEdge);
- if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Bot);
- GetHorzDirection(*horzEdge, dir, horzLeft, horzRight);
-
- } //end for (;;)
-
- if (horzEdge->OutIdx >= 0 && !op1)
- {
- op1 = GetLastOutPt(horzEdge);
- TEdge* eNextHorz = m_SortedEdges;
- while (eNextHorz)
- {
- if (eNextHorz->OutIdx >= 0 &&
- HorzSegmentsOverlap(horzEdge->Bot.X,
- horzEdge->Top.X, eNextHorz->Bot.X, eNextHorz->Top.X))
- {
- OutPt* op2 = GetLastOutPt(eNextHorz);
- AddJoin(op2, op1, eNextHorz->Top);
- }
- eNextHorz = eNextHorz->NextInSEL;
- }
- AddGhostJoin(op1, horzEdge->Top);
- }
-
- if (horzEdge->NextInLML)
- {
- if(horzEdge->OutIdx >= 0)
- {
- op1 = AddOutPt( horzEdge, horzEdge->Top);
- UpdateEdgeIntoAEL(horzEdge);
- if (horzEdge->WindDelta == 0) return;
- //nb: HorzEdge is no longer horizontal here
- TEdge* ePrev = horzEdge->PrevInAEL;
- TEdge* eNext = horzEdge->NextInAEL;
- if (ePrev && ePrev->Curr.X == horzEdge->Bot.X &&
- ePrev->Curr.Y == horzEdge->Bot.Y && ePrev->WindDelta != 0 &&
- (ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y &&
- SlopesEqual(*horzEdge, *ePrev, m_UseFullRange)))
- {
- OutPt* op2 = AddOutPt(ePrev, horzEdge->Bot);
- AddJoin(op1, op2, horzEdge->Top);
- }
- else if (eNext && eNext->Curr.X == horzEdge->Bot.X &&
- eNext->Curr.Y == horzEdge->Bot.Y && eNext->WindDelta != 0 &&
- eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y &&
- SlopesEqual(*horzEdge, *eNext, m_UseFullRange))
- {
- OutPt* op2 = AddOutPt(eNext, horzEdge->Bot);
- AddJoin(op1, op2, horzEdge->Top);
- }
- }
- else
- UpdateEdgeIntoAEL(horzEdge);
- }
- else
- {
- if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Top);
- DeleteFromAEL(horzEdge);
- }
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::ProcessIntersections(const cInt topY)
-{
- if( !m_ActiveEdges ) return true;
- try {
- BuildIntersectList(topY);
- size_t IlSize = m_IntersectList.size();
- if (IlSize == 0) return true;
- if (IlSize == 1 || FixupIntersectionOrder()) ProcessIntersectList();
- else return false;
- }
- catch(...)
- {
- m_SortedEdges = 0;
- DisposeIntersectNodes();
- throw clipperException("ProcessIntersections error");
- }
- m_SortedEdges = 0;
- return true;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DisposeIntersectNodes()
-{
- for (size_t i = 0; i < m_IntersectList.size(); ++i )
- delete m_IntersectList[i];
- m_IntersectList.clear();
-}
-//------------------------------------------------------------------------------
-
-void Clipper::BuildIntersectList(const cInt topY)
-{
- if ( !m_ActiveEdges ) return;
-
- //prepare for sorting ...
- TEdge* e = m_ActiveEdges;
- m_SortedEdges = e;
- while( e )
- {
- e->PrevInSEL = e->PrevInAEL;
- e->NextInSEL = e->NextInAEL;
- e->Curr.X = TopX( *e, topY );
- e = e->NextInAEL;
- }
-
- //bubblesort ...
- bool isModified;
- do
- {
- isModified = false;
- e = m_SortedEdges;
- while( e->NextInSEL )
- {
- TEdge *eNext = e->NextInSEL;
- IntPoint Pt;
- if(e->Curr.X > eNext->Curr.X)
- {
- IntersectPoint(*e, *eNext, Pt);
- if (Pt.Y < topY) Pt = IntPoint(TopX(*e, topY), topY);
- IntersectNode * newNode = new IntersectNode;
- newNode->Edge1 = e;
- newNode->Edge2 = eNext;
- newNode->Pt = Pt;
- m_IntersectList.push_back(newNode);
-
- SwapPositionsInSEL(e, eNext);
- isModified = true;
- }
- else
- e = eNext;
- }
- if( e->PrevInSEL ) e->PrevInSEL->NextInSEL = 0;
- else break;
- }
- while ( isModified );
- m_SortedEdges = 0; //important
-}
-//------------------------------------------------------------------------------
-
-
-void Clipper::ProcessIntersectList()
-{
- for (size_t i = 0; i < m_IntersectList.size(); ++i)
- {
- IntersectNode* iNode = m_IntersectList[i];
- {
- IntersectEdges( iNode->Edge1, iNode->Edge2, iNode->Pt);
- SwapPositionsInAEL( iNode->Edge1 , iNode->Edge2 );
- }
- delete iNode;
- }
- m_IntersectList.clear();
-}
-//------------------------------------------------------------------------------
-
-bool IntersectListSort(IntersectNode* node1, IntersectNode* node2)
-{
- return node2->Pt.Y < node1->Pt.Y;
-}
-//------------------------------------------------------------------------------
-
-inline bool EdgesAdjacent(const IntersectNode &inode)
-{
- return (inode.Edge1->NextInSEL == inode.Edge2) ||
- (inode.Edge1->PrevInSEL == inode.Edge2);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::FixupIntersectionOrder()
-{
- //pre-condition: intersections are sorted Bottom-most first.
- //Now it's crucial that intersections are made only between adjacent edges,
- //so to ensure this the order of intersections may need adjusting ...
- CopyAELToSEL();
- std::sort(m_IntersectList.begin(), m_IntersectList.end(), IntersectListSort);
- size_t cnt = m_IntersectList.size();
- for (size_t i = 0; i < cnt; ++i)
- {
- if (!EdgesAdjacent(*m_IntersectList[i]))
- {
- size_t j = i + 1;
- while (j < cnt && !EdgesAdjacent(*m_IntersectList[j])) j++;
- if (j == cnt) return false;
- std::swap(m_IntersectList[i], m_IntersectList[j]);
- }
- SwapPositionsInSEL(m_IntersectList[i]->Edge1, m_IntersectList[i]->Edge2);
- }
- return true;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DoMaxima(TEdge *e)
-{
- TEdge* eMaxPair = GetMaximaPairEx(e);
- if (!eMaxPair)
- {
- if (e->OutIdx >= 0)
- AddOutPt(e, e->Top);
- DeleteFromAEL(e);
- return;
- }
-
- TEdge* eNext = e->NextInAEL;
- while(eNext && eNext != eMaxPair)
- {
- IntersectEdges(e, eNext, e->Top);
- SwapPositionsInAEL(e, eNext);
- eNext = e->NextInAEL;
- }
-
- if(e->OutIdx == Unassigned && eMaxPair->OutIdx == Unassigned)
- {
- DeleteFromAEL(e);
- DeleteFromAEL(eMaxPair);
- }
- else if( e->OutIdx >= 0 && eMaxPair->OutIdx >= 0 )
- {
- if (e->OutIdx >= 0) AddLocalMaxPoly(e, eMaxPair, e->Top);
- DeleteFromAEL(e);
- DeleteFromAEL(eMaxPair);
- }
-#ifdef use_lines
- else if (e->WindDelta == 0)
- {
- if (e->OutIdx >= 0)
- {
- AddOutPt(e, e->Top);
- e->OutIdx = Unassigned;
- }
- DeleteFromAEL(e);
-
- if (eMaxPair->OutIdx >= 0)
- {
- AddOutPt(eMaxPair, e->Top);
- eMaxPair->OutIdx = Unassigned;
- }
- DeleteFromAEL(eMaxPair);
- }
-#endif
- else throw clipperException("DoMaxima error");
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY)
-{
- TEdge* e = m_ActiveEdges;
- while( e )
- {
- //1. process maxima, treating them as if they're 'bent' horizontal edges,
- // but exclude maxima with horizontal edges. nb: e can't be a horizontal.
- bool IsMaximaEdge = IsMaxima(e, topY);
-
- if(IsMaximaEdge)
- {
- TEdge* eMaxPair = GetMaximaPairEx(e);
- IsMaximaEdge = (!eMaxPair || !IsHorizontal(*eMaxPair));
- }
-
- if(IsMaximaEdge)
- {
- if (m_StrictSimple) m_Maxima.push_back(e->Top.X);
- TEdge* ePrev = e->PrevInAEL;
- DoMaxima(e);
- if( !ePrev ) e = m_ActiveEdges;
- else e = ePrev->NextInAEL;
- }
- else
- {
- //2. promote horizontal edges, otherwise update Curr.X and Curr.Y ...
- if (IsIntermediate(e, topY) && IsHorizontal(*e->NextInLML))
- {
- UpdateEdgeIntoAEL(e);
- if (e->OutIdx >= 0)
- AddOutPt(e, e->Bot);
- AddEdgeToSEL(e);
- }
- else
- {
- e->Curr.X = TopX( *e, topY );
- e->Curr.Y = topY;
-#ifdef use_xyz
- e->Curr.Z = topY == e->Top.Y ? e->Top.Z : (topY == e->Bot.Y ? e->Bot.Z : 0);
-#endif
- }
-
- //When StrictlySimple and 'e' is being touched by another edge, then
- //make sure both edges have a vertex here ...
- if (m_StrictSimple)
- {
- TEdge* ePrev = e->PrevInAEL;
- if ((e->OutIdx >= 0) && (e->WindDelta != 0) && ePrev && (ePrev->OutIdx >= 0) &&
- (ePrev->Curr.X == e->Curr.X) && (ePrev->WindDelta != 0))
- {
- IntPoint pt = e->Curr;
-#ifdef use_xyz
- SetZ(pt, *ePrev, *e);
-#endif
- OutPt* op = AddOutPt(ePrev, pt);
- OutPt* op2 = AddOutPt(e, pt);
- AddJoin(op, op2, pt); //StrictlySimple (type-3) join
- }
- }
-
- e = e->NextInAEL;
- }
- }
-
- //3. Process horizontals at the Top of the scanbeam ...
- m_Maxima.sort();
- ProcessHorizontals();
- m_Maxima.clear();
-
- //4. Promote intermediate vertices ...
- e = m_ActiveEdges;
- while(e)
- {
- if(IsIntermediate(e, topY))
- {
- OutPt* op = 0;
- if( e->OutIdx >= 0 )
- op = AddOutPt(e, e->Top);
- UpdateEdgeIntoAEL(e);
-
- //if output polygons share an edge, they'll need joining later ...
- TEdge* ePrev = e->PrevInAEL;
- TEdge* eNext = e->NextInAEL;
- if (ePrev && ePrev->Curr.X == e->Bot.X &&
- ePrev->Curr.Y == e->Bot.Y && op &&
- ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y &&
- SlopesEqual(e->Curr, e->Top, ePrev->Curr, ePrev->Top, m_UseFullRange) &&
- (e->WindDelta != 0) && (ePrev->WindDelta != 0))
- {
- OutPt* op2 = AddOutPt(ePrev, e->Bot);
- AddJoin(op, op2, e->Top);
- }
- else if (eNext && eNext->Curr.X == e->Bot.X &&
- eNext->Curr.Y == e->Bot.Y && op &&
- eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y &&
- SlopesEqual(e->Curr, e->Top, eNext->Curr, eNext->Top, m_UseFullRange) &&
- (e->WindDelta != 0) && (eNext->WindDelta != 0))
- {
- OutPt* op2 = AddOutPt(eNext, e->Bot);
- AddJoin(op, op2, e->Top);
- }
- }
- e = e->NextInAEL;
- }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixupOutPolyline(OutRec &outrec)
-{
- OutPt *pp = outrec.Pts;
- OutPt *lastPP = pp->Prev;
- while (pp != lastPP)
- {
- pp = pp->Next;
- if (pp->Pt == pp->Prev->Pt)
- {
- if (pp == lastPP) lastPP = pp->Prev;
- OutPt *tmpPP = pp->Prev;
- tmpPP->Next = pp->Next;
- pp->Next->Prev = tmpPP;
- delete pp;
- pp = tmpPP;
- }
- }
-
- if (pp == pp->Prev)
- {
- DisposeOutPts(pp);
- outrec.Pts = 0;
- return;
- }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixupOutPolygon(OutRec &outrec)
-{
- //FixupOutPolygon() - removes duplicate points and simplifies consecutive
- //parallel edges by removing the middle vertex.
- OutPt *lastOK = 0;
- outrec.BottomPt = 0;
- OutPt *pp = outrec.Pts;
- bool preserveCol = m_PreserveCollinear || m_StrictSimple;
-
- for (;;)
- {
- if (pp->Prev == pp || pp->Prev == pp->Next)
- {
- DisposeOutPts(pp);
- outrec.Pts = 0;
- return;
- }
-
- //test for duplicate points and collinear edges ...
- if ((pp->Pt == pp->Next->Pt) || (pp->Pt == pp->Prev->Pt) ||
- (SlopesEqual(pp->Prev->Pt, pp->Pt, pp->Next->Pt, m_UseFullRange) &&
- (!preserveCol || !Pt2IsBetweenPt1AndPt3(pp->Prev->Pt, pp->Pt, pp->Next->Pt))))
- {
- lastOK = 0;
- OutPt *tmp = pp;
- pp->Prev->Next = pp->Next;
- pp->Next->Prev = pp->Prev;
- pp = pp->Prev;
- delete tmp;
- }
- else if (pp == lastOK) break;
- else
- {
- if (!lastOK) lastOK = pp;
- pp = pp->Next;
- }
- }
- outrec.Pts = pp;
-}
-//------------------------------------------------------------------------------
-
-int PointCount(OutPt *Pts)
-{
- if (!Pts) return 0;
- int result = 0;
- OutPt* p = Pts;
- do
- {
- result++;
- p = p->Next;
- }
- while (p != Pts);
- return result;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::BuildResult(Paths &polys)
-{
- polys.reserve(m_PolyOuts.size());
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
- {
- if (!m_PolyOuts[i]->Pts) continue;
- Path pg;
- OutPt* p = m_PolyOuts[i]->Pts->Prev;
- int cnt = PointCount(p);
- if (cnt < 2) continue;
- pg.reserve(cnt);
- for (int i = 0; i < cnt; ++i)
- {
- pg.push_back(p->Pt);
- p = p->Prev;
- }
- polys.push_back(pg);
- }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::BuildResult2(PolyTree& polytree)
-{
- polytree.Clear();
- polytree.AllNodes.reserve(m_PolyOuts.size());
- //add each output polygon/contour to polytree ...
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
- {
- OutRec* outRec = m_PolyOuts[i];
- int cnt = PointCount(outRec->Pts);
- if ((outRec->IsOpen && cnt < 2) || (!outRec->IsOpen && cnt < 3)) continue;
- FixHoleLinkage(*outRec);
- PolyNode* pn = new PolyNode();
- //nb: polytree takes ownership of all the PolyNodes
- polytree.AllNodes.push_back(pn);
- outRec->PolyNd = pn;
- pn->Parent = 0;
- pn->Index = 0;
- pn->Contour.reserve(cnt);
- OutPt *op = outRec->Pts->Prev;
- for (int j = 0; j < cnt; j++)
- {
- pn->Contour.push_back(op->Pt);
- op = op->Prev;
- }
- }
-
- //fixup PolyNode links etc ...
- polytree.Childs.reserve(m_PolyOuts.size());
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
- {
- OutRec* outRec = m_PolyOuts[i];
- if (!outRec->PolyNd) continue;
- if (outRec->IsOpen)
- {
- outRec->PolyNd->m_IsOpen = true;
- polytree.AddChild(*outRec->PolyNd);
- }
- else if (outRec->FirstLeft && outRec->FirstLeft->PolyNd)
- outRec->FirstLeft->PolyNd->AddChild(*outRec->PolyNd);
- else
- polytree.AddChild(*outRec->PolyNd);
- }
-}
-//------------------------------------------------------------------------------
-
-void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2)
-{
- //just swap the contents (because fIntersectNodes is a single-linked-list)
- IntersectNode inode = int1; //gets a copy of Int1
- int1.Edge1 = int2.Edge1;
- int1.Edge2 = int2.Edge2;
- int1.Pt = int2.Pt;
- int2.Edge1 = inode.Edge1;
- int2.Edge2 = inode.Edge2;
- int2.Pt = inode.Pt;
-}
-//------------------------------------------------------------------------------
-
-inline bool E2InsertsBeforeE1(TEdge &e1, TEdge &e2)
-{
- if (e2.Curr.X == e1.Curr.X)
- {
- if (e2.Top.Y > e1.Top.Y)
- return e2.Top.X < TopX(e1, e2.Top.Y);
- else return e1.Top.X > TopX(e2, e1.Top.Y);
- }
- else return e2.Curr.X < e1.Curr.X;
-}
-//------------------------------------------------------------------------------
-
-bool GetOverlap(const cInt a1, const cInt a2, const cInt b1, const cInt b2,
- cInt& Left, cInt& Right)
-{
- if (a1 < a2)
- {
- if (b1 < b2) {Left = std::max(a1,b1); Right = std::min(a2,b2);}
- else {Left = std::max(a1,b2); Right = std::min(a2,b1);}
- }
- else
- {
- if (b1 < b2) {Left = std::max(a2,b1); Right = std::min(a1,b2);}
- else {Left = std::max(a2,b2); Right = std::min(a1,b1);}
- }
- return Left < Right;
-}
-//------------------------------------------------------------------------------
-
-inline void UpdateOutPtIdxs(OutRec& outrec)
-{
- OutPt* op = outrec.Pts;
- do
- {
- op->Idx = outrec.Idx;
- op = op->Prev;
- }
- while(op != outrec.Pts);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge)
-{
- if(!m_ActiveEdges)
- {
- edge->PrevInAEL = 0;
- edge->NextInAEL = 0;
- m_ActiveEdges = edge;
- }
- else if(!startEdge && E2InsertsBeforeE1(*m_ActiveEdges, *edge))
- {
- edge->PrevInAEL = 0;
- edge->NextInAEL = m_ActiveEdges;
- m_ActiveEdges->PrevInAEL = edge;
- m_ActiveEdges = edge;
- }
- else
- {
- if(!startEdge) startEdge = m_ActiveEdges;
- while(startEdge->NextInAEL &&
- !E2InsertsBeforeE1(*startEdge->NextInAEL , *edge))
- startEdge = startEdge->NextInAEL;
- edge->NextInAEL = startEdge->NextInAEL;
- if(startEdge->NextInAEL) startEdge->NextInAEL->PrevInAEL = edge;
- edge->PrevInAEL = startEdge;
- startEdge->NextInAEL = edge;
- }
-}
-//----------------------------------------------------------------------
-
-OutPt* DupOutPt(OutPt* outPt, bool InsertAfter)
-{
- OutPt* result = new OutPt;
- result->Pt = outPt->Pt;
- result->Idx = outPt->Idx;
- if (InsertAfter)
- {
- result->Next = outPt->Next;
- result->Prev = outPt;
- outPt->Next->Prev = result;
- outPt->Next = result;
- }
- else
- {
- result->Prev = outPt->Prev;
- result->Next = outPt;
- outPt->Prev->Next = result;
- outPt->Prev = result;
- }
- return result;
-}
-//------------------------------------------------------------------------------
-
-bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b,
- const IntPoint Pt, bool DiscardLeft)
-{
- Direction Dir1 = (op1->Pt.X > op1b->Pt.X ? dRightToLeft : dLeftToRight);
- Direction Dir2 = (op2->Pt.X > op2b->Pt.X ? dRightToLeft : dLeftToRight);
- if (Dir1 == Dir2) return false;
-
- //When DiscardLeft, we want Op1b to be on the Left of Op1, otherwise we
- //want Op1b to be on the Right. (And likewise with Op2 and Op2b.)
- //So, to facilitate this while inserting Op1b and Op2b ...
- //when DiscardLeft, make sure we're AT or RIGHT of Pt before adding Op1b,
- //otherwise make sure we're AT or LEFT of Pt. (Likewise with Op2b.)
- if (Dir1 == dLeftToRight)
- {
- while (op1->Next->Pt.X <= Pt.X &&
- op1->Next->Pt.X >= op1->Pt.X && op1->Next->Pt.Y == Pt.Y)
- op1 = op1->Next;
- if (DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next;
- op1b = DupOutPt(op1, !DiscardLeft);
- if (op1b->Pt != Pt)
- {
- op1 = op1b;
- op1->Pt = Pt;
- op1b = DupOutPt(op1, !DiscardLeft);
- }
- }
- else
- {
- while (op1->Next->Pt.X >= Pt.X &&
- op1->Next->Pt.X <= op1->Pt.X && op1->Next->Pt.Y == Pt.Y)
- op1 = op1->Next;
- if (!DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next;
- op1b = DupOutPt(op1, DiscardLeft);
- if (op1b->Pt != Pt)
- {
- op1 = op1b;
- op1->Pt = Pt;
- op1b = DupOutPt(op1, DiscardLeft);
- }
- }
-
- if (Dir2 == dLeftToRight)
- {
- while (op2->Next->Pt.X <= Pt.X &&
- op2->Next->Pt.X >= op2->Pt.X && op2->Next->Pt.Y == Pt.Y)
- op2 = op2->Next;
- if (DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next;
- op2b = DupOutPt(op2, !DiscardLeft);
- if (op2b->Pt != Pt)
- {
- op2 = op2b;
- op2->Pt = Pt;
- op2b = DupOutPt(op2, !DiscardLeft);
- };
- } else
- {
- while (op2->Next->Pt.X >= Pt.X &&
- op2->Next->Pt.X <= op2->Pt.X && op2->Next->Pt.Y == Pt.Y)
- op2 = op2->Next;
- if (!DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next;
- op2b = DupOutPt(op2, DiscardLeft);
- if (op2b->Pt != Pt)
- {
- op2 = op2b;
- op2->Pt = Pt;
- op2b = DupOutPt(op2, DiscardLeft);
- };
- };
-
- if ((Dir1 == dLeftToRight) == DiscardLeft)
- {
- op1->Prev = op2;
- op2->Next = op1;
- op1b->Next = op2b;
- op2b->Prev = op1b;
- }
- else
- {
- op1->Next = op2;
- op2->Prev = op1;
- op1b->Prev = op2b;
- op2b->Next = op1b;
- }
- return true;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2)
-{
- OutPt *op1 = j->OutPt1, *op1b;
- OutPt *op2 = j->OutPt2, *op2b;
-
- //There are 3 kinds of joins for output polygons ...
- //1. Horizontal joins where Join.OutPt1 & Join.OutPt2 are vertices anywhere
- //along (horizontal) collinear edges (& Join.OffPt is on the same horizontal).
- //2. Non-horizontal joins where Join.OutPt1 & Join.OutPt2 are at the same
- //location at the Bottom of the overlapping segment (& Join.OffPt is above).
- //3. StrictSimple joins where edges touch but are not collinear and where
- //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point.
- bool isHorizontal = (j->OutPt1->Pt.Y == j->OffPt.Y);
-
- if (isHorizontal && (j->OffPt == j->OutPt1->Pt) &&
- (j->OffPt == j->OutPt2->Pt))
- {
- //Strictly Simple join ...
- if (outRec1 != outRec2) return false;
- op1b = j->OutPt1->Next;
- while (op1b != op1 && (op1b->Pt == j->OffPt))
- op1b = op1b->Next;
- bool reverse1 = (op1b->Pt.Y > j->OffPt.Y);
- op2b = j->OutPt2->Next;
- while (op2b != op2 && (op2b->Pt == j->OffPt))
- op2b = op2b->Next;
- bool reverse2 = (op2b->Pt.Y > j->OffPt.Y);
- if (reverse1 == reverse2) return false;
- if (reverse1)
- {
- op1b = DupOutPt(op1, false);
- op2b = DupOutPt(op2, true);
- op1->Prev = op2;
- op2->Next = op1;
- op1b->Next = op2b;
- op2b->Prev = op1b;
- j->OutPt1 = op1;
- j->OutPt2 = op1b;
- return true;
- } else
- {
- op1b = DupOutPt(op1, true);
- op2b = DupOutPt(op2, false);
- op1->Next = op2;
- op2->Prev = op1;
- op1b->Prev = op2b;
- op2b->Next = op1b;
- j->OutPt1 = op1;
- j->OutPt2 = op1b;
- return true;
- }
- }
- else if (isHorizontal)
- {
- //treat horizontal joins differently to non-horizontal joins since with
- //them we're not yet sure where the overlapping is. OutPt1.Pt & OutPt2.Pt
- //may be anywhere along the horizontal edge.
- op1b = op1;
- while (op1->Prev->Pt.Y == op1->Pt.Y && op1->Prev != op1b && op1->Prev != op2)
- op1 = op1->Prev;
- while (op1b->Next->Pt.Y == op1b->Pt.Y && op1b->Next != op1 && op1b->Next != op2)
- op1b = op1b->Next;
- if (op1b->Next == op1 || op1b->Next == op2) return false; //a flat 'polygon'
-
- op2b = op2;
- while (op2->Prev->Pt.Y == op2->Pt.Y && op2->Prev != op2b && op2->Prev != op1b)
- op2 = op2->Prev;
- while (op2b->Next->Pt.Y == op2b->Pt.Y && op2b->Next != op2 && op2b->Next != op1)
- op2b = op2b->Next;
- if (op2b->Next == op2 || op2b->Next == op1) return false; //a flat 'polygon'
-
- cInt Left, Right;
- //Op1 --> Op1b & Op2 --> Op2b are the extremites of the horizontal edges
- if (!GetOverlap(op1->Pt.X, op1b->Pt.X, op2->Pt.X, op2b->Pt.X, Left, Right))
- return false;
-
- //DiscardLeftSide: when overlapping edges are joined, a spike will created
- //which needs to be cleaned up. However, we don't want Op1 or Op2 caught up
- //on the discard Side as either may still be needed for other joins ...
- IntPoint Pt;
- bool DiscardLeftSide;
- if (op1->Pt.X >= Left && op1->Pt.X <= Right)
- {
- Pt = op1->Pt; DiscardLeftSide = (op1->Pt.X > op1b->Pt.X);
- }
- else if (op2->Pt.X >= Left&& op2->Pt.X <= Right)
- {
- Pt = op2->Pt; DiscardLeftSide = (op2->Pt.X > op2b->Pt.X);
- }
- else if (op1b->Pt.X >= Left && op1b->Pt.X <= Right)
- {
- Pt = op1b->Pt; DiscardLeftSide = op1b->Pt.X > op1->Pt.X;
- }
- else
- {
- Pt = op2b->Pt; DiscardLeftSide = (op2b->Pt.X > op2->Pt.X);
- }
- j->OutPt1 = op1; j->OutPt2 = op2;
- return JoinHorz(op1, op1b, op2, op2b, Pt, DiscardLeftSide);
- } else
- {
- //nb: For non-horizontal joins ...
- // 1. Jr.OutPt1.Pt.Y == Jr.OutPt2.Pt.Y
- // 2. Jr.OutPt1.Pt > Jr.OffPt.Y
-
- //make sure the polygons are correctly oriented ...
- op1b = op1->Next;
- while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Next;
- bool Reverse1 = ((op1b->Pt.Y > op1->Pt.Y) ||
- !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange));
- if (Reverse1)
- {
- op1b = op1->Prev;
- while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Prev;
- if ((op1b->Pt.Y > op1->Pt.Y) ||
- !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange)) return false;
- };
- op2b = op2->Next;
- while ((op2b->Pt == op2->Pt) && (op2b != op2))op2b = op2b->Next;
- bool Reverse2 = ((op2b->Pt.Y > op2->Pt.Y) ||
- !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange));
- if (Reverse2)
- {
- op2b = op2->Prev;
- while ((op2b->Pt == op2->Pt) && (op2b != op2)) op2b = op2b->Prev;
- if ((op2b->Pt.Y > op2->Pt.Y) ||
- !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange)) return false;
- }
-
- if ((op1b == op1) || (op2b == op2) || (op1b == op2b) ||
- ((outRec1 == outRec2) && (Reverse1 == Reverse2))) return false;
-
- if (Reverse1)
- {
- op1b = DupOutPt(op1, false);
- op2b = DupOutPt(op2, true);
- op1->Prev = op2;
- op2->Next = op1;
- op1b->Next = op2b;
- op2b->Prev = op1b;
- j->OutPt1 = op1;
- j->OutPt2 = op1b;
- return true;
- } else
- {
- op1b = DupOutPt(op1, true);
- op2b = DupOutPt(op2, false);
- op1->Next = op2;
- op2->Prev = op1;
- op1b->Prev = op2b;
- op2b->Next = op1b;
- j->OutPt1 = op1;
- j->OutPt2 = op1b;
- return true;
- }
- }
-}
-//----------------------------------------------------------------------
-
-static OutRec* ParseFirstLeft(OutRec* FirstLeft)
-{
- while (FirstLeft && !FirstLeft->Pts)
- FirstLeft = FirstLeft->FirstLeft;
- return FirstLeft;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec)
-{
- //tests if NewOutRec contains the polygon before reassigning FirstLeft
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
- {
- OutRec* outRec = m_PolyOuts[i];
- OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft);
- if (outRec->Pts && firstLeft == OldOutRec)
- {
- if (Poly2ContainsPoly1(outRec->Pts, NewOutRec->Pts))
- outRec->FirstLeft = NewOutRec;
- }
- }
-}
-//----------------------------------------------------------------------
-
-void Clipper::FixupFirstLefts2(OutRec* InnerOutRec, OutRec* OuterOutRec)
-{
- //A polygon has split into two such that one is now the inner of the other.
- //It's possible that these polygons now wrap around other polygons, so check
- //every polygon that's also contained by OuterOutRec's FirstLeft container
- //(including 0) to see if they've become inner to the new inner polygon ...
- OutRec* orfl = OuterOutRec->FirstLeft;
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
- {
- OutRec* outRec = m_PolyOuts[i];
-
- if (!outRec->Pts || outRec == OuterOutRec || outRec == InnerOutRec)
- continue;
- OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft);
- if (firstLeft != orfl && firstLeft != InnerOutRec && firstLeft != OuterOutRec)
- continue;
- if (Poly2ContainsPoly1(outRec->Pts, InnerOutRec->Pts))
- outRec->FirstLeft = InnerOutRec;
- else if (Poly2ContainsPoly1(outRec->Pts, OuterOutRec->Pts))
- outRec->FirstLeft = OuterOutRec;
- else if (outRec->FirstLeft == InnerOutRec || outRec->FirstLeft == OuterOutRec)
- outRec->FirstLeft = orfl;
- }
-}
-//----------------------------------------------------------------------
-void Clipper::FixupFirstLefts3(OutRec* OldOutRec, OutRec* NewOutRec)
-{
- //reassigns FirstLeft WITHOUT testing if NewOutRec contains the polygon
- for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
- {
- OutRec* outRec = m_PolyOuts[i];
- OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft);
- if (outRec->Pts && firstLeft == OldOutRec)
- outRec->FirstLeft = NewOutRec;
- }
-}
-//----------------------------------------------------------------------
-
-void Clipper::JoinCommonEdges()
-{
- for (JoinList::size_type i = 0; i < m_Joins.size(); i++)
- {
- Join* join = m_Joins[i];
-
- OutRec *outRec1 = GetOutRec(join->OutPt1->Idx);
- OutRec *outRec2 = GetOutRec(join->OutPt2->Idx);
-
- if (!outRec1->Pts || !outRec2->Pts) continue;
- if (outRec1->IsOpen || outRec2->IsOpen) continue;
-
- //get the polygon fragment with the correct hole state (FirstLeft)
- //before calling JoinPoints() ...
- OutRec *holeStateRec;
- if (outRec1 == outRec2) holeStateRec = outRec1;
- else if (OutRec1RightOfOutRec2(outRec1, outRec2)) holeStateRec = outRec2;
- else if (OutRec1RightOfOutRec2(outRec2, outRec1)) holeStateRec = outRec1;
- else holeStateRec = GetLowermostRec(outRec1, outRec2);
-
- if (!JoinPoints(join, outRec1, outRec2)) continue;
-
- if (outRec1 == outRec2)
- {
- //instead of joining two polygons, we've just created a new one by
- //splitting one polygon into two.
- outRec1->Pts = join->OutPt1;
- outRec1->BottomPt = 0;
- outRec2 = CreateOutRec();
- outRec2->Pts = join->OutPt2;
-
- //update all OutRec2.Pts Idx's ...
- UpdateOutPtIdxs(*outRec2);
-
- if (Poly2ContainsPoly1(outRec2->Pts, outRec1->Pts))
- {
- //outRec1 contains outRec2 ...
- outRec2->IsHole = !outRec1->IsHole;
- outRec2->FirstLeft = outRec1;
-
- if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1);
-
- if ((outRec2->IsHole ^ m_ReverseOutput) == (Area(*outRec2) > 0))
- ReversePolyPtLinks(outRec2->Pts);
-
- } else if (Poly2ContainsPoly1(outRec1->Pts, outRec2->Pts))
- {
- //outRec2 contains outRec1 ...
- outRec2->IsHole = outRec1->IsHole;
- outRec1->IsHole = !outRec2->IsHole;
- outRec2->FirstLeft = outRec1->FirstLeft;
- outRec1->FirstLeft = outRec2;
-
- if (m_UsingPolyTree) FixupFirstLefts2(outRec1, outRec2);
-
- if ((outRec1->IsHole ^ m_ReverseOutput) == (Area(*outRec1) > 0))
- ReversePolyPtLinks(outRec1->Pts);
- }
- else
- {
- //the 2 polygons are completely separate ...
- outRec2->IsHole = outRec1->IsHole;
- outRec2->FirstLeft = outRec1->FirstLeft;
-
- //fixup FirstLeft pointers that may need reassigning to OutRec2
- if (m_UsingPolyTree) FixupFirstLefts1(outRec1, outRec2);
- }
-
- } else
- {
- //joined 2 polygons together ...
-
- outRec2->Pts = 0;
- outRec2->BottomPt = 0;
- outRec2->Idx = outRec1->Idx;
-
- outRec1->IsHole = holeStateRec->IsHole;
- if (holeStateRec == outRec2)
- outRec1->FirstLeft = outRec2->FirstLeft;
- outRec2->FirstLeft = outRec1;
-
- if (m_UsingPolyTree) FixupFirstLefts3(outRec2, outRec1);
- }
- }
-}
-
-//------------------------------------------------------------------------------
-// ClipperOffset support functions ...
-//------------------------------------------------------------------------------
-
-DoublePoint GetUnitNormal(const IntPoint &pt1, const IntPoint &pt2)
-{
- if(pt2.X == pt1.X && pt2.Y == pt1.Y)
- return DoublePoint(0, 0);
-
- double Dx = (double)(pt2.X - pt1.X);
- double dy = (double)(pt2.Y - pt1.Y);
- double f = 1 *1.0/ std::sqrt( Dx*Dx + dy*dy );
- Dx *= f;
- dy *= f;
- return DoublePoint(dy, -Dx);
-}
-
-//------------------------------------------------------------------------------
-// ClipperOffset class
-//------------------------------------------------------------------------------
-
-ClipperOffset::ClipperOffset(double miterLimit, double arcTolerance)
-{
- this->MiterLimit = miterLimit;
- this->ArcTolerance = arcTolerance;
- m_lowest.X = -1;
-}
-//------------------------------------------------------------------------------
-
-ClipperOffset::~ClipperOffset()
-{
- Clear();
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::Clear()
-{
- for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
- delete m_polyNodes.Childs[i];
- m_polyNodes.Childs.clear();
- m_lowest.X = -1;
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType)
-{
- int highI = (int)path.size() - 1;
- if (highI < 0) return;
- PolyNode* newNode = new PolyNode();
- newNode->m_jointype = joinType;
- newNode->m_endtype = endType;
-
- //strip duplicate points from path and also get index to the lowest point ...
- if (endType == etClosedLine || endType == etClosedPolygon)
- while (highI > 0 && path[0] == path[highI]) highI--;
- newNode->Contour.reserve(highI + 1);
- newNode->Contour.push_back(path[0]);
- int j = 0, k = 0;
- for (int i = 1; i <= highI; i++)
- if (newNode->Contour[j] != path[i])
- {
- j++;
- newNode->Contour.push_back(path[i]);
- if (path[i].Y > newNode->Contour[k].Y ||
- (path[i].Y == newNode->Contour[k].Y &&
- path[i].X < newNode->Contour[k].X)) k = j;
- }
- if (endType == etClosedPolygon && j < 2)
- {
- delete newNode;
- return;
- }
- m_polyNodes.AddChild(*newNode);
-
- //if this path's lowest pt is lower than all the others then update m_lowest
- if (endType != etClosedPolygon) return;
- if (m_lowest.X < 0)
- m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
- else
- {
- IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X]->Contour[(int)m_lowest.Y];
- if (newNode->Contour[k].Y > ip.Y ||
- (newNode->Contour[k].Y == ip.Y &&
- newNode->Contour[k].X < ip.X))
- m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
- }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::AddPaths(const Paths& paths, JoinType joinType, EndType endType)
-{
- for (Paths::size_type i = 0; i < paths.size(); ++i)
- AddPath(paths[i], joinType, endType);
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::FixOrientations()
-{
- //fixup orientations of all closed paths if the orientation of the
- //closed path with the lowermost vertex is wrong ...
- if (m_lowest.X >= 0 &&
- !Orientation(m_polyNodes.Childs[(int)m_lowest.X]->Contour))
- {
- for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
- {
- PolyNode& node = *m_polyNodes.Childs[i];
- if (node.m_endtype == etClosedPolygon ||
- (node.m_endtype == etClosedLine && Orientation(node.Contour)))
- ReversePath(node.Contour);
- }
- } else
- {
- for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
- {
- PolyNode& node = *m_polyNodes.Childs[i];
- if (node.m_endtype == etClosedLine && !Orientation(node.Contour))
- ReversePath(node.Contour);
- }
- }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::Execute(Paths& solution, double delta)
-{
- solution.clear();
- FixOrientations();
- DoOffset(delta);
-
- //now clean up 'corners' ...
- Clipper clpr;
- clpr.AddPaths(m_destPolys, ptSubject, true);
- if (delta > 0)
- {
- clpr.Execute(ctUnion, solution, pftPositive, pftPositive);
- }
- else
- {
- IntRect r = clpr.GetBounds();
- Path outer(4);
- outer[0] = IntPoint(r.left - 10, r.bottom + 10);
- outer[1] = IntPoint(r.right + 10, r.bottom + 10);
- outer[2] = IntPoint(r.right + 10, r.top - 10);
- outer[3] = IntPoint(r.left - 10, r.top - 10);
-
- clpr.AddPath(outer, ptSubject, true);
- clpr.ReverseSolution(true);
- clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
- if (solution.size() > 0) solution.erase(solution.begin());
- }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::Execute(PolyTree& solution, double delta)
-{
- solution.Clear();
- FixOrientations();
- DoOffset(delta);
-
- //now clean up 'corners' ...
- Clipper clpr;
- clpr.AddPaths(m_destPolys, ptSubject, true);
- if (delta > 0)
- {
- clpr.Execute(ctUnion, solution, pftPositive, pftPositive);
- }
- else
- {
- IntRect r = clpr.GetBounds();
- Path outer(4);
- outer[0] = IntPoint(r.left - 10, r.bottom + 10);
- outer[1] = IntPoint(r.right + 10, r.bottom + 10);
- outer[2] = IntPoint(r.right + 10, r.top - 10);
- outer[3] = IntPoint(r.left - 10, r.top - 10);
-
- clpr.AddPath(outer, ptSubject, true);
- clpr.ReverseSolution(true);
- clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
- //remove the outer PolyNode rectangle ...
- if (solution.ChildCount() == 1 && solution.Childs[0]->ChildCount() > 0)
- {
- PolyNode* outerNode = solution.Childs[0];
- solution.Childs.reserve(outerNode->ChildCount());
- solution.Childs[0] = outerNode->Childs[0];
- solution.Childs[0]->Parent = outerNode->Parent;
- for (int i = 1; i < outerNode->ChildCount(); ++i)
- solution.AddChild(*outerNode->Childs[i]);
- }
- else
- solution.Clear();
- }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoOffset(double delta)
-{
- m_destPolys.clear();
- m_delta = delta;
-
- //if Zero offset, just copy any CLOSED polygons to m_p and return ...
- if (NEAR_ZERO(delta))
- {
- m_destPolys.reserve(m_polyNodes.ChildCount());
- for (int i = 0; i < m_polyNodes.ChildCount(); i++)
- {
- PolyNode& node = *m_polyNodes.Childs[i];
- if (node.m_endtype == etClosedPolygon)
- m_destPolys.push_back(node.Contour);
- }
- return;
- }
-
- //see offset_triginometry3.svg in the documentation folder ...
- if (MiterLimit > 2) m_miterLim = 2/(MiterLimit * MiterLimit);
- else m_miterLim = 0.5;
-
- double y;
- if (ArcTolerance <= 0.0) y = def_arc_tolerance;
- else if (ArcTolerance > std::fabs(delta) * def_arc_tolerance)
- y = std::fabs(delta) * def_arc_tolerance;
- else y = ArcTolerance;
- //see offset_triginometry2.svg in the documentation folder ...
- double steps = pi / std::acos(1 - y / std::fabs(delta));
- if (steps > std::fabs(delta) * pi)
- steps = std::fabs(delta) * pi; //ie excessive precision check
- m_sin = std::sin(two_pi / steps);
- m_cos = std::cos(two_pi / steps);
- m_StepsPerRad = steps / two_pi;
- if (delta < 0.0) m_sin = -m_sin;
-
- m_destPolys.reserve(m_polyNodes.ChildCount() * 2);
- for (int i = 0; i < m_polyNodes.ChildCount(); i++)
- {
- PolyNode& node = *m_polyNodes.Childs[i];
- m_srcPoly = node.Contour;
-
- int len = (int)m_srcPoly.size();
- if (len == 0 || (delta <= 0 && (len < 3 || node.m_endtype != etClosedPolygon)))
- continue;
-
- m_destPoly.clear();
- if (len == 1)
- {
- if (node.m_jointype == jtRound)
- {
- double X = 1.0, Y = 0.0;
- for (cInt j = 1; j <= steps; j++)
- {
- m_destPoly.push_back(IntPoint(
- Round(m_srcPoly[0].X + X * delta),
- Round(m_srcPoly[0].Y + Y * delta)));
- double X2 = X;
- X = X * m_cos - m_sin * Y;
- Y = X2 * m_sin + Y * m_cos;
- }
- }
- else
- {
- double X = -1.0, Y = -1.0;
- for (int j = 0; j < 4; ++j)
- {
- m_destPoly.push_back(IntPoint(
- Round(m_srcPoly[0].X + X * delta),
- Round(m_srcPoly[0].Y + Y * delta)));
- if (X < 0) X = 1;
- else if (Y < 0) Y = 1;
- else X = -1;
- }
- }
- m_destPolys.push_back(m_destPoly);
- continue;
- }
- //build m_normals ...
- m_normals.clear();
- m_normals.reserve(len);
- for (int j = 0; j < len - 1; ++j)
- m_normals.push_back(GetUnitNormal(m_srcPoly[j], m_srcPoly[j + 1]));
- if (node.m_endtype == etClosedLine || node.m_endtype == etClosedPolygon)
- m_normals.push_back(GetUnitNormal(m_srcPoly[len - 1], m_srcPoly[0]));
- else
- m_normals.push_back(DoublePoint(m_normals[len - 2]));
-
- if (node.m_endtype == etClosedPolygon)
- {
- int k = len - 1;
- for (int j = 0; j < len; ++j)
- OffsetPoint(j, k, node.m_jointype);
- m_destPolys.push_back(m_destPoly);
- }
- else if (node.m_endtype == etClosedLine)
- {
- int k = len - 1;
- for (int j = 0; j < len; ++j)
- OffsetPoint(j, k, node.m_jointype);
- m_destPolys.push_back(m_destPoly);
- m_destPoly.clear();
- //re-build m_normals ...
- DoublePoint n = m_normals[len -1];
- for (int j = len - 1; j > 0; j--)
- m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y);
- m_normals[0] = DoublePoint(-n.X, -n.Y);
- k = 0;
- for (int j = len - 1; j >= 0; j--)
- OffsetPoint(j, k, node.m_jointype);
- m_destPolys.push_back(m_destPoly);
- }
- else
- {
- int k = 0;
- for (int j = 1; j < len - 1; ++j)
- OffsetPoint(j, k, node.m_jointype);
-
- IntPoint pt1;
- if (node.m_endtype == etOpenButt)
- {
- int j = len - 1;
- pt1 = IntPoint((cInt)Round(m_srcPoly[j].X + m_normals[j].X *
- delta), (cInt)Round(m_srcPoly[j].Y + m_normals[j].Y * delta));
- m_destPoly.push_back(pt1);
- pt1 = IntPoint((cInt)Round(m_srcPoly[j].X - m_normals[j].X *
- delta), (cInt)Round(m_srcPoly[j].Y - m_normals[j].Y * delta));
- m_destPoly.push_back(pt1);
- }
- else
- {
- int j = len - 1;
- k = len - 2;
- m_sinA = 0;
- m_normals[j] = DoublePoint(-m_normals[j].X, -m_normals[j].Y);
- if (node.m_endtype == etOpenSquare)
- DoSquare(j, k);
- else
- DoRound(j, k);
- }
-
- //re-build m_normals ...
- for (int j = len - 1; j > 0; j--)
- m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y);
- m_normals[0] = DoublePoint(-m_normals[1].X, -m_normals[1].Y);
-
- k = len - 1;
- for (int j = k - 1; j > 0; --j) OffsetPoint(j, k, node.m_jointype);
-
- if (node.m_endtype == etOpenButt)
- {
- pt1 = IntPoint((cInt)Round(m_srcPoly[0].X - m_normals[0].X * delta),
- (cInt)Round(m_srcPoly[0].Y - m_normals[0].Y * delta));
- m_destPoly.push_back(pt1);
- pt1 = IntPoint((cInt)Round(m_srcPoly[0].X + m_normals[0].X * delta),
- (cInt)Round(m_srcPoly[0].Y + m_normals[0].Y * delta));
- m_destPoly.push_back(pt1);
- }
- else
- {
- k = 1;
- m_sinA = 0;
- if (node.m_endtype == etOpenSquare)
- DoSquare(0, 1);
- else
- DoRound(0, 1);
- }
- m_destPolys.push_back(m_destPoly);
- }
- }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype)
-{
- //cross product ...
- m_sinA = (m_normals[k].X * m_normals[j].Y - m_normals[j].X * m_normals[k].Y);
- if (std::fabs(m_sinA * m_delta) < 1.0)
- {
- //dot product ...
- double cosA = (m_normals[k].X * m_normals[j].X + m_normals[j].Y * m_normals[k].Y );
- if (cosA > 0) // angle => 0 degrees
- {
- m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
- Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
- return;
- }
- //else angle => 180 degrees
- }
- else if (m_sinA > 1.0) m_sinA = 1.0;
- else if (m_sinA < -1.0) m_sinA = -1.0;
-
- if (m_sinA * m_delta < 0)
- {
- m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
- Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
- m_destPoly.push_back(m_srcPoly[j]);
- m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * m_delta),
- Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta)));
- }
- else
- switch (jointype)
- {
- case jtMiter:
- {
- double r = 1 + (m_normals[j].X * m_normals[k].X +
- m_normals[j].Y * m_normals[k].Y);
- if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k);
- break;
- }
- case jtSquare: DoSquare(j, k); break;
- case jtRound: DoRound(j, k); break;
- }
- k = j;
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoSquare(int j, int k)
-{
- double dx = std::tan(std::atan2(m_sinA,
- m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y) / 4);
- m_destPoly.push_back(IntPoint(
- Round(m_srcPoly[j].X + m_delta * (m_normals[k].X - m_normals[k].Y * dx)),
- Round(m_srcPoly[j].Y + m_delta * (m_normals[k].Y + m_normals[k].X * dx))));
- m_destPoly.push_back(IntPoint(
- Round(m_srcPoly[j].X + m_delta * (m_normals[j].X + m_normals[j].Y * dx)),
- Round(m_srcPoly[j].Y + m_delta * (m_normals[j].Y - m_normals[j].X * dx))));
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoMiter(int j, int k, double r)
-{
- double q = m_delta / r;
- m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + (m_normals[k].X + m_normals[j].X) * q),
- Round(m_srcPoly[j].Y + (m_normals[k].Y + m_normals[j].Y) * q)));
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoRound(int j, int k)
-{
- double a = std::atan2(m_sinA,
- m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y);
- int steps = std::max((int)Round(m_StepsPerRad * std::fabs(a)), 1);
-
- double X = m_normals[k].X, Y = m_normals[k].Y, X2;
- for (int i = 0; i < steps; ++i)
- {
- m_destPoly.push_back(IntPoint(
- Round(m_srcPoly[j].X + X * m_delta),
- Round(m_srcPoly[j].Y + Y * m_delta)));
- X2 = X;
- X = X * m_cos - m_sin * Y;
- Y = X2 * m_sin + Y * m_cos;
- }
- m_destPoly.push_back(IntPoint(
- Round(m_srcPoly[j].X + m_normals[j].X * m_delta),
- Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta)));
-}
-
-//------------------------------------------------------------------------------
-// Miscellaneous public functions
-//------------------------------------------------------------------------------
-
-void Clipper::DoSimplePolygons()
-{
- PolyOutList::size_type i = 0;
- while (i < m_PolyOuts.size())
- {
- OutRec* outrec = m_PolyOuts[i++];
- OutPt* op = outrec->Pts;
- if (!op || outrec->IsOpen) continue;
- do //for each Pt in Polygon until duplicate found do ...
- {
- OutPt* op2 = op->Next;
- while (op2 != outrec->Pts)
- {
- if ((op->Pt == op2->Pt) && op2->Next != op && op2->Prev != op)
- {
- //split the polygon into two ...
- OutPt* op3 = op->Prev;
- OutPt* op4 = op2->Prev;
- op->Prev = op4;
- op4->Next = op;
- op2->Prev = op3;
- op3->Next = op2;
-
- outrec->Pts = op;
- OutRec* outrec2 = CreateOutRec();
- outrec2->Pts = op2;
- UpdateOutPtIdxs(*outrec2);
- if (Poly2ContainsPoly1(outrec2->Pts, outrec->Pts))
- {
- //OutRec2 is contained by OutRec1 ...
- outrec2->IsHole = !outrec->IsHole;
- outrec2->FirstLeft = outrec;
- if (m_UsingPolyTree) FixupFirstLefts2(outrec2, outrec);
- }
- else
- if (Poly2ContainsPoly1(outrec->Pts, outrec2->Pts))
- {
- //OutRec1 is contained by OutRec2 ...
- outrec2->IsHole = outrec->IsHole;
- outrec->IsHole = !outrec2->IsHole;
- outrec2->FirstLeft = outrec->FirstLeft;
- outrec->FirstLeft = outrec2;
- if (m_UsingPolyTree) FixupFirstLefts2(outrec, outrec2);
- }
- else
- {
- //the 2 polygons are separate ...
- outrec2->IsHole = outrec->IsHole;
- outrec2->FirstLeft = outrec->FirstLeft;
- if (m_UsingPolyTree) FixupFirstLefts1(outrec, outrec2);
- }
- op2 = op; //ie get ready for the Next iteration
- }
- op2 = op2->Next;
- }
- op = op->Next;
- }
- while (op != outrec->Pts);
- }
-}
-//------------------------------------------------------------------------------
-
-void ReversePath(Path& p)
-{
- std::reverse(p.begin(), p.end());
-}
-//------------------------------------------------------------------------------
-
-void ReversePaths(Paths& p)
-{
- for (Paths::size_type i = 0; i < p.size(); ++i)
- ReversePath(p[i]);
-}
-//------------------------------------------------------------------------------
-
-void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType)
-{
- Clipper c;
- c.StrictlySimple(true);
- c.AddPath(in_poly, ptSubject, true);
- c.Execute(ctUnion, out_polys, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType)
-{
- Clipper c;
- c.StrictlySimple(true);
- c.AddPaths(in_polys, ptSubject, true);
- c.Execute(ctUnion, out_polys, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-void SimplifyPolygons(Paths &polys, PolyFillType fillType)
-{
- SimplifyPolygons(polys, polys, fillType);
-}
-//------------------------------------------------------------------------------
-
-inline double DistanceSqrd(const IntPoint& pt1, const IntPoint& pt2)
-{
- double Dx = ((double)pt1.X - pt2.X);
- double dy = ((double)pt1.Y - pt2.Y);
- return (Dx*Dx + dy*dy);
-}
-//------------------------------------------------------------------------------
-
-double DistanceFromLineSqrd(
- const IntPoint& pt, const IntPoint& ln1, const IntPoint& ln2)
-{
- //The equation of a line in general form (Ax + By + C = 0)
- //given 2 points (x¹,y¹) & (x²,y²) is ...
- //(y¹ - y²)x + (x² - x¹)y + (y² - y¹)x¹ - (x² - x¹)y¹ = 0
- //A = (y¹ - y²); B = (x² - x¹); C = (y² - y¹)x¹ - (x² - x¹)y¹
- //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²)
- //see http://en.wikipedia.org/wiki/Perpendicular_distance
- double A = double(ln1.Y - ln2.Y);
- double B = double(ln2.X - ln1.X);
- double C = A * ln1.X + B * ln1.Y;
- C = A * pt.X + B * pt.Y - C;
- return (C * C) / (A * A + B * B);
-}
-//---------------------------------------------------------------------------
-
-bool SlopesNearCollinear(const IntPoint& pt1,
- const IntPoint& pt2, const IntPoint& pt3, double distSqrd)
-{
- //this function is more accurate when the point that's geometrically
- //between the other 2 points is the one that's tested for distance.
- //ie makes it more likely to pick up 'spikes' ...
- if (Abs(pt1.X - pt2.X) > Abs(pt1.Y - pt2.Y))
- {
- if ((pt1.X > pt2.X) == (pt1.X < pt3.X))
- return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
- else if ((pt2.X > pt1.X) == (pt2.X < pt3.X))
- return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
- else
- return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
- }
- else
- {
- if ((pt1.Y > pt2.Y) == (pt1.Y < pt3.Y))
- return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
- else if ((pt2.Y > pt1.Y) == (pt2.Y < pt3.Y))
- return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
- else
- return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
- }
-}
-//------------------------------------------------------------------------------
-
-bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd)
-{
- double Dx = (double)pt1.X - pt2.X;
- double dy = (double)pt1.Y - pt2.Y;
- return ((Dx * Dx) + (dy * dy) <= distSqrd);
-}
-//------------------------------------------------------------------------------
-
-OutPt* ExcludeOp(OutPt* op)
-{
- OutPt* result = op->Prev;
- result->Next = op->Next;
- op->Next->Prev = result;
- result->Idx = 0;
- return result;
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygon(const Path& in_poly, Path& out_poly, double distance)
-{
- //distance = proximity in units/pixels below which vertices
- //will be stripped. Default ~= sqrt(2).
-
- size_t size = in_poly.size();
-
- if (size == 0)
- {
- out_poly.clear();
- return;
- }
-
- OutPt* outPts = new OutPt[size];
- for (size_t i = 0; i < size; ++i)
- {
- outPts[i].Pt = in_poly[i];
- outPts[i].Next = &outPts[(i + 1) % size];
- outPts[i].Next->Prev = &outPts[i];
- outPts[i].Idx = 0;
- }
-
- double distSqrd = distance * distance;
- OutPt* op = &outPts[0];
- while (op->Idx == 0 && op->Next != op->Prev)
- {
- if (PointsAreClose(op->Pt, op->Prev->Pt, distSqrd))
- {
- op = ExcludeOp(op);
- size--;
- }
- else if (PointsAreClose(op->Prev->Pt, op->Next->Pt, distSqrd))
- {
- ExcludeOp(op->Next);
- op = ExcludeOp(op);
- size -= 2;
- }
- else if (SlopesNearCollinear(op->Prev->Pt, op->Pt, op->Next->Pt, distSqrd))
- {
- op = ExcludeOp(op);
- size--;
- }
- else
- {
- op->Idx = 1;
- op = op->Next;
- }
- }
-
- if (size < 3) size = 0;
- out_poly.resize(size);
- for (size_t i = 0; i < size; ++i)
- {
- out_poly[i] = op->Pt;
- op = op->Next;
- }
- delete [] outPts;
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygon(Path& poly, double distance)
-{
- CleanPolygon(poly, poly, distance);
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance)
-{
- out_polys.resize(in_polys.size());
- for (Paths::size_type i = 0; i < in_polys.size(); ++i)
- CleanPolygon(in_polys[i], out_polys[i], distance);
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygons(Paths& polys, double distance)
-{
- CleanPolygons(polys, polys, distance);
-}
-//------------------------------------------------------------------------------
-
-void Minkowski(const Path& poly, const Path& path,
- Paths& solution, bool isSum, bool isClosed)
-{
- int delta = (isClosed ? 1 : 0);
- size_t polyCnt = poly.size();
- size_t pathCnt = path.size();
- Paths pp;
- pp.reserve(pathCnt);
- if (isSum)
- for (size_t i = 0; i < pathCnt; ++i)
- {
- Path p;
- p.reserve(polyCnt);
- for (size_t j = 0; j < poly.size(); ++j)
- p.push_back(IntPoint(path[i].X + poly[j].X, path[i].Y + poly[j].Y));
- pp.push_back(p);
- }
- else
- for (size_t i = 0; i < pathCnt; ++i)
- {
- Path p;
- p.reserve(polyCnt);
- for (size_t j = 0; j < poly.size(); ++j)
- p.push_back(IntPoint(path[i].X - poly[j].X, path[i].Y - poly[j].Y));
- pp.push_back(p);
- }
-
- solution.clear();
- solution.reserve((pathCnt + delta) * (polyCnt + 1));
- for (size_t i = 0; i < pathCnt - 1 + delta; ++i)
- for (size_t j = 0; j < polyCnt; ++j)
- {
- Path quad;
- quad.reserve(4);
- quad.push_back(pp[i % pathCnt][j % polyCnt]);
- quad.push_back(pp[(i + 1) % pathCnt][j % polyCnt]);
- quad.push_back(pp[(i + 1) % pathCnt][(j + 1) % polyCnt]);
- quad.push_back(pp[i % pathCnt][(j + 1) % polyCnt]);
- if (!Orientation(quad)) ReversePath(quad);
- solution.push_back(quad);
- }
-}
-//------------------------------------------------------------------------------
-
-void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed)
-{
- Minkowski(pattern, path, solution, true, pathIsClosed);
- Clipper c;
- c.AddPaths(solution, ptSubject, true);
- c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
-}
-//------------------------------------------------------------------------------
-
-void TranslatePath(const Path& input, Path& output, const IntPoint delta)
-{
- //precondition: input != output
- output.resize(input.size());
- for (size_t i = 0; i < input.size(); ++i)
- output[i] = IntPoint(input[i].X + delta.X, input[i].Y + delta.Y);
-}
-//------------------------------------------------------------------------------
-
-void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed)
-{
- Clipper c;
- for (size_t i = 0; i < paths.size(); ++i)
- {
- Paths tmp;
- Minkowski(pattern, paths[i], tmp, true, pathIsClosed);
- c.AddPaths(tmp, ptSubject, true);
- if (pathIsClosed)
- {
- Path tmp2;
- TranslatePath(paths[i], tmp2, pattern[0]);
- c.AddPath(tmp2, ptClip, true);
- }
- }
- c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
-}
-//------------------------------------------------------------------------------
-
-void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution)
-{
- Minkowski(poly1, poly2, solution, false, true);
- Clipper c;
- c.AddPaths(solution, ptSubject, true);
- c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
-}
-//------------------------------------------------------------------------------
-
-enum NodeType {ntAny, ntOpen, ntClosed};
-
-void AddPolyNodeToPaths(const PolyNode& polynode, NodeType nodetype, Paths& paths)
-{
- bool match = true;
- if (nodetype == ntClosed) match = !polynode.IsOpen();
- else if (nodetype == ntOpen) return;
-
- if (!polynode.Contour.empty() && match)
- paths.push_back(polynode.Contour);
- for (int i = 0; i < polynode.ChildCount(); ++i)
- AddPolyNodeToPaths(*polynode.Childs[i], nodetype, paths);
-}
-//------------------------------------------------------------------------------
-
-void PolyTreeToPaths(const PolyTree& polytree, Paths& paths)
-{
- paths.resize(0);
- paths.reserve(polytree.Total());
- AddPolyNodeToPaths(polytree, ntAny, paths);
-}
-//------------------------------------------------------------------------------
-
-void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths)
-{
- paths.resize(0);
- paths.reserve(polytree.Total());
- AddPolyNodeToPaths(polytree, ntClosed, paths);
-}
-//------------------------------------------------------------------------------
-
-void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths)
-{
- paths.resize(0);
- paths.reserve(polytree.Total());
- //Open paths are top level only, so ...
- for (int i = 0; i < polytree.ChildCount(); ++i)
- if (polytree.Childs[i]->IsOpen())
- paths.push_back(polytree.Childs[i]->Contour);
-}
-//------------------------------------------------------------------------------
-
-std::ostream& operator <<(std::ostream &s, const IntPoint &p)
-{
- s << "(" << p.X << "," << p.Y << ")";
- return s;
-}
-//------------------------------------------------------------------------------
-
-std::ostream& operator <<(std::ostream &s, const Path &p)
-{
- if (p.empty()) return s;
- Path::size_type last = p.size() -1;
- for (Path::size_type i = 0; i < last; i++)
- s << "(" << p[i].X << "," << p[i].Y << "), ";
- s << "(" << p[last].X << "," << p[last].Y << ")\n";
- return s;
-}
-//------------------------------------------------------------------------------
-
-std::ostream& operator <<(std::ostream &s, const Paths &p)
-{
- for (Paths::size_type i = 0; i < p.size(); i++)
- s << p[i];
- s << "\n";
- return s;
-}
-//------------------------------------------------------------------------------
-
-} //QtClipperLib namespace
diff --git a/src/3rdparty/clipper/clipper.h b/src/3rdparty/clipper/clipper.h
deleted file mode 100644
index de4a540d..00000000
--- a/src/3rdparty/clipper/clipper.h
+++ /dev/null
@@ -1,404 +0,0 @@
-/*******************************************************************************
-* *
-* Author : Angus Johnson *
-* Version : 6.4.2 *
-* Date : 27 February 2017 *
-* Website : http://www.angusj.com *
-* Copyright : Angus Johnson 2010-2017 *
-* *
-* License: *
-* Use, modification & distribution is subject to Boost Software License Ver 1. *
-* http://www.boost.org/LICENSE_1_0.txt *
-* *
-* Attributions: *
-* The code in this library is an extension of Bala Vatti's clipping algorithm: *
-* "A generic solution to polygon clipping" *
-* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
-* http://portal.acm.org/citation.cfm?id=129906 *
-* *
-* Computer graphics and geometric modeling: implementation and algorithms *
-* By Max K. Agoston *
-* Springer; 1 edition (January 4, 2005) *
-* http://books.google.com/books?q=vatti+clipping+agoston *
-* *
-* See also: *
-* "Polygon Offsetting by Computing Winding Numbers" *
-* Paper no. DETC2005-85513 pp. 565-575 *
-* ASME 2005 International Design Engineering Technical Conferences *
-* and Computers and Information in Engineering Conference (IDETC/CIE2005) *
-* September 24-28, 2005 , Long Beach, California, USA *
-* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
-* *
-*******************************************************************************/
-
-#ifndef clipper_hpp
-#define clipper_hpp
-
-#define CLIPPER_VERSION "6.4.2"
-
-//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
-//improve performance but coordinate values are limited to the range +/- 46340
-//#define use_int32
-
-//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
-//#define use_xyz
-
-//use_lines: Enables line clipping. Adds a very minor cost to performance.
-#define use_lines
-
-//use_deprecated: Enables temporary support for the obsolete functions
-//#define use_deprecated
-
-#include <vector>
-#include <list>
-#include <set>
-#include <stdexcept>
-#include <cstring>
-#include <cstdlib>
-#include <ostream>
-#include <functional>
-#include <queue>
-
-namespace QtClipperLib {
-
-enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
-enum PolyType { ptSubject, ptClip };
-//By far the most widely used winding rules for polygon filling are
-//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32)
-//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL)
-//see http://glprogramming.com/red/chapter11.html
-enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
-
-#ifdef use_int32
- typedef int cInt;
- static cInt const loRange = 0x7FFF;
- static cInt const hiRange = 0x7FFF;
-#else
- typedef signed long long cInt;
- static cInt const loRange = 0x3FFFFFFF;
- static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
- typedef signed long long long64; //used by Int128 class
- typedef unsigned long long ulong64;
-
-#endif
-
-struct IntPoint {
- cInt X;
- cInt Y;
-#ifdef use_xyz
- cInt Z;
- IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {};
-#else
- IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {};
-#endif
-
- friend inline bool operator== (const IntPoint& a, const IntPoint& b)
- {
- return a.X == b.X && a.Y == b.Y;
- }
- friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
- {
- return a.X != b.X || a.Y != b.Y;
- }
-};
-//------------------------------------------------------------------------------
-
-typedef std::vector< IntPoint > Path;
-typedef std::vector< Path > Paths;
-
-inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;}
-inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;}
-
-std::ostream& operator <<(std::ostream &s, const IntPoint &p);
-std::ostream& operator <<(std::ostream &s, const Path &p);
-std::ostream& operator <<(std::ostream &s, const Paths &p);
-
-struct DoublePoint
-{
- double X;
- double Y;
- DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {}
- DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {}
-};
-//------------------------------------------------------------------------------
-
-#ifdef use_xyz
-typedef void (*ZFillCallback)(IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top, IntPoint& pt);
-#endif
-
-enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
-enum JoinType {jtSquare, jtRound, jtMiter};
-enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
-
-class PolyNode;
-typedef std::vector< PolyNode* > PolyNodes;
-
-class PolyNode
-{
-public:
- PolyNode();
- virtual ~PolyNode(){};
- Path Contour;
- PolyNodes Childs;
- PolyNode* Parent;
- PolyNode* GetNext() const;
- bool IsHole() const;
- bool IsOpen() const;
- int ChildCount() const;
-private:
- unsigned Index; //node index in Parent.Childs
- bool m_IsOpen;
- JoinType m_jointype;
- EndType m_endtype;
- PolyNode* GetNextSiblingUp() const;
- void AddChild(PolyNode& child);
- friend class Clipper; //to access Index
- friend class ClipperOffset;
-};
-
-class PolyTree: public PolyNode
-{
-public:
- ~PolyTree(){ Clear(); };
- PolyNode* GetFirst() const;
- void Clear();
- int Total() const;
-private:
- PolyNodes AllNodes;
- friend class Clipper; //to access AllNodes
-};
-
-bool Orientation(const Path &poly);
-double Area(const Path &poly);
-int PointInPolygon(const IntPoint &pt, const Path &path);
-
-void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
-void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
-void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
-
-void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
-void CleanPolygon(Path& poly, double distance = 1.415);
-void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
-void CleanPolygons(Paths& polys, double distance = 1.415);
-
-void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed);
-void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed);
-void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution);
-
-void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
-void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths);
-void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
-
-void ReversePath(Path& p);
-void ReversePaths(Paths& p);
-
-struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
-
-//enums that are used internally ...
-enum EdgeSide { esLeft = 1, esRight = 2};
-
-//forward declarations (for stuff used internally) ...
-struct TEdge;
-struct IntersectNode;
-struct LocalMinimum;
-struct OutPt;
-struct OutRec;
-struct Join;
-
-typedef std::vector < OutRec* > PolyOutList;
-typedef std::vector < TEdge* > EdgeList;
-typedef std::vector < Join* > JoinList;
-typedef std::vector < IntersectNode* > IntersectList;
-
-//------------------------------------------------------------------------------
-
-//ClipperBase is the ancestor to the Clipper class. It should not be
-//instantiated directly. This class simply abstracts the conversion of sets of
-//polygon coordinates into edge objects that are stored in a LocalMinima list.
-class ClipperBase
-{
-public:
- ClipperBase();
- virtual ~ClipperBase();
- virtual bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
- bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
- virtual void Clear();
- IntRect GetBounds();
- bool PreserveCollinear() {return m_PreserveCollinear;};
- void PreserveCollinear(bool value) {m_PreserveCollinear = value;};
-protected:
- void DisposeLocalMinimaList();
- TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
- virtual void Reset();
- TEdge* ProcessBound(TEdge* E, bool IsClockwise);
- void InsertScanbeam(const cInt Y);
- bool PopScanbeam(cInt &Y);
- bool LocalMinimaPending();
- bool PopLocalMinima(cInt Y, const LocalMinimum *&locMin);
- OutRec* CreateOutRec();
- void DisposeAllOutRecs();
- void DisposeOutRec(PolyOutList::size_type index);
- void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
- void DeleteFromAEL(TEdge *e);
- void UpdateEdgeIntoAEL(TEdge *&e);
-
- typedef std::vector<LocalMinimum> MinimaList;
- MinimaList::iterator m_CurrentLM;
- MinimaList m_MinimaList;
-
- bool m_UseFullRange;
- EdgeList m_edges;
- bool m_PreserveCollinear;
- bool m_HasOpenPaths;
- PolyOutList m_PolyOuts;
- TEdge *m_ActiveEdges;
-
- typedef std::priority_queue<cInt> ScanbeamList;
- ScanbeamList m_Scanbeam;
-};
-//------------------------------------------------------------------------------
-
-class Clipper : public virtual ClipperBase
-{
-public:
- Clipper(int initOptions = 0);
- bool Execute(ClipType clipType,
- Paths &solution,
- PolyFillType fillType = pftEvenOdd);
- bool Execute(ClipType clipType,
- Paths &solution,
- PolyFillType subjFillType,
- PolyFillType clipFillType);
- bool Execute(ClipType clipType,
- PolyTree &polytree,
- PolyFillType fillType = pftEvenOdd);
- bool Execute(ClipType clipType,
- PolyTree &polytree,
- PolyFillType subjFillType,
- PolyFillType clipFillType);
- bool ReverseSolution() { return m_ReverseOutput; };
- void ReverseSolution(bool value) {m_ReverseOutput = value;};
- bool StrictlySimple() {return m_StrictSimple;};
- void StrictlySimple(bool value) {m_StrictSimple = value;};
- //set the callback function for z value filling on intersections (otherwise Z is 0)
-#ifdef use_xyz
- void ZFillFunction(ZFillCallback zFillFunc);
-#endif
-protected:
- virtual bool ExecuteInternal();
-private:
- JoinList m_Joins;
- JoinList m_GhostJoins;
- IntersectList m_IntersectList;
- ClipType m_ClipType;
- typedef std::list<cInt> MaximaList;
- MaximaList m_Maxima;
- TEdge *m_SortedEdges;
- bool m_ExecuteLocked;
- PolyFillType m_ClipFillType;
- PolyFillType m_SubjFillType;
- bool m_ReverseOutput;
- bool m_UsingPolyTree;
- bool m_StrictSimple;
-#ifdef use_xyz
- ZFillCallback m_ZFill; //custom callback
-#endif
- void SetWindingCount(TEdge& edge);
- bool IsEvenOddFillType(const TEdge& edge) const;
- bool IsEvenOddAltFillType(const TEdge& edge) const;
- void InsertLocalMinimaIntoAEL(const cInt botY);
- void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
- void AddEdgeToSEL(TEdge *edge);
- bool PopEdgeFromSEL(TEdge *&edge);
- void CopyAELToSEL();
- void DeleteFromSEL(TEdge *e);
- void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
- bool IsContributing(const TEdge& edge) const;
- bool IsTopHorz(const cInt XPos);
- void DoMaxima(TEdge *e);
- void ProcessHorizontals();
- void ProcessHorizontal(TEdge *horzEdge);
- void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
- OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
- OutRec* GetOutRec(int idx);
- void AppendPolygon(TEdge *e1, TEdge *e2);
- void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt);
- OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
- OutPt* GetLastOutPt(TEdge *e);
- bool ProcessIntersections(const cInt topY);
- void BuildIntersectList(const cInt topY);
- void ProcessIntersectList();
- void ProcessEdgesAtTopOfScanbeam(const cInt topY);
- void BuildResult(Paths& polys);
- void BuildResult2(PolyTree& polytree);
- void SetHoleState(TEdge *e, OutRec *outrec);
- void DisposeIntersectNodes();
- bool FixupIntersectionOrder();
- void FixupOutPolygon(OutRec &outrec);
- void FixupOutPolyline(OutRec &outrec);
- bool IsHole(TEdge *e);
- bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
- void FixHoleLinkage(OutRec &outrec);
- void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
- void ClearJoins();
- void ClearGhostJoins();
- void AddGhostJoin(OutPt *op, const IntPoint offPt);
- bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2);
- void JoinCommonEdges();
- void DoSimplePolygons();
- void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
- void FixupFirstLefts2(OutRec* InnerOutRec, OutRec* OuterOutRec);
- void FixupFirstLefts3(OutRec* OldOutRec, OutRec* NewOutRec);
-#ifdef use_xyz
- void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2);
-#endif
-};
-//------------------------------------------------------------------------------
-
-class ClipperOffset
-{
-public:
- ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25);
- ~ClipperOffset();
- void AddPath(const Path& path, JoinType joinType, EndType endType);
- void AddPaths(const Paths& paths, JoinType joinType, EndType endType);
- void Execute(Paths& solution, double delta);
- void Execute(PolyTree& solution, double delta);
- void Clear();
- double MiterLimit;
- double ArcTolerance;
-private:
- Paths m_destPolys;
- Path m_srcPoly;
- Path m_destPoly;
- std::vector<DoublePoint> m_normals;
- double m_delta, m_sinA, m_sin, m_cos;
- double m_miterLim, m_StepsPerRad;
- IntPoint m_lowest;
- PolyNode m_polyNodes;
-
- void FixOrientations();
- void DoOffset(double delta);
- void OffsetPoint(int j, int& k, JoinType jointype);
- void DoSquare(int j, int k);
- void DoMiter(int j, int k, double r);
- void DoRound(int j, int k);
-};
-//------------------------------------------------------------------------------
-
-class clipperException : public std::exception
-{
- public:
- clipperException(const char* description): m_descr(description) {}
- virtual ~clipperException() throw() {}
- const char* what() const throw() override {return m_descr.c_str();}
- private:
- std::string m_descr;
-};
-//------------------------------------------------------------------------------
-
-} //QtClipperLib namespace
-
-#endif //clipper_hpp
-
-
diff --git a/src/3rdparty/clipper/clipper.pro b/src/3rdparty/clipper/clipper.pro
deleted file mode 100644
index a518d248..00000000
--- a/src/3rdparty/clipper/clipper.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qt_clipper
-
-CONFIG += staticlib exceptions warn_off optimize_full
-
-load(qt_helper_lib)
-
-# workaround for QTBUG-31586
-contains(QT_CONFIG, c++11): CONFIG += c++11
-
-gcc {
- QMAKE_CFLAGS_OPTIMIZE_FULL += -ffast-math
- !clang:!intel_icc:!rim_qcc: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=return-type
-}
-
-HEADERS += clipper.h
-SOURCES += clipper.cpp
diff --git a/src/3rdparty/clipper/qt_attribution.json b/src/3rdparty/clipper/qt_attribution.json
deleted file mode 100644
index cc00a496..00000000
--- a/src/3rdparty/clipper/qt_attribution.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Id": "clipper",
- "Name": "Clipper Polygon Clipping Library",
- "QDocModule": "qtpositioning",
- "QtUsage": "Used in the QML plugin of Qt Location and in Qt Positioning.",
- "Description": "The Clipper library performs line & polygon clipping - intersection, union, difference & exclusive-or, and line & polygon offsetting.",
- "Homepage": "http://www.angusj.com/delphi/clipper.php",
- "Version": "6.4.2",
- "LicenseId": "BSL-1.0",
- "License": "Boost Software License 1.0",
- "LicenseFile": "LICENSE",
- "Copyright": "Copyright Angus Johnson 2010-2017"
-}
diff --git a/src/3rdparty/poly2tri/AUTHORS b/src/3rdparty/poly2tri/AUTHORS
deleted file mode 100644
index d8f4899f..00000000
--- a/src/3rdparty/poly2tri/AUTHORS
+++ /dev/null
@@ -1,8 +0,0 @@
-Primary Contributors:
-
- Mason Green <mason.green@gmail.com> (C++, Python)
- Thomas Åhlén <thahlen@gmail.com> (Java)
-
-Other Contributors:
-
-
diff --git a/src/3rdparty/poly2tri/CMakeLists.txt b/src/3rdparty/poly2tri/CMakeLists.txt
deleted file mode 100644
index 167485db..00000000
--- a/src/3rdparty/poly2tri/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# Generated from poly2tri.pro.
-
-#####################################################################
-## Bundled_Poly2Tri Generic Library:
-#####################################################################
-
-qt_internal_add_3rdparty_library(Bundled_Poly2Tri
- QMAKE_LIB_NAME _poly2tri
- STATIC
- SKIP_AUTOMOC # special case
- SOURCES
- common/shapes.cpp common/shapes.h
- common/utils.h
- poly2tri.h
- sweep/advancing_front.cpp sweep/advancing_front.h
- sweep/cdt.cpp sweep/cdt.h
- sweep/sweep.cpp sweep/sweep.h
- sweep/sweep_context.cpp sweep/sweep_context.h
-)
-qt_disable_warnings(Bundled_Poly2Tri)
-qt_set_symbol_visibility_hidden(Bundled_Poly2Tri)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 3:.:.:poly2tri.pro:GCC:
-# QMAKE_CFLAGS_OPTIMIZE_FULL = "-ffast-math"
-
-#### Keys ignored in scope 4:.:.:poly2tri.pro:NOT CLANG AND NOT ICC AND NOT rim_qcc:
-# QMAKE_CXXFLAGS_WARN_ON = "-Wno-error=return-type"
diff --git a/src/3rdparty/poly2tri/LICENSE b/src/3rdparty/poly2tri/LICENSE
deleted file mode 100644
index 9417c083..00000000
--- a/src/3rdparty/poly2tri/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
-http://code.google.com/p/poly2tri/
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-* Neither the name of Poly2Tri nor the names of its contributors may be
- used to endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/3rdparty/poly2tri/common/shapes.cpp b/src/3rdparty/poly2tri/common/shapes.cpp
deleted file mode 100644
index 2ac7e979..00000000
--- a/src/3rdparty/poly2tri/common/shapes.cpp
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "shapes.h"
-#include <iostream>
-
-namespace p2t {
-
-Triangle::Triangle(Point& a, Point& b, Point& c)
-{
- points_[0] = &a; points_[1] = &b; points_[2] = &c;
- neighbors_[0] = NULL; neighbors_[1] = NULL; neighbors_[2] = NULL;
- constrained_edge[0] = constrained_edge[1] = constrained_edge[2] = false;
- delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false;
- interior_ = false;
-}
-
-// Update neighbor pointers
-void Triangle::MarkNeighbor(Point* p1, Point* p2, Triangle* t)
-{
- if ((p1 == points_[2] && p2 == points_[1]) || (p1 == points_[1] && p2 == points_[2]))
- neighbors_[0] = t;
- else if ((p1 == points_[0] && p2 == points_[2]) || (p1 == points_[2] && p2 == points_[0]))
- neighbors_[1] = t;
- else if ((p1 == points_[0] && p2 == points_[1]) || (p1 == points_[1] && p2 == points_[0]))
- neighbors_[2] = t;
- else
- assert(0);
-}
-
-// Exhaustive search to update neighbor pointers
-void Triangle::MarkNeighbor(Triangle& t)
-{
- if (t.Contains(points_[1], points_[2])) {
- neighbors_[0] = &t;
- t.MarkNeighbor(points_[1], points_[2], this);
- } else if (t.Contains(points_[0], points_[2])) {
- neighbors_[1] = &t;
- t.MarkNeighbor(points_[0], points_[2], this);
- } else if (t.Contains(points_[0], points_[1])) {
- neighbors_[2] = &t;
- t.MarkNeighbor(points_[0], points_[1], this);
- }
-}
-
-/**
- * Clears all references to all other triangles and points
- */
-void Triangle::Clear()
-{
- Triangle *t;
- for (int i=0; i<3; i++)
- {
- t = neighbors_[i];
- if (t != NULL)
- {
- t->ClearNeighbor( this );
- }
- }
- ClearNeighbors();
- points_[0]=points_[1]=points_[2] = NULL;
-}
-
-void Triangle::ClearNeighbor(Triangle *triangle )
-{
- if (neighbors_[0] == triangle)
- {
- neighbors_[0] = NULL;
- }
- else if (neighbors_[1] == triangle)
- {
- neighbors_[1] = NULL;
- }
- else
- {
- neighbors_[2] = NULL;
- }
-}
-
-void Triangle::ClearNeighbors()
-{
- neighbors_[0] = NULL;
- neighbors_[1] = NULL;
- neighbors_[2] = NULL;
-}
-
-void Triangle::ClearDelunayEdges()
-{
- delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false;
-}
-
-Point* Triangle::OppositePoint(Triangle& t, Point& p)
-{
- Point *cw = t.PointCW(p);
- return PointCW(*cw);
-}
-
-// Legalized triangle by rotating clockwise around point(0)
-void Triangle::Legalize(Point& point)
-{
- points_[1] = points_[0];
- points_[0] = points_[2];
- points_[2] = &point;
-}
-
-// Legalize triagnle by rotating clockwise around oPoint
-void Triangle::Legalize(Point& opoint, Point& npoint)
-{
- if (&opoint == points_[0]) {
- points_[1] = points_[0];
- points_[0] = points_[2];
- points_[2] = &npoint;
- } else if (&opoint == points_[1]) {
- points_[2] = points_[1];
- points_[1] = points_[0];
- points_[0] = &npoint;
- } else if (&opoint == points_[2]) {
- points_[0] = points_[2];
- points_[2] = points_[1];
- points_[1] = &npoint;
- } else {
- assert(0);
- }
-}
-
-int Triangle::Index(const Point* p)
-{
- if (p == points_[0]) {
- return 0;
- } else if (p == points_[1]) {
- return 1;
- } else if (p == points_[2]) {
- return 2;
- }
- assert(0);
-}
-
-int Triangle::EdgeIndex(const Point* p1, const Point* p2)
-{
- if (points_[0] == p1) {
- if (points_[1] == p2) {
- return 2;
- } else if (points_[2] == p2) {
- return 1;
- }
- } else if (points_[1] == p1) {
- if (points_[2] == p2) {
- return 0;
- } else if (points_[0] == p2) {
- return 2;
- }
- } else if (points_[2] == p1) {
- if (points_[0] == p2) {
- return 1;
- } else if (points_[1] == p2) {
- return 0;
- }
- }
- return -1;
-}
-
-void Triangle::MarkConstrainedEdge(const int index)
-{
- constrained_edge[index] = true;
-}
-
-void Triangle::MarkConstrainedEdge(Edge& edge)
-{
- MarkConstrainedEdge(edge.p, edge.q);
-}
-
-// Mark edge as constrained
-void Triangle::MarkConstrainedEdge(Point* p, Point* q)
-{
- if ((q == points_[0] && p == points_[1]) || (q == points_[1] && p == points_[0])) {
- constrained_edge[2] = true;
- } else if ((q == points_[0] && p == points_[2]) || (q == points_[2] && p == points_[0])) {
- constrained_edge[1] = true;
- } else if ((q == points_[1] && p == points_[2]) || (q == points_[2] && p == points_[1])) {
- constrained_edge[0] = true;
- }
-}
-
-// The point counter-clockwise to given point
-Point* Triangle::PointCW(Point& point)
-{
- if (&point == points_[0]) {
- return points_[2];
- } else if (&point == points_[1]) {
- return points_[0];
- } else if (&point == points_[2]) {
- return points_[1];
- }
- assert(0);
-}
-
-// The point counter-clockwise to given point
-Point* Triangle::PointCCW(Point& point)
-{
- if (&point == points_[0]) {
- return points_[1];
- } else if (&point == points_[1]) {
- return points_[2];
- } else if (&point == points_[2]) {
- return points_[0];
- }
- assert(0);
-}
-
-// The neighbor clockwise to given point
-Triangle* Triangle::NeighborCW(Point& point)
-{
- if (&point == points_[0]) {
- return neighbors_[1];
- } else if (&point == points_[1]) {
- return neighbors_[2];
- }
- return neighbors_[0];
-}
-
-// The neighbor counter-clockwise to given point
-Triangle* Triangle::NeighborCCW(Point& point)
-{
- if (&point == points_[0]) {
- return neighbors_[2];
- } else if (&point == points_[1]) {
- return neighbors_[0];
- }
- return neighbors_[1];
-}
-
-bool Triangle::GetConstrainedEdgeCCW(Point& p)
-{
- if (&p == points_[0]) {
- return constrained_edge[2];
- } else if (&p == points_[1]) {
- return constrained_edge[0];
- }
- return constrained_edge[1];
-}
-
-bool Triangle::GetConstrainedEdgeCW(Point& p)
-{
- if (&p == points_[0]) {
- return constrained_edge[1];
- } else if (&p == points_[1]) {
- return constrained_edge[2];
- }
- return constrained_edge[0];
-}
-
-void Triangle::SetConstrainedEdgeCCW(Point& p, bool ce)
-{
- if (&p == points_[0]) {
- constrained_edge[2] = ce;
- } else if (&p == points_[1]) {
- constrained_edge[0] = ce;
- } else {
- constrained_edge[1] = ce;
- }
-}
-
-void Triangle::SetConstrainedEdgeCW(Point& p, bool ce)
-{
- if (&p == points_[0]) {
- constrained_edge[1] = ce;
- } else if (&p == points_[1]) {
- constrained_edge[2] = ce;
- } else {
- constrained_edge[0] = ce;
- }
-}
-
-bool Triangle::GetDelunayEdgeCCW(Point& p)
-{
- if (&p == points_[0]) {
- return delaunay_edge[2];
- } else if (&p == points_[1]) {
- return delaunay_edge[0];
- }
- return delaunay_edge[1];
-}
-
-bool Triangle::GetDelunayEdgeCW(Point& p)
-{
- if (&p == points_[0]) {
- return delaunay_edge[1];
- } else if (&p == points_[1]) {
- return delaunay_edge[2];
- }
- return delaunay_edge[0];
-}
-
-void Triangle::SetDelunayEdgeCCW(Point& p, bool e)
-{
- if (&p == points_[0]) {
- delaunay_edge[2] = e;
- } else if (&p == points_[1]) {
- delaunay_edge[0] = e;
- } else {
- delaunay_edge[1] = e;
- }
-}
-
-void Triangle::SetDelunayEdgeCW(Point& p, bool e)
-{
- if (&p == points_[0]) {
- delaunay_edge[1] = e;
- } else if (&p == points_[1]) {
- delaunay_edge[2] = e;
- } else {
- delaunay_edge[0] = e;
- }
-}
-
-// The neighbor across to given point
-Triangle& Triangle::NeighborAcross(Point& opoint)
-{
- if (&opoint == points_[0]) {
- return *neighbors_[0];
- } else if (&opoint == points_[1]) {
- return *neighbors_[1];
- }
- return *neighbors_[2];
-}
-
-void Triangle::DebugPrint()
-{
- using namespace std;
- cout << points_[0]->x << "," << points_[0]->y << " ";
- cout << points_[1]->x << "," << points_[1]->y << " ";
- cout << points_[2]->x << "," << points_[2]->y << endl;
-}
-
-}
-
diff --git a/src/3rdparty/poly2tri/common/shapes.h b/src/3rdparty/poly2tri/common/shapes.h
deleted file mode 100644
index 5b90ea6c..00000000
--- a/src/3rdparty/poly2tri/common/shapes.h
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// Include guard
-#ifndef SHAPES_H
-#define SHAPES_H
-
-#include <vector>
-#include <cstddef>
-#include <assert.h>
-#include <cmath>
-
-namespace p2t {
-
-struct Edge;
-
-struct Point {
-
- double x, y;
-
- /// Default constructor does nothing (for performance).
- Point()
- {
- x = 0.0;
- y = 0.0;
- }
-
- /// The edges this point constitutes an upper ending point
- std::vector<Edge*> edge_list;
-
- /// Construct using coordinates.
- Point(double x, double y) : x(x), y(y) {}
-
- /// Set this point to all zeros.
- void set_zero()
- {
- x = 0.0;
- y = 0.0;
- }
-
- /// Set this point to some specified coordinates.
- void set(double x_, double y_)
- {
- x = x_;
- y = y_;
- }
-
- /// Negate this point.
- Point operator -() const
- {
- Point v;
- v.set(-x, -y);
- return v;
- }
-
- /// Add a point to this point.
- void operator +=(const Point& v)
- {
- x += v.x;
- y += v.y;
- }
-
- /// Subtract a point from this point.
- void operator -=(const Point& v)
- {
- x -= v.x;
- y -= v.y;
- }
-
- /// Multiply this point by a scalar.
- void operator *=(double a)
- {
- x *= a;
- y *= a;
- }
-
- /// Get the length of this point (the norm).
- double Length() const
- {
- return std::sqrt(x * x + y * y);
- }
-
- /// Convert this point into a unit point. Returns the Length.
- double Normalize()
- {
- double len = Length();
- x /= len;
- y /= len;
- return len;
- }
-
-};
-
-// Represents a simple polygon's edge
-struct Edge {
-
- Point* p, *q;
-
- /// Constructor
- Edge(Point& p1, Point& p2) : p(&p1), q(&p2)
- {
- if (p1.y > p2.y) {
- q = &p1;
- p = &p2;
- } else if (p1.y == p2.y) {
- if (p1.x > p2.x) {
- q = &p1;
- p = &p2;
- } else if (p1.x == p2.x) {
- // Repeat points
- assert(false);
- }
- }
-
- q->edge_list.push_back(this);
- }
-};
-
-// Triangle-based data structures are know to have better performance than quad-edge structures
-// See: J. Shewchuk, "Triangle: Engineering a 2D Quality Mesh Generator and Delaunay Triangulator"
-// "Triangulations in CGAL"
-class Triangle {
-public:
-
-/// Constructor
-Triangle(Point& a, Point& b, Point& c);
-
-/// Flags to determine if an edge is a Constrained edge
-bool constrained_edge[3];
-/// Flags to determine if an edge is a Delauney edge
-bool delaunay_edge[3];
-
-Point* GetPoint(const int& index);
-Point* PointCW(Point& point);
-Point* PointCCW(Point& point);
-Point* OppositePoint(Triangle& t, Point& p);
-
-Triangle* GetNeighbor(const int& index);
-void MarkNeighbor(Point* p1, Point* p2, Triangle* t);
-void MarkNeighbor(Triangle& t);
-
-void MarkConstrainedEdge(const int index);
-void MarkConstrainedEdge(Edge& edge);
-void MarkConstrainedEdge(Point* p, Point* q);
-
-int Index(const Point* p);
-int EdgeIndex(const Point* p1, const Point* p2);
-
-Triangle* NeighborCW(Point& point);
-Triangle* NeighborCCW(Point& point);
-bool GetConstrainedEdgeCCW(Point& p);
-bool GetConstrainedEdgeCW(Point& p);
-void SetConstrainedEdgeCCW(Point& p, bool ce);
-void SetConstrainedEdgeCW(Point& p, bool ce);
-bool GetDelunayEdgeCCW(Point& p);
-bool GetDelunayEdgeCW(Point& p);
-void SetDelunayEdgeCCW(Point& p, bool e);
-void SetDelunayEdgeCW(Point& p, bool e);
-
-bool Contains(Point* p);
-bool Contains(const Edge& e);
-bool Contains(Point* p, Point* q);
-void Legalize(Point& point);
-void Legalize(Point& opoint, Point& npoint);
-/**
- * Clears all references to all other triangles and points
- */
-void Clear();
-void ClearNeighbor(Triangle *triangle );
-void ClearNeighbors();
-void ClearDelunayEdges();
-
-inline bool IsInterior();
-inline void IsInterior(bool b);
-
-Triangle& NeighborAcross(Point& opoint);
-
-void DebugPrint();
-
-private:
-
-/// Triangle points
-Point* points_[3];
-/// Neighbor list
-Triangle* neighbors_[3];
-
-/// Has this triangle been marked as an interior triangle?
-bool interior_;
-};
-
-inline bool cmp(const Point* a, const Point* b)
-{
- if (a->y < b->y) {
- return true;
- } else if (a->y == b->y) {
- // Make sure q is point with greater x value
- if (a->x < b->x) {
- return true;
- }
- }
- return false;
-}
-
-/// Add two points_ component-wise.
-inline Point operator +(const Point& a, const Point& b)
-{
- return Point(a.x + b.x, a.y + b.y);
-}
-
-/// Subtract two points_ component-wise.
-inline Point operator -(const Point& a, const Point& b)
-{
- return Point(a.x - b.x, a.y - b.y);
-}
-
-/// Multiply point by scalar
-inline Point operator *(double s, const Point& a)
-{
- return Point(s * a.x, s * a.y);
-}
-
-inline bool operator ==(const Point& a, const Point& b)
-{
- return a.x == b.x && a.y == b.y;
-}
-
-inline bool operator !=(const Point& a, const Point& b)
-{
- return !(a.x == b.x) && !(a.y == b.y);
-}
-
-/// Peform the dot product on two vectors.
-inline double Dot(const Point& a, const Point& b)
-{
- return a.x * b.x + a.y * b.y;
-}
-
-/// Perform the cross product on two vectors. In 2D this produces a scalar.
-inline double Cross(const Point& a, const Point& b)
-{
- return a.x * b.y - a.y * b.x;
-}
-
-/// Perform the cross product on a point and a scalar. In 2D this produces
-/// a point.
-inline Point Cross(const Point& a, double s)
-{
- return Point(s * a.y, -s * a.x);
-}
-
-/// Perform the cross product on a scalar and a point. In 2D this produces
-/// a point.
-inline Point Cross(const double s, const Point& a)
-{
- return Point(-s * a.y, s * a.x);
-}
-
-inline Point* Triangle::GetPoint(const int& index)
-{
- return points_[index];
-}
-
-inline Triangle* Triangle::GetNeighbor(const int& index)
-{
- return neighbors_[index];
-}
-
-inline bool Triangle::Contains(Point* p)
-{
- return p == points_[0] || p == points_[1] || p == points_[2];
-}
-
-inline bool Triangle::Contains(const Edge& e)
-{
- return Contains(e.p) && Contains(e.q);
-}
-
-inline bool Triangle::Contains(Point* p, Point* q)
-{
- return Contains(p) && Contains(q);
-}
-
-inline bool Triangle::IsInterior()
-{
- return interior_;
-}
-
-inline void Triangle::IsInterior(bool b)
-{
- interior_ = b;
-}
-
-}
-
-#endif
-
-
diff --git a/src/3rdparty/poly2tri/common/utils.h b/src/3rdparty/poly2tri/common/utils.h
deleted file mode 100644
index 8744b6d2..00000000
--- a/src/3rdparty/poly2tri/common/utils.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UTILS_H
-#define UTILS_H
-
-// Otherwise #defines like M_PI are undeclared under Visual Studio
-#define _USE_MATH_DEFINES
-
-#include <exception>
-#include <math.h>
-
-#ifndef M_PI
-#define M_PI (3.14159265358979323846)
-#endif
-
-namespace p2t {
-
-const double PI_3div4 = 3 * M_PI / 4;
-const double PI_div2 = 1.57079632679489661923;
-const double EPSILON = 1e-12;
-
-enum Orientation { CW, CCW, COLLINEAR };
-
-/**
- * Forumla to calculate signed area<br>
- * Positive if CCW<br>
- * Negative if CW<br>
- * 0 if collinear<br>
- * <pre>
- * A[P1,P2,P3] = (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1)
- * = (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
- * </pre>
- */
-Orientation Orient2d(Point& pa, Point& pb, Point& pc)
-{
- double detleft = (pa.x - pc.x) * (pb.y - pc.y);
- double detright = (pa.y - pc.y) * (pb.x - pc.x);
- double val = detleft - detright;
- if (val > -EPSILON && val < EPSILON) {
- return COLLINEAR;
- } else if (val > 0) {
- return CCW;
- }
- return CW;
-}
-
-/*
-bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
-{
- double pdx = pd.x;
- double pdy = pd.y;
- double adx = pa.x - pdx;
- double ady = pa.y - pdy;
- double bdx = pb.x - pdx;
- double bdy = pb.y - pdy;
-
- double adxbdy = adx * bdy;
- double bdxady = bdx * ady;
- double oabd = adxbdy - bdxady;
-
- if (oabd <= EPSILON) {
- return false;
- }
-
- double cdx = pc.x - pdx;
- double cdy = pc.y - pdy;
-
- double cdxady = cdx * ady;
- double adxcdy = adx * cdy;
- double ocad = cdxady - adxcdy;
-
- if (ocad <= EPSILON) {
- return false;
- }
-
- return true;
-}
-
-*/
-
-bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
-{
- double oadb = (pa.x - pb.x)*(pd.y - pb.y) - (pd.x - pb.x)*(pa.y - pb.y);
- if (oadb >= -EPSILON) {
- return false;
- }
-
- double oadc = (pa.x - pc.x)*(pd.y - pc.y) - (pd.x - pc.x)*(pa.y - pc.y);
- if (oadc <= EPSILON) {
- return false;
- }
- return true;
-}
-
-}
-
-#endif
-
diff --git a/src/3rdparty/poly2tri/poly2tri.h b/src/3rdparty/poly2tri/poly2tri.h
deleted file mode 100644
index 042cb3dc..00000000
--- a/src/3rdparty/poly2tri/poly2tri.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef POLY2TRI_H
-#define POLY2TRI_H
-
-#include "common/shapes.h"
-#include "sweep/cdt.h"
-
-#endif
-
diff --git a/src/3rdparty/poly2tri/poly2tri.pro b/src/3rdparty/poly2tri/poly2tri.pro
deleted file mode 100644
index 6c5f7692..00000000
--- a/src/3rdparty/poly2tri/poly2tri.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-TARGET = qt_poly2tri
-
-CONFIG += staticlib warn_off optimize_full
-
-load(qt_helper_lib)
-
-# workaround for QTBUG-31586
-contains(QT_CONFIG, c++11): CONFIG += c++11
-
-gcc {
- QMAKE_CFLAGS_OPTIMIZE_FULL += -ffast-math
- !clang:!intel_icc:!rim_qcc: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=return-type
-}
-
-HEADERS += poly2tri.h \
- common/shapes.h \
- common/utils.h \
- sweep/advancing_front.h \
- sweep/cdt.h \
- sweep/sweep.h \
- sweep/sweep_context.h
-
-SOURCES += common/shapes.cpp \
- sweep/sweep_context.cpp \
- sweep/cdt.cpp \
- sweep/sweep.cpp \
- sweep/advancing_front.cpp
diff --git a/src/3rdparty/poly2tri/qt_attribution.json b/src/3rdparty/poly2tri/qt_attribution.json
deleted file mode 100644
index 0571384d..00000000
--- a/src/3rdparty/poly2tri/qt_attribution.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Id": "poly2tri",
- "Name": "Poly2Tri Polygon Triangulation Library",
- "QDocModule": "qtpositioning",
- "QtUsage": "Used in the QML plugin of Qt Location and in Qt Positioning.",
-
- "Description": "Poly2Tri is a sweepline constrained Delaunay Polygon Triangulation Library.",
- "Homepage": "https://github.com/greenm01/poly2tri",
- "LicenseId": "BSD-3-Clause",
- "License": "BSD 3-clause \"New\" or \"Revised\" License",
- "LicenseFile": "LICENSE",
- "Copyright": "Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors"
-}
diff --git a/src/3rdparty/poly2tri/sweep/advancing_front.cpp b/src/3rdparty/poly2tri/sweep/advancing_front.cpp
deleted file mode 100644
index 03779840..00000000
--- a/src/3rdparty/poly2tri/sweep/advancing_front.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "advancing_front.h"
-
-namespace p2t {
-
-AdvancingFront::AdvancingFront(Node& head, Node& tail)
-{
- head_ = &head;
- tail_ = &tail;
- search_node_ = &head;
-}
-
-Node* AdvancingFront::LocateNode(const double& x)
-{
- Node* node = search_node_;
-
- if (x < node->value) {
- while ((node = node->prev) != NULL) {
- if (x >= node->value) {
- search_node_ = node;
- return node;
- }
- }
- } else {
- while ((node = node->next) != NULL) {
- if (x < node->value) {
- search_node_ = node->prev;
- return node->prev;
- }
- }
- }
- return NULL;
-}
-
-Node* AdvancingFront::FindSearchNode(const double& x)
-{
- (void)x; // suppress compiler warnings "unused parameter 'x'"
- // TODO: implement BST index
- return search_node_;
-}
-
-Node* AdvancingFront::LocatePoint(const Point* point)
-{
- const double px = point->x;
- Node* node = FindSearchNode(px);
- const double nx = node->point->x;
-
- if (px == nx) {
- if (point != node->point) {
- // We might have two nodes with same x value for a short time
- if (point == node->prev->point) {
- node = node->prev;
- } else if (point == node->next->point) {
- node = node->next;
- } else {
- assert(0);
- }
- }
- } else if (px < nx) {
- while ((node = node->prev) != NULL) {
- if (point == node->point) {
- break;
- }
- }
- } else {
- while ((node = node->next) != NULL) {
- if (point == node->point)
- break;
- }
- }
- if (node) search_node_ = node;
- return node;
-}
-
-AdvancingFront::~AdvancingFront()
-{
-}
-
-}
-
diff --git a/src/3rdparty/poly2tri/sweep/advancing_front.h b/src/3rdparty/poly2tri/sweep/advancing_front.h
deleted file mode 100644
index bab73d44..00000000
--- a/src/3rdparty/poly2tri/sweep/advancing_front.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ADVANCED_FRONT_H
-#define ADVANCED_FRONT_H
-
-#include "../common/shapes.h"
-
-namespace p2t {
-
-struct Node;
-
-// Advancing front node
-struct Node {
- Point* point;
- Triangle* triangle;
-
- Node* next;
- Node* prev;
-
- double value;
-
- Node(Point& p) : point(&p), triangle(NULL), next(NULL), prev(NULL), value(p.x)
- {
- }
-
- Node(Point& p, Triangle& t) : point(&p), triangle(&t), next(NULL), prev(NULL), value(p.x)
- {
- }
-
-};
-
-// Advancing front
-class AdvancingFront {
-public:
-
-AdvancingFront(Node& head, Node& tail);
-// Destructor
-~AdvancingFront();
-
-Node* head();
-void set_head(Node* node);
-Node* tail();
-void set_tail(Node* node);
-Node* search();
-void set_search(Node* node);
-
-/// Locate insertion point along advancing front
-Node* LocateNode(const double& x);
-
-Node* LocatePoint(const Point* point);
-
-private:
-
-Node* head_, *tail_, *search_node_;
-
-Node* FindSearchNode(const double& x);
-};
-
-inline Node* AdvancingFront::head()
-{
- return head_;
-}
-inline void AdvancingFront::set_head(Node* node)
-{
- head_ = node;
-}
-
-inline Node* AdvancingFront::tail()
-{
- return tail_;
-}
-inline void AdvancingFront::set_tail(Node* node)
-{
- tail_ = node;
-}
-
-inline Node* AdvancingFront::search()
-{
- return search_node_;
-}
-
-inline void AdvancingFront::set_search(Node* node)
-{
- search_node_ = node;
-}
-
-}
-
-#endif
diff --git a/src/3rdparty/poly2tri/sweep/cdt.cpp b/src/3rdparty/poly2tri/sweep/cdt.cpp
deleted file mode 100644
index e0b3ec79..00000000
--- a/src/3rdparty/poly2tri/sweep/cdt.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "cdt.h"
-
-namespace p2t {
-
-CDT::CDT(std::vector<Point*> polyline)
-{
- sweep_context_ = new SweepContext(polyline);
- sweep_ = new Sweep;
-}
-
-void CDT::AddHole(std::vector<Point*> polyline)
-{
- sweep_context_->AddHole(polyline);
-}
-
-void CDT::AddPoint(Point* point) {
- sweep_context_->AddPoint(point);
-}
-
-void CDT::Triangulate()
-{
- sweep_->Triangulate(*sweep_context_);
-}
-
-std::vector<p2t::Triangle*> CDT::GetTriangles()
-{
- return sweep_context_->GetTriangles();
-}
-
-std::list<p2t::Triangle*> CDT::GetMap()
-{
- return sweep_context_->GetMap();
-}
-
-CDT::~CDT()
-{
- delete sweep_context_;
- delete sweep_;
-}
-
-}
-
diff --git a/src/3rdparty/poly2tri/sweep/cdt.h b/src/3rdparty/poly2tri/sweep/cdt.h
deleted file mode 100644
index e7b703de..00000000
--- a/src/3rdparty/poly2tri/sweep/cdt.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CDT_H
-#define CDT_H
-
-#include "advancing_front.h"
-#include "sweep_context.h"
-#include "sweep.h"
-
-/**
- *
- * @author Mason Green <mason.green@gmail.com>
- *
- */
-
-namespace p2t {
-
-class CDT
-{
-public:
-
- /**
- * Constructor - add polyline with non repeating points
- *
- * @param polyline
- */
- CDT(std::vector<Point*> polyline);
-
- /**
- * Destructor - clean up memory
- */
- ~CDT();
-
- /**
- * Add a hole
- *
- * @param polyline
- */
- void AddHole(std::vector<Point*> polyline);
-
- /**
- * Add a steiner point
- *
- * @param point
- */
- void AddPoint(Point* point);
-
- /**
- * Triangulate - do this AFTER you've added the polyline, holes, and Steiner points
- */
- void Triangulate();
-
- /**
- * Get CDT triangles
- */
- std::vector<Triangle*> GetTriangles();
-
- /**
- * Get triangle map
- */
- std::list<Triangle*> GetMap();
-
- private:
-
- /**
- * Internals
- */
-
- SweepContext* sweep_context_;
- Sweep* sweep_;
-
-};
-
-}
-
-#endif
diff --git a/src/3rdparty/poly2tri/sweep/sweep.cpp b/src/3rdparty/poly2tri/sweep/sweep.cpp
deleted file mode 100644
index 954d2db2..00000000
--- a/src/3rdparty/poly2tri/sweep/sweep.cpp
+++ /dev/null
@@ -1,814 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stddef.h>
-#include <stdexcept>
-#include "sweep.h"
-#include "sweep_context.h"
-#include "advancing_front.h"
-#include "../common/utils.h"
-
-namespace p2t {
-
-// Triangulate simple polygon with holes
-void Sweep::Triangulate(SweepContext& tcx)
-{
- tcx.InitTriangulation();
- tcx.CreateAdvancingFront(nodes_);
- // Sweep points; build mesh
- SweepPoints(tcx);
- // Clean up
- FinalizationPolygon(tcx);
-}
-
-void Sweep::SweepPoints(SweepContext& tcx)
-{
- for (int i = 1; i < tcx.point_count(); i++) {
- Point& point = *tcx.GetPoint(i);
- Node* node = &PointEvent(tcx, point);
- for (unsigned int i = 0; i < point.edge_list.size(); i++) {
- EdgeEvent(tcx, point.edge_list[i], node);
- }
- }
-}
-
-void Sweep::FinalizationPolygon(SweepContext& tcx)
-{
- // Get an Internal triangle to start with
- Triangle* t = tcx.front()->head()->next->triangle;
- Point* p = tcx.front()->head()->next->point;
- while (!t->GetConstrainedEdgeCW(*p)) {
- t = t->NeighborCCW(*p);
- }
-
- // Collect interior triangles constrained by edges
- tcx.MeshClean(*t);
-}
-
-Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
-{
- Node& node = tcx.LocateNode(point);
- Node& new_node = NewFrontTriangle(tcx, point, node);
-
- // Only need to check +epsilon since point never have smaller
- // x value than node due to how we fetch nodes from the front
- if (point.x <= node.point->x + EPSILON) {
- Fill(tcx, node);
- }
-
- //tcx.AddNode(new_node);
-
- FillAdvancingFront(tcx, new_node);
- return new_node;
-}
-
-void Sweep::EdgeEvent(SweepContext& tcx, Edge* edge, Node* node)
-{
- tcx.edge_event.constrained_edge = edge;
- tcx.edge_event.right = (edge->p->x > edge->q->x);
-
- if (IsEdgeSideOfTriangle(*node->triangle, *edge->p, *edge->q)) {
- return;
- }
-
- // For now we will do all needed filling
- // TODO: integrate with flip process might give some better performance
- // but for now this avoid the issue with cases that needs both flips and fills
- FillEdgeEvent(tcx, edge, node);
- EdgeEvent(tcx, *edge->p, *edge->q, node->triangle, *edge->q);
-}
-
-void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Point& point)
-{
- if (IsEdgeSideOfTriangle(*triangle, ep, eq)) {
- return;
- }
-
- Point* p1 = triangle->PointCCW(point);
- Orientation o1 = Orient2d(eq, *p1, ep);
- if (o1 == COLLINEAR) {
- if ( triangle->Contains(&eq, p1)) {
- triangle->MarkConstrainedEdge(&eq, p1 );
- // We are modifying the constraint maybe it would be better to
- // not change the given constraint and just keep a variable for the new constraint
- tcx.edge_event.constrained_edge->q = p1;
- triangle = &triangle->NeighborAcross(point);
- EdgeEvent( tcx, ep, *p1, triangle, *p1 );
- } else {
- std::runtime_error("EdgeEvent - collinear points not supported");
- assert(0);
- }
- return;
- }
-
- Point* p2 = triangle->PointCW(point);
- Orientation o2 = Orient2d(eq, *p2, ep);
- if (o2 == COLLINEAR) {
- if ( triangle->Contains(&eq, p2)) {
- triangle->MarkConstrainedEdge(&eq, p2 );
- // We are modifying the constraint maybe it would be better to
- // not change the given constraint and just keep a variable for the new constraint
- tcx.edge_event.constrained_edge->q = p2;
- triangle = &triangle->NeighborAcross(point);
- EdgeEvent( tcx, ep, *p2, triangle, *p2 );
- } else {
- std::runtime_error("EdgeEvent - collinear points not supported");
- assert(0);
- }
- return;
- }
-
- if (o1 == o2) {
- // Need to decide if we are rotating CW or CCW to get to a triangle
- // that will cross edge
- if (o1 == CW) {
- triangle = triangle->NeighborCCW(point);
- } else{
- triangle = triangle->NeighborCW(point);
- }
- EdgeEvent(tcx, ep, eq, triangle, point);
- } else {
- // This triangle crosses constraint so lets flippin start!
- FlipEdgeEvent(tcx, ep, eq, triangle, point);
- }
-}
-
-bool Sweep::IsEdgeSideOfTriangle(Triangle& triangle, Point& ep, Point& eq)
-{
- int index = triangle.EdgeIndex(&ep, &eq);
-
- if (index != -1) {
- triangle.MarkConstrainedEdge(index);
- Triangle* t = triangle.GetNeighbor(index);
- if (t) {
- t->MarkConstrainedEdge(&ep, &eq);
- }
- return true;
- }
- return false;
-}
-
-Node& Sweep::NewFrontTriangle(SweepContext& tcx, Point& point, Node& node)
-{
- Triangle* triangle = new Triangle(point, *node.point, *node.next->point);
-
- triangle->MarkNeighbor(*node.triangle);
- tcx.AddToMap(triangle);
-
- Node* new_node = new Node(point);
- nodes_.push_back(new_node);
-
- new_node->next = node.next;
- new_node->prev = &node;
- node.next->prev = new_node;
- node.next = new_node;
-
- if (!Legalize(tcx, *triangle)) {
- tcx.MapTriangleToNodes(*triangle);
- }
-
- return *new_node;
-}
-
-void Sweep::Fill(SweepContext& tcx, Node& node)
-{
- Triangle* triangle = new Triangle(*node.prev->point, *node.point, *node.next->point);
-
- // TODO: should copy the constrained_edge value from neighbor triangles
- // for now constrained_edge values are copied during the legalize
- triangle->MarkNeighbor(*node.prev->triangle);
- triangle->MarkNeighbor(*node.triangle);
-
- tcx.AddToMap(triangle);
-
- // Update the advancing front
- node.prev->next = node.next;
- node.next->prev = node.prev;
-
- // If it was legalized the triangle has already been mapped
- if (!Legalize(tcx, *triangle)) {
- tcx.MapTriangleToNodes(*triangle);
- }
-
-}
-
-void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
-{
-
- // Fill right holes
- Node* node = n.next;
-
- while (node->next) {
- // if HoleAngle exceeds 90 degrees then break.
- if (LargeHole_DontFill(node)) break;
- Fill(tcx, *node);
- node = node->next;
- }
-
- // Fill left holes
- node = n.prev;
-
- while (node->prev) {
- // if HoleAngle exceeds 90 degrees then break.
- if (LargeHole_DontFill(node)) break;
- Fill(tcx, *node);
- node = node->prev;
- }
-
- // Fill right basins
- if (n.next && n.next->next) {
- double angle = BasinAngle(n);
- if (angle < PI_3div4) {
- FillBasin(tcx, n);
- }
- }
-}
-
-// True if HoleAngle exceeds 90 degrees.
-bool Sweep::LargeHole_DontFill(Node* node) {
-
- Node* nextNode = node->next;
- Node* prevNode = node->prev;
- if (!AngleExceeds90Degrees(node->point, nextNode->point, prevNode->point))
- return false;
-
- // Check additional points on front.
- Node* next2Node = nextNode->next;
- // "..Plus.." because only want angles on same side as point being added.
- if ((next2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, next2Node->point, prevNode->point))
- return false;
-
- Node* prev2Node = prevNode->prev;
- // "..Plus.." because only want angles on same side as point being added.
- if ((prev2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, nextNode->point, prev2Node->point))
- return false;
-
- return true;
-}
-
-bool Sweep::AngleExceeds90Degrees(Point* origin, Point* pa, Point* pb) {
- double angle = Angle(*origin, *pa, *pb);
- bool exceeds90Degrees = ((angle > PI_div2) || (angle < -PI_div2));
- return exceeds90Degrees;
-}
-
-bool Sweep::AngleExceedsPlus90DegreesOrIsNegative(Point* origin, Point* pa, Point* pb) {
- double angle = Angle(*origin, *pa, *pb);
- bool exceedsPlus90DegreesOrIsNegative = (angle > PI_div2) || (angle < 0);
- return exceedsPlus90DegreesOrIsNegative;
-}
-
-double Sweep::Angle(Point& origin, Point& pa, Point& pb) {
- /* Complex plane
- * ab = cosA +i*sinA
- * ab = (ax + ay*i)(bx + by*i) = (ax*bx + ay*by) + i(ax*by-ay*bx)
- * atan2(y,x) computes the principal value of the argument function
- * applied to the complex number x+iy
- * Where x = ax*bx + ay*by
- * y = ax*by - ay*bx
- */
- double px = origin.x;
- double py = origin.y;
- double ax = pa.x- px;
- double ay = pa.y - py;
- double bx = pb.x - px;
- double by = pb.y - py;
- double x = ax * by - ay * bx;
- double y = ax * bx + ay * by;
- double angle = atan2(x, y);
- return angle;
-}
-
-double Sweep::BasinAngle(Node& node)
-{
- double ax = node.point->x - node.next->next->point->x;
- double ay = node.point->y - node.next->next->point->y;
- return atan2(ay, ax);
-}
-
-double Sweep::HoleAngle(Node& node)
-{
- /* Complex plane
- * ab = cosA +i*sinA
- * ab = (ax + ay*i)(bx + by*i) = (ax*bx + ay*by) + i(ax*by-ay*bx)
- * atan2(y,x) computes the principal value of the argument function
- * applied to the complex number x+iy
- * Where x = ax*bx + ay*by
- * y = ax*by - ay*bx
- */
- double ax = node.next->point->x - node.point->x;
- double ay = node.next->point->y - node.point->y;
- double bx = node.prev->point->x - node.point->x;
- double by = node.prev->point->y - node.point->y;
- return atan2(ax * by - ay * bx, ax * bx + ay * by);
-}
-
-bool Sweep::Legalize(SweepContext& tcx, Triangle& t)
-{
- // To legalize a triangle we start by finding if any of the three edges
- // violate the Delaunay condition
- for (int i = 0; i < 3; i++) {
- if (t.delaunay_edge[i])
- continue;
-
- Triangle* ot = t.GetNeighbor(i);
-
- if (ot) {
- Point* p = t.GetPoint(i);
- Point* op = ot->OppositePoint(t, *p);
- int oi = ot->Index(op);
-
- // If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization)
- // then we should not try to legalize
- if (ot->constrained_edge[oi] || ot->delaunay_edge[oi]) {
- t.constrained_edge[i] = ot->constrained_edge[oi];
- continue;
- }
-
- bool inside = Incircle(*p, *t.PointCCW(*p), *t.PointCW(*p), *op);
-
- if (inside) {
- // Lets mark this shared edge as Delaunay
- t.delaunay_edge[i] = true;
- ot->delaunay_edge[oi] = true;
-
- // Lets rotate shared edge one vertex CW to legalize it
- RotateTrianglePair(t, *p, *ot, *op);
-
- // We now got one valid Delaunay Edge shared by two triangles
- // This gives us 4 new edges to check for Delaunay
-
- // Make sure that triangle to node mapping is done only one time for a specific triangle
- bool not_legalized = !Legalize(tcx, t);
- if (not_legalized) {
- tcx.MapTriangleToNodes(t);
- }
-
- not_legalized = !Legalize(tcx, *ot);
- if (not_legalized)
- tcx.MapTriangleToNodes(*ot);
-
- // Reset the Delaunay edges, since they only are valid Delaunay edges
- // until we add a new triangle or point.
- // XXX: need to think about this. Can these edges be tried after we
- // return to previous recursive level?
- t.delaunay_edge[i] = false;
- ot->delaunay_edge[oi] = false;
-
- // If triangle have been legalized no need to check the other edges since
- // the recursive legalization will handles those so we can end here.
- return true;
- }
- }
- }
- return false;
-}
-
-bool Sweep::Incircle(Point& pa, Point& pb, Point& pc, Point& pd)
-{
- double adx = pa.x - pd.x;
- double ady = pa.y - pd.y;
- double bdx = pb.x - pd.x;
- double bdy = pb.y - pd.y;
-
- double adxbdy = adx * bdy;
- double bdxady = bdx * ady;
- double oabd = adxbdy - bdxady;
-
- if (oabd <= 0)
- return false;
-
- double cdx = pc.x - pd.x;
- double cdy = pc.y - pd.y;
-
- double cdxady = cdx * ady;
- double adxcdy = adx * cdy;
- double ocad = cdxady - adxcdy;
-
- if (ocad <= 0)
- return false;
-
- double bdxcdy = bdx * cdy;
- double cdxbdy = cdx * bdy;
-
- double alift = adx * adx + ady * ady;
- double blift = bdx * bdx + bdy * bdy;
- double clift = cdx * cdx + cdy * cdy;
-
- double det = alift * (bdxcdy - cdxbdy) + blift * ocad + clift * oabd;
-
- return det > 0;
-}
-
-void Sweep::RotateTrianglePair(Triangle& t, Point& p, Triangle& ot, Point& op)
-{
- Triangle* n1, *n2, *n3, *n4;
- n1 = t.NeighborCCW(p);
- n2 = t.NeighborCW(p);
- n3 = ot.NeighborCCW(op);
- n4 = ot.NeighborCW(op);
-
- bool ce1, ce2, ce3, ce4;
- ce1 = t.GetConstrainedEdgeCCW(p);
- ce2 = t.GetConstrainedEdgeCW(p);
- ce3 = ot.GetConstrainedEdgeCCW(op);
- ce4 = ot.GetConstrainedEdgeCW(op);
-
- bool de1, de2, de3, de4;
- de1 = t.GetDelunayEdgeCCW(p);
- de2 = t.GetDelunayEdgeCW(p);
- de3 = ot.GetDelunayEdgeCCW(op);
- de4 = ot.GetDelunayEdgeCW(op);
-
- t.Legalize(p, op);
- ot.Legalize(op, p);
-
- // Remap delaunay_edge
- ot.SetDelunayEdgeCCW(p, de1);
- t.SetDelunayEdgeCW(p, de2);
- t.SetDelunayEdgeCCW(op, de3);
- ot.SetDelunayEdgeCW(op, de4);
-
- // Remap constrained_edge
- ot.SetConstrainedEdgeCCW(p, ce1);
- t.SetConstrainedEdgeCW(p, ce2);
- t.SetConstrainedEdgeCCW(op, ce3);
- ot.SetConstrainedEdgeCW(op, ce4);
-
- // Remap neighbors
- // XXX: might optimize the markNeighbor by keeping track of
- // what side should be assigned to what neighbor after the
- // rotation. Now mark neighbor does lots of testing to find
- // the right side.
- t.ClearNeighbors();
- ot.ClearNeighbors();
- if (n1) ot.MarkNeighbor(*n1);
- if (n2) t.MarkNeighbor(*n2);
- if (n3) t.MarkNeighbor(*n3);
- if (n4) ot.MarkNeighbor(*n4);
- t.MarkNeighbor(ot);
-}
-
-void Sweep::FillBasin(SweepContext& tcx, Node& node)
-{
- if (Orient2d(*node.point, *node.next->point, *node.next->next->point) == CCW) {
- tcx.basin.left_node = node.next->next;
- } else {
- tcx.basin.left_node = node.next;
- }
-
- // Find the bottom and right node
- tcx.basin.bottom_node = tcx.basin.left_node;
- while (tcx.basin.bottom_node->next
- && tcx.basin.bottom_node->point->y >= tcx.basin.bottom_node->next->point->y) {
- tcx.basin.bottom_node = tcx.basin.bottom_node->next;
- }
- if (tcx.basin.bottom_node == tcx.basin.left_node) {
- // No valid basin
- return;
- }
-
- tcx.basin.right_node = tcx.basin.bottom_node;
- while (tcx.basin.right_node->next
- && tcx.basin.right_node->point->y < tcx.basin.right_node->next->point->y) {
- tcx.basin.right_node = tcx.basin.right_node->next;
- }
- if (tcx.basin.right_node == tcx.basin.bottom_node) {
- // No valid basins
- return;
- }
-
- tcx.basin.width = tcx.basin.right_node->point->x - tcx.basin.left_node->point->x;
- tcx.basin.left_highest = tcx.basin.left_node->point->y > tcx.basin.right_node->point->y;
-
- FillBasinReq(tcx, tcx.basin.bottom_node);
-}
-
-void Sweep::FillBasinReq(SweepContext& tcx, Node* node)
-{
- // if shallow stop filling
- if (IsShallow(tcx, *node)) {
- return;
- }
-
- Fill(tcx, *node);
-
- if (node->prev == tcx.basin.left_node && node->next == tcx.basin.right_node) {
- return;
- } else if (node->prev == tcx.basin.left_node) {
- Orientation o = Orient2d(*node->point, *node->next->point, *node->next->next->point);
- if (o == CW) {
- return;
- }
- node = node->next;
- } else if (node->next == tcx.basin.right_node) {
- Orientation o = Orient2d(*node->point, *node->prev->point, *node->prev->prev->point);
- if (o == CCW) {
- return;
- }
- node = node->prev;
- } else {
- // Continue with the neighbor node with lowest Y value
- if (node->prev->point->y < node->next->point->y) {
- node = node->prev;
- } else {
- node = node->next;
- }
- }
-
- FillBasinReq(tcx, node);
-}
-
-bool Sweep::IsShallow(SweepContext& tcx, Node& node)
-{
- double height;
-
- if (tcx.basin.left_highest) {
- height = tcx.basin.left_node->point->y - node.point->y;
- } else {
- height = tcx.basin.right_node->point->y - node.point->y;
- }
-
- // if shallow stop filling
- if (tcx.basin.width > height) {
- return true;
- }
- return false;
-}
-
-void Sweep::FillEdgeEvent(SweepContext& tcx, Edge* edge, Node* node)
-{
- if (tcx.edge_event.right) {
- FillRightAboveEdgeEvent(tcx, edge, node);
- } else {
- FillLeftAboveEdgeEvent(tcx, edge, node);
- }
-}
-
-void Sweep::FillRightAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node)
-{
- while (node->next->point->x < edge->p->x) {
- // Check if next node is below the edge
- if (Orient2d(*edge->q, *node->next->point, *edge->p) == CCW) {
- FillRightBelowEdgeEvent(tcx, edge, *node);
- } else {
- node = node->next;
- }
- }
-}
-
-void Sweep::FillRightBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
-{
- if (node.point->x < edge->p->x) {
- if (Orient2d(*node.point, *node.next->point, *node.next->next->point) == CCW) {
- // Concave
- FillRightConcaveEdgeEvent(tcx, edge, node);
- } else{
- // Convex
- FillRightConvexEdgeEvent(tcx, edge, node);
- // Retry this one
- FillRightBelowEdgeEvent(tcx, edge, node);
- }
- }
-}
-
-void Sweep::FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
-{
- Fill(tcx, *node.next);
- if (node.next->point != edge->p) {
- // Next above or below edge?
- if (Orient2d(*edge->q, *node.next->point, *edge->p) == CCW) {
- // Below
- if (Orient2d(*node.point, *node.next->point, *node.next->next->point) == CCW) {
- // Next is concave
- FillRightConcaveEdgeEvent(tcx, edge, node);
- } else {
- // Next is convex
- }
- }
- }
-
-}
-
-void Sweep::FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
-{
- // Next concave or convex?
- if (Orient2d(*node.next->point, *node.next->next->point, *node.next->next->next->point) == CCW) {
- // Concave
- FillRightConcaveEdgeEvent(tcx, edge, *node.next);
- } else{
- // Convex
- // Next above or below edge?
- if (Orient2d(*edge->q, *node.next->next->point, *edge->p) == CCW) {
- // Below
- FillRightConvexEdgeEvent(tcx, edge, *node.next);
- } else{
- // Above
- }
- }
-}
-
-void Sweep::FillLeftAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node)
-{
- while (node->prev->point->x > edge->p->x) {
- // Check if next node is below the edge
- if (Orient2d(*edge->q, *node->prev->point, *edge->p) == CW) {
- FillLeftBelowEdgeEvent(tcx, edge, *node);
- } else {
- node = node->prev;
- }
- }
-}
-
-void Sweep::FillLeftBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
-{
- if (node.point->x > edge->p->x) {
- if (Orient2d(*node.point, *node.prev->point, *node.prev->prev->point) == CW) {
- // Concave
- FillLeftConcaveEdgeEvent(tcx, edge, node);
- } else {
- // Convex
- FillLeftConvexEdgeEvent(tcx, edge, node);
- // Retry this one
- FillLeftBelowEdgeEvent(tcx, edge, node);
- }
- }
-}
-
-void Sweep::FillLeftConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
-{
- // Next concave or convex?
- if (Orient2d(*node.prev->point, *node.prev->prev->point, *node.prev->prev->prev->point) == CW) {
- // Concave
- FillLeftConcaveEdgeEvent(tcx, edge, *node.prev);
- } else{
- // Convex
- // Next above or below edge?
- if (Orient2d(*edge->q, *node.prev->prev->point, *edge->p) == CW) {
- // Below
- FillLeftConvexEdgeEvent(tcx, edge, *node.prev);
- } else{
- // Above
- }
- }
-}
-
-void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node)
-{
- Fill(tcx, *node.prev);
- if (node.prev->point != edge->p) {
- // Next above or below edge?
- if (Orient2d(*edge->q, *node.prev->point, *edge->p) == CW) {
- // Below
- if (Orient2d(*node.point, *node.prev->point, *node.prev->prev->point) == CW) {
- // Next is concave
- FillLeftConcaveEdgeEvent(tcx, edge, node);
- } else{
- // Next is convex
- }
- }
- }
-
-}
-
-void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p)
-{
- Triangle& ot = t->NeighborAcross(p);
- Point& op = *ot.OppositePoint(*t, p);
-
- if (&ot == NULL) {
- // If we want to integrate the fillEdgeEvent do it here
- // With current implementation we should never get here
- //throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
- assert(0);
- }
-
- if (InScanArea(p, *t->PointCCW(p), *t->PointCW(p), op)) {
- // Lets rotate shared edge one vertex CW
- RotateTrianglePair(*t, p, ot, op);
- tcx.MapTriangleToNodes(*t);
- tcx.MapTriangleToNodes(ot);
-
- if (p == eq && op == ep) {
- if (eq == *tcx.edge_event.constrained_edge->q && ep == *tcx.edge_event.constrained_edge->p) {
- t->MarkConstrainedEdge(&ep, &eq);
- ot.MarkConstrainedEdge(&ep, &eq);
- Legalize(tcx, *t);
- Legalize(tcx, ot);
- } else {
- // XXX: I think one of the triangles should be legalized here?
- }
- } else {
- Orientation o = Orient2d(eq, op, ep);
- t = &NextFlipTriangle(tcx, (int)o, *t, ot, p, op);
- FlipEdgeEvent(tcx, ep, eq, t, p);
- }
- } else {
- Point& newP = NextFlipPoint(ep, eq, ot, op);
- FlipScanEdgeEvent(tcx, ep, eq, *t, ot, newP);
- EdgeEvent(tcx, ep, eq, t, p);
- }
-}
-
-Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangle& ot, Point& p, Point& op)
-{
- if (o == CCW) {
- // ot is not crossing edge after flip
- int edge_index = ot.EdgeIndex(&p, &op);
- ot.delaunay_edge[edge_index] = true;
- Legalize(tcx, ot);
- ot.ClearDelunayEdges();
- return t;
- }
-
- // t is not crossing edge after flip
- int edge_index = t.EdgeIndex(&p, &op);
-
- t.delaunay_edge[edge_index] = true;
- Legalize(tcx, t);
- t.ClearDelunayEdges();
- return ot;
-}
-
-Point& Sweep::NextFlipPoint(Point& ep, Point& eq, Triangle& ot, Point& op)
-{
- Orientation o2d = Orient2d(eq, op, ep);
- if (o2d == CW) {
- // Right
- return *ot.PointCCW(op);
- } else if (o2d == CCW) {
- // Left
- return *ot.PointCW(op);
- } else{
- //throw new RuntimeException("[Unsupported] Opposing point on constrained edge");
- assert(0);
- }
-}
-
-void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& flip_triangle,
- Triangle& t, Point& p)
-{
- Triangle& ot = t.NeighborAcross(p);
- Point& op = *ot.OppositePoint(t, p);
-
- if (&t.NeighborAcross(p) == NULL) {
- // If we want to integrate the fillEdgeEvent do it here
- // With current implementation we should never get here
- //throw new RuntimeException( "[BUG:FIXME] FLIP failed due to missing triangle");
- assert(0);
- }
-
- if (InScanArea(eq, *flip_triangle.PointCCW(eq), *flip_triangle.PointCW(eq), op)) {
- // flip with new edge op->eq
- FlipEdgeEvent(tcx, eq, op, &ot, op);
- // TODO: Actually I just figured out that it should be possible to
- // improve this by getting the next ot and op before the above
- // flip and continue the flipScanEdgeEvent here
- // set new ot and op here and loop back to inScanArea test
- // also need to set a new flip_triangle first
- // Turns out at first glance that this is somewhat complicated
- // so it will have to wait.
- } else{
- Point& newP = NextFlipPoint(ep, eq, ot, op);
- FlipScanEdgeEvent(tcx, ep, eq, flip_triangle, ot, newP);
- }
-}
-
-Sweep::~Sweep() {
-
- // Clean up memory
- for (size_t i = 0; i < nodes_.size(); i++) {
- delete nodes_[i];
- }
-
-}
-
-}
-
diff --git a/src/3rdparty/poly2tri/sweep/sweep.h b/src/3rdparty/poly2tri/sweep/sweep.h
deleted file mode 100644
index 9bb0b5d8..00000000
--- a/src/3rdparty/poly2tri/sweep/sweep.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/**
- * Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V. and
- * Zalik, B.(2008)'Sweep-line algorithm for constrained Delaunay triangulation',
- * International Journal of Geographical Information Science
- *
- * "FlipScan" Constrained Edge Algorithm invented by Thomas Åhlén, thahlen@gmail.com
- */
-
-#ifndef SWEEP_H
-#define SWEEP_H
-
-#include <vector>
-
-namespace p2t {
-
-class SweepContext;
-struct Node;
-struct Point;
-struct Edge;
-class Triangle;
-
-class Sweep
-{
-public:
-
- /**
- * Triangulate
- *
- * @param tcx
- */
- void Triangulate(SweepContext& tcx);
-
- /**
- * Destructor - clean up memory
- */
- ~Sweep();
-
-private:
-
- /**
- * Start sweeping the Y-sorted point set from bottom to top
- *
- * @param tcx
- */
- void SweepPoints(SweepContext& tcx);
-
- /**
- * Find closes node to the left of the new point and
- * create a new triangle. If needed new holes and basins
- * will be filled to.
- *
- * @param tcx
- * @param point
- * @return
- */
- Node& PointEvent(SweepContext& tcx, Point& point);
-
- /**
- *
- *
- * @param tcx
- * @param edge
- * @param node
- */
- void EdgeEvent(SweepContext& tcx, Edge* edge, Node* node);
-
- void EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Point& point);
-
- /**
- * Creates a new front triangle and legalize it
- *
- * @param tcx
- * @param point
- * @param node
- * @return
- */
- Node& NewFrontTriangle(SweepContext& tcx, Point& point, Node& node);
-
- /**
- * Adds a triangle to the advancing front to fill a hole.
- * @param tcx
- * @param node - middle node, that is the bottom of the hole
- */
- void Fill(SweepContext& tcx, Node& node);
-
- /**
- * Returns true if triangle was legalized
- */
- bool Legalize(SweepContext& tcx, Triangle& t);
-
- /**
- * <b>Requirement</b>:<br>
- * 1. a,b and c form a triangle.<br>
- * 2. a and d is know to be on opposite side of bc<br>
- * <pre>
- * a
- * +
- * / \
- * / \
- * b/ \c
- * +-------+
- * / d \
- * / \
- * </pre>
- * <b>Fact</b>: d has to be in area B to have a chance to be inside the circle formed by
- * a,b and c<br>
- * d is outside B if orient2d(a,b,d) or orient2d(c,a,d) is CW<br>
- * This preknowledge gives us a way to optimize the incircle test
- * @param a - triangle point, opposite d
- * @param b - triangle point
- * @param c - triangle point
- * @param d - point opposite a
- * @return true if d is inside circle, false if on circle edge
- */
- bool Incircle(Point& pa, Point& pb, Point& pc, Point& pd);
-
- /**
- * Rotates a triangle pair one vertex CW
- *<pre>
- * n2 n2
- * P +-----+ P +-----+
- * | t /| |\ t |
- * | / | | \ |
- * n1| / |n3 n1| \ |n3
- * | / | after CW | \ |
- * |/ oT | | oT \|
- * +-----+ oP +-----+
- * n4 n4
- * </pre>
- */
- void RotateTrianglePair(Triangle& t, Point& p, Triangle& ot, Point& op);
-
- /**
- * Fills holes in the Advancing Front
- *
- *
- * @param tcx
- * @param n
- */
- void FillAdvancingFront(SweepContext& tcx, Node& n);
-
- // Decision-making about when to Fill hole.
- // Contributed by ToolmakerSteve2
- bool LargeHole_DontFill(Node* node);
- bool AngleExceeds90Degrees(Point* origin, Point* pa, Point* pb);
- bool AngleExceedsPlus90DegreesOrIsNegative(Point* origin, Point* pa, Point* pb);
- double Angle(Point& origin, Point& pa, Point& pb);
-
- /**
- *
- * @param node - middle node
- * @return the angle between 3 front nodes
- */
- double HoleAngle(Node& node);
-
- /**
- * The basin angle is decided against the horizontal line [1,0]
- */
- double BasinAngle(Node& node);
-
- /**
- * Fills a basin that has formed on the Advancing Front to the right
- * of given node.<br>
- * First we decide a left,bottom and right node that forms the
- * boundaries of the basin. Then we do a reqursive fill.
- *
- * @param tcx
- * @param node - starting node, this or next node will be left node
- */
- void FillBasin(SweepContext& tcx, Node& node);
-
- /**
- * Recursive algorithm to fill a Basin with triangles
- *
- * @param tcx
- * @param node - bottom_node
- * @param cnt - counter used to alternate on even and odd numbers
- */
- void FillBasinReq(SweepContext& tcx, Node* node);
-
- bool IsShallow(SweepContext& tcx, Node& node);
-
- bool IsEdgeSideOfTriangle(Triangle& triangle, Point& ep, Point& eq);
-
- void FillEdgeEvent(SweepContext& tcx, Edge* edge, Node* node);
-
- void FillRightAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node);
-
- void FillRightBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node);
-
- void FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node);
-
- void FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node);
-
- void FillLeftAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node);
-
- void FillLeftBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node);
-
- void FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node);
-
- void FillLeftConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node);
-
- void FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p);
-
- /**
- * After a flip we have two triangles and know that only one will still be
- * intersecting the edge. So decide which to contiune with and legalize the other
- *
- * @param tcx
- * @param o - should be the result of an orient2d( eq, op, ep )
- * @param t - triangle 1
- * @param ot - triangle 2
- * @param p - a point shared by both triangles
- * @param op - another point shared by both triangles
- * @return returns the triangle still intersecting the edge
- */
- Triangle& NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangle& ot, Point& p, Point& op);
-
- /**
- * When we need to traverse from one triangle to the next we need
- * the point in current triangle that is the opposite point to the next
- * triangle.
- *
- * @param ep
- * @param eq
- * @param ot
- * @param op
- * @return
- */
- Point& NextFlipPoint(Point& ep, Point& eq, Triangle& ot, Point& op);
-
- /**
- * Scan part of the FlipScan algorithm<br>
- * When a triangle pair isn't flippable we will scan for the next
- * point that is inside the flip triangle scan area. When found
- * we generate a new flipEdgeEvent
- *
- * @param tcx
- * @param ep - last point on the edge we are traversing
- * @param eq - first point on the edge we are traversing
- * @param flipTriangle - the current triangle sharing the point eq with edge
- * @param t
- * @param p
- */
- void FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& flip_triangle, Triangle& t, Point& p);
-
- void FinalizationPolygon(SweepContext& tcx);
-
- std::vector<Node*> nodes_;
-
-};
-
-}
-
-#endif
diff --git a/src/3rdparty/poly2tri/sweep/sweep_context.cpp b/src/3rdparty/poly2tri/sweep/sweep_context.cpp
deleted file mode 100644
index 24dde11f..00000000
--- a/src/3rdparty/poly2tri/sweep/sweep_context.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "sweep_context.h"
-#include <algorithm>
-#include "advancing_front.h"
-
-namespace p2t {
-
-SweepContext::SweepContext(std::vector<Point*> polyline) :
- front_(0),
- head_(0),
- tail_(0),
- af_head_(0),
- af_middle_(0),
- af_tail_(0)
-{
- basin = Basin();
- edge_event = EdgeEvent();
-
- points_ = polyline;
-
- InitEdges(points_);
-}
-
-void SweepContext::AddHole(std::vector<Point*> polyline)
-{
- InitEdges(polyline);
- for (unsigned int i = 0; i < polyline.size(); i++) {
- points_.push_back(polyline[i]);
- }
-}
-
-void SweepContext::AddPoint(Point* point) {
- points_.push_back(point);
-}
-
-std::vector<Triangle*> SweepContext::GetTriangles()
-{
- return triangles_;
-}
-
-std::list<Triangle*> SweepContext::GetMap()
-{
- return map_;
-}
-
-void SweepContext::InitTriangulation()
-{
- double xmax(points_[0]->x), xmin(points_[0]->x);
- double ymax(points_[0]->y), ymin(points_[0]->y);
-
- // Calculate bounds.
- for (unsigned int i = 0; i < points_.size(); i++) {
- Point& p = *points_[i];
- if (p.x > xmax)
- xmax = p.x;
- if (p.x < xmin)
- xmin = p.x;
- if (p.y > ymax)
- ymax = p.y;
- if (p.y < ymin)
- ymin = p.y;
- }
-
- double dx = kAlpha * (xmax - xmin);
- double dy = kAlpha * (ymax - ymin);
- head_ = new Point(xmax + dx, ymin - dy);
- tail_ = new Point(xmin - dx, ymin - dy);
-
- // Sort points along y-axis
- std::sort(points_.begin(), points_.end(), cmp);
-
-}
-
-void SweepContext::InitEdges(std::vector<Point*> polyline)
-{
- int num_points = polyline.size();
- for (int i = 0; i < num_points; i++) {
- int j = i < num_points - 1 ? i + 1 : 0;
- edge_list.push_back(new Edge(*polyline[i], *polyline[j]));
- }
-}
-
-Point* SweepContext::GetPoint(const int& index)
-{
- return points_[index];
-}
-
-void SweepContext::AddToMap(Triangle* triangle)
-{
- map_.push_back(triangle);
-}
-
-Node& SweepContext::LocateNode(Point& point)
-{
- // TODO implement search tree
- return *front_->LocateNode(point.x);
-}
-
-void SweepContext::CreateAdvancingFront(std::vector<Node*> nodes)
-{
-
- (void) nodes;
- // Initial triangle
- Triangle* triangle = new Triangle(*points_[0], *tail_, *head_);
-
- map_.push_back(triangle);
-
- af_head_ = new Node(*triangle->GetPoint(1), *triangle);
- af_middle_ = new Node(*triangle->GetPoint(0), *triangle);
- af_tail_ = new Node(*triangle->GetPoint(2));
- front_ = new AdvancingFront(*af_head_, *af_tail_);
-
- // TODO: More intuitive if head is middles next and not previous?
- // so swap head and tail
- af_head_->next = af_middle_;
- af_middle_->next = af_tail_;
- af_middle_->prev = af_head_;
- af_tail_->prev = af_middle_;
-}
-
-void SweepContext::RemoveNode(Node* node)
-{
- delete node;
-}
-
-void SweepContext::MapTriangleToNodes(Triangle& t)
-{
- for (int i = 0; i < 3; i++) {
- if (!t.GetNeighbor(i)) {
- Node* n = front_->LocatePoint(t.PointCW(*t.GetPoint(i)));
- if (n)
- n->triangle = &t;
- }
- }
-}
-
-void SweepContext::RemoveFromMap(Triangle* triangle)
-{
- map_.remove(triangle);
-}
-
-void SweepContext::MeshClean(Triangle& triangle)
-{
- std::vector<Triangle *> triangles;
- triangles.push_back(&triangle);
-
- while(!triangles.empty()){
- Triangle *t = triangles.back();
- triangles.pop_back();
-
- if (t != NULL && !t->IsInterior()) {
- t->IsInterior(true);
- triangles_.push_back(t);
- for (int i = 0; i < 3; i++) {
- if (!t->constrained_edge[i])
- triangles.push_back(t->GetNeighbor(i));
- }
- }
- }
-}
-
-SweepContext::~SweepContext()
-{
-
- // Clean up memory
-
- delete head_;
- delete tail_;
- delete front_;
- delete af_head_;
- delete af_middle_;
- delete af_tail_;
-
- typedef std::list<Triangle*> type_list;
-
- for (type_list::iterator iter = map_.begin(); iter != map_.end(); ++iter) {
- Triangle* ptr = *iter;
- delete ptr;
- }
-
- for (unsigned int i = 0; i < edge_list.size(); i++) {
- delete edge_list[i];
- }
-
-}
-
-}
diff --git a/src/3rdparty/poly2tri/sweep/sweep_context.h b/src/3rdparty/poly2tri/sweep/sweep_context.h
deleted file mode 100644
index c110a744..00000000
--- a/src/3rdparty/poly2tri/sweep/sweep_context.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
- * http://code.google.com/p/poly2tri/
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Poly2Tri nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SWEEP_CONTEXT_H
-#define SWEEP_CONTEXT_H
-
-#include <list>
-#include <vector>
-#include <cstddef>
-
-namespace p2t {
-
-// Initial triangle factor, seed triangle will extend 30% of
-// PointSet width to both left and right.
-const double kAlpha = 0.3;
-
-struct Point;
-class Triangle;
-struct Node;
-struct Edge;
-class AdvancingFront;
-
-class SweepContext {
-public:
-
-/// Constructor
-SweepContext(std::vector<Point*> polyline);
-/// Destructor
-~SweepContext();
-
-void set_head(Point* p1);
-
-Point* head();
-
-void set_tail(Point* p1);
-
-Point* tail();
-
-int point_count();
-
-Node& LocateNode(Point& point);
-
-void RemoveNode(Node* node);
-
-void CreateAdvancingFront(std::vector<Node*> nodes);
-
-/// Try to map a node to all sides of this triangle that don't have a neighbor
-void MapTriangleToNodes(Triangle& t);
-
-void AddToMap(Triangle* triangle);
-
-Point* GetPoint(const int& index);
-
-Point* GetPoints();
-
-void RemoveFromMap(Triangle* triangle);
-
-void AddHole(std::vector<Point*> polyline);
-
-void AddPoint(Point* point);
-
-AdvancingFront* front();
-
-void MeshClean(Triangle& triangle);
-
-std::vector<Triangle*> GetTriangles();
-std::list<Triangle*> GetMap();
-
-std::vector<Edge*> edge_list;
-
-struct Basin {
- Node* left_node;
- Node* bottom_node;
- Node* right_node;
- double width;
- bool left_highest;
-
- Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false)
- {
- }
-
- void Clear()
- {
- left_node = NULL;
- bottom_node = NULL;
- right_node = NULL;
- width = 0.0;
- left_highest = false;
- }
-};
-
-struct EdgeEvent {
- Edge* constrained_edge;
- bool right;
-
- EdgeEvent() : constrained_edge(NULL), right(false)
- {
- }
-};
-
-Basin basin;
-EdgeEvent edge_event;
-
-private:
-
-friend class Sweep;
-
-std::vector<Triangle*> triangles_;
-std::list<Triangle*> map_;
-std::vector<Point*> points_;
-
-// Advancing front
-AdvancingFront* front_;
-// head point used with advancing front
-Point* head_;
-// tail point used with advancing front
-Point* tail_;
-
-Node *af_head_, *af_middle_, *af_tail_;
-
-void InitTriangulation();
-void InitEdges(std::vector<Point*> polyline);
-
-};
-
-inline AdvancingFront* SweepContext::front()
-{
- return front_;
-}
-
-inline int SweepContext::point_count()
-{
- return int(points_.size());
-}
-
-inline void SweepContext::set_head(Point* p1)
-{
- head_ = p1;
-}
-
-inline Point* SweepContext::head()
-{
- return head_;
-}
-
-inline void SweepContext::set_tail(Point* p1)
-{
- tail_ = p1;
-}
-
-inline Point* SweepContext::tail()
-{
- return tail_;
-}
-
-}
-
-#endif
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5e115c2c..d8516848 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,10 +1,4 @@
# special case begin
-add_subdirectory(3rdparty/clip2tri)
-add_subdirectory(3rdparty/poly2tri)
-add_subdirectory(3rdparty/clipper)
-add_subdirectory(positioning)
-add_subdirectory(plugins)
-if(TARGET Qt::Quick)
- add_subdirectory(positioningquick)
-endif()
+#add_subdirectory(location)
+#add_subdirectory(plugins)
# special case end
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index bf9732ab..36532ae7 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -1,9 +1,5 @@
# Generated from plugins.pro.
-if(TARGET Qt::Positioning)
- add_subdirectory(position)
+if(TARGET Qt::Location)
+ add_subdirectory(geoservices)
endif()
-# TODO: enable location plugins later!
-# if(TARGET Qt::Location)
-# add_subdirectory(geoservices)
-# endif()
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 35b462d4..c27440f0 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -1,3 +1,2 @@
TEMPLATE = subdirs
-qtHaveModule(positioning): SUBDIRS += position
qtHaveModule(location): SUBDIRS += geoservices
diff --git a/src/plugins/position/CMakeLists.txt b/src/plugins/position/CMakeLists.txt
deleted file mode 100644
index ceb4fe27..00000000
--- a/src/plugins/position/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Generated from position.pro.
-
-add_subdirectory(positionpoll)
-if(FREEBSD OR LINUX OR OPENBSD OR (NETBSD AND TARGET Qt::DBus))
- add_subdirectory(geoclue2)
-endif()
-if(QT_FEATURE_gypsy)
- add_subdirectory(gypsy)
-endif()
-if(QT_FEATURE_winrt_geolocation)
- add_subdirectory(winrt)
-endif()
-if(IOS OR MACOS OR TVOS)
- add_subdirectory(corelocation)
-endif()
-if(ANDROID)
- add_subdirectory(android)
-endif()
-if(TARGET Qt::SerialPort AND TARGET Qt::Network)
- add_subdirectory(nmea)
-endif()
diff --git a/src/plugins/position/android/CMakeLists.txt b/src/plugins/position/android/CMakeLists.txt
deleted file mode 100644
index 22fe2b6b..00000000
--- a/src/plugins/position/android/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from android.pro.
-
-add_subdirectory(jar)
-add_subdirectory(src)
diff --git a/src/plugins/position/android/android.pro b/src/plugins/position/android/android.pro
deleted file mode 100644
index 0dc6a3fc..00000000
--- a/src/plugins/position/android/android.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += jar src
diff --git a/src/plugins/position/android/jar/AndroidManifest.xml b/src/plugins/position/android/jar/AndroidManifest.xml
deleted file mode 100644
index 2e847fd1..00000000
--- a/src/plugins/position/android/jar/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.qt.android.positioning"
- android:versionCode="1"
- android:versionName="1.0" >
- <supports-screens android:smallScreens="true" android:largeScreens="true" android:anyDensity="true" android:normalScreens="true"/>
-</manifest>
diff --git a/src/plugins/position/android/jar/CMakeLists.txt b/src/plugins/position/android/jar/CMakeLists.txt
deleted file mode 100644
index 8eadc79c..00000000
--- a/src/plugins/position/android/jar/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Generated from jar.pro.
-
-set(java_sources
- src/org/qtproject/qt/android/positioning/QtPositioning.java # special case
-)
-
-qt_internal_add_jar(Qt${QtLocation_VERSION_MAJOR}AndroidPositioning # special case
- INCLUDE_JARS ${QT_ANDROID_JAR}
- SOURCES ${java_sources}
- OUTPUT_DIR "${QT_BUILD_DIR}/jar"
-)
-
-install_jar(Qt${QtLocation_VERSION_MAJOR}AndroidPositioning # special case
- DESTINATION jar
- COMPONENT Devel
-)
-
diff --git a/src/plugins/position/android/jar/jar.pro b/src/plugins/position/android/jar/jar.pro
deleted file mode 100644
index fae1f855..00000000
--- a/src/plugins/position/android/jar/jar.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = Qt$${QT_MAJOR_VERSION}AndroidPositioning
-
-load(qt_build_paths)
-
-CONFIG += java
-DESTDIR = $$MODULE_BASE_OUTDIR/jar
-
-JAVACLASSPATH += $$PWD/src
-
-JAVASOURCES += \
- $$PWD/src/org/qtproject/qt/android/positioning/QtPositioning.java
-
-# install
-target.path = $$[QT_INSTALL_PREFIX]/jar
-INSTALLS += target
-
diff --git a/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java b/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java
deleted file mode 100644
index 18ef40a2..00000000
--- a/src/plugins/position/android/jar/src/org/qtproject/qt/android/positioning/QtPositioning.java
+++ /dev/null
@@ -1,658 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-package org.qtproject.qt.android.positioning;
-
-import android.content.Context;
-import android.location.GpsSatellite;
-import android.location.GpsStatus;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.location.GnssStatus;
-import android.location.GnssStatus.Callback;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Build;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import android.util.Log;
-
-public class QtPositioning implements LocationListener
-{
-
- private static final String TAG = "qt.positioning.android";
- static LocationManager locationManager = null;
- static Object m_syncObject = new Object();
- static HashMap<Integer, QtPositioning> runningListeners = new HashMap<Integer, QtPositioning>();
-
- /*
- The positionInfo instance to which this
- QtPositioning instance is attached to.
- */
- private int nativeClassReference = 0;
-
- /*
- The provider type requested by Qt
- */
- private int expectedProviders = 0;
-
- public static final int QT_GPS_PROVIDER = 1;
- public static final int QT_NETWORK_PROVIDER = 2;
-
- /* The following values must match the corresponding error enums in the Qt API*/
- public static final int QT_ACCESS_ERROR = 0;
- public static final int QT_CLOSED_ERROR = 1;
- public static final int QT_POSITION_UNKNOWN_SOURCE_ERROR = 2;
- public static final int QT_POSITION_NO_ERROR = 3;
- public static final int QT_SATELLITE_NO_ERROR = 2;
- public static final int QT_SATELLITE_UNKNOWN_SOURCE_ERROR = -1;
-
- /* True, if updates were caused by requestUpdate() */
- private boolean isSingleUpdate = false;
- /* The length requested for regular intervals in msec. */
- private int updateIntervalTime = 0;
-
- /* The last received GPS update */
- private Location lastGps = null;
- /* The last received network update */
- private Location lastNetwork = null;
- /* If true this class acts as satellite signal monitor rather than location monitor */
- private boolean isSatelliteUpdate = false;
-
- private PositioningLooperBase looperThread;
-
- private boolean isLocationProvidersDisabledInvoked = false;
-
- static public void setContext(Context context)
- {
- try {
- locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- static private int[] providerList()
- {
- if (locationManager == null) {
- Log.w(TAG, "No locationManager available in QtPositioning");
- return new int[0];
- }
- List<String> providers = locationManager.getProviders(true);
- int retList[] = new int[providers.size()];
- for (int i = 0; i < providers.size(); i++) {
- if (providers.get(i).equals(LocationManager.GPS_PROVIDER)) {
- //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_GPS
- retList[i] = 0;
- } else if (providers.get(i).equals(LocationManager.NETWORK_PROVIDER)) {
- //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_NETWORK
- retList[i] = 1;
- } else if (providers.get(i).equals(LocationManager.PASSIVE_PROVIDER)) {
- //must be in sync with AndroidPositioning::PositionProvider::PROVIDER_PASSIVE
- retList[i] = 2;
- } else {
- retList[i] = -1;
- }
- }
- return retList;
- }
-
- static public Location lastKnownPosition(boolean fromSatelliteOnly)
- {
- Location gps = null;
- Location network = null;
- try {
- gps = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
- if (!fromSatelliteOnly)
- network = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
- } catch(Exception e) {
- e.printStackTrace();
- gps = network = null;
- }
-
- if (gps != null && network != null) {
- //we return the most recent location but slightly prefer GPS
- //prefer GPS if it is max 4 hrs older than network
- long delta = network.getTime() - gps.getTime();
- if (delta < 4*60*60*1000) {
- return gps;
- } else {
- return network;
- }
- } else if (gps != null ) {
- return gps;
- } else if (network != null) {
- return network;
- }
-
- return null;
- }
-
- /* Returns true if at least on of the given providers is enabled. */
- static private boolean expectedProvidersAvailable(int desiredProviders)
- {
- List<String> enabledProviders = locationManager.getProviders(true);
- if ((desiredProviders & QT_GPS_PROVIDER) > 0) { //gps desired
- if (enabledProviders.contains(LocationManager.GPS_PROVIDER)) {
- return true;
- }
- }
- if ((desiredProviders & QT_NETWORK_PROVIDER) > 0) { //network desired
- if (enabledProviders.contains(LocationManager.NETWORK_PROVIDER)) {
- return true;
- }
- }
-
- return false;
- }
-
-
- static private void addActiveListener(QtPositioning listener, String provider)
- {
- int androidClassKey = listener.nativeClassReference;
- //start update thread
- listener.setActiveLooper(true);
-
- if (runningListeners.containsKey(androidClassKey) && runningListeners.get(androidClassKey) != listener) {
- removeActiveListener(androidClassKey);
- }
-
- locationManager.requestSingleUpdate(provider,
- listener,
- listener.looper());
-
- runningListeners.put(androidClassKey, listener);
- }
-
-
- static private void addActiveListener(QtPositioning listener, String provider, long minTime, float minDistance)
- {
- int androidClassKey = listener.nativeClassReference;
- //start update thread
- listener.setActiveLooper(true);
-
- if (runningListeners.containsKey(androidClassKey) && runningListeners.get(androidClassKey) != listener) {
- removeActiveListener(androidClassKey);
- }
-
- locationManager.requestLocationUpdates(provider,
- minTime, minDistance,
- listener,
- listener.looper());
-
- runningListeners.put(androidClassKey, listener);
- }
-
-
- static private void removeActiveListener(QtPositioning listener)
- {
- removeActiveListener(listener.nativeClassReference);
- }
-
-
- static private void removeActiveListener(int androidClassKey)
- {
- QtPositioning listener = runningListeners.remove(androidClassKey);
-
- if (listener != null) {
- locationManager.removeUpdates(listener);
- listener.setActiveLooper(false);
- }
- }
-
-
- static public int startUpdates(int androidClassKey, int locationProvider, int updateInterval)
- {
- synchronized (m_syncObject) {
- try {
- boolean exceptionOccurred = false;
- QtPositioning positioningListener = new QtPositioning();
- positioningListener.nativeClassReference = androidClassKey;
- positioningListener.expectedProviders = locationProvider;
- positioningListener.isSatelliteUpdate = false;
-
- if (updateInterval == 0)
- updateInterval = 50; //don't update more often than once per 50ms
-
- positioningListener.updateIntervalTime = updateInterval;
- if ((locationProvider & QT_GPS_PROVIDER) > 0) {
- Log.d(TAG, "Regular updates using GPS " + updateInterval);
- try {
- addActiveListener(positioningListener,
- LocationManager.GPS_PROVIDER,
- updateInterval, 0);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
-
- if ((locationProvider & QT_NETWORK_PROVIDER) > 0) {
- Log.d(TAG, "Regular updates using network " + updateInterval);
- try {
- addActiveListener(positioningListener,
- LocationManager.NETWORK_PROVIDER,
- updateInterval, 0);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
- if (exceptionOccurred) {
- removeActiveListener(positioningListener);
- return QT_ACCESS_ERROR;
- }
-
- if (!expectedProvidersAvailable(locationProvider)) {
- //all location providers unavailbe -> when they come back we resume automatically
- return QT_CLOSED_ERROR;
- }
-
- } catch(Exception e) {
- e.printStackTrace();
- return QT_POSITION_UNKNOWN_SOURCE_ERROR;
- }
-
- return QT_POSITION_NO_ERROR;
- }
- }
-
- static public void stopUpdates(int androidClassKey)
- {
- synchronized (m_syncObject) {
- try {
- Log.d(TAG, "Stopping updates");
- removeActiveListener(androidClassKey);
- } catch(Exception e) {
- e.printStackTrace();
- return;
- }
- }
- }
-
- static public int requestUpdate(int androidClassKey, int locationProvider)
- {
- synchronized (m_syncObject) {
- try {
- boolean exceptionOccurred = false;
- QtPositioning positioningListener = new QtPositioning();
- positioningListener.nativeClassReference = androidClassKey;
- positioningListener.isSingleUpdate = true;
- positioningListener.expectedProviders = locationProvider;
- positioningListener.isSatelliteUpdate = false;
-
- if ((locationProvider & QT_GPS_PROVIDER) > 0) {
- Log.d(TAG, "Single update using GPS");
- try {
- addActiveListener(positioningListener, LocationManager.GPS_PROVIDER);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
-
- if ((locationProvider & QT_NETWORK_PROVIDER) > 0) {
- Log.d(TAG, "Single update using network");
- try {
- addActiveListener(positioningListener, LocationManager.NETWORK_PROVIDER);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
- }
- if (exceptionOccurred) {
- removeActiveListener(positioningListener);
- return QT_ACCESS_ERROR;
- }
-
- if (!expectedProvidersAvailable(locationProvider)) {
- //all location providers unavailable -> when they come back we resume automatically
- //in the mean time return ClosedError
- return QT_CLOSED_ERROR;
- }
-
- } catch(Exception e) {
- e.printStackTrace();
- return QT_POSITION_UNKNOWN_SOURCE_ERROR;
- }
-
- return QT_POSITION_NO_ERROR;
- }
- }
-
- static public int startSatelliteUpdates(int androidClassKey, int updateInterval, boolean isSingleRequest)
- {
- synchronized (m_syncObject) {
- try {
- boolean exceptionOccurred = false;
- QtPositioning positioningListener = new QtPositioning();
- positioningListener.isSatelliteUpdate = true;
- positioningListener.nativeClassReference = androidClassKey;
- positioningListener.expectedProviders = 1; //always satellite provider
- positioningListener.isSingleUpdate = isSingleRequest;
-
- if (updateInterval == 0)
- updateInterval = 50; //don't update more often than once per 50ms
-
- if (isSingleRequest)
- Log.d(TAG, "Single update for Satellites " + updateInterval);
- else
- Log.d(TAG, "Regular updates for Satellites " + updateInterval);
- try {
- addActiveListener(positioningListener, LocationManager.GPS_PROVIDER,
- updateInterval, 0);
- } catch (SecurityException se) {
- se.printStackTrace();
- exceptionOccurred = true;
- }
-
- if (exceptionOccurred) {
- removeActiveListener(positioningListener);
- return QT_ACCESS_ERROR;
- }
-
- if (!expectedProvidersAvailable(positioningListener.expectedProviders)) {
- //all location providers unavailable -> when they come back we resume automatically
- //in the mean time return ClosedError
- return QT_CLOSED_ERROR;
- }
-
- } catch(Exception e) {
- e.printStackTrace();
- return QT_SATELLITE_UNKNOWN_SOURCE_ERROR;
- }
-
- return QT_SATELLITE_NO_ERROR;
- }
- }
-
- public QtPositioning()
- {
- // Use GpsStatus for API Level <= 23 (version M and below) and
- // GnssStatus for other API levels.
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M)
- looperThread = new PositioningLooperGps();
- else
- looperThread = new PositioningLooperGnss();
- }
-
- public Looper looper()
- {
- return looperThread.looper();
- }
-
- private void setActiveLooper(boolean setActive)
- {
- try{
- if (setActive) {
- if (looperThread.isAlive())
- return;
-
- if (isSatelliteUpdate)
- looperThread.isSatelliteListener(true);
-
- long start = System.currentTimeMillis();
- looperThread.start();
-
- //busy wait but lasts ~20-30 ms only
- while (!looperThread.isReady());
-
- long stop = System.currentTimeMillis();
- Log.d(TAG, "Looper Thread startup time in ms: " + (stop-start));
- } else {
- looperThread.quitLooper();
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- private abstract class PositioningLooperBase extends Thread
- {
- private boolean looperRunning;
- private Looper posLooper;
- private boolean isSatelliteLooper = false;
-
- abstract protected void addSatelliteInfoListener();
- abstract protected void removeSatelliteInfoListener();
-
- private PositioningLooperBase()
- {
- looperRunning = false;
- }
-
- public void run()
- {
- Looper.prepare();
- Handler handler = new Handler();
-
- if (isSatelliteLooper)
- addSatelliteInfoListener();
-
- posLooper = Looper.myLooper();
- synchronized (this) {
- looperRunning = true;
- }
- Looper.loop();
- synchronized (this) {
- looperRunning = false;
- }
- }
-
- public void quitLooper()
- {
- if (isSatelliteLooper)
- removeSatelliteInfoListener();
- looper().quit();
- }
-
- public synchronized boolean isReady()
- {
- return looperRunning;
- }
-
- public void isSatelliteListener(boolean isListener)
- {
- isSatelliteLooper = isListener;
- }
-
- public Looper looper()
- {
- return posLooper;
- }
-
- }
-
- private class PositioningLooperGps extends PositioningLooperBase implements GpsStatus.Listener
- {
- @Override
- protected void addSatelliteInfoListener()
- {
- try {
- locationManager.addGpsStatusListener(this);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- protected void removeSatelliteInfoListener()
- {
- locationManager.removeGpsStatusListener(this);
- }
-
- @Override
- public void onGpsStatusChanged(int event) {
- switch (event) {
- case GpsStatus.GPS_EVENT_FIRST_FIX:
- break;
- case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
- GpsStatus status = locationManager.getGpsStatus(null);
- Iterable<GpsSatellite> iterable = status.getSatellites();
- Iterator<GpsSatellite> it = iterable.iterator();
-
- ArrayList<GpsSatellite> list = new ArrayList<GpsSatellite>();
- while (it.hasNext()) {
- GpsSatellite sat = (GpsSatellite) it.next();
- list.add(sat);
- }
- GpsSatellite[] sats = list.toArray(new GpsSatellite[list.size()]);
- satelliteGpsUpdated(sats, nativeClassReference, isSingleUpdate);
-
- break;
- case GpsStatus.GPS_EVENT_STARTED:
- break;
- case GpsStatus.GPS_EVENT_STOPPED:
- break;
- }
- }
- }
-
- private class PositioningGnssListener extends GnssStatus.Callback
- {
- @Override
- public void onSatelliteStatusChanged(GnssStatus status)
- {
- satelliteGnssUpdated(status, nativeClassReference, isSingleUpdate);
- }
- }
-
- private class PositioningLooperGnss extends PositioningLooperBase
- {
- private PositioningGnssListener gnssListener;
-
- private PositioningLooperGnss()
- {
- gnssListener = new PositioningGnssListener();
- }
-
- @Override
- protected void addSatelliteInfoListener()
- {
- try {
- locationManager.registerGnssStatusCallback(gnssListener);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- protected void removeSatelliteInfoListener()
- {
- locationManager.unregisterGnssStatusCallback(gnssListener);
- }
- }
-
- public static native void positionUpdated(Location update, int androidClassKey, boolean isSingleUpdate);
- public static native void locationProvidersDisabled(int androidClassKey);
- public static native void locationProvidersChanged(int androidClassKey);
- public static native void satelliteGpsUpdated(GpsSatellite[] update, int androidClassKey, boolean isSingleUpdate);
- public static native void satelliteGnssUpdated(GnssStatus update, int androidClassKey, boolean isSingleUpdate);
-
- @Override
- public void onLocationChanged(Location location) {
- //Log.d(TAG, "**** Position Update ****: " + location.toString() + " " + isSingleUpdate);
- if (location == null)
- return;
-
- if (isSatelliteUpdate) //we are a QGeoSatelliteInfoSource -> ignore
- return;
-
- if (isSingleUpdate || expectedProviders < 3) {
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- return;
- }
-
- /*
- We can use GPS and Network, pick the better location provider.
- Generally we prefer GPS data due to their higher accurancy but we
- let Network data pass until GPS fix is available
- */
-
- if (location.getProvider().equals(LocationManager.GPS_PROVIDER)) {
- lastGps = location;
-
- // assumption: GPS always better -> pass it on
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- } else if (location.getProvider().equals(LocationManager.NETWORK_PROVIDER)) {
- lastNetwork = location;
-
- if (lastGps == null) { //no GPS fix yet use network location
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- return;
- }
-
- long delta = location.getTime() - lastGps.getTime();
-
- // Ignore if network update is older than last GPS (delta < 0)
- // Ignore if gps update still has time to provide next location (delta < updateInterval)
- if (delta < updateIntervalTime)
- return;
-
- // Use network data -> GPS has timed out on updateInterval
- positionUpdated(location, nativeClassReference, isSingleUpdate);
- }
- }
-
- @Override
- public void onStatusChanged(String provider, int status, Bundle extras) {}
-
- @Override
- public void onProviderEnabled(String provider) {
- Log.d(TAG, "Enabled provider: " + provider);
- locationProvidersChanged(nativeClassReference);
- if (isLocationProvidersDisabledInvoked && expectedProvidersAvailable(expectedProviders))
- isLocationProvidersDisabledInvoked = false;
- }
-
- @Override
- public void onProviderDisabled(String provider) {
- Log.d(TAG, "Disabled provider: " + provider);
- locationProvidersChanged(nativeClassReference);
- if (!isLocationProvidersDisabledInvoked && !expectedProvidersAvailable(expectedProviders)) {
- isLocationProvidersDisabledInvoked = true;
- locationProvidersDisabled(nativeClassReference);
- }
- }
-}
diff --git a/src/plugins/position/android/src/CMakeLists.txt b/src/plugins/position/android/src/CMakeLists.txt
deleted file mode 100644
index b91181f4..00000000
--- a/src/plugins/position/android/src/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# Generated from src.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryAndroid Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryAndroidPlugin
- OUTPUT_NAME qtposition_android
- CLASS_NAME QGeoPositionInfoSourceFactoryAndroid
- PLUGIN_TYPE position
- SOURCES
- jnipositioning.cpp jnipositioning.h
- positionfactory_android.cpp positionfactory_android.h
- qgeopositioninfosource_android.cpp qgeopositioninfosource_android_p.h
- qgeosatelliteinfosource_android.cpp qgeosatelliteinfosource_android_p.h
- LIBRARIES
- Qt::Core
- Qt::CorePrivate
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:src.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp
deleted file mode 100644
index 5f87d08b..00000000
--- a/src/plugins/position/android/src/jnipositioning.cpp
+++ /dev/null
@@ -1,741 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDateTime>
-#include <QMap>
-#include <QRandomGenerator>
-#include <QGeoPositionInfo>
-#include <QJniEnvironment>
-#include <QJniObject>
-#include <QtCore/private/qandroidextras_p.h>
-#include <QCoreApplication>
-#include <android/log.h>
-#include "qgeopositioninfosource_android_p.h"
-#include "qgeosatelliteinfosource_android_p.h"
-#include "jnipositioning.h"
-
-class GlobalClassRefWrapper
-{
-public:
- GlobalClassRefWrapper() = default;
- ~GlobalClassRefWrapper()
- {
- if (m_classRef) {
- QJniEnvironment env;
- if (env.jniEnv())
- env->DeleteGlobalRef(m_classRef);
- }
- }
-
- bool init(const char *className)
- {
- QJniEnvironment env;
- if (env.jniEnv()) {
- if (m_classRef) {
- env->DeleteGlobalRef(m_classRef);
- m_classRef = nullptr;
- }
-
- m_classRef = env.findClass(className); // it returns global ref!
- }
- return m_classRef != nullptr;
- }
-
- jclass operator()() { return m_classRef; }
-
-private:
- jclass m_classRef = nullptr;
-};
-
-static GlobalClassRefWrapper positioningClass;
-
-static jmethodID providerListMethodId;
-static jmethodID lastKnownPositionMethodId;
-static jmethodID startUpdatesMethodId;
-static jmethodID stopUpdatesMethodId;
-static jmethodID requestUpdateMethodId;
-static jmethodID startSatelliteUpdatesMethodId;
-
-static const char logTag[] = "qt.positioning.android";
-static const char methodErrorMsg[] = "Can't find method \"%s%s\"";
-
-Q_LOGGING_CATEGORY(lcPositioning, logTag)
-
-namespace {
-
-/*!
- \internal
- This class encapsulates satellite system types, as defined by Android
- GnssStatus API. Initialize during JNI_OnLoad() by the init() method, from
- the Java side, rather than hard-coding.
-*/
-class ConstellationMapper
-{
-public:
- static bool init()
- {
- m_gnssStatusObject = nullptr;
- if (QNativeInterface::QAndroidApplication::sdkVersion() > 23) {
- m_gnssStatusObject = QJniEnvironment().findClass("android/location/GnssStatus");
- if (!m_gnssStatusObject)
- return false;
- }
- // no need to query it for API level <= 23
- return true;
- }
-
- static QGeoSatelliteInfo::SatelliteSystem toSatelliteSystem(int constellationType)
- {
- if (!m_gnssStatusObject)
- return QGeoSatelliteInfo::Undefined;
-
- static const int gps =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_GPS");
- static const int glonass =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_GLONASS");
- static const int galileo =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_GALILEO");
- static const int beidou =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_BEIDOU");
- static const int qzss =
- QJniObject::getStaticField<jint>(m_gnssStatusObject, "CONSTELLATION_QZSS");
-
- if (constellationType == gps) {
- return QGeoSatelliteInfo::GPS;
- } else if (constellationType == glonass) {
- return QGeoSatelliteInfo::GLONASS;
- } else if (constellationType == galileo) {
- return QGeoSatelliteInfo::GALILEO;
- } else if (constellationType == beidou) {
- return QGeoSatelliteInfo::BEIDOU;
- } else if (constellationType == qzss){
- return QGeoSatelliteInfo::QZSS;
- } else {
- qCWarning(lcPositioning) << "Unknown satellite system" << constellationType;
- return QGeoSatelliteInfo::Undefined;
- }
- }
-
-private:
- static jclass m_gnssStatusObject;
-};
-
-jclass ConstellationMapper::m_gnssStatusObject = nullptr;
-
-} // anonymous namespace
-
-namespace AndroidPositioning {
- typedef QMap<int, QGeoPositionInfoSourceAndroid * > PositionSourceMap;
- typedef QMap<int, QGeoSatelliteInfoSourceAndroid * > SatelliteSourceMap;
-
- Q_GLOBAL_STATIC(PositionSourceMap, idToPosSource)
-
- Q_GLOBAL_STATIC(SatelliteSourceMap, idToSatSource)
-
- int registerPositionInfoSource(QObject *obj)
- {
- int key = -1;
- if (obj->inherits("QGeoPositionInfoSource")) {
- QGeoPositionInfoSourceAndroid *src = qobject_cast<QGeoPositionInfoSourceAndroid *>(obj);
- Q_ASSERT(src);
- do {
- key = qAbs(int(QRandomGenerator::global()->generate()));
- } while (idToPosSource()->contains(key));
-
- idToPosSource()->insert(key, src);
- } else if (obj->inherits("QGeoSatelliteInfoSource")) {
- QGeoSatelliteInfoSourceAndroid *src = qobject_cast<QGeoSatelliteInfoSourceAndroid *>(obj);
- Q_ASSERT(src);
- do {
- key = qAbs(int(QRandomGenerator::global()->generate()));
- } while (idToSatSource()->contains(key));
-
- idToSatSource()->insert(key, src);
- }
-
- return key;
- }
-
- void unregisterPositionInfoSource(int key)
- {
- idToPosSource()->remove(key);
- idToSatSource()->remove(key);
- }
-
- enum PositionProvider
- {
- PROVIDER_GPS = 0,
- PROVIDER_NETWORK = 1,
- PROVIDER_PASSIVE = 2
- };
-
-
- QGeoPositionInfoSource::PositioningMethods availableProviders()
- {
- QGeoPositionInfoSource::PositioningMethods ret = QGeoPositionInfoSource::NoPositioningMethods;
- QJniEnvironment env;
- if (!env.jniEnv())
- return ret;
- QJniObject jniProvidersObj =
- QJniObject::callStaticObjectMethod(positioningClass(), providerListMethodId);
- jintArray jProviders = jniProvidersObj.object<jintArray>();
- jint *providers = env->GetIntArrayElements(jProviders, nullptr);
- const int size = env->GetArrayLength(jProviders);
- for (int i = 0; i < size; i++) {
- switch (providers[i]) {
- case PROVIDER_GPS:
- ret |= QGeoPositionInfoSource::SatellitePositioningMethods;
- break;
- case PROVIDER_NETWORK:
- ret |= QGeoPositionInfoSource::NonSatellitePositioningMethods;
- break;
- case PROVIDER_PASSIVE:
- //we ignore as Qt doesn't have interface for it right now
- break;
- default:
- __android_log_print(ANDROID_LOG_INFO, logTag, "Unknown positioningMethod");
- }
- }
-
- env->ReleaseIntArrayElements(jProviders, providers, 0);
-
- return ret;
- }
-
- QGeoPositionInfo positionInfoFromJavaLocation(const jobject &location)
- {
- QGeoPositionInfo info;
-
- QJniObject jniObject(location);
- if (!jniObject.isValid())
- return QGeoPositionInfo();
-
- const jdouble latitude = jniObject.callMethod<jdouble>("getLatitude");
- const jdouble longitude = jniObject.callMethod<jdouble>("getLongitude");
-
- QGeoCoordinate coordinate(latitude, longitude);
-
- // altitude
- jboolean attributeExists = jniObject.callMethod<jboolean>("hasAltitude");
- if (attributeExists) {
- const jdouble value = jniObject.callMethod<jdouble>("getAltitude");
- if (!qFuzzyIsNull(value))
- coordinate.setAltitude(value);
- }
-
- info.setCoordinate(coordinate);
-
- // time stamp
- const jlong timestamp = jniObject.callMethod<jlong>("getTime");
- info.setTimestamp(QDateTime::fromMSecsSinceEpoch(timestamp, Qt::UTC));
-
- // horizontal accuracy
- attributeExists = jniObject.callMethod<jboolean>("hasAccuracy");
- if (attributeExists) {
- const jfloat accuracy = jniObject.callMethod<jfloat>("getAccuracy");
- if (!qFuzzyIsNull(accuracy))
- info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, qreal(accuracy));
- }
-
- // vertical accuracy
- // The check for method existence happens inside QJniObject. If the
- // method is not found, 0 (or 0.0, or false) is returned, so we do not
- // need to handle it specially.
- attributeExists = jniObject.callMethod<jboolean>("hasVerticalAccuracy");
- if (attributeExists) {
- const jfloat accuracy = jniObject.callMethod<jfloat>("getVerticalAccuracyMeters");
- if (!qFuzzyIsNull(accuracy))
- info.setAttribute(QGeoPositionInfo::VerticalAccuracy, qreal(accuracy));
- }
-
- // ground speed
- attributeExists = jniObject.callMethod<jboolean>("hasSpeed");
- if (attributeExists) {
- const jfloat speed = jniObject.callMethod<jfloat>("getSpeed");
- if (!qFuzzyIsNull(speed))
- info.setAttribute(QGeoPositionInfo::GroundSpeed, qreal(speed));
- }
-
- // bearing
- attributeExists = jniObject.callMethod<jboolean>("hasBearing");
- if (attributeExists) {
- const jfloat bearing = jniObject.callMethod<jfloat>("getBearing");
- if (!qFuzzyIsNull(bearing))
- info.setAttribute(QGeoPositionInfo::Direction, qreal(bearing));
- }
-
- return info;
- }
-
- QList<QGeoSatelliteInfo> satelliteInfoFromJavaLocation(JNIEnv *jniEnv,
- jobjectArray satellites,
- QList<QGeoSatelliteInfo>* usedInFix)
- {
- QList<QGeoSatelliteInfo> sats;
- jsize length = jniEnv->GetArrayLength(satellites);
- for (int i = 0; i<length; i++) {
- jobject element = jniEnv->GetObjectArrayElement(satellites, i);
- if (QJniEnvironment::checkAndClearExceptions(jniEnv)) {
- qCWarning(lcPositioning) << "Cannot process all satellite data due to exception.";
- break;
- }
-
- QJniObject jniObj = QJniObject::fromLocalRef(element);
- if (!jniObj.isValid())
- continue;
-
- QGeoSatelliteInfo info;
-
- // signal strength
- const jfloat snr = jniObj.callMethod<jfloat>("getSnr");
- info.setSignalStrength(int(snr));
-
- // ignore any satellite with no signal whatsoever
- if (qFuzzyIsNull(snr))
- continue;
-
- // prn
- const jint prn = jniObj.callMethod<jint>("getPrn");
- info.setSatelliteIdentifier(prn);
-
- if (prn >= 1 && prn <= 32)
- info.setSatelliteSystem(QGeoSatelliteInfo::GPS);
- else if (prn >= 65 && prn <= 96)
- info.setSatelliteSystem(QGeoSatelliteInfo::GLONASS);
- else if (prn >= 193 && prn <= 200)
- info.setSatelliteSystem(QGeoSatelliteInfo::QZSS);
- else if ((prn >= 201 && prn <= 235) || (prn >= 401 && prn <= 437))
- info.setSatelliteSystem(QGeoSatelliteInfo::BEIDOU);
- else if (prn >= 301 && prn <= 336)
- info.setSatelliteSystem(QGeoSatelliteInfo::GALILEO);
-
- // azimuth
- const jfloat azimuth = jniObj.callMethod<jfloat>("getAzimuth");
- info.setAttribute(QGeoSatelliteInfo::Azimuth, qreal(azimuth));
-
- // elevation
- const jfloat elevation = jniObj.callMethod<jfloat>("getElevation");
- info.setAttribute(QGeoSatelliteInfo::Elevation, qreal(elevation));
-
- // Used in fix - true if this satellite is actually used in
- // determining the position.
- const jboolean inFix = jniObj.callMethod<jboolean>("usedInFix");
-
- sats.append(info);
-
- if (inFix)
- usedInFix->append(info);
- }
-
- return sats;
- }
-
- QList<QGeoSatelliteInfo> satelliteInfoFromJavaGnssStatus(jobject gnssStatus,
- QList<QGeoSatelliteInfo>* usedInFix)
- {
- QJniObject jniStatus(gnssStatus);
- QList<QGeoSatelliteInfo> sats;
-
- const int satellitesCount = jniStatus.callMethod<jint>("getSatelliteCount");
- for (int i = 0; i < satellitesCount; ++i) {
- QGeoSatelliteInfo info;
-
- // signal strength - this is actually a carrier-to-noise density,
- // but the values are very close to what was previously returned by
- // getSnr() method of the GpsSatellite API.
- const jfloat cn0 = jniStatus.callMethod<jfloat>("getCn0DbHz", "(I)F", i);
- info.setSignalStrength(static_cast<int>(cn0));
-
- // satellite system
- const jint constellationType =
- jniStatus.callMethod<jint>("getConstellationType", "(I)I", i);
- info.setSatelliteSystem(ConstellationMapper::toSatelliteSystem(constellationType));
-
- // satellite identifier
- const jint svId = jniStatus.callMethod<jint>("getSvid", "(I)I", i);
- info.setSatelliteIdentifier(svId);
-
- // azimuth
- const jfloat azimuth = jniStatus.callMethod<jfloat>("getAzimuthDegrees", "(I)F", i);
- info.setAttribute(QGeoSatelliteInfo::Azimuth, static_cast<qreal>(azimuth));
-
- // elevation
- const jfloat elevation = jniStatus.callMethod<jfloat>("getElevationDegrees", "(I)F", i);
- info.setAttribute(QGeoSatelliteInfo::Elevation, static_cast<qreal>(elevation));
-
- // Used in fix - true if this satellite is actually used in
- // determining the position.
- const jboolean inFix = jniStatus.callMethod<jboolean>("usedInFix", "(I)Z", i);
-
- sats.append(info);
-
- if (inFix)
- usedInFix->append(info);
- }
-
- return sats;
- }
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoPositionInfo();
-
- if (!requestionPositioningPermissions())
- return {};
-
- QJniObject locationObj = QJniObject::callStaticObjectMethod(
- positioningClass(), lastKnownPositionMethodId, fromSatellitePositioningMethodsOnly);
- jobject location = locationObj.object();
- if (location == nullptr)
- return QGeoPositionInfo();
-
- const QGeoPositionInfo info = positionInfoFromJavaLocation(location);
-
- return info;
- }
-
- inline int positioningMethodToInt(QGeoPositionInfoSource::PositioningMethods m)
- {
- int providerSelection = 0;
- if (m & QGeoPositionInfoSource::SatellitePositioningMethods)
- providerSelection |= 1;
- if (m & QGeoPositionInfoSource::NonSatellitePositioningMethods)
- providerSelection |= 2;
-
- return providerSelection;
- }
-
- QGeoPositionInfoSource::Error startUpdates(int androidClassKey)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoPositionInfoSource::UnknownSourceError;
-
- QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
-
- if (source) {
- if (!requestionPositioningPermissions())
- return QGeoPositionInfoSource::AccessError;
-
- int errorCode = QJniObject::callStaticMethod<jint>(
- positioningClass(), startUpdatesMethodId, androidClassKey,
- positioningMethodToInt(source->preferredPositioningMethods()),
- source->updateInterval());
- switch (errorCode) {
- case 0:
- case 1:
- case 2:
- case 3:
- return static_cast<QGeoPositionInfoSource::Error>(errorCode);
- default:
- break;
- }
- }
-
- return QGeoPositionInfoSource::UnknownSourceError;
- }
-
- //used for stopping regular and single updates
- void stopUpdates(int androidClassKey)
- {
- QJniObject::callStaticMethod<void>(positioningClass(), stopUpdatesMethodId,
- androidClassKey);
- }
-
- QGeoPositionInfoSource::Error requestUpdate(int androidClassKey)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoPositionInfoSource::UnknownSourceError;
-
- QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
-
- if (source) {
- if (!requestionPositioningPermissions())
- return QGeoPositionInfoSource::AccessError;
-
- int errorCode = QJniObject::callStaticMethod<jint>(
- positioningClass(), requestUpdateMethodId, androidClassKey,
- positioningMethodToInt(source->preferredPositioningMethods()));
- switch (errorCode) {
- case 0:
- case 1:
- case 2:
- case 3:
- return static_cast<QGeoPositionInfoSource::Error>(errorCode);
- default:
- break;
- }
- }
- return QGeoPositionInfoSource::UnknownSourceError;
- }
-
- QGeoSatelliteInfoSource::Error startSatelliteUpdates(int androidClassKey, bool isSingleRequest, int requestTimeout)
- {
- QJniEnvironment env;
- if (!env.jniEnv())
- return QGeoSatelliteInfoSource::UnknownSourceError;
-
- QGeoSatelliteInfoSourceAndroid *source = AndroidPositioning::idToSatSource()->value(androidClassKey);
-
- if (source) {
- if (!requestionPositioningPermissions())
- return QGeoSatelliteInfoSource::AccessError;
-
- int interval = source->updateInterval();
- if (isSingleRequest)
- interval = requestTimeout;
- int errorCode = QJniObject::callStaticMethod<jint>(positioningClass(),
- startSatelliteUpdatesMethodId,
- androidClassKey, interval,
- isSingleRequest);
- switch (errorCode) {
- case -1:
- case 0:
- case 1:
- case 2:
- return static_cast<QGeoSatelliteInfoSource::Error>(errorCode);
- default:
- qCWarning(lcPositioning)
- << "startSatelliteUpdates: Unknown error code" << errorCode;
- break;
- }
- }
- return QGeoSatelliteInfoSource::UnknownSourceError;
- }
-
- bool requestionPositioningPermissions()
- {
- // If the code is running as a service, we can't request permissions.
- // We can only check if we have the needed permissions. Also make sure
- // to request the background location permissions.
- if (!QNativeInterface::QAndroidApplication::isActivityContext()) {
- const auto permission = QtAndroidPrivate::PreciseBackgroundLocation;
- const auto result = QtAndroidPrivate::checkPermission(permission).result();
- if (result != QtAndroidPrivate::Authorized) {
- qCWarning(lcPositioning)
- << "Position data not available due to missing permission" << permission;
- }
- return result == QtAndroidPrivate::Authorized;
- } else {
- // Running from a normal Activity. Checking and requesting the
- // permissions if necessary.
-
- // Android v23+ requires runtime permission check and requests
- const auto permission = QtAndroidPrivate::PreciseLocation;
- auto checkFuture = QtAndroidPrivate::checkPermission(permission);
- if (checkFuture.result() == QtAndroidPrivate::Denied) {
- auto requestFuture = QtAndroidPrivate::requestPermission(permission);
- if (requestFuture.result() != QtAndroidPrivate::Authorized) {
- qCWarning(lcPositioning)
- << "Position data not available due to missing permission"
- << permission;
- return false;
- }
- }
-
- return true;
- }
- }
-}
-
-static void positionUpdated(JNIEnv *env, jobject thiz, jobject location,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
- QGeoPositionInfo info = AndroidPositioning::positionInfoFromJavaLocation(location);
-
- QGeoPositionInfoSourceAndroid *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "positionUpdated: source == 0";
- return;
- }
-
- //we need to invoke indirectly as the Looper thread is likely to be not the same thread
- if (!isSingleUpdate)
- QMetaObject::invokeMethod(source, "processPositionUpdate", Qt::AutoConnection,
- Q_ARG(QGeoPositionInfo, info));
- else
- QMetaObject::invokeMethod(source, "processSinglePositionUpdate", Qt::AutoConnection,
- Q_ARG(QGeoPositionInfo, info));
-}
-
-static void locationProvidersDisabled(JNIEnv *env, jobject thiz, jint androidClassKey)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
- QObject *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
- if (!source)
- source = AndroidPositioning::idToSatSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "locationProvidersDisabled: source == 0";
- return;
- }
-
- QMetaObject::invokeMethod(source, "locationProviderDisabled", Qt::AutoConnection);
-}
-
-static void locationProvidersChanged(JNIEnv *env, jobject thiz, jint androidClassKey)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
- QObject *source = AndroidPositioning::idToPosSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "locationProvidersChanged: source == 0";
- return;
- }
-
- QMetaObject::invokeMethod(source, "locationProvidersChanged", Qt::AutoConnection);
-}
-
-static void notifySatelliteInfoUpdated(const QList<QGeoSatelliteInfo> &inView,
- const QList<QGeoSatelliteInfo> &inUse,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- QGeoSatelliteInfoSourceAndroid *source = AndroidPositioning::idToSatSource()->value(androidClassKey);
- if (!source) {
- qCWarning(lcPositioning) << "notifySatelliteInfoUpdated: source == 0";
- return;
- }
-
- QMetaObject::invokeMethod(source, "processSatelliteUpdateInView", Qt::AutoConnection,
- Q_ARG(QList<QGeoSatelliteInfo>, inView), Q_ARG(bool, isSingleUpdate));
-
- QMetaObject::invokeMethod(source, "processSatelliteUpdateInUse", Qt::AutoConnection,
- Q_ARG(QList<QGeoSatelliteInfo>, inUse), Q_ARG(bool, isSingleUpdate));
-}
-
-static void satelliteGpsUpdated(JNIEnv *env, jobject thiz, jobjectArray satellites,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- Q_UNUSED(thiz);
- QList<QGeoSatelliteInfo> inUse;
- QList<QGeoSatelliteInfo> sats =
- AndroidPositioning::satelliteInfoFromJavaLocation(env, satellites, &inUse);
-
- notifySatelliteInfoUpdated(sats, inUse, androidClassKey, isSingleUpdate);
-}
-
-static void satelliteGnssUpdated(JNIEnv *env, jobject thiz, jobject gnssStatus,
- jint androidClassKey, jboolean isSingleUpdate)
-{
- Q_UNUSED(env);
- Q_UNUSED(thiz);
-
- QList<QGeoSatelliteInfo> inUse;
- QList<QGeoSatelliteInfo> sats =
- AndroidPositioning::satelliteInfoFromJavaGnssStatus(gnssStatus, &inUse);
-
- notifySatelliteInfoUpdated(sats, inUse, androidClassKey, isSingleUpdate);
-}
-
-#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
- VAR = env.findStaticMethod(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
- if (!VAR) { \
- __android_log_print(ANDROID_LOG_FATAL, logTag, methodErrorMsg, METHOD_NAME, \
- METHOD_SIGNATURE); \
- return false; \
- }
-
-static bool registerNatives()
-{
- const JNINativeMethod methods[] = {
- {"positionUpdated", "(Landroid/location/Location;IZ)V", (void *)positionUpdated},
- {"locationProvidersDisabled", "(I)V", (void *) locationProvidersDisabled},
- {"satelliteGpsUpdated", "([Landroid/location/GpsSatellite;IZ)V", (void *)satelliteGpsUpdated},
- {"locationProvidersChanged", "(I)V", (void *) locationProvidersChanged},
- {"satelliteGnssUpdated", "(Landroid/location/GnssStatus;IZ)V", (void *)satelliteGnssUpdated}
- };
-
- QJniEnvironment env;
- if (!env.jniEnv()) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "Failed to create environment");
- return false;
- }
-
- if (!positioningClass.init("org/qtproject/qt/android/positioning/QtPositioning")) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "Failed to create global class ref");
- return false;
- }
-
- if (!env.registerNativeMethods(positioningClass(), methods,
- sizeof(methods) / sizeof(methods[0]))) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "Failed to register native methods");
- return false;
- }
-
- GET_AND_CHECK_STATIC_METHOD(providerListMethodId, positioningClass(), "providerList", "()[I");
- GET_AND_CHECK_STATIC_METHOD(lastKnownPositionMethodId, positioningClass(), "lastKnownPosition",
- "(Z)Landroid/location/Location;");
- GET_AND_CHECK_STATIC_METHOD(startUpdatesMethodId, positioningClass(), "startUpdates", "(III)I");
- GET_AND_CHECK_STATIC_METHOD(stopUpdatesMethodId, positioningClass(), "stopUpdates", "(I)V");
- GET_AND_CHECK_STATIC_METHOD(requestUpdateMethodId, positioningClass(), "requestUpdate",
- "(II)I");
- GET_AND_CHECK_STATIC_METHOD(startSatelliteUpdatesMethodId, positioningClass(),
- "startSatelliteUpdates", "(IIZ)I");
-
- return true;
-}
-
-Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM * /*vm*/, void * /*reserved*/)
-{
- static bool initialized = false;
- if (initialized)
- return JNI_VERSION_1_6;
- initialized = true;
-
- __android_log_print(ANDROID_LOG_INFO, logTag, "Positioning start");
-
- if (!registerNatives()) {
- __android_log_print(ANDROID_LOG_FATAL, logTag, "registerNatives() failed");
- return -1;
- }
-
- if (!ConstellationMapper::init()) {
- __android_log_print(ANDROID_LOG_ERROR, logTag,
- "Failed to extract constellation type constants. "
- "Satellite system will be undefined!");
- }
-
- return JNI_VERSION_1_6;
-}
-
diff --git a/src/plugins/position/android/src/jnipositioning.h b/src/plugins/position/android/src/jnipositioning.h
deleted file mode 100644
index a9a72ecb..00000000
--- a/src/plugins/position/android/src/jnipositioning.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef JNIPOSITIONING_H
-#define JNIPOSITIONING_H
-
-#include <QGeoPositionInfoSource>
-#include <QGeoSatelliteInfoSource>
-
-namespace AndroidPositioning
-{
- int registerPositionInfoSource(QObject *obj);
- void unregisterPositionInfoSource(int key);
-
- QGeoPositionInfoSource::PositioningMethods availableProviders();
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly);
-
- QGeoPositionInfoSource::Error startUpdates(int androidClassKey);
- void stopUpdates(int androidClassKey);
- QGeoPositionInfoSource::Error requestUpdate(int androidClassKey);
-
- QGeoSatelliteInfoSource::Error startSatelliteUpdates(int androidClassKey,
- bool isSingleRequest,
- int updateRequestTimeout);
- bool requestionPositioningPermissions();
-}
-
-#endif // JNIPOSITIONING_H
diff --git a/src/plugins/position/android/src/plugin.json b/src/plugins/position/android/src/plugin.json
deleted file mode 100644
index 4fd87892..00000000
--- a/src/plugins/position/android/src/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["android"],
- "Provider": "android",
- "Position": true,
- "Satellite": true,
- "Monitor": false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/android/src/positionfactory_android.cpp b/src/plugins/position/android/src/positionfactory_android.cpp
deleted file mode 100644
index 436b1df6..00000000
--- a/src/plugins/position/android/src/positionfactory_android.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "positionfactory_android.h"
-#include "qgeopositioninfosource_android_p.h"
-#include "qgeosatelliteinfosource_android_p.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryAndroid::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoPositionInfoSourceAndroid *src = new QGeoPositionInfoSourceAndroid(parent);
- return src;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryAndroid::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoSatelliteInfoSourceAndroid *src = new QGeoSatelliteInfoSourceAndroid(parent);
- return src;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryAndroid::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
diff --git a/src/plugins/position/android/src/positionfactory_android.h b/src/plugins/position/android/src/positionfactory_android.h
deleted file mode 100644
index 0494b533..00000000
--- a/src/plugins/position/android/src/positionfactory_android.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef POSITIONPOLLFACTORY_H
-#define POSITIONPOLLFACTORY_H
-
-#include <QObject>
-#include <QGeoPositionInfoSourceFactory>
-
-class QGeoPositionInfoSourceFactoryAndroid : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif // POSITIONPOLLFACTORY_H
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
deleted file mode 100644
index b1a41e92..00000000
--- a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_android_p.h"
-#include "jnipositioning.h"
-#include <QGeoPositionInfo>
-
-static constexpr int kUpdateFromColdStart = 2 * 60 * 1000;
-static constexpr int kRegularUpdatesTimerInterval = 30 * 1000;
-
-QGeoPositionInfoSourceAndroid::QGeoPositionInfoSourceAndroid(QObject *parent) :
- QGeoPositionInfoSource(parent)
-{
- androidClassKeyForUpdate = AndroidPositioning::registerPositionInfoSource(this);
- androidClassKeyForSingleRequest = AndroidPositioning::registerPositionInfoSource(this);
-
- //by default use all methods
- setPreferredPositioningMethods(AllPositioningMethods);
-
- m_requestTimer.setSingleShot(true);
- connect(&m_requestTimer, &QTimer::timeout, this,
- &QGeoPositionInfoSourceAndroid::requestTimeout);
-
- m_regularUpdatesTimer.setSingleShot(false);
- connect(&m_regularUpdatesTimer, &QTimer::timeout, this,
- &QGeoPositionInfoSourceAndroid::regularUpdatesTimeout);
-}
-
-QGeoPositionInfoSourceAndroid::~QGeoPositionInfoSourceAndroid()
-{
- stopUpdates();
-
- if (m_requestTimer.isActive()) {
- m_requestTimer.stop();
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
- }
-
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForUpdate);
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForSingleRequest);
-}
-
-void QGeoPositionInfoSourceAndroid::setUpdateInterval(int msec)
-{
- int previousInterval = updateInterval();
- msec = (((msec > 0) && (msec < minimumUpdateInterval())) || msec < 0)? minimumUpdateInterval() : msec;
-
- if (msec == previousInterval)
- return;
-
- QGeoPositionInfoSource::setUpdateInterval(msec);
-
- if (updatesRunning)
- reconfigureRunningSystem();
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceAndroid::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- return AndroidPositioning::lastKnownPosition(fromSatellitePositioningMethodsOnly);
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceAndroid::supportedPositioningMethods() const
-{
- return AndroidPositioning::availableProviders();
-}
-
-void QGeoPositionInfoSourceAndroid::setPreferredPositioningMethods(QGeoPositionInfoSource::PositioningMethods methods)
-{
- PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods();
- QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
- if (previousPreferredPositioningMethods == preferredPositioningMethods())
- return;
-
- if (updatesRunning)
- reconfigureRunningSystem();
-}
-
-int QGeoPositionInfoSourceAndroid::minimumUpdateInterval() const
-{
- return 50;
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceAndroid::error() const
-{
- return m_error;
-}
-
-void QGeoPositionInfoSourceAndroid::setError(Error error)
-{
- m_error = error;
- if (error != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(m_error);
-}
-
-void QGeoPositionInfoSourceAndroid::startUpdates()
-{
- if (updatesRunning)
- return;
-
- m_error = QGeoPositionInfoSource::NoError;
-
- if (preferredPositioningMethods() == 0) {
- setError(UnknownSourceError);
- return;
- }
-
- updatesRunning = true;
- // Start calculating updates from now.
- m_lastUpdateTime = QDateTime::currentMSecsSinceEpoch();
- m_regularUpdatesErrorRaised = false;
- QGeoPositionInfoSource::Error error = AndroidPositioning::startUpdates(androidClassKeyForUpdate);
- if (error != QGeoPositionInfoSource::NoError) {
- updatesRunning = false;
- setError(error);
- } else {
- m_regularUpdatesTimer.start(kRegularUpdatesTimerInterval);
- }
-}
-
-void QGeoPositionInfoSourceAndroid::stopUpdates()
-{
- if (!updatesRunning)
- return;
-
- updatesRunning = false;
- m_regularUpdatesTimer.stop();
- AndroidPositioning::stopUpdates(androidClassKeyForUpdate);
-}
-
-void QGeoPositionInfoSourceAndroid::requestUpdate(int timeout)
-{
- if (m_requestTimer.isActive())
- return;
-
- m_error = QGeoPositionInfoSource::NoError;
-
- if (timeout != 0 && timeout < minimumUpdateInterval()) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- if (timeout == 0)
- timeout = kUpdateFromColdStart;
-
- m_requestTimer.start(timeout);
-
- // if updates already running with interval equal to timeout
- // then we wait for next update coming through
- // assume that a single update will not be quicker than regular updates anyway
- if (updatesRunning && updateInterval() <= timeout)
- return;
-
- QGeoPositionInfoSource::Error error = AndroidPositioning::requestUpdate(androidClassKeyForSingleRequest);
- if (error != QGeoPositionInfoSource::NoError) {
- m_requestTimer.stop();
- setError(error);
- }
-}
-
-void QGeoPositionInfoSourceAndroid::processPositionUpdate(const QGeoPositionInfo &pInfo)
-{
- //single update request and served as part of regular update
- if (m_requestTimer.isActive())
- m_requestTimer.stop();
-
- m_lastUpdateTime = QDateTime::currentMSecsSinceEpoch();
- m_regularUpdatesErrorRaised = false;
-
- emit positionUpdated(pInfo);
-}
-
-// Might still be called multiple times (once for each provider)
-void QGeoPositionInfoSourceAndroid::processSinglePositionUpdate(const QGeoPositionInfo &pInfo)
-{
- //timeout but we received a late update -> ignore
- if (!m_requestTimer.isActive())
- return;
-
- queuedSingleUpdates.append(pInfo);
-}
-
-void QGeoPositionInfoSourceAndroid::locationProviderDisabled()
-{
- if (updatesRunning && !m_regularUpdatesErrorRaised) {
- m_regularUpdatesErrorRaised = true;
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- }
-
- setError(QGeoPositionInfoSource::ClosedError);
-}
-
-void QGeoPositionInfoSourceAndroid::locationProvidersChanged()
-{
- emit supportedPositioningMethodsChanged();
-}
-
-void QGeoPositionInfoSourceAndroid::requestTimeout()
-{
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
- //no queued update to process -> timeout
- const int count = queuedSingleUpdates.count();
-
- if (!count) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- //pick best
- QGeoPositionInfo best = queuedSingleUpdates[0];
- for (int i = 1; i < count; i++) {
- const QGeoPositionInfo info = queuedSingleUpdates[i];
-
- //anything newer by 20s is always better
- const qint64 timeDelta = best.timestamp().secsTo(info.timestamp());
- if (abs(timeDelta) > 20) {
- if (timeDelta > 0)
- best = info;
- continue;
- }
-
- //compare accuracy
- if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy) &&
- best.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
- {
- best = info.attribute(QGeoPositionInfo::HorizontalAccuracy) <
- best.attribute(QGeoPositionInfo::HorizontalAccuracy) ? info : best;
- continue;
- }
-
- //prefer info with accuracy information
- if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
- best = info;
- }
-
- queuedSingleUpdates.clear();
- emit positionUpdated(best);
-}
-
-void QGeoPositionInfoSourceAndroid::regularUpdatesTimeout()
-{
- if (!m_regularUpdatesErrorRaised) {
- const auto now = QDateTime::currentMSecsSinceEpoch();
- if ((now - m_lastUpdateTime) > (updateInterval() + kUpdateFromColdStart)) {
- m_regularUpdatesErrorRaised = true;
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- }
- }
-}
-
-/*
- Updates the system assuming that updateInterval
- and/or preferredPositioningMethod have changed.
- */
-void QGeoPositionInfoSourceAndroid::reconfigureRunningSystem()
-{
- if (!updatesRunning)
- return;
-
- stopUpdates();
- startUpdates();
-}
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android_p.h b/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
deleted file mode 100644
index 44cb2799..00000000
--- a/src/plugins/position/android/src/qgeopositioninfosource_android_p.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCE_ANDROID_P_H
-#define QGEOPOSITIONINFOSOURCE_ANDROID_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QGeoPositionInfoSource>
-#include <QTimer>
-
-class QGeoPositionInfoSourceAndroid : public QGeoPositionInfoSource
-{
- Q_OBJECT
-public:
- QGeoPositionInfoSourceAndroid(QObject *parent = 0);
- ~QGeoPositionInfoSourceAndroid();
-
- // From QGeoPositionInfoSource
- void setUpdateInterval(int msec) override;
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
- void setPreferredPositioningMethods(PositioningMethods methods) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
-public Q_SLOTS:
- virtual void startUpdates() override;
- virtual void stopUpdates() override;
-
- virtual void requestUpdate(int timeout = 0) override;
-
- void processPositionUpdate(const QGeoPositionInfo& pInfo);
- void processSinglePositionUpdate(const QGeoPositionInfo& pInfo);
-
- void locationProviderDisabled();
- void locationProvidersChanged();
-private Q_SLOTS:
- void requestTimeout();
- void regularUpdatesTimeout();
-
-private:
- void reconfigureRunningSystem();
- void setError(Error error);
-
- bool updatesRunning = false;
- int androidClassKeyForUpdate;
- int androidClassKeyForSingleRequest;
- QList<QGeoPositionInfo> queuedSingleUpdates;
- Error m_error = NoError;
- QTimer m_requestTimer;
- QTimer m_regularUpdatesTimer;
- qint64 m_lastUpdateTime = 0;
- bool m_regularUpdatesErrorRaised = false;
-};
-
-#endif // QGEOPOSITIONINFOSOURCE_ANDROID_P_H
diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp b/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp
deleted file mode 100644
index 13c09680..00000000
--- a/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-
-#include "qgeosatelliteinfosource_android_p.h"
-#include "jnipositioning.h"
-
-Q_DECLARE_METATYPE(QList<QGeoSatelliteInfo>)
-
-#define UPDATE_FROM_COLD_START 2*60*1000
-
-QGeoSatelliteInfoSourceAndroid::QGeoSatelliteInfoSourceAndroid(QObject *parent) :
- QGeoSatelliteInfoSource(parent), m_error(NoError), updatesRunning(false)
-{
- qRegisterMetaType< QGeoSatelliteInfo >();
- qRegisterMetaType< QList<QGeoSatelliteInfo> >();
- androidClassKeyForUpdate = AndroidPositioning::registerPositionInfoSource(this);
- androidClassKeyForSingleRequest = AndroidPositioning::registerPositionInfoSource(this);
-
- requestTimer.setSingleShot(true);
- QObject::connect(&requestTimer, SIGNAL(timeout()),
- this, SLOT(requestTimeout()));
-}
-
-QGeoSatelliteInfoSourceAndroid::~QGeoSatelliteInfoSourceAndroid()
-{
- stopUpdates();
-
- if (requestTimer.isActive()) {
- requestTimer.stop();
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
- }
-
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForUpdate);
- AndroidPositioning::unregisterPositionInfoSource(androidClassKeyForSingleRequest);
-}
-
-
-void QGeoSatelliteInfoSourceAndroid::setUpdateInterval(int msec)
-{
- int previousInterval = updateInterval();
- msec = (((msec > 0) && (msec < minimumUpdateInterval())) || msec < 0)? minimumUpdateInterval() : msec;
-
- if (msec == previousInterval)
- return;
-
- QGeoSatelliteInfoSource::setUpdateInterval(msec);
-
- if (updatesRunning)
- reconfigureRunningSystem();
-}
-
-int QGeoSatelliteInfoSourceAndroid::minimumUpdateInterval() const
-{
- return 50;
-}
-
-QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSourceAndroid::error() const
-{
- return m_error;
-}
-
-void QGeoSatelliteInfoSourceAndroid::startUpdates()
-{
- if (updatesRunning)
- return;
-
- updatesRunning = true;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- QGeoSatelliteInfoSource::Error error = AndroidPositioning::startSatelliteUpdates(
- androidClassKeyForUpdate, false, updateInterval());
- if (error != QGeoSatelliteInfoSource::NoError) {
- updatesRunning = false;
- setError(error);
- }
-}
-
-void QGeoSatelliteInfoSourceAndroid::stopUpdates()
-{
- if (!updatesRunning)
- return;
-
- updatesRunning = false;
- AndroidPositioning::stopUpdates(androidClassKeyForUpdate);
-}
-
-void QGeoSatelliteInfoSourceAndroid::requestUpdate(int timeout)
-{
- if (requestTimer.isActive())
- return;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- if (timeout != 0 && timeout < minimumUpdateInterval()) {
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
-
- if (timeout == 0)
- timeout = UPDATE_FROM_COLD_START;
-
- requestTimer.start(timeout);
-
- // if updates already running with interval equal or less then timeout
- // then we wait for next update coming through
- // assume that a single update will not be quicker than regular updates anyway
- if (updatesRunning && updateInterval() <= timeout)
- return;
-
- QGeoSatelliteInfoSource::Error error = AndroidPositioning::startSatelliteUpdates(
- androidClassKeyForSingleRequest, true, timeout);
- if (error != QGeoSatelliteInfoSource::NoError) {
- requestTimer.stop();
- setError(error);
- }
-}
-
-void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate)
-{
- if (!isSingleUpdate) {
- //if requested while regular updates were running
- if (requestTimer.isActive())
- requestTimer.stop();
- emit QGeoSatelliteInfoSource::satellitesInViewUpdated(satsInView);
- return;
- }
-
- m_satsInView = satsInView;
-}
-
-void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate)
-{
- if (!isSingleUpdate) {
- //if requested while regular updates were running
- if (requestTimer.isActive())
- requestTimer.stop();
- emit QGeoSatelliteInfoSource::satellitesInUseUpdated(satsInUse);
- return;
- }
-
- m_satsInUse = satsInUse;
-}
-
-void QGeoSatelliteInfoSourceAndroid::requestTimeout()
-{
- AndroidPositioning::stopUpdates(androidClassKeyForSingleRequest);
-
- const int count = m_satsInView.count();
- if (!count) {
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
-
- emit QGeoSatelliteInfoSource::satellitesInViewUpdated(m_satsInView);
- emit QGeoSatelliteInfoSource::satellitesInUseUpdated(m_satsInUse);
-
- m_satsInUse.clear();
- m_satsInView.clear();
-}
-
-/*
- Updates the system assuming that updateInterval
- and/or preferredPositioningMethod have changed.
- */
-void QGeoSatelliteInfoSourceAndroid::reconfigureRunningSystem()
-{
- if (!updatesRunning)
- return;
-
- stopUpdates();
- startUpdates();
-}
-
-void QGeoSatelliteInfoSourceAndroid::setError(QGeoSatelliteInfoSource::Error error)
-{
- m_error = error;
- if (m_error != QGeoSatelliteInfoSource::NoError)
- emit QGeoSatelliteInfoSource::errorOccurred(m_error);
-}
-
-void QGeoSatelliteInfoSourceAndroid::locationProviderDisabled()
-{
- setError(QGeoSatelliteInfoSource::ClosedError);
-}
diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h b/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h
deleted file mode 100644
index 19b7b577..00000000
--- a/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QGEOSATELLITEINFOSOURCEANDROID_H
-#define QGEOSATELLITEINFOSOURCEANDROID_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QGeoSatelliteInfoSource>
-#include <QTimer>
-
-class QGeoSatelliteInfoSourceAndroid : public QGeoSatelliteInfoSource
-{
- Q_OBJECT
-public:
- explicit QGeoSatelliteInfoSourceAndroid(QObject *parent = 0);
- ~QGeoSatelliteInfoSourceAndroid();
-
- //From QGeoSatelliteInfoSource
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
-
- Error error() const override;
-
-public Q_SLOTS:
- void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 0) override;
-
- void processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate);
- void processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate);
-
- void locationProviderDisabled();
-private Q_SLOTS:
- void requestTimeout();
-
-private:
- void reconfigureRunningSystem();
- void setError(QGeoSatelliteInfoSource::Error error);
-
- Error m_error;
- int androidClassKeyForUpdate;
- int androidClassKeyForSingleRequest;
- bool updatesRunning;
-
- QTimer requestTimer;
- QList<QGeoSatelliteInfo> m_satsInUse;
- QList<QGeoSatelliteInfo> m_satsInView;
-
-};
-
-#endif // QGEOSATELLITEINFOSOURCEANDROID_H
diff --git a/src/plugins/position/android/src/src.pro b/src/plugins/position/android/src/src.pro
deleted file mode 100644
index 36facc55..00000000
--- a/src/plugins/position/android/src/src.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-TARGET = qtposition_android
-
-QT = core core-private positioning
-
-HEADERS = \
- positionfactory_android.h \
- qgeopositioninfosource_android_p.h \
- jnipositioning.h \
- qgeosatelliteinfosource_android_p.h
-
-SOURCES = \
- positionfactory_android.cpp \
- qgeopositioninfosource_android.cpp \
- jnipositioning.cpp \
- qgeosatelliteinfosource_android.cpp
-
-OTHER_FILES = plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryAndroid
-load(qt_plugin)
diff --git a/src/plugins/position/corelocation/CMakeLists.txt b/src/plugins/position/corelocation/CMakeLists.txt
deleted file mode 100644
index 0126aa65..00000000
--- a/src/plugins/position/corelocation/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from corelocation.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryCL Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryCLPlugin
- OUTPUT_NAME qtposition_cl
- CLASS_NAME QGeoPositionInfoSourceFactoryCL
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosource_cl.mm qgeopositioninfosource_cl_p.h
- qgeopositioninfosourcefactory_cl.h qgeopositioninfosourcefactory_cl.mm
- LIBRARIES
- ${FWCoreLocation}
- ${FWFoundation}
- Qt::Core
- Qt::CorePrivate
- Qt::Positioning
-)
-
-# special case begin
-set_target_properties(QGeoPositionInfoSourceFactoryCLPlugin
- PROPERTIES
- DISABLE_PRECOMPILE_HEADERS ON
-)
-# special case end
-
-#### Keys ignored in scope 1:.:.:corelocation.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:corelocation.pro:NOT APPLE:
-# DISTFILES = "$$OBJECTIVE_SOURCES"
diff --git a/src/plugins/position/corelocation/corelocation.pro b/src/plugins/position/corelocation/corelocation.pro
deleted file mode 100644
index 6b7ba82c..00000000
--- a/src/plugins/position/corelocation/corelocation.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-TARGET = qtposition_cl
-
-QT = core core-private positioning
-
-OBJECTIVE_SOURCES += \
- qgeopositioninfosource_cl.mm \
- qgeopositioninfosourcefactory_cl.mm
-
-HEADERS += \
- qgeopositioninfosource_cl_p.h \
- qgeopositioninfosourcefactory_cl.h
-
-OTHER_FILES += \
- plugin.json
-
-LIBS += -framework Foundation -framework CoreLocation
-
-!darwin {
- DISTFILES += $$OBJECTIVE_SOURCES
-}
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryCL
-load(qt_plugin)
diff --git a/src/plugins/position/corelocation/plugin.json b/src/plugins/position/corelocation/plugin.json
deleted file mode 100644
index 58e3acd0..00000000
--- a/src/plugins/position/corelocation/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["corelocation"],
- "Provider": "corelocation",
- "Position": true,
- "Satellite": false,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
deleted file mode 100644
index c7e02443..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm
+++ /dev/null
@@ -1,336 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QTimerEvent>
-#include <QDebug>
-#include <QtCore/qglobal.h>
-#include <QtCore/private/qglobal_p.h>
-
-#include "qgeopositioninfosource_cl_p.h"
-
-#define MINIMUM_UPDATE_INTERVAL 1000
-
-@interface PositionLocationDelegate : NSObject <CLLocationManagerDelegate>
-@end
-
-@implementation PositionLocationDelegate
-{
- QGeoPositionInfoSourceCL *m_positionInfoSource;
-}
-
-- (instancetype)initWithInfoSource:(QGeoPositionInfoSourceCL*) positionInfoSource
-{
- if ((self = [self init])) {
- m_positionInfoSource = positionInfoSource;
- }
- return self;
-}
-- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
-{
- Q_UNUSED(manager);
- if (status == kCLAuthorizationStatusNotDetermined)
- m_positionInfoSource->requestUpdate(MINIMUM_UPDATE_INTERVAL);
-}
-
-- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
-{
- Q_UNUSED(manager);
- Q_UNUSED(oldLocation);
-
- // Convert location timestamp to QDateTime
- NSTimeInterval locationTimeStamp = [newLocation.timestamp timeIntervalSince1970];
- const QDateTime timeStamp = QDateTime::fromMSecsSinceEpoch(qRound64(locationTimeStamp * 1000), Qt::UTC);
-
- // Construct position info from location data
- QGeoPositionInfo location(QGeoCoordinate(newLocation.coordinate.latitude,
- newLocation.coordinate.longitude,
- newLocation.altitude),
- timeStamp);
- if (newLocation.horizontalAccuracy >= 0)
- location.setAttribute(QGeoPositionInfo::HorizontalAccuracy, newLocation.horizontalAccuracy);
- if (newLocation.verticalAccuracy >= 0)
- location.setAttribute(QGeoPositionInfo::VerticalAccuracy, newLocation.verticalAccuracy);
-#ifndef Q_OS_TVOS
- if (newLocation.course >= 0)
- location.setAttribute(QGeoPositionInfo::Direction, newLocation.course);
- if (newLocation.speed >= 0)
- location.setAttribute(QGeoPositionInfo::GroundSpeed, newLocation.speed);
-#endif
-
- m_positionInfoSource->locationDataAvailable(location);
-}
-
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
-{
- Q_UNUSED(manager);
- m_positionInfoSource->setError(QGeoPositionInfoSource::AccessError);
-
- qWarning() << QString::fromNSString([error localizedDescription]);
-
- if ([error code] == 0
- && QString::fromNSString([error domain]) == QStringLiteral("kCLErrorDomain"))
- qWarning() << "(is Wi-Fi turned on?)";
-}
-@end
-
-QT_BEGIN_NAMESPACE
-
-QGeoPositionInfoSourceCL::QGeoPositionInfoSourceCL(QObject *parent)
- : QGeoPositionInfoSource(parent)
- , m_locationManager(0)
- , m_started(false)
- , m_updateTimer(0)
- , m_updateTimeout(0)
- , m_positionError(QGeoPositionInfoSource::NoError)
-{
-}
-
-QGeoPositionInfoSourceCL::~QGeoPositionInfoSourceCL()
-{
- stopUpdates();
- [m_locationManager release];
-}
-
-void QGeoPositionInfoSourceCL::setUpdateInterval(int msec)
-{
- // If msec is 0 we send updates as data becomes available, otherwise we force msec to be equal
- // to or larger than the minimum update interval.
- if (msec != 0 && msec < minimumUpdateInterval())
- msec = minimumUpdateInterval();
-
- QGeoPositionInfoSource::setUpdateInterval(msec);
-
- // Must timeout if update takes longer than specified interval
- m_updateTimeout = msec;
- if (m_started) setTimeoutInterval(m_updateTimeout);
-}
-
-bool QGeoPositionInfoSourceCL::enableLocationManager()
-{
- if (!m_locationManager) {
- if ([CLLocationManager locationServicesEnabled]) {
- // Location Services Are Enabled
- switch ([CLLocationManager authorizationStatus]) {
- case kCLAuthorizationStatusNotDetermined:
- // User has not yet made a choice with regards to this application
- break;
- case kCLAuthorizationStatusRestricted:
- // This application is not authorized to use location services. Due
- // to active restrictions on location services, the user cannot change
- // this status, and may not have personally denied authorization
- return false;
- case kCLAuthorizationStatusDenied:
- // User has explicitly denied authorization for this application, or
- // location services are disabled in Settings
- return false;
- case kCLAuthorizationStatusAuthorizedAlways:
- // This app is authorized to start location services at any time.
- break;
-#ifndef Q_OS_MACOS
- case kCLAuthorizationStatusAuthorizedWhenInUse:
- // This app is authorized to start most location services while running in the foreground.
- break;
-#endif
- default:
- // By default, try to enable it
- break;
- }
- } else {
- // Location Services Disabled
- return false;
- }
-
- m_locationManager = [[CLLocationManager alloc] init];
-
-#if defined(Q_OS_IOS) || defined(Q_OS_WATCHOS)
- if (__builtin_available(watchOS 4.0, *)) {
- NSDictionary<NSString *, id> *infoDict = [[NSBundle mainBundle] infoDictionary];
- if (id value = [infoDict objectForKey:@"UIBackgroundModes"]) {
- if ([value isKindOfClass:[NSArray class]]) {
- NSArray *modes = static_cast<NSArray *>(value);
- for (id mode in modes) {
- if ([@"location" isEqualToString:mode]) {
- m_locationManager.allowsBackgroundLocationUpdates = YES;
- break;
- }
- }
- }
- }
- }
-#endif
-
- m_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
- m_locationManager.delegate = [[PositionLocationDelegate alloc] initWithInfoSource:this];
-
- // -requestAlwaysAuthorization is available on iOS (>= 8.0) and watchOS (>= 2.0).
- // This method requires both NSLocationAlwaysAndWhenInUseUsageDescription and
- // NSLocationWhenInUseUsageDescription entries present in Info.plist (otherwise,
- // while probably a noop, the call generates a warning).
- // -requestWhenInUseAuthorization only requires NSLocationWhenInUseUsageDescription
- // entry in Info.plist (available on iOS (>= 8.0), tvOS (>= 9.0) and watchOS (>= 2.0).
- }
-
-#ifndef Q_OS_MACOS
- NSDictionary<NSString *, id> *infoDict = NSBundle.mainBundle.infoDictionary;
- const bool hasAlwaysUseUsage = !![infoDict objectForKey:@"NSLocationAlwaysAndWhenInUseUsageDescription"];
- const bool hasWhenInUseUsage = !![infoDict objectForKey:@"NSLocationWhenInUseUsageDescription"];
-#ifndef Q_OS_TVOS
- if (hasAlwaysUseUsage && hasWhenInUseUsage)
- [m_locationManager requestAlwaysAuthorization];
- else
-#endif // !Q_OS_TVOS
- if (hasWhenInUseUsage)
- [m_locationManager requestWhenInUseAuthorization];
-#endif // !Q_OS_MACOS
-
- return (m_locationManager != nullptr);
-}
-
-void QGeoPositionInfoSourceCL::setTimeoutInterval(int msec)
-{
- // Start timeout timer
- if (m_updateTimer) killTimer(m_updateTimer);
- if (msec > 0) m_updateTimer = startTimer(msec);
- else m_updateTimer = 0;
-}
-
-void QGeoPositionInfoSourceCL::startUpdates()
-{
- m_positionError = QGeoPositionInfoSource::NoError;
- if (enableLocationManager()) {
-#ifdef Q_OS_TVOS
- [m_locationManager requestLocation]; // service will run long enough for one location update
-#else
- [m_locationManager startUpdatingLocation];
-#endif
- m_started = true;
-
- setTimeoutInterval(m_updateTimeout);
- } else setError(QGeoPositionInfoSource::AccessError);
-}
-
-void QGeoPositionInfoSourceCL::stopUpdates()
-{
- if (m_locationManager) {
- [m_locationManager stopUpdatingLocation];
- m_started = false;
-
- // Stop timeout timer
- setTimeoutInterval(0);
- } else setError(QGeoPositionInfoSource::AccessError);
-}
-
-void QGeoPositionInfoSourceCL::requestUpdate(int timeout)
-{
- // Get a single update within timeframe
- m_positionError = QGeoPositionInfoSource::NoError;
- if (timeout < minimumUpdateInterval() && timeout != 0)
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- else if (enableLocationManager()) {
- // This will force LM to generate a new update
- [m_locationManager stopUpdatingLocation];
-#ifdef Q_OS_TVOS
- [m_locationManager requestLocation]; // service will run long enough for one location update
-#else
- [m_locationManager startUpdatingLocation];
-#endif
-
- setTimeoutInterval(timeout);
- } else setError(QGeoPositionInfoSource::AccessError);
-}
-
-void QGeoPositionInfoSourceCL::timerEvent( QTimerEvent * event )
-{
- // Update timed out?
- if (event->timerId() == m_updateTimer) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
-
- // Only timeout once since last data
- setTimeoutInterval(0);
-
- // Started for single update?
- if (!m_started) stopUpdates();
- }
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceCL::supportedPositioningMethods() const
-{
- // CoreLocation doesn't say which positioning method(s) it used
- return QGeoPositionInfoSource::AllPositioningMethods;
-}
-
-int QGeoPositionInfoSourceCL::minimumUpdateInterval() const
-{
- return MINIMUM_UPDATE_INTERVAL;
-}
-
-void QGeoPositionInfoSourceCL::locationDataAvailable(QGeoPositionInfo location)
-{
- // Signal position data available
- m_lastUpdate = location;
- emit positionUpdated(location);
-
- // Started for single update?
- if (!m_started) stopUpdates();
- // ...otherwise restart timeout timer
- else setTimeoutInterval(m_updateTimeout);
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceCL::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- Q_UNUSED(fromSatellitePositioningMethodsOnly);
-
- return m_lastUpdate;
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceCL::error() const
-{
- return m_positionError;
-}
-
-void QGeoPositionInfoSourceCL::setError(QGeoPositionInfoSource::Error positionError)
-{
- m_positionError = positionError;
- if (m_positionError != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(positionError);
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qgeopositioninfosource_cl_p.cpp"
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h b/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h
deleted file mode 100644
index d38e7c3b..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosource_cl_p.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCECL_H
-#define QGEOPOSITIONINFOSOURCECL_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#import <CoreLocation/CoreLocation.h>
-
-#include "qgeopositioninfosource.h"
-#include "qgeopositioninfo.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceCL : public QGeoPositionInfoSource
-{
- Q_OBJECT
-public:
- QGeoPositionInfoSourceCL(QObject *parent = 0);
- ~QGeoPositionInfoSourceCL();
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
-
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
- void locationDataAvailable(QGeoPositionInfo location);
- void setError(QGeoPositionInfoSource::Error positionError);
-
-private:
- bool enableLocationManager();
- void setTimeoutInterval(int msec);
-
-public Q_SLOTS:
- void startUpdates() override;
- void stopUpdates() override;
-
- void requestUpdate(int timeout = 0) override;
-
-protected:
- void timerEvent(QTimerEvent *event) override;
-
-private:
- Q_DISABLE_COPY(QGeoPositionInfoSourceCL);
- CLLocationManager *m_locationManager;
- bool m_started;
-
- QGeoPositionInfo m_lastUpdate;
-
- int m_updateTimer;
- int m_updateTimeout;
-
- QGeoPositionInfoSource::Error m_positionError;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCECL_H
diff --git a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h
deleted file mode 100644
index 7e14e31f..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_CL_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_CL_H
-
-#include <QObject>
-#include <QGeoPositionInfoSourceFactory>
-
-class QGeoPositionInfoSourceFactoryCL : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif // QGEOPOSITIONINFOSOURCEFACTORY_CL_H
diff --git a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm
deleted file mode 100644
index e7d2a116..00000000
--- a/src/plugins/position/corelocation/qgeopositioninfosourcefactory_cl.mm
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_cl_p.h"
-#include "qgeopositioninfosourcefactory_cl.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryCL::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- return new QGeoPositionInfoSourceCL(parent);
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryCL::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryCL::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
diff --git a/src/plugins/position/geoclue2/CMakeLists.txt b/src/plugins/position/geoclue2/CMakeLists.txt
deleted file mode 100644
index c573ee1d..00000000
--- a/src/plugins/position/geoclue2/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Generated from geoclue2.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryGeoclue2 Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryGeoclue2Plugin
- OUTPUT_NAME qtposition_geoclue2
- CLASS_NAME QGeoPositionInfoSourceFactoryGeoclue2
- PLUGIN_TYPE position
- SOURCES
- geocluetypes.cpp geocluetypes.h
- qgeopositioninfosource_geoclue2.cpp qgeopositioninfosource_geoclue2_p.h
- qgeopositioninfosourcefactory_geoclue2.cpp qgeopositioninfosourcefactory_geoclue2.h
- DBUS_INTERFACE_SOURCES
- org.freedesktop.GeoClue2.Client.xml
- org.freedesktop.GeoClue2.Location.xml
- org.freedesktop.GeoClue2.Manager.xml
- DBUS_INTERFACE_FLAGS
- -N -i geocluetypes.h # special case
- INCLUDE_DIRECTORIES
- ${CMAKE_CURRENT_BINARY_DIR}
- core.location.includes
- LIBRARIES
- Qt::Core
- Qt::DBus
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:geoclue2.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/geoclue2/geoclue2.pro b/src/plugins/position/geoclue2/geoclue2.pro
deleted file mode 100644
index 1bd129d5..00000000
--- a/src/plugins/position/geoclue2/geoclue2.pro
+++ /dev/null
@@ -1,30 +0,0 @@
-TARGET = qtposition_geoclue2
-
-QT = core positioning dbus
-
-HEADERS += \
- qgeopositioninfosource_geoclue2_p.h \
- qgeopositioninfosourcefactory_geoclue2.h \
- geocluetypes.h
-
-SOURCES += \
- qgeopositioninfosource_geoclue2.cpp \
- qgeopositioninfosourcefactory_geoclue2.cpp \
- geocluetypes.cpp
-
-QDBUSXML2CPP_INTERFACE_HEADER_FLAGS += \
- "-N -i geocluetypes.h"
-
-DBUS_INTERFACES += \
- org.freedesktop.GeoClue2.Manager.xml \
- org.freedesktop.GeoClue2.Client.xml \
- org.freedesktop.GeoClue2.Location.xml
-
-INCLUDEPATH += $$QT.location.includes $$OUT_PWD
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryGeoclue2
-load(qt_plugin)
diff --git a/src/plugins/position/geoclue2/geocluetypes.cpp b/src/plugins/position/geoclue2/geocluetypes.cpp
deleted file mode 100644
index dec55d3c..00000000
--- a/src/plugins/position/geoclue2/geocluetypes.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "geocluetypes.h"
-
-QT_BEGIN_NAMESPACE
-
-QDBusArgument &operator<<(QDBusArgument &arg, const Timestamp &ts)
-{
- arg.beginStructure();
- arg << ts.m_seconds;
- arg << ts.m_microseconds;
- arg.endStructure();
- return arg;
-}
-
-const QDBusArgument &operator>>(const QDBusArgument &arg, Timestamp &ts)
-{
- arg.beginStructure();
- arg >> ts.m_seconds;
- arg >> ts.m_microseconds;
- arg.endStructure();
- return arg;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/geoclue2/geocluetypes.h b/src/plugins/position/geoclue2/geocluetypes.h
deleted file mode 100644
index 2fc3ca2d..00000000
--- a/src/plugins/position/geoclue2/geocluetypes.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GEOCLUETYPES_H
-#define GEOCLUETYPES_H
-
-#include <QtDBus/QDBusArgument>
-
-class Timestamp
-{
-public:
- quint64 m_seconds = 0;
- quint64 m_microseconds = 0;
-};
-
-QT_BEGIN_NAMESPACE
-
-Q_DECLARE_TYPEINFO(Timestamp, Q_RELOCATABLE_TYPE);
-
-QDBusArgument &operator<<(QDBusArgument &arg, const Timestamp &ts);
-const QDBusArgument &operator>>(const QDBusArgument &arg, Timestamp &ts);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(Timestamp)
-
-#endif // GEOCLUETYPES_H
diff --git a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml b/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml
deleted file mode 100644
index 4a9399b7..00000000
--- a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Client.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<!--
- GeoClue 2.0 Interface Specification
-
- Copyright 2013 Red Hat, Inc.
--->
-
-<node>
-
- <!--
- org.freedesktop.GeoClue2.Client:
- @short_description: The Application-specific client API
-
- This is the interface you use to retrieve location information and receive
- location update signals from GeoClue service. You get the client object to
- use this interface on from org.freedesktop.GeoClue2.Manager.GetClient()
- method.
- -->
- <interface name="org.freedesktop.GeoClue2.Client">
- <!--
- Location:
-
- Current location as path to a #org.freedesktop.GeoClue2.Location object.
- Please note that this property will be set to "/" (D-Bus equivalent of
- null) initially, until Geoclue finds user's location. You want to delay
- reading this property until your callback to
- #org.freedesktop.GeoClue2.Client::LocationUpdated signal is called for
- the first time after starting the client.
- -->
- <property name="Location" type="o" access="read"/>
-
- <!--
- DistanceThreshold:
-
- Contains the current distance threshold in meters. This value is used
- by the service when it gets new location info. If the distance moved is
- below the threshold, it won't emit the LocationUpdated signal.
- The default value is 0. When TimeThreshold is zero, it always emits
- the signal.
- -->
- <property name="DistanceThreshold" type="u" access="readwrite">
- <annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
- </property>
-
- <!--
- TimeThreshold:
-
- Contains the current time threshold in seconds. This value is used
- by the service when it gets new location info. If the time since the
- last update is below the threshold, it won't emit the LocationUpdated
- signal. The default value is 0. When TimeThreshold is zero, it always
- emits the signal.
- -->
- <property name="TimeThreshold" type="u" access="readwrite">
- <annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/>
- </property>
-
- <!--
- DesktopId:
-
- The desktop file id (the basename of the desktop file). This property
- must be set by applications for authorization to work.
- -->
- <property name="DesktopId" type="s" access="readwrite"/>
-
- <!--
- RequestedAccuracyLevel:
-
- The level of accuracy requested by client, as
- <link linkend="GClueAccuracyLevel">GClueAccuracyLevel</link>.
-
- Please keep in mind that the actual accuracy of location information is
- dependent on available hardware on your machine, external resources
- and/or how much accuracy user agrees to be confortable with.
- -->
- <property name="RequestedAccuracyLevel" type="u" access="readwrite"/>
-
- <!--
- Active:
-
- If client is active, i-e started successfully using
- org.freedesktop.GeoClue2.Client.Start() and receiving location updates.
-
- Please keep in mind that geoclue can at any time stop and start the
- client on user (agent) request. Applications that are interested in
- in these changes, should watch for changes in this property.
- -->
- <property name="Active" type="b" access="read"/>
-
- <!--
- Start:
-
- Start receiving events about the current location. Applications should
- hook-up to #org.freedesktop.GeoClue2.Client::LocationUpdated signal
- before calling this method.
- -->
- <method name="Start"/>
-
- <!--
- Stop:
-
- Stop receiving events about the current location.
- -->
- <method name="Stop"/>
-
- <!--
- LocationUpdated:
- @old: old location as path to a #org.freedesktop.GeoClue2.Location object
- @new: new location as path to a #org.freedesktop.GeoClue2.Location object
-
- The signal is emitted every time the location changes.
- The client should set the DistanceThreshold property to control how
- often this signal is emitted.
- -->
- <signal name="LocationUpdated">
- <arg name="oldLocation" type="o"/>
- <arg name="newLocation" type="o"/>
- </signal>
- </interface>
-</node>
diff --git a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml b/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml
deleted file mode 100644
index ebf2ea6b..00000000
--- a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Location.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<!--
- GeoClue 2.0 Interface Specification
-
- Copyright 2013 Red Hat, Inc.
--->
-
-<node>
-
- <!--
- org.freedesktop.GeoClue2.Location:
- @short_description: The Location interface
-
- This is the interface you use on location objects.
- -->
- <interface name="org.freedesktop.GeoClue2.Location">
-
- <!--
- Latitude:
-
- The latitude of the location, in degrees.
- -->
- <property name="Latitude" type="d" access="read"/>
-
- <!--
- Longitude:
-
- The longitude of the location, in degrees.
- -->
- <property name="Longitude" type="d" access="read"/>
-
- <!--
- Accuracy:
-
- The accuracy of the location fix, in meters.
- -->
- <property name="Accuracy" type="d" access="read"/>
-
- <!--
- Altitude:
-
- The altitude of the location fix, in meters. When unknown, its set to
- minimum double value, -1.7976931348623157e+308.
- -->
- <property name="Altitude" type="d" access="read"/>
-
- <!--
- Speed:
-
- The speed in meters per second. When unknown, it's set to -1.0.
- -->
- <property name="Speed" type="d" access="read"/>
-
- <!--
- Heading:
-
- The heading direction in degrees with respect to North direction, in
- clockwise order. That means North becomes 0 degree, East: 90 degrees,
- South: 180 degrees, West: 270 degrees and so on. When unknown,
- it's set to -1.0.
- -->
- <property name="Heading" type="d" access="read"/>
-
- <!--
- Description:
-
- A human-readable description of the location, if available.
-
- WARNING: Applications should not rely on this property since not all
- sources provide a description. If you really need a description (or
- more details) about current location, use a reverse-geocoding API, e.g
- geocode-glib.
- -->
- <property name="Description" type="s" access="read"/>
-
-
- <!--
- Timestamp:
-
- The timestamp when the location was determined, in seconds and
- microseconds since the Epoch. This is the time of measurement if the
- backend provided that information, otherwise the time when GeoClue
- received the new location.
-
- Note that GeoClue can't guarantee that the timestamp will always
- monotonically increase, as a backend may not respect that.
- Also note that a timestamp can be very old, e.g. because of a cached
- location.
- -->
- <property name="Timestamp" type="(tt)" access="read">
- <annotation name="org.qtproject.QtDBus.QtTypeName" value="Timestamp"/>
- </property>
- </interface>
-</node>
diff --git a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml b/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml
deleted file mode 100644
index cf9590f6..00000000
--- a/src/plugins/position/geoclue2/org.freedesktop.GeoClue2.Manager.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<!--
- GeoClue 2.0 Interface Specification
-
- Copyright 2013 Red Hat, Inc.
--->
-
-<node>
-
- <!--
- org.freedesktop.GeoClue2.Manager:
- @short_description: The GeoClue service manager
-
- This is the interface you use to talk to main GeoClue2 manager object at
- path "/org/freedesktop/GeoClue2/Manager". The only thing you do with this
- interface is to call org.freedesktop.GeoClue2.Manager.GetClient() on it
- to get your application specific client object.
- -->
- <interface name="org.freedesktop.GeoClue2.Manager">
- <!--
- InUse:
-
- Whether service is currently is use by any application.
- -->
- <property name="InUse" type="b" access="read"/>
-
- <!--
- AvailableAccuracyLevel:
-
- The level of available accuracy, as
- <link linkend="GClueAccuracyLevel">GClueAccuracyLevel</link>.
- -->
- <property name="AvailableAccuracyLevel" type="u" access="read"/>
-
- <!--
- GetClient:
- @client: The path for newly created client object
-
- Retrieves a client object which can only be used by the calling
- application only.
- -->
- <method name="GetClient">
- <arg name="client" type="o" direction="out"/>
- </method>
-
- <!--
- AddAgent:
- @id: The Desktop ID (excluding .desktop) of the agent
-
- An API for user authorization agents to register themselves. Each agent
- is responsible for the user it is running as. Application developers
- can and should simply ignore this API.
- -->
- <method name="AddAgent">
- <arg name="id" type="s" direction="in"/>
- </method>
- </interface>
-</node>
diff --git a/src/plugins/position/geoclue2/plugin.json b/src/plugins/position/geoclue2/plugin.json
deleted file mode 100644
index c23d40e0..00000000
--- a/src/plugins/position/geoclue2/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["geoclue2"],
- "Provider": "geoclue2",
- "Position": true,
- "Satellite": false,
- "Monitor": false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
deleted file mode 100644
index 3c78a075..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2.cpp
+++ /dev/null
@@ -1,458 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_geoclue2_p.h"
-
-#include <QtCore/QLoggingCategory>
-#include <QtCore/QSaveFile>
-#include <QtCore/QScopedPointer>
-#include <QtCore/QTimer>
-#include <QtDBus/QDBusPendingCallWatcher>
-
-// Auto-generated D-Bus files.
-#include <client_interface.h>
-#include <location_interface.h>
-
-Q_DECLARE_LOGGING_CATEGORY(lcPositioningGeoclue2)
-
-QT_BEGIN_NAMESPACE
-
-namespace {
-
-// NOTE: Copied from the /usr/include/libgeoclue-2.0/gclue-client.h
-enum GClueAccuracyLevel {
- GCLUE_ACCURACY_LEVEL_NONE = 0,
- GCLUE_ACCURACY_LEVEL_COUNTRY = 1,
- GCLUE_ACCURACY_LEVEL_CITY = 4,
- GCLUE_ACCURACY_LEVEL_NEIGHBORHOOD = 5,
- GCLUE_ACCURACY_LEVEL_STREET = 6,
- GCLUE_ACCURACY_LEVEL_EXACT = 8
-};
-
-const char GEOCLUE2_SERVICE_NAME[] = "org.freedesktop.GeoClue2";
-const int MINIMUM_UPDATE_INTERVAL = 1000;
-const int UPDATE_TIMEOUT_COLD_START = 120000;
-static const auto desktopIdParameter = "desktopId";
-
-static QString lastPositionFilePath()
-{
- return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
- + QStringLiteral("/qtposition-geoclue2");
-}
-
-} // namespace
-
-QGeoPositionInfoSourceGeoclue2::QGeoPositionInfoSourceGeoclue2(const QVariantMap &parameters,
- QObject *parent)
- : QGeoPositionInfoSource(parent)
- , m_requestTimer(new QTimer(this))
- , m_manager(QLatin1String(GEOCLUE2_SERVICE_NAME),
- QStringLiteral("/org/freedesktop/GeoClue2/Manager"),
- QDBusConnection::systemBus(),
- this)
-{
- parseParameters(parameters);
-
- qDBusRegisterMetaType<Timestamp>();
-
- restoreLastPosition();
-
- m_requestTimer->setSingleShot(true);
- connect(m_requestTimer, &QTimer::timeout,
- this, &QGeoPositionInfoSourceGeoclue2::requestUpdateTimeout);
-}
-
-QGeoPositionInfoSourceGeoclue2::~QGeoPositionInfoSourceGeoclue2()
-{
- saveLastPosition();
-}
-
-void QGeoPositionInfoSourceGeoclue2::setUpdateInterval(int msec)
-{
- QGeoPositionInfoSource::setUpdateInterval(msec);
- configureClient();
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceGeoclue2::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- if (fromSatellitePositioningMethodsOnly && !m_lastPositionFromSatellite)
- return QGeoPositionInfo();
- return m_lastPosition;
-}
-
-QGeoPositionInfoSourceGeoclue2::PositioningMethods QGeoPositionInfoSourceGeoclue2::supportedPositioningMethods() const
-{
- bool ok;
- const auto accuracy = m_manager.property("AvailableAccuracyLevel").toUInt(&ok);
- if (!ok) {
- const_cast<QGeoPositionInfoSourceGeoclue2 *>(this)->setError(AccessError);
- return NoPositioningMethods;
- }
-
- switch (accuracy) {
- case GCLUE_ACCURACY_LEVEL_COUNTRY:
- case GCLUE_ACCURACY_LEVEL_CITY:
- case GCLUE_ACCURACY_LEVEL_NEIGHBORHOOD:
- case GCLUE_ACCURACY_LEVEL_STREET:
- return NonSatellitePositioningMethods;
- case GCLUE_ACCURACY_LEVEL_EXACT:
- return AllPositioningMethods;
- case GCLUE_ACCURACY_LEVEL_NONE:
- default:
- return NoPositioningMethods;
- }
-}
-
-void QGeoPositionInfoSourceGeoclue2::setPreferredPositioningMethods(PositioningMethods methods)
-{
- QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
- configureClient();
-}
-
-int QGeoPositionInfoSourceGeoclue2::minimumUpdateInterval() const
-{
- return MINIMUM_UPDATE_INTERVAL;
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceGeoclue2::error() const
-{
- return m_error;
-}
-
-void QGeoPositionInfoSourceGeoclue2::startUpdates()
-{
- if (m_running) {
- qCWarning(lcPositioningGeoclue2) << "Already running";
- return;
- }
-
- qCDebug(lcPositioningGeoclue2) << "Starting updates";
-
- m_error = QGeoPositionInfoSource::NoError;
-
- m_running = true;
-
- startClient();
-
- if (m_lastPosition.isValid()) {
- QMetaObject::invokeMethod(this, "positionUpdated", Qt::QueuedConnection,
- Q_ARG(QGeoPositionInfo, m_lastPosition));
- }
-}
-
-void QGeoPositionInfoSourceGeoclue2::stopUpdates()
-{
- if (!m_running) {
- qCWarning(lcPositioningGeoclue2) << "Already stopped";
- return;
- }
-
- qCDebug(lcPositioningGeoclue2) << "Stopping updates";
- m_running = false;
-
- stopClient();
-}
-
-void QGeoPositionInfoSourceGeoclue2::requestUpdate(int timeout)
-{
- if (m_requestTimer->isActive()) {
- qCDebug(lcPositioningGeoclue2) << "Request timer was active, ignoring startUpdates";
- return;
- }
-
- m_error = QGeoPositionInfoSource::NoError;
-
- if (timeout < minimumUpdateInterval() && timeout != 0) {
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- m_requestTimer->start(timeout ? timeout : UPDATE_TIMEOUT_COLD_START);
- startClient();
-}
-
-void QGeoPositionInfoSourceGeoclue2::setError(QGeoPositionInfoSource::Error error)
-{
- m_error = error;
- if (m_error != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(m_error);
-}
-
-void QGeoPositionInfoSourceGeoclue2::restoreLastPosition()
-{
-#if !defined(QT_NO_DATASTREAM)
- const auto filePath = lastPositionFilePath();
- QFile file(filePath);
- if (file.open(QIODevice::ReadOnly)) {
- QDataStream out(&file);
- out >> m_lastPosition;
- }
-#endif
-}
-
-void QGeoPositionInfoSourceGeoclue2::saveLastPosition()
-{
-#if !defined(QT_NO_DATASTREAM) && QT_CONFIG(temporaryfile)
- if (!m_lastPosition.isValid())
- return;
-
- const auto filePath = lastPositionFilePath();
- QSaveFile file(filePath);
- if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- QDataStream out(&file);
- // Only save position and timestamp.
- out << QGeoPositionInfo(m_lastPosition.coordinate(), m_lastPosition.timestamp());
- file.commit();
- }
-#endif
-}
-
-void QGeoPositionInfoSourceGeoclue2::createClient()
-{
- const QDBusPendingReply<QDBusObjectPath> reply = m_manager.GetClient();
- const auto watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- [this](QDBusPendingCallWatcher *watcher) {
- const QScopedPointer<QDBusPendingCallWatcher, QScopedPointerDeleteLater>
- scopedWatcher(watcher);
- const QDBusPendingReply<QDBusObjectPath> reply = *scopedWatcher;
- if (reply.isError()) {
- const auto error = reply.error();
- qCWarning(lcPositioningGeoclue2) << "Unable to obtain the client patch:"
- << error.name() + error.message();
- setError(AccessError);
- } else {
- const QString clientPath = reply.value().path();
- qCDebug(lcPositioningGeoclue2) << "Client path is:"
- << clientPath;
- delete m_client;
- m_client = new OrgFreedesktopGeoClue2ClientInterface(
- QLatin1String(GEOCLUE2_SERVICE_NAME),
- clientPath,
- QDBusConnection::systemBus(),
- this);
- if (!m_client->isValid()) {
- const auto error = m_client->lastError();
- qCCritical(lcPositioningGeoclue2) << "Unable to create the client object:"
- << error.name() << error.message();
- setError(AccessError);
- delete m_client;
- } else {
- connect(m_client.data(), &OrgFreedesktopGeoClue2ClientInterface::LocationUpdated,
- this, &QGeoPositionInfoSourceGeoclue2::handleNewLocation);
-
- if (configureClient())
- startClient();
- }
- }
- });
-}
-
-void QGeoPositionInfoSourceGeoclue2::startClient()
-{
- // only start the client if someone asked for it already
- if (!m_running && !m_requestTimer->isActive())
- return;
-
- if (!m_client) {
- createClient();
- return;
- }
-
- const QDBusPendingReply<> reply = m_client->Start();
- const auto watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- [this](QDBusPendingCallWatcher *watcher) {
- const QScopedPointer<QDBusPendingCallWatcher, QScopedPointerDeleteLater>
- scopedWatcher(watcher);
- const QDBusPendingReply<> reply = *scopedWatcher;
- if (reply.isError()) {
- const auto error = reply.error();
- qCCritical(lcPositioningGeoclue2) << "Unable to start the client:"
- << error.name() << error.message();
- setError(AccessError);
- delete m_client;
- } else {
- qCDebug(lcPositioningGeoclue2) << "Client successfully started";
-
- const QDBusObjectPath location = m_client->location();
- const QString path = location.path();
- if (path.isEmpty() || path == QLatin1String("/"))
- return;
-
- handleNewLocation({}, location);
- }
- });
-}
-
-void QGeoPositionInfoSourceGeoclue2::stopClient()
-{
- // Only stop client if updates are no longer wanted.
- if (m_requestTimer->isActive() || m_running || !m_client)
- return;
-
- const QDBusPendingReply<> reply = m_client->Stop();
- const auto watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, &QDBusPendingCallWatcher::finished,
- [this](QDBusPendingCallWatcher *watcher) {
- const QScopedPointer<QDBusPendingCallWatcher, QScopedPointerDeleteLater>
- scopedWatcher(watcher);
- const QDBusPendingReply<> reply = *scopedWatcher;
- if (reply.isError()) {
- const auto error = reply.error();
- qCCritical(lcPositioningGeoclue2) << "Unable to stop the client:"
- << error.name() << error.message();
- setError(AccessError);
- } else {
- qCDebug(lcPositioningGeoclue2) << "Client successfully stopped";
- }
- delete m_client;
- });
-}
-
-bool QGeoPositionInfoSourceGeoclue2::configureClient()
-{
- if (!m_client)
- return false;
-
- if (m_desktopId.isEmpty()) {
- qCCritical(lcPositioningGeoclue2)
- << "Unable to configure the client due to the desktop id is not set via"
- << desktopIdParameter << "plugin parameter or QCoreApplication::applicationName";
- setError(AccessError);
- return false;
- }
-
- m_client->setDesktopId(m_desktopId);
-
- const auto msecs = updateInterval();
- const uint secs = qMax(uint(msecs), 0u) / 1000u;
- m_client->setTimeThreshold(secs);
-
- const auto methods = preferredPositioningMethods();
- switch (methods) {
- case SatellitePositioningMethods:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_EXACT);
- break;
- case NonSatellitePositioningMethods:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_STREET);
- break;
- case AllPositioningMethods:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_EXACT);
- break;
- default:
- m_client->setRequestedAccuracyLevel(GCLUE_ACCURACY_LEVEL_NONE);
- break;
- }
-
- return true;
-}
-
-void QGeoPositionInfoSourceGeoclue2::requestUpdateTimeout()
-{
- qCDebug(lcPositioningGeoclue2) << "Request update timeout occurred";
-
- setError(QGeoPositionInfoSource::UpdateTimeoutError);
-
- stopClient();
-}
-
-void QGeoPositionInfoSourceGeoclue2::handleNewLocation(const QDBusObjectPath &oldLocation,
- const QDBusObjectPath &newLocation)
-{
- if (m_requestTimer->isActive())
- m_requestTimer->stop();
-
- const auto oldPath = oldLocation.path();
- const auto newPath = newLocation.path();
- qCDebug(lcPositioningGeoclue2) << "Old location object path:" << oldPath;
- qCDebug(lcPositioningGeoclue2) << "New location object path:" << newPath;
-
- OrgFreedesktopGeoClue2LocationInterface location(
- QLatin1String(GEOCLUE2_SERVICE_NAME),
- newPath,
- QDBusConnection::systemBus(),
- this);
- if (!location.isValid()) {
- const auto error = location.lastError();
- qCCritical(lcPositioningGeoclue2) << "Unable to create the location object:"
- << error.name() << error.message();
- } else {
- QGeoCoordinate coordinate(location.latitude(),
- location.longitude());
- if (const auto altitude = location.altitude() > std::numeric_limits<double>::min())
- coordinate.setAltitude(altitude);
-
- const Timestamp ts = location.timestamp();
- if (ts.m_seconds == 0 && ts.m_microseconds == 0) {
- const auto dt = QDateTime::currentDateTime();
- m_lastPosition = QGeoPositionInfo(coordinate, dt);
- } else {
- auto dt = QDateTime::fromSecsSinceEpoch(qint64(ts.m_seconds));
- dt = dt.addMSecs(ts.m_microseconds / 1000);
- m_lastPosition = QGeoPositionInfo(coordinate, dt);
- }
-
- const auto accuracy = location.accuracy();
- // We assume that an accuracy as 0.0 means that it comes from a sattelite.
- m_lastPositionFromSatellite = qFuzzyCompare(accuracy, 0.0);
-
- m_lastPosition.setAttribute(QGeoPositionInfo::HorizontalAccuracy, accuracy);
- if (const auto speed = location.speed() >= 0.0)
- m_lastPosition.setAttribute(QGeoPositionInfo::GroundSpeed, speed);
- if (const auto heading = location.heading() >= 0.0)
- m_lastPosition.setAttribute(QGeoPositionInfo::Direction, heading);
-
- emit positionUpdated(m_lastPosition);
- qCDebug(lcPositioningGeoclue2) << "New position:" << m_lastPosition;
- }
-
- stopClient();
-}
-
-void QGeoPositionInfoSourceGeoclue2::parseParameters(const QVariantMap &parameters)
-{
- if (parameters.contains(desktopIdParameter))
- m_desktopId = parameters.value(desktopIdParameter).toString();
-
- if (m_desktopId.isEmpty())
- m_desktopId = QCoreApplication::applicationName();
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h b/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h
deleted file mode 100644
index f5ec2b06..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosource_geoclue2_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCE_GEOCLUE2_P_H
-#define QGEOPOSITIONINFOSOURCE_GEOCLUE2_P_H
-
-#include <QtPositioning/QGeoPositionInfoSource>
-#include <QtCore/QPointer>
-#include <manager_interface.h>
-
-class OrgFreedesktopGeoClue2ClientInterface;
-
-QT_BEGIN_NAMESPACE
-class QDBusObjectPath;
-class QTimer;
-
-class QGeoPositionInfoSourceGeoclue2 : public QGeoPositionInfoSource
-{
- Q_OBJECT
-
-public:
- explicit QGeoPositionInfoSourceGeoclue2(const QVariantMap &parameters,
- QObject *parent = nullptr);
- ~QGeoPositionInfoSourceGeoclue2();
-
- // From QGeoPositionInfoSource
- void setUpdateInterval(int msec) override;
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
- void setPreferredPositioningMethods(PositioningMethods methods) override;
- int minimumUpdateInterval() const override;
-
- Error error() const override;
-
- void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 5000) override;
-
-private:
- void setError(QGeoPositionInfoSource::Error error);
- void restoreLastPosition();
- void saveLastPosition();
- void createClient();
- bool configureClient();
- void startClient();
- void stopClient();
- void requestUpdateTimeout();
- void handleNewLocation(const QDBusObjectPath &oldLocation,
- const QDBusObjectPath &newLocation);
- void parseParameters(const QVariantMap &parameters);
-
- QTimer *m_requestTimer = nullptr;
- OrgFreedesktopGeoClue2ManagerInterface m_manager;
- QPointer<OrgFreedesktopGeoClue2ClientInterface> m_client;
- bool m_running = false;
- bool m_lastPositionFromSatellite = false;
- QGeoPositionInfoSource::Error m_error = NoError;
- QGeoPositionInfo m_lastPosition;
- QString m_desktopId;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCE_GEOCLUE2_P_H
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp b/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp
deleted file mode 100644
index 68161f41..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_geoclue2_p.h"
-#include "qgeopositioninfosourcefactory_geoclue2.h"
-
-#include <QtCore/QLoggingCategory>
-
-Q_LOGGING_CATEGORY(lcPositioningGeoclue2, "qt.positioning.geoclue2")
-
-QT_BEGIN_NAMESPACE
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryGeoclue2::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- return new QGeoPositionInfoSourceGeoclue2(parameters, parent);
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGeoclue2::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryGeoclue2::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h b/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h
deleted file mode 100644
index 1cd72fff..00000000
--- a/src/plugins/position/geoclue2/qgeopositioninfosourcefactory_geoclue2.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_GEOCLUE2_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_GEOCLUE2_H
-
-#include <QtCore/QObject>
-#include <QtPositioning/QGeoPositionInfoSourceFactory>
-
-QT_BEGIN_NAMESPACE
-
-/*
- Qt Positioning plugin for Geoclue. This plugin supports Geoclue version 2.x.
-*/
-class QGeoPositionInfoSourceFactoryGeoclue2 : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
-
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
-
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEFACTORY_GEOCLUE2_H
diff --git a/src/plugins/position/gypsy/CMakeLists.txt b/src/plugins/position/gypsy/CMakeLists.txt
deleted file mode 100644
index 1791bdcc..00000000
--- a/src/plugins/position/gypsy/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# Generated from gypsy.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryGypsy Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryGypsyPlugin
- OUTPUT_NAME qtposition_gypsy
- CLASS_NAME QGeoPositionInfoSourceFactoryGypsy
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosourcefactory_gypsy.cpp qgeopositioninfosourcefactory_gypsy.h
- qgeosatelliteinfosource_gypsy.cpp qgeosatelliteinfosource_gypsy_p.h
-# special case begin
- LIBRARIES
- Gypsy::Gypsy
- Gconf::Gconf
- Qt::Core
- Qt::Positioning
-# special case end
-)
-
-#### Keys ignored in scope 1:.:.:gypsy.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/gypsy/gypsy.pro b/src/plugins/position/gypsy/gypsy.pro
deleted file mode 100644
index c7b74325..00000000
--- a/src/plugins/position/gypsy/gypsy.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGET = qtposition_gypsy
-
-QT = core positioning-private
-
-HEADERS += \
- qgeosatelliteinfosource_gypsy_p.h \
- qgeopositioninfosourcefactory_gypsy.h
-
-SOURCES += \
- qgeosatelliteinfosource_gypsy.cpp \
- qgeopositioninfosourcefactory_gypsy.cpp
-
-QMAKE_USE_PRIVATE += gypsy
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryGypsy
-load(qt_plugin)
diff --git a/src/plugins/position/gypsy/plugin.json b/src/plugins/position/gypsy/plugin.json
deleted file mode 100644
index 9cef03f8..00000000
--- a/src/plugins/position/gypsy/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["gypsy"],
- "Provider": "gypsy",
- "Position": false,
- "Satellite": true,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp
deleted file mode 100644
index be7634cd..00000000
--- a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosourcefactory_gypsy.h"
-#include "qgeosatelliteinfosource_gypsy_p.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryGypsy::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryGypsy::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoSatelliteInfoSourceGypsy *src = new QGeoSatelliteInfoSourceGypsy(parent);
- if (src->init(parameters) < 0) {
- delete src;
- src = nullptr;
- }
- return src;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryGypsy::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
diff --git a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h b/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h
deleted file mode 100644
index 495301fd..00000000
--- a/src/plugins/position/gypsy/qgeopositioninfosourcefactory_gypsy.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_GYPSY_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_GYPSY_H
-
-#include <QObject>
-#include <qgeopositioninfosourcefactory.h>
-
-class QGeoPositionInfoSourceFactoryGypsy : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif
diff --git a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp
deleted file mode 100644
index b7f91131..00000000
--- a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy.cpp
+++ /dev/null
@@ -1,442 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeosatelliteinfosource_gypsy_p.h"
-
-#ifdef Q_LOCATION_GYPSY_DEBUG
-#include <QDebug>
-#endif
-#include <QFile>
-#include <QVariantMap>
-
-QT_BEGIN_NAMESPACE
-
-#define UPDATE_TIMEOUT_COLD_START 120000
-
-static const auto deviceNameParameter = "deviceName";
-static const auto gconfKeyParameter = "gconfKey";
-static const auto defaultGconfKey = "/apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice";
-
-// Callback function for 'satellites-changed' -signal
-static void satellites_changed (GypsySatellite *satellite,
- GPtrArray *satellites,
- gpointer userdata)
-{
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug() << "QGeoSatelliteInfoSourceGypsy Gypsy satellites-changed -signal received.";
-#endif
- ((QGeoSatelliteInfoSourceGypsy *)userdata)->satellitesChanged(satellite, satellites);
-}
-
-SatelliteGypsyEngine::SatelliteGypsyEngine(QGeoSatelliteInfoSource *parent) :
- m_owner(parent)
-{
-}
-SatelliteGypsyEngine::~SatelliteGypsyEngine()
-{
-}
-
-// Glib symbols
-gulong SatelliteGypsyEngine::eng_g_signal_connect(gpointer instance,
- const gchar *detailed_signal,
- GCallback c_handler,
- gpointer data)
-{
- return ::g_signal_connect(instance, detailed_signal, c_handler, data);
-}
-guint SatelliteGypsyEngine::eng_g_signal_handlers_disconnect_by_func (gpointer instance,
- gpointer func,
- gpointer data)
-{
- return ::g_signal_handlers_disconnect_by_func(instance, func, data);
-}
-
-void SatelliteGypsyEngine::eng_g_free(gpointer mem)
-{
- return ::g_free(mem);
-}
-// Gypsy symbols
-GypsyControl *SatelliteGypsyEngine::eng_gypsy_control_get_default (void)
-{
- return ::gypsy_control_get_default();
-}
-char *SatelliteGypsyEngine::eng_gypsy_control_create (GypsyControl *control, const char *device_name, GError **error)
-{
- return ::gypsy_control_create(control, device_name, error);
-}
-GypsyDevice *SatelliteGypsyEngine::eng_gypsy_device_new (const char *object_path)
-{
- return ::gypsy_device_new(object_path);
-}
-GypsySatellite *SatelliteGypsyEngine::eng_gypsy_satellite_new (const char *object_path)
-{
- return ::gypsy_satellite_new (object_path);
-}
-gboolean SatelliteGypsyEngine::eng_gypsy_device_start (GypsyDevice *device, GError **error)
-{
- return ::gypsy_device_start(device, error);
-}
-gboolean SatelliteGypsyEngine::eng_gypsy_device_stop (GypsyDevice *device, GError **error)
-{
- // Unfortunately this cannot be done; calling this will stop the GPS device
- // (basically makes gypsy-daemon unusable for anyone), regardless of applications
- // using it (see bug http://bugs.meego.com/show_bug.cgi?id=11707).
- Q_UNUSED(device);
- Q_UNUSED(error);
- return true;
- //return ::gypsy_device_stop (device, error);
-}
-GypsyDeviceFixStatus SatelliteGypsyEngine::eng_gypsy_device_get_fix_status (GypsyDevice *device, GError **error)
-{
- return ::gypsy_device_get_fix_status (device, error);
-}
-GPtrArray *SatelliteGypsyEngine::eng_gypsy_satellite_get_satellites (GypsySatellite *satellite, GError **error)
-{
- return ::gypsy_satellite_get_satellites (satellite, error);
-}
-void SatelliteGypsyEngine::eng_gypsy_satellite_free_satellite_array (GPtrArray *satellites)
-{
- return ::gypsy_satellite_free_satellite_array(satellites);
-}
-// GConf symbols (mockability due to X11 requirement)
-GConfClient *SatelliteGypsyEngine::eng_gconf_client_get_default(void)
-{
- return ::gconf_client_get_default();
-}
-gchar *SatelliteGypsyEngine::eng_gconf_client_get_string(GConfClient *client, const gchar *key, GError** err)
-{
- return ::gconf_client_get_string(client, key, err);
-}
-
-QGeoSatelliteInfoSourceGypsy::QGeoSatelliteInfoSourceGypsy(QObject *parent)
- : QGeoSatelliteInfoSource(parent), m_engine(0), m_satellite(0), m_device(0),
- m_requestTimer(this), m_updatesOngoing(false), m_requestOngoing(false)
-{
- m_requestTimer.setSingleShot(true);
- QObject::connect(&m_requestTimer, SIGNAL(timeout()), this, SLOT(requestUpdateTimeout()));
-}
-
-void QGeoSatelliteInfoSourceGypsy::createEngine()
-{
- delete m_engine;
- m_engine = new SatelliteGypsyEngine(this);
-}
-
-QGeoSatelliteInfoSourceGypsy::~QGeoSatelliteInfoSourceGypsy()
-{
- GError *error = NULL;
- if (m_device) {
- m_engine->eng_gypsy_device_stop (m_device, &error);
- g_object_unref(m_device);
- }
- if (m_satellite)
- g_object_unref(m_satellite);
- if (m_control)
- g_object_unref(m_control);
- if (error)
- g_error_free(error);
- delete m_engine;
-}
-
-static QGeoSatelliteInfo::SatelliteSystem idToSystem(int prn)
-{
- if (prn >= 1 && prn <= 32)
- return QGeoSatelliteInfo::GPS;
- else if (prn >= 65 && prn <= 96)
- return QGeoSatelliteInfo::GLONASS;
- else if (prn >= 193 && prn <= 200)
- return QGeoSatelliteInfo::QZSS;
- else if ((prn >= 201 && prn <= 235) || (prn >= 401 && prn <= 437))
- return QGeoSatelliteInfo::BEIDOU;
- else if (prn >= 301 && prn <= 336)
- return QGeoSatelliteInfo::GALILEO;
- return QGeoSatelliteInfo::Undefined;
-}
-
-void QGeoSatelliteInfoSourceGypsy::satellitesChanged(GypsySatellite *satellite,
- GPtrArray *satellites)
-{
- if (!satellite || !satellites)
- return;
- // We have satellite data and assume it is valid.
- // If a single updateRequest was active, send signals right away.
- // If a periodic timer was running (meaning that the client wishes
- // to have updates at defined intervals), store the data for later sending.
- QList<QGeoSatelliteInfo> lastSatellitesInView;
- QList<QGeoSatelliteInfo> lastSatellitesInUse;
-
- unsigned int i;
- for (i = 0; i < satellites->len; i++) {
- GypsySatelliteDetails *details = (GypsySatelliteDetails *)satellites->pdata[i];
- QGeoSatelliteInfo info;
- info.setSatelliteIdentifier(details->satellite_id);
- info.setSatelliteSystem(idToSystem(details->satellite_id));
- info.setAttribute(QGeoSatelliteInfo::Elevation, details->elevation);
- info.setAttribute(QGeoSatelliteInfo::Azimuth, details->azimuth);
- info.setSignalStrength(details->snr);
- if (details->in_use)
- lastSatellitesInUse.append(info);
- lastSatellitesInView.append(info);
- }
- bool sendUpdates(false);
- // If a single updateRequest() has been issued:
- if (m_requestOngoing) {
- sendUpdates = true;
- m_requestTimer.stop();
- m_requestOngoing = false;
- // If there is no regular updates ongoing, disconnect now.
- if (!m_updatesOngoing) {
- m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void *)satellites_changed, this);
- }
- }
- // If regular updates are to be delivered as they come:
- if (m_updatesOngoing)
- sendUpdates = true;
-
- if (sendUpdates) {
- emit satellitesInUseUpdated(lastSatellitesInUse);
- emit satellitesInViewUpdated(lastSatellitesInView);
- }
-}
-
-QString QGeoSatelliteInfoSourceGypsy::extractDeviceNameFromParameters(const QVariantMap &parameters) const
-{
- // The logic is as follows:
- // 1. If the deviceNameParameter is specified, its value is used to get the
- // device name.
- // 2. If the gconfKeyParameter is specified, its value is used as a key to
- // extract the device name from GConf.
- // 3. If nothing is specified, defaultGconfKey is used as a key to extract
- // the device name from GConf.
- if (parameters.contains(deviceNameParameter))
- return parameters.value(deviceNameParameter).toString();
-
- QString gconfKey = parameters.value(gconfKeyParameter).toString();
- if (gconfKey.isEmpty())
- gconfKey = defaultGconfKey;
-
- if (!m_engine)
- return QString();
-
- GConfClient *client = m_engine->eng_gconf_client_get_default();
- if (!client)
- return QString();
-
- gchar *device_name = m_engine->eng_gconf_client_get_string(client,
- gconfKey.toLatin1().constData(),
- nullptr);
- g_object_unref(client);
-
- const QString deviceName = QString::fromLatin1(device_name);
- m_engine->eng_g_free(device_name);
-
- return deviceName;
-}
-
-int QGeoSatelliteInfoSourceGypsy::init(const QVariantMap parameters)
-{
- GError *error = NULL;
- char *path;
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init (); // this function was deprecated in glib 2.36
-#endif
- createEngine();
-
- const QString deviceName = extractDeviceNameFromParameters(parameters);
-
- if (deviceName.isEmpty() ||
- (deviceName.trimmed().at(0) == '/' && !QFile::exists(deviceName.trimmed()))) {
- qWarning ("QGeoSatelliteInfoSourceGypsy Empty/nonexistent GPS device name detected.");
- qWarning("Use '%s' plugin parameter to specify device name directly", deviceNameParameter);
- qWarning("or use '%s' plugin parameter to specify a GConf key to extract the device name.",
- gconfKeyParameter);
- qWarning ("If the GConf key is used, the gconftool-2 tool can be used to set device name "
- "for the selected key, e.g. on terminal:");
- qWarning ("gconftool-2 -t string -s %s /dev/ttyUSB0", gconfKeyParameter);
- return -1;
- }
- m_control = m_engine->eng_gypsy_control_get_default();
- if (!m_control) {
- qWarning("QGeoSatelliteInfoSourceGypsy unable to create Gypsy control.");
- return -1;
- }
- // (path is the DBus path)
- path = m_engine->eng_gypsy_control_create(m_control, deviceName.toLatin1().constData(), &error);
- if (!path) {
- qWarning ("QGeoSatelliteInfoSourceGypsy error creating client.");
- if (error) {
- qWarning ("error message: %s", error->message);
- g_error_free (error);
- }
- return -1;
- }
- m_device = m_engine->eng_gypsy_device_new (path);
- m_satellite = m_engine->eng_gypsy_satellite_new (path);
- m_engine->eng_g_free(path);
- if (!m_device || !m_satellite) {
- qWarning ("QGeoSatelliteInfoSourceGypsy error creating satellite device.");
- qWarning ("Please check that the GPS device is specified correctly.");
- qWarning("Use '%s' plugin parameter to specify device name directly", deviceNameParameter);
- qWarning("or use '%s' plugin parameter to specify a GConf key to extract the device name.",
- gconfKeyParameter);
- qWarning ("If the GConf key is used, the gconftool-2 tool can be used to set device name "
- "for the selected key, e.g. on terminal:");
- qWarning ("gconftool-2 -t string -s %s /dev/ttyUSB0", gconfKeyParameter);
- if (m_device)
- g_object_unref(m_device);
- if (m_satellite)
- g_object_unref(m_satellite);
- return -1;
- }
- m_engine->eng_gypsy_device_start (m_device, &error);
- if (error) {
- qWarning ("QGeoSatelliteInfoSourceGypsy error starting device: %s ",
- error->message);
- g_error_free(error);
- g_object_unref(m_device);
- g_object_unref(m_satellite);
- return -1;
- }
- return 0;
-}
-
-int QGeoSatelliteInfoSourceGypsy::minimumUpdateInterval() const
-{
- return 1;
-}
-
-QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSourceGypsy::error() const
-{
- return m_error;
-}
-
-void QGeoSatelliteInfoSourceGypsy::startUpdates()
-{
- if (m_updatesOngoing)
- return;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- // If there is a request timer ongoing, we've connected to the signal already
- if (!m_requestTimer.isActive()) {
- m_engine->eng_g_signal_connect (m_satellite, "satellites-changed",
- G_CALLBACK (satellites_changed), this);
- }
- m_updatesOngoing = true;
-}
-
-void QGeoSatelliteInfoSourceGypsy::stopUpdates()
-{
- if (!m_updatesOngoing)
- return;
- m_updatesOngoing = false;
- // Disconnect only if there is no single update request ongoing. Once single update request
- // is completed and it notices that there is no active update ongoing, it will disconnect
- // the signal.
- if (!m_requestTimer.isActive())
- m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void *)satellites_changed, this);
-}
-
-void QGeoSatelliteInfoSourceGypsy::requestUpdate(int timeout)
-{
- if (m_requestOngoing)
- return;
-
- m_error = QGeoSatelliteInfoSource::NoError;
-
- if (timeout < 0) {
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
- m_requestOngoing = true;
- GError *error = 0;
- // If GPS has a fix a already, request current data.
- GypsyDeviceFixStatus fixStatus = m_engine->eng_gypsy_device_get_fix_status(m_device, &error);
- if (!error && (fixStatus != GYPSY_DEVICE_FIX_STATUS_INVALID &&
- fixStatus != GYPSY_DEVICE_FIX_STATUS_NONE)) {
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug() << "QGeoSatelliteInfoSourceGypsy fix available, requesting current satellite data";
-#endif
- GPtrArray *satelliteData = m_engine->eng_gypsy_satellite_get_satellites(m_satellite, &error);
- if (!error) {
- // The fix was available and we have satellite data to deliver right away.
- satellitesChanged(m_satellite, satelliteData);
- m_engine->eng_gypsy_satellite_free_satellite_array(satelliteData);
- return;
- }
- }
- // No fix is available. If updates are not ongoing already, start them.
- m_requestTimer.setInterval(timeout == 0? UPDATE_TIMEOUT_COLD_START: timeout);
- if (!m_updatesOngoing) {
- m_engine->eng_g_signal_connect (m_satellite, "satellites-changed",
- G_CALLBACK (satellites_changed), this);
- }
- m_requestTimer.start();
- if (error) {
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug() << "QGeoSatelliteInfoSourceGypsy error asking fix status or satellite data: " << error->message;
-#endif
- g_error_free(error);
- }
-}
-
-void QGeoSatelliteInfoSourceGypsy::requestUpdateTimeout()
-{
-#ifdef Q_LOCATION_GYPSY_DEBUG
- qDebug("QGeoSatelliteInfoSourceGypsy request update timeout occurred.");
-#endif
- // If we end up here, there has not been valid satellite update.
- // Emit timeout and disconnect from signal if regular updates are not
- // ongoing (as we were listening just for one single requestUpdate).
- if (!m_updatesOngoing) {
- m_engine->eng_g_signal_handlers_disconnect_by_func(G_OBJECT(m_satellite), (void *)satellites_changed, this);
- }
- m_requestOngoing = false;
- setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
-}
-
-void QGeoSatelliteInfoSourceGypsy::setError(QGeoSatelliteInfoSource::Error error)
-{
- m_error = error;
- if (m_error != QGeoSatelliteInfoSource::NoError)
- emit QGeoSatelliteInfoSource::errorOccurred(m_error);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h b/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h
deleted file mode 100644
index c9d1de71..00000000
--- a/src/plugins/position/gypsy/qgeosatelliteinfosource_gypsy_p.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOSATELLITEINFOSOURCE_GYPSY_H
-#define QGEOSATELLITEINFOSOURCE_GYPSY_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeosatelliteinfosource.h"
-#include "qgeosatelliteinfo.h"
-#include <gypsy/gypsy-satellite.h>
-#include <gypsy/gypsy-control.h>
-#include <gypsy/gypsy-device.h>
-#include <gconf/gconf-client.h>
-#include <QTimer>
-
-// #define Q_LOCATION_GYPSY_DEBUG
-
-QT_BEGIN_NAMESPACE
-
-// An engine that encapsulates all symbols we want
-// to be able to mock (for unit/autotest purposes).
-class SatelliteGypsyEngine
-{
-public:
- SatelliteGypsyEngine(QGeoSatelliteInfoSource *parent = 0);
- virtual ~SatelliteGypsyEngine();
- // Glib symbols
- virtual gulong eng_g_signal_connect(gpointer instance,
- const gchar *detailed_signal,
- GCallback c_handler,
- gpointer data);
- virtual guint eng_g_signal_handlers_disconnect_by_func(gpointer instance,
- gpointer func,
- gpointer data);
- virtual void eng_g_free(gpointer mem);
- // Gypsy symbols
- virtual GypsyControl *eng_gypsy_control_get_default (void);
- virtual char *eng_gypsy_control_create (GypsyControl *control, const char *device_name, GError **error);
- virtual GypsyDevice *eng_gypsy_device_new (const char *object_path);
- virtual GypsySatellite *eng_gypsy_satellite_new (const char *object_path);
- virtual gboolean eng_gypsy_device_start (GypsyDevice *device, GError **error);
- virtual gboolean eng_gypsy_device_stop (GypsyDevice *device, GError **error);
- virtual GypsyDeviceFixStatus eng_gypsy_device_get_fix_status (GypsyDevice *device, GError **error);
- virtual GPtrArray *eng_gypsy_satellite_get_satellites (GypsySatellite *satellite, GError **error);
- virtual void eng_gypsy_satellite_free_satellite_array (GPtrArray *satellites);
- // GConf symbols (mockability due to X11 requirement)
- virtual GConfClient *eng_gconf_client_get_default(void);
- virtual gchar *eng_gconf_client_get_string(GConfClient *client, const gchar *key, GError** err);
-protected:
- QGeoSatelliteInfoSource *m_owner;
-};
-
-class QGeoSatelliteInfoSourceGypsy : public QGeoSatelliteInfoSource
- {
- Q_OBJECT
-
-public:
- explicit QGeoSatelliteInfoSourceGypsy(QObject *parent = 0);
- ~QGeoSatelliteInfoSourceGypsy();
- int init(const QVariantMap parameters);
-
- int minimumUpdateInterval() const override;
- Error error() const override;
-
-public slots:
- virtual void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 5000) override;
- void satellitesChanged(GypsySatellite *satellite, GPtrArray *satellites);
-
-private slots:
- void requestUpdateTimeout();
-
-private:
- void setError(QGeoSatelliteInfoSource::Error error);
- QString extractDeviceNameFromParameters(const QVariantMap &parameters) const;
-
-protected:
- // Creates an engine which encapsulates all used symbols
- // that we want to be also able to mock.
- virtual void createEngine();
- SatelliteGypsyEngine *m_engine;
-
-private:
- Q_DISABLE_COPY(QGeoSatelliteInfoSourceGypsy)
- GypsySatellite *m_satellite;
- GypsyDevice *m_device;
- QTimer m_requestTimer;
- bool m_updatesOngoing;
- bool m_requestOngoing;
- QGeoSatelliteInfoSource::Error m_error = QGeoSatelliteInfoSource::NoError;
- GypsyControl *m_control = nullptr;
- };
-
-QT_END_NAMESPACE
-
-#endif // QGEOSATELLITEINFOSOURCE_GYPSY_H
diff --git a/src/plugins/position/nmea/CMakeLists.txt b/src/plugins/position/nmea/CMakeLists.txt
deleted file mode 100644
index 73c5a3b1..00000000
--- a/src/plugins/position/nmea/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# Generated from nmea.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryNmea Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryNmeaPlugin
- OUTPUT_NAME qtposition_nmea
- CLASS_NAME QGeoPositionInfoSourceFactoryNmea
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosourcefactory_nmea.cpp qgeopositioninfosourcefactory_nmea.h
- qiopipe.cpp qiopipe_p.h
- LIBRARIES
- Qt::CorePrivate
- Qt::Positioning
- Qt::SerialPort
- Qt::Network
-)
-
-#### Keys ignored in scope 1:.:.:serialnmea.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/nmea/nmea.pro b/src/plugins/position/nmea/nmea.pro
deleted file mode 100644
index f52d8812..00000000
--- a/src/plugins/position/nmea/nmea.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qtposition_nmea
-
-QT = core-private positioning-private serialport
-
-HEADERS += \
- qgeopositioninfosourcefactory_nmea.h qiopipe_p.h
-
-SOURCES += \
- qgeopositioninfosourcefactory_nmea.cpp qiopipe.cpp
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryNmea
-load(qt_plugin)
diff --git a/src/plugins/position/nmea/plugin.json b/src/plugins/position/nmea/plugin.json
deleted file mode 100644
index 15d22f1f..00000000
--- a/src/plugins/position/nmea/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["nmea"],
- "Provider": "nmea",
- "Position": true,
- "Satellite": false,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp b/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp
deleted file mode 100644
index 15460062..00000000
--- a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.cpp
+++ /dev/null
@@ -1,505 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosourcefactory_nmea.h"
-#include <QtPositioning/QNmeaPositionInfoSource>
-#include <QtPositioning/QNmeaSatelliteInfoSource>
-#include <QtSerialPort/QSerialPort>
-#include <QtSerialPort/QSerialPortInfo>
-#include <QtNetwork/QTcpSocket>
-#include <QLoggingCategory>
-#include <QSet>
-#include <QUrl>
-#include <QFile>
-#include <QSharedPointer>
-#include "qiopipe_p.h"
-
-Q_LOGGING_CATEGORY(lcNmea, "qt.positioning.nmea")
-
-QT_BEGIN_NAMESPACE
-
-static const auto sourceParameterName = QStringLiteral("nmea.source");
-static const auto socketScheme = QStringLiteral("socket:");
-static const auto serialScheme = QStringLiteral("serial:");
-
-// This class is used only for SerialPort devices, because we can't open the
-// same serial port twice.
-// In case of files and sockets it's easier to explicitly create a QIODevice for
-// each new instance of Nmea*InfoSource.
-// Also QFile can't be directly used with QIOPipe, because QFile is not a
-// sequential device.
-// TcpSocket could be used with QIOPipe, but it complicates error handling
-// dramatically, as we would need to somehow forward socket errors through
-// QIOPipes to the clients.
-class IODeviceContainer
-{
-public:
- IODeviceContainer() {}
- IODeviceContainer(IODeviceContainer const&) = delete;
- void operator=(IODeviceContainer const&) = delete;
-
- QSharedPointer<QIOPipe> serial(const QString &portName)
- {
- if (m_serialPorts.contains(portName)) {
- m_serialPorts[portName].refs++;
- QIOPipe *endPipe = new QIOPipe(m_serialPorts[portName].proxy);
- m_serialPorts[portName].proxy->addChildPipe(endPipe);
- return QSharedPointer<QIOPipe>(endPipe);
- }
- IODevice device;
- QSerialPort *port = new QSerialPort(portName);
- port->setBaudRate(4800);
- qCDebug(lcNmea) << "Opening serial port" << portName;
- if (!port->open(QIODevice::ReadOnly)) {
- qWarning("nmea: Failed to open %s", qPrintable(portName));
- delete port;
- return {};
- }
- qCDebug(lcNmea) << "Opened successfully";
- device.device = port;
- device.refs = 1;
- device.proxy = new QIOPipe(port, QIOPipe::ProxyPipe);
- m_serialPorts[portName] = device;
- QIOPipe *endPipe = new QIOPipe(device.proxy);
- device.proxy->addChildPipe(endPipe);
- return QSharedPointer<QIOPipe>(endPipe);
- }
-
- void releaseSerial(const QString &portName, QSharedPointer<QIOPipe> &pipe)
- {
- if (!m_serialPorts.contains(portName))
- return;
-
- pipe.clear(); // make sure to release the pipe returned by getSerial, or else, if there are still refs, data will be leaked through it
- IODevice &device = m_serialPorts[portName];
- if (device.refs > 1) {
- device.refs--;
- return;
- }
-
- IODevice taken = m_serialPorts.take(portName);
- taken.device->deleteLater();
- }
-
-private:
-
- struct IODevice {
- QIODevice *device = nullptr;
- QIOPipe *proxy = nullptr; // adding client pipes as children of proxy
- // allows to dynamically add clients to one device.
- unsigned int refs = 1;
- };
-
- QMap<QString, IODevice> m_serialPorts;
-};
-
-Q_GLOBAL_STATIC(IODeviceContainer, deviceContainer)
-
-// We use a string prefix to distinguish between the different data sources.
-// "socket:" means that we use a socket connection
-// "serial:" means that we use a serial port connection
-// "file:///", "qrc:///" and just plain strings mean that we try to use local
-// file.
-// Note: if we do not specify anything, or specify "serial:" without specifying
-// the port name, then we will try to search for a well-known serial port
-// device.
-class NmeaSource : public QNmeaPositionInfoSource
-{
- Q_OBJECT
-public:
- NmeaSource(QObject *parent, const QVariantMap &parameters);
- NmeaSource(QObject *parent, const QString &fileName);
- ~NmeaSource() override;
- bool isValid() const
- {
- return !m_dataSource.isNull() || !m_fileSource.isNull() || !m_socket.isNull();
- }
-
-private slots:
- void onSocketError(QAbstractSocket::SocketError error);
-
-private:
- void parseSourceParameter(const QString &source);
- void addSerialDevice(const QString &requestedPort);
- void setFileName(const QString &fileName);
- void connectSocket(const QString &source);
-
- QSharedPointer<QIOPipe> m_dataSource;
- QScopedPointer<QFile> m_fileSource;
- QScopedPointer<QTcpSocket> m_socket;
- QString m_sourceName;
-};
-
-NmeaSource::NmeaSource(QObject *parent, const QVariantMap &parameters)
- : QNmeaPositionInfoSource(RealTimeMode, parent)
-{
- const QString source = parameters.value(sourceParameterName).toString();
- parseSourceParameter(source);
-}
-
-NmeaSource::NmeaSource(QObject *parent, const QString &fileName)
- : QNmeaPositionInfoSource(SimulationMode, parent)
-{
- setFileName(fileName);
-}
-
-NmeaSource::~NmeaSource()
-{
- deviceContainer->releaseSerial(m_sourceName, m_dataSource);
-}
-
-void NmeaSource::onSocketError(QAbstractSocket::SocketError error)
-{
- m_socket->close();
-
- switch (error) {
- case QAbstractSocket::UnknownSocketError:
- setError(QGeoPositionInfoSource::UnknownSourceError);
- break;
- case QAbstractSocket::SocketAccessError:
- setError(QGeoPositionInfoSource::AccessError);
- break;
- case QAbstractSocket::RemoteHostClosedError:
- setError(QGeoPositionInfoSource::ClosedError);
- break;
- default:
- qWarning() << "Connection failed! QAbstractSocket::SocketError" << error;
- // TODO - introduce new type of error. TransportError?
- setError(QGeoPositionInfoSource::UnknownSourceError);
- break;
- }
-}
-
-void NmeaSource::parseSourceParameter(const QString &source)
-{
- if (source.startsWith(socketScheme)) {
- // This is a socket
- connectSocket(source);
- } else {
- // Last chance - this can be serial device.
- // Note: File is handled in a separate case.
- addSerialDevice(source);
- }
-}
-
-static QString tryFindSerialDevice(const QString &requestedPort)
-{
- QString portName;
- if (requestedPort.isEmpty()) {
- const QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
- qCDebug(lcNmea) << "Found" << ports.count() << "serial ports";
- if (ports.isEmpty()) {
- qWarning("nmea: No serial ports found");
- return portName;
- }
-
- // Try to find a well-known device.
- QSet<int> supportedDevices;
- supportedDevices << 0x67b; // GlobalSat (BU-353S4 and probably others)
- supportedDevices << 0xe8d; // Qstarz MTK II
- for (const QSerialPortInfo& port : ports) {
- if (port.hasVendorIdentifier() && supportedDevices.contains(port.vendorIdentifier())) {
- portName = port.portName();
- break;
- }
- }
-
- if (portName.isEmpty()) {
- qWarning("nmea: No known GPS device found.");
- }
- } else {
- portName = requestedPort;
- if (portName.startsWith(serialScheme))
- portName.remove(0, 7);
- }
- return portName;
-}
-
-void NmeaSource::addSerialDevice(const QString &requestedPort)
-{
- m_sourceName = tryFindSerialDevice(requestedPort);
- if (m_sourceName.isEmpty())
- return;
-
- m_dataSource = deviceContainer->serial(m_sourceName);
- if (!m_dataSource)
- return;
-
- setDevice(m_dataSource.data());
-}
-
-void NmeaSource::setFileName(const QString &fileName)
-{
- m_sourceName = fileName;
-
- m_fileSource.reset(new QFile(fileName));
- qCDebug(lcNmea) << "Opening file" << fileName;
- if (!m_fileSource->open(QIODevice::ReadOnly)) {
- qWarning("nmea: failed to open file %s", qPrintable(fileName));
- m_fileSource.reset();
- }
-
- if (!m_fileSource)
- return;
-
- qCDebug(lcNmea) << "Opened successfully";
-
- setDevice(m_fileSource.data());
-}
-
-void NmeaSource::connectSocket(const QString &source)
-{
- const QUrl url(source);
- const QString host = url.host();
- const int port = url.port();
- if (!host.isEmpty() && (port > 0)) {
- m_socket.reset(new QTcpSocket);
- // no need to explicitly connect to connected() signal
- connect(m_socket.get(), &QTcpSocket::errorOccurred, this, &NmeaSource::onSocketError);
- m_socket->connectToHost(host, port, QTcpSocket::ReadOnly);
- m_sourceName = source;
-
- setDevice(m_socket.data());
- } else {
- qWarning("nmea: incorrect socket parameters %s:%d", qPrintable(host), port);
- }
-}
-
-class NmeaSatelliteSource : public QNmeaSatelliteInfoSource
-{
- Q_OBJECT
-public:
- NmeaSatelliteSource(QObject *parent, const QVariantMap &parameters);
- NmeaSatelliteSource(QObject *parent, const QString &fileName, const QVariantMap &parameters);
- ~NmeaSatelliteSource();
-
- bool isValid() const { return !m_port.isNull() || !m_file.isNull() || !m_socket.isNull(); }
-
-private slots:
- void onSocketError(QAbstractSocket::SocketError error);
-
-private:
- void parseRealtimeSource(const QString &source);
- void parseSimulationSource(const QString &localFileName);
-
- QSharedPointer<QIOPipe> m_port;
- QScopedPointer<QFile> m_file;
- QScopedPointer<QTcpSocket> m_socket;
- QString m_sourceName;
-};
-
-NmeaSatelliteSource::NmeaSatelliteSource(QObject *parent, const QVariantMap &parameters)
- : QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode::RealTimeMode, parent)
-{
- const QString source = parameters.value(sourceParameterName).toString();
- parseRealtimeSource(source);
-}
-
-// We can use a QNmeaSatelliteInfoSource::SimulationUpdateInterval parameter to
-// set the file read frequency in simulation mode. We use setBackendProperty()
-// for it. The value can't be smaller than minimumUpdateInterval().
-// This check is done on the QNmeaSatelliteInfoSource level
-NmeaSatelliteSource::NmeaSatelliteSource(QObject *parent, const QString &fileName,
- const QVariantMap &parameters)
- : QNmeaSatelliteInfoSource(QNmeaSatelliteInfoSource::UpdateMode::SimulationMode, parent)
-{
- bool ok = false;
- const int interval =
- parameters.value(QNmeaSatelliteInfoSource::SimulationUpdateInterval).toInt(&ok);
- if (ok)
- setBackendProperty(QNmeaSatelliteInfoSource::SimulationUpdateInterval, interval);
- parseSimulationSource(fileName);
-}
-
-NmeaSatelliteSource::~NmeaSatelliteSource()
-{
- deviceContainer->releaseSerial(m_sourceName, m_port);
-}
-
-void NmeaSatelliteSource::onSocketError(QAbstractSocket::SocketError error)
-{
- m_socket->close();
-
- switch (error) {
- case QAbstractSocket::UnknownSocketError:
- setError(QGeoSatelliteInfoSource::UnknownSourceError);
- break;
- case QAbstractSocket::SocketAccessError:
- setError(QGeoSatelliteInfoSource::AccessError);
- break;
- case QAbstractSocket::RemoteHostClosedError:
- setError(QGeoSatelliteInfoSource::ClosedError);
- break;
- default:
- qWarning() << "Connection failed! QAbstractSocket::SocketError" << error;
- // TODO - introduce new type of error. TransportError?
- setError(QGeoSatelliteInfoSource::UnknownSourceError);
- break;
- }
-}
-
-void NmeaSatelliteSource::parseRealtimeSource(const QString &source)
-{
- if (source.startsWith(socketScheme)) {
- // This is a socket.
- const QUrl url(source);
- const QString host = url.host();
- const int port = url.port();
- if (!host.isEmpty() && (port > 0)) {
- m_socket.reset(new QTcpSocket);
- // no need to explicitly connect to connected() signal
- connect(m_socket.get(), &QTcpSocket::errorOccurred,
- this, &NmeaSatelliteSource::onSocketError);
- m_socket->connectToHost(host, port, QTcpSocket::ReadOnly);
- m_sourceName = source;
-
- setDevice(m_socket.data());
- } else {
- qWarning("nmea: incorrect socket parameters %s:%d", qPrintable(host), port);
- }
- } else {
- // Last chance - this can be serial device.
- m_sourceName = tryFindSerialDevice(source);
- if (m_sourceName.isEmpty())
- return;
-
- m_port = deviceContainer->serial(m_sourceName);
- if (!m_port)
- return;
-
- setDevice(m_port.data());
- }
-}
-
-void NmeaSatelliteSource::parseSimulationSource(const QString &localFileName)
-{
- // This is a text file.
- m_sourceName = localFileName;
-
- qCDebug(lcNmea) << "Opening file" << localFileName;
- m_file.reset(new QFile(localFileName));
- if (!m_file->open(QIODevice::ReadOnly)) {
- qWarning("nmea: failed to open file %s", qPrintable(localFileName));
- m_file.reset();
- return;
- }
- qCDebug(lcNmea) << "Opened successfully";
-
- setDevice(m_file.data());
-}
-
-/*!
- \internal
- Returns a local file name if \a source represents it.
- The returned value can be different from \a source, as the method tries to
- modify the path
-*/
-static QString checkSourceIsFile(const QString &source)
-{
- if (source.isEmpty())
- return QString();
-
- QString localFileName = source;
-
- if (!QFile::exists(localFileName)) {
- if (localFileName.startsWith(QStringLiteral("qrc:///")))
- localFileName.remove(0, 7);
- else if (localFileName.startsWith(QStringLiteral("file:///")))
- localFileName.remove(0, 7);
- else if (localFileName.startsWith(QStringLiteral("qrc:/")))
- localFileName.remove(0, 5);
-
- if (!QFile::exists(localFileName) && localFileName.startsWith(QLatin1Char('/')))
- localFileName.remove(0, 1);
- }
- if (!QFile::exists(localFileName))
- localFileName.prepend(QLatin1Char(':'));
-
- const bool isLocalFile = QFile::exists(localFileName);
- return isLocalFile ? localFileName : QString();
-}
-
-/*!
- \internal
- Returns a local file name if file exists, or an empty string otherwise
-*/
-static QString extractLocalFileName(const QVariantMap &parameters)
-{
- QString localFileName = parameters.value(sourceParameterName).toString();
- return checkSourceIsFile(localFileName);
-}
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryNmea::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- std::unique_ptr<NmeaSource> src = nullptr;
-
- const QString localFileName = extractLocalFileName(parameters);
- if (localFileName.isEmpty())
- src = std::make_unique<NmeaSource>(parent, parameters); // use RealTimeMode
- else
- src = std::make_unique<NmeaSource>(parent, localFileName); // use SimulationMode
-
- return (src && src->isValid()) ? src.release() : nullptr;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryNmea::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- std::unique_ptr<NmeaSatelliteSource> src = nullptr;
-
- const QString localFileName = extractLocalFileName(parameters);
- if (localFileName.isEmpty()) {
- // use RealTimeMode
- src = std::make_unique<NmeaSatelliteSource>(parent, parameters);
- } else {
- // use SimulationMode
- src = std::make_unique<NmeaSatelliteSource>(parent, localFileName, parameters);
- }
- return (src && src->isValid()) ? src.release() : nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryNmea::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent);
- Q_UNUSED(parameters);
- return nullptr;
-}
-
-QT_END_NAMESPACE
-
-#include "qgeopositioninfosourcefactory_nmea.moc"
diff --git a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h b/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h
deleted file mode 100644
index d7ac98aa..00000000
--- a/src/plugins/position/nmea/qgeopositioninfosourcefactory_nmea.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_NMEA_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_NMEA_H
-
-#include <QObject>
-#include <QtPositioning/QGeoPositionInfoSourceFactory>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceFactoryNmea : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/position/nmea/qiopipe.cpp b/src/plugins/position/nmea/qiopipe.cpp
deleted file mode 100644
index 75cd923c..00000000
--- a/src/plugins/position/nmea/qiopipe.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qiopipe_p.h"
-#include <QtCore/qmetaobject.h>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*
- proxying means do *not* emit readyRead, and instead pump data
- into child pipes directly in a zero-copy fashion.
-*/
-QIOPipePrivate::QIOPipePrivate(QIODevice *iodevice, bool proxying)
- : m_proxying(proxying), source(iodevice)
-{
-}
-
-QIOPipePrivate::~QIOPipePrivate()
-{
-}
-
-void QIOPipePrivate::initialize()
-{
- const QIOPipe *parentPipe = qobject_cast<QIOPipe *>(source);
- if (parentPipe && parentPipe->d_func()->m_proxying) // with proxying parent,
- return; // don't do anything
-
- // read available data, does not emit.
- readAvailableData();
- // connect readyRead to onReadyRead
- QObjectPrivate::connect(source, &QIODevice::readyRead, this, &QIOPipePrivate::_q_onReadyRead);
-}
-
-bool QIOPipePrivate::readAvailableData() {
- if (!source)
- return false;
- QByteArray ba = source->readAll();
- if (!ba.size())
- return false;
-
- pumpData(ba);
- return true;
-}
-
-void QIOPipePrivate::pumpData(const QByteArray &ba)
-{
- if (m_proxying) {
- QList<int> toRemove;
- for (int i = 0; i < childPipes.size(); ++i) {
- const QPointer<QIOPipe> &cp = childPipes.at(i);
- if (!cp) {
- toRemove.append(i);
- continue;
- }
- QIOPipePrivate *cpp = cp->d_func();
- cpp->pushData(ba);
- }
- for (int i = toRemove.size() - 1; i >= 0; --i) {
- childPipes.remove(i);
- }
- } else {
- for (int i = 0; i < readBuffers.size(); i++)
- readBuffers[i].append(ba);
- }
-}
-
-void QIOPipePrivate::pushData(const QByteArray &ba)
-{
- Q_Q(QIOPipe);
- if (!ba.size())
- return;
-
- pumpData(ba);
- if (!m_proxying)
- emit q->readyRead();
-}
-
-void QIOPipePrivate::_q_onReadyRead()
-{
- Q_Q(QIOPipe);
- if (readAvailableData() && !m_proxying)
- emit q->readyRead();
-}
-
-void QIOPipePrivate::addChildPipe(QIOPipe *childPipe)
-{
- if (childPipes.contains(childPipe))
- return;
- childPipes.append(childPipe);
-}
-
-void QIOPipePrivate::removeChildPipe(QIOPipe *childPipe)
-{
- childPipes.removeOne(childPipe);
-}
-
-QIOPipe::QIOPipe(QIODevice *parent, Mode mode)
- : QIODevice(*new QIOPipePrivate(parent, mode == ProxyPipe), parent)
-{
- this->d_func()->initialize();
- if (!parent->isOpen() && !parent->open(QIODevice::ReadOnly)) {
- qWarning() << "QIOPipe: Failed to open " << parent;
- return;
- }
- open(ReadOnly);
-}
-
-QIOPipe::~QIOPipe()
-{
-
-}
-
-bool QIOPipe::open(QIODevice::OpenMode mode)
-{
- if (isOpen())
- return true;
-
- static const OpenMode supportedOpenMode = ReadOnly; // Currently limit it to read only
- if (!(mode & supportedOpenMode)) {
- qFatal("Unsupported open mode");
- return false;
- }
-
- return QIODevice::open(mode);
-}
-
-bool QIOPipe::isSequential() const
-{
- return true;
-}
-
-void QIOPipe::setReadChannelCount(int count)
-{
- Q_D(QIOPipe);
- d->setReadChannelCount(qMax(count, 1));
-}
-
-void QIOPipe::addChildPipe(QIOPipe *childPipe)
-{
- Q_D(QIOPipe);
- d->addChildPipe(childPipe);
-}
-
-/*!
- \reimp
-
- \omit
- This function does not really read anything, as we use QIODevicePrivate's
- buffer. The buffer will be read inside of QIODevice before this
- method will be called.
- See QIODevicePrivate::read, buffer.read(data, maxSize).
- \endomit
-*/
-qint64 QIOPipe::readData(char *data, qint64 maxlen)
-{
- Q_UNUSED(data);
- Q_UNUSED(maxlen);
-
- // return 0 indicating there may be more data in the future
- // Returning -1 means no more data in the future (end of stream).
- return qint64(0);
-}
-
-qint64 QIOPipe::writeData(const char * /*data*/, qint64 /*len*/)
-{
- qFatal("QIOPipe is a read-only device");
- return qint64(0);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/nmea/qiopipe_p.h b/src/plugins/position/nmea/qiopipe_p.h
deleted file mode 100644
index dd83588a..00000000
--- a/src/plugins/position/nmea/qiopipe_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QIOPIPE_P_H
-#define QIOPIPE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qiodevice.h>
-#include <QtCore/qbytearray.h>
-#include <QtCore/private/qiodevice_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QObject;
-class QIOPipePrivate;
-
-class QIOPipe : public QIODevice
-{
- Q_OBJECT
-
-public:
- enum Mode {
- EndPipe = 0x0000,
- ProxyPipe = 0x0001
- };
-
- explicit QIOPipe(QIODevice *parent, Mode mode = EndPipe);
- ~QIOPipe() override;
-
- bool open(OpenMode openMode) override;
- bool isSequential() const override;
- void setReadChannelCount(int count);
- void addChildPipe(QIOPipe *childPipe);
-
-protected:
- qint64 readData(char *data, qint64 maxlen) override;
- qint64 writeData(const char *data, qint64 len) override;
-
-private:
- Q_DECLARE_PRIVATE(QIOPipe)
- Q_DISABLE_COPY(QIOPipe)
-};
-
-class QIOPipePrivate : public QIODevicePrivate
-{
- Q_DECLARE_PUBLIC(QIOPipe)
-
-public:
- explicit QIOPipePrivate(QIODevice *iodevice, bool proxying);
- ~QIOPipePrivate() override;
-
- void initialize();
- bool readAvailableData();
- void pumpData(const QByteArray &ba);
- void pushData(const QByteArray &ba);
- void _q_onReadyRead();
- void addChildPipe(QIOPipe *childPipe);
- void removeChildPipe(QIOPipe *childPipe);
-
- bool m_proxying = false;
- QPointer<QIODevice> source;
- QList<QPointer<QIOPipe>> childPipes;
-};
-
-QT_END_NAMESPACE
-
-#endif // QIOPIPE_P_H
-
diff --git a/src/plugins/position/position.pro b/src/plugins/position/position.pro
deleted file mode 100644
index 145150ee..00000000
--- a/src/plugins/position/position.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = subdirs
-
-QT_FOR_CONFIG += positioning-private
-
-linux|freebsd|openbsd|netbsd:qtHaveModule(dbus):SUBDIRS += geoclue2
-qtConfig(gypsy):SUBDIRS += gypsy
-qtConfig(winrt_geolocation):SUBDIRS += winrt
-osx|ios|tvos:SUBDIRS += corelocation
-android:SUBDIRS += android
-qtHaveModule(serialport):SUBDIRS += serialnmea
-
-SUBDIRS += \
- positionpoll
diff --git a/src/plugins/position/positionpoll/CMakeLists.txt b/src/plugins/position/positionpoll/CMakeLists.txt
deleted file mode 100644
index 59810be1..00000000
--- a/src/plugins/position/positionpoll/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# Generated from positionpoll.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryPoll Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryPollPlugin
- OUTPUT_NAME qtposition_positionpoll
- CLASS_NAME QGeoPositionInfoSourceFactoryPoll
- PLUGIN_TYPE position
- SOURCES
- positionpollfactory.cpp positionpollfactory.h
- qgeoareamonitor_polling.cpp qgeoareamonitor_polling.h
- LIBRARIES
- Qt::Core
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:positionpoll.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
diff --git a/src/plugins/position/positionpoll/plugin.json b/src/plugins/position/positionpoll/plugin.json
deleted file mode 100644
index df1f47de..00000000
--- a/src/plugins/position/positionpoll/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["positionpoll"],
- "Provider": "positionpoll",
- "Position": false,
- "Satellite": false,
- "Monitor": true,
- "Priority": 1000,
- "Testable": true
-}
diff --git a/src/plugins/position/positionpoll/positionpoll.pro b/src/plugins/position/positionpoll/positionpoll.pro
deleted file mode 100644
index be60bf43..00000000
--- a/src/plugins/position/positionpoll/positionpoll.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TARGET = qtposition_positionpoll
-
-QT = core positioning
-
-SOURCES += \
- qgeoareamonitor_polling.cpp \
- positionpollfactory.cpp
-
-HEADERS += \
- qgeoareamonitor_polling.h \
- positionpollfactory.h
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryPoll
-load(qt_plugin)
diff --git a/src/plugins/position/positionpoll/positionpollfactory.cpp b/src/plugins/position/positionpoll/positionpollfactory.cpp
deleted file mode 100644
index a47b2b10..00000000
--- a/src/plugins/position/positionpoll/positionpollfactory.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "positionpollfactory.h"
-#include "qgeoareamonitor_polling.h"
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryPoll::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryPoll::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryPoll::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parameters)
- QGeoAreaMonitorPolling *ret = new QGeoAreaMonitorPolling(parent);
- if (ret && ret->isValid())
- return ret;
- delete ret;
- return nullptr;
-}
diff --git a/src/plugins/position/positionpoll/positionpollfactory.h b/src/plugins/position/positionpoll/positionpollfactory.h
deleted file mode 100644
index 570b3b21..00000000
--- a/src/plugins/position/positionpoll/positionpollfactory.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef POSITIONPOLLFACTORY_H
-#define POSITIONPOLLFACTORY_H
-
-#include <QObject>
-#include <QtPositioning/qgeopositioninfosourcefactory.h>
-
-class QGeoPositionInfoSourceFactoryPoll : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-#endif // POSITIONPOLLFACTORY_H
diff --git a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
deleted file mode 100644
index e69516c8..00000000
--- a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
+++ /dev/null
@@ -1,508 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeoareamonitor_polling.h"
-#include <QtPositioning/qgeocoordinate.h>
-#include <QtPositioning/qgeorectangle.h>
-#include <QtPositioning/qgeocircle.h>
-
-#include <QtCore/qmetaobject.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qmutex.h>
-
-#include <mutex>
-
-#define UPDATE_INTERVAL_5S 5000
-
-typedef QHash<QString, QGeoAreaMonitorInfo> MonitorTable;
-
-
-static QMetaMethod areaEnteredSignal()
-{
- static QMetaMethod signal = QMetaMethod::fromSignal(&QGeoAreaMonitorPolling::areaEntered);
- return signal;
-}
-
-static QMetaMethod areaExitedSignal()
-{
- static QMetaMethod signal = QMetaMethod::fromSignal(&QGeoAreaMonitorPolling::areaExited);
- return signal;
-}
-
-static QMetaMethod monitorExpiredSignal()
-{
- static QMetaMethod signal = QMetaMethod::fromSignal(&QGeoAreaMonitorPolling::monitorExpired);
- return signal;
-}
-
-class QGeoAreaMonitorPollingPrivate : public QObject
-{
- Q_OBJECT
-public:
- QGeoAreaMonitorPollingPrivate()
- {
- nextExpiryTimer = new QTimer(this);
- nextExpiryTimer->setSingleShot(true);
- connect(nextExpiryTimer, SIGNAL(timeout()),
- this, SLOT(timeout()));
- }
-
- void startMonitoring(const QGeoAreaMonitorInfo &monitor)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- activeMonitorAreas.insert(monitor.identifier(), monitor);
- singleShotTrigger.remove(monitor.identifier());
-
- checkStartStop();
- setupNextExpiryTimeout();
- }
-
- void requestUpdate(const QGeoAreaMonitorInfo &monitor, int signalId)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- activeMonitorAreas.insert(monitor.identifier(), monitor);
- singleShotTrigger.insert(monitor.identifier(), signalId);
-
- checkStartStop();
- setupNextExpiryTimeout();
- }
-
- QGeoAreaMonitorInfo stopMonitoring(const QGeoAreaMonitorInfo &monitor)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- QGeoAreaMonitorInfo mon = activeMonitorAreas.take(monitor.identifier());
-
- checkStartStop();
- setupNextExpiryTimeout();
-
- return mon;
- }
-
- void registerClient(QGeoAreaMonitorPolling *client)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- connect(this, SIGNAL(timeout(QGeoAreaMonitorInfo)),
- client, SLOT(timeout(QGeoAreaMonitorInfo)));
-
- connect(this, SIGNAL(positionError(QGeoPositionInfoSource::Error)),
- client, SLOT(positionError(QGeoPositionInfoSource::Error)));
-
- connect(this, SIGNAL(areaEventDetected(QGeoAreaMonitorInfo,QGeoPositionInfo,bool)),
- client, SLOT(processAreaEvent(QGeoAreaMonitorInfo,QGeoPositionInfo,bool)));
-
- registeredClients.append(client);
- }
-
- void deregisterClient(QGeoAreaMonitorPolling *client)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- registeredClients.removeAll(client);
- if (registeredClients.isEmpty())
- checkStartStop();
- }
-
- void setPositionSource(QGeoPositionInfoSource *newSource)
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- if (newSource == source)
- return;
-
- if (source)
- delete source;
-
- source = newSource;
-
- if (source) {
- source->setParent(this);
- source->moveToThread(this->thread());
- if (source->updateInterval() == 0)
- source->setUpdateInterval(UPDATE_INTERVAL_5S);
- disconnect(source, 0, 0, 0); //disconnect all
- connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
- this, SLOT(positionUpdated(QGeoPositionInfo)));
- connect(source, SIGNAL(errorOccurred(QGeoPositionInfoSource::Error)),
- this, SIGNAL(positionError(QGeoPositionInfoSource::Error)));
- checkStartStop();
- }
- }
-
- QGeoPositionInfoSource* positionSource() const
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
- return source;
- }
-
- MonitorTable activeMonitors() const
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- return activeMonitorAreas;
- }
-
- void checkStartStop()
- {
- const std::lock_guard<QRecursiveMutex> locker(mutex);
-
- bool signalsConnected = false;
- foreach (const QGeoAreaMonitorPolling *client, registeredClients) {
- if (client->hasConnections()) {
- signalsConnected = true;
- break;
- }
- }
-
- if (signalsConnected && !activeMonitorAreas.isEmpty()) {
- if (source)
- source->startUpdates();
- else
- //translated to InsufficientPositionInfo
- emit positionError(QGeoPositionInfoSource::ClosedError);
- } else {
- if (source)
- source->stopUpdates();
- }
- }
-
-private:
- void setupNextExpiryTimeout()
- {
- nextExpiryTimer->stop();
- activeExpiry.first = QDateTime();
- activeExpiry.second = QString();
-
- foreach (const QGeoAreaMonitorInfo &info, activeMonitors()) {
- if (info.expiration().isValid()) {
- if (!activeExpiry.first.isValid()) {
- activeExpiry.first = info.expiration();
- activeExpiry.second = info.identifier();
- continue;
- }
- if (info.expiration() < activeExpiry.first) {
- activeExpiry.first = info.expiration();
- activeExpiry.second = info.identifier();
- }
- }
- }
-
- if (activeExpiry.first.isValid())
- nextExpiryTimer->start(QDateTime::currentDateTime().msecsTo(activeExpiry.first));
- }
-
-
- //returns true if areaEntered should be emitted
- bool processInsideArea(const QString &monitorIdent)
- {
- if (!insideArea.contains(monitorIdent)) {
- if (singleShotTrigger.value(monitorIdent, -1) == areaEnteredSignal().methodIndex()) {
- //this is the finishing singleshot event
- singleShotTrigger.remove(monitorIdent);
- activeMonitorAreas.remove(monitorIdent);
- setupNextExpiryTimeout();
- } else {
- insideArea.insert(monitorIdent);
- }
- return true;
- }
-
- return false;
- }
-
- //returns true if areaExited should be emitted
- bool processOutsideArea(const QString &monitorIdent)
- {
- if (insideArea.contains(monitorIdent)) {
- if (singleShotTrigger.value(monitorIdent, -1) == areaExitedSignal().methodIndex()) {
- //this is the finishing singleShot event
- singleShotTrigger.remove(monitorIdent);
- activeMonitorAreas.remove(monitorIdent);
- setupNextExpiryTimeout();
- } else {
- insideArea.remove(monitorIdent);
- }
- return true;
- }
- return false;
- }
-
-
-
-Q_SIGNALS:
- void timeout(const QGeoAreaMonitorInfo &info);
- void positionError(const QGeoPositionInfoSource::Error error);
- void areaEventDetected(const QGeoAreaMonitorInfo &minfo,
- const QGeoPositionInfo &pinfo, bool isEnteredEvent);
-private Q_SLOTS:
- void timeout()
- {
- /*
- * Don't block timer firing even if monitorExpiredSignal is not connected.
- * This allows us to continue to remove the existing monitors as they expire.
- **/
- const QGeoAreaMonitorInfo info = activeMonitorAreas.take(activeExpiry.second);
- setupNextExpiryTimeout();
- emit timeout(info);
-
- }
-
- void positionUpdated(const QGeoPositionInfo &info)
- {
- foreach (const QGeoAreaMonitorInfo &monInfo, activeMonitors()) {
- const QString identifier = monInfo.identifier();
- if (monInfo.area().contains(info.coordinate())) {
- if (processInsideArea(identifier))
- emit areaEventDetected(monInfo, info, true);
- } else {
- if (processOutsideArea(identifier))
- emit areaEventDetected(monInfo, info, false);
- }
- }
- }
-
-private:
- QPair<QDateTime, QString> activeExpiry;
- QHash<QString, int> singleShotTrigger;
- QTimer* nextExpiryTimer;
- QSet<QString> insideArea;
-
- MonitorTable activeMonitorAreas;
-
- QGeoPositionInfoSource* source = nullptr;
- QList<QGeoAreaMonitorPolling*> registeredClients;
- mutable QRecursiveMutex mutex;
-};
-
-Q_GLOBAL_STATIC(QGeoAreaMonitorPollingPrivate, pollingPrivate)
-
-QGeoAreaMonitorPolling::QGeoAreaMonitorPolling(QObject *parent) : QGeoAreaMonitorSource(parent)
-{
- d = pollingPrivate();
- d->registerClient(this);
- //hookup to default source if existing
- if (!positionInfoSource())
- setPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this));
-}
-
-QGeoAreaMonitorPolling::~QGeoAreaMonitorPolling()
-{
- d->deregisterClient(this);
-}
-
-QGeoPositionInfoSource* QGeoAreaMonitorPolling::positionInfoSource() const
-{
- return d->positionSource();
-}
-
-void QGeoAreaMonitorPolling::setPositionInfoSource(QGeoPositionInfoSource *source)
-{
- d->setPositionSource(source);
-}
-
-QGeoAreaMonitorSource::Error QGeoAreaMonitorPolling::error() const
-{
- return lastError;
-}
-
-bool QGeoAreaMonitorPolling::startMonitoring(const QGeoAreaMonitorInfo &monitor)
-{
- if (!monitor.isValid())
- return false;
-
- //reject an expiry in the past
- if (monitor.expiration().isValid() &&
- (monitor.expiration() < QDateTime::currentDateTime()))
- return false;
-
- //don't accept persistent monitor since we don't support it
- if (monitor.isPersistent())
- return false;
-
- lastError = QGeoAreaMonitorSource::NoError;
-
- //update or insert
- d->startMonitoring(monitor);
-
- return true;
-}
-
-int QGeoAreaMonitorPolling::idForSignal(const char *signal)
-{
- const QByteArray sig = QMetaObject::normalizedSignature(signal + 1);
- const QMetaObject * const mo = metaObject();
-
- return mo->indexOfSignal(sig.constData());
-}
-
-bool QGeoAreaMonitorPolling::hasConnections() const
-{
- // This method is internal and requires the mutex to be already locked.
- return signalConnections > 0;
-}
-
-bool QGeoAreaMonitorPolling::requestUpdate(const QGeoAreaMonitorInfo &monitor, const char *signal)
-{
- if (!monitor.isValid())
- return false;
- //reject an expiry in the past
- if (monitor.expiration().isValid() &&
- (monitor.expiration() < QDateTime::currentDateTime()))
- return false;
-
- //don't accept persistent monitor since we don't support it
- if (monitor.isPersistent())
- return false;
-
- if (!signal)
- return false;
-
- const int signalId = idForSignal(signal);
- if (signalId < 0)
- return false;
-
- //only accept area entered or exit signal
- if (signalId != areaEnteredSignal().methodIndex() &&
- signalId != areaExitedSignal().methodIndex())
- {
- return false;
- }
-
- lastError = QGeoAreaMonitorSource::NoError;
-
- d->requestUpdate(monitor, signalId);
-
- return true;
-}
-
-bool QGeoAreaMonitorPolling::stopMonitoring(const QGeoAreaMonitorInfo &monitor)
-{
- QGeoAreaMonitorInfo info = d->stopMonitoring(monitor);
-
- return info.isValid();
-}
-
-QList<QGeoAreaMonitorInfo> QGeoAreaMonitorPolling::activeMonitors() const
-{
- return d->activeMonitors().values();
-}
-
-QList<QGeoAreaMonitorInfo> QGeoAreaMonitorPolling::activeMonitors(const QGeoShape &region) const
-{
- QList<QGeoAreaMonitorInfo> results;
- if (region.isEmpty())
- return results;
-
- const MonitorTable list = d->activeMonitors();
- foreach (const QGeoAreaMonitorInfo &monitor, list) {
- if (region.contains(monitor.area().center()))
- results.append(monitor);
- }
-
- return results;
-}
-
-QGeoAreaMonitorSource::AreaMonitorFeatures QGeoAreaMonitorPolling::supportedAreaMonitorFeatures() const
-{
- return {};
-}
-
-void QGeoAreaMonitorPolling::connectNotify(const QMetaMethod &signal)
-{
- QMutexLocker locker(&connectionMutex);
- if (signal == areaEnteredSignal() || signal == areaExitedSignal()) {
- const bool alreadyConnected = hasConnections();
- signalConnections++;
- if (!alreadyConnected)
- d->checkStartStop();
- }
-}
-
-void QGeoAreaMonitorPolling::disconnectNotify(const QMetaMethod &signal)
-{
- QMutexLocker locker(&connectionMutex);
- if (signal == areaEnteredSignal() || signal == areaExitedSignal()) {
- if (hasConnections())
- signalConnections--;
- if (!hasConnections())
- d->checkStartStop();
- }
-}
-
-void QGeoAreaMonitorPolling::positionError(const QGeoPositionInfoSource::Error error)
-{
- switch (error) {
- case QGeoPositionInfoSource::AccessError:
- lastError = QGeoAreaMonitorSource::AccessError;
- break;
- case QGeoPositionInfoSource::UnknownSourceError:
- lastError = QGeoAreaMonitorSource::UnknownSourceError;
- break;
- case QGeoPositionInfoSource::ClosedError:
- case QGeoPositionInfoSource::UpdateTimeoutError:
- lastError = QGeoAreaMonitorSource::InsufficientPositionInfo;
- break;
- case QGeoPositionInfoSource::NoError:
- return;
- }
-
- emit QGeoAreaMonitorSource::errorOccurred(lastError);
-}
-
-void QGeoAreaMonitorPolling::timeout(const QGeoAreaMonitorInfo& monitor)
-{
- if (isSignalConnected(monitorExpiredSignal()))
- emit monitorExpired(monitor);
-}
-
-void QGeoAreaMonitorPolling::processAreaEvent(const QGeoAreaMonitorInfo &minfo,
- const QGeoPositionInfo &pinfo, bool isEnteredEvent)
-{
- if (isEnteredEvent)
- emit areaEntered(minfo, pinfo);
- else
- emit areaExited(minfo, pinfo);
-}
-
-#include "qgeoareamonitor_polling.moc"
-#include "moc_qgeoareamonitor_polling.cpp"
diff --git a/src/plugins/position/positionpoll/qgeoareamonitor_polling.h b/src/plugins/position/positionpoll/qgeoareamonitor_polling.h
deleted file mode 100644
index 38a685d4..00000000
--- a/src/plugins/position/positionpoll/qgeoareamonitor_polling.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOAREAMONITORPOLLING_H
-#define QGEOAREAMONITORPOLLING_H
-
-#include <QtPositioning/qgeoareamonitorsource.h>
-#include <QtPositioning/qgeopositioninfosource.h>
-#include <QtCore/qmutex.h>
-
-/**
- * QGeoAreaMonitorPolling
- *
- */
-
-class QGeoAreaMonitorPollingPrivate;
-class QGeoAreaMonitorPolling : public QGeoAreaMonitorSource
-{
- Q_OBJECT
-public :
- explicit QGeoAreaMonitorPolling(QObject *parent = 0);
- ~QGeoAreaMonitorPolling();
-
- void setPositionInfoSource(QGeoPositionInfoSource *source) override;
- QGeoPositionInfoSource* positionInfoSource() const override;
-
- Error error() const override;
-
- bool startMonitoring(const QGeoAreaMonitorInfo &monitor) override;
- bool requestUpdate(const QGeoAreaMonitorInfo &monitor,
- const char *signal) override;
- bool stopMonitoring(const QGeoAreaMonitorInfo &monitor) override;
-
- QList<QGeoAreaMonitorInfo> activeMonitors() const override;
- QList<QGeoAreaMonitorInfo> activeMonitors(const QGeoShape &region) const override;
-
- QGeoAreaMonitorSource::AreaMonitorFeatures supportedAreaMonitorFeatures() const override;
-
- inline bool isValid() { return positionInfoSource(); }
-
-private Q_SLOTS:
- void positionError(QGeoPositionInfoSource::Error error);
- void timeout(const QGeoAreaMonitorInfo &monitor);
- void processAreaEvent(const QGeoAreaMonitorInfo &minfo, const QGeoPositionInfo &pinfo, bool isEnteredEvent);
-
-private:
- QGeoAreaMonitorPollingPrivate* d;
- QGeoAreaMonitorSource::Error lastError = QGeoAreaMonitorSource::NoError;
- friend class QGeoAreaMonitorPollingPrivate;
-
- int signalConnections = 0;
- // connectNotify() and disconnectNotify() can be called from a different
- // thread, so we need to synchronize the access to signalConnections
- QMutex connectionMutex;
-
- void connectNotify(const QMetaMethod &signal) override;
- void disconnectNotify(const QMetaMethod &signal) override;
-
- int idForSignal(const char *signal);
-
- bool hasConnections() const;
-};
-
-#endif // QGEOAREAMONITORPOLLING_H
diff --git a/src/plugins/position/winrt/CMakeLists.txt b/src/plugins/position/winrt/CMakeLists.txt
deleted file mode 100644
index 44de9655..00000000
--- a/src/plugins/position/winrt/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Generated from winrt.pro.
-
-#####################################################################
-## QGeoPositionInfoSourceFactoryWinRT Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QGeoPositionInfoSourceFactoryWinRTPlugin
- OUTPUT_NAME qtposition_winrt
- CLASS_NAME QGeoPositionInfoSourceFactoryWinRT
- PLUGIN_TYPE position
- SOURCES
- qgeopositioninfosource_winrt.cpp qgeopositioninfosource_winrt_p.h
- qgeopositioninfosourcefactory_winrt.cpp qgeopositioninfosourcefactory_winrt.h
- LIBRARIES
- Qt::Core
- Qt::CorePrivate
- Qt::Positioning
-)
-
-#### Keys ignored in scope 1:.:.:winrt.pro:<TRUE>:
-# OTHER_FILES = "plugin.json"
-
-## Scopes:
-#####################################################################
-
-qt_internal_extend_target(QGeoPositionInfoSourceFactoryWinRTPlugin CONDITION MSVC AND NOT WINRT
- LIBRARIES
- runtimeobject.lib
-)
diff --git a/src/plugins/position/winrt/plugin.json b/src/plugins/position/winrt/plugin.json
deleted file mode 100644
index 0696cb0a..00000000
--- a/src/plugins/position/winrt/plugin.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Keys": ["winrt"],
- "Provider": "winrt",
- "Position": true,
- "Satellite": false,
- "Monitor" : false,
- "Priority": 1000,
- "Testable": false
-}
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
deleted file mode 100644
index a8e9816f..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp
+++ /dev/null
@@ -1,675 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_winrt_p.h"
-
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/private/qfunctions_winrt_p.h>
-#include <QtCore/qloggingcategory.h>
-#include <QtCore/qmutex.h>
-#ifdef Q_OS_WINRT
-#include <QtCore/private/qeventdispatcher_winrt_p.h>
-#endif
-
-#include <functional>
-#include <windows.system.h>
-#include <windows.devices.geolocation.h>
-#include <windows.foundation.h>
-#include <windows.foundation.collections.h>
-
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-using namespace ABI::Windows::Devices::Geolocation;
-using namespace ABI::Windows::Foundation;
-using namespace ABI::Windows::Foundation::Collections;
-
-typedef ITypedEventHandler<Geolocator *, PositionChangedEventArgs *> GeoLocatorPositionHandler;
-typedef ITypedEventHandler<Geolocator *, StatusChangedEventArgs *> GeoLocatorStatusHandler;
-typedef IAsyncOperationCompletedHandler<Geoposition*> PositionHandler;
-typedef IAsyncOperationCompletedHandler<GeolocationAccessStatus> AccessHandler;
-
-Q_DECLARE_LOGGING_CATEGORY(lcPositioningWinRT)
-
-Q_DECLARE_METATYPE(QGeoPositionInfoSource::Error)
-
-QT_BEGIN_NAMESPACE
-
-#ifndef Q_OS_WINRT
-namespace QEventDispatcherWinRT {
-HRESULT runOnXamlThread(const std::function<HRESULT ()> &delegate, bool waitForRun = true)
-{
- Q_UNUSED(waitForRun);
- return delegate();
-}
-}
-
-static inline HRESULT await(const ComPtr<IAsyncOperation<GeolocationAccessStatus>> &asyncOp,
- GeolocationAccessStatus *result)
-{
- ComPtr<IAsyncInfo> asyncInfo;
- HRESULT hr = asyncOp.As(&asyncInfo);
- if (FAILED(hr))
- return hr;
-
- AsyncStatus status;
- while (SUCCEEDED(hr = asyncInfo->get_Status(&status)) && status == AsyncStatus::Started)
- QThread::yieldCurrentThread();
-
- if (FAILED(hr) || status != AsyncStatus::Completed) {
- HRESULT ec;
- hr = asyncInfo->get_ErrorCode(&ec);
- if (FAILED(hr))
- return hr;
- hr = asyncInfo->Close();
- if (FAILED(hr))
- return hr;
- return ec;
- }
-
- if (FAILED(hr))
- return hr;
-
- return asyncOp->GetResults(result);
-}
-#endif // !Q_OS_WINRT
-
-enum class InitializationState {
- Uninitialized,
- Initializing,
- Initialized
-};
-
-class QGeoPositionInfoSourceWinRTPrivate {
-public:
- ComPtr<IGeolocator> locator;
- mutable ComPtr<IGeolocatorStatics> statics;
- QTimer periodicTimer;
- QTimer singleUpdateTimer;
- QGeoPositionInfo lastPosition;
- QGeoPositionInfoSource::Error positionError = QGeoPositionInfoSource::NoError;
- EventRegistrationToken statusToken;
- EventRegistrationToken positionToken;
- QMutex mutex;
- bool updatesOngoing = false;
- int minimumUpdateInterval = -1;
- int updateInterval = -1;
- InitializationState initState = InitializationState::Uninitialized;
-
- PositionStatus positionStatus = PositionStatus_NotInitialized;
-};
-
-QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent)
- : QGeoPositionInfoSource(parent)
- , d_ptr(new QGeoPositionInfoSourceWinRTPrivate)
-{
- qRegisterMetaType<QGeoPositionInfoSource::Error>();
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
- Q_D(QGeoPositionInfoSourceWinRT);
- d->positionError = QGeoPositionInfoSource::NoError;
- d->updatesOngoing = false;
- d->positionToken.value = 0;
- d->statusToken.value = 0;
-}
-
-QGeoPositionInfoSourceWinRT::~QGeoPositionInfoSourceWinRT()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- CoUninitialize();
-}
-
-int QGeoPositionInfoSourceWinRT::init()
-{
- Q_D(QGeoPositionInfoSourceWinRT);
- Q_ASSERT(d->initState != InitializationState::Initializing);
- if (d->initState == InitializationState::Initialized)
- return 0;
-
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- d->initState = InitializationState::Initializing;
- if (!requestAccess()) {
- d->initState = InitializationState::Uninitialized;
- setError(QGeoPositionInfoSource::AccessError);
- qWarning ("Location access failed.");
- return -1;
- }
- HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, d]() {
- HRESULT hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Devices_Geolocation_Geolocator).Get(),
- &d->locator);
- RETURN_HR_IF_FAILED("Could not initialize native location services.");
-
- if (d->minimumUpdateInterval == -1) {
- UINT32 interval;
- hr = d->locator->get_ReportInterval(&interval);
- RETURN_HR_IF_FAILED("Could not retrieve report interval.");
- d->minimumUpdateInterval = static_cast<int>(interval);
- }
- if (d->updateInterval == -1)
- d->updateInterval = d->minimumUpdateInterval;
- setUpdateInterval(d->updateInterval);
-
- return hr;
- });
- if (FAILED(hr)) {
- d->initState = InitializationState::Uninitialized;
- setError(QGeoPositionInfoSource::UnknownSourceError);
- return -1;
- }
-
- d->periodicTimer.setSingleShot(true);
- connect(&d->periodicTimer, &QTimer::timeout, this, &QGeoPositionInfoSourceWinRT::virtualPositionUpdate);
-
- d->singleUpdateTimer.setSingleShot(true);
- connect(&d->singleUpdateTimer, &QTimer::timeout, this, &QGeoPositionInfoSourceWinRT::singleUpdateTimeOut);
-
- QGeoPositionInfoSource::PositioningMethods preferredMethods = preferredPositioningMethods();
- if (preferredMethods == QGeoPositionInfoSource::NoPositioningMethods)
- preferredMethods = QGeoPositionInfoSource::AllPositioningMethods;
- setPreferredPositioningMethods(preferredMethods);
-
- connect(this, &QGeoPositionInfoSourceWinRT::nativePositionUpdate, this, &QGeoPositionInfoSourceWinRT::updateSynchronized);
- d->initState = InitializationState::Initialized;
- return 0;
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceWinRT::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(const QGeoPositionInfoSourceWinRT);
- Q_UNUSED(fromSatellitePositioningMethodsOnly);
- return d->lastPosition;
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinRT::supportedPositioningMethods() const
-{
- return requestAccess() ? QGeoPositionInfoSource::AllPositioningMethods
- : QGeoPositionInfoSource::NoPositioningMethods;
-}
-
-void QGeoPositionInfoSourceWinRT::setPreferredPositioningMethods(QGeoPositionInfoSource::PositioningMethods methods)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << methods;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods();
- QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
- if (previousPreferredPositioningMethods == preferredPositioningMethods()
- || d->initState == InitializationState::Uninitialized) {
- return;
- }
-
- const bool needsRestart = d->positionToken.value != 0 || d->statusToken.value != 0;
-
- if (needsRestart)
- stopHandler();
-
- PositionAccuracy acc = methods & PositioningMethod::SatellitePositioningMethods ?
- PositionAccuracy::PositionAccuracy_High :
- PositionAccuracy::PositionAccuracy_Default;
- HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, acc]() {
- return d->locator->put_DesiredAccuracy(acc);
- });
- RETURN_VOID_IF_FAILED("Could not set positioning accuracy.");
-
- if (needsRestart)
- startHandler();
-}
-
-void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << msec;
- Q_D(QGeoPositionInfoSourceWinRT);
- if (d->initState == InitializationState::Uninitialized) {
- d->updateInterval = msec;
- return;
- }
-
- // minimumUpdateInterval is initialized to the lowest possible update interval in init().
- // Passing 0 will cause an error on Windows 10.
- // See https://docs.microsoft.com/en-us/uwp/api/windows.devices.geolocation.geolocator.reportinterval
- if (msec != 0 && msec < minimumUpdateInterval())
- msec = minimumUpdateInterval();
-
- const bool needsRestart = d->positionToken.value != 0 || d->statusToken.value != 0;
-
- if (needsRestart)
- stopHandler();
-
- HRESULT hr = d->locator->put_ReportInterval(static_cast<UINT32>(msec));
- if (FAILED(hr)) {
- setError(QGeoPositionInfoSource::UnknownSourceError);
- qErrnoWarning(hr, "Failed to set update interval");
- return;
- }
-
- d->updateInterval = msec;
- d->periodicTimer.setInterval(d->updateInterval);
-
- QGeoPositionInfoSource::setUpdateInterval(d->updateInterval);
-
- if (needsRestart)
- startHandler();
-}
-
-int QGeoPositionInfoSourceWinRT::minimumUpdateInterval() const
-{
- Q_D(const QGeoPositionInfoSourceWinRT);
- return d->minimumUpdateInterval == -1 ? 1000 : d->minimumUpdateInterval;
-}
-
-void QGeoPositionInfoSourceWinRT::startUpdates()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- setError(QGeoPositionInfoSource::NoError);
- if (init() < 0)
- return;
-
- if (d->updatesOngoing)
- return;
-
- if (!startHandler())
- return;
- d->updatesOngoing = true;
- d->periodicTimer.start();
-}
-
-void QGeoPositionInfoSourceWinRT::stopUpdates()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (init() < 0)
- return;
-
- stopHandler();
- d->updatesOngoing = false;
- d->periodicTimer.stop();
-}
-
-bool QGeoPositionInfoSourceWinRT::startHandler()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- // Check if already attached
- if (d->positionToken.value != 0)
- return true;
-
- if (preferredPositioningMethods() == QGeoPositionInfoSource::NoPositioningMethods) {
- setError(QGeoPositionInfoSource::UnknownSourceError);
- return false;
- }
-
- if (!requestAccess()) {
- setError(QGeoPositionInfoSource::AccessError);
- return false;
- }
-
- HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, d]() {
- HRESULT hr;
-
- // We need to call this at least once on Windows 10 Mobile.
- // Unfortunately this operation does not have a completion handler
- // registered. That could have helped in the single update case
- ComPtr<IAsyncOperation<Geoposition*>> op;
- hr = d->locator->GetGeopositionAsync(&op);
- RETURN_HR_IF_FAILED("Could not start position operation");
-
- hr = d->locator->add_PositionChanged(Callback<GeoLocatorPositionHandler>(this,
- &QGeoPositionInfoSourceWinRT::onPositionChanged).Get(),
- &d->positionToken);
- RETURN_HR_IF_FAILED("Could not add position handler");
-
- hr = d->locator->add_StatusChanged(Callback<GeoLocatorStatusHandler>(this,
- &QGeoPositionInfoSourceWinRT::onStatusChanged).Get(),
- &d->statusToken);
- RETURN_HR_IF_FAILED("Could not add status handler");
- return hr;
- });
- if (FAILED(hr)) {
- setError(QGeoPositionInfoSource::UnknownSourceError);
- return false;
- }
-
- return true;
-}
-
-void QGeoPositionInfoSourceWinRT::stopHandler()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (!d->positionToken.value)
- return;
- QEventDispatcherWinRT::runOnXamlThread([d]() {
- d->locator->remove_PositionChanged(d->positionToken);
- d->locator->remove_StatusChanged(d->statusToken);
- return S_OK;
- });
- d->positionToken.value = 0;
- d->statusToken.value = 0;
-}
-
-void QGeoPositionInfoSourceWinRT::requestUpdate(int timeout)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << timeout;
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (init() < 0)
- return;
-
- setError(QGeoPositionInfoSource::NoError);
- if (timeout != 0 && timeout < minimumUpdateInterval()) {
- d->positionError = QGeoPositionInfoSource::UpdateTimeoutError;
- emit QGeoPositionInfoSource::errorOccurred(d->positionError);
- return;
- }
-
- if (timeout == 0)
- timeout = 2*60*1000; // Maximum time for cold start (see Android)
-
- startHandler();
- d->singleUpdateTimer.start(timeout);
-}
-
-void QGeoPositionInfoSourceWinRT::virtualPositionUpdate()
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_D(QGeoPositionInfoSourceWinRT);
- QMutexLocker locker(&d->mutex);
-
- // The operating system did not provide information in time
- // Hence we send a virtual position update to keep same behavior
- // between backends.
- // This only applies to the periodic timer, not for single requests
- // We can only do this if we received a valid position before
- if (d->lastPosition.isValid()) {
- QGeoPositionInfo sent = d->lastPosition;
- sent.setTimestamp(sent.timestamp().addMSecs(updateInterval()));
- d->lastPosition = sent;
- emit positionUpdated(sent);
- }
- d->periodicTimer.start();
-}
-
-void QGeoPositionInfoSourceWinRT::singleUpdateTimeOut()
-{
- Q_D(QGeoPositionInfoSourceWinRT);
- QMutexLocker locker(&d->mutex);
-
- if (d->singleUpdateTimer.isActive()) {
- d->positionError = QGeoPositionInfoSource::UpdateTimeoutError;
- emit QGeoPositionInfoSource::errorOccurred(d->positionError);
- if (!d->updatesOngoing)
- stopHandler();
- }
-}
-
-void QGeoPositionInfoSourceWinRT::updateSynchronized(QGeoPositionInfo currentInfo)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << currentInfo;
- Q_D(QGeoPositionInfoSourceWinRT);
- QMutexLocker locker(&d->mutex);
-
- d->periodicTimer.stop();
- d->lastPosition = currentInfo;
-
- if (d->updatesOngoing)
- d->periodicTimer.start();
-
- if (d->singleUpdateTimer.isActive()) {
- d->singleUpdateTimer.stop();
- if (!d->updatesOngoing)
- stopHandler();
- }
-
- emit positionUpdated(currentInfo);
-}
-
-QGeoPositionInfoSource::Error QGeoPositionInfoSourceWinRT::error() const
-{
- Q_D(const QGeoPositionInfoSourceWinRT);
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << d->positionError;
-
- // If the last encountered error was "Access denied", it is possible that the location service
- // has been enabled by now so that we are clear again.
- if ((d->positionError == QGeoPositionInfoSource::AccessError
- || d->positionError == QGeoPositionInfoSource::UnknownSourceError) && requestAccess())
- return QGeoPositionInfoSource::NoError;
-
- return d->positionError;
-}
-
-void QGeoPositionInfoSourceWinRT::setError(QGeoPositionInfoSource::Error positionError)
-{
- Q_D(QGeoPositionInfoSourceWinRT);
-
- if (positionError == d->positionError)
- return;
-
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << positionError;
- d->positionError = positionError;
- if (positionError != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(positionError);
-}
-
-void QGeoPositionInfoSourceWinRT::reactOnError(QGeoPositionInfoSource::Error positionError)
-{
- setError(positionError);
- stopUpdates();
-}
-
-HRESULT QGeoPositionInfoSourceWinRT::onPositionChanged(IGeolocator *locator, IPositionChangedEventArgs *args)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(locator);
-
- HRESULT hr;
- ComPtr<IGeoposition> position;
- hr = args->get_Position(&position);
- RETURN_HR_IF_FAILED("Could not access position object.");
-
- QGeoPositionInfo currentInfo;
-
- ComPtr<IGeocoordinate> coord;
- hr = position->get_Coordinate(&coord);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not access coordinate");
-
- ComPtr<IGeocoordinateWithPoint> pointCoordinate;
- hr = coord.As(&pointCoordinate);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not cast coordinate.");
-
- ComPtr<IGeopoint> point;
- hr = pointCoordinate->get_Point(&point);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not obtain coordinate's point.");
-
- BasicGeoposition pos;
- hr = point->get_Position(&pos);
- if (FAILED(hr))
- qErrnoWarning(hr, "Could not obtain point's position.");
-
- DOUBLE lat = pos.Latitude;
- DOUBLE lon = pos.Longitude;
- DOUBLE alt = pos.Altitude;
-
- bool altitudeAvailable = false;
- ComPtr<IGeoshape> shape;
- hr = point.As(&shape);
- if (SUCCEEDED(hr) && shape) {
- AltitudeReferenceSystem altitudeSystem;
- hr = shape->get_AltitudeReferenceSystem(&altitudeSystem);
- if (SUCCEEDED(hr) && altitudeSystem == AltitudeReferenceSystem_Geoid)
- altitudeAvailable = true;
- }
- if (altitudeAvailable)
- currentInfo.setCoordinate(QGeoCoordinate(lat, lon, alt));
- else
- currentInfo.setCoordinate(QGeoCoordinate(lat, lon));
-
- DOUBLE accuracy;
- hr = coord->get_Accuracy(&accuracy);
- if (SUCCEEDED(hr))
- currentInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy, accuracy);
-
- IReference<double> *altAccuracy;
- hr = coord->get_AltitudeAccuracy(&altAccuracy);
- if (SUCCEEDED(hr) && altAccuracy) {
- double value;
- hr = altAccuracy->get_Value(&value);
- currentInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy, value);
- }
-
- IReference<double> *speed;
- hr = coord->get_Speed(&speed);
- if (SUCCEEDED(hr) && speed) {
- double value;
- hr = speed->get_Value(&value);
- currentInfo.setAttribute(QGeoPositionInfo::GroundSpeed, value);
- }
-
- IReference<double> *heading;
- hr = coord->get_Heading(&heading);
- if (SUCCEEDED(hr) && heading) {
- double value;
- hr = heading->get_Value(&value);
- double mod = 0;
- value = modf(value, &mod);
- value += static_cast<int>(mod) % 360;
- if (value >=0 && value <= 359) // get_Value might return nan/-nan
- currentInfo.setAttribute(QGeoPositionInfo::Direction, value);
- }
-
- DateTime dateTime;
- hr = coord->get_Timestamp(&dateTime);
-
- if (dateTime.UniversalTime > 0) {
- ULARGE_INTEGER uLarge;
- uLarge.QuadPart = dateTime.UniversalTime;
- FILETIME fileTime;
- fileTime.dwHighDateTime = uLarge.HighPart;
- fileTime.dwLowDateTime = uLarge.LowPart;
- SYSTEMTIME systemTime;
- if (FileTimeToSystemTime(&fileTime, &systemTime)) {
- currentInfo.setTimestamp(QDateTime(QDate(systemTime.wYear, systemTime.wMonth,
- systemTime.wDay),
- QTime(systemTime.wHour, systemTime.wMinute,
- systemTime.wSecond, systemTime.wMilliseconds),
- Qt::UTC));
- }
- }
-
- emit nativePositionUpdate(currentInfo);
-
- return S_OK;
-}
-
-static inline bool isDisabledStatus(PositionStatus status)
-{
- return status == PositionStatus_NoData || status == PositionStatus_Disabled
- || status == PositionStatus_NotAvailable;
-}
-
-HRESULT QGeoPositionInfoSourceWinRT::onStatusChanged(IGeolocator *, IStatusChangedEventArgs *args)
-{
- Q_D(QGeoPositionInfoSourceWinRT);
-
- const PositionStatus oldStatus = d->positionStatus;
- HRESULT hr = args->get_Status(&d->positionStatus);
- RETURN_HR_IF_FAILED("Could not obtain position status");
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << d->positionStatus;
- QGeoPositionInfoSource::Error error = QGeoPositionInfoSource::NoError;
- switch (d->positionStatus) {
- case PositionStatus::PositionStatus_NotAvailable:
- error = QGeoPositionInfoSource::UnknownSourceError;
- break;
- case PositionStatus::PositionStatus_Disabled:
- error = QGeoPositionInfoSource::AccessError;
- break;
- case PositionStatus::PositionStatus_NoData:
- error = QGeoPositionInfoSource::ClosedError;
- break;
- }
- if (error != QGeoPositionInfoSource::NoError) {
- QMetaObject::invokeMethod(this, "reactOnError", Qt::QueuedConnection,
- Q_ARG(QGeoPositionInfoSource::Error,
- QGeoPositionInfoSource::UnknownSourceError));
- }
-
- if (isDisabledStatus(oldStatus) != isDisabledStatus(d->positionStatus))
- emit supportedPositioningMethodsChanged();
-
- return S_OK;
-}
-
-bool QGeoPositionInfoSourceWinRT::requestAccess() const
-{
- Q_D(const QGeoPositionInfoSourceWinRT);
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- GeolocationAccessStatus accessStatus;
-
- ComPtr<IAsyncOperation<GeolocationAccessStatus>> op;
- HRESULT hr;
- hr = QEventDispatcherWinRT::runOnXamlThread([&op, d]() {
- HRESULT hr;
- if (!d->statics) {
- hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Devices_Geolocation_Geolocator).Get(),
- IID_PPV_ARGS(&d->statics));
- RETURN_HR_IF_FAILED("Could not access Geolocation Statics.");
- }
-
- hr = d->statics->RequestAccessAsync(&op);
- return hr;
- });
- if (FAILED(hr)) {
- qCDebug(lcPositioningWinRT) << __FUNCTION__ << "Requesting access from Xaml thread failed";
- return false;
- }
-
- // We cannot wait inside the XamlThread as that would deadlock
-#ifdef Q_OS_WINRT
- QWinRTFunctions::await(op, &accessStatus);
-#else
- await(op, &accessStatus);
-#endif
- return accessStatus == GeolocationAccessStatus_Allowed;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h b/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h
deleted file mode 100644
index dbfde0e9..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosource_winrt_p.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEWINRT_H
-#define QGEOPOSITIONINFOSOURCEWINRT_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeopositioninfosource.h"
-#include "qgeopositioninfo.h"
-
-#include <QtCore/qtimer.h>
-
-#include <EventToken.h>
-#include <wrl.h>
-
-namespace ABI {
- namespace Windows {
- namespace Devices {
- namespace Geolocation{
- struct IGeolocator;
- struct IPositionChangedEventArgs;
- struct IStatusChangedEventArgs;
- }
- }
- }
-}
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceWinRTPrivate;
-
-class QGeoPositionInfoSourceWinRT : public QGeoPositionInfoSource
-{
- Q_OBJECT
-public:
- QGeoPositionInfoSourceWinRT(QObject *parent = nullptr);
- ~QGeoPositionInfoSourceWinRT() override;
- int init();
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
-
- void setPreferredPositioningMethods(PositioningMethods methods) override;
-
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
- HRESULT onPositionChanged(ABI::Windows::Devices::Geolocation::IGeolocator *locator,
- ABI::Windows::Devices::Geolocation::IPositionChangedEventArgs *args);
- HRESULT onStatusChanged(ABI::Windows::Devices::Geolocation::IGeolocator *locator,
- ABI::Windows::Devices::Geolocation::IStatusChangedEventArgs *args);
-
- bool requestAccess() const;
-Q_SIGNALS:
- void nativePositionUpdate(const QGeoPositionInfo);
-public slots:
- void startUpdates() override;
- void stopUpdates() override;
-
- void requestUpdate(int timeout = 0) override;
-
-private slots:
- void stopHandler();
- void virtualPositionUpdate();
- void singleUpdateTimeOut();
- void updateSynchronized(const QGeoPositionInfo info);
- void reactOnError(QGeoPositionInfoSource::Error positionError);
-private:
- bool startHandler();
-
- Q_DISABLE_COPY(QGeoPositionInfoSourceWinRT)
- void setError(QGeoPositionInfoSource::Error positionError);
-
- QScopedPointer<QGeoPositionInfoSourceWinRTPrivate> d_ptr;
- Q_DECLARE_PRIVATE(QGeoPositionInfoSourceWinRT)
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEWINRT_H
diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp
deleted file mode 100644
index 4e75c242..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosourcefactory_winrt.h"
-#include "qgeopositioninfosource_winrt_p.h"
-
-#include <QtCore/qloggingcategory.h>
-
-Q_LOGGING_CATEGORY(lcPositioningWinRT, "qt.positioning.winrt")
-
-QT_BEGIN_NAMESPACE
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryWinRT::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(parameters)
- QGeoPositionInfoSourceWinRT *src = new QGeoPositionInfoSourceWinRT(parent);
- return src;
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryWinRT::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryWinRT::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- qCDebug(lcPositioningWinRT) << __FUNCTION__;
- Q_UNUSED(parent)
- Q_UNUSED(parameters)
- return nullptr;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h b/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h
deleted file mode 100644
index 3e1ca3c5..00000000
--- a/src/plugins/position/winrt/qgeopositioninfosourcefactory_winrt.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H
-
-#include <QtCore/qobject.h>
-#include <QtPositioning/qgeopositioninfosourcefactory.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourceFactoryWinRT : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEFACTORY_WINRT_H
diff --git a/src/plugins/position/winrt/winrt.pro b/src/plugins/position/winrt/winrt.pro
deleted file mode 100644
index 446cb345..00000000
--- a/src/plugins/position/winrt/winrt.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qtposition_winrt
-
-QT = core core-private positioning
-
-SOURCES += qgeopositioninfosource_winrt.cpp \
- qgeopositioninfosourcefactory_winrt.cpp
-HEADERS += qgeopositioninfosource_winrt_p.h \
- qgeopositioninfosourcefactory_winrt.h
-
-OTHER_FILES += \
- plugin.json
-
-PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryWinRT
-msvc:!winrt: LIBS += runtimeobject.lib
-load(qt_plugin)
diff --git a/src/positioning/CMakeLists.txt b/src/positioning/CMakeLists.txt
deleted file mode 100644
index 5e976735..00000000
--- a/src/positioning/CMakeLists.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-# Generated from positioning.pro.
-
-#####################################################################
-## Positioning Module:
-#####################################################################
-
-qt_internal_add_module(Positioning
- PLUGIN_TYPES position
- SOURCES
- qclipperutils.cpp qclipperutils_p.h
- qdoublematrix4x4.cpp qdoublematrix4x4_p.h
- qdoublevector2d.cpp qdoublevector2d_p.h
- qdoublevector3d.cpp qdoublevector3d_p.h
- qgeoaddress.cpp qgeoaddress.h qgeoaddress_p.h
- qgeoareamonitorinfo.cpp qgeoareamonitorinfo.h
- qgeoareamonitorsource.cpp qgeoareamonitorsource.h
- qgeocircle.cpp qgeocircle.h qgeocircle_p.h
- qgeocoordinate.cpp qgeocoordinate.h qgeocoordinate_p.h
- qgeocoordinateobject.cpp qgeocoordinateobject_p.h
- qgeolocation.cpp qgeolocation.h qgeolocation_p.h
- qgeopath.cpp qgeopath.h qgeopath_p.h
- qgeopolygon.cpp qgeopolygon.h qgeopolygon_p.h
- qgeopositioninfo.cpp qgeopositioninfo.h qgeopositioninfo_p.h
- qgeopositioninfosource.cpp qgeopositioninfosource.h qgeopositioninfosource_p.h
- qgeopositioninfosourcefactory.cpp qgeopositioninfosourcefactory.h
- qgeorectangle.cpp qgeorectangle.h qgeorectangle_p.h
- qgeosatelliteinfo.cpp qgeosatelliteinfo.h qgeosatelliteinfo_p.h
- qgeosatelliteinfosource.cpp qgeosatelliteinfosource.h qgeosatelliteinfosource_p.h
- qgeoshape.cpp qgeoshape.h qgeoshape_p.h
- qlocationutils.cpp qlocationutils_p.h
- qnmeapositioninfosource.cpp qnmeapositioninfosource.h qnmeapositioninfosource_p.h
- qnmeasatelliteinfosource.cpp qnmeasatelliteinfosource.h qnmeasatelliteinfosource_p.h
- qpositioningglobal.h qpositioningglobal_p.h
- qwebmercator.cpp qwebmercator_p.h
- INCLUDE_DIRECTORIES
- ../3rdparty/clip2tri
- ../3rdparty/clipper
- LIBRARIES
- Qt::CorePrivate
- Qt::Bundled_Clip2Tri
- PUBLIC_LIBRARIES
- Qt::Core
- PRIVATE_MODULE_INTERFACE
- Qt::CorePrivate
-)
-
-if(ANDROID)
- set_property(TARGET Positioning APPEND PROPERTY QT_ANDROID_BUNDLED_JAR_DEPENDENCIES
- jar/Qt${QtLocation_VERSION_MAJOR}AndroidPositioning.jar:org.qtproject.qt.android.positioning.QtPositioning # special case
- )
- set_property(TARGET Positioning APPEND PROPERTY QT_ANDROID_LIB_DEPENDENCIES
- plugins/position/libplugins_position_qtposition_android.so
- )
- set_property(TARGET Positioning APPEND PROPERTY QT_ANDROID_PERMISSIONS
- android.permission.ACCESS_FINE_LOCATION
- )
-endif()
-
-#### Keys ignored in scope 1:.:.:positioning.pro:<TRUE>:
-# ANDROID_FEATURES = "android.hardware.location.gps"
-# MODULE_WINRT_CAPABILITIES_DEVICE = "location"
-# OTHER_FILES = "configure.json" "doc/src/*.qdoc" "doc/src/plugins/*.qdoc"
-qt_internal_add_docs(Positioning
- doc/qtpositioning.qdocconf
-)
-
diff --git a/src/positioning/configure.cmake b/src/positioning/configure.cmake
deleted file mode 100644
index 979c1432..00000000
--- a/src/positioning/configure.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# begin special case
-
-#### Libraries
-
-qt_find_package(Gypsy PROVIDED_TARGETS Gypsy::Gypsy)
-qt_find_package(Gconf PROVIDED_TARGETS Gconf::Gconf)
-
-#### Tests
-
-if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../config.tests/winrt/CMakeLists.txt")
- qt_config_compile_test("winrt_geolocation"
- LABEL "WinRT geolocation"
- PROJECT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../config.tests/winrt")
-endif()
-
-#### Features
-
-qt_feature("gypsy" PUBLIC
- LABEL "Gypsy - A GPS Multiplexing Daemon"
- CONDITION Gypsy_FOUND AND Gconf_FOUND
-)
-
-qt_feature("winrt_geolocation" PRIVATE
- LABEL "WinRT geolocation API"
- CONDITION WIN32 AND TEST_winrt_geolocation
-)
-
-# end special case
diff --git a/src/positioning/configure.json b/src/positioning/configure.json
deleted file mode 100644
index 49e32be4..00000000
--- a/src/positioning/configure.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "module": "positioning",
- "testDir": "../../config.tests",
-
- "libraries": {
- "gypsy": {
- "label": "Gypsy",
- "test": "gypsy",
- "sources": [
- { "type": "pkgConfig", "args": "gypsy gconf-2.0" }
- ]
- }
- },
-
- "tests": {
- "winrt_geolocation": {
- "label": "WinRT Geolocation API",
- "type": "compile",
- "test": "winrt"
- }
- },
-
- "features": {
- "gypsy": {
- "label": "Gypsy GPS Daemon",
- "condition": "libs.gypsy",
- "output": [ "privateFeature" ]
- },
- "winrt_geolocation": {
- "label": "WinRT Geolocation API",
- "condition": "tests.winrt_geolocation",
- "output": [ "privateFeature" ]
- }
- },
-
- "report": [
- ],
-
- "summary": [
- {
- "section": "Qt Positioning",
- "entries": [
- "gypsy",
- "winrt_geolocation"
- ]
- }
- ]
-}
diff --git a/src/positioning/doc/images/permissions.png b/src/positioning/doc/images/permissions.png
deleted file mode 100644
index bd8c4850..00000000
--- a/src/positioning/doc/images/permissions.png
+++ /dev/null
Binary files differ
diff --git a/src/positioning/doc/qtpositioning.qdocconf b/src/positioning/doc/qtpositioning.qdocconf
deleted file mode 100644
index 67e5837a..00000000
--- a/src/positioning/doc/qtpositioning.qdocconf
+++ /dev/null
@@ -1,56 +0,0 @@
-include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
-include($QT_INSTALL_DOCS/config/exampleurl-qtlocation.qdocconf)
-
-project = QtPositioning
-description = Qt Positioning Reference Documentation
-version = $QT_VERSION
-
-
-
-qhp.projects = QtPositioning
-
-qhp.QtPositioning.file = qtpositioning.qhp
-qhp.QtPositioning.namespace = org.qt-project.qtpositioning.$QT_VERSION_TAG
-qhp.QtPositioning.virtualFolder = qtpositioning
-qhp.QtPositioning.indexTitle = Qt Positioning
-qhp.QtPositioning.indexRoot =
-
-qhp.QtPositioning.filterAttributes = qtpositioning $QT_VERSION qtrefdoc
-qhp.QtPositioning.customFilters.Qt.name = QtPositioning $QT_VERSION
-qhp.QtPositioning.customFilters.Qt.filterAttributes = qtpositioning $QT_VERSION
-qhp.QtPositioning.subprojects = classes qml examples
-qhp.QtPositioning.subprojects.classes.title = C++ Classes
-qhp.QtPositioning.subprojects.classes.indexTitle = Qt Positioning C++ Classes
-qhp.QtPositioning.subprojects.classes.selectors = class fake:headerfile
-qhp.QtPositioning.subprojects.classes.sortPages = true
-qhp.QtPositioning.subprojects.qml.title = QML Types
-qhp.QtPositioning.subprojects.qml.indexTitle = Qt Positioning QML Types
-qhp.QtPositioning.subprojects.qml.selectors = qmlclass
-qhp.QtPositioning.subprojects.qml.sortPages = true
-qhp.QtPositioning.subprojects.examples.title = Qt Positioning Examples
-qhp.QtPositioning.subprojects.examples.indexTitle = Qt Positioning Examples
-qhp.QtPositioning.subprojects.examples.selectors = fake:example
-
-tagfile = ../../../doc/qtpositioning/qtpositioning.tags
-
-depends += qtcore qtdoc qtquick qtqml qtnetwork qtqmlxmllistmodel qmake qtcmake
-
-headerdirs += .. \
- ../../positioningquick
-
-sourcedirs += .. \
- ../../positioningquick
-
-examplesinstallpath = positioning
-
-exampledirs += ../../../examples/positioning \
- snippets/
-
-
-imagedirs += images
-
-navigation.landingpage = "Qt Positioning"
-navigation.cppclassespage = "Qt Positioning C++ Classes"
-navigation.qmltypespage = "Qt Positioning QML Types"
-
-manifestmeta.thumbnail.names += "QtPositioning/Log File*"
diff --git a/src/positioning/doc/snippets/cpp/cpp.pro b/src/positioning/doc/snippets/cpp/cpp.pro
deleted file mode 100644
index 47401e90..00000000
--- a/src/positioning/doc/snippets/cpp/cpp.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-TARGET = positioning_cppsnippet
-QT = core positioning
-
-SOURCES += \
- main.cpp \
- cppqml.cpp
-
diff --git a/src/positioning/doc/snippets/cpp/cppqml.cpp b/src/positioning/doc/snippets/cpp/cppqml.cpp
deleted file mode 100644
index c3d0139e..00000000
--- a/src/positioning/doc/snippets/cpp/cppqml.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QObject>
-#include <QtCore/QDebug>
-#include <QtCore/QVariant>
-#include <QtPositioning/QGeoAddress>
-#include <QtPositioning/QGeoLocation>
-#include <QtPositioning/QGeoCircle>
-#include <QtPositioning/QGeoAreaMonitorSource>
-
-void cppQmlInterface(QObject *qmlObject)
-{
- //! [Address get]
- QGeoAddress geoAddress = qmlObject->property("address").value<QGeoAddress>();
- //! [Address get]
-
- //! [Address set]
- qmlObject->setProperty("address", QVariant::fromValue(geoAddress));
- //! [Address set]
-
- //! [Location get]
- QGeoLocation geoLocation = qmlObject->property("location").value<QGeoLocation>();
- //! [Location get]
-
- //! [Location set]
- qmlObject->setProperty("location", QVariant::fromValue(geoLocation));
- //! [Location set]
-}
-
-class MyClass : public QObject
-{
- Q_OBJECT
-//! [BigBen]
-public:
- MyClass() : QObject()
- {
- QGeoAreaMonitorSource *monitor = QGeoAreaMonitorSource::createDefaultSource(this);
- if (monitor) {
- connect(monitor, SIGNAL(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)),
- this, SLOT(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)));
- connect(monitor, SIGNAL(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo)),
- this, SLOT(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo)));
-
- QGeoAreaMonitorInfo bigBen("Big Ben");
- QGeoCoordinate position(51.50104, -0.124632);
- bigBen.setArea(QGeoCircle(position, 100));
-
- monitor->startMonitoring(bigBen);
-
- } else {
- qDebug() << "Could not create default area monitor";
- }
- }
-
-public Q_SLOTS:
- void areaEntered(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update)
- {
- Q_UNUSED(mon);
-
- qDebug() << "Now within 100 meters, current position is" << update.coordinate();
- }
-
- void areaExited(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update)
- {
- Q_UNUSED(mon);
-
- qDebug() << "No longer within 100 meters, current position is" << update.coordinate();
- }
-//! [BigBen]
-};
diff --git a/src/positioning/doc/snippets/cpp/main.cpp b/src/positioning/doc/snippets/cpp/main.cpp
deleted file mode 100644
index 285bf6af..00000000
--- a/src/positioning/doc/snippets/cpp/main.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-int main(int /*argc*/, char ** /*argv*/)
-{
- return 0;
-}
-
diff --git a/src/positioning/doc/snippets/doc_src_qtpositioning.qml b/src/positioning/doc/snippets/doc_src_qtpositioning.qml
deleted file mode 100644
index f6d15572..00000000
--- a/src/positioning/doc/snippets/doc_src_qtpositioning.qml
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//! [import]
-import QtPositioning
-//! [import]
-
-Item {
-}
-
diff --git a/src/positioning/doc/snippets/snippets.pro b/src/positioning/doc/snippets/snippets.pro
deleted file mode 100644
index 451d1c36..00000000
--- a/src/positioning/doc/snippets/snippets.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += cpp
diff --git a/src/positioning/doc/src/cpp-position.qdoc b/src/positioning/doc/src/cpp-position.qdoc
deleted file mode 100644
index a380f105..00000000
--- a/src/positioning/doc/src/cpp-position.qdoc
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page location-positioning-cpp.html
-
-\title Positioning (C++)
-
-\brief The Location Positioning API enables location positioning by means of
-GPS or an NMEA data source.
-
-\section1 Positioning
-
-The Positioning component of the Qt Location API is about the geographical
-position, size, and address of some place. Positioning contains a
-\l QGeoCoordinate class, containing latitude, longitude and altitude in meters.
-\l QGeoLocation contains a \l QGeoCoordinate plus address and size information
-(a bounding box) so that positions can be more than mathematical points.
-Movement into or out of the defined bounding box areas can be monitored. The API
-also allows the developer to control the source of the positional information
-as well.
-
-Location data involves a precisely specified position on the Earth's
-surface \unicode {0x2014} as provided by a latitude-longitude coordinate
-\unicode {0x2014} along with associated data, such as:
-
- \list
- \li The date and time at which the position was reported
- \li The velocity of the device that reported the position
- \li The altitude of the reported position (height above sea level)
- \li The bearing of the device in degrees, relative to true north
- \endlist
-
-This data can be extracted through a variety of methods. One of the most
-well known methods of positioning is GPS (Global Positioning System), a
-publicly available system that uses radiowave signals received from
-Earth-orbiting satellites to calculate the precise position and time of
-the receiver. Another popular method is 'Cell Identifier Positioning', which uses
-the cell identifier of the cell site that is currently serving the receiving
-device to calculate its approximate location. These and other positioning
-methods can all be used with the Location API; the only requirement for a
-location data source within the API is that it provides a
-latitude-longitude coordinate with a date/time value, with the option of
-providing the other attributes listed above.
-
-
-Location data sources are created by subclassing \l QGeoPositionInfoSource and
-providing \l QGeoPositionInfo objects through the
-\l {QGeoPositionInfoSource::positionUpdated()} signal. Clients that require
-location data can connect to the
-\l{QGeoPositionInfoSource::positionUpdated()}{positionUpdated()} signal and
-call \l{QGeoPositionInfoSource::startUpdates()}{startUpdates()} or
-\l{QGeoPositionInfoSource::requestUpdate()}{requestUpdate()} to trigger the
-distribution of location data. The location data distribution can be stopped by
-calling the \l {QGeoPositionInfoSource::stopUpdates()}{stopUpdates()} function.
-
-A default position source may be available on some platforms. Call
-\l {QGeoPositionInfoSource::createDefaultSource()} to create an instance of the
-default position source. The method returns \c nullptr if no default source is
-available for the platform.
-
-If a problem occurs with access to the information source then an
-\l {QGeoPositionInfoSource::errorOccurred()}{errorOccurred()} signal is emitted.
-
-The \l QGeoAreaMonitorSource class enables client applications to be notified
-when the receiving device has moved into or out of a particular area, as
-specified by a coordinate and radius. If the platform provides built-in support
-for area monitoring, the \l {QGeoAreaMonitorSource::createDefaultSource()}
-method returns an instance of the default area monitor.
-
-Satellite information can also be distributed through the
-\l QGeoSatelliteInfoSource class. Call
-\l {QGeoSatelliteInfoSource::createDefaultSource()} to create an instance of the
-default satellite data source for the platform if one is available.
-Alternatively, clients can subclass it to provide a custom satellite data
-source.
-
-
-
-\section2 Requesting Location Data from Data Sources
-
-To receive data from a source, connect to its
-\l{QGeoPositionInfoSource::positionUpdated()}{positionUpdated()} signal,
-then call either \l{QGeoPositionInfoSource::startUpdates()}{startUpdates()}
-or \l{QGeoPositionInfoSource::requestUpdate()}{requestUpdate()} to begin.
-
-Here is an example of a client that receives data from the default location
-data source, as returned by \l {QGeoPositionInfoSource::createDefaultSource()}:
-
-\code
-class MyClass : public QObject
-{
- Q_OBJECT
-public:
- MyClass(QObject *parent = 0)
- : QObject(parent)
- {
- QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
- if (source) {
- connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
- this, SLOT(positionUpdated(QGeoPositionInfo)));
- source->startUpdates();
- }
- }
-
-private slots:
- void positionUpdated(const QGeoPositionInfo &info)
- {
- qDebug() << "Position updated:" << info;
- }
-};
-
-\endcode
-
-\section2 Controlling Aspects of Data Sources
-
-The \l {QGeoPositionInfoSource::setUpdateInterval()} method can be used to
-control the rate at which position updates are received. For example, if
-the client application only requires updates once every 30 seconds, it can
-call \c setUpdateInterval(30000). If no update interval is set, or
-\l {QGeoPositionInfoSource::}{setUpdateInterval()} is called with a value of 0,
-the source uses a default interval or some other internal logic to determine
-when updates should be provided.
-
-\l {QGeoPositionInfoSource::setPreferredPositioningMethods()} enables client
-applications to request that a certain type of positioning method be used.
-For example, if the application prefers to use only satellite positioning,
-which offers fairly precise outdoor positioning but can be a heavy user of
-power resources, it can call this method with the
-\l {QGeoPositionInfoSource::SatellitePositioningMethods} value. However, this
-method should only be used in specialized client applications; in most
-cases, the default positioning methods should not be changed, as a source
-may internally use a variety of positioning methods that can be useful to
-the application.
-
-\section2 NMEA Data
-
-\l {http://en.wikipedia.org/wiki/NMEA_0183}{NMEA} is a common text-based
-protocol for specifying navigational data. For convenience, the
-\l QNmeaPositionInfoSource is provided to enable client applications to read
-and distribute NMEA data in either real-time mode (for example, when
-streaming from a GPS device) or simulation mode (for example, when reading
-from a NMEA log file). In simulation mode, the source will emit updates
-according to the time stamp of each NMEA sentence to produce a "replay"
-of the recorded data.
-
-Generally, the capabilities provided by the default position source as
-returned by \l {QGeoPositionInfoSource::createDefaultSource()}, along with the
-\l QNmeaPositionInfoSource class, are sufficient for retrieving location
-data. However, in some cases developers may wish to write their own custom
-location data source.
-
-The \l {Log File Position Source (C++)} example demonstrates how to subclass
-\l QGeoPositionInfoSource to create a custom positioning source.
-
-
-\section1 Examples
-
-\section3 \b{Flickr Example}
-
-The \l{GeoFlickr QML}{Flickr Example} uses the current location to download thumbnail
-images from Flickr relevant to the current location.
-
-
-
-\section1 Positioning Classes
-
-\annotatedlist QtPositioning-positioning
-
-*/
diff --git a/src/positioning/doc/src/cpp-qml-positioning.qdoc b/src/positioning/doc/src/cpp-qml-positioning.qdoc
deleted file mode 100644
index f1044306..00000000
--- a/src/positioning/doc/src/cpp-qml-positioning.qdoc
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page positioning-cpp-qml.html
-\title Interfaces between C++ and QML Code in Qt Positioning
-
-\brief Describes the methods used to exchange position data between C++ and QML
-code.
-
-\section1 Overview
-
-Qt Positioning utilizes two methods to simplify exchange of position data
-between C++ and QML code.
-
-\target Cpp_value_integration_positioning
-\section1 Direct C++ Value Integration in QtPositioning
-
-Starting with Qt 5.5, it has become much easier to integrate non-QObject based
-data types into QML. This is achieved by adding \l Q_GADGET support to \l QtQml.
-The macro converts classes into a light-weight version of a \l QObject without
-the required \l QObject inheritance. At the same time, it retains the reflection
-capabilities of \l QMetaObject. As a result, they can be directly exposed to
-QML.
-
-A significant number of Position related data types were converted to
-\l {Q_GADGET}s. They retain their API and value type character but have become
-introspectable via \l QMetaObject.
-
-The \l QML_ANONYMOUS macro is used to expose these types to the QML environment.
-See the \l QQmlEngine documentation for more details and the full list of
-available macros.
-
-The classes, however, are not directly extended with this macro, because we do
-not want Qt Positioning to depend on \l QtQml. So a helper class is created for
-each of them, and the \l QML_FOREIGN macro is used:
-
-\code
-struct QGeoCoordinateForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoCoordinate)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-\endcode
-
-The above registration of Positioning types is automatically done once by the
-QtPositioning QML plugin.
-
-\section1 QVariant Based integration
-
-This section provides information on how to integrate QGeoAddress and
-QGeoLocation.
-
-\section2 Address - QGeoAddress
-
-The \l {QtPositioning::Address::address} {Address.address} property is used to
-provide an interface between C++ and QML code. First a pointer to an
-\l {QtPositioning::}{Address} object must be obtained from C++, then the
-\l {QObject::}{property()} and \l {QObject::}{setProperty()} functions must be
-used to get and set the \c address property.
-
-The following piece of code gets the \l QGeoAddress object from C++:
-
-\snippet cpp/cppqml.cpp Address get
-
-The following piece of code sets the address property of the QML object based
-on a \l QGeoAddress object from C++:
-
-\snippet cpp/cppqml.cpp Address set
-
-
-\section2 Location - QGeoLocation
-The \l {Location::location} {Location.location} property is used to provide an
-interface between C++ and QML code. First a pointer to a \l Location object
-must be obtained from C++, then the \l {QObject::}{property()} and
-\l {QObject::}{setProperty()} functions must be used to get and set the
-\c location property.
-
-The following piece of code gets the \l QGeoLocation object from C++:
-
-\snippet cpp/cppqml.cpp Location get
-
-The following piece of code sets the location property of the QML object based
-on a \l QGeoLocation object from C++:
-
-\snippet cpp/cppqml.cpp Location set
-
-*/
diff --git a/src/positioning/doc/src/external-resources.qdoc b/src/positioning/doc/src/external-resources.qdoc
deleted file mode 100644
index 948249d9..00000000
--- a/src/positioning/doc/src/external-resources.qdoc
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\externalpage https://developer.android.com/about/versions/oreo/background-location-limits
-\title Background Location Limits
-*/
-
-/*!
-\externalpage https://developer.android.com/guide/components/foreground-services
-\title Foreground Service
-*/
-
-/*!
-\externalpage https://developer.android.com/reference/android/Manifest.permission#ACCESS_BACKGROUND_LOCATION
-\title ACCESS_BACKGROUND_LOCATION
-*/
-
-/*!
-\externalpage https://developer.android.com/training/location/background
-\title Access Location in the Background
-*/
-
-/*!
-\externalpage https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home
-\title GeoClue service
-*/
-
-/*!
-\externalpage https://www.freedesktop.org/software/geoclue/docs/gdbus-org.freedesktop.GeoClue2.Client.html#gdbus-property-org-freedesktop-GeoClue2-Client.DesktopId
-\title GeoClue DesktopId property
-*/
-
-/*!
-\externalpage https://gypsy.freedesktop.org/wiki/
-\title Gypsy daemon
-*/
diff --git a/src/positioning/doc/src/plugins/geoclue2.qdoc b/src/positioning/doc/src/plugins/geoclue2.qdoc
deleted file mode 100644
index 13ba2d2d..00000000
--- a/src/positioning/doc/src/plugins/geoclue2.qdoc
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page position-plugin-geoclue2.html
-\title Qt Positioning GeoClue v2 plugin
-\ingroup QtPositioning-plugins
-
-\brief Uses the GeoClue v2 library to provide positioning updates
-
-\section1 Overview
-
-This plugin is an interface to the \l {GeoClue service}{GeoClue v2} library.
-It requires this library to be installed on the system to function.
-
-The plugin uses D-Bus to establish communication with the GeoClue v2 D-Bus
-service and to provide positioning information.
-
-The plugin can be used to receive only the positioning information.
-It \e {does not} provide satellite information.
-
-The plugin can be loaded by using the provider name \b geoclue2.
-
-\section1 Parameters
-
-The following table lists parameters that \e can be passed to the geoclue2
-plugin.
-
-\table
-\header
- \li Parameter
- \li Description
-\row
- \li desktopId
- \li The \l {GeoClue DesktopId property}{Desktop Id} property used by the
- D-Bus service. If the parameter is not specified, the application name
- provided by \l QCoreApplication::applicationName() is used.
-\endtable
-
-\section1 Usage example
-
-The following examples show how to create a \b geoclue2 PositionSource from
-C++ and QML.
-
-\section2 QML
-
-\code
-PositionSource {
- name: "geoclue2"
- PluginParameter { name: "desktopId"; value: "SomeIdentifierString" }
-}
-\endcode
-
-\section2 C++
-
-\code
-QVariantMap params;
-params["desktopId"] = "SomeIdentifierString";
-QGeoPositionInfoSource *positionSource = QGeoPositionInfoSource::createSource("geoclue2", params, this);
-\endcode
-
-*/
diff --git a/src/positioning/doc/src/plugins/gypsy.qdoc b/src/positioning/doc/src/plugins/gypsy.qdoc
deleted file mode 100644
index 9b59314a..00000000
--- a/src/positioning/doc/src/plugins/gypsy.qdoc
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page position-plugin-gypsy.html
-\title Qt Positioning Gypsy plugin
-\ingroup QtPositioning-plugins
-
-\brief Uses the Gypsy daemon to provide satellite information
-
-\section1 Overview
-
-The plugin is an interface to the \l {Gypsy daemon}. It requires the daemon
-to be installed and running on the system to function.
-
-The plugin uses D-Bus and GLib to connect to GPS device and provide satellite
-information.
-
-Currently the plugin \e {does not} provide positioning information.
-
-The plugin can be loaded using provider name \b gypsy.
-
-\section1 Parameters
-
-The following table lists parameters that \e can be passed to the gypsy
-plugin.
-
-\table
-\header
- \li Parameter
- \li Description
-\row
- \li deviceName
- \li The name of the device (or path to the device file) that will be used
- to provide satellite information. The typical values can be
- \c {/dev/ttyUSB0} or \c {/dev/ttyACM0}.
-\row
- \li gconfKey
- \li The key that will be used to extract device name from the GConf
- configuration system.
-\endtable
-
-The plugin supports two ways of specifying the device name:
-\list
- \li Specify the device name directly with the \e deviceName plugin
- parameter.
- \li Specify the configuration key using \e gconfKey plugin parameter and
- extract the device name from the GConf configuration system. This
- approach is useful when the device name is already specified for some
- other GConf-based application.
-\endlist
-
-By default, when none of the parameters is specified, the plugin will try to
-extract the device name from the GConf configuration system using the following
-hardcoded key:
-
-\badcode
-/apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice
-\endcode
-
-\section2 Using GConf to set parameters
-
-To specify a value for a key in the GConf configuration system, use
-\e {gconftool-2} as follows:
-
-\badcode
-gconftool-2 -t string -s /apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice /dev/ttyUSB0
-\endcode
-
-\section1 Usage example
-
-The following examples show how to create a \b gypsy satellite info source
-from C++.
-
-Specifying device name directly:
-
-\code
-QVariantMap parameters;
-parameters["deviceName"] = "/dev/ttyACM0";
-QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createSource("gypsy", parameters, this);
-\endcode
-
-Using GConf key:
-
-\code
-QVariantMap parameters;
-parameters["gconfKey"] = "/apps/myapp/mykey";
-QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createSource("gypsy", parameters, this);
-\endcode
-
-*/
diff --git a/src/positioning/doc/src/plugins/nmea.qdoc b/src/positioning/doc/src/plugins/nmea.qdoc
deleted file mode 100644
index 00a50f0e..00000000
--- a/src/positioning/doc/src/plugins/nmea.qdoc
+++ /dev/null
@@ -1,201 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page position-plugin-nmea.html
-\title Qt Positioning NMEA plugin
-\ingroup QtPositioning-plugins
-
-\brief Reads the NMEA stream to provide position updates.
-
-\section1 Overview
-
-Included with Qt Positioning is a position plugin which parses NMEA sentences
-into position updates. This plugin can use serial port, socket or file as a
-source.
-
-This plugin can be loaded by using the provider name \b nmea.
-
-\section1 Parameters
-
-The following table lists parameters that \e can be passed to the nmea plugin.
-
-\table
-\header
- \li Parameter
- \li Description
-\row
- \li nmea.source
- \li The source that will be used to get NMEA data.
-\row
- \li nmea.satellite_info_simulation_interval
- \li The interval for reading satellite information data from the file in
- simulation mode.
-\endtable
-
-Different sources require different ways of providing the data. The following
-table lists different ways of providing \c {nmea.source} parameter for socket,
-serial port and file inputs.
-
-\table
-\header
- \li Scheme
- \li Example
- \li Description
-\row
- \li socket://hostname:port
- \li \c {socket://localhost:12345}
- \li Use \b {socket:} keyword to specify that you want to get the nmea data
- from the socket. A TCP socket will be created, which will try to connect
- to host \c hostname using port \c port. Upon successful connection
- a text NMEA stream is expected to be received from the server.
-\row
- \li {1, 3} serial:portname
- \li \c {serial:/dev/ttyUSB0}
- \li {1, 3} Use \b {serial:} keyword to specify that you want to get the nmea
- data from the serial port. The plugin will try to establish a connection
- to port \c portname with baudrate = 4800 Bd. Upon successful connection
- a text NMEA stream is expected to be received from the serial port.
- If you use \b {serial:} without any port name, the plugin will try to
- find one of the well known serial devices using vendor identifier. Note
- however that this is not a recommended way of using the serial port
- connection, as the list of well-known devices is small and most probably
- does not include your hardware.
-\row
- \li \c {serial:COM1}
-\row
- \li \c {serial:}
-\row
- \li filepath
- \li \c {/home/user/nmealog.txt}
- \li {1, 2} Use \b {file:///} or just full file path to specify a path to a
- local file.
-\row
- \li file:///filepath
- \li \c {file:///home/user/nmealog.txt}
-\row
- \li qrc:///filepath
- \li \c {qrc:///nmealog.txt}
- \li Use \b {qrc:///} prefix to specify a path to a file in the application
- resources.
-\endtable
-
-\note If \c {nmea.source} parameter is not specified, the plugin will try to
-locate one of the well-known serial devices (as if \c {nmea.source = serial:}
-was specified).
-
-\section1 Position source usage example
-
-The following examples show how to create a \b nmea PositionSource
-using different data sources.
-
-\section2 QML
-
-\code
-// text file
-PositionSource {
- name: "nmea"
- PluginParameter { name: "nmea.source"; value: "qrc:///nmealog.txt" }
-}
-
-// socket
-PositionSource {
- name: "nmea"
- PluginParameter { name: "nmea.source"; value: "socket://localhost:22222" }
-}
-
-// serial port
-PositionSource {
- name: "nmea"
- PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" }
-}
-\endcode
-
-\section2 C++
-
-\code
-// text file
-QVariantMap params;
-params["nmea.source"] = "qrc:///nmealog.txt";
-QGeoPositionInfoSource *textPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
-
-// socket
-params["nmea.source"] = "socket://localhost:22222";
-QGeoPositionInfoSource *socketPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
-
-// serial port
-params["nmea.source"] = "serial:/dev/ttyACM0";
-QGeoPositionInfoSource *serialPositionSource = QGeoPositionInfoSource::createSource("nmea", params, this);
-\endcode
-
-\note Once a PositionSource is created, it can't be reconfigured to use other
-type of source data.
-
-\section1 Satellite information source usage example
-
-Apart from the position information, \b nmea plugin is also capable of providing
-satellite information. For now it does not have any QML object, but can be
-created directly from C++ code.
-
-\code
-// serial port
-QVariantMap parameters;
-parameters["nmea.source"] = "serial:/dev/ttyUSB0";
-QGeoSatelliteInfoSource *serialSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
-
-// socket
-parameters["nmea.source"] = "socket://localhost:22222";
-QGeoSatelliteInfoSource *socketSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
-\endcode
-
-If you want to use \l QGeoSatelliteInfoSource to read file with NMEA stream, you
-can also use additional parameter \c "nmea.satellite_info_simulation_interval".
-This parameter is used to specify the playback rate (in milliseconds) for the
-satellite info messages. The minimum allowed frequency is specified by
-\l {QGeoSatelliteInfoSource::}{minimumUpdateInterval()}. If you specify a
-smaller value, it will be ignored. If no value is specified, the default value
-is \c {qMax(100, minimumUpdateInterval())}.
-At runtime \l {QNmeaSatelliteInfoSource::setBackendProperty()} method can be
-used to update this parameter.
-
-\code
-// file
-QVariantMap parameters;
-parameters["nmea.source"] = "qrc:///nmealog.txt";
-parameters["nmea.satellite_info_simulation_interval"] = 1000;
-QGeoSatelliteInfoSource *fileSource = QGeoSatelliteInfoSource::createSource("nmea", parameters, this);
-\endcode
-
-This parameter is not applicable to position source because NMEA protocol
-already has timestamps in position messages. These timestamps are used to
-simulate the correct message rate while using \l QGeoPositionInfoSource with
-file as a data source.
-
-\note Once a \l QGeoSatelliteInfoSource is created, it can't be reconfigured to
-use other type of source data.
-
-*/
diff --git a/src/positioning/doc/src/qml-position.qdoc b/src/positioning/doc/src/qml-position.qdoc
deleted file mode 100644
index 27e55583..00000000
--- a/src/positioning/doc/src/qml-position.qdoc
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page location-positioning-qml.html
-
-\title Positioning (QML)
-
-\brief The Location Positioning API enables location positioning by means of
-GPS or an NMEA data source.
-
-\section1 Location Positioning
-
-Location data involves a precisely specified position on the Earth's
-surface \unicode {0x2014} as provided by a latitude-longitude coordinate
-\unicode {0x2014} along with associated data, such as:
-
- \list
- \li The date and time at which the position was reported
- \li The velocity of the device that reported the position
- \li The altitude of the reported position (height above sea level)
- \li The bearing of the device in degrees, relative to true north
- \endlist
-
-For more information see
-\l {http://en.wikipedia.org/wiki/Geographic_coordinate}{Geographic Coordinate}.
-
-This data can be extracted through a variety of methods. One of the most
-well known methods of positioning is GPS (Global Positioning System), a
-publicly available system that uses radiowave signals received from
-Earth-orbiting satellites to calculate the precise position and time of
-the receiver. Another popular method is 'Cell Identifier Positioning', which uses
-the cell identifier of the cell site that is currently serving the receiving
-device to calculate its approximate location. These and other positioning
-methods can all be used with the Location API; the only requirement for a
-location data source within the API is that it provides a
-latitude-longitude coordinate with a date/time value, with the option of
-providing the other attributes listed above.
-
-\section2 Coordinates
-
-The \l {coordinate} is a basic unit of geographical information. The
-\l {coordinate} type has attributes to hold the \c {latitude},
-\c longitude and \c altitude.
-
-\section2 Positions
-
-The three dimensional position of an object such as a mobile device can be specified by giving
-the latitude, longitude and altitude. That is the values held in the
-\l {coordinate} type. Additionally for computation of future
-positions we would like to know if the object is moving, what \l [QML] {Position::}{speed} it is
-doing and what is the \l {Position::timestamp}{timestamp} of the last position data. Position
-therefore includes values for the \l {Position::coordinate}{coordinate},
-\l {Position::speed}{speed} and a \l {Position::timestamp}{timestamp}. \l Position also takes
-responsibility for validation of sensible values for these properties. These are exposed as
-the \l {Position::latitudeValid}{latitudeValid}, \l {Position::longitudeValid}{longitudeValid},
-\l {Position::altitudeValid}{altitudeValid}, \l {Position::speedValid}{speedValid},
-\l {Position::horizontalAccuracyValid}{horizontalAccuracyValid}, and
-\l {Position::verticalAccuracyValid}{verticalAccuracyValid} properties.
-
-
-\section2 PositionSource Type
-
-We have a \l Position type, a \l {coordinate} type but where does the data come
-from? Also it is a good idea to be able to indicate alternative sources.
-Perhaps instead of directly picking up GPS satellites it might be desirable to
-do some testing using a datafile.
-
-The \l PositionSource type provides the developer with control, within the
-limits allowed by the platform, of the source of the geographical data.
-\l PositionSource supports multiple plugins, including an
-\l {Qt Positioning NMEA plugin}{NMEA} plugin.
-
-\l {http://en.wikipedia.org/wiki/NMEA}{NMEA} is a common text-based
-protocol for specifying navigational data. The \l PositionSource
-\l {Qt Positioning NMEA plugin}{NMEA} plugin supports multiple data sources,
-including raw file or TCP socket. The source will emit updates according to the
-time stamp of each NMEA sentence to produce a "replay" of the recorded data.
-
-See the \l {Qt Positioning NMEA plugin}{plugin description} for usage examples.
-
-
-\section2 GeoFlickr Example
-
-The \l{GeoFlickr (QML)}{GeoFlickr Example} uses the \l PositionSource to
-download thumbnail images from Flickr relevant to the current location.
-
-*/
diff --git a/src/positioning/doc/src/qt6-changes.qdoc b/src/positioning/doc/src/qt6-changes.qdoc
deleted file mode 100644
index ab53823b..00000000
--- a/src/positioning/doc/src/qt6-changes.qdoc
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \page qtpositioning-changes-qt6.html
- \title Changes to Qt Positioning
- \ingroup changes-qt-5-to-6
- \brief Migrate Qt Positioning to Qt 6.
-
- Qt 6 is a result of the conscious effort to make the framework more
- efficient and easy to use.
-
- We try to maintain binary and source compatibility for all the public
- APIs in each release. But some changes were inevitable in an effort to
- make Qt a better framework.
-
- In this topic we summarize those changes in Qt Positioning, and provide
- guidance to handle them.
-
- \section1 Breaking public API changes
-
- This section contains information about API changes that break source
- compatibility.
-
- \section2 Rename QGeoPolygon::path()
-
- The \c QGeoPolygon::path() and \c QGeoPolygon::setPath() methods are renamed
- to \l QGeoPolygon::perimeter() and \l QGeoPolygon::setPerimeter()
- respectively. On the QML side the \l QGeoPolygon::perimeter property can be
- used without any changes.
-
- \section2 Use \l QGeoShape for \l QGeoLocation bounding area
-
- The \l QGeoLocation class and its \l [QML] Location QML counterpart are
- updated to use \l QGeoShape instead of \l QGeoRectangle for a bounding area.
-
- \section3 C++
-
- The \c QGeoLocation::boundingBox() and \c QGeoLocation::setBoundingBox()
- are replaced by \l QGeoLocation::boundingShape() and
- \l QGeoLocation::setBoundingShape() respectively. A \l QGeoShape object
- is now used as an underlying data storage.
-
- \section3 QML
-
- The \c QGeoLocation::boundingBox property is replaced by
- \l QGeoLocation::boundingShape. This property is available since
- QtPositioning 6.2, so make sure to update the import version in the QML
- files.
-
- \code
- import QtPositioning 6.2
- \endcode
-
- \section2 Remove QGeoShape::extendShape()
-
- The \c QGeoShape::extendShape() method was deprecated in Qt 5.9 and finally
- removed in Qt 6. Use \l QGeoRectangle::extendRectangle() and
- \l QGeoCircle::extendCircle() if you need this functionality for these
- classes.
-
- \section2 Rename signal error to errorOccurred
-
- In Qt 5 multiple Qt Positioning classes had the \c error() signal, which was
- clashing with the \c error() method. In Qt 6 we renamed these signals to
- \c errorOccurred(). Specifically:
-
- \list
-
- \li \c QGeoAreaMonitorSource::error() is renamed to
- \l QGeoAreaMonitorSource::errorOccurred().
-
- \li \c QGeoPositionInfoSource::error() is renamed to
- \l QGeoPositionInfoSource::errorOccurred().
-
- \li \c QGeoSatelliteInfoSource::error() is renamed to
- \l QGeoSatelliteInfoSource::errorOccurred().
-
- \endlist
-
- \section2 Remove update timeout signals
-
- In Qt 5 \c {QGeoPositionInfoSource::updateTimeout()} and
- \c {QGeoSatelliteInfoSource::requestTimeout()} signals were used to notify
- about the cases when the current position or satellite information could
- not be retrieved within specified timeout. These signals were removed in
- Qt 6. The \c {errorOccurred()} signals with the new error types are
- used instead. Specifically:
-
- \list
-
- \li \l QGeoPositionInfoSource uses an \l {QGeoPositionInfoSource::}
- {errorOccurred()} signal with a new
- \l QGeoPositionInfoSource::UpdateTimeoutError error code.
-
- \li \l QGeoSatelliteInfoSource uses an \l {QGeoSatelliteInfoSource::}
- {errorOccurred()} signal with a new
- \l QGeoSatelliteInfoSource::UpdateTimeoutError error code.
-
- \endlist
-
- Same changes apply to \l [QML] PositionSource QML object. The
- \c {PositionSource::updateTimeout()} signal is removed.
- \l [QML] {PositionSource::sourceError} property with a
- \c {PositionSource.UpdateTimeoutError} is used instead.
-
- \section2 Redesign NMEA support
-
- In Qt 5 we had a \b serialnmea positioning plugin and a \c nmeaSource
- property in \l [QML] {PositionSource} object.
-
- The plugin provided access to NMEA streams via serial port, while the QML
- object was responsible for reading NMEA stream from TCP socket or local
- file.
-
- In Qt 6 we joined all these features in the plugin, which is now renamed to
- \b nmea. It is now capable of working with all three NMEA data sources:
- serial port, TCP socket and local file. See \l {Qt Positioning NMEA plugin}
- {plugin description} for more details.
-
- The \c nmeaSource property of \l [QML] {PositionSource} object is now
- removed.
-
- \section1 Other API changes
-
- This section contains API improvements that do not break source
- compatibility. However they might have an impact on the application logic,
- so it is still useful to know about them.
-
- \section2 Reset errors properly
-
- In Qt 5 the errors for \l QGeoAreaMonitorSource, \l QGeoPositionInfoSource
- and \l QGeoSatelliteInfoSource classes were never reset. This behavior is
- not logical, as calling \c {startUpdates()}, \c {startMonitoring()} or
- \c {requestUpdates()} on one of these classes or their subclasses
- effectively means starting a new work sessions, which means that we should
- not care about previous errors. Since Qt 6 we reset the error to \c NoError
- once one of the aforementioned methods is called.
-
- \section2 Add \l QGeoAddress::streetNumber
-
- The \l QGeoAddress class is extended with \l {QGeoAddress::}{streetNumber}
- property, which holds the information about street number, building name, or
- anything else that might be used to distinguish one address from another.
- Use \l {QGeoAddress::}{streetNumber()} and \l {QGeoAddress::}
- {setStreetNumber()} to access this property from C++ code.
-
- The \l QGeoAddress::street now holds only the street name.
-
- Same applies to \l [QML] {Address} QML counterpart. The \l [QML]
- {Address::street} property is now used only for street name, while the
- \l [QML] {Address::streetNumber} property is used for other important
- address details.
-
- \section2 Add timeout argument to \l [QML] {PositionSource::update()}
-
- The \c timeout is specified in milliseconds. If the \c timeout is zero
- (the default value), it defaults to a reasonable timeout period as
- appropriate for the source.
-
- \section2 Refactor \l QGeoSatelliteInfo, \l QGeoPositionInfo and \l QGeoAreaMonitorInfo classes
-
- These classes now use \l QExplicitlySharedDataPointer in their
- implementation. It means that the classes implement copy-on-write. It makes
- them cheap to copy, so that they can be passed by value.
-
- Another improvement is the addition of support for the efficient move
- operations.
-
- \section1 Changes in Qt Positioning plugin implementation
-
- This section provides information about the changes in plugin interface.
-
- In Qt 5 for we had two versions of plugin interface:
-
- \list
-
- \li \c QGeoPositionInfoSourceFactory which provided the basic features.
- \li \c QGeoPositionInfoSourceFactoryV2 which extended the base class with
- the possibility to provide custom parameters for the created objects.
-
- \endlist
-
- In Qt 6 we merged these two implementations into one, leaving only the
- \l QGeoPositionInfoSourceFactory class. Its methods now allow to pass
- custom parameters.
-
- \note The interface \e identifier is updated to reflect the major version
- update. Use \c {"org.qt-project.qt.position.sourcefactory/6.0"} in your
- Qt Positioning plugins.
-
- Here is an example of plugin class declaration:
-
- \code
- class MyPlugin : public QObject, public QGeoPositionInfoSourceFactory
- {
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
- public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
- };
- \endcode
-
-*/
diff --git a/src/positioning/doc/src/qtpositioning-android.qdoc b/src/positioning/doc/src/qtpositioning-android.qdoc
deleted file mode 100644
index 1857574e..00000000
--- a/src/positioning/doc/src/qtpositioning-android.qdoc
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qtpositioning-android.html
-\inmodule QtPositioning
-\title Qt Positioning on Android
-\brief Notes on using Qt Positioning on Android
-
-\section1 Using Qt Positioning from Android Services
-
-Using Qt Positioning from a service requires several extra actions to be taken,
-depending on the Android version. The sections below give more details on
-these actions.
-
-\note Since Android 8 (API level 26), the OS limits how frequently an
-application can retrieve the user's current location while running in the
-background. The application will normally be able to receive location updates
-only a few times each hour. For more information, see
-\l {Background Location Limits}.
-
-\section2 Using Foreground Service
-
-Since Android 8 (API level 26), the background service can be killed by the
-Android OS when the application goes to the background. This normally happens
-after around a minute of running in the background. To keep the location service
-running, the service should be implemented as a \l {Foreground Service}. Such
-service shows a status bar notification, which cannot be dismissed until the
-service is stopped or removed from the foreground. This allows the user to be
-always aware of the important background activities.
-
-\note Since Android 9 (API level 28), foreground services require a special
-\c FOREGROUND_SERVICE permission. See the Android documentation for more
-details on implementing foreground services.
-
-\section2 Use Background Location Permission
-
-Since Android 10 (API level 29), the service \e must request the
-\l {ACCESS_BACKGROUND_LOCATION} permission. It should be added to the
-\c AndroidManifest.xml file as follows:
-
-\badcode
-<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
-\endcode
-
-\note Once the permission is added to \c {AndroidManifest.xml}, it is still
-required to explicitly allow the constant access to the location services
-for the application. To do it, one should navigate to \uicontrol Settings ->
-\uicontrol {Apps}, select a proper application, open its permissions, and
-specify the \uicontrol {Allow all the time} permission for Location
-(see the screenshot below).
-
-\image permissions.png
-
-Check \l {Access Location in the Background} Android documentation for more
-details.
-
-*/
diff --git a/src/positioning/doc/src/qtpositioning-examples.qdoc b/src/positioning/doc/src/qtpositioning-examples.qdoc
deleted file mode 100644
index fbcc9a40..00000000
--- a/src/positioning/doc/src/qtpositioning-examples.qdoc
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \group qtpositioning-examples
- \title Qt Positioning Examples
- \brief Examples for the Qt Positioning module
- \ingroup all-examples
- \ingroup qtpositioning
-
- The list of \l {Qt Positioning} examples demonstrating how to use
- Positioning API from C++ and QML.
-
-*/
diff --git a/src/positioning/doc/src/qtpositioning-plugins.qdoc b/src/positioning/doc/src/qtpositioning-plugins.qdoc
deleted file mode 100644
index c75896f4..00000000
--- a/src/positioning/doc/src/qtpositioning-plugins.qdoc
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qtpositioning-plugins.html
-\title Qt Positioning Plugins
-\brief Default Plugins and Implementing Qt Positioning plugins
-
-Qt Positioning provides the majority of its functionality through plugins.
-This document outlines how to develop a new position plugin.
-
-\section1 Default plugins
-Some plugins already ship with Qt. These are:
-
-\table
- \row
- \li \b android
- \li Wraps Android positioning subsystem. Available only on Android.
- \row
- \li \b corelocation
- \li Wraps iOS and macOS positioning subsystems. Available only on Apple platforms supporting corelocation.
- \row
- \li \b geoclue2
- \li A \l {Qt Positioning GeoClue v2 plugin}{GeoClue v2} backend that
- provides an interface to the GeoClue v2 D-Bus service.
- \row
- \li \b gypsy
- \li A \l {Qt Positioning Gypsy plugin}{Gypsy} backend that provides
- an interface to the Gypsy daemon.
- \row
- \li \b winrt
- \li Wraps WinRT positioning subsystem. Available only on WinRT and Windows10.
- \row
- \li \b nmea
- \li An \l {Qt Positioning NMEA plugin}{NMEA} backend that parses NMEA
- streams from a GPS receiver to provide position updates. This plugin can
- use serial port, socket or file as a source.
- \row
- \li \b positionpoll
- \li A backend providing only area monitoring functionalities via polling on position updates.
-\endtable
-
-
-\section1 Plugin Description
-
-Each plugin is described by a json file. The json describes the plugins capabilities and
-version. Below is an example of a json file used by the postionpoll plugin:
-
-\quotefile ../../../plugins/position/positionpoll/plugin.json
-
-The entries have the following meaning:
-
-\table
- \header
- \li Key
- \li Description
- \row
- \li Keys
- \li The unique name/key of the plugin. Each position plugin must have a unique name.
- \row
- \li Provider
- \li The provider name of the services. Multiple plugins may have the same name.
- In such cases the Version string will be used to further distinguish the plugins.
- \row
- \li Position
- \li Set to \c true if the plugin implements a \l QGeoPositionInfoSource.
- \row
- \li Satellite
- \li Set to \c true if the plugin implements a \l QGeoSatelliteInfoSource.
- \row
- \li Monitor
- \li Set to \c true if the plugin implements a \l QGeoAreaMonitorSource.
- \row
- \li Priority
- \li The plugin priority. If multiple plugins have the same provider name, the plugin
- with the higest priority will be used.
-\endtable
-
-\section1 Implementing Plugins
-
-A plugin implementer needs to subclass \l QGeoPositionInfoSourceFactory and override one or more of
-its functions. If a plugin does not support a specific feature the function should return 0 or
-utilize the default implementation.
-
-\list
- \li \l QGeoPositionInfoSourceFactory::areaMonitor()
- \li \l QGeoPositionInfoSourceFactory::positionInfoSource()
- \li \l QGeoPositionInfoSourceFactory::satelliteInfoSource()
-\endlist
-*/
diff --git a/src/positioning/doc/src/qtpositioning-qml.qdoc b/src/positioning/doc/src/qtpositioning-qml.qdoc
deleted file mode 100644
index 0c84484b..00000000
--- a/src/positioning/doc/src/qtpositioning-qml.qdoc
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \qmlmodule QtPositioning \QtVer
- \title Qt Positioning QML Types
- \ingroup qmlmodules
- \brief Provides QML types for position information.
-
- \section1 Overview
-
- The identifying string for this module is \e QtPositioning. To use the QML
- from this module, include the following import statement in the QML file:
-
- \qml \QtVer
- import QtPositioning \1
- \endqml
-
- \section2 Positioning QML Concepts
-
- Position information can come from a variety of sources including
- satellites, Wi-Fi, text files and so on. The position is described by the
- latitude, longitude, and the altitude in meters. For more information, see
- the Wikipedia page on
- \l {http://en.wikipedia.org/wiki/Geographic_coordinate}
- {Geographic Coordinates}.
-
- The QML position is stored in a \l {coordinate} which contains the
- latitude, longitude and altitude of the device. The \l {QtPositioning::}
- {Location} contains this \l {coordinate} and adds an address, and also has
- a bounding box which defines the recommended viewing region when displaying
- the location.
-
- Now that the device has a position, with regular updates the API can
- determine the speed and heading of the device. It can also define a
- box-shaped or circular region that triggers notifications when the device
- either leaves or enters that region.
-
- More detailed information on retrieving the current position can be found
- under \l {Positioning (QML)}{Location Positioning via QML}.
-
- \section1 Basic Types
-
- \annotatedlist qml-QtPositioning5-basictypes
-
- \section1 Alphabetical Listing of All QML Types
-*/
diff --git a/src/positioning/doc/src/qtpositioning.qdoc b/src/positioning/doc/src/qtpositioning.qdoc
deleted file mode 100644
index e4e7f8a4..00000000
--- a/src/positioning/doc/src/qtpositioning.qdoc
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \module QtPositioning
- \title Qt Positioning C++ Classes
- \ingroup modules
- \qtcmakepackage Positioning
- \qtvariable positioning
-
- \brief The Positioning module provides positioning information via QML and C++ interfaces.
-
- To load the Qt Positioning module, add the following statement to your .qml files
-
- \snippet doc_src_qtpositioning.qml import
-
- For C++ projects include the header appropriate for the current use case,
- for example applications using routes may use
-
- \code
- #include <QGeoCoordinate>
- \endcode
-
- \include module-use.qdocinc using qt module
-
- \badcode
- find_package(Qt6 COMPONENTS Positioning REQUIRED)
- target_link_libraries(mytarget PRIVATE Qt6::Positioning)
- \endcode
-
- \include module-use.qdocinc building with qmake
-
- \badcode
- QT += positioning
- \endcode
-
- See more in the \l{Qt Positioning}{Qt Positioning Overview}.
-
-*/
-
-
-
-/*!
-\page qtpositioning-index.html
-\title Qt Positioning
-\brief The Qt Positioning API provides positioning information via QML and C++ interfaces.
-\ingroup technology-apis
-
-The Qt Positioning API provides positioning information via QML and C++ interfaces.
-
-Currently the API is supported on \l {Qt for Android}{Android},
-\l {Qt for iOS}{iOS}, \l {Qt for macOS}{\macos}, \l {Qt for Linux/X11}{Linux},
-and \l {Qt for Windows}{Windows} (with GPS receivers exposed as a serial port
-providing NMEA sentences or using \c {Windows.Devices.Geolocation}).
-
-\section1 Overview
-
-The Qt Positioning API gives developers the ability to determine a position by
-using a variety of possible sources, including satellite, or wifi, or text file,
-and so on. That information can then be used to for example determine a position
-on a map. In addition satellite information can be retrieved and area based monitoring
-can be performed.
-
-\include module-use.qdocinc using qt module
-
-\badcode
-find_package(Qt6 COMPONENTS Positioning REQUIRED)
-target_link_libraries(mytarget PRIVATE Qt6::Positioning)
-\endcode
-
-See also the \l {Build with CMake} overview.
-
-\include module-use.qdocinc building with qmake
-
-\badcode
-QT += positioning
-\endcode
-
-\section2 Getting Started
-
-To load the Qt Positioning module, add the following statement to your .qml files
-
-\snippet doc_src_qtpositioning.qml import
-
-For C++ projects include the header appropriate for the current use case,
-for example applications using routes may use
-
-\code
-#include <QGeoCoordinate>
-\endcode
-
-\section1 Module Evolution
-
-\l {Changes to Qt Positioning} lists important changes in the module API and
-functionality that were done for the Qt 6 series of Qt.
-
-\section1 Licenses
-
-Qt Positioning is available under commercial licenses from \l{The Qt Company}.
-In addition, it is available under free software licenses. Since Qt 5.4,
-these free software licenses are
-\l{GNU Lesser General Public License, version 3}, or
-the \l{GNU General Public License, version 2}.
-See \l{Qt Licensing} for further details.
-
-\section1 Articles and Guides
-
-\list
- \li \l {Positioning (C++)} {Positioning introduction for C++}
- \li \l {Positioning (QML)} {Positioning introduction for QML}
- \li \l {Qt Positioning Plugins}
- \li \l {Interfaces between C++ and QML Code in Qt Positioning}
- \li \l {Qt Positioning on Android}
-\endlist
-
-\section1 Reference
-
-\list
- \li \l {Qt Positioning C++ Classes}
- \li \l {Qt Positioning QML Types}
-\endlist
-
-\section1 Examples
-
-\list
- \li \l {Qt Positioning Examples}
-\endlist
-
-*/
diff --git a/src/positioning/positioning.pro b/src/positioning/positioning.pro
deleted file mode 100644
index 64a6cc2e..00000000
--- a/src/positioning/positioning.pro
+++ /dev/null
@@ -1,96 +0,0 @@
-TARGET = QtPositioning
-QT = core-private
-CONFIG += simd optimize_full
-
-#INCLUDEPATH += ../3rdparty/poly2tri
-INCLUDEPATH += ../3rdparty/clipper
-INCLUDEPATH += ../3rdparty/clip2tri
-
-QMAKE_DOCS = $$PWD/doc/qtpositioning.qdocconf
-OTHER_FILES += configure.json doc/src/*.qdoc doc/src/plugins/*.qdoc # show .qdoc files in Qt Creator
-
-ANDROID_BUNDLED_JAR_DEPENDENCIES = \
- jar/Qt$${QT_MAJOR_VERSION}AndroidPositioning.jar:org.qtproject.qt.android.positioning.QtPositioning
-ANDROID_PERMISSIONS += \
- android.permission.ACCESS_FINE_LOCATION
-ANDROID_FEATURES += \
- android.hardware.location.gps
-ANDROID_LIB_DEPENDENCIES = \
- plugins/position/libplugins_position_qtposition_android.so
-MODULE_WINRT_CAPABILITIES_DEVICE += \
- location
-MODULE_PLUGIN_TYPES = \
- position
-
-PUBLIC_HEADERS += \
- qgeoaddress.h \
- qgeoareamonitorinfo.h \
- qgeoareamonitorsource.h \
- qgeoshape.h \
- qgeorectangle.h \
- qgeocircle.h \
- qgeocoordinate.h \
- qgeolocation.h \
- qgeopositioninfo.h \
- qgeopositioninfosource.h \
- qgeosatelliteinfo.h \
- qgeosatelliteinfosource.h \
- qnmeapositioninfosource.h \
- qgeopositioninfosourcefactory.h \
- qpositioningglobal.h \
- qgeopolygon.h \
- qgeopath.h \
-
-PRIVATE_HEADERS += \
- qgeoaddress_p.h \
- qgeoshape_p.h \
- qgeorectangle_p.h \
- qgeocircle_p.h \
- qgeolocation_p.h \
- qlocationutils_p.h \
- qnmeapositioninfosource_p.h \
- qgeocoordinate_p.h \
- qgeopositioninfosource_p.h \
- qdoublevector2d_p.h \
- qdoublevector3d_p.h \
- qwebmercator_p.h \
- qpositioningglobal_p.h \
- qdoublematrix4x4_p.h \
- qgeopath_p.h \
- qgeopolygon_p.h \
- qgeocoordinateobject_p.h \
- qgeopositioninfo_p.h \
- qgeosatelliteinfo_p.h \
- qgeosatelliteinfosource_p.h \
- qclipperutils_p.h
-
-SOURCES += \
- qgeoaddress.cpp \
- qgeoareamonitorsource.cpp \
- qgeoareamonitorinfo.cpp \
- qgeoshape.cpp \
- qgeorectangle.cpp \
- qgeocircle.cpp \
- qgeocoordinate.cpp \
- qgeolocation.cpp \
- qgeopositioninfo.cpp \
- qgeopositioninfosource.cpp \
- qgeosatelliteinfo.cpp \
- qgeosatelliteinfosource.cpp \
- qlocationutils.cpp \
- qnmeapositioninfosource.cpp \
- qgeopositioninfosourcefactory.cpp \
- qdoublevector2d.cpp \
- qdoublevector3d.cpp \
- qgeopath.cpp \
- qgeopolygon.cpp \
- qwebmercator.cpp \
- qdoublematrix4x4.cpp \
- qclipperutils.cpp \
- qgeocoordinateobject.cpp
-
-HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
-
-load(qt_module)
-
-LIBS_PRIVATE += -L$$MODULE_BASE_OUTDIR/lib -lqt_clip2tri$$qtPlatformTargetSuffix()
diff --git a/src/positioning/qclipperutils.cpp b/src/positioning/qclipperutils.cpp
deleted file mode 100644
index 2f69d984..00000000
--- a/src/positioning/qclipperutils.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qclipperutils_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static const double kClipperScaleFactor = 281474976710656.0; // 48 bits of precision
-static const double kClipperScaleFactorInv = 1.0 / kClipperScaleFactor;
-
-double QClipperUtils::clipperScaleFactor()
-{
- return kClipperScaleFactor;
-}
-
-QDoubleVector2D QClipperUtils::toVector2D(const IntPoint &p)
-{
- return QDoubleVector2D(double(p.X) * kClipperScaleFactorInv, double(p.Y) * kClipperScaleFactorInv);
-}
-
-IntPoint QClipperUtils::toIntPoint(const QDoubleVector2D &p)
-{
- return IntPoint(cInt(p.x() * kClipperScaleFactor), cInt(p.y() * kClipperScaleFactor));
-}
-
-QList<QDoubleVector2D> QClipperUtils::pathToQList(const Path &path)
-{
- QList<QDoubleVector2D> res;
- res.reserve(int(path.size()));
- for (const IntPoint &ip: path)
- res.append(toVector2D(ip));
- return res;
-}
-
-QList<QList<QDoubleVector2D> > QClipperUtils::pathsToQList(const Paths &paths)
-{
- QList<QList<QDoubleVector2D> > res;
- res.reserve(int(paths.size()));
- for (const Path &p: paths) {
- res.append(pathToQList(p));
- }
- return res;
-}
-
-Path QClipperUtils::qListToPath(const QList<QDoubleVector2D> &list)
-{
- Path res;
- res.reserve(list.size());
- for (const QDoubleVector2D &p: list)
- res.push_back(toIntPoint(p));
- return res;
-}
-
-Paths QClipperUtils::qListToPaths(const QList<QList<QDoubleVector2D> > &lists)
-{
- Paths res;
- res.reserve(lists.size());
- for (const QList<QDoubleVector2D> &l: lists) {
- res.push_back(qListToPath(l));
- }
- return res;
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qclipperutils_p.h b/src/positioning/qclipperutils_p.h
deleted file mode 100644
index f05d9838..00000000
--- a/src/positioning/qclipperutils_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QCLIPPERUTILS_P_H
-#define QCLIPPERUTILS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-/*
- * This file is intended to be include only in source files of
- * QtPositioning/QtLocation. It is in QtPositioning to enable manipulation
- * of geo polygons
- */
-
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include <QtCore/QtGlobal>
-#include <QtCore/QList>
-#include <cmath>
-/* clip2tri triangulator includes */
-#include <clip2tri.h>
-#include <QtPositioning/private/qdoublevector2d_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONING_PRIVATE_EXPORT QClipperUtils
-{
-public:
- static double clipperScaleFactor();
-
- static QDoubleVector2D toVector2D(const IntPoint &p);
- static IntPoint toIntPoint(const QDoubleVector2D &p);
-
- static QList<QDoubleVector2D> pathToQList(const Path &path);
- static QList<QList<QDoubleVector2D> > pathsToQList(const Paths &paths);
-
- static Path qListToPath(const QList<QDoubleVector2D> &list);
- static Paths qListToPaths(const QList<QList<QDoubleVector2D> > &lists);
-};
-
-QT_END_NAMESPACE
-
-#endif // QCLIPPERUTILS_P_H
diff --git a/src/positioning/qdoublematrix4x4.cpp b/src/positioning/qdoublematrix4x4.cpp
deleted file mode 100644
index 0bc56460..00000000
--- a/src/positioning/qdoublematrix4x4.cpp
+++ /dev/null
@@ -1,1112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdoublematrix4x4_p.h"
-#include <QtCore/qmath.h>
-//#include <QtCore/qvariant.h>
-#include <QtCore/qdatastream.h>
-#include <cmath>
-
-QT_BEGIN_NAMESPACE
-
-static const double inv_dist_to_plane = 1.0 / 1024.0;
-
-QDoubleMatrix4x4::QDoubleMatrix4x4(const double *values)
-{
- for (int row = 0; row < 4; ++row)
- for (int col = 0; col < 4; ++col)
- m[col][row] = values[row * 4 + col];
- flagBits = General;
-}
-
-QDoubleMatrix4x4::QDoubleMatrix4x4(const double *values, int cols, int rows)
-{
- for (int col = 0; col < 4; ++col) {
- for (int row = 0; row < 4; ++row) {
- if (col < cols && row < rows)
- m[col][row] = values[col * rows + row];
- else if (col == row)
- m[col][row] = 1.0;
- else
- m[col][row] = 0.0;
- }
- }
- flagBits = General;
-}
-
-static inline double matrixDet2(const double m[4][4], int col0, int col1, int row0, int row1)
-{
- return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0];
-}
-
-static inline double matrixDet3
- (const double m[4][4], int col0, int col1, int col2,
- int row0, int row1, int row2)
-{
- return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2)
- - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2)
- + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2);
-}
-
-static inline double matrixDet4(const double m[4][4])
-{
- double det;
- det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
- det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
- det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
- det -= m[3][0] * matrixDet3(m, 0, 1, 2, 1, 2, 3);
- return det;
-}
-
-double QDoubleMatrix4x4::determinant() const
-{
- if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity)
- return 1.0;
-
- if (flagBits < Rotation2D)
- return m[0][0] * m[1][1] * m[2][2]; // Translation | Scale
- if (flagBits < Perspective)
- return matrixDet3(m, 0, 1, 2, 0, 1, 2);
- return matrixDet4(m);
-}
-
-QDoubleMatrix4x4 QDoubleMatrix4x4::inverted(bool *invertible) const
-{
- // Handle some of the easy cases first.
- if (flagBits == Identity) {
- if (invertible)
- *invertible = true;
- return QDoubleMatrix4x4();
- } else if (flagBits == Translation) {
- QDoubleMatrix4x4 inv;
- inv.m[3][0] = -m[3][0];
- inv.m[3][1] = -m[3][1];
- inv.m[3][2] = -m[3][2];
- inv.flagBits = Translation;
- if (invertible)
- *invertible = true;
- return inv;
- } else if (flagBits < Rotation2D) {
- // Translation | Scale
- if (m[0][0] == 0 || m[1][1] == 0 || m[2][2] == 0) {
- if (invertible)
- *invertible = false;
- return QDoubleMatrix4x4();
- }
- QDoubleMatrix4x4 inv;
- inv.m[0][0] = 1.0 / m[0][0];
- inv.m[1][1] = 1.0 / m[1][1];
- inv.m[2][2] = 1.0 / m[2][2];
- inv.m[3][0] = -m[3][0] * inv.m[0][0];
- inv.m[3][1] = -m[3][1] * inv.m[1][1];
- inv.m[3][2] = -m[3][2] * inv.m[2][2];
- inv.flagBits = flagBits;
-
- if (invertible)
- *invertible = true;
- return inv;
- } else if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity) {
- if (invertible)
- *invertible = true;
- return orthonormalInverse();
- } else if (flagBits < Perspective) {
- QDoubleMatrix4x4 inv(1); // The "1" says to not load the identity.
-
- double det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
- if (det == 0.0) {
- if (invertible)
- *invertible = false;
- return QDoubleMatrix4x4();
- }
- det = 1.0 / det;
-
- inv.m[0][0] = matrixDet2(m, 1, 2, 1, 2) * det;
- inv.m[0][1] = -matrixDet2(m, 0, 2, 1, 2) * det;
- inv.m[0][2] = matrixDet2(m, 0, 1, 1, 2) * det;
- inv.m[0][3] = 0;
- inv.m[1][0] = -matrixDet2(m, 1, 2, 0, 2) * det;
- inv.m[1][1] = matrixDet2(m, 0, 2, 0, 2) * det;
- inv.m[1][2] = -matrixDet2(m, 0, 1, 0, 2) * det;
- inv.m[1][3] = 0;
- inv.m[2][0] = matrixDet2(m, 1, 2, 0, 1) * det;
- inv.m[2][1] = -matrixDet2(m, 0, 2, 0, 1) * det;
- inv.m[2][2] = matrixDet2(m, 0, 1, 0, 1) * det;
- inv.m[2][3] = 0;
- inv.m[3][0] = -inv.m[0][0] * m[3][0] - inv.m[1][0] * m[3][1] - inv.m[2][0] * m[3][2];
- inv.m[3][1] = -inv.m[0][1] * m[3][0] - inv.m[1][1] * m[3][1] - inv.m[2][1] * m[3][2];
- inv.m[3][2] = -inv.m[0][2] * m[3][0] - inv.m[1][2] * m[3][1] - inv.m[2][2] * m[3][2];
- inv.m[3][3] = 1;
- inv.flagBits = flagBits;
-
- if (invertible)
- *invertible = true;
- return inv;
- }
-
- QDoubleMatrix4x4 inv(1); // The "1" says to not load the identity.
-
- double det = matrixDet4(m);
- if (det == 0.0) {
- if (invertible)
- *invertible = false;
- return QDoubleMatrix4x4();
- }
- det = 1.0 / det;
-
- inv.m[0][0] = matrixDet3(m, 1, 2, 3, 1, 2, 3) * det;
- inv.m[0][1] = -matrixDet3(m, 0, 2, 3, 1, 2, 3) * det;
- inv.m[0][2] = matrixDet3(m, 0, 1, 3, 1, 2, 3) * det;
- inv.m[0][3] = -matrixDet3(m, 0, 1, 2, 1, 2, 3) * det;
- inv.m[1][0] = -matrixDet3(m, 1, 2, 3, 0, 2, 3) * det;
- inv.m[1][1] = matrixDet3(m, 0, 2, 3, 0, 2, 3) * det;
- inv.m[1][2] = -matrixDet3(m, 0, 1, 3, 0, 2, 3) * det;
- inv.m[1][3] = matrixDet3(m, 0, 1, 2, 0, 2, 3) * det;
- inv.m[2][0] = matrixDet3(m, 1, 2, 3, 0, 1, 3) * det;
- inv.m[2][1] = -matrixDet3(m, 0, 2, 3, 0, 1, 3) * det;
- inv.m[2][2] = matrixDet3(m, 0, 1, 3, 0, 1, 3) * det;
- inv.m[2][3] = -matrixDet3(m, 0, 1, 2, 0, 1, 3) * det;
- inv.m[3][0] = -matrixDet3(m, 1, 2, 3, 0, 1, 2) * det;
- inv.m[3][1] = matrixDet3(m, 0, 2, 3, 0, 1, 2) * det;
- inv.m[3][2] = -matrixDet3(m, 0, 1, 3, 0, 1, 2) * det;
- inv.m[3][3] = matrixDet3(m, 0, 1, 2, 0, 1, 2) * det;
- inv.flagBits = flagBits;
-
- if (invertible)
- *invertible = true;
- return inv;
-}
-
-QDoubleMatrix4x4 QDoubleMatrix4x4::transposed() const
-{
- QDoubleMatrix4x4 result(1); // The "1" says to not load the identity.
- for (int row = 0; row < 4; ++row) {
- for (int col = 0; col < 4; ++col) {
- result.m[col][row] = m[row][col];
- }
- }
- // When a translation is transposed, it becomes a perspective transformation.
- result.flagBits = (flagBits & Translation ? General : flagBits);
- return result;
-}
-
-QDoubleMatrix4x4& QDoubleMatrix4x4::operator/=(double divisor)
-{
- m[0][0] /= divisor;
- m[0][1] /= divisor;
- m[0][2] /= divisor;
- m[0][3] /= divisor;
- m[1][0] /= divisor;
- m[1][1] /= divisor;
- m[1][2] /= divisor;
- m[1][3] /= divisor;
- m[2][0] /= divisor;
- m[2][1] /= divisor;
- m[2][2] /= divisor;
- m[2][3] /= divisor;
- m[3][0] /= divisor;
- m[3][1] /= divisor;
- m[3][2] /= divisor;
- m[3][3] /= divisor;
- flagBits = General;
- return *this;
-}
-
-QDoubleMatrix4x4 operator/(const QDoubleMatrix4x4& matrix, double divisor)
-{
- QDoubleMatrix4x4 m(1); // The "1" says to not load the identity.
- m.m[0][0] = matrix.m[0][0] / divisor;
- m.m[0][1] = matrix.m[0][1] / divisor;
- m.m[0][2] = matrix.m[0][2] / divisor;
- m.m[0][3] = matrix.m[0][3] / divisor;
- m.m[1][0] = matrix.m[1][0] / divisor;
- m.m[1][1] = matrix.m[1][1] / divisor;
- m.m[1][2] = matrix.m[1][2] / divisor;
- m.m[1][3] = matrix.m[1][3] / divisor;
- m.m[2][0] = matrix.m[2][0] / divisor;
- m.m[2][1] = matrix.m[2][1] / divisor;
- m.m[2][2] = matrix.m[2][2] / divisor;
- m.m[2][3] = matrix.m[2][3] / divisor;
- m.m[3][0] = matrix.m[3][0] / divisor;
- m.m[3][1] = matrix.m[3][1] / divisor;
- m.m[3][2] = matrix.m[3][2] / divisor;
- m.m[3][3] = matrix.m[3][3] / divisor;
- m.flagBits = QDoubleMatrix4x4::General;
- return m;
-}
-
-void QDoubleMatrix4x4::scale(const QDoubleVector3D& vector)
-{
- double vx = vector.x();
- double vy = vector.y();
- double vz = vector.z();
- if (flagBits < Scale) {
- m[0][0] = vx;
- m[1][1] = vy;
- m[2][2] = vz;
- } else if (flagBits < Rotation2D) {
- m[0][0] *= vx;
- m[1][1] *= vy;
- m[2][2] *= vz;
- } else if (flagBits < Rotation) {
- m[0][0] *= vx;
- m[0][1] *= vx;
- m[1][0] *= vy;
- m[1][1] *= vy;
- m[2][2] *= vz;
- } else {
- m[0][0] *= vx;
- m[0][1] *= vx;
- m[0][2] *= vx;
- m[0][3] *= vx;
- m[1][0] *= vy;
- m[1][1] *= vy;
- m[1][2] *= vy;
- m[1][3] *= vy;
- m[2][0] *= vz;
- m[2][1] *= vz;
- m[2][2] *= vz;
- m[2][3] *= vz;
- }
- flagBits |= Scale;
-}
-
-void QDoubleMatrix4x4::scale(double x, double y)
-{
- if (flagBits < Scale) {
- m[0][0] = x;
- m[1][1] = y;
- } else if (flagBits < Rotation2D) {
- m[0][0] *= x;
- m[1][1] *= y;
- } else if (flagBits < Rotation) {
- m[0][0] *= x;
- m[0][1] *= x;
- m[1][0] *= y;
- m[1][1] *= y;
- } else {
- m[0][0] *= x;
- m[0][1] *= x;
- m[0][2] *= x;
- m[0][3] *= x;
- m[1][0] *= y;
- m[1][1] *= y;
- m[1][2] *= y;
- m[1][3] *= y;
- }
- flagBits |= Scale;
-}
-
-void QDoubleMatrix4x4::scale(double x, double y, double z)
-{
- if (flagBits < Scale) {
- m[0][0] = x;
- m[1][1] = y;
- m[2][2] = z;
- } else if (flagBits < Rotation2D) {
- m[0][0] *= x;
- m[1][1] *= y;
- m[2][2] *= z;
- } else if (flagBits < Rotation) {
- m[0][0] *= x;
- m[0][1] *= x;
- m[1][0] *= y;
- m[1][1] *= y;
- m[2][2] *= z;
- } else {
- m[0][0] *= x;
- m[0][1] *= x;
- m[0][2] *= x;
- m[0][3] *= x;
- m[1][0] *= y;
- m[1][1] *= y;
- m[1][2] *= y;
- m[1][3] *= y;
- m[2][0] *= z;
- m[2][1] *= z;
- m[2][2] *= z;
- m[2][3] *= z;
- }
- flagBits |= Scale;
-}
-
-void QDoubleMatrix4x4::scale(double factor)
-{
- if (flagBits < Scale) {
- m[0][0] = factor;
- m[1][1] = factor;
- m[2][2] = factor;
- } else if (flagBits < Rotation2D) {
- m[0][0] *= factor;
- m[1][1] *= factor;
- m[2][2] *= factor;
- } else if (flagBits < Rotation) {
- m[0][0] *= factor;
- m[0][1] *= factor;
- m[1][0] *= factor;
- m[1][1] *= factor;
- m[2][2] *= factor;
- } else {
- m[0][0] *= factor;
- m[0][1] *= factor;
- m[0][2] *= factor;
- m[0][3] *= factor;
- m[1][0] *= factor;
- m[1][1] *= factor;
- m[1][2] *= factor;
- m[1][3] *= factor;
- m[2][0] *= factor;
- m[2][1] *= factor;
- m[2][2] *= factor;
- m[2][3] *= factor;
- }
- flagBits |= Scale;
-}
-
-void QDoubleMatrix4x4::translate(const QDoubleVector3D& vector)
-{
- double vx = vector.x();
- double vy = vector.y();
- double vz = vector.z();
- if (flagBits == Identity) {
- m[3][0] = vx;
- m[3][1] = vy;
- m[3][2] = vz;
- } else if (flagBits == Translation) {
- m[3][0] += vx;
- m[3][1] += vy;
- m[3][2] += vz;
- } else if (flagBits == Scale) {
- m[3][0] = m[0][0] * vx;
- m[3][1] = m[1][1] * vy;
- m[3][2] = m[2][2] * vz;
- } else if (flagBits == (Translation | Scale)) {
- m[3][0] += m[0][0] * vx;
- m[3][1] += m[1][1] * vy;
- m[3][2] += m[2][2] * vz;
- } else if (flagBits < Rotation) {
- m[3][0] += m[0][0] * vx + m[1][0] * vy;
- m[3][1] += m[0][1] * vx + m[1][1] * vy;
- m[3][2] += m[2][2] * vz;
- } else {
- m[3][0] += m[0][0] * vx + m[1][0] * vy + m[2][0] * vz;
- m[3][1] += m[0][1] * vx + m[1][1] * vy + m[2][1] * vz;
- m[3][2] += m[0][2] * vx + m[1][2] * vy + m[2][2] * vz;
- m[3][3] += m[0][3] * vx + m[1][3] * vy + m[2][3] * vz;
- }
- flagBits |= Translation;
-}
-
-void QDoubleMatrix4x4::translate(double x, double y)
-{
- if (flagBits == Identity) {
- m[3][0] = x;
- m[3][1] = y;
- } else if (flagBits == Translation) {
- m[3][0] += x;
- m[3][1] += y;
- } else if (flagBits == Scale) {
- m[3][0] = m[0][0] * x;
- m[3][1] = m[1][1] * y;
- } else if (flagBits == (Translation | Scale)) {
- m[3][0] += m[0][0] * x;
- m[3][1] += m[1][1] * y;
- } else if (flagBits < Rotation) {
- m[3][0] += m[0][0] * x + m[1][0] * y;
- m[3][1] += m[0][1] * x + m[1][1] * y;
- } else {
- m[3][0] += m[0][0] * x + m[1][0] * y;
- m[3][1] += m[0][1] * x + m[1][1] * y;
- m[3][2] += m[0][2] * x + m[1][2] * y;
- m[3][3] += m[0][3] * x + m[1][3] * y;
- }
- flagBits |= Translation;
-}
-
-void QDoubleMatrix4x4::translate(double x, double y, double z)
-{
- if (flagBits == Identity) {
- m[3][0] = x;
- m[3][1] = y;
- m[3][2] = z;
- } else if (flagBits == Translation) {
- m[3][0] += x;
- m[3][1] += y;
- m[3][2] += z;
- } else if (flagBits == Scale) {
- m[3][0] = m[0][0] * x;
- m[3][1] = m[1][1] * y;
- m[3][2] = m[2][2] * z;
- } else if (flagBits == (Translation | Scale)) {
- m[3][0] += m[0][0] * x;
- m[3][1] += m[1][1] * y;
- m[3][2] += m[2][2] * z;
- } else if (flagBits < Rotation) {
- m[3][0] += m[0][0] * x + m[1][0] * y;
- m[3][1] += m[0][1] * x + m[1][1] * y;
- m[3][2] += m[2][2] * z;
- } else {
- m[3][0] += m[0][0] * x + m[1][0] * y + m[2][0] * z;
- m[3][1] += m[0][1] * x + m[1][1] * y + m[2][1] * z;
- m[3][2] += m[0][2] * x + m[1][2] * y + m[2][2] * z;
- m[3][3] += m[0][3] * x + m[1][3] * y + m[2][3] * z;
- }
- flagBits |= Translation;
-}
-
-void QDoubleMatrix4x4::rotate(double angle, const QDoubleVector3D& vector)
-{
- rotate(angle, vector.x(), vector.y(), vector.z());
-}
-
-void QDoubleMatrix4x4::rotate(double angle, double x, double y, double z)
-{
- if (angle == 0.0)
- return;
- double c, s;
- if (angle == 90.0 || angle == -270.0) {
- s = 1.0;
- c = 0.0;
- } else if (angle == -90.0 || angle == 270.0) {
- s = -1.0;
- c = 0.0;
- } else if (angle == 180.0 || angle == -180.0) {
- s = 0.0;
- c = -1.0;
- } else {
- double a = qDegreesToRadians(angle);
- c = std::cos(a);
- s = std::sin(a);
- }
- if (x == 0.0) {
- if (y == 0.0) {
- if (z != 0.0) {
- // Rotate around the Z axis.
- if (z < 0)
- s = -s;
- double tmp;
- m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;
- m[1][0] = m[1][0] * c - tmp * s;
- m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;
- m[1][1] = m[1][1] * c - tmp * s;
- m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;
- m[1][2] = m[1][2] * c - tmp * s;
- m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;
- m[1][3] = m[1][3] * c - tmp * s;
-
- flagBits |= Rotation2D;
- return;
- }
- } else if (z == 0.0) {
- // Rotate around the Y axis.
- if (y < 0)
- s = -s;
- double tmp;
- m[2][0] = (tmp = m[2][0]) * c + m[0][0] * s;
- m[0][0] = m[0][0] * c - tmp * s;
- m[2][1] = (tmp = m[2][1]) * c + m[0][1] * s;
- m[0][1] = m[0][1] * c - tmp * s;
- m[2][2] = (tmp = m[2][2]) * c + m[0][2] * s;
- m[0][2] = m[0][2] * c - tmp * s;
- m[2][3] = (tmp = m[2][3]) * c + m[0][3] * s;
- m[0][3] = m[0][3] * c - tmp * s;
-
- flagBits |= Rotation;
- return;
- }
- } else if (y == 0.0 && z == 0.0) {
- // Rotate around the X axis.
- if (x < 0)
- s = -s;
- double tmp;
- m[1][0] = (tmp = m[1][0]) * c + m[2][0] * s;
- m[2][0] = m[2][0] * c - tmp * s;
- m[1][1] = (tmp = m[1][1]) * c + m[2][1] * s;
- m[2][1] = m[2][1] * c - tmp * s;
- m[1][2] = (tmp = m[1][2]) * c + m[2][2] * s;
- m[2][2] = m[2][2] * c - tmp * s;
- m[1][3] = (tmp = m[1][3]) * c + m[2][3] * s;
- m[2][3] = m[2][3] * c - tmp * s;
-
- flagBits |= Rotation;
- return;
- }
-
- double len = double(x) * double(x) +
- double(y) * double(y) +
- double(z) * double(z);
- if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) {
- len = std::sqrt(len);
- x = double(double(x) / len);
- y = double(double(y) / len);
- z = double(double(z) / len);
- }
- double ic = 1.0 - c;
- QDoubleMatrix4x4 rot(1); // The "1" says to not load the identity.
- rot.m[0][0] = x * x * ic + c;
- rot.m[1][0] = x * y * ic - z * s;
- rot.m[2][0] = x * z * ic + y * s;
- rot.m[3][0] = 0.0;
- rot.m[0][1] = y * x * ic + z * s;
- rot.m[1][1] = y * y * ic + c;
- rot.m[2][1] = y * z * ic - x * s;
- rot.m[3][1] = 0.0;
- rot.m[0][2] = x * z * ic - y * s;
- rot.m[1][2] = y * z * ic + x * s;
- rot.m[2][2] = z * z * ic + c;
- rot.m[3][2] = 0.0;
- rot.m[0][3] = 0.0;
- rot.m[1][3] = 0.0;
- rot.m[2][3] = 0.0;
- rot.m[3][3] = 1.0;
- rot.flagBits = Rotation;
- *this *= rot;
-}
-
-void QDoubleMatrix4x4::projectedRotate(double angle, double x, double y, double z)
-{
- // Used by QGraphicsRotation::applyTo() to perform a rotation
- // and projection back to 2D in a single step.
- if (angle == 0.0)
- return;
- double c, s;
- if (angle == 90.0 || angle == -270.0) {
- s = 1.0;
- c = 0.0;
- } else if (angle == -90.0 || angle == 270.0) {
- s = -1.0;
- c = 0.0;
- } else if (angle == 180.0 || angle == -180.0) {
- s = 0.0;
- c = -1.0;
- } else {
- double a = qDegreesToRadians(angle);
- c = std::cos(a);
- s = std::sin(a);
- }
- if (x == 0.0) {
- if (y == 0.0) {
- if (z != 0.0) {
- // Rotate around the Z axis.
- if (z < 0)
- s = -s;
- double tmp;
- m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;
- m[1][0] = m[1][0] * c - tmp * s;
- m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;
- m[1][1] = m[1][1] * c - tmp * s;
- m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;
- m[1][2] = m[1][2] * c - tmp * s;
- m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;
- m[1][3] = m[1][3] * c - tmp * s;
-
- flagBits |= Rotation2D;
- return;
- }
- } else if (z == 0.0) {
- // Rotate around the Y axis.
- if (y < 0)
- s = -s;
- m[0][0] = m[0][0] * c + m[3][0] * s * inv_dist_to_plane;
- m[0][1] = m[0][1] * c + m[3][1] * s * inv_dist_to_plane;
- m[0][2] = m[0][2] * c + m[3][2] * s * inv_dist_to_plane;
- m[0][3] = m[0][3] * c + m[3][3] * s * inv_dist_to_plane;
- flagBits = General;
- return;
- }
- } else if (y == 0.0 && z == 0.0) {
- // Rotate around the X axis.
- if (x < 0)
- s = -s;
- m[1][0] = m[1][0] * c - m[3][0] * s * inv_dist_to_plane;
- m[1][1] = m[1][1] * c - m[3][1] * s * inv_dist_to_plane;
- m[1][2] = m[1][2] * c - m[3][2] * s * inv_dist_to_plane;
- m[1][3] = m[1][3] * c - m[3][3] * s * inv_dist_to_plane;
- flagBits = General;
- return;
- }
- double len = double(x) * double(x) +
- double(y) * double(y) +
- double(z) * double(z);
- if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) {
- len = std::sqrt(len);
- x = double(double(x) / len);
- y = double(double(y) / len);
- z = double(double(z) / len);
- }
- double ic = 1.0 - c;
- QDoubleMatrix4x4 rot(1); // The "1" says to not load the identity.
- rot.m[0][0] = x * x * ic + c;
- rot.m[1][0] = x * y * ic - z * s;
- rot.m[2][0] = 0.0;
- rot.m[3][0] = 0.0;
- rot.m[0][1] = y * x * ic + z * s;
- rot.m[1][1] = y * y * ic + c;
- rot.m[2][1] = 0.0;
- rot.m[3][1] = 0.0;
- rot.m[0][2] = 0.0;
- rot.m[1][2] = 0.0;
- rot.m[2][2] = 1.0;
- rot.m[3][2] = 0.0;
- rot.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane;
- rot.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane;
- rot.m[2][3] = 0.0;
- rot.m[3][3] = 1.0;
- rot.flagBits = General;
- *this *= rot;
-}
-
-void QDoubleMatrix4x4::ortho(const QRect& rect)
-{
- // Note: rect.right() and rect.bottom() subtract 1 in QRect,
- // which gives the location of a pixel within the rectangle,
- // instead of the extent of the rectangle. We want the extent.
- // QRectF expresses the extent properly.
- ortho(rect.x(), rect.x() + rect.width(), rect.y() + rect.height(), rect.y(), -1.0, 1.0);
-}
-
-void QDoubleMatrix4x4::ortho(const QRectF& rect)
-{
- ortho(rect.left(), rect.right(), rect.bottom(), rect.top(), -1.0, 1.0);
-}
-
-void QDoubleMatrix4x4::ortho(double left, double right, double bottom, double top, double nearPlane, double farPlane)
-{
- // Bail out if the projection volume is zero-sized.
- if (left == right || bottom == top || nearPlane == farPlane)
- return;
-
- // Construct the projection.
- double width = right - left;
- double invheight = top - bottom;
- double clip = farPlane - nearPlane;
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = 2.0 / width;
- m.m[1][0] = 0.0;
- m.m[2][0] = 0.0;
- m.m[3][0] = -(left + right) / width;
- m.m[0][1] = 0.0;
- m.m[1][1] = 2.0 / invheight;
- m.m[2][1] = 0.0;
- m.m[3][1] = -(top + bottom) / invheight;
- m.m[0][2] = 0.0;
- m.m[1][2] = 0.0;
- m.m[2][2] = -2.0 / clip;
- m.m[3][2] = -(nearPlane + farPlane) / clip;
- m.m[0][3] = 0.0;
- m.m[1][3] = 0.0;
- m.m[2][3] = 0.0;
- m.m[3][3] = 1.0;
- m.flagBits = Translation | Scale;
-
- // Apply the projection.
- *this *= m;
-}
-
-void QDoubleMatrix4x4::frustum(double left, double right, double bottom, double top, double nearPlane, double farPlane)
-{
- // Bail out if the projection volume is zero-sized.
- if (left == right || bottom == top || nearPlane == farPlane)
- return;
-
- // Construct the projection.
- QDoubleMatrix4x4 m(1);
- double width = right - left;
- double invheight = top - bottom;
- double clip = farPlane - nearPlane;
- m.m[0][0] = 2.0 * nearPlane / width;
- m.m[1][0] = 0.0;
- m.m[2][0] = (left + right) / width;
- m.m[3][0] = 0.0;
- m.m[0][1] = 0.0;
- m.m[1][1] = 2.0 * nearPlane / invheight;
- m.m[2][1] = (top + bottom) / invheight;
- m.m[3][1] = 0.0;
- m.m[0][2] = 0.0;
- m.m[1][2] = 0.0;
- m.m[2][2] = -(nearPlane + farPlane) / clip;
- m.m[3][2] = -2.0 * nearPlane * farPlane / clip;
- m.m[0][3] = 0.0;
- m.m[1][3] = 0.0;
- m.m[2][3] = -1.0;
- m.m[3][3] = 0.0;
- m.flagBits = General;
-
- // Apply the projection.
- *this *= m;
-}
-
-void QDoubleMatrix4x4::perspective(double verticalAngle, double aspectRatio, double nearPlane, double farPlane)
-{
- // Bail out if the projection volume is zero-sized.
- if (nearPlane == farPlane || aspectRatio == 0.0)
- return;
-
- // Construct the projection.
- QDoubleMatrix4x4 m(1);
- double radians = qDegreesToRadians(verticalAngle / 2.0);
- double sine = std::sin(radians);
- if (sine == 0.0)
- return;
- double cotan = std::cos(radians) / sine;
- double clip = farPlane - nearPlane;
- m.m[0][0] = cotan / aspectRatio;
- m.m[1][0] = 0.0;
- m.m[2][0] = 0.0;
- m.m[3][0] = 0.0;
- m.m[0][1] = 0.0;
- m.m[1][1] = cotan;
- m.m[2][1] = 0.0;
- m.m[3][1] = 0.0;
- m.m[0][2] = 0.0;
- m.m[1][2] = 0.0;
- m.m[2][2] = -(nearPlane + farPlane) / clip;
- m.m[3][2] = -(2.0 * nearPlane * farPlane) / clip;
- m.m[0][3] = 0.0;
- m.m[1][3] = 0.0;
- m.m[2][3] = -1.0;
- m.m[3][3] = 0.0;
- m.flagBits = General;
-
- // Apply the projection.
- *this *= m;
-}
-
-void QDoubleMatrix4x4::lookAt(const QDoubleVector3D& eye, const QDoubleVector3D& center, const QDoubleVector3D& up)
-{
- QDoubleVector3D forward = center - eye;
- if (qFuzzyIsNull(forward.x()) && qFuzzyIsNull(forward.y()) && qFuzzyIsNull(forward.z()))
- return;
-
- forward.normalize();
- QDoubleVector3D side = QDoubleVector3D::crossProduct(forward, up).normalized();
- QDoubleVector3D upVector = QDoubleVector3D::crossProduct(side, forward);
-
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = side.x();
- m.m[1][0] = side.y();
- m.m[2][0] = side.z();
- m.m[3][0] = 0.0;
- m.m[0][1] = upVector.x();
- m.m[1][1] = upVector.y();
- m.m[2][1] = upVector.z();
- m.m[3][1] = 0.0;
- m.m[0][2] = -forward.x();
- m.m[1][2] = -forward.y();
- m.m[2][2] = -forward.z();
- m.m[3][2] = 0.0;
- m.m[0][3] = 0.0;
- m.m[1][3] = 0.0;
- m.m[2][3] = 0.0;
- m.m[3][3] = 1.0;
- m.flagBits = Rotation;
-
- *this *= m;
- translate(-eye);
-}
-
-void QDoubleMatrix4x4::viewport(double left, double bottom, double width, double height, double nearPlane, double farPlane)
-{
- const double w2 = width / 2.0;
- const double h2 = height / 2.0;
-
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = w2;
- m.m[1][0] = 0.0;
- m.m[2][0] = 0.0;
- m.m[3][0] = left + w2;
- m.m[0][1] = 0.0;
- m.m[1][1] = h2;
- m.m[2][1] = 0.0;
- m.m[3][1] = bottom + h2;
- m.m[0][2] = 0.0;
- m.m[1][2] = 0.0;
- m.m[2][2] = (farPlane - nearPlane) / 2.0;
- m.m[3][2] = (nearPlane + farPlane) / 2.0;
- m.m[0][3] = 0.0;
- m.m[1][3] = 0.0;
- m.m[2][3] = 0.0;
- m.m[3][3] = 1.0;
- m.flagBits = General;
-
- *this *= m;
-}
-
-void QDoubleMatrix4x4::flipCoordinates()
-{
- // Multiplying the y and z coordinates with -1 does NOT flip between right-handed and
- // left-handed coordinate systems, it just rotates 180 degrees around the x axis, so
- // I'm deprecating this function.
- if (flagBits < Rotation2D) {
- // Translation | Scale
- m[1][1] = -m[1][1];
- m[2][2] = -m[2][2];
- } else {
- m[1][0] = -m[1][0];
- m[1][1] = -m[1][1];
- m[1][2] = -m[1][2];
- m[1][3] = -m[1][3];
- m[2][0] = -m[2][0];
- m[2][1] = -m[2][1];
- m[2][2] = -m[2][2];
- m[2][3] = -m[2][3];
- }
- flagBits |= Scale;
-}
-
-void QDoubleMatrix4x4::copyDataTo(double *values) const
-{
- for (int row = 0; row < 4; ++row)
- for (int col = 0; col < 4; ++col)
- values[row * 4 + col] = double(m[col][row]);
-}
-
-QRect QDoubleMatrix4x4::mapRect(const QRect& rect) const
-{
- if (flagBits < Scale) {
- // Translation
- return QRect(qRound(rect.x() + m[3][0]),
- qRound(rect.y() + m[3][1]),
- rect.width(), rect.height());
- } else if (flagBits < Rotation2D) {
- // Translation | Scale
- double x = rect.x() * m[0][0] + m[3][0];
- double y = rect.y() * m[1][1] + m[3][1];
- double w = rect.width() * m[0][0];
- double h = rect.height() * m[1][1];
- if (w < 0) {
- w = -w;
- x -= w;
- }
- if (h < 0) {
- h = -h;
- y -= h;
- }
- return QRect(qRound(x), qRound(y), qRound(w), qRound(h));
- }
-
- QPoint tl = map(rect.topLeft());
- QPoint tr = map(QPoint(rect.x() + rect.width(), rect.y()));
- QPoint bl = map(QPoint(rect.x(), rect.y() + rect.height()));
- QPoint br = map(QPoint(rect.x() + rect.width(),
- rect.y() + rect.height()));
-
- int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));
- int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));
- int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));
- int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));
-
- return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
-}
-
-QRectF QDoubleMatrix4x4::mapRect(const QRectF& rect) const
-{
- if (flagBits < Scale) {
- // Translation
- return rect.translated(m[3][0], m[3][1]);
- } else if (flagBits < Rotation2D) {
- // Translation | Scale
- double x = rect.x() * m[0][0] + m[3][0];
- double y = rect.y() * m[1][1] + m[3][1];
- double w = rect.width() * m[0][0];
- double h = rect.height() * m[1][1];
- if (w < 0) {
- w = -w;
- x -= w;
- }
- if (h < 0) {
- h = -h;
- y -= h;
- }
- return QRectF(x, y, w, h);
- }
-
- QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight());
- QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight());
-
- double xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));
- double xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));
- double ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));
- double ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));
-
- return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
-}
-
-QDoubleMatrix4x4 QDoubleMatrix4x4::orthonormalInverse() const
-{
- QDoubleMatrix4x4 result(1); // The '1' says not to load identity
-
- result.m[0][0] = m[0][0];
- result.m[1][0] = m[0][1];
- result.m[2][0] = m[0][2];
-
- result.m[0][1] = m[1][0];
- result.m[1][1] = m[1][1];
- result.m[2][1] = m[1][2];
-
- result.m[0][2] = m[2][0];
- result.m[1][2] = m[2][1];
- result.m[2][2] = m[2][2];
-
- result.m[0][3] = 0.0;
- result.m[1][3] = 0.0;
- result.m[2][3] = 0.0;
-
- result.m[3][0] = -(result.m[0][0] * m[3][0] + result.m[1][0] * m[3][1] + result.m[2][0] * m[3][2]);
- result.m[3][1] = -(result.m[0][1] * m[3][0] + result.m[1][1] * m[3][1] + result.m[2][1] * m[3][2]);
- result.m[3][2] = -(result.m[0][2] * m[3][0] + result.m[1][2] * m[3][1] + result.m[2][2] * m[3][2]);
- result.m[3][3] = 1.0;
-
- result.flagBits = flagBits;
-
- return result;
-}
-
-void QDoubleMatrix4x4::optimize()
-{
- // If the last row is not (0, 0, 0, 1), the matrix is not a special type.
- flagBits = General;
- if (m[0][3] != 0 || m[1][3] != 0 || m[2][3] != 0 || m[3][3] != 1)
- return;
-
- flagBits &= ~Perspective;
-
- // If the last column is (0, 0, 0, 1), then there is no translation.
- if (m[3][0] == 0 && m[3][1] == 0 && m[3][2] == 0)
- flagBits &= ~Translation;
-
- // If the two first elements of row 3 and column 3 are 0, then any rotation must be about Z.
- if (!m[0][2] && !m[1][2] && !m[2][0] && !m[2][1]) {
- flagBits &= ~Rotation;
- // If the six non-diagonal elements in the top left 3x3 matrix are 0, there is no rotation.
- if (!m[0][1] && !m[1][0]) {
- flagBits &= ~Rotation2D;
- // Check for identity.
- if (m[0][0] == 1 && m[1][1] == 1 && m[2][2] == 1)
- flagBits &= ~Scale;
- } else {
- // If the columns are orthonormal and form a right-handed system, then there is no scale.
- double det = matrixDet2(m, 0, 1, 0, 1);
- double lenX = m[0][0] * m[0][0] + m[0][1] * m[0][1];
- double lenY = m[1][0] * m[1][0] + m[1][1] * m[1][1];
- double lenZ = m[2][2];
- if (qFuzzyCompare(det, 1.0) && qFuzzyCompare(lenX, 1.0)
- && qFuzzyCompare(lenY, 1.0) && qFuzzyCompare(lenZ, 1.0))
- {
- flagBits &= ~Scale;
- }
- }
- } else {
- // If the columns are orthonormal and form a right-handed system, then there is no scale.
- double det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
- double lenX = m[0][0] * m[0][0] + m[0][1] * m[0][1] + m[0][2] * m[0][2];
- double lenY = m[1][0] * m[1][0] + m[1][1] * m[1][1] + m[1][2] * m[1][2];
- double lenZ = m[2][0] * m[2][0] + m[2][1] * m[2][1] + m[2][2] * m[2][2];
- if (qFuzzyCompare(det, 1.0) && qFuzzyCompare(lenX, 1.0)
- && qFuzzyCompare(lenY, 1.0) && qFuzzyCompare(lenZ, 1.0))
- {
- flagBits &= ~Scale;
- }
- }
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QDoubleMatrix4x4 &m)
-{
- QDebugStateSaver saver(dbg);
- // Create a string that represents the matrix type.
- QByteArray bits;
- if (m.flagBits == QDoubleMatrix4x4::Identity) {
- bits = "Identity";
- } else if (m.flagBits == QDoubleMatrix4x4::General) {
- bits = "General";
- } else {
- if ((m.flagBits & QDoubleMatrix4x4::Translation) != 0)
- bits += "Translation,";
- if ((m.flagBits & QDoubleMatrix4x4::Scale) != 0)
- bits += "Scale,";
- if ((m.flagBits & QDoubleMatrix4x4::Rotation2D) != 0)
- bits += "Rotation2D,";
- if ((m.flagBits & QDoubleMatrix4x4::Rotation) != 0)
- bits += "Rotation,";
- if ((m.flagBits & QDoubleMatrix4x4::Perspective) != 0)
- bits += "Perspective,";
- if (bits.size() > 0)
- bits = bits.left(bits.size() - 1);
- }
-
- // Output in row-major order because it is more human-readable.
- dbg.nospace() << "QDoubleMatrix4x4(type:" << bits.constData() << Qt::endl
- << qSetFieldWidth(10)
- << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << Qt::endl
- << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << Qt::endl
- << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << Qt::endl
- << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << Qt::endl
- << qSetFieldWidth(0) << ')';
- return dbg;
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-QDataStream &operator<<(QDataStream &stream, const QDoubleMatrix4x4 &matrix)
-{
- for (int row = 0; row < 4; ++row)
- for (int col = 0; col < 4; ++col)
- stream << matrix(row, col);
- return stream;
-}
-
-QDataStream &operator>>(QDataStream &stream, QDoubleMatrix4x4 &matrix)
-{
- double x;
- for (int row = 0; row < 4; ++row) {
- for (int col = 0; col < 4; ++col) {
- stream >> x;
- matrix(row, col) = x;
- }
- }
- matrix.optimize();
- return stream;
-}
-
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qdoublematrix4x4_p.h b/src/positioning/qdoublematrix4x4_p.h
deleted file mode 100644
index 1f9dcfa8..00000000
--- a/src/positioning/qdoublematrix4x4_p.h
+++ /dev/null
@@ -1,946 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDOUBLEMATRIX4X4_H
-#define QDOUBLEMATRIX4X4_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include <QtPositioning/private/qdoublevector3d_p.h>
-#include <QtCore/QDebug>
-#include <QtCore/qmetatype.h>
-#include <QtCore/QRectF>
-
-QT_BEGIN_NAMESPACE
-
-/*
- * This class is a copy/paste/replace of QMatrix4x4
- * No algorithm has been changed.
- * Some methods have been removed.
- */
-
-class Q_POSITIONING_PRIVATE_EXPORT QDoubleMatrix4x4
-{
-public:
- inline QDoubleMatrix4x4() { setToIdentity(); }
- explicit QDoubleMatrix4x4(Qt::Initialization) : flagBits(General) {}
- explicit QDoubleMatrix4x4(const double *values);
- inline QDoubleMatrix4x4(double m11, double m12, double m13, double m14,
- double m21, double m22, double m23, double m24,
- double m31, double m32, double m33, double m34,
- double m41, double m42, double m43, double m44);
-
- QDoubleMatrix4x4(const double *values, int cols, int rows);
-
- inline const double& operator()(int row, int column) const;
- inline double& operator()(int row, int column);
-
- inline bool isAffine() const;
-
- inline bool isIdentity() const;
- inline void setToIdentity();
-
- inline void fill(double value);
-
- double determinant() const;
- QDoubleMatrix4x4 inverted(bool *invertible = nullptr) const;
- QDoubleMatrix4x4 transposed() const;
-
- inline QDoubleMatrix4x4& operator+=(const QDoubleMatrix4x4& other);
- inline QDoubleMatrix4x4& operator-=(const QDoubleMatrix4x4& other);
- inline QDoubleMatrix4x4& operator*=(const QDoubleMatrix4x4& other);
- inline QDoubleMatrix4x4& operator*=(double factor);
- QDoubleMatrix4x4& operator/=(double divisor);
- inline bool operator==(const QDoubleMatrix4x4& other) const;
- inline bool operator!=(const QDoubleMatrix4x4& other) const;
-
- friend QDoubleMatrix4x4 operator+(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2);
- friend QDoubleMatrix4x4 operator-(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2);
- friend QDoubleMatrix4x4 operator*(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2);
-
- friend QDoubleVector3D operator*(const QDoubleMatrix4x4& matrix, const QDoubleVector3D& vector);
- friend QDoubleVector3D operator*(const QDoubleVector3D& vector, const QDoubleMatrix4x4& matrix);
-
- friend QPoint operator*(const QPoint& point, const QDoubleMatrix4x4& matrix);
- friend QPointF operator*(const QPointF& point, const QDoubleMatrix4x4& matrix);
- friend QDoubleMatrix4x4 operator-(const QDoubleMatrix4x4& matrix);
- friend QPoint operator*(const QDoubleMatrix4x4& matrix, const QPoint& point);
- friend QPointF operator*(const QDoubleMatrix4x4& matrix, const QPointF& point);
- friend QDoubleMatrix4x4 operator*(double factor, const QDoubleMatrix4x4& matrix);
- friend QDoubleMatrix4x4 operator*(const QDoubleMatrix4x4& matrix, double factor);
- friend Q_POSITIONING_PRIVATE_EXPORT QDoubleMatrix4x4 operator/(const QDoubleMatrix4x4& matrix, double divisor);
-
- friend inline bool qFuzzyCompare(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2);
-
-
- void scale(const QDoubleVector3D& vector);
- void translate(const QDoubleVector3D& vector);
- void rotate(double angle, const QDoubleVector3D& vector);
-
- void scale(double x, double y);
- void scale(double x, double y, double z);
- void scale(double factor);
- void translate(double x, double y);
- void translate(double x, double y, double z);
- void rotate(double angle, double x, double y, double z = 0.0f);
-
- void ortho(const QRect& rect);
- void ortho(const QRectF& rect);
- void ortho(double left, double right, double bottom, double top, double nearPlane, double farPlane);
- void frustum(double left, double right, double bottom, double top, double nearPlane, double farPlane);
- void perspective(double verticalAngle, double aspectRatio, double nearPlane, double farPlane);
-
- void lookAt(const QDoubleVector3D& eye, const QDoubleVector3D& center, const QDoubleVector3D& up);
-
- void viewport(const QRectF &rect);
- void viewport(double left, double bottom, double width, double height, double nearPlane = 0.0f, double farPlane = 1.0f);
- void flipCoordinates();
-
- void copyDataTo(double *values) const;
-
- QPoint map(const QPoint& point) const;
- QPointF map(const QPointF& point) const;
-
- QDoubleVector3D map(const QDoubleVector3D& point) const;
- QDoubleVector3D mapVector(const QDoubleVector3D& vector) const;
-
- QRect mapRect(const QRect& rect) const;
- QRectF mapRect(const QRectF& rect) const;
-
- inline double *data();
- inline const double *data() const { return *m; }
- inline const double *constData() const { return *m; }
-
- void optimize();
-
-#ifndef QT_NO_DEBUG_STREAM
- friend Q_POSITIONING_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QDoubleMatrix4x4 &m);
-#endif
-
-private:
- double m[4][4]; // Column-major order to match OpenGL.
- int flagBits; // Flag bits from the enum below.
-
- // When matrices are multiplied, the flag bits are or-ed together.
- enum {
- Identity = 0x0000, // Identity matrix
- Translation = 0x0001, // Contains a translation
- Scale = 0x0002, // Contains a scale
- Rotation2D = 0x0004, // Contains a rotation about the Z axis
- Rotation = 0x0008, // Contains an arbitrary rotation
- Perspective = 0x0010, // Last row is different from (0, 0, 0, 1)
- General = 0x001f // General matrix, unknown contents
- };
-
- // Construct without initializing identity matrix.
- explicit QDoubleMatrix4x4(int) { }
-
- QDoubleMatrix4x4 orthonormalInverse() const;
-
- void projectedRotate(double angle, double x, double y, double z);
-};
-
-Q_DECLARE_TYPEINFO(QDoubleMatrix4x4, Q_RELOCATABLE_TYPE);
-
-inline QDoubleMatrix4x4::QDoubleMatrix4x4
- (double m11, double m12, double m13, double m14,
- double m21, double m22, double m23, double m24,
- double m31, double m32, double m33, double m34,
- double m41, double m42, double m43, double m44)
-{
- m[0][0] = m11; m[0][1] = m21; m[0][2] = m31; m[0][3] = m41;
- m[1][0] = m12; m[1][1] = m22; m[1][2] = m32; m[1][3] = m42;
- m[2][0] = m13; m[2][1] = m23; m[2][2] = m33; m[2][3] = m43;
- m[3][0] = m14; m[3][1] = m24; m[3][2] = m34; m[3][3] = m44;
- flagBits = General;
-}
-
-inline const double& QDoubleMatrix4x4::operator()(int aRow, int aColumn) const
-{
- Q_ASSERT(aRow >= 0 && aRow < 4 && aColumn >= 0 && aColumn < 4);
- return m[aColumn][aRow];
-}
-
-inline double& QDoubleMatrix4x4::operator()(int aRow, int aColumn)
-{
- Q_ASSERT(aRow >= 0 && aRow < 4 && aColumn >= 0 && aColumn < 4);
- flagBits = General;
- return m[aColumn][aRow];
-}
-
-Q_POSITIONING_PRIVATE_EXPORT QDoubleMatrix4x4 operator/(const QDoubleMatrix4x4& matrix, double divisor);
-
-inline bool QDoubleMatrix4x4::isAffine() const
-{
- return m[0][3] == 0.0f && m[1][3] == 0.0f && m[2][3] == 0.0f && m[3][3] == 1.0f;
-}
-
-inline bool QDoubleMatrix4x4::isIdentity() const
-{
- if (flagBits == Identity)
- return true;
- if (m[0][0] != 1.0f || m[0][1] != 0.0f || m[0][2] != 0.0f)
- return false;
- if (m[0][3] != 0.0f || m[1][0] != 0.0f || m[1][1] != 1.0f)
- return false;
- if (m[1][2] != 0.0f || m[1][3] != 0.0f || m[2][0] != 0.0f)
- return false;
- if (m[2][1] != 0.0f || m[2][2] != 1.0f || m[2][3] != 0.0f)
- return false;
- if (m[3][0] != 0.0f || m[3][1] != 0.0f || m[3][2] != 0.0f)
- return false;
- return (m[3][3] == 1.0f);
-}
-
-inline void QDoubleMatrix4x4::setToIdentity()
-{
- m[0][0] = 1.0f;
- m[0][1] = 0.0f;
- m[0][2] = 0.0f;
- m[0][3] = 0.0f;
- m[1][0] = 0.0f;
- m[1][1] = 1.0f;
- m[1][2] = 0.0f;
- m[1][3] = 0.0f;
- m[2][0] = 0.0f;
- m[2][1] = 0.0f;
- m[2][2] = 1.0f;
- m[2][3] = 0.0f;
- m[3][0] = 0.0f;
- m[3][1] = 0.0f;
- m[3][2] = 0.0f;
- m[3][3] = 1.0f;
- flagBits = Identity;
-}
-
-inline void QDoubleMatrix4x4::fill(double value)
-{
- m[0][0] = value;
- m[0][1] = value;
- m[0][2] = value;
- m[0][3] = value;
- m[1][0] = value;
- m[1][1] = value;
- m[1][2] = value;
- m[1][3] = value;
- m[2][0] = value;
- m[2][1] = value;
- m[2][2] = value;
- m[2][3] = value;
- m[3][0] = value;
- m[3][1] = value;
- m[3][2] = value;
- m[3][3] = value;
- flagBits = General;
-}
-
-inline QDoubleMatrix4x4& QDoubleMatrix4x4::operator+=(const QDoubleMatrix4x4& other)
-{
- m[0][0] += other.m[0][0];
- m[0][1] += other.m[0][1];
- m[0][2] += other.m[0][2];
- m[0][3] += other.m[0][3];
- m[1][0] += other.m[1][0];
- m[1][1] += other.m[1][1];
- m[1][2] += other.m[1][2];
- m[1][3] += other.m[1][3];
- m[2][0] += other.m[2][0];
- m[2][1] += other.m[2][1];
- m[2][2] += other.m[2][2];
- m[2][3] += other.m[2][3];
- m[3][0] += other.m[3][0];
- m[3][1] += other.m[3][1];
- m[3][2] += other.m[3][2];
- m[3][3] += other.m[3][3];
- flagBits = General;
- return *this;
-}
-
-inline QDoubleMatrix4x4& QDoubleMatrix4x4::operator-=(const QDoubleMatrix4x4& other)
-{
- m[0][0] -= other.m[0][0];
- m[0][1] -= other.m[0][1];
- m[0][2] -= other.m[0][2];
- m[0][3] -= other.m[0][3];
- m[1][0] -= other.m[1][0];
- m[1][1] -= other.m[1][1];
- m[1][2] -= other.m[1][2];
- m[1][3] -= other.m[1][3];
- m[2][0] -= other.m[2][0];
- m[2][1] -= other.m[2][1];
- m[2][2] -= other.m[2][2];
- m[2][3] -= other.m[2][3];
- m[3][0] -= other.m[3][0];
- m[3][1] -= other.m[3][1];
- m[3][2] -= other.m[3][2];
- m[3][3] -= other.m[3][3];
- flagBits = General;
- return *this;
-}
-
-inline QDoubleMatrix4x4& QDoubleMatrix4x4::operator*=(const QDoubleMatrix4x4& other)
-{
- flagBits |= other.flagBits;
-
- if (flagBits < Rotation2D) {
- m[3][0] += m[0][0] * other.m[3][0];
- m[3][1] += m[1][1] * other.m[3][1];
- m[3][2] += m[2][2] * other.m[3][2];
-
- m[0][0] *= other.m[0][0];
- m[1][1] *= other.m[1][1];
- m[2][2] *= other.m[2][2];
- return *this;
- }
-
- double m0, m1, m2;
- m0 = m[0][0] * other.m[0][0]
- + m[1][0] * other.m[0][1]
- + m[2][0] * other.m[0][2]
- + m[3][0] * other.m[0][3];
- m1 = m[0][0] * other.m[1][0]
- + m[1][0] * other.m[1][1]
- + m[2][0] * other.m[1][2]
- + m[3][0] * other.m[1][3];
- m2 = m[0][0] * other.m[2][0]
- + m[1][0] * other.m[2][1]
- + m[2][0] * other.m[2][2]
- + m[3][0] * other.m[2][3];
- m[3][0] = m[0][0] * other.m[3][0]
- + m[1][0] * other.m[3][1]
- + m[2][0] * other.m[3][2]
- + m[3][0] * other.m[3][3];
- m[0][0] = m0;
- m[1][0] = m1;
- m[2][0] = m2;
-
- m0 = m[0][1] * other.m[0][0]
- + m[1][1] * other.m[0][1]
- + m[2][1] * other.m[0][2]
- + m[3][1] * other.m[0][3];
- m1 = m[0][1] * other.m[1][0]
- + m[1][1] * other.m[1][1]
- + m[2][1] * other.m[1][2]
- + m[3][1] * other.m[1][3];
- m2 = m[0][1] * other.m[2][0]
- + m[1][1] * other.m[2][1]
- + m[2][1] * other.m[2][2]
- + m[3][1] * other.m[2][3];
- m[3][1] = m[0][1] * other.m[3][0]
- + m[1][1] * other.m[3][1]
- + m[2][1] * other.m[3][2]
- + m[3][1] * other.m[3][3];
- m[0][1] = m0;
- m[1][1] = m1;
- m[2][1] = m2;
-
- m0 = m[0][2] * other.m[0][0]
- + m[1][2] * other.m[0][1]
- + m[2][2] * other.m[0][2]
- + m[3][2] * other.m[0][3];
- m1 = m[0][2] * other.m[1][0]
- + m[1][2] * other.m[1][1]
- + m[2][2] * other.m[1][2]
- + m[3][2] * other.m[1][3];
- m2 = m[0][2] * other.m[2][0]
- + m[1][2] * other.m[2][1]
- + m[2][2] * other.m[2][2]
- + m[3][2] * other.m[2][3];
- m[3][2] = m[0][2] * other.m[3][0]
- + m[1][2] * other.m[3][1]
- + m[2][2] * other.m[3][2]
- + m[3][2] * other.m[3][3];
- m[0][2] = m0;
- m[1][2] = m1;
- m[2][2] = m2;
-
- m0 = m[0][3] * other.m[0][0]
- + m[1][3] * other.m[0][1]
- + m[2][3] * other.m[0][2]
- + m[3][3] * other.m[0][3];
- m1 = m[0][3] * other.m[1][0]
- + m[1][3] * other.m[1][1]
- + m[2][3] * other.m[1][2]
- + m[3][3] * other.m[1][3];
- m2 = m[0][3] * other.m[2][0]
- + m[1][3] * other.m[2][1]
- + m[2][3] * other.m[2][2]
- + m[3][3] * other.m[2][3];
- m[3][3] = m[0][3] * other.m[3][0]
- + m[1][3] * other.m[3][1]
- + m[2][3] * other.m[3][2]
- + m[3][3] * other.m[3][3];
- m[0][3] = m0;
- m[1][3] = m1;
- m[2][3] = m2;
- return *this;
-}
-
-inline QDoubleMatrix4x4& QDoubleMatrix4x4::operator*=(double factor)
-{
- m[0][0] *= factor;
- m[0][1] *= factor;
- m[0][2] *= factor;
- m[0][3] *= factor;
- m[1][0] *= factor;
- m[1][1] *= factor;
- m[1][2] *= factor;
- m[1][3] *= factor;
- m[2][0] *= factor;
- m[2][1] *= factor;
- m[2][2] *= factor;
- m[2][3] *= factor;
- m[3][0] *= factor;
- m[3][1] *= factor;
- m[3][2] *= factor;
- m[3][3] *= factor;
- flagBits = General;
- return *this;
-}
-
-inline bool QDoubleMatrix4x4::operator==(const QDoubleMatrix4x4& other) const
-{
- return m[0][0] == other.m[0][0] &&
- m[0][1] == other.m[0][1] &&
- m[0][2] == other.m[0][2] &&
- m[0][3] == other.m[0][3] &&
- m[1][0] == other.m[1][0] &&
- m[1][1] == other.m[1][1] &&
- m[1][2] == other.m[1][2] &&
- m[1][3] == other.m[1][3] &&
- m[2][0] == other.m[2][0] &&
- m[2][1] == other.m[2][1] &&
- m[2][2] == other.m[2][2] &&
- m[2][3] == other.m[2][3] &&
- m[3][0] == other.m[3][0] &&
- m[3][1] == other.m[3][1] &&
- m[3][2] == other.m[3][2] &&
- m[3][3] == other.m[3][3];
-}
-
-inline bool QDoubleMatrix4x4::operator!=(const QDoubleMatrix4x4& other) const
-{
- return m[0][0] != other.m[0][0] ||
- m[0][1] != other.m[0][1] ||
- m[0][2] != other.m[0][2] ||
- m[0][3] != other.m[0][3] ||
- m[1][0] != other.m[1][0] ||
- m[1][1] != other.m[1][1] ||
- m[1][2] != other.m[1][2] ||
- m[1][3] != other.m[1][3] ||
- m[2][0] != other.m[2][0] ||
- m[2][1] != other.m[2][1] ||
- m[2][2] != other.m[2][2] ||
- m[2][3] != other.m[2][3] ||
- m[3][0] != other.m[3][0] ||
- m[3][1] != other.m[3][1] ||
- m[3][2] != other.m[3][2] ||
- m[3][3] != other.m[3][3];
-}
-
-inline QDoubleMatrix4x4 operator+(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2)
-{
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = m1.m[0][0] + m2.m[0][0];
- m.m[0][1] = m1.m[0][1] + m2.m[0][1];
- m.m[0][2] = m1.m[0][2] + m2.m[0][2];
- m.m[0][3] = m1.m[0][3] + m2.m[0][3];
- m.m[1][0] = m1.m[1][0] + m2.m[1][0];
- m.m[1][1] = m1.m[1][1] + m2.m[1][1];
- m.m[1][2] = m1.m[1][2] + m2.m[1][2];
- m.m[1][3] = m1.m[1][3] + m2.m[1][3];
- m.m[2][0] = m1.m[2][0] + m2.m[2][0];
- m.m[2][1] = m1.m[2][1] + m2.m[2][1];
- m.m[2][2] = m1.m[2][2] + m2.m[2][2];
- m.m[2][3] = m1.m[2][3] + m2.m[2][3];
- m.m[3][0] = m1.m[3][0] + m2.m[3][0];
- m.m[3][1] = m1.m[3][1] + m2.m[3][1];
- m.m[3][2] = m1.m[3][2] + m2.m[3][2];
- m.m[3][3] = m1.m[3][3] + m2.m[3][3];
- m.flagBits = QDoubleMatrix4x4::General;
- return m;
-}
-
-inline QDoubleMatrix4x4 operator-(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2)
-{
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = m1.m[0][0] - m2.m[0][0];
- m.m[0][1] = m1.m[0][1] - m2.m[0][1];
- m.m[0][2] = m1.m[0][2] - m2.m[0][2];
- m.m[0][3] = m1.m[0][3] - m2.m[0][3];
- m.m[1][0] = m1.m[1][0] - m2.m[1][0];
- m.m[1][1] = m1.m[1][1] - m2.m[1][1];
- m.m[1][2] = m1.m[1][2] - m2.m[1][2];
- m.m[1][3] = m1.m[1][3] - m2.m[1][3];
- m.m[2][0] = m1.m[2][0] - m2.m[2][0];
- m.m[2][1] = m1.m[2][1] - m2.m[2][1];
- m.m[2][2] = m1.m[2][2] - m2.m[2][2];
- m.m[2][3] = m1.m[2][3] - m2.m[2][3];
- m.m[3][0] = m1.m[3][0] - m2.m[3][0];
- m.m[3][1] = m1.m[3][1] - m2.m[3][1];
- m.m[3][2] = m1.m[3][2] - m2.m[3][2];
- m.m[3][3] = m1.m[3][3] - m2.m[3][3];
- m.flagBits = QDoubleMatrix4x4::General;
- return m;
-}
-
-inline QDoubleMatrix4x4 operator*(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2)
-{
- int flagBits = m1.flagBits | m2.flagBits;
- if (flagBits < QDoubleMatrix4x4::Rotation2D) {
- QDoubleMatrix4x4 m = m1;
- m.m[3][0] += m.m[0][0] * m2.m[3][0];
- m.m[3][1] += m.m[1][1] * m2.m[3][1];
- m.m[3][2] += m.m[2][2] * m2.m[3][2];
-
- m.m[0][0] *= m2.m[0][0];
- m.m[1][1] *= m2.m[1][1];
- m.m[2][2] *= m2.m[2][2];
- m.flagBits = flagBits;
- return m;
- }
-
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = m1.m[0][0] * m2.m[0][0]
- + m1.m[1][0] * m2.m[0][1]
- + m1.m[2][0] * m2.m[0][2]
- + m1.m[3][0] * m2.m[0][3];
- m.m[0][1] = m1.m[0][1] * m2.m[0][0]
- + m1.m[1][1] * m2.m[0][1]
- + m1.m[2][1] * m2.m[0][2]
- + m1.m[3][1] * m2.m[0][3];
- m.m[0][2] = m1.m[0][2] * m2.m[0][0]
- + m1.m[1][2] * m2.m[0][1]
- + m1.m[2][2] * m2.m[0][2]
- + m1.m[3][2] * m2.m[0][3];
- m.m[0][3] = m1.m[0][3] * m2.m[0][0]
- + m1.m[1][3] * m2.m[0][1]
- + m1.m[2][3] * m2.m[0][2]
- + m1.m[3][3] * m2.m[0][3];
-
- m.m[1][0] = m1.m[0][0] * m2.m[1][0]
- + m1.m[1][0] * m2.m[1][1]
- + m1.m[2][0] * m2.m[1][2]
- + m1.m[3][0] * m2.m[1][3];
- m.m[1][1] = m1.m[0][1] * m2.m[1][0]
- + m1.m[1][1] * m2.m[1][1]
- + m1.m[2][1] * m2.m[1][2]
- + m1.m[3][1] * m2.m[1][3];
- m.m[1][2] = m1.m[0][2] * m2.m[1][0]
- + m1.m[1][2] * m2.m[1][1]
- + m1.m[2][2] * m2.m[1][2]
- + m1.m[3][2] * m2.m[1][3];
- m.m[1][3] = m1.m[0][3] * m2.m[1][0]
- + m1.m[1][3] * m2.m[1][1]
- + m1.m[2][3] * m2.m[1][2]
- + m1.m[3][3] * m2.m[1][3];
-
- m.m[2][0] = m1.m[0][0] * m2.m[2][0]
- + m1.m[1][0] * m2.m[2][1]
- + m1.m[2][0] * m2.m[2][2]
- + m1.m[3][0] * m2.m[2][3];
- m.m[2][1] = m1.m[0][1] * m2.m[2][0]
- + m1.m[1][1] * m2.m[2][1]
- + m1.m[2][1] * m2.m[2][2]
- + m1.m[3][1] * m2.m[2][3];
- m.m[2][2] = m1.m[0][2] * m2.m[2][0]
- + m1.m[1][2] * m2.m[2][1]
- + m1.m[2][2] * m2.m[2][2]
- + m1.m[3][2] * m2.m[2][3];
- m.m[2][3] = m1.m[0][3] * m2.m[2][0]
- + m1.m[1][3] * m2.m[2][1]
- + m1.m[2][3] * m2.m[2][2]
- + m1.m[3][3] * m2.m[2][3];
-
- m.m[3][0] = m1.m[0][0] * m2.m[3][0]
- + m1.m[1][0] * m2.m[3][1]
- + m1.m[2][0] * m2.m[3][2]
- + m1.m[3][0] * m2.m[3][3];
- m.m[3][1] = m1.m[0][1] * m2.m[3][0]
- + m1.m[1][1] * m2.m[3][1]
- + m1.m[2][1] * m2.m[3][2]
- + m1.m[3][1] * m2.m[3][3];
- m.m[3][2] = m1.m[0][2] * m2.m[3][0]
- + m1.m[1][2] * m2.m[3][1]
- + m1.m[2][2] * m2.m[3][2]
- + m1.m[3][2] * m2.m[3][3];
- m.m[3][3] = m1.m[0][3] * m2.m[3][0]
- + m1.m[1][3] * m2.m[3][1]
- + m1.m[2][3] * m2.m[3][2]
- + m1.m[3][3] * m2.m[3][3];
- m.flagBits = flagBits;
- return m;
-}
-
-inline QDoubleVector3D operator*(const QDoubleVector3D& vector, const QDoubleMatrix4x4& matrix)
-{
- double x, y, z, w;
- x = vector.x() * matrix.m[0][0] +
- vector.y() * matrix.m[0][1] +
- vector.z() * matrix.m[0][2] +
- matrix.m[0][3];
- y = vector.x() * matrix.m[1][0] +
- vector.y() * matrix.m[1][1] +
- vector.z() * matrix.m[1][2] +
- matrix.m[1][3];
- z = vector.x() * matrix.m[2][0] +
- vector.y() * matrix.m[2][1] +
- vector.z() * matrix.m[2][2] +
- matrix.m[2][3];
- w = vector.x() * matrix.m[3][0] +
- vector.y() * matrix.m[3][1] +
- vector.z() * matrix.m[3][2] +
- matrix.m[3][3];
- if (w == 1.0f)
- return QDoubleVector3D(x, y, z);
- else
- return QDoubleVector3D(x / w, y / w, z / w);
-}
-
-inline QDoubleVector3D operator*(const QDoubleMatrix4x4& matrix, const QDoubleVector3D& vector)
-{
- double x, y, z, w;
- if (matrix.flagBits == QDoubleMatrix4x4::Identity) {
- return vector;
- } else if (matrix.flagBits < QDoubleMatrix4x4::Rotation2D) {
- // Translation | Scale
- return QDoubleVector3D(vector.x() * matrix.m[0][0] + matrix.m[3][0],
- vector.y() * matrix.m[1][1] + matrix.m[3][1],
- vector.z() * matrix.m[2][2] + matrix.m[3][2]);
- } else if (matrix.flagBits < QDoubleMatrix4x4::Rotation) {
- // Translation | Scale | Rotation2D
- return QDoubleVector3D(vector.x() * matrix.m[0][0] + vector.y() * matrix.m[1][0] + matrix.m[3][0],
- vector.x() * matrix.m[0][1] + vector.y() * matrix.m[1][1] + matrix.m[3][1],
- vector.z() * matrix.m[2][2] + matrix.m[3][2]);
- } else {
- x = vector.x() * matrix.m[0][0] +
- vector.y() * matrix.m[1][0] +
- vector.z() * matrix.m[2][0] +
- matrix.m[3][0];
- y = vector.x() * matrix.m[0][1] +
- vector.y() * matrix.m[1][1] +
- vector.z() * matrix.m[2][1] +
- matrix.m[3][1];
- z = vector.x() * matrix.m[0][2] +
- vector.y() * matrix.m[1][2] +
- vector.z() * matrix.m[2][2] +
- matrix.m[3][2];
- w = vector.x() * matrix.m[0][3] +
- vector.y() * matrix.m[1][3] +
- vector.z() * matrix.m[2][3] +
- matrix.m[3][3];
- if (w == 1.0f)
- return QDoubleVector3D(x, y, z);
- else
- return QDoubleVector3D(x / w, y / w, z / w);
- }
-}
-
-inline QPoint operator*(const QPoint& point, const QDoubleMatrix4x4& matrix)
-{
- double xin, yin;
- double x, y, w;
- xin = point.x();
- yin = point.y();
- x = xin * matrix.m[0][0] +
- yin * matrix.m[0][1] +
- matrix.m[0][3];
- y = xin * matrix.m[1][0] +
- yin * matrix.m[1][1] +
- matrix.m[1][3];
- w = xin * matrix.m[3][0] +
- yin * matrix.m[3][1] +
- matrix.m[3][3];
- if (w == 1.0f)
- return QPoint(qRound(x), qRound(y));
- else
- return QPoint(qRound(x / w), qRound(y / w));
-}
-
-inline QPointF operator*(const QPointF& point, const QDoubleMatrix4x4& matrix)
-{
- double xin, yin;
- double x, y, w;
- xin = point.x();
- yin = point.y();
- x = xin * matrix.m[0][0] +
- yin * matrix.m[0][1] +
- matrix.m[0][3];
- y = xin * matrix.m[1][0] +
- yin * matrix.m[1][1] +
- matrix.m[1][3];
- w = xin * matrix.m[3][0] +
- yin * matrix.m[3][1] +
- matrix.m[3][3];
- if (w == 1.0f) {
- return QPointF(double(x), double(y));
- } else {
- return QPointF(double(x / w), double(y / w));
- }
-}
-
-inline QPoint operator*(const QDoubleMatrix4x4& matrix, const QPoint& point)
-{
- double xin, yin;
- double x, y, w;
- xin = point.x();
- yin = point.y();
- if (matrix.flagBits == QDoubleMatrix4x4::Identity) {
- return point;
- } else if (matrix.flagBits < QDoubleMatrix4x4::Rotation2D) {
- // Translation | Scale
- return QPoint(qRound(xin * matrix.m[0][0] + matrix.m[3][0]),
- qRound(yin * matrix.m[1][1] + matrix.m[3][1]));
- } else if (matrix.flagBits < QDoubleMatrix4x4::Perspective) {
- return QPoint(qRound(xin * matrix.m[0][0] + yin * matrix.m[1][0] + matrix.m[3][0]),
- qRound(xin * matrix.m[0][1] + yin * matrix.m[1][1] + matrix.m[3][1]));
- } else {
- x = xin * matrix.m[0][0] +
- yin * matrix.m[1][0] +
- matrix.m[3][0];
- y = xin * matrix.m[0][1] +
- yin * matrix.m[1][1] +
- matrix.m[3][1];
- w = xin * matrix.m[0][3] +
- yin * matrix.m[1][3] +
- matrix.m[3][3];
- if (w == 1.0f)
- return QPoint(qRound(x), qRound(y));
- else
- return QPoint(qRound(x / w), qRound(y / w));
- }
-}
-
-inline QPointF operator*(const QDoubleMatrix4x4& matrix, const QPointF& point)
-{
- double xin, yin;
- double x, y, w;
- xin = point.x();
- yin = point.y();
- if (matrix.flagBits == QDoubleMatrix4x4::Identity) {
- return point;
- } else if (matrix.flagBits < QDoubleMatrix4x4::Rotation2D) {
- // Translation | Scale
- return QPointF(xin * matrix.m[0][0] + matrix.m[3][0],
- yin * matrix.m[1][1] + matrix.m[3][1]);
- } else if (matrix.flagBits < QDoubleMatrix4x4::Perspective) {
- return QPointF(xin * matrix.m[0][0] + yin * matrix.m[1][0] + matrix.m[3][0],
- xin * matrix.m[0][1] + yin * matrix.m[1][1] + matrix.m[3][1]);
- } else {
- x = xin * matrix.m[0][0] +
- yin * matrix.m[1][0] +
- matrix.m[3][0];
- y = xin * matrix.m[0][1] +
- yin * matrix.m[1][1] +
- matrix.m[3][1];
- w = xin * matrix.m[0][3] +
- yin * matrix.m[1][3] +
- matrix.m[3][3];
- if (w == 1.0f) {
- return QPointF(double(x), double(y));
- } else {
- return QPointF(double(x / w), double(y / w));
- }
- }
-}
-
-inline QDoubleMatrix4x4 operator-(const QDoubleMatrix4x4& matrix)
-{
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = -matrix.m[0][0];
- m.m[0][1] = -matrix.m[0][1];
- m.m[0][2] = -matrix.m[0][2];
- m.m[0][3] = -matrix.m[0][3];
- m.m[1][0] = -matrix.m[1][0];
- m.m[1][1] = -matrix.m[1][1];
- m.m[1][2] = -matrix.m[1][2];
- m.m[1][3] = -matrix.m[1][3];
- m.m[2][0] = -matrix.m[2][0];
- m.m[2][1] = -matrix.m[2][1];
- m.m[2][2] = -matrix.m[2][2];
- m.m[2][3] = -matrix.m[2][3];
- m.m[3][0] = -matrix.m[3][0];
- m.m[3][1] = -matrix.m[3][1];
- m.m[3][2] = -matrix.m[3][2];
- m.m[3][3] = -matrix.m[3][3];
- m.flagBits = QDoubleMatrix4x4::General;
- return m;
-}
-
-inline QDoubleMatrix4x4 operator*(double factor, const QDoubleMatrix4x4& matrix)
-{
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = matrix.m[0][0] * factor;
- m.m[0][1] = matrix.m[0][1] * factor;
- m.m[0][2] = matrix.m[0][2] * factor;
- m.m[0][3] = matrix.m[0][3] * factor;
- m.m[1][0] = matrix.m[1][0] * factor;
- m.m[1][1] = matrix.m[1][1] * factor;
- m.m[1][2] = matrix.m[1][2] * factor;
- m.m[1][3] = matrix.m[1][3] * factor;
- m.m[2][0] = matrix.m[2][0] * factor;
- m.m[2][1] = matrix.m[2][1] * factor;
- m.m[2][2] = matrix.m[2][2] * factor;
- m.m[2][3] = matrix.m[2][3] * factor;
- m.m[3][0] = matrix.m[3][0] * factor;
- m.m[3][1] = matrix.m[3][1] * factor;
- m.m[3][2] = matrix.m[3][2] * factor;
- m.m[3][3] = matrix.m[3][3] * factor;
- m.flagBits = QDoubleMatrix4x4::General;
- return m;
-}
-
-inline QDoubleMatrix4x4 operator*(const QDoubleMatrix4x4& matrix, double factor)
-{
- QDoubleMatrix4x4 m(1);
- m.m[0][0] = matrix.m[0][0] * factor;
- m.m[0][1] = matrix.m[0][1] * factor;
- m.m[0][2] = matrix.m[0][2] * factor;
- m.m[0][3] = matrix.m[0][3] * factor;
- m.m[1][0] = matrix.m[1][0] * factor;
- m.m[1][1] = matrix.m[1][1] * factor;
- m.m[1][2] = matrix.m[1][2] * factor;
- m.m[1][3] = matrix.m[1][3] * factor;
- m.m[2][0] = matrix.m[2][0] * factor;
- m.m[2][1] = matrix.m[2][1] * factor;
- m.m[2][2] = matrix.m[2][2] * factor;
- m.m[2][3] = matrix.m[2][3] * factor;
- m.m[3][0] = matrix.m[3][0] * factor;
- m.m[3][1] = matrix.m[3][1] * factor;
- m.m[3][2] = matrix.m[3][2] * factor;
- m.m[3][3] = matrix.m[3][3] * factor;
- m.flagBits = QDoubleMatrix4x4::General;
- return m;
-}
-
-inline bool qFuzzyCompare(const QDoubleMatrix4x4& m1, const QDoubleMatrix4x4& m2)
-{
- return qFuzzyCompare(m1.m[0][0], m2.m[0][0]) &&
- qFuzzyCompare(m1.m[0][1], m2.m[0][1]) &&
- qFuzzyCompare(m1.m[0][2], m2.m[0][2]) &&
- qFuzzyCompare(m1.m[0][3], m2.m[0][3]) &&
- qFuzzyCompare(m1.m[1][0], m2.m[1][0]) &&
- qFuzzyCompare(m1.m[1][1], m2.m[1][1]) &&
- qFuzzyCompare(m1.m[1][2], m2.m[1][2]) &&
- qFuzzyCompare(m1.m[1][3], m2.m[1][3]) &&
- qFuzzyCompare(m1.m[2][0], m2.m[2][0]) &&
- qFuzzyCompare(m1.m[2][1], m2.m[2][1]) &&
- qFuzzyCompare(m1.m[2][2], m2.m[2][2]) &&
- qFuzzyCompare(m1.m[2][3], m2.m[2][3]) &&
- qFuzzyCompare(m1.m[3][0], m2.m[3][0]) &&
- qFuzzyCompare(m1.m[3][1], m2.m[3][1]) &&
- qFuzzyCompare(m1.m[3][2], m2.m[3][2]) &&
- qFuzzyCompare(m1.m[3][3], m2.m[3][3]);
-}
-
-inline QPoint QDoubleMatrix4x4::map(const QPoint& point) const
-{
- return *this * point;
-}
-
-inline QPointF QDoubleMatrix4x4::map(const QPointF& point) const
-{
- return *this * point;
-}
-
-inline QDoubleVector3D QDoubleMatrix4x4::map(const QDoubleVector3D& point) const
-{
- return *this * point;
-}
-
-inline QDoubleVector3D QDoubleMatrix4x4::mapVector(const QDoubleVector3D& vector) const
-{
- if (flagBits < Scale) {
- // Translation
- return vector;
- } else if (flagBits < Rotation2D) {
- // Translation | Scale
- return QDoubleVector3D(vector.x() * m[0][0],
- vector.y() * m[1][1],
- vector.z() * m[2][2]);
- } else {
- return QDoubleVector3D(vector.x() * m[0][0] +
- vector.y() * m[1][0] +
- vector.z() * m[2][0],
- vector.x() * m[0][1] +
- vector.y() * m[1][1] +
- vector.z() * m[2][1],
- vector.x() * m[0][2] +
- vector.y() * m[1][2] +
- vector.z() * m[2][2]);
- }
-}
-
-inline double *QDoubleMatrix4x4::data()
-{
- // We have to assume that the caller will modify the matrix elements,
- // so we flip it over to "General" mode.
- flagBits = General;
- return *m;
-}
-
-inline void QDoubleMatrix4x4::viewport(const QRectF &rect)
-{
- viewport(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_POSITIONING_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QDoubleMatrix4x4 &m);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDoubleMatrix4x4 &);
-Q_POSITIONING_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDoubleMatrix4x4 &);
-#endif
-
-
-QT_END_NAMESPACE
-
-
-#endif // QDOUBLEMATRIX4X4_H
diff --git a/src/positioning/qdoublevector2d.cpp b/src/positioning/qdoublevector2d.cpp
deleted file mode 100644
index c18f2366..00000000
--- a/src/positioning/qdoublevector2d.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
-#include <QtCore/qdatastream.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-QDoubleVector2D::QDoubleVector2D(const QDoubleVector3D &vector) :
- xp(vector.xp), yp(vector.yp)
-{
-}
-
-double QDoubleVector2D::length() const
-{
- return qSqrt(xp * xp + yp * yp);
-}
-
-QDoubleVector2D QDoubleVector2D::normalized() const
-{
- // Need some extra precision if the length is very small.
- double len = double(xp) * double(xp) +
- double(yp) * double(yp);
- if (qFuzzyIsNull(len - 1.0))
- return *this;
- else if (!qFuzzyIsNull(len))
- return *this / (double)qSqrt(len);
- else
- return QDoubleVector2D();
-}
-
-void QDoubleVector2D::normalize()
-{
- // Need some extra precision if the length is very small.
- double len = double(xp) * double(xp) +
- double(yp) * double(yp);
- if (qFuzzyIsNull(len - 1.0) || qFuzzyIsNull(len))
- return;
-
- len = qSqrt(len);
-
- xp /= len;
- yp /= len;
-}
-
-QDoubleVector3D QDoubleVector2D::toVector3D() const
-{
- return QDoubleVector3D(xp, yp, 0.0);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QDoubleVector2D &vector)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "QDoubleVector2D(" << vector.x() << ", " << vector.y() << ')';
- return dbg;
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-QDataStream &operator<<(QDataStream &stream, const QDoubleVector2D &vector)
-{
- stream << double(vector.x()) << double(vector.y());
- return stream;
-}
-
-QDataStream &operator>>(QDataStream &stream, QDoubleVector2D &vector)
-{
- double x, y;
- stream >> x;
- stream >> y;
- vector.setX(double(x));
- vector.setY(double(y));
- return stream;
-}
-
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qdoublevector2d_p.h b/src/positioning/qdoublevector2d_p.h
deleted file mode 100644
index a692e190..00000000
--- a/src/positioning/qdoublevector2d_p.h
+++ /dev/null
@@ -1,262 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDOUBLEVECTOR2D_P_H
-#define QDOUBLEVECTOR2D_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#ifdef QT_BUILD_LOCATION_LIB
-#include <QVector2D>
-#endif
-
-#include "qpositioningglobal_p.h"
-#include <QtCore/qmetatype.h>
-#include <QPointF>
-
-QT_BEGIN_NAMESPACE
-
-class QDoubleVector3D;
-
-class Q_POSITIONING_PRIVATE_EXPORT QDoubleVector2D
-{
-public:
- Q_DECL_CONSTEXPR inline QDoubleVector2D();
- Q_DECL_CONSTEXPR inline QDoubleVector2D(double xpos, double ypos);
- Q_DECL_CONSTEXPR explicit inline QDoubleVector2D(const QPointF &p);
- explicit QDoubleVector2D(const QDoubleVector3D &vector);
-
- Q_DECL_CONSTEXPR inline double manhattanLength() const;
- inline bool isNull() const;
- inline bool isFinite() const;
-
- Q_DECL_CONSTEXPR inline double x() const;
- Q_DECL_CONSTEXPR inline double y() const;
-
- inline void setX(double x);
- inline void setY(double y);
-
- double length() const;
- Q_DECL_CONSTEXPR inline double lengthSquared() const;
-
- QDoubleVector2D normalized() const;
- void normalize();
-
- inline QDoubleVector2D &operator+=(const QDoubleVector2D &vector);
- inline QDoubleVector2D &operator-=(const QDoubleVector2D &vector);
- inline QDoubleVector2D &operator*=(double factor);
- inline QDoubleVector2D &operator*=(const QDoubleVector2D &vector);
- inline QDoubleVector2D &operator/=(double divisor);
- inline QDoubleVector2D &operator/=(const QDoubleVector2D &vector);
-
- Q_DECL_CONSTEXPR static inline double dotProduct(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
- { return v1.xp * v2.xp + v1.yp * v2.yp; }
-
-
- friend Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &vector);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor);
-
- friend Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2);
-
- QDoubleVector3D toVector3D() const;
- Q_DECL_CONSTEXPR inline QPointF toPointF() const;
-
-private:
- double xp, yp;
-
- friend class QDoubleVector3D;
-};
-
-Q_DECLARE_TYPEINFO(QDoubleVector2D, Q_RELOCATABLE_TYPE);
-
-Q_DECL_CONSTEXPR inline QDoubleVector2D::QDoubleVector2D() : xp(0.0), yp(0.0) {}
-
-Q_DECL_CONSTEXPR inline QDoubleVector2D::QDoubleVector2D(double xpos, double ypos) : xp(xpos), yp(ypos) {}
-
-Q_DECL_CONSTEXPR inline QDoubleVector2D::QDoubleVector2D(const QPointF &p) : xp(p.x()), yp(p.y()) { }
-
-Q_DECL_CONSTEXPR inline double QDoubleVector2D::manhattanLength() const
-{
- return qAbs(x())+qAbs(y());
-}
-
-inline bool QDoubleVector2D::isNull() const
-{
- return qIsNull(xp) && qIsNull(yp);
-}
-
-inline bool QDoubleVector2D::isFinite() const
-{
- return qIsFinite(xp) && qIsFinite(yp);
-}
-
-Q_DECL_CONSTEXPR inline double QDoubleVector2D::x() const { return xp; }
-Q_DECL_CONSTEXPR inline double QDoubleVector2D::y() const { return yp; }
-
-inline void QDoubleVector2D::setX(double aX) { xp = aX; }
-inline void QDoubleVector2D::setY(double aY) { yp = aY; }
-
-Q_DECL_CONSTEXPR inline double QDoubleVector2D::lengthSquared() const
-{ return xp * xp + yp * yp; }
-
-inline QDoubleVector2D &QDoubleVector2D::operator+=(const QDoubleVector2D &vector)
-{
- xp += vector.xp;
- yp += vector.yp;
- return *this;
-}
-
-inline QDoubleVector2D &QDoubleVector2D::operator-=(const QDoubleVector2D &vector)
-{
- xp -= vector.xp;
- yp -= vector.yp;
- return *this;
-}
-
-inline QDoubleVector2D &QDoubleVector2D::operator*=(double factor)
-{
- xp *= factor;
- yp *= factor;
- return *this;
-}
-
-inline QDoubleVector2D &QDoubleVector2D::operator*=(const QDoubleVector2D &vector)
-{
- xp *= vector.xp;
- yp *= vector.yp;
- return *this;
-}
-
-inline QDoubleVector2D &QDoubleVector2D::operator/=(double divisor)
-{
- xp /= divisor;
- yp /= divisor;
- return *this;
-}
-
-inline QDoubleVector2D &QDoubleVector2D::operator/=(const QDoubleVector2D &vector)
-{
- xp /= vector.xp;
- yp /= vector.yp;
- return *this;
-}
-
-Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
-{
- return v1.xp == v2.xp && v1.yp == v2.yp;
-}
-
-Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
-{
- return v1.xp != v2.xp || v1.yp != v2.yp;
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector2D operator+(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
-{
- return QDoubleVector2D(v1.xp + v2.xp, v1.yp + v2.yp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
-{
- return QDoubleVector2D(v1.xp - v2.xp, v1.yp - v2.yp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(double factor, const QDoubleVector2D &vector)
-{
- return QDoubleVector2D(vector.xp * factor, vector.yp * factor);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &vector, double factor)
-{
- return QDoubleVector2D(vector.xp * factor, vector.yp * factor);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector2D operator*(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
-{
- return QDoubleVector2D(v1.xp * v2.xp, v1.yp * v2.yp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector2D operator-(const QDoubleVector2D &vector)
-{
- return QDoubleVector2D(-vector.xp, -vector.yp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector2D operator/(const QDoubleVector2D &vector, double divisor)
-{
- return QDoubleVector2D(vector.xp / divisor, vector.yp / divisor);
-}
-
-Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector2D &v1, const QDoubleVector2D &v2)
-{
- return qFuzzyCompare(v1.xp, v2.xp) && qFuzzyCompare(v1.yp, v2.yp);
-}
-
-Q_DECL_CONSTEXPR inline QPointF QDoubleVector2D::toPointF() const
-{
- return QPointF(qreal(xp), qreal(yp));
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_POSITIONING_EXPORT QDebug operator<<(QDebug dbg, const QDoubleVector2D &vector);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_POSITIONING_EXPORT QDataStream &operator<<(QDataStream &, const QDoubleVector2D &);
-Q_POSITIONING_EXPORT QDataStream &operator>>(QDataStream &, QDoubleVector2D &);
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qdoublevector3d.cpp b/src/positioning/qdoublevector3d.cpp
deleted file mode 100644
index b308084b..00000000
--- a/src/positioning/qdoublevector3d.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdoublevector3d_p.h"
-#include <QtCore/qdatastream.h>
-#include <QtCore/qmath.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QDoubleVector3D QDoubleVector3D::normalized() const
-{
- // Need some extra precision if the length is very small.
- double len = double(xp) * double(xp) +
- double(yp) * double(yp) +
- double(zp) * double(zp);
- if (qFuzzyIsNull(len - 1.0))
- return *this;
- else if (!qFuzzyIsNull(len))
- return *this / (double)qSqrt(len);
- else
- return QDoubleVector3D();
-}
-
-void QDoubleVector3D::normalize()
-{
- // Need some extra precision if the length is very small.
- double len = double(xp) * double(xp) +
- double(yp) * double(yp) +
- double(zp) * double(zp);
- if (qFuzzyIsNull(len - 1.0) || qFuzzyIsNull(len))
- return;
-
- len = qSqrt(len);
-
- xp /= len;
- yp /= len;
- zp /= len;
-}
-
-QDoubleVector3D QDoubleVector3D::normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return crossProduct(v1, v2).normalized();
-}
-
-QDoubleVector3D QDoubleVector3D::normal
- (const QDoubleVector3D &v1, const QDoubleVector3D &v2, const QDoubleVector3D &v3)
-{
- return crossProduct((v2 - v1), (v3 - v1)).normalized();
-}
-
-double QDoubleVector3D::distanceToPlane
- (const QDoubleVector3D &plane1, const QDoubleVector3D &plane2, const QDoubleVector3D &plane3) const
-{
- QDoubleVector3D n = normal(plane2 - plane1, plane3 - plane1);
- return dotProduct(*this - plane1, n);
-}
-
-double QDoubleVector3D::distanceToLine
- (const QDoubleVector3D &point, const QDoubleVector3D &direction) const
-{
- if (direction.isNull())
- return (*this - point).length();
- QDoubleVector3D p = point + dotProduct(*this - point, direction) * direction;
- return (*this - p).length();
-}
-
-double QDoubleVector3D::length() const
-{
- return qSqrt(xp * xp + yp * yp + zp * zp);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-
-QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "QDoubleVector3D("
- << vector.x() << ", " << vector.y() << ", " << vector.z() << ')';
- return dbg;
-}
-
-#endif
-
-#ifndef QT_NO_DATASTREAM
-
-QDataStream &operator<<(QDataStream &stream, const QDoubleVector3D &vector)
-{
- stream << double(vector.x()) << double(vector.y())
- << double(vector.z());
- return stream;
-}
-
-QDataStream &operator>>(QDataStream &stream, QDoubleVector3D &vector)
-{
- double x, y, z;
- stream >> x;
- stream >> y;
- stream >> z;
- vector.setX(double(x));
- vector.setY(double(y));
- vector.setZ(double(z));
- return stream;
-}
-
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qdoublevector3d_p.h b/src/positioning/qdoublevector3d_p.h
deleted file mode 100644
index 3b4503aa..00000000
--- a/src/positioning/qdoublevector3d_p.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDOUBLEVECTOR3D_P_H
-#define QDOUBLEVECTOR3D_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#ifdef QT_BUILD_LOCATION_LIB
-#include <QVector3D>
-#endif
-
-#include "qpositioningglobal_p.h"
-#include "qdoublevector2d_p.h"
-#include <QtCore/qmetatype.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONING_PRIVATE_EXPORT QDoubleVector3D
-{
-public:
- Q_DECL_CONSTEXPR inline QDoubleVector3D();
- Q_DECL_CONSTEXPR inline QDoubleVector3D(double xpos, double ypos, double zpos);
- Q_DECL_CONSTEXPR inline QDoubleVector3D(const QDoubleVector2D &vector);
- Q_DECL_CONSTEXPR inline QDoubleVector3D(const QDoubleVector2D &vector, double zpos);
-
- inline bool isNull() const;
-
- Q_DECL_CONSTEXPR inline double x() const;
- Q_DECL_CONSTEXPR inline double y() const;
- Q_DECL_CONSTEXPR inline double z() const;
-
- inline void setX(double x);
- inline void setY(double y);
- inline void setZ(double z);
-
- inline double get(int i) const;
- inline void set(int i, double value);
-
- double length() const;
- Q_DECL_CONSTEXPR inline double lengthSquared() const;
-
- QDoubleVector3D normalized() const;
- void normalize();
-
- inline QDoubleVector3D &operator+=(const QDoubleVector3D &vector);
- inline QDoubleVector3D &operator-=(const QDoubleVector3D &vector);
- inline QDoubleVector3D &operator*=(double factor);
- inline QDoubleVector3D &operator*=(const QDoubleVector3D &vector);
- inline QDoubleVector3D &operator/=(double divisor);
-
- Q_DECL_CONSTEXPR static inline double dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
- { return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp; }
-
- Q_DECL_CONSTEXPR static inline QDoubleVector3D crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
- { return QDoubleVector3D(v1.yp * v2.zp - v1.zp * v2.yp,
- v1.zp * v2.xp - v1.xp * v2.zp,
- v1.xp * v2.yp - v1.yp * v2.xp); }
-
- static QDoubleVector3D normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- static QDoubleVector3D normal
- (const QDoubleVector3D &v1, const QDoubleVector3D &v2, const QDoubleVector3D &v3);
-
- double distanceToPlane(const QDoubleVector3D &plane, const QDoubleVector3D &normal) const;
- double distanceToPlane(const QDoubleVector3D &plane1, const QDoubleVector3D &plane2, const QDoubleVector3D &plane3) const;
- double distanceToLine(const QDoubleVector3D &point, const QDoubleVector3D &direction) const;
-
- friend Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &vector);
- friend Q_DECL_CONSTEXPR inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor);
-
- friend Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2);
-
- Q_DECL_CONSTEXPR inline QDoubleVector2D toVector2D() const;
-
-private:
- double xp, yp, zp;
-
- friend class QDoubleVector2D;
-};
-
-Q_DECLARE_TYPEINFO(QDoubleVector3D, Q_RELOCATABLE_TYPE);
-
-Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D() : xp(0.0), yp(0.0), zp(0.0) {}
-
-Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D(double xpos, double ypos, double zpos) : xp(xpos), yp(ypos), zp(zpos) {}
-
-Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &v)
- : xp(v.xp), yp(v.yp), zp(0.0) {}
-
-Q_DECL_CONSTEXPR inline QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &v, double zpos)
- : xp(v.xp), yp(v.yp), zp(zpos) {}
-
-inline bool QDoubleVector3D::isNull() const
-{
- return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
-}
-
-Q_DECL_CONSTEXPR inline double QDoubleVector3D::x() const { return xp; }
-Q_DECL_CONSTEXPR inline double QDoubleVector3D::y() const { return yp; }
-Q_DECL_CONSTEXPR inline double QDoubleVector3D::z() const { return zp; }
-
-Q_DECL_CONSTEXPR inline double QDoubleVector3D::lengthSquared() const
-{ return xp * xp + yp * yp + zp * zp; }
-
-
-inline void QDoubleVector3D::setX(double aX) { xp = aX; }
-inline void QDoubleVector3D::setY(double aY) { yp = aY; }
-inline void QDoubleVector3D::setZ(double aZ) { zp = aZ; }
-
-inline double QDoubleVector3D::get(int i) const
-{
- switch (i) {
- case 0:
- return xp;
- case 1:
- return yp;
- case 2:
- return zp;
- default:
- return 0.0;
- }
-}
-
-inline void QDoubleVector3D::set(int i, double value)
-{
- switch (i) {
- case 0:
- xp = value;
- break;
- case 1:
- yp = value;
- break;
- case 2:
- zp = value;
- break;
- default:
- break;
- }
-}
-
-inline QDoubleVector3D &QDoubleVector3D::operator+=(const QDoubleVector3D &vector)
-{
- xp += vector.xp;
- yp += vector.yp;
- zp += vector.zp;
- return *this;
-}
-
-inline QDoubleVector3D &QDoubleVector3D::operator-=(const QDoubleVector3D &vector)
-{
- xp -= vector.xp;
- yp -= vector.yp;
- zp -= vector.zp;
- return *this;
-}
-
-inline QDoubleVector3D &QDoubleVector3D::operator*=(double factor)
-{
- xp *= factor;
- yp *= factor;
- zp *= factor;
- return *this;
-}
-
-inline QDoubleVector3D &QDoubleVector3D::operator*=(const QDoubleVector3D &vector)
-{
- xp *= vector.xp;
- yp *= vector.yp;
- zp *= vector.zp;
- return *this;
-}
-
-inline QDoubleVector3D &QDoubleVector3D::operator/=(double divisor)
-{
- xp /= divisor;
- yp /= divisor;
- zp /= divisor;
- return *this;
-}
-
-Q_DECL_CONSTEXPR inline bool operator==(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp;
-}
-
-Q_DECL_CONSTEXPR inline bool operator!=(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp;
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector3D operator+(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return QDoubleVector3D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return QDoubleVector3D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(double factor, const QDoubleVector3D &vector)
-{
- return QDoubleVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &vector, double factor)
-{
- return QDoubleVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector3D operator*(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return QDoubleVector3D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector3D operator-(const QDoubleVector3D &vector)
-{
- return QDoubleVector3D(-vector.xp, -vector.yp, -vector.zp);
-}
-
-Q_DECL_CONSTEXPR inline const QDoubleVector3D operator/(const QDoubleVector3D &vector, double divisor)
-{
- return QDoubleVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor);
-}
-
-Q_DECL_CONSTEXPR inline bool qFuzzyCompare(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return qFuzzyCompare(v1.xp, v2.xp) &&
- qFuzzyCompare(v1.yp, v2.yp) &&
- qFuzzyCompare(v1.zp, v2.zp);
-}
-
-Q_DECL_CONSTEXPR inline QDoubleVector2D QDoubleVector3D::toVector2D() const
-{
- return QDoubleVector2D(xp, yp);
-}
-
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_POSITIONING_EXPORT QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector);
-#endif
-
-#ifndef QT_NO_DATASTREAM
-Q_POSITIONING_EXPORT QDataStream &operator<<(QDataStream &, const QDoubleVector3D &);
-Q_POSITIONING_EXPORT QDataStream &operator>>(QDataStream &, QDoubleVector3D &);
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeoaddress.cpp b/src/positioning/qgeoaddress.cpp
deleted file mode 100644
index 9d00c769..00000000
--- a/src/positioning/qgeoaddress.cpp
+++ /dev/null
@@ -1,776 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeoaddress.h"
-#include "qgeoaddress_p.h"
-
-#include <QtCore/QStringList>
-
-#ifdef QGEOADDRESS_DEBUG
-#include <QDebug>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*
- Combines a list of address parts into a single line.
-
- The parts parameter contains both address elements such as city, state and so on
- as well as separators such as spaces and commas.
-
- It is expected that an element is always followed by a separator and the last
- sepator is usually a new line delimeter.
-
- For example: Springfield, 8900
- would have four parts
- ["Springfield", ", ", "8900", "<br>"]
-
- The addressLine takes care of putting in separators appropriately or leaving
- them out depending on whether the adjacent elements are present or not.
- For example if city were empty in the above scenario the returned string is "8900<br>"
- If the postal code was empty, returned string is "Springfield<br>"
- If both city and postal code were empty, the returned string is "".
-*/
-static QString addressLine(const QStringList &parts)
-{
- QString line;
- Q_ASSERT(parts.count() % 2 == 0);
-
- //iterate until just before the last pair
- QString penultimateSeparator;
- for (int i = 0; i < parts.count() - 2; i += 2) {
- if (!parts.at(i).isEmpty()) {
- line.append(parts.at(i) + parts.at(i + 1));
- penultimateSeparator = parts.at(i + 1);
- }
- }
-
- if (parts.at(parts.count() - 2).isEmpty()) {
- line.chop(penultimateSeparator.length());
-
- if (!line.isEmpty())
- line.append(parts.at(parts.count() - 1));
- } else {
- line.append(parts.at(parts.count() - 2));
- line.append(parts.at(parts.count() - 1));
- }
-
- return line;
-}
-
-/*
- Returns a single formatted string representing the \a address. Lines of the address
- are delimited by \a newLine. By default lines are delimited by <br/>. The \l
- {QGeoAddress::countryCode} {countryCode} of the \a address determines the format of
- the resultant string.
-*/
-static QString formattedAddress(const QGeoAddress &address,
- const QString &newLine = QLatin1String("<br/>"))
-{
- const QString Comma(QStringLiteral(", "));
- const QString Dash(QStringLiteral("-"));
- const QString Space(QStringLiteral(" "));
-
- QString text;
-
- // We have 2 main approaches here:
- // 1. street number goes after street name
- // 2. street number goes before street name
- // We need to take it into account while generating the formatted address.
- // Currently these pages were used to check the formats:
- // https://en.wikipedia.org/wiki/Address
- // https://www.grcdi.nl/gsb/world%20address%20formats.html
- // We do not take into account such address extensions as apartment number,
- // because this is not what you can usually get from map providers (like
- // openstreetmap).
-
- if (address.countryCode() == QLatin1String("ALB")
- || address.countryCode() == QLatin1String("MTQ")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Comma
- << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("AND")
- || address.countryCode() == QLatin1String("AUT")
- || address.countryCode() == QLatin1String("GLP")
- || address.countryCode() == QLatin1String("ITA")
- || address.countryCode() == QLatin1String("RUS")
- || address.countryCode() == QLatin1String("SMR")
- || address.countryCode() == QLatin1String("VAT")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space
- << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- }else if (address.countryCode() == QLatin1String("FRA")
- || address.countryCode() == QLatin1String("GUF")
- || address.countryCode() == QLatin1String("LUX")
- || address.countryCode() == QLatin1String("MCO")
- || address.countryCode() == QLatin1String("REU")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space
- << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
-
- } else if (address.countryCode() == QLatin1String("ARE")
- || address.countryCode() == QLatin1String("BHS")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << Space
- << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("AUS")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << (address.district().isEmpty() ? address.city() : address.district())
- << Space << address.state() << Space << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("BHR")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << Comma
- << address.city() << Comma << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("BRA")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << Space
- << address.city() << Dash << address.state() << Space << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("BRN")
- || address.countryCode() == QLatin1String("JOR")
- || address.countryCode() == QLatin1String("LBN")
- || address.countryCode() == QLatin1String("NZL")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.district() << Space
- << address.city() << Space << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("CAN")
- || address.countryCode() == QLatin1String("USA")
- || address.countryCode() == QLatin1String("VIR")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.city() << Comma << address.state() << Space
- << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("CHN")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << Comma
- << address.city() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("CHL")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space
- << address.district() << Comma << address.city() << Comma
- << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("CYM")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.state() << Space
- << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("GBR")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.district() << Comma
- << address.city() << Comma << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("GIB")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("HKG")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.district() << newLine);
- text += addressLine(QStringList() << address.city() << newLine);
- } else if (address.countryCode() == QLatin1String("IND")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.city() << Space << address.postalCode() << Space
- << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("IDN")
- || address.countryCode() == QLatin1String("JEY")
- || address.countryCode() == QLatin1String("LVA")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.city() << Comma << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("IRL")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.district() << Comma << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("KWT")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Comma
- << address.district() << Comma << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("MLT")
- || address.countryCode() == QLatin1String("SGP")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.city() << Space << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("UKR")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.city() << Space << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("MEX")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space << address.city() << Comma
- << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("MYS")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space << address.city() << newLine);
- text += addressLine(QStringList() << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("OMN")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << newLine);
- text += addressLine(QStringList() << address.district() << Comma
- << address.postalCode() << Comma
- << address.city() << Comma
- << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("PRI")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << Comma << address.city() << Comma
- << address.state() << Comma << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("QAT")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << Space << address.city() << Comma
- << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("SAU")) {
- text += addressLine(QStringList() << address.streetNumber() << Space
- << address.street() << Space
- << address.district() << newLine);
- text += addressLine(QStringList() << address.city() << Space << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("TWN")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << Comma
- << address.district() << Comma
- << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("THA")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << Comma << address.city() << Space
- << address.postalCode() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("TUR")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space << address.district() << Comma
- << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("VEN")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.city() << Space << address.postalCode() << Comma
- << address.state() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else if (address.countryCode() == QLatin1String("ZAF")) {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.district() << Comma << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- } else {
- text += addressLine(QStringList() << address.street() << Space
- << address.streetNumber() << newLine);
- text += addressLine(QStringList() << address.postalCode() << Space << address.city() << newLine);
- text += addressLine(QStringList() << address.country() << newLine);
- }
-
- text.chop(newLine.length());
- return text;
-}
-
-QGeoAddressPrivate::QGeoAddressPrivate()
- : QSharedData(),
- m_autoGeneratedText(false)
-{
-}
-
-QGeoAddressPrivate::QGeoAddressPrivate(const QGeoAddressPrivate &other)
- : QSharedData(other),
- sCountry(other.sCountry),
- sCountryCode(other.sCountryCode),
- sState(other.sState),
- sCounty(other.sCounty),
- sCity(other.sCity),
- sDistrict(other.sDistrict),
- sStreet(other.sStreet),
- sStreetNumber(other.sStreetNumber),
- sPostalCode(other.sPostalCode),
- sText(other.sText),
- m_autoGeneratedText(false)
-{
-}
-
-QGeoAddressPrivate::~QGeoAddressPrivate()
-{
-}
-
-/*!
- \class QGeoAddress
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \ingroup QtLocation-places-data
- \ingroup QtLocation-places
- \since 5.2
-
- \brief The QGeoAddress class represents an address of a \l QGeoLocation.
-
- The address' attributes are normalized to US feature names and can be mapped
- to the local feature levels (for example State matches "Bundesland" in Germany).
-
- The address contains a \l text() for displaying purposes and additional
- properties to access the components of an address:
-
- \list
- \li QGeoAddress::country()
- \li QGeoAddress::countryCode()
- \li QGeoAddress::state()
- \li QGeoAddress::city()
- \li QGeoAddress::district()
- \li QGeoAddress::street()
- \li QGeoAddress::postalCode()
- \endlist
-*/
-
-/*!
- Default constructor.
-*/
-QGeoAddress::QGeoAddress()
- : d(new QGeoAddressPrivate)
-{
-}
-
-/*!
- Constructs a copy of \a other.
-*/
-QGeoAddress::QGeoAddress(const QGeoAddress &other)
- : d(other.d)
-{
-}
-
-/*!
- \fn QGeoAddress::QGeoAddress(QGeoAddress &&other) noexcept
- \since 6.2
-
- Constructs a geo address object by moving from \a other.
-
- \note The moved-from QGeoAddress object can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- \fn QGeoAddress &QGeoAddress::operator=(QGeoAddress &other)
- \since 6.2
-
- Move-assigns the \a other to this address and returns a reference to this
- address.
-
- \note The moved-from QGeoAddress object can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- Destroys this address.
-*/
-QGeoAddress::~QGeoAddress()
-{
-}
-
-QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoAddressPrivate)
-
-/*!
- Assigns the given \a address to this address and
- returns a reference to this address.
-*/
-QGeoAddress &QGeoAddress::operator=(const QGeoAddress & address)
-{
- if (this == &address)
- return *this;
-
- d = address.d;
- return *this;
-}
-
-/*!
- \fn bool QGeoAddress::operator==(const QGeoAddress &lhs, const QGeoAddress &rhs)
-
- Returns \c true if \a lhs address is equal to \a rhs, otherwise returns
- \c false.
-*/
-
-/*!
- \fn bool QGeoAddress::operator!=(const QGeoAddress &lhs, const QGeoAddress &rhs)
-
- Returns \c true if \a lhs address is not equal to \a rhs, otherwise returns
- \c false.
-*/
-
-/*!
- Returns the address as a single formatted string. It is the recommended string
- to use to display the address to the user. It typically takes the format of
- an address as found on an envelope, but this is not always necessarily the case.
-
- The address text is either automatically generated or explicitly assigned.
- This can be determined by checking \l {QGeoAddress::isTextGenerated()} {isTextGenerated}.
-
- If an empty string is provided to setText(), then isTextGenerated() will be set
- to \c true and text() will return a string which is locally formatted according to
- countryCode() and based on the elements of the address such as street, city and so on.
- Because the text string is generated from the address elements, a sequence
- of calls such as text(), setStreet(), text() may return different strings for each
- invocation of text().
-
- If a non-empty string is provided to setText(), then isTextGenerated() will be
- set to \c false and text() will always return the explicitly assigned string.
- Calls to modify other elements such as setStreet(), setCity() and so on will not
- affect the resultant string from text().
-*/
-QString QGeoAddress::text() const
-{
- if (d->sText.isEmpty())
- return formattedAddress(*this);
- else
- return d->sText;
-}
-
-/*!
- If \a text is not empty, explicitly assigns \a text as the string to be returned by
- text(). isTextGenerated() will return false.
-
- If \a text is empty, indicates that text() should be automatically generated
- from the address elements. isTextGenerated() will return true.
-*/
-void QGeoAddress::setText(const QString &text)
-{
- d->sText = text;
-}
-
-/*!
- Returns the country name.
-*/
-QString QGeoAddress::country() const
-{
- return d->sCountry;
-}
-
-/*!
- Sets the \a country name.
-*/
-void QGeoAddress::setCountry(const QString &country)
-{
- d->sCountry = country;
-}
-
-/*!
- Returns the country code according to ISO 3166-1 alpha-3
-*/
-QString QGeoAddress::countryCode() const
-{
- return d->sCountryCode;
-}
-
-/*!
- Sets the \a countryCode according to ISO 3166-1 alpha-3
-*/
-void QGeoAddress::setCountryCode(const QString &countryCode)
-{
- d->sCountryCode = countryCode;
-}
-
-/*!
- Returns the state. The state is considered the first subdivision below country.
-*/
-QString QGeoAddress::state() const
-{
- return d->sState;
-}
-
-/*!
- Sets the \a state.
-*/
-void QGeoAddress::setState(const QString &state)
-{
- d->sState = state;
-}
-
-/*!
- Returns the county. The county is considered the second subdivision below country.
-*/
-QString QGeoAddress::county() const
-{
- return d->sCounty;
-}
-
-/*!
- Sets the \a county.
-*/
-void QGeoAddress::setCounty(const QString &county)
-{
- d->sCounty = county;
-}
-
-/*!
- Returns the city.
-*/
-QString QGeoAddress::city() const
-{
- return d->sCity;
-}
-
-/*!
- Sets the \a city.
-*/
-void QGeoAddress::setCity(const QString &city)
-{
- d->sCity = city;
-}
-
-/*!
- Returns the district. The district is considered the subdivison below city.
-*/
-QString QGeoAddress::district() const
-{
- return d->sDistrict;
-}
-
-/*!
- Sets the \a district.
-*/
-void QGeoAddress::setDistrict(const QString &district)
-{
- d->sDistrict = district;
-}
-
-/*!
- Returns the street name.
-
- \note Before Qt6 this could also contain things like a unit number,
- a building name, or anything else that might be used to distinguish
- one address from another. Use streetNumber() to obtain this data now.
-
- \sa streetNumber()
-*/
-QString QGeoAddress::street() const
-{
- return d->sStreet;
-}
-
-/*!
- Sets the street name to \a street.
-
- \note Before Qt6 this could also contain things like a unit number,
- a building name, or anything else that might be used to distinguish
- one address from another. Use setStreetNumber() to set this data now.
-
- \sa setStreetNumber()
-*/
-void QGeoAddress::setStreet(const QString &street)
-{
- d->sStreet = street;
-}
-
-/*!
- \since 6.2
- Returns the street number.
-
- This may also contain things like a unit number, a building name, or
- anything else that might be used to distinguish one address from another.
-
- \note Before Qt6 this information was returned by street() method.
-
- \sa street()
-*/
-QString QGeoAddress::streetNumber() const
-{
- return d->sStreetNumber;
-}
-
-/*!
- \since 6.2
- Sets the street number to \a streetNumber.
-
- This may also contain things like a unit number, a building name, or
- anything else that might be used to distinguish one address from another.
-
- \note Before Qt6 this information was set by setStreet() method.
-
- \sa setStreet()
-*/
-void QGeoAddress::setStreetNumber(const QString &streetNumber)
-{
- d->sStreetNumber = streetNumber;
-}
-
-/*!
- Returns the postal code.
-*/
-QString QGeoAddress::postalCode() const
-{
- return d->sPostalCode;
-}
-
-/*!
- Sets the \a postalCode.
-*/
-void QGeoAddress::setPostalCode(const QString &postalCode)
-{
- d->sPostalCode = postalCode;
-}
-
-/*!
- Returns whether this address is empty. An address is considered empty
- if \e all of its fields are empty.
-*/
-bool QGeoAddress::isEmpty() const
-{
- return d->sCountry.isEmpty() &&
- d->sCountryCode.isEmpty() &&
- d->sState.isEmpty() &&
- d->sCounty.isEmpty() &&
- d->sCity.isEmpty() &&
- d->sDistrict.isEmpty() &&
- d->sStreet.isEmpty() &&
- d->sStreetNumber.isEmpty() &&
- d->sPostalCode.isEmpty() &&
- d->sText.isEmpty();
-
-}
-
-/*!
- Clears all of the address' data fields.
-*/
-void QGeoAddress::clear()
-{
- d->sCountry.clear();
- d->sCountryCode.clear();
- d->sState.clear();
- d->sCounty.clear();
- d->sCity.clear();
- d->sDistrict.clear();
- d->sStreet.clear();
- d->sStreetNumber.clear();
- d->sPostalCode.clear();
- d->sText.clear();
-}
-
-/*!
- Returns true if QGeoAddress::text() is automatically generated from address elements,
- otherwise returns false if text() has been explicitly assigned.
-
- \sa text(), setText()
-*/
-bool QGeoAddress::isTextGenerated() const
-{
- return d->sText.isEmpty();
-}
-
-bool QGeoAddress::equals(const QGeoAddress &lhs, const QGeoAddress &rhs)
-{
-#ifdef QGEOADDRESS_DEBUG
- qDebug() << "country" << (lhs.d->sCountry == rhs.d->sCountry);
- qDebug() << "countryCode" << (lhs.d->sCountryCode == rhs.d->sCountryCode);
- qDebug() << "state:" << (lhs.d->sState == rhs.d->sState);
- qDebug() << "county:" << (lhs.d->sCounty == rhs.d->sCounty);
- qDebug() << "city:" << (lhs.d->sCity == rhs.d->sCity);
- qDebug() << "district:" << (lhs.d->sDistrict == rhs.d->sDistrict);
- qDebug() << "street:" << (lhs.d->sStreet == rhs.d->sStreet);
- qDebug() << "street number:" << (lhs.d->sStreetNumber == rhs.d->sStreetNumber);
- qDebug() << "postalCode:" << (lhs.d->sPostalCode == rhs.d->sPostalCode);
- qDebug() << "text:" << (lhs.text() == rhs.text());
-#endif
-
- return lhs.d->sCountry == rhs.d->sCountry &&
- lhs.d->sCountryCode == rhs.d->sCountryCode &&
- lhs.d->sState == rhs.d->sState &&
- lhs.d->sCounty == rhs.d->sCounty &&
- lhs.d->sCity == rhs.d->sCity &&
- lhs.d->sDistrict == rhs.d->sDistrict &&
- lhs.d->sStreet == rhs.d->sStreet &&
- lhs.d->sStreetNumber == rhs.d->sStreetNumber &&
- lhs.d->sPostalCode == rhs.d->sPostalCode &&
- lhs.text() == rhs.text();
-}
-
-/*!
- \relates QGeoAddress
-
- Returns the hash value for the \a address, using \a seed for the
- calculation.
-*/
-size_t qHash(const QGeoAddress &address, size_t seed) noexcept
-{
- size_t hash = qHashMulti(seed, address.country(), address.countryCode(), address.state(),
- address.county(), address.city(), address.district(),
- address.street(), address.streetNumber(), address.postalCode());
-
- // If the text is generated from all fields, there is no need to use the
- // resulting string in the hash. However, when the text is specified
- // explicitly, we need to use it as well.
- if (!address.isTextGenerated())
- hash = qHashMulti(seed, hash, address.text());
- return hash;
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeoaddress.h b/src/positioning/qgeoaddress.h
deleted file mode 100644
index 703a808d..00000000
--- a/src/positioning/qgeoaddress.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOADDRESS_H
-#define QGEOADDRESS_H
-
-#include <QtCore/QMetaType>
-#include <QtCore/QSharedDataPointer>
-#include <QtPositioning/qpositioningglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QString;
-class QGeoAddressPrivate;
-QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGeoAddressPrivate, Q_POSITIONING_EXPORT)
-
-class Q_POSITIONING_EXPORT QGeoAddress
-{
-public:
- QGeoAddress();
- QGeoAddress(const QGeoAddress &other);
- QGeoAddress(QGeoAddress &&other) noexcept = default;
- ~QGeoAddress();
-
- QGeoAddress &operator=(const QGeoAddress &other);
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGeoAddress)
-
- void swap(QGeoAddress &other) noexcept { d.swap(other.d); }
-
- friend bool operator==(const QGeoAddress &lhs, const QGeoAddress &rhs)
- {
- return equals(lhs, rhs);
- }
- friend bool operator!=(const QGeoAddress &lhs, const QGeoAddress &rhs)
- {
- return !equals(lhs, rhs);
- }
-
- QString text() const;
- void setText(const QString &text);
-
- QString country() const;
- void setCountry(const QString &country);
-
- QString countryCode() const;
- void setCountryCode(const QString &countryCode);
-
- QString state() const;
- void setState(const QString &state);
-
- QString county() const;
- void setCounty(const QString &county);
-
- QString city() const;
- void setCity(const QString &city);
-
- QString district() const;
- void setDistrict(const QString &district);
-
- QString postalCode() const;
- void setPostalCode(const QString &postalCode);
-
- QString street() const;
- void setStreet(const QString &street);
-
- QString streetNumber() const;
- void setStreetNumber(const QString &streetNumber);
-
- bool isEmpty() const;
- void clear();
-
- bool isTextGenerated() const;
-
-private:
- static bool equals(const QGeoAddress &lhs, const QGeoAddress &rhs);
- QSharedDataPointer<QGeoAddressPrivate> d;
-};
-
-Q_POSITIONING_EXPORT size_t qHash(const QGeoAddress &address, size_t seed = 0) noexcept;
-
-Q_DECLARE_SHARED(QGeoAddress)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoAddress)
-
-#endif
diff --git a/src/positioning/qgeoaddress_p.h b/src/positioning/qgeoaddress_p.h
deleted file mode 100644
index c0e8820c..00000000
--- a/src/positioning/qgeoaddress_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOCATION_GEOADDRESS_P_H
-#define QLOCATION_GEOADDRESS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QString>
-#include <QSharedData>
-
-QT_BEGIN_NAMESPACE
-
-// The fields for the class are based on the nominatim openstreetmap API:
-// https://nominatim.org/release-docs/latest/api/Output/#addressdetails
-// It might not reflect all the address levels, but can be used to provide a
-// more or less well-formed address.
-class QGeoAddressPrivate : public QSharedData
-{
-public:
- QGeoAddressPrivate();
- QGeoAddressPrivate(const QGeoAddressPrivate &other);
- ~QGeoAddressPrivate();
-
- QString sCountry; //!< country field
- QString sCountryCode; //!< country code field
- QString sState; //!< state field
- QString sCounty; //!< county field
- QString sCity; //!< city field
- QString sDistrict; //!< district field
- QString sStreet; //!< street name field
- QString sStreetNumber; //!< street number field
- QString sPostalCode; //!< postal code field
- QString sText;
- bool m_autoGeneratedText;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeoareamonitorinfo.cpp b/src/positioning/qgeoareamonitorinfo.cpp
deleted file mode 100644
index ae9548f0..00000000
--- a/src/positioning/qgeoareamonitorinfo.cpp
+++ /dev/null
@@ -1,440 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGeoAreaMonitorInfo>
-#include <QDateTime>
-#include <QSharedData>
-#include <QUuid>
-#include <QDataStream>
-
-#ifndef QT_NO_DEBUG_STREAM
-#include <QDebug>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoAreaMonitorInfo
- \inmodule QtPositioning
- \since 5.2
- \ingroup QtPositioning-positioning
- \ingroup shared
-
- \brief The QGeoAreaMonitorInfo class describes the parameters of an area or region
- to be monitored for proximity.
-
- The purpose of area monitoring is to inform a user when he/she comes close to an area of
- interest. In general such an area is described by a \l QGeoCircle. The circle's center
- represents the place of interest and the area around it identifies the geographical region
- within which notifications are sent.
-
- A QGeoAreaMonitorInfo object is valid if it has a non-empty name and a valid \l area().
- Such objects must be registered with a \l QGeoAreaMonitorSource to start and stop the
- monitoring process. Note that extensive monitoring can be very resource consuming
- because the positioning engine must remain active and has to match the current position
- with each QGeoAreaMonitorInfo instance.
-
- To further reduce the burden on the system there are optional attributes which can
- set. Each monitored area can have an expiry date which automatically removes the
- to-be-monitored area from the monitoring source once the expiry date has been reached.
- Another option is to adjust the persistence of a monitored area. A QGeoAreaMonitorInfo
- that \l isPersistent() will remain active beyond
- the current applications lifetime. If an area is entered while the monitoring
- application is not running the application will be started. Note that this feature is
- not available on all platforms. Its availability can be checked via
- \l QGeoAreaMonitorSource::supportedAreaMonitorFeatures().
-
- \sa QGeoAreaMonitorSource
-
- */
-
-class QGeoAreaMonitorInfoPrivate : public QSharedData
-{
-public:
- QGeoAreaMonitorInfoPrivate() : QSharedData(), persistent(false) {}
- QGeoAreaMonitorInfoPrivate(const QGeoAreaMonitorInfoPrivate &other)
- : QSharedData(other)
- {
- uid = other.uid;
- name = other.name;
- shape = other.shape;
- persistent = other.persistent;
- notificationParameters = other.notificationParameters;
- expiry = other.expiry;
- }
- ~QGeoAreaMonitorInfoPrivate() {}
-
- QUuid uid;
- QString name;
- QGeoShape shape;
- bool persistent;
- QVariantMap notificationParameters;
- QDateTime expiry;
-};
-
-/*!
- Constructs a QGeoAreaMonitorInfo object with the specified \a name.
-
- \sa name()
- */
-QGeoAreaMonitorInfo::QGeoAreaMonitorInfo(const QString &name)
-{
- d = new QGeoAreaMonitorInfoPrivate;
- d->name = name;
- d->uid = QUuid::createUuid();
-}
-
-/*!
- Constructs a QGeoAreaMonitorInfo object as a copy of \a other.
- */
-QGeoAreaMonitorInfo::QGeoAreaMonitorInfo(const QGeoAreaMonitorInfo &other)
- : d(other.d)
-{
-}
-
-/*!
- \fn QGeoAreaMonitorInfo::QGeoAreaMonitorInfo(QGeoAreaMonitorInfo &&other) noexcept
- \since 6.2
-
- Constructs a QGeoAreaMonitorInfo object by moving from \a other.
-
- Note that a moved-from QGeoAreaMonitorInfo can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- Destructor
- */
-QGeoAreaMonitorInfo::~QGeoAreaMonitorInfo()
-{
-}
-
-QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QGeoAreaMonitorInfoPrivate)
-
-/*!
- Assigns \a other to this QGeoAreaMonitorInfo object and returns a reference
- to this QGeoAreaMonitorInfo object.
- */
-QGeoAreaMonitorInfo &QGeoAreaMonitorInfo::operator=(const QGeoAreaMonitorInfo &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- \fn QGeoAreaMonitorInfo &QGeoAreaMonitorInfo::operator=(QGeoAreaMonitorInfo &&other) noexcept
- \since 6.2
-
- Move-assigns \a other to this QGeoAreaMonitorInfo object and returns a
- reference to this QGeoAreaMonitorInfo object.
-
- Note that a moved-from QGeoAreaMonitorInfo can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- \fn bool QGeoAreaMonitorInfo::operator==(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)
-
- Returns \c true if all of the \a lhs object's values are the same as those
- of \a rhs object. Otherwise returns \c false.
-*/
-
-/*!
- \fn bool QGeoAreaMonitorInfo::operator!=(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)
-
- Returns \c true if any of the \a lhs object's values are not the same as
- those of \a rhs object. Otherwise returns \c false.
-*/
-
-/*!
- Returns the name of the QGeoAreaMonitorInfo object. The name should be used
- for user-visibility purposes.
- */
-QString QGeoAreaMonitorInfo::name() const
-{
- return d->name;
-}
-
-/*!
- Sets the user visibile \a name.
- */
-void QGeoAreaMonitorInfo::setName(const QString &name)
-{
- if (d->name != name) {
- d.detach();
- d->name = name;
- }
-}
-
-/*!
- Returns the identifier of the QGeoAreaMonitorInfo object.
- The identifier is automatically generated upon construction of a new
- QGeoAreaMonitorInfo object.
-*/
-
-QString QGeoAreaMonitorInfo::identifier() const
-{
- return d->uid.toString();
-}
-
-/*!
- Returns true, if the monitor is valid. A valid QGeoAreaMonitorInfo has a non-empty name()
- and the monitored area is not \l {QGeoShape::isEmpty()}{empty()}.
- Otherwise this function returns false.
- */
-bool QGeoAreaMonitorInfo::isValid() const
-{
- return (!d->name.isEmpty() && !d->shape.isEmpty());
-}
-
-/*!
- Returns the boundaries of the to-be-monitored area. This area must not be empty.
-
- \sa setArea()
- */
-QGeoShape QGeoAreaMonitorInfo::area() const
-{
- return d->shape;
-}
-
-/*!
- Sets the to-be-monitored area to \a newShape.
-
- \sa area()
- */
-void QGeoAreaMonitorInfo::setArea(const QGeoShape &newShape)
-{
- d.detach();
- d->shape = newShape;
-}
-
-/*!
- Returns the expiry date.
-
- After an active QGeoAreaMonitorInfo has expired the region is no longer monitored
- and the QGeoAreaMonitorInfo object is removed from the list of
- \l {QGeoAreaMonitorSource::activeMonitors()}{active monitors}.
-
- If the expiry \l QDateTime is invalid the QGeoAreaMonitorInfo object is treated as not having
- an expiry date. This implies an indefinite monitoring period if the object is persistent or
- until the current application closes if the object is non-persistent.
-
- \sa QGeoAreaMonitorSource::activeMonitors()
- */
-QDateTime QGeoAreaMonitorInfo::expiration() const
-{
- return d->expiry;
-}
-
-/*!
- Sets the expiry date and time to \a expiry.
- */
-void QGeoAreaMonitorInfo::setExpiration(const QDateTime &expiry)
-{
- d.detach();
- d->expiry = expiry;
-}
-
-/*!
- Returns true if the QGeoAreaMonitorInfo is persistent.
- The default value for this property is false.
-
- A non-persistent QGeoAreaMonitorInfo will be removed by the system once
- the application owning the monitor object stops. Persistent objects remain
- active and can be retrieved once the application restarts.
-
- If the system triggers an event associated to a persistent QGeoAreaMonitorInfo
- the relevant application will be re-started and the appropriate signal emitted.
-
- \sa setPersistent()
- */
-bool QGeoAreaMonitorInfo::isPersistent() const
-{
- return d->persistent;
-}
-
-/*!
- Sets the QGeoAreaMonitorInfo object's persistence to \a isPersistent.
-
- Note that setting this flag does not imply that \l QGeoAreaMonitorSource
- supports persistent monitoring.
- \l QGeoAreaMonitorSource::supportedAreaMonitorFeatures() can be used to
- check for this feature's availability.
-
- \sa isPersistent()
- */
-void QGeoAreaMonitorInfo::setPersistent(bool isPersistent)
-{
- d.detach();
- d->persistent = isPersistent;
-}
-
-
-/*!
- Returns the set of platform specific parameters used by this
- QGeoAreaMonitorInfo.
-
- \sa setNotificationParameters()
- */
-QVariantMap QGeoAreaMonitorInfo::notificationParameters() const
-{
- return d->notificationParameters;
-}
-
-/*!
- Sets the set of platform specific \a parameters used by QGeoAreaMonitorInfo.
-
- \sa notificationParameters()
- */
-void QGeoAreaMonitorInfo::setNotificationParameters(const QVariantMap &parameters)
-{
- d.detach();
- d->notificationParameters = parameters;
-}
-
-/*!
- \internal
-*/
-void QGeoAreaMonitorInfo::detach()
-{
- if (d)
- d.detach();
- else
- d = new QGeoAreaMonitorInfoPrivate;
-}
-
-bool QGeoAreaMonitorInfo::equals(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)
-{
- return (lhs.d->name == rhs.d->name &&
- lhs.d->uid == rhs.d->uid &&
- lhs.d->shape == rhs.d->shape &&
- lhs.d->persistent == rhs.d->persistent &&
- lhs.d->expiry == rhs.d->expiry &&
- lhs.d->notificationParameters == rhs.d->notificationParameters);
-}
-
-#ifndef QT_NO_DATASTREAM
-
-/*!
- \fn QDataStream &QGeoAreaMonitorInfo::operator<<(QDataStream &stream, const QGeoAreaMonitorInfo &monitor)
-
- Writes the given \a monitor to the specified \a stream.
-
- \sa {Serializing Qt Data Types}
-*/
-QDataStream &QGeoAreaMonitorInfo::dataStreamOut(QDataStream &ds, const QGeoAreaMonitorInfo &monitor)
-{
- ds << monitor.name() << monitor.d->uid << monitor.area()
- << monitor.isPersistent() << monitor.notificationParameters() << monitor.expiration();
- return ds;
-}
-
-/*!
- \fn QDataStream &QGeoAreaMonitorInfo::operator>>(QDataStream &stream, QGeoAreaMonitorInfo &monitor)
-
- Reads a area monitoring data from the specified \a stream into the given
- \a monitor.
-
- \sa {Serializing Qt Data Types}
-*/
-QDataStream &QGeoAreaMonitorInfo::dataStreamIn(QDataStream &ds, QGeoAreaMonitorInfo &monitor)
-{
- QString s;
- ds >> s;
- monitor = QGeoAreaMonitorInfo(s);
-
- QUuid id;
- ds >> id;
- monitor.d->uid = id;
-
- QGeoShape shape;
- ds >> shape;
- monitor.setArea(shape);
-
- bool persistent;
- ds >> persistent;
- monitor.setPersistent(persistent);
-
- QVariantMap map;
- ds >> map;
- monitor.setNotificationParameters(map);
-
- QDateTime dt;
- ds >> dt;
- monitor.setExpiration(dt);
-
- return ds;
-}
-
-#endif
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug QGeoAreaMonitorInfo::debugStreaming(QDebug dbg, const QGeoAreaMonitorInfo &monitor)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "QGeoAreaMonitorInfo(\"" << qPrintable(monitor.name())
- << "\", " << monitor.area()
- << ", persistent: " << monitor.isPersistent()
- << ", expiry: " << monitor.expiration() << ")";
- return dbg;
-}
-
-#endif
-
-size_t qHash(const QGeoAreaMonitorInfo &key, size_t seed) noexcept
-{
- return qHashMulti(seed, key.d->uid);
-}
-
-namespace QTest
-{
-
-char *toString(const QGeoAreaMonitorInfo &info)
-{
- QString result;
- QDebug dbg(&result);
- dbg << info;
- return qstrdup(qPrintable(result));
-}
-
-} // namespace QTest
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeoareamonitorinfo.h b/src/positioning/qgeoareamonitorinfo.h
deleted file mode 100644
index def03b8b..00000000
--- a/src/positioning/qgeoareamonitorinfo.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOAREAMONITORINFO_H
-#define QGEOAREAMONITORINFO_H
-
-#include <QtPositioning/QGeoCoordinate>
-#include <QtPositioning/QGeoShape>
-#include <QtCore/QExplicitlySharedDataPointer>
-#include <QtCore/QMetaType>
-#include <QtCore/QVariantMap>
-
-QT_BEGIN_NAMESPACE
-
-class QDataStream;
-class QGeoAreaMonitorInfo;
-
-Q_POSITIONING_EXPORT size_t qHash(const QGeoAreaMonitorInfo &key, size_t seed = 0) noexcept;
-namespace QTest
-{
-Q_POSITIONING_EXPORT char *toString(const QGeoAreaMonitorInfo &info);
-} // namespace QTest
-
-class QGeoAreaMonitorInfoPrivate;
-QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGeoAreaMonitorInfoPrivate, Q_POSITIONING_EXPORT)
-
-class Q_POSITIONING_EXPORT QGeoAreaMonitorInfo
-{
-public:
- explicit QGeoAreaMonitorInfo(const QString &name = QString());
- QGeoAreaMonitorInfo(const QGeoAreaMonitorInfo &other);
- QGeoAreaMonitorInfo(QGeoAreaMonitorInfo &&other) noexcept = default;
- ~QGeoAreaMonitorInfo();
-
- QGeoAreaMonitorInfo &operator=(const QGeoAreaMonitorInfo &other);
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGeoAreaMonitorInfo)
-
- void swap(QGeoAreaMonitorInfo &other) noexcept { d.swap(other.d); }
-
- friend bool operator==(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)
- {
- return equals(lhs, rhs);
- }
- friend bool operator!=(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)
- {
- return !equals(lhs, rhs);
- }
-
- QString name() const;
- void setName(const QString &name);
-
- QString identifier() const;
- bool isValid() const;
-
- QGeoShape area() const;
- void setArea(const QGeoShape &newShape);
-
- QDateTime expiration() const;
- void setExpiration(const QDateTime &expiry);
-
- bool isPersistent() const;
- void setPersistent(bool isPersistent);
-
- QVariantMap notificationParameters() const;
- void setNotificationParameters(const QVariantMap &parameters);
-
- void detach();
-
-private:
- static bool equals(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs);
- QExplicitlySharedDataPointer<QGeoAreaMonitorInfoPrivate> d;
- friend class QGeoAreaMonitorInfoPrivate;
-
-#ifndef QT_NO_DATASTREAM
- friend QDataStream &operator<<(QDataStream &ds, const QGeoAreaMonitorInfo &monitor)
- {
- return dataStreamOut(ds, monitor);
- }
- friend QDataStream &operator>>(QDataStream &ds, QGeoAreaMonitorInfo &monitor)
- {
- return dataStreamIn(ds, monitor);
- }
- static QDataStream &dataStreamOut(QDataStream &ds, const QGeoAreaMonitorInfo &monitor);
- static QDataStream &dataStreamIn(QDataStream &ds, QGeoAreaMonitorInfo &monitor);
-#endif
- friend Q_POSITIONING_EXPORT size_t qHash(const QGeoAreaMonitorInfo &key, size_t seed) noexcept;
- friend Q_POSITIONING_EXPORT char *QTest::toString(const QGeoAreaMonitorInfo& info);
-#ifndef QT_NO_DEBUG_STREAM
- friend QDebug operator<<(QDebug dbg, const QGeoAreaMonitorInfo &monitor)
- {
- return debugStreaming(dbg, monitor);
- }
- static QDebug debugStreaming(QDebug dbg, const QGeoAreaMonitorInfo &monitor);
-#endif
-};
-
-Q_DECLARE_SHARED(QGeoAreaMonitorInfo)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoAreaMonitorInfo)
-
-#endif // QGEOAREAMONITORINFO_H
diff --git a/src/positioning/qgeoareamonitorsource.cpp b/src/positioning/qgeoareamonitorsource.cpp
deleted file mode 100644
index 6df3dc73..00000000
--- a/src/positioning/qgeoareamonitorsource.cpp
+++ /dev/null
@@ -1,432 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/private/qobject_p.h>
-#include <QGeoAreaMonitorSource>
-#include "qgeopositioninfosourcefactory.h"
-#include "qgeopositioninfosource_p.h"
-
-/*!
- \class QGeoAreaMonitorSource
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QGeoAreaMonitorSource class enables the detection of proximity
- changes for a specified set of coordinates.
-
- A QGeoAreaMonitorSource emits signals when the current position is in
- range, or has moved out of range, of a specified area.
- Each area is specified by a \l QGeoAreaMonitorInfo object.
- For example:
-
- \snippet cpp/cppqml.cpp BigBen
-
- \c QGeoAreaMonitorSource follows a singleton pattern. Each instance of
- the class with the same \l sourceName() shares the same area monitoring backend.
- If a new \l QGeoAreaMonitorInfo object is added via \l startMonitoring()
- or \l requestUpdate() it can be retrieved by another instance of this class
- (provided that they are sourced from the same area monitor provider plug-in).
- The same singleton pattern applies to the \l QGeoPositionInfoSource instance
- used by this class. The following code snippet emphasizes the behavior:
-
- \code
- QGeoAreaMonitorSource *s1 = QGeoAreaMonitorSource::createSource("blah", this);
- QGeoAreaMonitorSource *s2 = QGeoAreaMonitorSource::createSource("blah", this);
- QVERIFY(s1->positionInfoSource() == s2->positionInfoSource);
- \endcode
-*/
-
-QT_BEGIN_NAMESPACE
-
-
-
-class QGeoAreaMonitorSourcePrivate : public QObjectPrivate
-{
-public:
- QGeoPositionInfoSource *source;
- QString providerName;
-};
-
-/*!
- \enum QGeoAreaMonitorSource::Error
- Defines the types of positioning methods.
-
- The Error enumeration represents the errors which can occur.
-
- \value AccessError The connection setup to the remote area monitoring backend failed because the
- application lacked the required privileges.
- \value InsufficientPositionInfo The area monitoring source could not retrieve a location fix or
- the accuracy of the fix is not high enough to provide an effective area monitoring.
- \value NoError No error has occurred.
- \value UnknownSourceError An unidentified error occurred.
-*/
-
-/*!
- \enum QGeoAreaMonitorSource::AreaMonitorFeature
- Defines the types of area monitoring capabilities.
-
- \value PersistentAreaMonitorFeature QGeoAreaMonitorInfo instances can be made persistent.
- A persistent monitor continues to be active even when the application managing the monitor is
- not running.
- \value AnyAreaMonitorFeature Matches all possible area monitoring features.
-*/
-
-/*!
- \fn virtual AreaMonitoringFeatures QGeoAreaMonitorSource::supportedAreaMonitorFeatures() const = 0;
-
- Returns the area monitoring features available to this source.
-*/
-
-/*!
- \fn virtual QGeoAreaMonitorSource::Error QGeoAreaMonitorSource::error() const
-
- Returns the type of error that last occurred.
-
- \note Since Qt6 the last error is always reset when calling
- startMonitoring() or requestUpdate().
-*/
-
-/*!
- Creates a monitor source with the given \a parent.
-*/
-QGeoAreaMonitorSource::QGeoAreaMonitorSource(QObject *parent)
- : QObject(*new QGeoAreaMonitorSourcePrivate, parent)
-{
- Q_D(QGeoAreaMonitorSource);
- d->source = nullptr;
-}
-
-/*!
- Destroys the monitor source.
-*/
-QGeoAreaMonitorSource::~QGeoAreaMonitorSource()
-{
-}
-
-/*!
- Creates and returns a monitor source with the given \a parent that
- monitors areas using resources on the underlying system.
-
- Returns \c nullptr if the system has no support for position monitoring.
-*/
-QGeoAreaMonitorSource *QGeoAreaMonitorSource::createDefaultSource(QObject *parent)
-{
- QList<QJsonObject> plugins = QGeoPositionInfoSourcePrivate::pluginsSorted();
- foreach (const QJsonObject &obj, plugins) {
- if (obj.value(QStringLiteral("Monitor")).isBool()
- && obj.value(QStringLiteral("Monitor")).toBool())
- {
- QGeoAreaMonitorSource *s = nullptr;
- auto factory = QGeoPositionInfoSourcePrivate::loadFactory(obj);
- if (factory)
- s = factory->areaMonitor(parent, QVariantMap());
- if (s)
- s->d_func()->providerName = obj.value(QStringLiteral("Provider")).toString();
- return s;
- }
- }
- return nullptr;
-}
-
-/*!
- Creates and returns a monitor source with the given \a parent,
- by loading the plugin named \a sourceName.
-
- Returns \c nullptr if the plugin cannot be found.
-*/
-QGeoAreaMonitorSource *QGeoAreaMonitorSource::createSource(const QString &sourceName, QObject *parent)
-{
- auto plugins = QGeoPositionInfoSourcePrivate::plugins();
- if (plugins.contains(sourceName)) {
- const auto metaData = plugins.value(sourceName);
- QGeoAreaMonitorSource *s = nullptr;
- auto factory = QGeoPositionInfoSourcePrivate::loadFactory(metaData);
- if (factory)
- s = factory->areaMonitor(parent, QVariantMap());
- if (s)
- s->d_func()->providerName = metaData.value(QStringLiteral("Provider")).toString();
- return s;
- }
-
- return nullptr;
-}
-
-/*!
- Returns a list of available monitor plugins, including the default system
- backend if one is available.
-*/
-QStringList QGeoAreaMonitorSource::availableSources()
-{
- QStringList plugins;
- const auto meta = QGeoPositionInfoSourcePrivate::plugins();
- for (auto it = meta.cbegin(), end = meta.cend(); it != end; ++it) {
- if (it.value().value(QStringLiteral("Monitor")).isBool()
- && it.value().value(QStringLiteral("Monitor")).toBool()) {
- plugins << it.key();
- }
- }
-
- return plugins;
-}
-
-/*!
- Returns the unique name of the area monitor source implementation in use.
-
- This is the same name that can be passed to createSource() in order to
- create a new instance of a particular area monitor source implementation.
-*/
-QString QGeoAreaMonitorSource::sourceName() const
-{
- Q_D(const QGeoAreaMonitorSource);
- return d->providerName;
-}
-
-/*!
- \since 6.2
-
- Sets the backend-specific property named \a name to \a value.
- Returns \c true on success, otherwise returns \c false.
- Backend-specific properties can be used to configure the area monitoring
- subsystem behavior at runtime.
-
- \sa backendProperty()
-*/
-bool QGeoAreaMonitorSource::setBackendProperty(const QString &name, const QVariant &value)
-{
- Q_UNUSED(name);
- Q_UNUSED(value);
- return false;
-}
-
-/*!
- \since 6.2
-
- Returns the value of the backend-specific property named \a name,
- if present. Otherwise the returned value will be invalid.
-
- \sa setBackendProperty()
-*/
-QVariant QGeoAreaMonitorSource::backendProperty(const QString &name) const
-{
- Q_UNUSED(name);
- return QVariant();
-}
-
-/*!
- Returns the current QGeoPositionInfoSource used by this QGeoAreaMonitorSource
- object. The function will return \l QGeoPositionInfoSource::createDefaultSource()
- if no other object has been set.
-
- The function returns \c nullptr if not even a default QGeoPositionInfoSource
- exists.
-
- Any usage of the returned \l QGeoPositionInfoSource instance should account
- for the fact that it may reside in a different thread.
-
- \sa QGeoPositionInfoSource, setPositionInfoSource()
-*/
-QGeoPositionInfoSource* QGeoAreaMonitorSource::positionInfoSource() const
-{
- Q_D(const QGeoAreaMonitorSource);
- return d->source;
-}
-
-/*!
- Sets the new \l QGeoPositionInfoSource to be used by this QGeoAreaMonitorSource object.
- The area monitoring backend becomes the new QObject parent for \a newSource.
- The previous \l QGeoPositionInfoSource object will be deleted. All QGeoAreaMonitorSource
- instances based on the same \l sourceName() share the same QGeoPositionInfoSource
- instance.
-
- This may be useful when it is desirable to manipulate the positioning system
- used by the area monitoring engine.
-
- Note that ownership must be taken care of by subclasses of QGeoAreaMonitorSource.
- Due to the singleton pattern behind this class \a newSource may be moved to a
- new thread.
-
- \sa positionInfoSource()
- */
-void QGeoAreaMonitorSource::setPositionInfoSource(QGeoPositionInfoSource *newSource)
-{
- Q_D(QGeoAreaMonitorSource);
- d->source = newSource;
-}
-
-
-/*!
- \fn virtual bool QGeoAreaMonitorSource::startMonitoring(const QGeoAreaMonitorInfo &monitor)
-
- Returns \c true if the monitoring of \a monitor could be successfully started; otherwise
- returns \c false. A reason for not being able to start monitoring could be the unavailability
- of an appropriate default position info source while no alternative QGeoPositionInfoSource
- has been set via \l setPositionInfoSource().
-
- If \a monitor is already active, the existing monitor object will be replaced by the new \a monitor reference.
- The identification of QGeoAreaMonitorInfo instances happens via \l QGeoAreaMonitorInfo::identifier().
- Therefore this function can also be used to update active monitors.
-
- If \a monitor has an expiry date that has been passed this function returns false. Calling
- this function for an already via \l requestUpdate() registered single shot monitor
- switches the monitor to a permanent monitoring mode.
-
- Requesting persistent monitoring on a QGeoAreaMonitorSource instance fails if the area monitoring
- backend doesn't support \l QGeoAreaMonitorSource::PersistentAreaMonitorFeature.
-
- \note Since Qt6 this method always resets the last error to
- \l {QGeoAreaMonitorSource::}{NoError} before starting monitoring.
-
- \sa stopMonitoring()
-*/
-
-/*!
- \fn virtual bool QGeoAreaMonitorSource::requestUpdate(const QGeoAreaMonitorInfo &monitor, const char *signal)
-
- Enables single shot area monitoring. Area monitoring for \a monitor will be performed
- until this QGeoAreaMonitorSource instance emits \a signal for the first time. Once
- the signal was emitted, \a monitor is automatically removed from the list of
- \l activeMonitors(). If \a monitor is invalid or has an expiry date that has
- been passed, this function returns \c false.
-
- \code
- QGeoAreaMonitor singleShotMonitor;
- QGeoAreaMonitorSource * source = QGeoAreaMonitorSource::createDefaultSource(this);
- //...
- bool ret = source->requestUpdate(singleShotMonitor,
- SIGNAL(areaExited(QGeoAreaMonitor,QGeoPositionInfo)));
- \endcode
-
- The above \c singleShotMonitor object will cease to send updates once the \l areaExited() signal
- was emitted for the first time. Until this point in time any other signal may be emitted
- zero or more times depending on the area context.
-
- It is not possible to simultanously request updates for more than one signal of the same monitor object.
- The last call to this function determines the signal upon which the updates cease to continue.
- At this stage only the \l areaEntered() and \l areaExited() signals can be used to
- terminate the monitoring process.
-
- Requesting persistent monitoring on a QGeoAreaMonitorSource instance fails if the area monitoring
- backend doesn't support \l QGeoAreaMonitorSource::PersistentAreaMonitorFeature.
-
- If \a monitor was already registered via \l startMonitoring() it is converted to a single
- shot behavior.
-
- \note Since Qt6 this method always resets the last error to
- \l {QGeoAreaMonitorSource::}{NoError} before starting monitoring.
-
- \sa startMonitoring(), stopMonitoring()
- */
-
-/*!
- \fn virtual bool QGeoAreaMonitorSource::stopMonitoring(const QGeoAreaMonitorInfo &monitor)
-
- Returns true if \a monitor was successfully removed from the list of \l activeMonitors();
- otherwise returns false. This behavior is independent on whether \a monitor was registered
- via \l startMonitoring() or \l requestUpdate().
-*/
-
-/*!
- \fn virtual QList<QGeoAreaMonitorInfo> QGeoAreaMonitorSource::activeMonitors() const
-
- Returns the list of all active monitors known to the QGeoAreaMonitorSource object.
-
- An active monitor was started via startMonitoring(). For every active
- monitor the source object will emit the required signals, such as
- areaEntered() or areaExited(). Multiple \l QGeoAreaMonitorSource instances
- within the same application share the same active monitor objects.
-
- Unless an active QGeoAreaMonitorInfo \l {QGeoAreaMonitorInfo::isPersistent()}{isPersistent()} an active QGeoAreaMonitorInfo
- will be stopped once the current application terminates.
-*/
-
-/*!
- \fn virtual QList<QGeoAreaMonitorInfo> QGeoAreaMonitorSource::activeMonitors(const QGeoShape &lookupArea) const
-
- Returns the list of all active monitors known to the QGeoAreaMonitorSource object whose
- center lies within \a lookupArea. If \a lookupArea is empty the returned list will be empty.
-
- An active monitor was started via startMonitoring(). For every active
- monitor the source object will emit the required signals, such as
- areaEntered() or areaExited(). Multiple \l QGeoAreaMonitorSource instances
- within the same application share the same active monitor objects.
-
- Unless an active QGeoAreaMonitorInfo \l {QGeoAreaMonitorInfo::isPersistent()}{isPersistent()} an active QGeoAreaMonitorInfo
- will be stopped once the current application terminates.
-
- \sa QGeoShape
-*/
-
-
-/*!
- \fn void QGeoAreaMonitorSource::monitorExpired(const QGeoAreaMonitorInfo &monitor)
-
- Emitted when \a monitor has expired. An expired area monitor is automatically
- removed from the list of \l activeMonitors().
-
- \sa activeMonitors()
-*/
-
-/*!
- \fn void QGeoAreaMonitorSource::areaEntered(const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
-
- Emitted when the current position has moved from a position outside of the active \a monitor
- to a position within the monitored area.
-
- The \a update holds the new position.
-*/
-
-/*!
- \fn void QGeoAreaMonitorSource::areaExited(const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
-
- Emitted when the current position has moved from a position within the active \a monitor
- to a position outside the monitored area.
-
- The \a update holds the new position.
-*/
-
-/*!
- \fn void QGeoAreaMonitorSource::errorOccurred(QGeoAreaMonitorSource::Error areaMonitoringError)
-
- This signal is emitted after an error occurred. The \a areaMonitoringError
- parameter describes the type of error that occurred.
-
-*/
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeoareamonitorsource.h b/src/positioning/qgeoareamonitorsource.h
deleted file mode 100644
index 803914b5..00000000
--- a/src/positioning/qgeoareamonitorsource.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QGEOAREAMONITORSOURCE_H
-#define QGEOAREAMONITORSOURCE_H
-
-#include <QtPositioning/QGeoCoordinate>
-#include <QtPositioning/QGeoAreaMonitorInfo>
-#include <QtPositioning/QGeoPositionInfoSource>
-
-#include <QtCore/QObject>
-#include <QtCore/QStringList>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfo;
-class QGeoAreaMonitorSourcePrivate;
-class Q_POSITIONING_EXPORT QGeoAreaMonitorSource : public QObject
-{
- Q_OBJECT
-
-public:
- enum Error {
- AccessError = 0,
- InsufficientPositionInfo = 1,
- UnknownSourceError = 2,
- NoError = 3
- };
- Q_ENUMS(Error)
-
- enum AreaMonitorFeature {
- PersistentAreaMonitorFeature = 0x00000001,
- AnyAreaMonitorFeature = 0xffffffff
- };
- Q_DECLARE_FLAGS(AreaMonitorFeatures, AreaMonitorFeature)
-
- explicit QGeoAreaMonitorSource(QObject *parent);
- virtual ~QGeoAreaMonitorSource();
-
- static QGeoAreaMonitorSource *createDefaultSource(QObject *parent);
- static QGeoAreaMonitorSource *createSource(const QString& sourceName, QObject *parent);
- static QStringList availableSources();
-
- virtual void setPositionInfoSource(QGeoPositionInfoSource *source);
- virtual QGeoPositionInfoSource* positionInfoSource() const;
-
- QString sourceName() const;
-
- virtual Error error() const = 0;
- virtual AreaMonitorFeatures supportedAreaMonitorFeatures() const = 0;
-
- virtual bool startMonitoring(const QGeoAreaMonitorInfo &monitor) = 0;
- virtual bool stopMonitoring(const QGeoAreaMonitorInfo &monitor) = 0;
- virtual bool requestUpdate(const QGeoAreaMonitorInfo &monitor, const char *signal) = 0;
-
- virtual QList<QGeoAreaMonitorInfo> activeMonitors() const = 0;
- virtual QList<QGeoAreaMonitorInfo> activeMonitors(const QGeoShape &lookupArea) const = 0;
-
- virtual bool setBackendProperty(const QString &name, const QVariant &value);
- virtual QVariant backendProperty(const QString &name) const;
-
-Q_SIGNALS:
- void areaEntered(const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update);
- void areaExited(const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update);
- void monitorExpired(const QGeoAreaMonitorInfo &monitor);
- void errorOccurred(QGeoAreaMonitorSource::Error error);
-
-private:
- Q_DISABLE_COPY(QGeoAreaMonitorSource)
- Q_DECLARE_PRIVATE(QGeoAreaMonitorSource)
-};
-
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeocircle.cpp b/src/positioning/qgeocircle.cpp
deleted file mode 100644
index 094a7dcb..00000000
--- a/src/positioning/qgeocircle.cpp
+++ /dev/null
@@ -1,477 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeocircle.h"
-#include "qgeocircle_p.h"
-
-#include "qgeocoordinate.h"
-#include "qnumeric.h"
-#include "qlocationutils_p.h"
-
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
-#include <cmath>
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoCircle
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QGeoCircle class defines a circular geographic area.
-
- The circle is defined in terms of a QGeoCoordinate which specifies the
- center of the circle and a qreal which specifies the radius of the circle
- in meters.
-
- The circle is considered invalid if the center coordinate is invalid
- or if the radius is less than zero.
-
- This class is a \l Q_GADGET since Qt 5.5. It can be
- \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.
-*/
-
-/*!
- \property QGeoCircle::center
- \brief This property holds the center coordinate for the geo circle.
-
- The circle is considered invalid if this property contains an invalid
- coordinate.
-
- A default constructed QGeoCircle uses an invalid \l QGeoCoordinate
- as center.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoCircle::radius
- \brief This property holds the circle radius in meters.
-
- The circle is considered invalid if this property is negative.
-
- By default, the radius is initialized with \c -1.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-inline QGeoCirclePrivate *QGeoCircle::d_func()
-{
- return static_cast<QGeoCirclePrivate *>(d_ptr.data());
-}
-
-inline const QGeoCirclePrivate *QGeoCircle::d_func() const
-{
- return static_cast<const QGeoCirclePrivate *>(d_ptr.constData());
-}
-
-struct CircleVariantConversions
-{
- CircleVariantConversions()
- {
- QMetaType::registerConverter<QGeoShape, QGeoCircle>();
- QMetaType::registerConverter<QGeoCircle, QGeoShape>();
- }
-};
-
-Q_GLOBAL_STATIC(CircleVariantConversions, initCircleConversions)
-
-/*!
- Constructs a new, invalid geo circle.
-*/
-QGeoCircle::QGeoCircle()
-: QGeoShape(new QGeoCirclePrivate)
-{
- initCircleConversions();
-}
-
-/*!
- Constructs a new geo circle centered at \a center and with a radius of \a radius meters.
-*/
-QGeoCircle::QGeoCircle(const QGeoCoordinate &center, qreal radius)
-{
- initCircleConversions();
- d_ptr = new QGeoCirclePrivate(center, radius);
-}
-
-/*!
- Constructs a new geo circle from the contents of \a other.
-*/
-QGeoCircle::QGeoCircle(const QGeoCircle &other)
-: QGeoShape(other)
-{
- initCircleConversions();
-}
-
-/*!
- Constructs a new geo circle from the contents of \a other.
-*/
-QGeoCircle::QGeoCircle(const QGeoShape &other)
-: QGeoShape(other)
-{
- initCircleConversions();
- if (type() != QGeoShape::CircleType)
- d_ptr = new QGeoCirclePrivate;
-}
-
-/*!
- Destroys this geo circle.
-*/
-QGeoCircle::~QGeoCircle() {}
-
-/*!
- Assigns \a other to this geo circle and returns a reference to this geo circle.
-*/
-QGeoCircle &QGeoCircle::operator=(const QGeoCircle &other)
-{
- QGeoShape::operator=(other);
- return *this;
-}
-
-bool QGeoCirclePrivate::isValid() const
-{
- return m_center.isValid() && !qIsNaN(m_radius) && m_radius >= -1e-7;
-}
-
-bool QGeoCirclePrivate::isEmpty() const
-{
- return !isValid() || m_radius <= 1e-7;
-}
-
-/*!
- Sets the center coordinate of this geo circle to \a center.
-*/
-void QGeoCircle::setCenter(const QGeoCoordinate &center)
-{
- Q_D(QGeoCircle);
-
- d->setCenter(center);
-}
-
-/*!
- Returns the center coordinate of this geo circle. Equivalent to QGeoShape::center().
-*/
-QGeoCoordinate QGeoCircle::center() const
-{
- Q_D(const QGeoCircle);
-
- return d->center();
-}
-
-/*!
- Sets the radius in meters of this geo circle to \a radius.
-*/
-void QGeoCircle::setRadius(qreal radius)
-{
- Q_D(QGeoCircle);
-
- d->setRadius(radius);
-}
-
-/*!
- Returns the radius in meters of this geo circle.
-*/
-qreal QGeoCircle::radius() const
-{
- Q_D(const QGeoCircle);
-
- return d->m_radius;
-}
-
-bool QGeoCirclePrivate::contains(const QGeoCoordinate &coordinate) const
-{
- if (!isValid() || !coordinate.isValid())
- return false;
-
- // see QTBUG-41447 for details
- qreal distance = m_center.distanceTo(coordinate);
- if (qFuzzyCompare(distance, m_radius) || distance <= m_radius)
- return true;
-
- return false;
-}
-
-QGeoCoordinate QGeoCirclePrivate::center() const
-{
- return m_center;
-}
-
-QGeoRectangle QGeoCirclePrivate::boundingGeoRectangle() const
-{
- return m_bbox;
-}
-
-void QGeoCirclePrivate::updateBoundingBox()
-{
- if (isEmpty()) {
- if (m_center.isValid()) {
- m_bbox.setTopLeft(m_center);
- m_bbox.setBottomRight(m_center);
- }
- return;
- }
-
- bool crossNorth = crossNorthPole();
- bool crossSouth = crossSouthPole();
-
- if (crossNorth && crossSouth) {
- // Circle crossing both poles fills the whole map
- m_bbox = QGeoRectangle(QGeoCoordinate(90.0, -180.0), QGeoCoordinate(-90.0, 180.0));
- } else if (crossNorth) {
- // Circle crossing one pole fills the map in the longitudinal direction
- m_bbox = QGeoRectangle(QGeoCoordinate(90.0, -180.0), QGeoCoordinate(m_center.atDistanceAndAzimuth(m_radius, 180.0).latitude(), 180.0));
- } else if (crossSouth) {
- m_bbox = QGeoRectangle(QGeoCoordinate(m_center.atDistanceAndAzimuth(m_radius, 0.0).latitude(), -180.0), QGeoCoordinate(-90, 180.0));
- } else {
- // Regular circle not crossing anything
-
- // Calculate geo bounding box of the circle
- //
- // A circle tangential point with a meridian, together with pole and
- // the circle center create a spherical triangle.
- // Finding the tangential point with the spherical law of sines:
- //
- // * lon_delta_in_rad : delta between the circle center and a tangential
- // point (absolute value).
- // * r_in_rad : angular radius of the circle
- // * lat_in_rad : latitude of the circle center
- // * alpha_in_rad : angle between meridian and radius of the circle.
- // At the tangential point, sin(alpha_in_rad) == 1.
- // * lat_delta_in_rad - absolute delta of latitudes between the circle center and
- // any of the two points where the great circle going through the circle
- // center and the pole crosses the circle. In other words, the points
- // on the circle with azimuth 0 or 180.
- //
- // Using:
- // sin(lon_delta_in_rad)/sin(r_in_rad) = sin(alpha_in_rad)/sin(pi/2 - lat_in_rad)
-
- double r_in_rad = m_radius / QLocationUtils::earthMeanRadius(); // angular r
- double lat_delta_in_deg = QLocationUtils::degrees(r_in_rad);
- double lon_delta_in_deg = QLocationUtils::degrees(std::asin(
- std::sin(r_in_rad) /
- std::cos(QLocationUtils::radians(m_center.latitude()))
- ));
-
- QGeoCoordinate topLeft;
- topLeft.setLatitude(QLocationUtils::clipLat(m_center.latitude() + lat_delta_in_deg));
- topLeft.setLongitude(QLocationUtils::wrapLong(m_center.longitude() - lon_delta_in_deg));
- QGeoCoordinate bottomRight;
- bottomRight.setLatitude(QLocationUtils::clipLat(m_center.latitude() - lat_delta_in_deg));
- bottomRight.setLongitude(QLocationUtils::wrapLong(m_center.longitude() + lon_delta_in_deg));
-
- m_bbox = QGeoRectangle(topLeft, bottomRight);
- }
-}
-
-void QGeoCirclePrivate::setCenter(const QGeoCoordinate &c)
-{
- m_center = c;
- updateBoundingBox();
-}
-
-void QGeoCirclePrivate::setRadius(const qreal r)
-{
- m_radius = r;
- updateBoundingBox();
-}
-
-bool QGeoCirclePrivate::crossNorthPole() const
-{
- const QGeoCoordinate northPole(90.0, m_center.longitude());
- qreal distanceToPole = m_center.distanceTo(northPole);
- if (distanceToPole < m_radius)
- return true;
- return false;
-}
-
-bool QGeoCirclePrivate::crossSouthPole() const
-{
- const QGeoCoordinate southPole(-90.0, m_center.longitude());
- qreal distanceToPole = m_center.distanceTo(southPole);
- if (distanceToPole < m_radius)
- return true;
- return false;
-}
-
-/*
- Extends the circle to include \a coordinate.
-*/
-void QGeoCirclePrivate::extendCircle(const QGeoCoordinate &coordinate)
-{
- if (!isValid() || !coordinate.isValid() || contains(coordinate))
- return;
-
- setRadius(m_center.distanceTo(coordinate));
-}
-
-/*!
- Translates this geo circle by \a degreesLatitude northwards and \a degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-*/
-void QGeoCircle::translate(double degreesLatitude, double degreesLongitude)
-{
- // TODO handle dlat, dlon larger than 360 degrees
-
- Q_D(QGeoCircle);
-
- double lat = d->m_center.latitude();
- double lon = d->m_center.longitude();
-
- lat += degreesLatitude;
- lon += degreesLongitude;
- lon = QLocationUtils::wrapLong(lon);
-
- // TODO: remove this and simply clip latitude.
- if (lat > 90.0) {
- lat = 180.0 - lat;
- if (lon < 0.0)
- lon = 180.0;
- else
- lon -= 180;
- }
-
- if (lat < -90.0) {
- lat = 180.0 + lat;
- if (lon < 0.0)
- lon = 180.0;
- else
- lon -= 180;
- }
-
- d->setCenter(QGeoCoordinate(lat, lon));
-}
-
-/*!
- Returns a copy of this geo circle translated by \a degreesLatitude northwards and
- \a degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-
- \sa translate()
-*/
-QGeoCircle QGeoCircle::translated(double degreesLatitude, double degreesLongitude) const
-{
- QGeoCircle result(*this);
- result.translate(degreesLatitude, degreesLongitude);
- return result;
-}
-
-/*!
- Extends the geo circle to also cover the coordinate \a coordinate
-
- \since 5.9
-*/
-void QGeoCircle::extendCircle(const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoCircle);
- d->extendCircle(coordinate);
-}
-
-/*!
- Returns the geo circle properties as a string.
-
- \since 5.5
-*/
-
-QString QGeoCircle::toString() const
-{
- if (type() != QGeoShape::CircleType) {
- qWarning("Not a circle");
- return QStringLiteral("QGeoCircle(not a circle)");
- }
-
- return QStringLiteral("QGeoCircle({%1, %2}, %3)")
- .arg(center().latitude())
- .arg(center().longitude())
- .arg(radius());
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoCirclePrivate::QGeoCirclePrivate()
-: QGeoShapePrivate(QGeoShape::CircleType), m_radius(-1.0)
-{
-}
-
-QGeoCirclePrivate::QGeoCirclePrivate(const QGeoCoordinate &center, qreal radius)
-: QGeoShapePrivate(QGeoShape::CircleType), m_center(center), m_radius(radius)
-{
- updateBoundingBox();
-}
-
-QGeoCirclePrivate::QGeoCirclePrivate(const QGeoCirclePrivate &other)
-: QGeoShapePrivate(QGeoShape::CircleType), m_center(other.m_center),
- m_radius(other.m_radius), m_bbox(other.m_bbox)
-{
-}
-
-QGeoCirclePrivate::~QGeoCirclePrivate() {}
-
-QGeoShapePrivate *QGeoCirclePrivate::clone() const
-{
- return new QGeoCirclePrivate(*this);
-}
-
-bool QGeoCirclePrivate::operator==(const QGeoShapePrivate &other) const
-{
- if (!QGeoShapePrivate::operator==(other))
- return false;
-
- const QGeoCirclePrivate &otherCircle = static_cast<const QGeoCirclePrivate &>(other);
-
- return m_radius == otherCircle.m_radius && m_center == otherCircle.m_center;
-}
-
-size_t QGeoCirclePrivate::hash(size_t seed) const
-{
- return qHashMulti(seed, m_center, m_radius);
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeocircle.h b/src/positioning/qgeocircle.h
deleted file mode 100644
index e02ae4a9..00000000
--- a/src/positioning/qgeocircle.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOCIRCLE_H
-#define QGEOCIRCLE_H
-
-#include <QtPositioning/QGeoRectangle>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QGeoCirclePrivate;
-
-class Q_POSITIONING_EXPORT QGeoCircle : public QGeoShape
-{
- Q_GADGET
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
- Q_PROPERTY(qreal radius READ radius WRITE setRadius)
-
-public:
- QGeoCircle();
- QGeoCircle(const QGeoCoordinate &center, qreal radius = -1.0);
- QGeoCircle(const QGeoCircle &other);
- QGeoCircle(const QGeoShape &other);
-
- ~QGeoCircle();
-
- QGeoCircle &operator=(const QGeoCircle &other);
-
- void setCenter(const QGeoCoordinate &center);
- QGeoCoordinate center() const;
-
- void setRadius(qreal radius);
- qreal radius() const;
-
- Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
- Q_INVOKABLE QGeoCircle translated(double degreesLatitude, double degreesLongitude) const;
- Q_INVOKABLE void extendCircle(const QGeoCoordinate &coordinate);
-
- Q_INVOKABLE QString toString() const;
-
-private:
- inline QGeoCirclePrivate *d_func();
- inline const QGeoCirclePrivate *d_func() const;
-};
-
-Q_DECLARE_TYPEINFO(QGeoCircle, Q_RELOCATABLE_TYPE);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoCircle)
-
-#endif
-
diff --git a/src/positioning/qgeocircle_p.h b/src/positioning/qgeocircle_p.h
deleted file mode 100644
index 65f1d9d1..00000000
--- a/src/positioning/qgeocircle_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOCIRCLE_P_H
-#define QGEOCIRCLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeoshape_p.h"
-#include "qgeocoordinate.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCirclePrivate : public QGeoShapePrivate
-{
-public:
- QGeoCirclePrivate();
- QGeoCirclePrivate(const QGeoCoordinate &center, qreal radius);
- QGeoCirclePrivate(const QGeoCirclePrivate &other);
- ~QGeoCirclePrivate();
-
- bool isValid() const override;
- bool isEmpty() const override;
- bool contains(const QGeoCoordinate &coordinate) const override;
-
- QGeoCoordinate center() const override;
-
- QGeoRectangle boundingGeoRectangle() const override;
-
- bool crossNorthPole() const;
- bool crossSouthPole() const;
- void updateBoundingBox();
- void setCenter(const QGeoCoordinate &c);
- void setRadius(const qreal r);
-
- void extendCircle(const QGeoCoordinate &coordinate);
-
- QGeoShapePrivate *clone() const override;
-
- bool operator==(const QGeoShapePrivate &other) const override;
-
- size_t hash(size_t seed) const override;
-
- QGeoCoordinate m_center;
- qreal m_radius;
- QGeoRectangle m_bbox;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeocoordinate.cpp b/src/positioning/qgeocoordinate.cpp
deleted file mode 100644
index 58c2ee15..00000000
--- a/src/positioning/qgeocoordinate.cpp
+++ /dev/null
@@ -1,792 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qgeocoordinate.h"
-#include "qgeocoordinate_p.h"
-#include "qlocationutils_p.h"
-
-#include <QDateTime>
-#include <QHash>
-#include <QDataStream>
-#include <QDebug>
-#include <QMetaType>
-#include <qnumeric.h>
-#include <qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-
-static const double qgeocoordinate_EARTH_MEAN_RADIUS = 6371.0072;
-
-
-QGeoCoordinatePrivate::QGeoCoordinatePrivate():
- lat(qQNaN()),
- lng(qQNaN()),
- alt(qQNaN())
-{}
-
-QGeoCoordinatePrivate::QGeoCoordinatePrivate(const QGeoCoordinatePrivate &other)
- : QSharedData(other),
- lat(other.lat),
- lng(other.lng),
- alt(other.alt)
-{}
-
-QGeoCoordinatePrivate::~QGeoCoordinatePrivate()
-{}
-
-
-QGeoMercatorCoordinatePrivate::QGeoMercatorCoordinatePrivate():
- QGeoCoordinatePrivate(),
- m_mercatorX(qQNaN()),
- m_mercatorY(qQNaN())
-{}
-
-QGeoMercatorCoordinatePrivate::QGeoMercatorCoordinatePrivate(const QGeoMercatorCoordinatePrivate &other)
- : QGeoCoordinatePrivate(other),
- m_mercatorX(other.m_mercatorX),
- m_mercatorY(other.m_mercatorY)
-{}
-
-QGeoMercatorCoordinatePrivate::~QGeoMercatorCoordinatePrivate()
-{}
-
-/*!
- \class QGeoCoordinate
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QGeoCoordinate class defines a geographical position on the surface of the Earth.
-
- A QGeoCoordinate is defined by latitude, longitude, and optionally, altitude.
-
- Use type() to determine whether a coordinate is a 2D coordinate (has
- latitude and longitude only) or 3D coordinate (has latitude, longitude
- and altitude). Use distanceTo() and azimuthTo() to calculate the distance
- and bearing between coordinates.
-
- The coordinate values should be specified using the WGS84 datum. For more information
- on geographical terms see this article on \l {http://en.wikipedia.org/wiki/Geographic_coordinate_system}{coordinates} and
- another on \l {http://en.wikipedia.org/wiki/Geodetic_system}{geodetic systems}
- including WGS84.
-
- Azimuth in this context is equivalent to a compass bearing based on true north.
-
- This class is a \l Q_GADGET since Qt 5.5. It can be
- \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.
-*/
-
-/*!
- \enum QGeoCoordinate::CoordinateType
- Defines the types of a coordinate.
-
- \value InvalidCoordinate An invalid coordinate. A coordinate is invalid if its latitude or longitude values are invalid.
- \value Coordinate2D A coordinate with valid latitude and longitude values.
- \value Coordinate3D A coordinate with valid latitude and longitude values, and also an altitude value.
-*/
-
-/*!
- \enum QGeoCoordinate::CoordinateFormat
- Defines the possible formatting options for toString().
-
- \value Degrees Returns a string representation of the coordinates in decimal degrees format.
- \value DegreesWithHemisphere Returns a string representation of the coordinates in decimal degrees format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
- \value DegreesMinutes Returns a string representation of the coordinates in degrees-minutes format.
- \value DegreesMinutesWithHemisphere Returns a string representation of the coordinates in degrees-minutes format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
- \value DegreesMinutesSeconds Returns a string representation of the coordinates in degrees-minutes-seconds format.
- \value DegreesMinutesSecondsWithHemisphere Returns a string representation of the coordinates in degrees-minutes-seconds format, using 'N', 'S', 'E' or 'W' to indicate the hemispheres of the coordinates.
-
- \sa toString()
-*/
-
-/*!
- \property QGeoCoordinate::latitude
- \brief This property holds the latitude in decimal degrees.
-
- The property is undefined (\l {qQNaN()}) if the latitude has not been set.
- A positive latitude indicates the Northern Hemisphere, and a negative
- latitude indicates the Southern Hemisphere. When setting the latitude the
- new value should be in the
- \l {http://en.wikipedia.org/wiki/World_Geodetic_System}{WGS84} datum format.
-
- To be valid, the latitude must be between -90 to 90 inclusive.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoCoordinate::longitude
- \brief This property holds the longitude in decimal degrees.
-
- The property is undefined (\l {qQNaN()}) if the longitude has not been set.
- A positive longitude indicates the Eastern Hemisphere, and a negative
- longitude indicates the Western Hemisphere. When setting the longitude the
- new value should be in the
- \l {http://en.wikipedia.org/wiki/World_Geodetic_System}{WGS84} datum format.
-
- To be valid, the longitude must be between -180 to 180 inclusive.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoCoordinate::altitude
- \brief This property holds the altitude in meters above sea level.
-
- The property is undefined (\l {qQNaN()}) if the altitude has not been set.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoCoordinate::isValid
- \brief This property holds the validity of this geo coordinate.
-
- The geo coordinate is valid if the \l [CPP]{longitude} and \l [CPP]{latitude}
- properties have been set to valid values.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- Constructs a coordinate. The coordinate will be invalid until
- setLatitude() and setLongitude() have been called.
-*/
-QGeoCoordinate::QGeoCoordinate()
- : d(new QGeoCoordinatePrivate)
-{
-}
-
-/*!
- Constructs a coordinate with the given \a latitude and \a longitude.
-
- If the latitude is not between -90 to 90 inclusive, or the longitude
- is not between -180 to 180 inclusive, none of the values are set and
- the type() will be QGeoCoordinate::InvalidCoordinate.
-
- \sa isValid()
-*/
-QGeoCoordinate::QGeoCoordinate(double latitude, double longitude)
- : d(new QGeoCoordinatePrivate)
-{
- if (QLocationUtils::isValidLat(latitude) && QLocationUtils::isValidLong(longitude)) {
- d->lat = latitude;
- d->lng = longitude;
- }
-}
-
-/*!
- Constructs a coordinate with the given \a latitude, \a longitude
- and \a altitude.
-
- If the latitude is not between -90 to 90 inclusive, or the longitude
- is not between -180 to 180 inclusive, none of the values are set and
- the type() will be QGeoCoordinate::InvalidCoordinate.
-
- Note that \a altitude specifies the meters above sea level.
-
- \sa isValid()
-*/
-QGeoCoordinate::QGeoCoordinate(double latitude, double longitude, double altitude)
- : d(new QGeoCoordinatePrivate)
-{
- if (QLocationUtils::isValidLat(latitude) && QLocationUtils::isValidLong(longitude)) {
- d->lat = latitude;
- d->lng = longitude;
- d->alt = altitude;
- }
-}
-
-/*!
- Constructs a coordinate from the contents of \a other.
-*/
-QGeoCoordinate::QGeoCoordinate(const QGeoCoordinate &other)
- : d(other.d)
-{}
-
-/*!
- \fn QGeoCoordinate::QGeoCoordinate(QGeoCoordinate &&other)
- \since 6.2
-
- Constructs a coordinate by moving from \a other.
-
- \note The moved-from QGeoCoordinate object can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- Assigns \a other to this coordinate and returns a reference to this coordinate.
-*/
-QGeoCoordinate &QGeoCoordinate::operator=(const QGeoCoordinate &other)
-{
- if (this == &other)
- return *this;
-
- d = other.d;
- return (*this);
-}
-
-/*!
- \fn QGeoCoordinate &QGeoCoordinate::operator=(QGeoCoordinate &&other)
- \since 6.2
-
- Move-assigns \a other to this coordinate and returns a reference to this
- coordinate.
-
- \note The moved-from QGeoCoordinate object can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- Destroys the coordinate object.
-*/
-QGeoCoordinate::~QGeoCoordinate()
-{
-}
-
-QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoCoordinatePrivate)
-
-/*!
- \fn bool QGeoCoordinate::operator==(const QGeoCoordinate &lhs, const QGeoCoordinate &rhs)
-
- Returns \c true if the latitude, longitude and altitude of the \a lhs
- coordinate are the same as those of the \a rhs coordinate. Otherwise
- returns \c false.
-
- The longitude will be ignored if the latitude is +/- 90 degrees.
-*/
-
-/*!
- \fn bool QGeoCoordinate::operator!=(const QGeoCoordinate &lhs, const QGeoCoordinate &rhs)
-
- Returns \c true if latitude, longitude, or altitude of the \a lhs
- coordinate are not identical to those of the \a rhs coordinate. Otherwise
- returns \c false.
-*/
-
-/*!
- Returns \c true if the \l longitude and \l latitude are valid.
-*/
-bool QGeoCoordinate::isValid() const
-{
- CoordinateType t = type();
- return t == Coordinate2D || t == Coordinate3D;
-}
-
-/*!
- Returns the type of this coordinate.
-*/
-QGeoCoordinate::CoordinateType QGeoCoordinate::type() const
-{
- if (QLocationUtils::isValidLat(d->lat)
- && QLocationUtils::isValidLong(d->lng)) {
- if (qIsNaN(d->alt))
- return Coordinate2D;
- return Coordinate3D;
- }
- return InvalidCoordinate;
-}
-
-
-/*!
- Returns the latitude, in decimal degrees. The return value is undefined
- if the latitude has not been set.
-
- A positive latitude indicates the Northern Hemisphere, and a negative
- latitude indicates the Southern Hemisphere.
-
- \sa setLatitude(), type()
-*/
-double QGeoCoordinate::latitude() const
-{
- return d->lat;
-}
-
-/*!
- Sets the latitude (in decimal degrees) to \a latitude. The value should
- be in the WGS84 datum.
-
- To be valid, the latitude must be between -90 to 90 inclusive.
-
- \sa latitude()
-*/
-void QGeoCoordinate::setLatitude(double latitude)
-{
- d->lat = latitude;
-}
-
-/*!
- Returns the longitude, in decimal degrees. The return value is undefined
- if the longitude has not been set.
-
- A positive longitude indicates the Eastern Hemisphere, and a negative
- longitude indicates the Western Hemisphere.
-
- \sa setLongitude(), type()
-*/
-double QGeoCoordinate::longitude() const
-{
- return d->lng;
-}
-
-/*!
- Sets the longitude (in decimal degrees) to \a longitude. The value should
- be in the WGS84 datum.
-
- To be valid, the longitude must be between -180 to 180 inclusive.
-
- \sa longitude()
-*/
-void QGeoCoordinate::setLongitude(double longitude)
-{
- d->lng = longitude;
-}
-
-/*!
- Returns the altitude (meters above sea level).
-
- The return value is undefined if the altitude has not been set.
-
- \sa setAltitude(), type()
-*/
-double QGeoCoordinate::altitude() const
-{
- return d->alt;
-}
-
-/*!
- Sets the altitude (meters above sea level) to \a altitude.
-
- \sa altitude()
-*/
-void QGeoCoordinate::setAltitude(double altitude)
-{
- d->alt = altitude;
-}
-
-/*!
- Returns the distance (in meters) from this coordinate to the coordinate
- specified by \a other. Altitude is not used in the calculation.
-
- This calculation returns the great-circle distance between the two
- coordinates, with an assumption that the Earth is spherical for the
- purpose of this calculation.
-
- Returns 0 if the type of this coordinate or the type of \a other is
- QGeoCoordinate::InvalidCoordinate.
-*/
-qreal QGeoCoordinate::distanceTo(const QGeoCoordinate &other) const
-{
- if (type() == QGeoCoordinate::InvalidCoordinate
- || other.type() == QGeoCoordinate::InvalidCoordinate) {
- return 0;
- }
-
- // Haversine formula
- double dlat = qDegreesToRadians(other.d->lat - d->lat);
- double dlon = qDegreesToRadians(other.d->lng - d->lng);
- double haversine_dlat = sin(dlat / 2.0);
- haversine_dlat *= haversine_dlat;
- double haversine_dlon = sin(dlon / 2.0);
- haversine_dlon *= haversine_dlon;
- double y = haversine_dlat
- + cos(qDegreesToRadians(d->lat))
- * cos(qDegreesToRadians(other.d->lat))
- * haversine_dlon;
- double x = 2 * asin(sqrt(y));
- return qreal(x * qgeocoordinate_EARTH_MEAN_RADIUS * 1000);
-}
-
-/*!
- Returns the azimuth (or bearing) in degrees from this coordinate to the
- coordinate specified by \a other. Altitude is not used in the calculation.
-
- The bearing returned is the bearing from the origin to \a other along the
- great-circle between the two coordinates. There is an assumption that the
- Earth is spherical for the purpose of this calculation.
-
- Returns 0 if the type of this coordinate or the type of \a other is
- QGeoCoordinate::InvalidCoordinate.
-*/
-qreal QGeoCoordinate::azimuthTo(const QGeoCoordinate &other) const
-{
- if (type() == QGeoCoordinate::InvalidCoordinate
- || other.type() == QGeoCoordinate::InvalidCoordinate) {
- return 0;
- }
-
- double dlon = qDegreesToRadians(other.d->lng - d->lng);
- double lat1Rad = qDegreesToRadians(d->lat);
- double lat2Rad = qDegreesToRadians(other.d->lat);
-
- double y = sin(dlon) * cos(lat2Rad);
- double x = cos(lat1Rad) * sin(lat2Rad) - sin(lat1Rad) * cos(lat2Rad) * cos(dlon);
-
- double azimuth = qRadiansToDegrees(atan2(y, x)) + 360.0;
- double whole;
- double fraction = modf(azimuth, &whole);
- return qreal((int(whole + 360) % 360) + fraction);
-}
-
-void QGeoCoordinatePrivate::atDistanceAndAzimuth(const QGeoCoordinate &coord,
- qreal distance, qreal azimuth,
- double *lon, double *lat)
-{
- double latRad = qDegreesToRadians(coord.d->lat);
- double lonRad = qDegreesToRadians(coord.d->lng);
- double cosLatRad = cos(latRad);
- double sinLatRad = sin(latRad);
-
- double azimuthRad = qDegreesToRadians(azimuth);
-
- double ratio = (distance / (qgeocoordinate_EARTH_MEAN_RADIUS * 1000.0));
- double cosRatio = cos(ratio);
- double sinRatio = sin(ratio);
-
- double resultLatRad = asin(sinLatRad * cosRatio
- + cosLatRad * sinRatio * cos(azimuthRad));
- double resultLonRad = lonRad + atan2(sin(azimuthRad) * sinRatio * cosLatRad,
- cosRatio - sinLatRad * sin(resultLatRad));
-
- *lat = qRadiansToDegrees(resultLatRad);
- *lon = qRadiansToDegrees(resultLonRad);
-}
-
-/*!
- Returns the coordinate that is reached by traveling \a distance meters
- from the current coordinate at \a azimuth (or bearing) along a great-circle.
- There is an assumption that the Earth is spherical for the purpose of this
- calculation.
-
- The altitude will have \a distanceUp added to it.
-
- Returns an invalid coordinate if this coordinate is invalid.
-*/
-QGeoCoordinate QGeoCoordinate::atDistanceAndAzimuth(qreal distance, qreal azimuth, qreal distanceUp) const
-{
- if (!isValid())
- return QGeoCoordinate();
-
- double resultLon, resultLat;
- QGeoCoordinatePrivate::atDistanceAndAzimuth(*this, distance, azimuth,
- &resultLon, &resultLat);
- double resultAlt = d->alt + distanceUp;
- return QGeoCoordinate(resultLat, QLocationUtils::wrapLong(resultLon), resultAlt);
-}
-
-/*!
- Returns this coordinate as a string in the specified \a format.
-
- For example, if this coordinate has a latitude of -27.46758, a longitude
- of 153.027892 and an altitude of 28.1, these are the strings
- returned depending on \a format:
-
- \table
- \header
- \li \a format value
- \li Returned string
- \row
- \li \l Degrees
- \li -27.46758\unicode{0xB0}, 153.02789\unicode{0xB0}, 28.1m
- \row
- \li \l DegreesWithHemisphere
- \li 27.46758\unicode{0xB0} S, 153.02789\unicode{0xB0} E, 28.1m
- \row
- \li \l DegreesMinutes
- \li -27\unicode{0xB0} 28.054', 153\unicode{0xB0} 1.673', 28.1m
- \row
- \li \l DegreesMinutesWithHemisphere
- \li 27\unicode{0xB0} 28.054 S', 153\unicode{0xB0} 1.673' E, 28.1m
- \row
- \li \l DegreesMinutesSeconds
- \li -27\unicode{0xB0} 28' 3.2", 153\unicode{0xB0} 1' 40.4", 28.1m
- \row
- \li \l DegreesMinutesSecondsWithHemisphere
- \li 27\unicode{0xB0} 28' 3.2" S, 153\unicode{0xB0} 1' 40.4" E, 28.1m
- \endtable
-
- The altitude field is omitted if no altitude is set.
-
- If the coordinate is invalid, an empty string is returned.
-*/
-QString QGeoCoordinate::toString(CoordinateFormat format) const
-{
- if (type() == QGeoCoordinate::InvalidCoordinate)
- return QString();
-
- QString latStr;
- QString longStr;
-
- double absLat = qAbs(d->lat);
- double absLng = qAbs(d->lng);
- QChar symbol(0x00B0); // degrees symbol
-
- switch (format) {
- case Degrees:
- case DegreesWithHemisphere: {
- latStr = QString::number(absLat, 'f', 5) + symbol;
- longStr = QString::number(absLng, 'f', 5) + symbol;
- break;
- }
- case DegreesMinutes:
- case DegreesMinutesWithHemisphere: {
- double latMin = (absLat - int(absLat)) * 60;
- double lngMin = (absLng - int(absLng)) * 60;
-
- // We use QString::number(val, 'f', 3) to represent minutes.
- // It rounds up to the next integer in case the fraction > 0.9995.
- // Such behavior should be handled specifically when the rounded
- // value is 60, so that we overflow to degrees correctly.
- // If we overflow, the minutes should unconditionally be 0.0.
- if (latMin > 59.9995) {
- absLat++;
- latMin = 0.0f;
- }
- if (lngMin > 59.9995) {
- absLng++;
- lngMin = 0.0f;
- }
-
- latStr = QString::fromLatin1("%1%2 %3'")
- .arg(QString::number(int(absLat)))
- .arg(symbol)
- .arg(QString::number(latMin, 'f', 3));
- longStr = QString::fromLatin1("%1%2 %3'")
- .arg(QString::number(int(absLng)))
- .arg(symbol)
- .arg(QString::number(lngMin, 'f', 3));
- break;
- }
- case DegreesMinutesSeconds:
- case DegreesMinutesSecondsWithHemisphere: {
- double latMin = (absLat - int(absLat)) * 60;
- double lngMin = (absLng - int(absLng)) * 60;
- double latSec = (latMin - int(latMin)) * 60;
- double lngSec = (lngMin - int(lngMin)) * 60;
-
- // We use QString::number(val, 'f', 1) to represent seconds.
- // It rounds up to the next integer in case the fraction >= 0.95.
- // Such behavior should be handled specifically when the rounded
- // value is 60, so that we overflow to minutes correctly.
- // If we overflow, the seconds should unconditionally be 0.0.
- if (latSec >= 59.95) {
- latMin++;
- latSec = 0.0f;
- // We cast to int to represent minutes, so we can use qRound()
- // to determine if we need to overflow to full degrees.
- // If we overflow, the minutes will unconditionally be 0.0.
- if (qRound(latMin) >= 60) {
- absLat++;
- latMin = 0.0f;
- }
- }
- if (lngSec >= 59.95) {
- lngMin++;
- lngSec = 0.0f;
- if (qRound(lngMin) >= 60) {
- absLng++;
- lngMin = 0.0f;
- }
- }
-
- latStr = QString::fromLatin1("%1%2 %3' %4\"")
- .arg(QString::number(int(absLat)))
- .arg(symbol)
- .arg(QString::number(int(latMin)))
- .arg(QString::number(latSec, 'f', 1));
- longStr = QString::fromLatin1("%1%2 %3' %4\"")
- .arg(QString::number(int(absLng)))
- .arg(symbol)
- .arg(QString::number(int(lngMin)))
- .arg(QString::number(lngSec, 'f', 1));
- break;
- }
- }
-
- // now add the "-" to the start, or append the hemisphere char
- switch (format) {
- case Degrees:
- case DegreesMinutes:
- case DegreesMinutesSeconds: {
- if (d->lat < 0)
- latStr.insert(0, QStringLiteral("-"));
- if (d->lng < 0)
- longStr.insert(0, QStringLiteral("-"));
- break;
- }
- case DegreesWithHemisphere:
- case DegreesMinutesWithHemisphere:
- case DegreesMinutesSecondsWithHemisphere: {
- if (d->lat < 0)
- latStr.append(QString::fromLatin1(" S"));
- else if (d->lat > 0)
- latStr.append(QString::fromLatin1(" N"));
- if (d->lng < 0)
- longStr.append(QString::fromLatin1(" W"));
- else if (d->lng > 0)
- longStr.append(QString::fromLatin1(" E"));
- break;
- }
- }
-
- if (qIsNaN(d->alt))
- return QString::fromLatin1("%1, %2").arg(latStr, longStr);
- return QString::fromLatin1("%1, %2, %3m").arg(latStr, longStr, QString::number(d->alt));
-}
-
-bool QGeoCoordinate::equals(const QGeoCoordinate &lhs, const QGeoCoordinate &rhs)
-{
- bool latEqual = (qIsNaN(lhs.d->lat) && qIsNaN(rhs.d->lat))
- || qFuzzyCompare(lhs.d->lat, rhs.d->lat);
- bool lngEqual = (qIsNaN(lhs.d->lng) && qIsNaN(rhs.d->lng))
- || qFuzzyCompare(lhs.d->lng, rhs.d->lng);
- bool altEqual = (qIsNaN(lhs.d->alt) && qIsNaN(rhs.d->alt))
- || qFuzzyCompare(lhs.d->alt, rhs.d->alt);
-
- if (!qIsNaN(lhs.d->lat) && ((lhs.d->lat == 90.0) || (lhs.d->lat == -90.0)))
- lngEqual = true;
-
- return (latEqual && lngEqual && altEqual);
-}
-
-QGeoCoordinate::QGeoCoordinate(QGeoCoordinatePrivate &dd):
- d(&dd)
-{
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug QGeoCoordinate::debugStreaming(QDebug dbg, const QGeoCoordinate &coord)
-{
- QDebugStateSaver saver(dbg);
- double lat = coord.latitude();
- double lng = coord.longitude();
-
- QTextStreamManipulator tsm = qSetRealNumberPrecision(11);
- dbg << tsm;
- dbg.nospace() << "QGeoCoordinate(";
- if (qIsNaN(lat))
- dbg << '?';
- else
- dbg << lat;
- dbg << ", ";
- if (qIsNaN(lng))
- dbg << '?';
- else
- dbg << lng;
- if (coord.type() == QGeoCoordinate::Coordinate3D) {
- dbg << ", ";
- dbg << coord.altitude();
- }
- dbg << ')';
- return dbg;
-}
-#endif
-
-#ifndef QT_NO_DATASTREAM
-/*!
- \fn QDataStream &QGeoCoordinate::operator<<(QDataStream &stream, const QGeoCoordinate &coordinate)
-
- Writes the given \a coordinate to the specified \a stream.
-
- \sa {Serializing Qt Data Types}
-*/
-
-QDataStream &QGeoCoordinate::dataStreamOut(QDataStream &stream, const QGeoCoordinate &coordinate)
-{
- stream << coordinate.latitude();
- stream << coordinate.longitude();
- stream << coordinate.altitude();
- return stream;
-}
-#endif
-
-#ifndef QT_NO_DATASTREAM
-/*!
- \fn QDataStream &QGeoCoordinate::operator>>(QDataStream &stream, QGeoCoordinate &coordinate)
-
- Reads a coordinate from the specified \a stream into the given
- \a coordinate.
-
- \sa {Serializing Qt Data Types}
-*/
-
-QDataStream &QGeoCoordinate::dataStreamIn(QDataStream &stream, QGeoCoordinate &coordinate)
-{
- double value;
- stream >> value;
- coordinate.setLatitude(value);
- stream >> value;
- coordinate.setLongitude(value);
- stream >> value;
- coordinate.setAltitude(value);
- return stream;
-}
-#endif
-
-/*! \fn size_t qHash(const QGeoCoordinate &coordinate, size_t seed = 0)
- \relates QHash
-
- Returns a hash value for \a coordinate, using \a seed to seed the calculation.
-*/
-size_t qHash(const QGeoCoordinate &coordinate, size_t seed)
-{
- QtPrivate::QHashCombine hash;
- // north and south pole are geographically equivalent (no matter the longitude)
- if (coordinate.latitude() != 90.0 && coordinate.latitude() != -90.0)
- seed = hash(seed, coordinate.longitude());
- seed = hash(seed, coordinate.latitude());
- seed = hash(seed, coordinate.altitude());
- return seed;
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeocoordinate.h b/src/positioning/qgeocoordinate.h
deleted file mode 100644
index 46a539a2..00000000
--- a/src/positioning/qgeocoordinate.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOCOORDINATE_H
-#define QGEOCOORDINATE_H
-
-#include <QtCore/QMetaType>
-#include <QtCore/QString>
-#include <QtCore/QSharedDataPointer>
-#include <QtCore/QDebug>
-#include <QtPositioning/qpositioningglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDebug;
-class QDataStream;
-
-class QGeoCoordinatePrivate;
-QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGeoCoordinatePrivate, Q_POSITIONING_EXPORT)
-
-class Q_POSITIONING_EXPORT QGeoCoordinate
-{
- Q_GADGET
- Q_ENUMS(CoordinateFormat)
-
- Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
- Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
- Q_PROPERTY(double altitude READ altitude WRITE setAltitude)
- Q_PROPERTY(bool isValid READ isValid)
-
-public:
-
- enum CoordinateType {
- InvalidCoordinate,
- Coordinate2D,
- Coordinate3D
- };
-
- enum CoordinateFormat {
- Degrees,
- DegreesWithHemisphere,
- DegreesMinutes,
- DegreesMinutesWithHemisphere,
- DegreesMinutesSeconds,
- DegreesMinutesSecondsWithHemisphere
- };
-
- QGeoCoordinate();
- QGeoCoordinate(double latitude, double longitude);
- QGeoCoordinate(double latitude, double longitude, double altitude);
- QGeoCoordinate(const QGeoCoordinate &other);
- QGeoCoordinate(QGeoCoordinate &&other) noexcept = default;
- ~QGeoCoordinate();
-
- QGeoCoordinate &operator=(const QGeoCoordinate &other);
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGeoCoordinate)
-
- void swap(QGeoCoordinate &other) noexcept { d.swap(other.d); }
-
- friend bool operator==(const QGeoCoordinate &lhs, const QGeoCoordinate &rhs)
- {
- return equals(lhs, rhs);
- }
- friend bool operator!=(const QGeoCoordinate &lhs, const QGeoCoordinate &rhs)
- {
- return !equals(lhs, rhs);
- }
-
- bool isValid() const;
- CoordinateType type() const;
-
- void setLatitude(double latitude);
- double latitude() const;
-
- void setLongitude(double longitude);
- double longitude() const;
-
- void setAltitude(double altitude);
- double altitude() const;
-
- Q_INVOKABLE qreal distanceTo(const QGeoCoordinate &other) const;
- Q_INVOKABLE qreal azimuthTo(const QGeoCoordinate &other) const;
-
- Q_INVOKABLE QGeoCoordinate atDistanceAndAzimuth(qreal distance, qreal azimuth, qreal distanceUp = 0.0) const;
-
- Q_INVOKABLE QString toString(CoordinateFormat format = DegreesMinutesSecondsWithHemisphere) const;
-
-private:
- static bool equals(const QGeoCoordinate &lhs, const QGeoCoordinate &rhs);
- QGeoCoordinate(QGeoCoordinatePrivate &dd);
- QSharedDataPointer<QGeoCoordinatePrivate> d;
- friend class QGeoCoordinatePrivate;
- friend class QQuickGeoCoordinateAnimation;
-#ifndef QT_NO_DEBUG_STREAM
- friend QDebug operator<<(QDebug dbg, const QGeoCoordinate &coord)
- {
- return debugStreaming(dbg, coord);
- }
- static QDebug debugStreaming(QDebug dbg, const QGeoCoordinate &coord);
-#endif
-#ifndef QT_NO_DATASTREAM
- friend QDataStream &operator<<(QDataStream &stream, const QGeoCoordinate &coordinate)
- {
- return dataStreamOut(stream, coordinate);
- }
- friend QDataStream &operator>>(QDataStream &stream, QGeoCoordinate &coordinate)
- {
- return dataStreamIn(stream, coordinate);
- }
- static QDataStream &dataStreamOut(QDataStream &stream, const QGeoCoordinate &coordinate);
- static QDataStream &dataStreamIn(QDataStream &stream, QGeoCoordinate &coordinate);
-#endif
-};
-
-Q_DECLARE_SHARED(QGeoCoordinate)
-
-
-Q_POSITIONING_EXPORT size_t qHash(const QGeoCoordinate &coordinate, size_t seed = 0);
-
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoCoordinate)
-
-#endif
diff --git a/src/positioning/qgeocoordinate_p.h b/src/positioning/qgeocoordinate_p.h
deleted file mode 100644
index e00cbfa0..00000000
--- a/src/positioning/qgeocoordinate_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOCOORDINATE_P_H
-#define QGEOCOORDINATE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QSharedData>
-#include "qgeocoordinate.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinatePrivate : public QSharedData
-{
-public:
- QGeoCoordinatePrivate();
- QGeoCoordinatePrivate(const QGeoCoordinatePrivate &other);
- ~QGeoCoordinatePrivate();
-
- double lat;
- double lng;
- double alt;
-
- static void atDistanceAndAzimuth(const QGeoCoordinate &coord,
- qreal distance, qreal azimuth,
- double *lon, double *lat);
- static const QGeoCoordinatePrivate *get(const QGeoCoordinate *c) {
- return c->d.constData();
- }
-};
-
-class Q_POSITIONING_EXPORT QGeoMercatorCoordinatePrivate : public QGeoCoordinatePrivate
-{
-public:
- QGeoMercatorCoordinatePrivate();
- QGeoMercatorCoordinatePrivate(const QGeoMercatorCoordinatePrivate &other);
- ~QGeoMercatorCoordinatePrivate();
-
- double m_mercatorX;
- double m_mercatorY;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QGEOCOORDINATE_P_H
diff --git a/src/positioning/qgeocoordinateobject.cpp b/src/positioning/qgeocoordinateobject.cpp
deleted file mode 100644
index af79470e..00000000
--- a/src/positioning/qgeocoordinateobject.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeocoordinateobject_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*
-
- Note: This class only purpose is to enable conversion between QGeoCoordinate and QDeclarativeGeoWaypoint.
- Since QGeoCoordinate lives in the QtPositioning module, this class acts as a base for QDeclarativeGeoWaypoint,
- and contains the bare minimum to convert/compare to a QGeoCoordinate
-
-*/
-
-QGeoCoordinateObject::QGeoCoordinateObject(QObject *parent) : QObject(parent)
-{
-}
-
-QGeoCoordinateObject::QGeoCoordinateObject(const QGeoCoordinate &c, QObject *parent) : QObject(parent)
-{
- setCoordinate(c);
-}
-
-QGeoCoordinateObject::~QGeoCoordinateObject()
-{
-
-}
-
-bool QGeoCoordinateObject::operator==(const QGeoCoordinateObject &other) const
-{
- return m_coordinate.value() == other.m_coordinate.value();
-}
-
-bool QGeoCoordinateObject::operator==(const QGeoCoordinate &other) const
-{
- return m_coordinate.value() == other;
-}
-
-QGeoCoordinate QGeoCoordinateObject::coordinate() const
-{
- return m_coordinate;
-}
-
-void QGeoCoordinateObject::setCoordinate(const QGeoCoordinate &c)
-{
- m_coordinate = c; // The signal is emitted automatically if needed
-}
-
-QBindable<QGeoCoordinate> QGeoCoordinateObject::bindableCoordinate()
-{
- return QBindable<QGeoCoordinate>(&m_coordinate);
-}
-
-QT_END_NAMESPACE
-
-
diff --git a/src/positioning/qgeocoordinateobject_p.h b/src/positioning/qgeocoordinateobject_p.h
deleted file mode 100644
index 65d47fe5..00000000
--- a/src/positioning/qgeocoordinateobject_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOCOORDINATEOBJECT_P_H
-#define QGEOCOORDINATEOBJECT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include <QObject>
-#include <QGeoCoordinate>
-#include <QVariantMap>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONING_PRIVATE_EXPORT QGeoCoordinateObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY
- coordinateChanged BINDABLE bindableCoordinate)
-
-public:
- QGeoCoordinateObject(QObject *parent = 0);
- QGeoCoordinateObject(const QGeoCoordinate &c, QObject *parent = 0);
- virtual ~QGeoCoordinateObject();
-
- bool operator==(const QGeoCoordinate &other) const;
- bool operator==(const QGeoCoordinateObject &other) const;
- inline bool operator!=(const QGeoCoordinate &other) const {
- return !operator==(other);
- }
- inline bool operator!=(const QGeoCoordinateObject &other) const {
- return !operator==(other);
- }
-
- QGeoCoordinate coordinate() const;
- void setCoordinate(const QGeoCoordinate &c);
- QBindable<QGeoCoordinate> bindableCoordinate();
-
-Q_SIGNALS:
- void coordinateChanged();
-
-protected:
- Q_OBJECT_BINDABLE_PROPERTY(QGeoCoordinateObject, QGeoCoordinate, m_coordinate,
- &QGeoCoordinateObject::coordinateChanged)
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoCoordinateObject*)
-
-#endif // QGEOCOORDINATEOBJECT_P_H
diff --git a/src/positioning/qgeolocation.cpp b/src/positioning/qgeolocation.cpp
deleted file mode 100644
index a7c86f1f..00000000
--- a/src/positioning/qgeolocation.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeolocation.h"
-#include "qgeolocation_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QGeoLocationPrivate::QGeoLocationPrivate()
- : QSharedData()
-{
-}
-
-QGeoLocationPrivate::QGeoLocationPrivate(const QGeoLocationPrivate &other)
- : QSharedData()
-{
- this->address = other.address;
- this->coordinate = other.coordinate;
- this->viewport = other.viewport;
- this->extendedAttributes = other.extendedAttributes;
-}
-
-QGeoLocationPrivate::~QGeoLocationPrivate()
-{
-}
-
-bool QGeoLocationPrivate::operator==(const QGeoLocationPrivate &other) const
-{
- return (this->address == other.address
- && this->coordinate == other.coordinate
- && this->viewport == other.viewport
- && this->extendedAttributes == other.extendedAttributes);
-
-}
-
-bool QGeoLocationPrivate::isEmpty() const
-{
- return (address.isEmpty()
- && !coordinate.isValid()
- && viewport.isEmpty()
- && extendedAttributes.isEmpty());
-}
-
-/*!
- \class QGeoLocation
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \ingroup QtLocation-places
- \ingroup QtLocation-places-data
- \since 5.2
-
- \brief The QGeoLocation class represents basic information about a location.
-
- A QGeoLocation consists of a coordinate and corresponding address, along with an optional
- bounding shape, which is the recommended region to be displayed when viewing the location.
-*/
-
-/*!
- Constructs an new location object.
-*/
-QGeoLocation::QGeoLocation()
- : d(new QGeoLocationPrivate)
-{
-}
-
-/*!
- Constructs a copy of \a other
-*/
-QGeoLocation::QGeoLocation(const QGeoLocation &other)
- :d(other.d)
-{
-}
-
-/*!
- \fn QGeoLocation::QGeoLocation(QGeoLocation &&other)
- \since 6.2
-
- Constructs a geo location object by moving from \a other.
-
- \note The moved-from QGeoLocation object can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- Destroys the location object.
-*/
-QGeoLocation::~QGeoLocation()
-{
-}
-
-QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoLocationPrivate)
-
-/*!
- Assigns \a other to this location and returns a reference to this location.
-*/
-QGeoLocation &QGeoLocation::operator =(const QGeoLocation &other)
-{
- if (this == &other)
- return *this;
-
- d = other.d;
- return *this;
-}
-
-/*!
- \fn QGeoLocation &QGeoLocation::operator=(QGeoLocation &&other)
- \since 6.2
-
- Move-assings \a other to this location and returns a reference to this
- location.
-
- \note The moved-from QGeoLocation object can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- \fn bool QGeoLocation::operator==(const QGeoLocation &lhs, const QGeoLocation &rhs)
-
- Returns \c true if the \a lhs location is equal to \a rhs, otherwise
- returns \c false.
-*/
-
-/*!
- \fn bool QGeoLocation::operator!=(const QGeoLocation &lhs, const QGeoLocation &rhs)
-
- Returns \c true if the \a lhs location is not equal to \a rhs, otherwise
- returns \c false.
-*/
-
-/*!
- Returns the address of the location.
-*/
-QGeoAddress QGeoLocation::address() const
-{
- return d->address;
-}
-
-/*!
- Sets the \a address of the location.
-*/
-void QGeoLocation::setAddress(const QGeoAddress &address)
-{
- d->address = address;
-}
-
-/*!
- Returns the coordinate of the location.
-*/
-QGeoCoordinate QGeoLocation::coordinate() const
-{
- return d->coordinate;
-}
-
-/*!
- Sets the \a coordinate of the location.
-*/
-void QGeoLocation::setCoordinate(const QGeoCoordinate &coordinate)
-{
- d->coordinate = coordinate;
-}
-
-/*!
- \since 6.2
-
- Returns a bounding shape which represents the recommended region
- to display when viewing this location.
-
- For example, a building's location may have a region centered around the
- building, but the region is large enough to show it's immediate surrounding
- geographical context.
-
- \note This method was introduced in Qt6 instead of boundingBox() method.
- It returns a QGeoShape instead of a QGeoRectangle.
- Use \l QGeoShape::boundingGeoRectangle() to obtain a bounding QGeoRectangle
- for the shape.
-*/
-QGeoShape QGeoLocation::boundingShape() const
-{
- return d->viewport;
-}
-
-/*!
- \since 6.2
-
- Sets the \a boundingShape of the location.
-*/
-void QGeoLocation::setBoundingShape(const QGeoShape &boundingShape)
-{
- d->viewport = boundingShape;
-}
-
-/*!
- Returns the extended attributes associated to this location.
- Extended attributes are backend-dependent and can be location-dependent.
-
- \since 5.13
-*/
-QVariantMap QGeoLocation::extendedAttributes() const
-{
- return d->extendedAttributes;
-}
-
-/*!
- Sets the extended attributes of the location with the
- parameters specified in \a data.
-
- \since 5.13
-*/
-void QGeoLocation::setExtendedAttributes(const QVariantMap &data)
-{
- d->extendedAttributes = data;
-}
-
-/*!
- Returns \c true if the location coordinate is \l {QGeoCoordinate::isValid}
- {invalid}, and all the other location fields are empty. Otherwise returns
- \c false.
-*/
-bool QGeoLocation::isEmpty() const
-{
- return d->isEmpty();
-}
-
-bool QGeoLocation::equals(const QGeoLocation &lhs, const QGeoLocation &rhs)
-{
- return (*(lhs.d.constData()) == *(rhs.d.constData()));
-}
-
-/*!
- \relates QGeoLocation
-
- Returns the hash value for the \a location, using \a seed for the
- calculation.
-
- \note The hash does not take extended attributes into account. This means
- that two geo location objects that differ only in the extended attributes
- will provide similar hashes.
-*/
-size_t qHash(const QGeoLocation &location, size_t seed) noexcept
-{
- return qHashMulti(seed, location.coordinate(), location.boundingShape(), location.address());
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeolocation.h b/src/positioning/qgeolocation.h
deleted file mode 100644
index 3fe20986..00000000
--- a/src/positioning/qgeolocation.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOLOCATION_H
-#define QGEOLOCATION_H
-
-#include <QtCore/QSharedDataPointer>
-#include <QtCore/QMetaType>
-#include <QtPositioning/qpositioningglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoAddress;
-class QGeoCoordinate;
-class QGeoShape;
-class QGeoLocationPrivate;
-QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGeoLocationPrivate, Q_POSITIONING_EXPORT)
-
-class Q_POSITIONING_EXPORT QGeoLocation
-{
-public:
- QGeoLocation();
- QGeoLocation(const QGeoLocation &other);
- QGeoLocation(QGeoLocation &&other) noexcept = default;
- ~QGeoLocation();
-
- QGeoLocation &operator=(const QGeoLocation &other);
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGeoLocation)
-
- void swap(QGeoLocation &other) noexcept { d.swap(other.d); }
-
- friend bool operator==(const QGeoLocation &lhs, const QGeoLocation &rhs)
- {
- return equals(lhs, rhs);
- }
- friend bool operator!=(const QGeoLocation &lhs, const QGeoLocation &rhs)
- {
- return !equals(lhs, rhs);
- }
-
- QGeoAddress address() const;
- void setAddress(const QGeoAddress &address);
- QGeoCoordinate coordinate() const;
- void setCoordinate(const QGeoCoordinate &position);
- QGeoShape boundingShape() const;
- void setBoundingShape(const QGeoShape &shape);
- QVariantMap extendedAttributes() const;
- void setExtendedAttributes(const QVariantMap &data);
-
- bool isEmpty() const;
-
-private:
- static bool equals(const QGeoLocation &lhs, const QGeoLocation &rhs);
- QSharedDataPointer<QGeoLocationPrivate> d;
-};
-
-Q_POSITIONING_EXPORT size_t qHash(const QGeoLocation &location, size_t seed = 0) noexcept;
-
-Q_DECLARE_SHARED(QGeoLocation)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoLocation)
-
-#endif
diff --git a/src/positioning/qgeolocation_p.h b/src/positioning/qgeolocation_p.h
deleted file mode 100644
index f402afe2..00000000
--- a/src/positioning/qgeolocation_p.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOLOCATION_P_H
-#define QGEOLOCATION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QSharedData>
-#include <QtPositioning/QGeoAddress>
-#include <QtPositioning/QGeoCoordinate>
-#include <QtPositioning/QGeoShape>
-#include <QVariantMap>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoLocationPrivate : public QSharedData
-{
-public:
- QGeoLocationPrivate();
- QGeoLocationPrivate(const QGeoLocationPrivate &other);
-
- ~QGeoLocationPrivate();
-
- bool operator==(const QGeoLocationPrivate &other) const;
-
- bool isEmpty() const;
-
- QGeoAddress address;
- QGeoCoordinate coordinate;
- QGeoShape viewport;
- QVariantMap extendedAttributes;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
deleted file mode 100644
index 4d6b1af2..00000000
--- a/src/positioning/qgeopath.cpp
+++ /dev/null
@@ -1,774 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopath.h"
-#include "qgeopolygon.h"
-#include "qgeopath_p.h"
-
-#include "qgeocoordinate.h"
-#include "qnumeric.h"
-#include "qlocationutils_p.h"
-#include "qwebmercator_p.h"
-
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
-QT_BEGIN_NAMESPACE
-
-constexpr int kMaxInt = std::numeric_limits<int>::max();
-constexpr auto kWarningString = u"The path has more elements than fit into an int. "
- "This can cause errors while querying elements from QML";
-
-/*!
- \class QGeoPath
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.9
-
- \brief The QGeoPath class defines a geographic path.
-
- The path is defined by an ordered list of \l QGeoCoordinate objects.
-
- Each two adjacent elements in the path are intended to be connected
- together by the shortest line segment of constant bearing passing
- through both elements.
- This type of connection can cross the dateline in the longitudinal direction,
- but never crosses the poles.
-
- This is relevant for the calculation of the bounding box returned by
- \l QGeoShape::boundingGeoRectangle() for this shape, which will have the latitude of
- the top left corner set to the maximum latitude in the path point set.
- Similarly, the latitude of the bottom right corner will be the minimum latitude
- in the path point set.
-
- This class is a \l Q_GADGET.
- It can be \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.
-
- A QGeoPath is both invalid and empty if it contains no coordinate.
-
- \note A default constructed QGeoPath is both invalid and empty as it does not contain any coordinates.
-*/
-
-/*!
- \property QGeoPath::path
- \brief This property holds the list of coordinates for the geo path.
-
- \note The coordinates cannot be processed in place. To change the value
- of this property, retrieve the complete list of coordinates, process them,
- and assign the new value to the property.
-*/
-
-inline QGeoPathPrivate *QGeoPath::d_func()
-{
- return static_cast<QGeoPathPrivate *>(d_ptr.data());
-}
-
-inline const QGeoPathPrivate *QGeoPath::d_func() const
-{
- return static_cast<const QGeoPathPrivate *>(d_ptr.constData());
-}
-
-struct PathVariantConversions
-{
- PathVariantConversions()
- {
- QMetaType::registerConverter<QGeoShape, QGeoPath>();
- QMetaType::registerConverter<QGeoPath, QGeoShape>();
- }
-};
-
-Q_GLOBAL_STATIC(PathVariantConversions, initPathConversions)
-
-/*!
- Constructs a new, empty geo path.
-*/
-QGeoPath::QGeoPath()
-: QGeoShape(new QGeoPathPrivate())
-{
- initPathConversions();
-}
-
-/*!
- Constructs a new geo path from a list of coordinates
- (\a path and \a width).
-*/
-QGeoPath::QGeoPath(const QList<QGeoCoordinate> &path, const qreal &width)
-: QGeoShape(new QGeoPathPrivate(path, width))
-{
- initPathConversions();
-}
-
-/*!
- Constructs a new geo path from the contents of \a other.
-*/
-QGeoPath::QGeoPath(const QGeoPath &other)
-: QGeoShape(other)
-{
- initPathConversions();
-}
-
-/*!
- Constructs a new geo path from the contents of \a other.
-*/
-QGeoPath::QGeoPath(const QGeoShape &other)
-: QGeoShape(other)
-{
- initPathConversions();
- if (type() != QGeoShape::PathType)
- d_ptr = new QGeoPathPrivate();
-}
-
-/*!
- Destroys this path.
-*/
-QGeoPath::~QGeoPath() {}
-
-/*!
- Assigns \a other to this geo path and returns a reference to this geo path.
-*/
-QGeoPath &QGeoPath::operator=(const QGeoPath &other)
-{
- QGeoShape::operator=(other);
- return *this;
-}
-
-/*!
- Sets all the elements of the \a path.
-*/
-void QGeoPath::setPath(const QList<QGeoCoordinate> &path)
-{
- Q_D(QGeoPath);
- return d->setPath(path);
-}
-
-/*!
- Returns all the elements of the path.
-*/
-const QList<QGeoCoordinate> &QGeoPath::path() const
-{
- Q_D(const QGeoPath);
- return d->path();
-}
-
-/*!
- Clears the path.
-
- \since 5.12
-*/
-void QGeoPath::clearPath()
-{
- Q_D(QGeoPath);
- d->clearPath();
-}
-
-/*!
- Sets all the elements of the path.
-
- \internal
-*/
-void QGeoPath::setVariantPath(const QVariantList &path)
-{
- Q_D(QGeoPath);
- QList<QGeoCoordinate> p;
- for (const auto &c: path) {
- if (c.canConvert<QGeoCoordinate>())
- p << c.value<QGeoCoordinate>();
- }
- d->setPath(p);
-}
-/*!
- Returns all the elements of the path.
-
- \internal
-*/
-QVariantList QGeoPath::variantPath() const
-{
- Q_D(const QGeoPath);
- QVariantList p;
- for (const auto &c: d->path())
- p << QVariant::fromValue(c);
- return p;
-}
-
-
-/*!
- \property QGeoPath::width
-
- \brief the width of the path in meters.
-*/
-void QGeoPath::setWidth(const qreal &width)
-{
- Q_D(QGeoPath);
- d->setWidth(width);
-}
-
-/*!
- Returns the width of the path, in meters. This information is used in the \l contains method.
- The default value is 0.
-*/
-qreal QGeoPath::width() const
-{
- Q_D(const QGeoPath);
- return d->width();
-}
-
-/*!
- Translates this geo path by \a degreesLatitude northwards and \a degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-*/
-void QGeoPath::translate(double degreesLatitude, double degreesLongitude)
-{
- Q_D(QGeoPath);
- d->translate(degreesLatitude, degreesLongitude);
-}
-
-/*!
- Returns a copy of this geo path translated by \a degreesLatitude northwards and
- \a degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-
- \sa translate()
-*/
-QGeoPath QGeoPath::translated(double degreesLatitude, double degreesLongitude) const
-{
- QGeoPath result(*this);
- result.translate(degreesLatitude, degreesLongitude);
- return result;
-}
-
-/*!
- Returns the length of the path, in meters, from the element \a indexFrom to the element \a indexTo.
- The length is intended to be the sum of the shortest distances for each pair of adjacent points.
-
- If \a indexTo is -1 (the default value), the length will be including the distance between last coordinate
- and the first (closed loop).
- To retrieve the length for the path, use 0 for \a indexFrom and \l QGeoPath::size() - 1 for \a indexTo.
-*/
-double QGeoPath::length(qsizetype indexFrom, qsizetype indexTo) const
-{
- Q_D(const QGeoPath);
- return d->length(indexFrom, indexTo);
-}
-
-/*!
- Returns the number of elements in the path.
-
- \since 5.10
-*/
-qsizetype QGeoPath::size() const
-{
- Q_D(const QGeoPath);
- const qsizetype result = d->size();
- if (result > kMaxInt)
- qWarning() << kWarningString;
- return result;
-}
-
-/*!
- Appends \a coordinate to the path.
-*/
-void QGeoPath::addCoordinate(const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPath);
- d->addCoordinate(coordinate);
- if (d->size() > kMaxInt)
- qWarning() << kWarningString;
-}
-
-/*!
- Inserts \a coordinate at the specified \a index.
-*/
-void QGeoPath::insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPath);
- d->insertCoordinate(index, coordinate);
-}
-
-/*!
- Replaces the path element at the specified \a index with \a coordinate.
-*/
-void QGeoPath::replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPath);
- d->replaceCoordinate(index, coordinate);
-}
-
-/*!
- Returns the coordinate at \a index .
-*/
-QGeoCoordinate QGeoPath::coordinateAt(qsizetype index) const
-{
- Q_D(const QGeoPath);
- return d->coordinateAt(index);
-}
-
-/*!
- Returns true if the path contains \a coordinate as one of the elements.
-*/
-bool QGeoPath::containsCoordinate(const QGeoCoordinate &coordinate) const
-{
- Q_D(const QGeoPath);
- return d->containsCoordinate(coordinate);
-}
-
-/*!
- Removes the last occurrence of \a coordinate from the path.
-*/
-void QGeoPath::removeCoordinate(const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPath);
- d->removeCoordinate(coordinate);
-}
-
-/*!
- Removes element at position \a index from the path.
-*/
-void QGeoPath::removeCoordinate(qsizetype index)
-{
- Q_D(QGeoPath);
- d->removeCoordinate(index);
-}
-
-/*!
- Returns the geo path properties as a string.
-*/
-QString QGeoPath::toString() const
-{
- if (type() != QGeoShape::PathType) {
- qWarning("Not a path");
- return QStringLiteral("QGeoPath(not a path)");
- }
-
- QString pathString;
- for (const auto &p : path())
- pathString += p.toString() + QLatin1Char(',');
-
- return QStringLiteral("QGeoPath([ %1 ])").arg(pathString);
-}
-
-/*******************************************************************************
- *
- * QGeoPathPrivate & friends
- *
-*******************************************************************************/
-
-QGeoPathPrivate::QGeoPathPrivate()
-: QGeoShapePrivate(QGeoShape::PathType)
-{
-
-}
-
-QGeoPathPrivate::QGeoPathPrivate(const QList<QGeoCoordinate> &path, const qreal width)
-: QGeoShapePrivate(QGeoShape::PathType)
-{
- setPath(path);
- setWidth(width);
-}
-
-QGeoPathPrivate::~QGeoPathPrivate()
-{
-
-}
-
-QGeoShapePrivate *QGeoPathPrivate::clone() const
-{
- return new QGeoPathPrivate(*this);
-}
-
-bool QGeoPathPrivate::isValid() const
-{
- return !isEmpty();
-}
-
-bool QGeoPathPrivate::isEmpty() const
-{
- return path().isEmpty(); // this should perhaps return geometric emptiness, less than 2 points for line, or empty polygon for polygons
-}
-
-QGeoCoordinate QGeoPathPrivate::center() const
-{
- return boundingGeoRectangle().center();
-}
-
-bool QGeoPathPrivate::operator==(const QGeoShapePrivate &other) const
-{
- if (!QGeoShapePrivate::operator==(other))
- return false;
-
- const QGeoPathPrivate &otherPath = static_cast<const QGeoPathPrivate &>(other);
- if (m_path.size() != otherPath.m_path.size())
- return false;
- return m_width == otherPath.m_width && m_path == otherPath.m_path;
-}
-
-const QList<QGeoCoordinate> &QGeoPathPrivate::path() const
-{
- return m_path;
-}
-
-bool QGeoPathPrivate::lineContains(const QGeoCoordinate &coordinate) const
-{
- // Unoptimized approach:
- // - consider each segment of the path
- // - project it into mercator space (rhumb lines are straight in mercator space)
- // - find closest point to coordinate
- // - unproject the closest point
- // - calculate coordinate to closest point distance with distanceTo()
- // - if not within lineRadius, advance
- //
- // To keep wrapping into the equation:
- // If the mercator x value of a coordinate of the line, or the coordinate parameter, is less
- // than mercator(m_bbox).x, add that to the conversion.
-
- if (m_bboxDirty)
- const_cast<QGeoPathPrivate &>(*this).computeBoundingBox();
-
- double lineRadius = qMax(width() * 0.5, 0.2); // minimum radius: 20cm
-
- if (!m_path.size())
- return false;
- else if (m_path.size() == 1)
- return (m_path[0].distanceTo(coordinate) <= lineRadius);
-
- QDoubleVector2D p = QWebMercator::coordToMercator(coordinate);
- if (p.x() < m_leftBoundWrapped)
- p.setX(p.x() + m_leftBoundWrapped); // unwrap X
-
- QDoubleVector2D a;
- QDoubleVector2D b;
- if (m_path.size()) {
- a = QWebMercator::coordToMercator(m_path[0]);
- if (a.x() < m_leftBoundWrapped)
- a.setX(a.x() + m_leftBoundWrapped); // unwrap X
- }
- for (qsizetype i = 1; i < m_path.size(); i++) {
- b = QWebMercator::coordToMercator(m_path[i]);
- if (b.x() < m_leftBoundWrapped)
- b.setX(b.x() + m_leftBoundWrapped); // unwrap X
- if (b == a)
- continue;
-
- double u = ((p.x() - a.x()) * (b.x() - a.x()) + (p.y() - a.y()) * (b.y() - a.y()) ) / (b - a).lengthSquared();
- QDoubleVector2D intersection(a.x() + u * (b.x() - a.x()) , a.y() + u * (b.y() - a.y()) );
-
- QDoubleVector2D candidate = ( (p-a).length() < (p-b).length() ) ? a : b;
-
- if (u > 0 && u < 1
- && (p-intersection).length() < (p-candidate).length() ) // And it falls in the segment
- candidate = intersection;
-
-
- if (candidate.x() > 1.0)
- candidate.setX(candidate.x() - m_leftBoundWrapped); // wrap X
-
- QGeoCoordinate closest = QWebMercator::mercatorToCoord(candidate);
-
- double distanceMeters = coordinate.distanceTo(closest);
- if (distanceMeters <= lineRadius)
- return true;
-
- // swap
- a = b;
- }
-
- // Last check if the coordinate is on the left of leftBoundMercator, but close enough to
- // m_path[0]
- return (m_path[0].distanceTo(coordinate) <= lineRadius);
-}
-
-bool QGeoPathPrivate::contains(const QGeoCoordinate &coordinate) const
-{
- return lineContains(coordinate);
-}
-
-qreal QGeoPathPrivate::width() const
-{
- return m_width;
-}
-
-void QGeoPathPrivate::setWidth(const qreal &width)
-{
- if (qIsNaN(width) || width < 0.0)
- return;
- m_width = width;
-}
-
-double QGeoPathPrivate::length(qsizetype indexFrom, qsizetype indexTo) const
-{
- if (path().isEmpty())
- return 0.0;
-
- bool wrap = indexTo == -1;
- if (indexTo < 0 || indexTo >= path().size())
- indexTo = path().size() - 1;
- double len = 0.0;
- // TODO: consider calculating the length of the actual rhumb line segments
- // instead of the shortest path from A to B.
- for (qsizetype i = indexFrom; i < indexTo; i++)
- len += m_path[i].distanceTo(m_path[i+1]);
- if (wrap)
- len += m_path.last().distanceTo(m_path.first());
- return len;
-}
-
-qsizetype QGeoPathPrivate::size() const
-{
- return m_path.size();
-}
-
-QGeoCoordinate QGeoPathPrivate::coordinateAt(qsizetype index) const
-{
- if (index < 0 || index >= m_path.size())
- return QGeoCoordinate();
-
- return m_path.at(index);
-}
-
-bool QGeoPathPrivate::containsCoordinate(const QGeoCoordinate &coordinate) const
-{
- return m_path.indexOf(coordinate) > -1;
-}
-
-void QGeoPathPrivate::translate(double degreesLatitude, double degreesLongitude)
-{
- // Need min/maxLati, so update bbox
- QList<double> m_deltaXs;
- double m_minX, m_maxX, m_minLati, m_maxLati;
- m_bboxDirty = false;
- computeBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox);
-
- if (degreesLatitude > 0.0)
- degreesLatitude = qMin(degreesLatitude, 90.0 - m_maxLati);
- else
- degreesLatitude = qMax(degreesLatitude, -90.0 - m_minLati);
- for (QGeoCoordinate &p: m_path) {
- p.setLatitude(p.latitude() + degreesLatitude);
- p.setLongitude(QLocationUtils::wrapLong(p.longitude() + degreesLongitude));
- }
- m_bbox.translate(degreesLatitude, degreesLongitude);
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
-}
-
-QGeoRectangle QGeoPathPrivate::boundingGeoRectangle() const
-{
- if (m_bboxDirty)
- const_cast<QGeoPathPrivate &>(*this).computeBoundingBox();
- return m_bbox;
-}
-
-size_t QGeoPathPrivate::hash(size_t seed) const
-{
- const size_t res = qHashRange(m_path.cbegin(), m_path.cend(), seed);
- return qHashMulti(seed, res, m_width);
-}
-
-void QGeoPathPrivate::setPath(const QList<QGeoCoordinate> &path)
-{
- for (const QGeoCoordinate &c: path)
- if (!c.isValid())
- return;
- m_path = path;
- markDirty();
-}
-
-void QGeoPathPrivate::clearPath()
-{
- m_path.clear();
- markDirty();
-}
-
-void QGeoPathPrivate::addCoordinate(const QGeoCoordinate &coordinate)
-{
- if (!coordinate.isValid())
- return;
- m_path.append(coordinate);
- markDirty();
-}
-
-void QGeoPathPrivate::insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
-{
- if (index < 0 || index > m_path.size() || !coordinate.isValid())
- return;
- m_path.insert(index, coordinate);
- markDirty();
-}
-
-void QGeoPathPrivate::replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
-{
- if (index < 0 || index >= m_path.size() || !coordinate.isValid())
- return;
- m_path[index] = coordinate;
- markDirty();
-}
-
-void QGeoPathPrivate::removeCoordinate(const QGeoCoordinate &coordinate)
-{
- qsizetype index = m_path.lastIndexOf(coordinate);
- removeCoordinate(index);
-}
-
-void QGeoPathPrivate::removeCoordinate(qsizetype index)
-{
- if (index < 0 || index >= m_path.size())
- return;
- m_path.removeAt(index);
- markDirty();
-}
-
-void QGeoPathPrivate::markDirty()
-{
- m_bboxDirty = true;
-}
-
-void QGeoPathPrivate::computeBoundingBox()
-{
- QList<double> m_deltaXs;
- double m_minX, m_maxX, m_minLati, m_maxLati;
- m_bboxDirty = false;
- computeBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox);
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
-}
-
-QGeoPathPrivateEager::QGeoPathPrivateEager()
-: QGeoPathPrivate()
-{
- m_bboxDirty = false; // never dirty on the eager version
-}
-
-QGeoPathPrivateEager::QGeoPathPrivateEager(const QList<QGeoCoordinate> &path, const qreal width)
-: QGeoPathPrivate(path, width)
-{
- m_bboxDirty = false; // never dirty on the eager version
-}
-
-QGeoPathPrivateEager::~QGeoPathPrivateEager()
-{
-
-}
-
-QGeoShapePrivate *QGeoPathPrivateEager::clone() const
-{
- return new QGeoPathPrivateEager(*this);
-}
-
-void QGeoPathPrivateEager::markDirty()
-{
- computeBoundingBox();
-}
-
-void QGeoPathPrivateEager::translate(double degreesLatitude, double degreesLongitude)
-{
- if (degreesLatitude > 0.0)
- degreesLatitude = qMin(degreesLatitude, 90.0 - m_maxLati);
- else
- degreesLatitude = qMax(degreesLatitude, -90.0 - m_minLati);
- for (QGeoCoordinate &p: m_path) {
- p.setLatitude(p.latitude() + degreesLatitude);
- p.setLongitude(QLocationUtils::wrapLong(p.longitude() + degreesLongitude));
- }
- m_bbox.translate(degreesLatitude, degreesLongitude);
- m_minLati += degreesLatitude;
- m_maxLati += degreesLatitude;
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
-}
-
-void QGeoPathPrivateEager::addCoordinate(const QGeoCoordinate &coordinate)
-{
- if (!coordinate.isValid())
- return;
- m_path.append(coordinate);
- //m_clipperDirty = true; // clipper not used in polylines
- updateBoundingBox();
-}
-
-void QGeoPathPrivateEager::QGeoPathPrivateEager::computeBoundingBox()
-{
- computeBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox);
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
-}
-
-void QGeoPathPrivateEager::QGeoPathPrivateEager::updateBoundingBox()
-{
- updateBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox);
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
-}
-
-QGeoPathEager::QGeoPathEager() : QGeoPath()
-{
- initPathConversions();
- d_ptr = new QGeoPathPrivateEager;
-}
-
-QGeoPathEager::QGeoPathEager(const QList<QGeoCoordinate> &path, const qreal &width) : QGeoPath()
-{
- initPathConversions();
- d_ptr = new QGeoPathPrivateEager(path, width);
-}
-
-QGeoPathEager::QGeoPathEager(const QGeoPath &other) : QGeoPath()
-{
- initPathConversions();
- d_ptr = new QGeoPathPrivateEager;
- setPath(other.path());
- setWidth(other.width());
-}
-
-QGeoPathEager::QGeoPathEager(const QGeoShape &other) : QGeoPath()
-{
- initPathConversions();
- if (other.type() == QGeoShape::PathType)
- *this = QGeoPathEager(QGeoPath(other));
- else
- d_ptr = new QGeoPathPrivateEager;
-}
-
-QGeoPathEager::~QGeoPathEager() {}
-
-QT_END_NAMESPACE
-
-
-
-
-
-
-
-
diff --git a/src/positioning/qgeopath.h b/src/positioning/qgeopath.h
deleted file mode 100644
index 581b453c..00000000
--- a/src/positioning/qgeopath.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPATH_H
-#define QGEOPATH_H
-
-#include <QtPositioning/QGeoShape>
-#include <QtCore/QVariantList>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QGeoPathPrivate;
-
-class Q_POSITIONING_EXPORT QGeoPath : public QGeoShape
-{
- Q_GADGET
- Q_PROPERTY(QVariantList path READ variantPath WRITE setVariantPath)
- Q_PROPERTY(qreal width READ width WRITE setWidth)
-
-public:
- QGeoPath();
- QGeoPath(const QList<QGeoCoordinate> &path, const qreal &width = 0.0);
- QGeoPath(const QGeoPath &other);
- QGeoPath(const QGeoShape &other);
-
- ~QGeoPath();
-
- QGeoPath &operator=(const QGeoPath &other);
-
- void setPath(const QList<QGeoCoordinate> &path);
- const QList<QGeoCoordinate> &path() const;
- void clearPath();
- void setVariantPath(const QVariantList &path);
- QVariantList variantPath() const;
-
- void setWidth(const qreal &width);
- qreal width() const;
-
- Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
- Q_INVOKABLE QGeoPath translated(double degreesLatitude, double degreesLongitude) const;
- Q_INVOKABLE double length(qsizetype indexFrom = 0, qsizetype indexTo = -1) const;
- Q_INVOKABLE qsizetype size() const;
- Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate);
- Q_INVOKABLE void insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate);
- Q_INVOKABLE void replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate);
- Q_INVOKABLE QGeoCoordinate coordinateAt(qsizetype index) const;
- Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate) const;
- Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate);
- Q_INVOKABLE void removeCoordinate(qsizetype index);
-
- Q_INVOKABLE QString toString() const;
-
-private:
- inline QGeoPathPrivate *d_func();
- inline const QGeoPathPrivate *d_func() const;
-};
-
-Q_DECLARE_TYPEINFO(QGeoPath, Q_RELOCATABLE_TYPE);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoPath)
-
-#endif // QGEOPATH_H
diff --git a/src/positioning/qgeopath_p.h b/src/positioning/qgeopath_p.h
deleted file mode 100644
index 64abb621..00000000
--- a/src/positioning/qgeopath_p.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPATH_P_H
-#define QGEOPATH_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include "qgeoshape_p.h"
-#include "qgeocoordinate.h"
-#include "qlocationutils_p.h"
-#include <QtPositioning/qgeopath.h>
-#include <QtCore/QList>
-
-QT_BEGIN_NAMESPACE
-
-inline static void computeBBox(const QList<QGeoCoordinate> &m_path, QList<double> &m_deltaXs,
- double &m_minX, double &m_maxX, double &m_minLati, double &m_maxLati,
- QGeoRectangle &m_bbox)
-{
- if (m_path.isEmpty()) {
- m_deltaXs.clear();
- m_minX = qInf();
- m_maxX = -qInf();
- m_minLati = qInf();
- m_maxLati = -qInf();
- m_bbox = QGeoRectangle();
- return;
- }
-
- m_minLati = m_maxLati = m_path.at(0).latitude();
- qsizetype minId = 0;
- qsizetype maxId = 0;
- m_deltaXs.resize(m_path.size());
- m_deltaXs[0] = m_minX = m_maxX = 0.0;
-
- for (qsizetype i = 1; i < m_path.size(); i++) {
- const QGeoCoordinate &geoFrom = m_path.at(i-1);
- const QGeoCoordinate &geoTo = m_path.at(i);
- double longiFrom = geoFrom.longitude();
- double longiTo = geoTo.longitude();
- double deltaLongi = longiTo - longiFrom;
- if (qAbs(deltaLongi) > 180.0) {
- if (longiTo > 0.0)
- longiTo -= 360.0;
- else
- longiTo += 360.0;
- deltaLongi = longiTo - longiFrom;
- }
- m_deltaXs[i] = m_deltaXs[i-1] + deltaLongi;
- if (m_deltaXs[i] < m_minX) {
- m_minX = m_deltaXs[i];
- minId = i;
- }
- if (m_deltaXs[i] > m_maxX) {
- m_maxX = m_deltaXs[i];
- maxId = i;
- }
- if (geoTo.latitude() > m_maxLati)
- m_maxLati = geoTo.latitude();
- if (geoTo.latitude() < m_minLati)
- m_minLati = geoTo.latitude();
- }
-
- m_bbox = QGeoRectangle(QGeoCoordinate(m_maxLati, m_path.at(minId).longitude()),
- QGeoCoordinate(m_minLati, m_path.at(maxId).longitude()));
-}
-
-inline static void updateBBox(const QList<QGeoCoordinate> &m_path, QList<double> &m_deltaXs,
- double &m_minX, double &m_maxX, double &m_minLati, double &m_maxLati,
- QGeoRectangle &m_bbox)
-{
- if (m_path.isEmpty()) {
- m_deltaXs.clear();
- m_minX = qInf();
- m_maxX = -qInf();
- m_minLati = qInf();
- m_maxLati = -qInf();
- m_bbox = QGeoRectangle();
- return;
- } else if (m_path.size() == 1) { // was 0 now is 1
- m_deltaXs.resize(1);
- m_deltaXs[0] = m_minX = m_maxX = 0.0;
- m_minLati = m_maxLati = m_path.at(0).latitude();
- m_bbox = QGeoRectangle(QGeoCoordinate(m_maxLati, m_path.at(0).longitude()),
- QGeoCoordinate(m_minLati, m_path.at(0).longitude()));
- return;
- } else if ( m_path.size() != m_deltaXs.size() + 1 ) { // this case should not happen
- computeBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox); // something went wrong
- return;
- }
-
- const QGeoCoordinate &geoFrom = m_path.at(m_path.size()-2);
- const QGeoCoordinate &geoTo = m_path.last();
- double longiFrom = geoFrom.longitude();
- double longiTo = geoTo.longitude();
- double deltaLongi = longiTo - longiFrom;
- if (qAbs(deltaLongi) > 180.0) {
- if (longiTo > 0.0)
- longiTo -= 360.0;
- else
- longiTo += 360.0;
- deltaLongi = longiTo - longiFrom;
- }
-
- m_deltaXs.push_back(m_deltaXs.last() + deltaLongi);
- double currentMinLongi = m_bbox.topLeft().longitude();
- double currentMaxLongi = m_bbox.bottomRight().longitude();
- if (m_deltaXs.last() < m_minX) {
- m_minX = m_deltaXs.last();
- currentMinLongi = geoTo.longitude();
- }
- if (m_deltaXs.last() > m_maxX) {
- m_maxX = m_deltaXs.last();
- currentMaxLongi = geoTo.longitude();
- }
- if (geoTo.latitude() > m_maxLati)
- m_maxLati = geoTo.latitude();
- if (geoTo.latitude() < m_minLati)
- m_minLati = geoTo.latitude();
- m_bbox = QGeoRectangle(QGeoCoordinate(m_maxLati, currentMinLongi),
- QGeoCoordinate(m_minLati, currentMaxLongi));
-}
-
-// Lazy by default. Eager, within the module, used only in MapItems/MapObjectsQSG
-class Q_POSITIONING_PRIVATE_EXPORT QGeoPathPrivate : public QGeoShapePrivate
-{
-public:
- QGeoPathPrivate();
- QGeoPathPrivate(const QList<QGeoCoordinate> &path, const qreal width = 0.0);
- ~QGeoPathPrivate();
-
-// QGeoShape API
- virtual QGeoShapePrivate *clone() const override;
- virtual bool isValid() const override;
- virtual bool isEmpty() const override;
- virtual QGeoCoordinate center() const override;
- virtual bool operator==(const QGeoShapePrivate &other) const override;
- virtual bool contains(const QGeoCoordinate &coordinate) const override;
- virtual QGeoRectangle boundingGeoRectangle() const override;
- size_t hash(size_t seed) const override;
-
-// QGeoPathPrivate API
- virtual const QList<QGeoCoordinate> &path() const;
- virtual bool lineContains(const QGeoCoordinate &coordinate) const;
- virtual qreal width() const;
- virtual double length(qsizetype indexFrom, qsizetype indexTo) const;
- virtual qsizetype size() const;
- virtual QGeoCoordinate coordinateAt(qsizetype index) const;
- virtual bool containsCoordinate(const QGeoCoordinate &coordinate) const;
-
- virtual void setWidth(const qreal &width);
- virtual void translate(double degreesLatitude, double degreesLongitude);
- virtual void setPath(const QList<QGeoCoordinate> &path);
- virtual void clearPath();
- virtual void addCoordinate(const QGeoCoordinate &coordinate);
- virtual void insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate);
- virtual void replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate);
- virtual void removeCoordinate(const QGeoCoordinate &coordinate);
- virtual void removeCoordinate(qsizetype index);
- virtual void computeBoundingBox();
- virtual void markDirty();
-
-// data members
- QList<QGeoCoordinate> m_path;
- qreal m_width = 0;
- QGeoRectangle m_bbox; // cached
- double m_leftBoundWrapped; // cached
- bool m_bboxDirty = false;
-};
-
-class Q_POSITIONING_PRIVATE_EXPORT QGeoPathPrivateEager : public QGeoPathPrivate
-{
-public:
- QGeoPathPrivateEager();
- QGeoPathPrivateEager(const QList<QGeoCoordinate> &path, const qreal width = 0.0);
- ~QGeoPathPrivateEager();
-
-// QGeoShapePrivate API
- virtual QGeoShapePrivate *clone() const override;
- virtual void translate(double degreesLatitude, double degreesLongitude) override;
-
-// QGeoShapePrivate API
- virtual void markDirty() override;
- virtual void addCoordinate(const QGeoCoordinate &coordinate) override;
- virtual void computeBoundingBox() override;
-
-// *Eager API
- void updateBoundingBox();
-
-// data members
- QList<double> m_deltaXs; // longitude deltas from m_path[0]
- double m_minX = 0; // minimum value inside deltaXs
- double m_maxX = 0; // maximum value inside deltaXs
- double m_minLati = 0; // minimum latitude. paths do not wrap around through the poles
- double m_maxLati = 0; // minimum latitude. paths do not wrap around through the poles
-};
-
-// This is a mean of creating a QGeoPathPrivateEager and injecting it into QGeoPaths via operator=
-class Q_POSITIONING_PRIVATE_EXPORT QGeoPathEager : public QGeoPath
-{
- Q_GADGET
-public:
-
- QGeoPathEager();
- QGeoPathEager(const QList<QGeoCoordinate> &path, const qreal &width = 0.0);
- QGeoPathEager(const QGeoPath &other);
- QGeoPathEager(const QGeoShape &other);
- ~QGeoPathEager();
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPATH_P_H
diff --git a/src/positioning/qgeopolygon.cpp b/src/positioning/qgeopolygon.cpp
deleted file mode 100644
index fc8d50cd..00000000
--- a/src/positioning/qgeopolygon.cpp
+++ /dev/null
@@ -1,719 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopolygon.h"
-#include "qgeopolygon_p.h"
-#include "qgeopath_p.h"
-#include "qgeocircle.h"
-
-#include "qgeocoordinate.h"
-#include "qnumeric.h"
-#include "qlocationutils_p.h"
-#include "qwebmercator_p.h"
-
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
-#include "qwebmercator_p.h"
-
-QT_BEGIN_NAMESPACE
-
-constexpr int kMaxInt = std::numeric_limits<int>::max();
-constexpr auto kTooManyHoles = u"The polygon has more holes than fit into an int. "
- "This can cause errors while querying holes from QML";
-constexpr auto kTooManyElements = u"The polygon has more elements than fit into an int. "
- "This can cause errors while querying elements from QML";
-
-/*!
- \class QGeoPolygon
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.10
-
- \brief The QGeoPolygon class defines a geographic polygon.
-
- The polygon is defined by an ordered list of \l QGeoCoordinate objects
- representing its perimeter.
-
- Each two adjacent elements in this list are intended to be connected
- together by the shortest line segment of constant bearing passing
- through both elements.
- This type of connection can cross the date line in the longitudinal direction,
- but never crosses the poles.
-
- This is relevant for the calculation of the bounding box returned by
- \l QGeoShape::boundingGeoRectangle() for this shape, which will have the latitude of
- the top left corner set to the maximum latitude in the path point set.
- Similarly, the latitude of the bottom right corner will be the minimum latitude
- in the path point set.
-
- This class is a \l Q_GADGET.
- It can be \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.
-*/
-
-/*
- \property QGeoPolygon::path
- \brief This property holds the list of coordinates for the geo polygon.
-
- The polygon is both invalid and empty if it contains no coordinate.
-
- A default constructed QGeoPolygon is therefore invalid.
-*/
-
-inline QGeoPolygonPrivate *QGeoPolygon::d_func()
-{
- return static_cast<QGeoPolygonPrivate *>(d_ptr.data());
-}
-
-inline const QGeoPolygonPrivate *QGeoPolygon::d_func() const
-{
- return static_cast<const QGeoPolygonPrivate *>(d_ptr.constData());
-}
-
-struct PolygonVariantConversions
-{
- PolygonVariantConversions()
- {
- QMetaType::registerConverter<QGeoShape, QGeoPolygon>();
- QMetaType::registerConverter<QGeoPolygon, QGeoShape>();
- }
-};
-
-Q_GLOBAL_STATIC(PolygonVariantConversions, initPolygonConversions)
-
-/*!
- Constructs a new, empty geo polygon.
-*/
-QGeoPolygon::QGeoPolygon()
-: QGeoShape(new QGeoPolygonPrivate())
-{
- initPolygonConversions();
-}
-
-/*!
- Constructs a new geo polygon from the coordinates specified
- in \a path.
-*/
-QGeoPolygon::QGeoPolygon(const QList<QGeoCoordinate> &path)
-: QGeoShape(new QGeoPolygonPrivate(path))
-{
- initPolygonConversions();
-}
-
-/*!
- Constructs a new geo polygon from the contents of \a other.
-*/
-QGeoPolygon::QGeoPolygon(const QGeoPolygon &other)
-: QGeoShape(other)
-{
- initPolygonConversions();
-}
-
-static void calculatePeripheralPoints(QList<QGeoCoordinate> &path,
- const QGeoCircle &circle,
- int steps)
-{
- const QGeoCoordinate &center = circle.center();
- const qreal distance = circle.radius();
- // Calculate points based on great-circle distance
- // Calculation is the same as GeoCoordinate's atDistanceAndAzimuth function
- // but tweaked here for computing multiple points
-
- // pre-calculations
- steps = qMax(steps, 3);
- qreal centerLon = center.longitude();
- qreal latRad = QLocationUtils::radians(center.latitude());
- qreal lonRad = QLocationUtils::radians(centerLon);
- qreal cosLatRad = std::cos(latRad);
- qreal sinLatRad = std::sin(latRad);
- qreal ratio = (distance / QLocationUtils::earthMeanRadius());
- qreal cosRatio = std::cos(ratio);
- qreal sinRatio = std::sin(ratio);
- qreal sinLatRad_x_cosRatio = sinLatRad * cosRatio;
- qreal cosLatRad_x_sinRatio = cosLatRad * sinRatio;
- for (int i = 0; i < steps; ++i) {
- qreal azimuthRad = 2 * M_PI * i / steps;
- qreal resultLatRad = std::asin(sinLatRad_x_cosRatio
- + cosLatRad_x_sinRatio * std::cos(azimuthRad));
- qreal resultLonRad = lonRad + std::atan2(std::sin(azimuthRad) * cosLatRad_x_sinRatio,
- cosRatio - sinLatRad * std::sin(resultLatRad));
- qreal lat2 = QLocationUtils::degrees(resultLatRad);
- qreal lon2 = QLocationUtils::wrapLong(QLocationUtils::degrees(resultLonRad));
-
- path << QGeoCoordinate(lat2, lon2, center.altitude());
- }
-}
-
-/*!
- Constructs a new geo polygon from the contents of \a other.
-*/
-QGeoPolygon::QGeoPolygon(const QGeoShape &other)
-: QGeoShape(other)
-{
- initPolygonConversions();
- if (type() != QGeoShape::PolygonType) {
- QGeoPolygonPrivate *poly = new QGeoPolygonPrivate();
- if (type() == QGeoShape::CircleType) {
- const QGeoCircle &circle = static_cast<const QGeoCircle &>(other);
- QList<QGeoCoordinate> perimeter;
- calculatePeripheralPoints(perimeter, circle, 128);
- poly->setPath(perimeter);
- } else if (type() == QGeoShape::RectangleType) {
- const QGeoRectangle &rect = static_cast<const QGeoRectangle &>(other);
- QList<QGeoCoordinate> perimeter;
- perimeter << rect.topLeft() << rect.topRight()
- << rect.bottomRight() << rect.bottomLeft();
- poly->setPath(perimeter);
- }
- d_ptr = poly;
- }
-}
-
-/*!
- Destroys this polygon.
-*/
-QGeoPolygon::~QGeoPolygon() {}
-
-/*!
- Assigns \a other to this geo polygon and returns a reference to this geo polygon.
-*/
-QGeoPolygon &QGeoPolygon::operator=(const QGeoPolygon &other)
-{
- QGeoShape::operator=(other);
- return *this;
-}
-
-/*!
- Sets the perimeter of the polygon based on a list of coordinates \a path.
-
- \since QtPositioning 5.12
-*/
-void QGeoPolygon::setPerimeter(const QList<QGeoCoordinate> &path)
-{
- Q_D(QGeoPolygon);
- return d->setPath(path);
-}
-
-/*!
- Returns all the elements of the polygon's perimeter.
-
- \since QtPositioning 5.12
-*/
-const QList<QGeoCoordinate> &QGeoPolygon::perimeter() const
-{
- Q_D(const QGeoPolygon);
- return d->path();
-}
-
-/*!
- Translates this geo polygon by \a degreesLatitude northwards and \a degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-*/
-void QGeoPolygon::translate(double degreesLatitude, double degreesLongitude)
-{
- Q_D(QGeoPolygon);
- d->translate(degreesLatitude, degreesLongitude);
-}
-
-/*!
- Returns a copy of this geo polygon translated by \a degreesLatitude northwards and
- \a degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-
- \sa translate()
-*/
-QGeoPolygon QGeoPolygon::translated(double degreesLatitude, double degreesLongitude) const
-{
- QGeoPolygon result(*this);
- result.translate(degreesLatitude, degreesLongitude);
- return result;
-}
-
-/*!
- Returns the length of the polygon's perimeter, in meters, from the element \a indexFrom to the element \a indexTo.
- The length is intended to be the sum of the shortest distances for each pair of adjacent points.
-*/
-double QGeoPolygon::length(qsizetype indexFrom, qsizetype indexTo) const
-{
- Q_D(const QGeoPolygon);
- return d->length(indexFrom, indexTo);
-}
-
-/*!
- Returns the number of elements in the polygon.
-
- \since 5.10
-*/
-qsizetype QGeoPolygon::size() const
-{
- Q_D(const QGeoPolygon);
- const qsizetype result = d->size();
- if (result > kMaxInt)
- qWarning() << kTooManyElements;
- return result;
-}
-
-/*!
- Appends \a coordinate to the polygon.
-*/
-void QGeoPolygon::addCoordinate(const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPolygon);
- d->addCoordinate(coordinate);
- if (d->size() > kMaxInt)
- qWarning() << kTooManyElements;
-}
-
-/*!
- Inserts \a coordinate at the specified \a index.
-*/
-void QGeoPolygon::insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPolygon);
- d->insertCoordinate(index, coordinate);
-}
-
-/*!
- Replaces the path element at the specified \a index with \a coordinate.
-*/
-void QGeoPolygon::replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPolygon);
- d->replaceCoordinate(index, coordinate);
-}
-
-/*!
- Returns the coordinate at \a index .
-*/
-QGeoCoordinate QGeoPolygon::coordinateAt(qsizetype index) const
-{
- Q_D(const QGeoPolygon);
- return d->coordinateAt(index);
-}
-
-/*!
- Returns true if the polygon's perimeter contains \a coordinate as one of the elements.
-*/
-bool QGeoPolygon::containsCoordinate(const QGeoCoordinate &coordinate) const
-{
- Q_D(const QGeoPolygon);
- return d->containsCoordinate(coordinate);
-}
-
-/*!
- Removes the last occurrence of \a coordinate from the polygon.
-*/
-void QGeoPolygon::removeCoordinate(const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoPolygon);
- d->removeCoordinate(coordinate);
-}
-
-/*!
- Removes element at position \a index from the polygon.
-*/
-void QGeoPolygon::removeCoordinate(qsizetype index)
-{
- Q_D(QGeoPolygon);
- d->removeCoordinate(index);
-}
-
-/*!
- Returns the geo polygon properties as a string.
-*/
-QString QGeoPolygon::toString() const
-{
- if (type() != QGeoShape::PolygonType) {
- qWarning("Not a polygon");
- return QStringLiteral("QGeoPolygon(not a polygon)");
- }
-
- QString pathString;
- for (const auto &p : perimeter())
- pathString += p.toString() + QLatin1Char(',');
-
- return QStringLiteral("QGeoPolygon([ %1 ])").arg(pathString);
-}
-
-/*!
- Sets the \a holePath for a hole inside the polygon. The hole is a
- QVariant containing a QList<QGeoCoordinate>.
-
- \since 5.12
-*/
-void QGeoPolygon::addHole(const QVariant &holePath)
-{
- QList<QGeoCoordinate> qgcHolePath;
- if (holePath.canConvert<QVariantList>()) {
- const QVariantList qvlHolePath = holePath.toList();
- for (const QVariant &vertex : qvlHolePath) {
- if (vertex.canConvert<QGeoCoordinate>())
- qgcHolePath << vertex.value<QGeoCoordinate>();
- }
- }
- //ToDo: add QGeoShape support
- addHole(qgcHolePath);
-}
-
-/*!
- Overloaded method. Sets the \a holePath for a hole inside the polygon. The hole is a QList<QGeoCoordinate>.
-
- \since 5.12
-*/
-void QGeoPolygon::addHole(const QList<QGeoCoordinate> &holePath)
-{
- Q_D(QGeoPolygon);
- d->addHole(holePath);
- if (d->holesCount() > kMaxInt)
- qDebug() << kTooManyHoles;
-}
-
-/*!
- Returns a QVariant containing a QList<QGeoCoordinate>
- which represents the hole at \a index.
-
- \since 5.12
-*/
-const QVariantList QGeoPolygon::hole(qsizetype index) const
-{
- Q_D(const QGeoPolygon);
- QVariantList holeCoordinates;
- for (const QGeoCoordinate &coords: d->holePath(index))
- holeCoordinates << QVariant::fromValue(coords);
- return holeCoordinates;
-}
-
-/*!
- Returns a QList<QGeoCoordinate> which represents the hole at \a index.
-
- \since 5.12
-*/
-const QList<QGeoCoordinate> QGeoPolygon::holePath(qsizetype index) const
-{
- Q_D(const QGeoPolygon);
- return d->holePath(index);
-}
-
-/*!
- Removes element at position \a index from the list of holes.
-
- \since 5.12
-*/
-void QGeoPolygon::removeHole(qsizetype index)
-{
- Q_D(QGeoPolygon);
- return d->removeHole(index);
-}
-
-/*!
- Returns the number of holes.
-
- \since 5.12
-*/
-qsizetype QGeoPolygon::holesCount() const
-{
- Q_D(const QGeoPolygon);
- const qsizetype result = d->holesCount();
- if (result > kMaxInt)
- qWarning() << kTooManyHoles;
- return result;
-}
-
-/*******************************************************************************
- *
- * QGeoPathPrivate & friends
- *
-*******************************************************************************/
-
-QGeoPolygonPrivate::QGeoPolygonPrivate()
-: QGeoPathPrivate()
-{
- type = QGeoShape::PolygonType;
-}
-
-QGeoPolygonPrivate::QGeoPolygonPrivate(const QList<QGeoCoordinate> &path)
-: QGeoPathPrivate(path)
-{
- type = QGeoShape::PolygonType;
-}
-
-QGeoPolygonPrivate::~QGeoPolygonPrivate() {}
-
-QGeoShapePrivate *QGeoPolygonPrivate::clone() const
-{
- return new QGeoPolygonPrivate(*this);
-}
-
-bool QGeoPolygonPrivate::isValid() const
-{
- return path().size() > 2;
-}
-
-bool QGeoPolygonPrivate::contains(const QGeoCoordinate &coordinate) const
-{
- return polygonContains(coordinate);
-}
-
-inline static void translatePoly( QList<QGeoCoordinate> &m_path,
- QList<QList<QGeoCoordinate>> &m_holesList,
- QGeoRectangle &m_bbox,
- double degreesLatitude,
- double degreesLongitude,
- double m_maxLati,
- double m_minLati)
-{
- if (degreesLatitude > 0.0)
- degreesLatitude = qMin(degreesLatitude, 90.0 - m_maxLati);
- else
- degreesLatitude = qMax(degreesLatitude, -90.0 - m_minLati);
- for (QGeoCoordinate &p: m_path) {
- p.setLatitude(p.latitude() + degreesLatitude);
- p.setLongitude(QLocationUtils::wrapLong(p.longitude() + degreesLongitude));
- }
- if (!m_holesList.isEmpty()){
- for (QList<QGeoCoordinate> &hole: m_holesList){
- for (QGeoCoordinate &holeVertex: hole){
- holeVertex.setLatitude(holeVertex.latitude() + degreesLatitude);
- holeVertex.setLongitude(QLocationUtils::wrapLong(holeVertex.longitude() + degreesLongitude));
- }
- }
- }
- m_bbox.translate(degreesLatitude, degreesLongitude);
-}
-
-void QGeoPolygonPrivate::translate(double degreesLatitude, double degreesLongitude)
-{
- // Need min/maxLati, so update bbox
- QList<double> m_deltaXs;
- double m_minX, m_maxX, m_minLati, m_maxLati;
- m_bboxDirty = false; // Updated in translatePoly
- computeBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox);
- translatePoly(m_path, m_holesList, m_bbox, degreesLatitude, degreesLongitude, m_maxLati, m_minLati);
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
- m_clipperDirty = true;
-}
-
-bool QGeoPolygonPrivate::operator==(const QGeoShapePrivate &other) const
-{
- if (!QGeoShapePrivate::operator==(other)) // checks type
- return false;
-
- const QGeoPolygonPrivate &otherPath = static_cast<const QGeoPolygonPrivate &>(other);
- if (m_path.size() != otherPath.m_path.size()
- || m_holesList.size() != otherPath.m_holesList.size())
- return false;
- return m_path == otherPath.m_path && m_holesList == otherPath.m_holesList;
-}
-
-size_t QGeoPolygonPrivate::hash(size_t seed) const
-{
- const size_t pointsHash = qHashRange(m_path.cbegin(), m_path.cend(), seed);
- const size_t holesHash = qHashRange(m_holesList.cbegin(), m_holesList.cend(), seed);
- return qHashMulti(seed, pointsHash, holesHash);
-}
-
-void QGeoPolygonPrivate::addHole(const QList<QGeoCoordinate> &holePath)
-{
- for (const QGeoCoordinate &holeVertex: holePath)
- if (!holeVertex.isValid())
- return;
-
- m_holesList << holePath;
- // ToDo: mark clipper dirty when hole caching gets added
-}
-
-const QList<QGeoCoordinate> QGeoPolygonPrivate::holePath(qsizetype index) const
-{
- return m_holesList.at(index);
-}
-
-void QGeoPolygonPrivate::removeHole(qsizetype index)
-{
- if (index < 0 || index >= m_holesList.size())
- return;
-
- m_holesList.removeAt(index);
- // ToDo: mark clipper dirty when hole caching gets added
-}
-
-qsizetype QGeoPolygonPrivate::holesCount() const
-{
- return m_holesList.size();
-}
-
-bool QGeoPolygonPrivate::polygonContains(const QGeoCoordinate &coordinate) const
-{
- if (m_clipperDirty)
- const_cast<QGeoPolygonPrivate *>(this)->updateClipperPath(); // this one updates bbox too if needed
-
- QDoubleVector2D coord = QWebMercator::coordToMercator(coordinate);
-
- if (coord.x() < m_leftBoundWrapped)
- coord.setX(coord.x() + 1.0);
-
-
- IntPoint intCoord = QClipperUtils::toIntPoint(coord);
- if (!c2t::clip2tri::pointInPolygon(intCoord, m_clipperPath))
- return false;
-
- // else iterates the holes List checking whether the point is contained inside the holes
- for (const QList<QGeoCoordinate> &holePath : qAsConst(m_holesList)) {
- // ToDo: cache these
- QGeoPolygon holePolygon;
- holePolygon.setPerimeter(holePath);
- if (holePolygon.contains(coordinate))
- return false;
- }
- return true;
-}
-
-void QGeoPolygonPrivate::markDirty()
-{
- m_bboxDirty = m_clipperDirty = true;
-}
-
-void QGeoPolygonPrivate::updateClipperPath()
-{
- if (m_bboxDirty)
- computeBoundingBox();
- m_clipperDirty = false;
-
- QList<QDoubleVector2D> preservedPath;
- for (const QGeoCoordinate &c : m_path) {
- QDoubleVector2D crd = QWebMercator::coordToMercator(c);
- if (crd.x() < m_leftBoundWrapped)
- crd.setX(crd.x() + 1.0);
- preservedPath << crd;
- }
- m_clipperPath = QClipperUtils::qListToPath(preservedPath);
-}
-
-QGeoPolygonPrivateEager::QGeoPolygonPrivateEager() : QGeoPolygonPrivate()
-{
- m_bboxDirty = false; // never dirty on the eager version
-}
-
-QGeoPolygonPrivateEager::QGeoPolygonPrivateEager(const QList<QGeoCoordinate> &path) : QGeoPolygonPrivate(path)
-{
- m_bboxDirty = false; // never dirty on the eager version
-}
-
-QGeoPolygonPrivateEager::~QGeoPolygonPrivateEager()
-{
-
-}
-
-QGeoShapePrivate *QGeoPolygonPrivateEager::clone() const
-{
- return new QGeoPolygonPrivate(*this);
-}
-
-void QGeoPolygonPrivateEager::translate(double degreesLatitude, double degreesLongitude)
-{
- translatePoly(m_path, m_holesList, m_bbox, degreesLatitude, degreesLongitude, m_maxLati, m_minLati);
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
- m_clipperDirty = true;
-}
-
-void QGeoPolygonPrivateEager::markDirty()
-{
- m_clipperDirty = true;
- computeBoundingBox();
-}
-
-void QGeoPolygonPrivateEager::addCoordinate(const QGeoCoordinate &coordinate)
-{
- if (!coordinate.isValid())
- return;
- m_path.append(coordinate);
- m_clipperDirty = true;
- updateBoundingBox(); // do not markDirty as it uses computeBoundingBox instead
-}
-
-void QGeoPolygonPrivateEager::computeBoundingBox()
-{
- computeBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox);
- m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
-}
-
-void QGeoPolygonPrivateEager::updateBoundingBox()
-{
- updateBBox(m_path, m_deltaXs, m_minX, m_maxX, m_minLati, m_maxLati, m_bbox);
-}
-
-QGeoPolygonEager::QGeoPolygonEager() : QGeoPolygon()
-{
- initPolygonConversions();
- d_ptr = new QGeoPolygonPrivateEager;
-}
-
-QGeoPolygonEager::QGeoPolygonEager(const QList<QGeoCoordinate> &path) : QGeoPolygon()
-{
- initPolygonConversions();
- d_ptr = new QGeoPolygonPrivateEager(path);
-}
-
-QGeoPolygonEager::QGeoPolygonEager(const QGeoPolygon &other) : QGeoPolygon()
-{
- initPolygonConversions();
- // without being able to dynamic_cast the d_ptr, only way to be sure is to reconstruct a new QGeoPolygonPrivateEager
- d_ptr = new QGeoPolygonPrivateEager;
- setPerimeter(other.perimeter());
- for (qsizetype i = 0; i < other.holesCount(); i++)
- addHole(other.holePath(i));
-}
-
-QGeoPolygonEager::QGeoPolygonEager(const QGeoShape &other) : QGeoPolygon()
-{
- initPolygonConversions();
- if (other.type() == QGeoShape::PolygonType)
- *this = QGeoPolygonEager(QGeoPolygon(other));
- else
- d_ptr = new QGeoPolygonPrivateEager;
-}
-
-QGeoPolygonEager::~QGeoPolygonEager()
-{
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeopolygon.h b/src/positioning/qgeopolygon.h
deleted file mode 100644
index 1a24ea11..00000000
--- a/src/positioning/qgeopolygon.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOLYGON_H
-#define QGEOPOLYGON_H
-
-#include <QtPositioning/QGeoShape>
-#include <QtCore/QVariantList>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QGeoPolygonPrivate;
-
-class Q_POSITIONING_EXPORT QGeoPolygon : public QGeoShape
-{
- Q_GADGET
- Q_PROPERTY(QList<QGeoCoordinate> perimeter READ perimeter WRITE setPerimeter REVISION(5, 12))
-
-public:
- QGeoPolygon();
- QGeoPolygon(const QList<QGeoCoordinate> &path);
- QGeoPolygon(const QGeoPolygon &other);
- QGeoPolygon(const QGeoShape &other);
-
- ~QGeoPolygon();
-
- QGeoPolygon &operator=(const QGeoPolygon &other);
-
- void setPerimeter(const QList<QGeoCoordinate> &path);
- const QList<QGeoCoordinate> &perimeter() const;
-
- Q_INVOKABLE void addHole(const QVariant &holePath);
- void addHole(const QList<QGeoCoordinate> &holePath);
- Q_INVOKABLE const QVariantList hole(qsizetype index) const;
- const QList<QGeoCoordinate> holePath(qsizetype index) const;
- Q_INVOKABLE void removeHole(qsizetype index);
- Q_INVOKABLE qsizetype holesCount() const;
- Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
- Q_INVOKABLE QGeoPolygon translated(double degreesLatitude, double degreesLongitude) const;
- Q_INVOKABLE double length(qsizetype indexFrom = 0, qsizetype indexTo = -1) const;
- Q_INVOKABLE qsizetype size() const;
- Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate);
- Q_INVOKABLE void insertCoordinate(qsizetype index, const QGeoCoordinate &coordinate);
- Q_INVOKABLE void replaceCoordinate(qsizetype index, const QGeoCoordinate &coordinate);
- Q_INVOKABLE QGeoCoordinate coordinateAt(qsizetype index) const;
- Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate) const;
- Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate);
- Q_INVOKABLE void removeCoordinate(qsizetype index);
-
- Q_INVOKABLE QString toString() const;
-
-private:
- inline QGeoPolygonPrivate *d_func();
- inline const QGeoPolygonPrivate *d_func() const;
-};
-
-Q_DECLARE_TYPEINFO(QGeoPolygon, Q_RELOCATABLE_TYPE);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoPolygon)
-
-#endif // QGEOPOLYGON_H
diff --git a/src/positioning/qgeopolygon_p.h b/src/positioning/qgeopolygon_p.h
deleted file mode 100644
index 718f2ddd..00000000
--- a/src/positioning/qgeopolygon_p.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOLYGON_P_H
-#define QGEOPOLYGON_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioning/private/qgeopath_p.h>
-#include <QtPositioning/qgeopolygon.h>
-#include <QtPositioning/private/qclipperutils_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONING_PRIVATE_EXPORT QGeoPolygonPrivate : public QGeoPathPrivate
-{
-public:
- QGeoPolygonPrivate();
- QGeoPolygonPrivate(const QList<QGeoCoordinate> &path);
- ~QGeoPolygonPrivate();
-
-// QGeoShape API
- virtual QGeoShapePrivate *clone() const override;
- virtual bool isValid() const override;
- virtual bool contains(const QGeoCoordinate &coordinate) const override;
- virtual void translate(double degreesLatitude, double degreesLongitude) override;
- virtual bool operator==(const QGeoShapePrivate &other) const override;
- size_t hash(size_t seed) const override;
-
-// QGeoPath API
- virtual void markDirty() override;
-
-// QGeoPolygonPrivate API
- qsizetype holesCount() const;
- bool polygonContains(const QGeoCoordinate &coordinate) const;
- const QList<QGeoCoordinate> holePath(qsizetype index) const;
-
- virtual void addHole(const QList<QGeoCoordinate> &holePath);
- virtual void removeHole(qsizetype index);
- virtual void updateClipperPath();
-
-// data members
- bool m_clipperDirty = true;
- QList<QList<QGeoCoordinate>> m_holesList;
- QtClipperLib::Path m_clipperPath;
-};
-
-class Q_POSITIONING_PRIVATE_EXPORT QGeoPolygonPrivateEager : public QGeoPolygonPrivate
-{
-public:
- QGeoPolygonPrivateEager();
- QGeoPolygonPrivateEager(const QList<QGeoCoordinate> &path);
- ~QGeoPolygonPrivateEager();
-
-// QGeoShape API
- virtual QGeoShapePrivate *clone() const override;
- virtual void translate(double degreesLatitude, double degreesLongitude) override;
-
-// QGeoPath API
- virtual void markDirty() override;
- virtual void addCoordinate(const QGeoCoordinate &coordinate) override;
- virtual void computeBoundingBox() override;
-
-// QGeoPolygonPrivate API
-
-// *Eager API
- void updateBoundingBox();
-
-// data members
- QList<double> m_deltaXs; // longitude deltas from m_path[0]
- double m_minX = 0; // minimum value inside deltaXs
- double m_maxX = 0; // maximum value inside deltaXs
- double m_minLati = 0; // minimum latitude. paths do not wrap around through the poles
- double m_maxLati = 0; // minimum latitude. paths do not wrap around through the poles
-};
-
-// This is a mean of creating a QGeoPolygonPrivateEager and injecting it into QGeoPolygons via operator=
-class Q_POSITIONING_PRIVATE_EXPORT QGeoPolygonEager : public QGeoPolygon
-{
- Q_GADGET
-public:
-
- QGeoPolygonEager();
- QGeoPolygonEager(const QList<QGeoCoordinate> &path);
- QGeoPolygonEager(const QGeoPolygon &other);
- QGeoPolygonEager(const QGeoShape &other);
- ~QGeoPolygonEager();
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOLYGON_P_H
diff --git a/src/positioning/qgeopositioninfo.cpp b/src/positioning/qgeopositioninfo.cpp
deleted file mode 100644
index f641c0ad..00000000
--- a/src/positioning/qgeopositioninfo.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qgeopositioninfo.h"
-#include "private/qgeopositioninfo_p.h"
-#include <QHash>
-#include <QDebug>
-#include <QDataStream>
-#include <QtCore/QtNumeric>
-
-#include <algorithm>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoPositionInfo
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \ingroup shared
- \since 5.2
-
- \brief The QGeoPositionInfo class contains information gathered on a global position, direction and velocity at a particular point in time.
-
- A QGeoPositionInfo contains, at a minimum, a geographical coordinate and
- a timestamp. It may also have heading and speed measurements as well as
- estimates of the accuracy of the provided data.
-
- \sa QGeoPositionInfoSource
-*/
-
-/*!
- \enum QGeoPositionInfo::Attribute
- Defines the attributes for positional information.
-
- \value Direction The bearing measured in degrees clockwise from true north to the direction of travel.
- \value GroundSpeed The ground speed, in meters/sec.
- \value VerticalSpeed The vertical speed, in meters/sec.
- \value MagneticVariation The angle between the horizontal component of the magnetic field and true north, in degrees. Also known as magnetic declination. A positive value indicates a clockwise direction from true north and a negative value indicates a counter-clockwise direction.
- \value HorizontalAccuracy The accuracy of the provided latitude-longitude value, in meters.
- \value VerticalAccuracy The accuracy of the provided altitude value, in meters.
-
- NMEA protocol also suggests another type of accuracy - PositionAccuracy,
- which is a 3D accuracy value. Qt does not provide a separate attribute for
- it. If you need this value, you can calculate it based on the following
- formula:
-
- \c {PositionAccuracy} \sup 2 \c {= HorizontalAccuracy} \sup 2 \c { +
- VerticalAccuracy} \sup 2
-*/
-
-/*!
- Creates an invalid QGeoPositionInfo object.
-
- \sa isValid()
-*/
-QGeoPositionInfo::QGeoPositionInfo()
- : d(new QGeoPositionInfoPrivate)
-{
-}
-
-/*!
- Creates a QGeoPositionInfo for the given \a coordinate and \a timestamp.
-*/
-QGeoPositionInfo::QGeoPositionInfo(const QGeoCoordinate &coordinate, const QDateTime &timestamp)
- : d(new QGeoPositionInfoPrivate)
-{
- d->timestamp = timestamp;
- d->coord = coordinate;
-}
-
-/*!
- Creates a QGeoPositionInfo with the values of \a other.
-*/
-QGeoPositionInfo::QGeoPositionInfo(const QGeoPositionInfo &other)
- : d(other.d)
-{
-}
-
-/*!
- \fn QGeoPositionInfo::QGeoPositionInfo(QGeoPositionInfo &&other) noexcept
- \since 6.2
-
- Creates a QGeoPositionInfo object by moving from \a other.
-
- Note that a moved-from QGeoPositionInfo can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-QGeoPositionInfo::QGeoPositionInfo(QGeoPositionInfoPrivate &dd) : d(&dd)
-{
-}
-
-/*!
- Destroys a QGeoPositionInfo object.
-*/
-QGeoPositionInfo::~QGeoPositionInfo()
-{
-}
-
-QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QGeoPositionInfoPrivate)
-
-/*!
- Assigns the values from \a other to this QGeoPositionInfo.
-*/
-QGeoPositionInfo &QGeoPositionInfo::operator=(const QGeoPositionInfo & other)
-{
- if (this == &other)
- return *this;
-
- d = other.d;
- return *this;
-}
-
-/*!
- \fn QGeoPositionInfo &QGeoPositionInfo::operator=(QGeoPositionInfo &&other) noexcept
- \since 6.2
-
- Move-assigns the values from \a other to this object.
-
- Note that a moved-from QGeoPositionInfo can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- \fn bool QGeoPositionInfo::operator==(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs)
-
- Returns \c true if all of the \a lhs object's values are the same as those
- of \a rhs. Otherwise returns \c false.
-*/
-
-/*!
- \fn bool QGeoPositionInfo::operator!=(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs)
-
- Returns \c true if any of the \a lhs object's values are not the same as
- those of \a rhs. Otherwise returns \c false.
-*/
-
-/*!
- Returns true if the timestamp() and coordinate() values are both valid.
-
- \sa QGeoCoordinate::isValid(), QDateTime::isValid()
-*/
-bool QGeoPositionInfo::isValid() const
-{
- return d->timestamp.isValid() && d->coord.isValid();
-}
-
-/*!
- Sets the date and time at which this position was reported to \a timestamp.
-
- The \a timestamp must be in UTC time.
-
- \sa timestamp()
-*/
-void QGeoPositionInfo::setTimestamp(const QDateTime &timestamp)
-{
- d.detach();
- d->timestamp = timestamp;
-}
-
-/*!
- Returns the date and time at which this position was reported, in UTC time.
-
- Returns an invalid QDateTime if no date/time value has been set.
-
- \sa setTimestamp()
-*/
-QDateTime QGeoPositionInfo::timestamp() const
-{
- return d->timestamp;
-}
-
-/*!
- Sets the coordinate for this position to \a coordinate.
-
- \sa coordinate()
-*/
-void QGeoPositionInfo::setCoordinate(const QGeoCoordinate &coordinate)
-{
- d.detach();
- d->coord = coordinate;
-}
-
-/*!
- Returns the coordinate for this position.
-
- Returns an invalid coordinate if no coordinate has been set.
-
- \sa setCoordinate()
-*/
-QGeoCoordinate QGeoPositionInfo::coordinate() const
-{
- return d->coord;
-}
-
-/*!
- Sets the value for \a attribute to \a value.
-
- \sa attribute()
-*/
-void QGeoPositionInfo::setAttribute(Attribute attribute, qreal value)
-{
- d.detach();
- d->doubleAttribs[attribute] = value;
-}
-
-/*!
- Returns the value of the specified \a attribute as a qreal value.
-
- Returns NaN if the value has not been set.
-
- The function hasAttribute() should be used to determine whether or
- not a value has been set for an attribute.
-
- \sa hasAttribute(), setAttribute()
-*/
-qreal QGeoPositionInfo::attribute(Attribute attribute) const
-{
- if (d->doubleAttribs.contains(attribute))
- return d->doubleAttribs[attribute];
- return qQNaN();
-}
-
-/*!
- Removes the specified \a attribute and its value.
-*/
-void QGeoPositionInfo::removeAttribute(Attribute attribute)
-{
- d.detach();
- d->doubleAttribs.remove(attribute);
-}
-
-/*!
- Returns true if the specified \a attribute is present for this
- QGeoPositionInfo object.
-*/
-bool QGeoPositionInfo::hasAttribute(Attribute attribute) const
-{
- return d->doubleAttribs.contains(attribute);
-}
-
-/*!
- \internal
-*/
-void QGeoPositionInfo::detach()
-{
- if (d)
- d.detach();
- else
- d = new QGeoPositionInfoPrivate;
-}
-
-bool QGeoPositionInfo::equals(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs)
-{
- return *lhs.d == *rhs.d;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug QGeoPositionInfo::debugStreaming(QDebug dbg, const QGeoPositionInfo &info)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "QGeoPositionInfo(" << info.d->timestamp;
- dbg.nospace() << ", "; // timestamp force dbg.space() -> reverting here
- dbg << info.d->coord;
-
- QList<QGeoPositionInfo::Attribute> attribs = info.d->doubleAttribs.keys();
- std::stable_sort(attribs.begin(), attribs.end()); // Output a sorted list from an unsorted hash.
- for (int i = 0; i < attribs.count(); ++i) {
- dbg << ", ";
- switch (attribs[i]) {
- case QGeoPositionInfo::Direction:
- dbg << "Direction=";
- break;
- case QGeoPositionInfo::GroundSpeed:
- dbg << "GroundSpeed=";
- break;
- case QGeoPositionInfo::VerticalSpeed:
- dbg << "VerticalSpeed=";
- break;
- case QGeoPositionInfo::MagneticVariation:
- dbg << "MagneticVariation=";
- break;
- case QGeoPositionInfo::HorizontalAccuracy:
- dbg << "HorizontalAccuracy=";
- break;
- case QGeoPositionInfo::VerticalAccuracy:
- dbg << "VerticalAccuracy=";
- break;
- }
- dbg << info.d->doubleAttribs[attribs[i]];
- }
- dbg << ')';
- return dbg;
-}
-#endif
-
-
-#ifndef QT_NO_DATASTREAM
-/*!
- \fn QDataStream &QGeoPositionInfo::operator<<(QDataStream &stream, QGeoPositionInfo::Attribute attr)
-
- Writes the given \a attr enumeration to the specified \a stream.
-
- \sa {Serializing Qt Data Types}
-*/
-QDataStream &QGeoPositionInfo::dataStreamOut(QDataStream &stream, QGeoPositionInfo::Attribute attr)
-{
- return stream << int(attr);
-}
-
-/*!
- \fn QDataStream &QGeoPositionInfo::operator>>(QDataStream &stream, QGeoPositionInfo::Attribute &attr)
-
- Reads an attribute enumeration from the specified \a stream info the given \a attr.
-
- \sa {Serializing Qt Data Types}
-*/
-QDataStream &QGeoPositionInfo::dataStreamIn(QDataStream &stream, QGeoPositionInfo::Attribute &attr)
-{
- int a;
- stream >> a;
- attr = static_cast<QGeoPositionInfo::Attribute>(a);
- return stream;
-}
-
-/*!
- \fn QDataStream &QGeoPositionInfo::operator<<(QDataStream &stream, const QGeoPositionInfo &info)
-
- Writes the given \a info to the specified \a stream.
-
- \sa {Serializing Qt Data Types}
-*/
-
-QDataStream &QGeoPositionInfo::dataStreamOut(QDataStream &stream, const QGeoPositionInfo &info)
-{
- stream << info.d->timestamp;
- stream << info.d->coord;
- stream << info.d->doubleAttribs;
- return stream;
-}
-
-/*!
- \fn QDataStream &QGeoPositionInfo::operator>>(QDataStream &stream, QGeoPositionInfo &info)
-
- Reads a coordinate from the specified \a stream into the given
- \a info.
-
- \sa {Serializing Qt Data Types}
-*/
-
-QDataStream &QGeoPositionInfo::dataStreamIn(QDataStream &stream, QGeoPositionInfo &info)
-{
- stream >> info.d->timestamp;
- stream >> info.d->coord;
- stream >> info.d->doubleAttribs;
- return stream;
-}
-#endif
-
-QGeoPositionInfoPrivate::QGeoPositionInfoPrivate() : QSharedData()
-{
-}
-
-QGeoPositionInfoPrivate::QGeoPositionInfoPrivate(const QGeoPositionInfoPrivate &other)
- : QSharedData(other),
- timestamp(other.timestamp),
- coord(other.coord),
- doubleAttribs(other.doubleAttribs)
-{
-}
-
-QGeoPositionInfoPrivate::~QGeoPositionInfoPrivate()
-{
-
-}
-
-bool QGeoPositionInfoPrivate::operator==(const QGeoPositionInfoPrivate &other) const
-{
- return timestamp == other.timestamp
- && coord == other.coord
- && doubleAttribs == other.doubleAttribs;
-}
-
-QGeoPositionInfoPrivate *QGeoPositionInfoPrivate::get(const QGeoPositionInfo &info)
-{
- return info.d.data();
-}
-
-size_t qHash(const QGeoPositionInfo &key, size_t seed) noexcept
-{
- return qHashMulti(seed, key.d->coord);
-}
-
-namespace QTest
-{
-
-char *toString(const QGeoPositionInfo &info)
-{
- QString result;
- QDebug dbg(&result);
- dbg << info;
-
- return qstrdup(qPrintable(result));
-}
-
-} // namespace QTest
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeopositioninfo.h b/src/positioning/qgeopositioninfo.h
deleted file mode 100644
index 76f667b7..00000000
--- a/src/positioning/qgeopositioninfo.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QGEOPOSITIONINFO_H
-#define QGEOPOSITIONINFO_H
-
-#include <QtPositioning/QGeoCoordinate>
-#include <QtCore/QExplicitlySharedDataPointer>
-#include <QtCore/QMetaType>
-#include <QtCore/QDateTime>
-
-QT_BEGIN_NAMESPACE
-
-class QDebug;
-class QDataStream;
-
-class QGeoPositionInfo;
-Q_POSITIONING_EXPORT size_t qHash(const QGeoPositionInfo &key, size_t seed = 0) noexcept;
-namespace QTest
-{
-
-Q_POSITIONING_EXPORT char *toString(const QGeoPositionInfo &info);
-
-} // namespace QTest
-
-class QGeoPositionInfoPrivate;
-QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGeoPositionInfoPrivate, Q_POSITIONING_EXPORT)
-
-class Q_POSITIONING_EXPORT QGeoPositionInfo
-{
-public:
- enum Attribute {
- Direction,
- GroundSpeed,
- VerticalSpeed,
- MagneticVariation,
- HorizontalAccuracy,
- VerticalAccuracy
- };
-
- QGeoPositionInfo();
- QGeoPositionInfo(const QGeoCoordinate &coordinate, const QDateTime &updateTime);
- QGeoPositionInfo(const QGeoPositionInfo &other);
- QGeoPositionInfo(QGeoPositionInfo &&other) noexcept = default;
- QGeoPositionInfo(QGeoPositionInfoPrivate &dd);
- ~QGeoPositionInfo();
-
- QGeoPositionInfo &operator=(const QGeoPositionInfo &other);
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGeoPositionInfo)
-
- void swap(QGeoPositionInfo &other) noexcept { d.swap(other.d); }
-
- friend bool operator==(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs)
- {
- return equals(lhs, rhs);
- }
- friend bool operator!=(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs)
- {
- return !equals(lhs, rhs);
- }
-
- bool isValid() const;
-
- void setTimestamp(const QDateTime &timestamp);
- QDateTime timestamp() const;
-
- void setCoordinate(const QGeoCoordinate &coordinate);
- QGeoCoordinate coordinate() const;
-
- void setAttribute(Attribute attribute, qreal value);
- qreal attribute(Attribute attribute) const;
- void removeAttribute(Attribute attribute);
- bool hasAttribute(Attribute attribute) const;
-
- void detach();
-
-private:
- static bool equals(const QGeoPositionInfo &lhs, const QGeoPositionInfo &rhs);
-#ifndef QT_NO_DEBUG_STREAM
- friend QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info)
- {
- return debugStreaming(dbg, info);
- }
- static QDebug debugStreaming(QDebug dbg, const QGeoPositionInfo &info);
-#endif
-#ifndef QT_NO_DATASTREAM
- friend QDataStream &operator<<(QDataStream &stream, const QGeoPositionInfo &info)
- {
- return dataStreamOut(stream, info);
- }
- friend QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo &info)
- {
- return dataStreamIn(stream, info);
- }
- static QDataStream &dataStreamOut(QDataStream &stream, const QGeoPositionInfo &info);
- static QDataStream &dataStreamIn(QDataStream &stream, QGeoPositionInfo &info);
-
- friend QDataStream &operator<<(QDataStream &stream, QGeoPositionInfo::Attribute attr)
- {
- return dataStreamOut(stream, attr);
- }
- friend QDataStream &operator>>(QDataStream &stream, QGeoPositionInfo::Attribute &attr)
- {
- return dataStreamIn(stream, attr);
- }
- static QDataStream &dataStreamOut(QDataStream &stream, QGeoPositionInfo::Attribute attr);
- static QDataStream &dataStreamIn(QDataStream &stream, QGeoPositionInfo::Attribute &attr);
-#endif
- QExplicitlySharedDataPointer<QGeoPositionInfoPrivate> d;
- friend class QGeoPositionInfoPrivate;
-
- friend Q_POSITIONING_EXPORT size_t qHash(const QGeoPositionInfo &key, size_t seed) noexcept;
- friend Q_POSITIONING_EXPORT char *QTest::toString(const QGeoPositionInfo &info);
-};
-
-Q_DECLARE_SHARED(QGeoPositionInfo)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoPositionInfo)
-
-#endif // QGEOPOSITIONINFO_H
diff --git a/src/positioning/qgeopositioninfo_p.h b/src/positioning/qgeopositioninfo_p.h
deleted file mode 100644
index e3d9f436..00000000
--- a/src/positioning/qgeopositioninfo_p.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QGEOPOSITIONINFO_P_H
-#define QGEOPOSITIONINFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include "qgeopositioninfo.h"
-#include <QHash>
-#include <QDateTime>
-#include <QtPositioning/qgeocoordinate.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoPrivate : public QSharedData
-{
-public:
- QGeoPositionInfoPrivate();
- QGeoPositionInfoPrivate(const QGeoPositionInfoPrivate &other);
- virtual ~QGeoPositionInfoPrivate();
- bool operator==(const QGeoPositionInfoPrivate &other) const;
-
- QDateTime timestamp;
- QGeoCoordinate coord;
- QHash<QGeoPositionInfo::Attribute, qreal> doubleAttribs;
-
- static QGeoPositionInfoPrivate *get(const QGeoPositionInfo &info);
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFO_P_H
diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp
deleted file mode 100644
index e09be54e..00000000
--- a/src/positioning/qgeopositioninfosource.cpp
+++ /dev/null
@@ -1,634 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qgeopositioninfosource.h>
-#include "qgeopositioninfosource_p.h"
-#include "qgeopositioninfosourcefactory.h"
-
-#include <QFile>
-#include <QPluginLoader>
-#include <QStringList>
-#include <QJsonObject>
-#include <QCryptographicHash>
-#include <QtCore/private/qfactoryloader_p.h>
-#include <QtCore/private/qthread_p.h>
-
-#include <algorithm>
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- ("org.qt-project.qt.position.sourcefactory/6.0",
- QLatin1String("/position")))
-
-/*!
- \class QGeoPositionInfoSource
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QGeoPositionInfoSource class is an abstract base class for the distribution of positional updates.
-
- The static function QGeoPositionInfoSource::createDefaultSource() creates a default
- position source that is appropriate for the platform, if one is available.
- Otherwise, QGeoPositionInfoSource will check for available plugins that
- implement the QGeoPositionInfoSourceFactory interface.
-
- Users of a QGeoPositionInfoSource subclass can request the current position using
- requestUpdate(), or start and stop regular position updates using
- startUpdates() and stopUpdates(). When an update is available,
- positionUpdated() is emitted. The last known position can be accessed with
- lastKnownPosition().
-
- If regular position updates are required, setUpdateInterval() can be used
- to specify how often these updates should be emitted. If no interval is
- specified, updates are simply provided whenever they are available.
- For example:
-
- \code
- // Emit updates every 10 seconds if available
- QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(0);
- if (source)
- source->setUpdateInterval(10000);
- \endcode
-
- To remove an update interval that was previously set, call
- setUpdateInterval() with a value of 0.
-
- \note The position source may have a minimum value requirement for
- update intervals, as returned by minimumUpdateInterval().
-
- \note To use this class from Android service, see
- \l {Qt Positioning on Android}.
-*/
-
-/*!
- \enum QGeoPositionInfoSource::PositioningMethod
- Defines the types of positioning methods.
-
- \value NoPositioningMethods None of the positioning methods.
- \value SatellitePositioningMethods Satellite-based positioning methods such as GPS or GLONASS.
- \value NonSatellitePositioningMethods Other positioning methods such as 3GPP cell identifier or WiFi based positioning.
- \value AllPositioningMethods Satellite-based positioning methods as soon as available. Otherwise non-satellite based methods.
-*/
-
-QGeoPositionInfoSourcePrivate::~QGeoPositionInfoSourcePrivate()
-{
-
-}
-
-QGeoPositionInfoSourceFactory *QGeoPositionInfoSourcePrivate::loadFactory(const QJsonObject &meta)
-{
- const int idx = static_cast<int>(meta.value(QStringLiteral("index")).toDouble());
- if (idx < 0)
- return nullptr;
- QObject *instance = loader()->instance(idx);
- if (!instance)
- return nullptr;
- return qobject_cast<QGeoPositionInfoSourceFactory *>(instance);
-}
-
-QMultiHash<QString, QJsonObject> QGeoPositionInfoSourcePrivate::plugins(bool reload)
-{
- static QMultiHash<QString, QJsonObject> plugins;
- static bool alreadyDiscovered = false;
-
- if (reload == true)
- alreadyDiscovered = false;
-
- if (!alreadyDiscovered) {
- loadPluginMetadata(plugins);
- alreadyDiscovered = true;
- }
- return plugins;
-}
-
-static bool pluginComparator(const QJsonObject &p1, const QJsonObject &p2)
-{
- const QString prio = QStringLiteral("Priority");
- if (p1.contains(prio) && !p2.contains(prio))
- return true;
- if (!p1.contains(prio) && p2.contains(prio))
- return false;
- if (p1.value(prio).isDouble() && !p2.value(prio).isDouble())
- return true;
- if (!p1.value(prio).isDouble() && p2.value(prio).isDouble())
- return false;
- return (p1.value(prio).toDouble() > p2.value(prio).toDouble());
-}
-
-QList<QJsonObject> QGeoPositionInfoSourcePrivate::pluginsSorted()
-{
- QList<QJsonObject> list = plugins().values();
- std::stable_sort(list.begin(), list.end(), pluginComparator);
- return list;
-}
-
-void QGeoPositionInfoSourcePrivate::loadPluginMetadata(QMultiHash<QString, QJsonObject> &plugins)
-{
- QFactoryLoader *l = loader();
- QList<QJsonObject> meta = l->metaData();
- for (int i = 0; i < meta.size(); ++i) {
- QJsonObject obj = meta.at(i).value(QStringLiteral("MetaData")).toObject();
- const QString testableKey = QStringLiteral("Testable");
- if (obj.contains(testableKey) && !obj.value(testableKey).toBool()) {
- static bool inTest = qEnvironmentVariableIsSet("QT_QTESTLIB_RUNNING");
- if (inTest)
- continue;
- }
- obj.insert(QStringLiteral("index"), i);
- plugins.insert(obj.value(QStringLiteral("Provider")).toString(), obj);
- }
-}
-
-/*!
- Creates a position source with the specified \a parent.
-*/
-
-QGeoPositionInfoSource::QGeoPositionInfoSource(QObject *parent)
- : QObject(*new QGeoPositionInfoSourcePrivate, parent)
-{
- qRegisterMetaType<QGeoPositionInfo>();
-}
-
-/*!
- Destroys the position source.
-*/
-QGeoPositionInfoSource::~QGeoPositionInfoSource()
-{
-}
-
-/*!
- \property QGeoPositionInfoSource::sourceName
- \brief This property holds the unique name of the position source
- implementation in use.
-
- This is the same name that can be passed to createSource() in order to
- create a new instance of a particular position source implementation.
-*/
-QString QGeoPositionInfoSource::sourceName() const
-{
- Q_D(const QGeoPositionInfoSource);
- return d->sourceName;
-}
-
-/*!
- Sets the backend-specific property named \a name to \a value.
- Returns \c true on success, \c false otherwise.
- Backend-specific properties can be used to configure the positioning subsystem behavior
- at runtime.
- Supported backend-specific properties are listed and described in
- \l {Qt Positioning plugins#Default plugins}.
-
- \sa backendProperty
- \since Qt 5.14
-*/
-bool QGeoPositionInfoSource::setBackendProperty(const QString &name, const QVariant &value)
-{
- Q_UNUSED(name)
- Q_UNUSED(value)
- return false;
-}
-
-/*!
- Returns the value of the backend-specific property named \a name, if present.
- Otherwise, the returned value will be invalid.
- Supported backend-specific properties are listed and described in
- \l {Qt Positioning plugins#Default plugins}.
-
- \sa setBackendProperty
- \since Qt 5.14
-*/
-QVariant QGeoPositionInfoSource::backendProperty(const QString &name) const
-{
- Q_UNUSED(name)
- return QVariant();
-}
-
-/*!
- \property QGeoPositionInfoSource::updateInterval
- \brief This property holds the requested interval in milliseconds between each update.
-
- If the update interval is not set (or is set to 0) the
- source will provide updates as often as necessary.
-
- If the update interval is set, the source will provide updates at an
- interval as close to the requested interval as possible. If the requested
- interval is less than the minimumUpdateInterval(),
- the minimum interval is used instead.
-
- Changes to the update interval will happen as soon as is practical, however the
- time the change takes may vary between implementations. Whether or not the elapsed
- time from the previous interval is counted as part of the new interval is also
- implementation dependent.
-
- The default value for this property is 0.
-
- \note Subclass implementations must call the base implementation of
- \c {setUpdateInterval()} so that \c {updateInterval()} returns the correct
- value.
-*/
-void QGeoPositionInfoSource::setUpdateInterval(int msec)
-{
- Q_D(QGeoPositionInfoSource);
- d->interval = msec;
-}
-
-int QGeoPositionInfoSource::updateInterval() const
-{
- Q_D(const QGeoPositionInfoSource);
- return d->interval.value();
-}
-
-QBindable<int> QGeoPositionInfoSource::bindableUpdateInterval()
-{
- Q_D(QGeoPositionInfoSource);
- return QBindable<int>(&d->interval);
-}
-
-/*!
- \property QGeoPositionInfoSource::preferredPositioningMethods
-
- \brief Sets the preferred positioning methods for this source.
-
- If new methods include a method that is not supported by the source, the
- unsupported method will be ignored.
-
- If new methods do not include a single method available/supported by the
- source, the preferred methods will be set to the set of methods which the
- source has available. If the source has no method availabe (e.g. because its
- Location service is turned off or it does not offer a Location service),
- the passed methods are accepted as they are.
-
- The default value for this property is \l {QGeoPositionInfoSource::}
- {NoPositioningMethods}.
-
- \note Subclass implementations must call the base implementation of
- \c {setPreferredPositioningMethods()} to ensure
- \c {preferredPositioningMethods()} returns the correct value.
-
- \sa supportedPositioningMethods()
-*/
-void QGeoPositionInfoSource::setPreferredPositioningMethods(PositioningMethods methods)
-{
- Q_D(QGeoPositionInfoSource);
- d->methods.removeBindingUnlessInWrapper();
- // The supported positioning methods can change during the calls to this
- // method, so we can't have a simple check like:
- // if (currentMethods == methods) return;
- // Instead we need to save the current value and compare it afterwards
- const auto prevMethods = d->methods.value();
-
- if (supportedPositioningMethods() != QGeoPositionInfoSource::NoPositioningMethods) {
- d->methods.setValueBypassingBindings(methods & supportedPositioningMethods());
- if (d->methods.value() == 0) {
- d->methods.setValueBypassingBindings(supportedPositioningMethods());
- }
- } else { // avoid that turned of Location service blocks any changes to d->methods
- d->methods.setValueBypassingBindings(methods);
- }
- if (prevMethods != d->methods.value())
- d->methods.notify();
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSource::preferredPositioningMethods() const
-{
- Q_D(const QGeoPositionInfoSource);
- return d->methods.value();
-}
-
-QBindable<QGeoPositionInfoSource::PositioningMethods>
-QGeoPositionInfoSource::bindablePreferredPositioningMethods()
-{
- Q_D(QGeoPositionInfoSource);
- return QBindable<PositioningMethods>(&d->methods);
-}
-
-QGeoPositionInfoSource *QGeoPositionInfoSourcePrivate::createSourceReal(const QJsonObject &meta, const QVariantMap &parameters, QObject *parent)
-{
- QGeoPositionInfoSource *s = nullptr;
- auto factory = QGeoPositionInfoSourcePrivate::loadFactory(meta);
- if (factory)
- s = factory->positionInfoSource(parent, parameters);
- if (s)
- s->d_func()->sourceName = meta.value(QStringLiteral("Provider")).toString();
-
- return s;
-}
-
-/*!
- Creates and returns a position source with the given \a parent that
- reads from the system's default sources of location data, or the plugin
- with the highest available priority.
-
- Returns \c nullptr if the system has no default position source, no valid
- plugins could be found or the user does not have the permission to access
- the current position.
-*/
-QGeoPositionInfoSource *QGeoPositionInfoSource::createDefaultSource(QObject *parent)
-{
- return createDefaultSource(QVariantMap(), parent);
-}
-
-/*!
- Creates and returns a position source with the given \a parent that
- reads from the system's default sources of location data, or the plugin
- with the highest available priority.
-
- Returns \c nullptr if the system has no default position source, no valid plugins
- could be found or the user does not have the permission to access the current position.
-
- This method passes \a parameters to the factory to configure the source.
-
- \since Qt 5.14
-*/
-QGeoPositionInfoSource *QGeoPositionInfoSource::createDefaultSource(const QVariantMap &parameters, QObject *parent)
-{
- QList<QJsonObject> plugins = QGeoPositionInfoSourcePrivate::pluginsSorted();
- foreach (const QJsonObject &obj, plugins) {
- if (obj.value(QStringLiteral("Position")).isBool()
- && obj.value(QStringLiteral("Position")).toBool()) {
- QGeoPositionInfoSource *source = QGeoPositionInfoSourcePrivate::createSourceReal(obj, parameters, parent);
- if (source)
- return source;
- }
- }
- return nullptr;
-}
-
-/*!
- Creates and returns a position source with the given \a parent,
- by loading the plugin named \a sourceName.
-
- Returns \c nullptr if the plugin cannot be found.
-*/
-QGeoPositionInfoSource *QGeoPositionInfoSource::createSource(const QString &sourceName, QObject *parent)
-{
- return createSource(sourceName, QVariantMap(), parent);
-}
-
-/*!
- Creates and returns a position source with the given \a parent,
- by loading the plugin named \a sourceName.
-
- Returns \c nullptr if the plugin cannot be found.
-
- This method passes \a parameters to the factory to configure the source.
-
- \since Qt 5.14
-*/
-QGeoPositionInfoSource *QGeoPositionInfoSource::createSource(const QString &sourceName, const QVariantMap &parameters, QObject *parent)
-{
- auto plugins = QGeoPositionInfoSourcePrivate::plugins();
- if (plugins.contains(sourceName))
- return QGeoPositionInfoSourcePrivate::createSourceReal(plugins.value(sourceName), parameters, parent);
- return nullptr;
-}
-
-/*!
- Returns a list of available source plugins. This includes any default backend
- plugin for the current platform.
-*/
-QStringList QGeoPositionInfoSource::availableSources()
-{
- QStringList plugins;
- const auto meta = QGeoPositionInfoSourcePrivate::plugins();
- for (auto it = meta.cbegin(), end = meta.cend(); it != end; ++it) {
- if (it.value().value(QStringLiteral("Position")).isBool()
- && it.value().value(QStringLiteral("Position")).toBool()) {
- plugins << it.key();
- }
- }
-
- return plugins;
-}
-
-QGeoPositionInfoSource::QGeoPositionInfoSource(QGeoPositionInfoSourcePrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
- qRegisterMetaType<QGeoPositionInfo>();
- Q_D(QGeoPositionInfoSource);
- d->interval.setValueBypassingBindings(0);
- d->methods.setValueBypassingBindings(NoPositioningMethods);
-}
-
-/*!
- \fn QGeoPositionInfo QGeoPositionInfoSource::lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const = 0;
-
- Returns an update containing the last known position, or a null update
- if none is available.
-
- If \a fromSatellitePositioningMethodsOnly is true, this returns the last
- known position received from a satellite positioning method; if none
- is available, a null update is returned.
-*/
-
-/*!
- \fn virtual PositioningMethods QGeoPositionInfoSource::supportedPositioningMethods() const = 0;
-
- Returns the positioning methods available to this source. Availability is defined as being usable
- at the time of calling this function. Therefore user settings like turned off location service or
- limitations to Satellite-based position providers are reflected by this function. Runtime notifications
- when the status changes can be obtained via \l supportedPositioningMethodsChanged().
-
- Not all platforms distinguish the different positioning methods or communicate the current user
- configuration of the device. The following table provides an overview of the current platform situation:
-
- \table
- \header
- \li Platform
- \li Brief Description
- \row
- \li Android
- \li Individual provider status and general Location service state are known and communicated
- when location service is active.
- \row
- \li GeoClue
- \li Hardcoced to always return AllPositioningMethods.
- \row
- \li GeoClue2
- \li Individual providers are not distinguishable but disabled Location services reflected.
- \row
- \li iOS/tvOS
- \li Hardcoced to always return AllPositioningMethods.
- \row
- \li macOS
- \li Hardcoced to always return AllPositioningMethods.
- \row
- \li Windows (UWP)
- \li Individual providers are not distinguishable but disabled Location services reflected.
- \endtable
-
- \sa supportedPositioningMethodsChanged(), setPreferredPositioningMethods()
-*/
-
-
-/*!
- \property QGeoPositionInfoSource::minimumUpdateInterval
- \brief This property holds the minimum time (in milliseconds) required to retrieve a position update.
-
- This is the minimum value accepted by setUpdateInterval() and
- requestUpdate().
-*/
-
-
-/*!
- \fn virtual void QGeoPositionInfoSource::startUpdates() = 0;
-
- Starts emitting updates at regular intervals as specified by setUpdateInterval().
-
- If setUpdateInterval() has not been called, the source will emit updates
- as soon as they become available.
-
- An errorOccurred() signal with the \l {QGeoPositionInfoSource::}
- {UpdateTimeoutError} will be emitted if this QGeoPositionInfoSource subclass
- determines that it will not be able to provide regular updates. This could
- happen if a satellite fix is lost or if a hardware error is detected.
- Position updates will recommence if the data becomes available later on.
- The \l {QGeoPositionInfoSource::}{UpdateTimeoutError} error will not
- be emitted again until after the periodic updates resume.
-
- \note Since Qt6 this method always resets the last error to
- \l {QGeoPositionInfoSource::}{NoError} before starting the updates.
-
- \note To understand how to use this method from an Android service, see
- \l {Qt Positioning on Android}.
-
- On iOS, starting from version 8, Core Location framework requires additional
- entries in the application's Info.plist with keys NSLocationAlwaysUsageDescription or
- NSLocationWhenInUseUsageDescription and a string to be displayed in the authorization prompt.
- The key NSLocationWhenInUseUsageDescription is used when requesting permission
- to use location services while the app is in the foreground.
- The key NSLocationAlwaysUsageDescription is used when requesting permission
- to use location services whenever the app is running (both the foreground and the background).
- If both entries are defined, NSLocationWhenInUseUsageDescription has a priority in the
- foreground mode.
-*/
-
-/*!
- \fn virtual void QGeoPositionInfoSource::stopUpdates() = 0;
-
- Stops emitting updates at regular intervals.
-*/
-
-/*!
- \fn virtual void QGeoPositionInfoSource::requestUpdate(int timeout = 0);
-
- Attempts to get the current position and emit positionUpdated() with
- this information. If the current position cannot be found within the given \a timeout
- (in milliseconds) or if \a timeout is less than the value returned by
- minimumUpdateInterval(), an errorOccurred() signal with the
- \l {QGeoPositionInfoSource::}{UpdateTimeoutError} is emitted.
-
- If the timeout is zero, the timeout defaults to a reasonable timeout
- period as appropriate for the source.
-
- This does nothing if another update request is in progress. However
- it can be called even if startUpdates() has already been called and
- regular updates are in progress.
-
- If the source uses multiple positioning methods, it tries to get the
- current position from the most accurate positioning method within the
- given timeout.
-
- \note Since Qt6 this method always resets the last error to
- \l {QGeoPositionInfoSource::}{NoError} before requesting
- the position.
-
- \note To understand how to use this method from an Android service, see
- \l {Qt Positioning on Android}.
-*/
-
-/*!
- \fn virtual QGeoPositionInfoSource::Error QGeoPositionInfoSource::error() const;
-
- Returns the type of error that last occurred.
-
- \note Since Qt6 the last error is always reset when calling startUpdates()
- or requestUpdate().
-*/
-
-/*!
- \fn void QGeoPositionInfoSource::positionUpdated(const QGeoPositionInfo &update);
-
- If startUpdates() or requestUpdate() is called, this signal is emitted
- when an update becomes available.
-
- The \a update value holds the value of the new update.
-*/
-
-/*!
- \fn void QGeoPositionInfoSource::errorOccurred(QGeoPositionInfoSource::Error positioningError)
-
- This signal is emitted after an error occurred. The \a positioningError
- parameter describes the type of error that occurred.
-*/
-
-/*!
- \enum QGeoPositionInfoSource::Error
-
- The Error enumeration represents the errors which can occur.
-
- \value AccessError The connection setup to the remote positioning backend failed because the
- application lacked the required privileges.
- \value ClosedError The remote positioning backend closed the connection, which happens for example in case
- the user is switching location services to off. As soon as the location service is re-enabled
- regular updates will resume.
- \value NoError No error has occurred.
- \value UnknownSourceError An unidentified error occurred.
- \value [since 6.2] UpdateTimeoutError If requestUpdate() was called, this
- error indicates that the current position could not be retrieved within
- the specified timeout. If startUpdates() was called, this error
- indicates that this QGeoPositionInfoSource subclass determined that it
- will not be able to provide further regular updates. In the latter case
- the error would not be emitted again until after the regular updates
- resume.
- */
-
-/*!
- \fn void QGeoPositionInfoSource::supportedPositioningMethodsChanged()
-
- This signal is emitted when the supported positioning methods changed. The cause for a change could be
- a user turning Location services on/off or restricting Location services to certain types (e.g. GPS only).
- Note that changes to the supported positioning methods cannot be detected on all platforms.
- \l supportedPositioningMethods() provides an overview of the current platform support.
-
- \since Qt 5.12
-*/
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeopositioninfosource.h b/src/positioning/qgeopositioninfosource.h
deleted file mode 100644
index e03f6797..00000000
--- a/src/positioning/qgeopositioninfosource.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCE_H
-#define QGEOPOSITIONINFOSOURCE_H
-
-#include <QtPositioning/QGeoPositionInfo>
-
-#include <QtCore/QObject>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourcePrivate;
-class Q_POSITIONING_EXPORT QGeoPositionInfoSource : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval BINDABLE
- bindableUpdateInterval)
- Q_PROPERTY(int minimumUpdateInterval READ minimumUpdateInterval)
- Q_PROPERTY(QString sourceName READ sourceName)
- Q_PROPERTY(PositioningMethods preferredPositioningMethods READ preferredPositioningMethods WRITE
- setPreferredPositioningMethods BINDABLE bindablePreferredPositioningMethods)
-
-public:
- enum Error {
- AccessError = 0,
- ClosedError = 1,
- UnknownSourceError = 2,
- NoError = 3,
- UpdateTimeoutError = 4
- };
- Q_ENUM(Error)
-
- enum PositioningMethod {
- NoPositioningMethods = 0x00000000,
- SatellitePositioningMethods = 0x000000ff,
- NonSatellitePositioningMethods = 0xffffff00,
- AllPositioningMethods = 0xffffffff
- };
- Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)
-
- explicit QGeoPositionInfoSource(QObject *parent);
- virtual ~QGeoPositionInfoSource();
-
- virtual void setUpdateInterval(int msec);
- int updateInterval() const;
- QBindable<int> bindableUpdateInterval();
-
- virtual void setPreferredPositioningMethods(PositioningMethods methods);
- PositioningMethods preferredPositioningMethods() const;
- QBindable<PositioningMethods> bindablePreferredPositioningMethods();
-
- virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const = 0;
-
- virtual PositioningMethods supportedPositioningMethods() const = 0;
- virtual int minimumUpdateInterval() const = 0;
-
- QString sourceName() const;
-
- virtual bool setBackendProperty(const QString &name, const QVariant &value);
- virtual QVariant backendProperty(const QString &name) const;
-
- static QGeoPositionInfoSource *createDefaultSource(QObject *parent);
- static QGeoPositionInfoSource *createDefaultSource(const QVariantMap &parameters, QObject *parent);
- static QGeoPositionInfoSource *createSource(const QString &sourceName, QObject *parent);
- static QGeoPositionInfoSource *createSource(const QString &sourceName, const QVariantMap &parameters, QObject *parent);
- static QStringList availableSources();
- virtual Error error() const = 0;
-
-public Q_SLOTS:
- virtual void startUpdates() = 0;
- virtual void stopUpdates() = 0;
-
- virtual void requestUpdate(int timeout = 0) = 0;
-
-Q_SIGNALS:
- void positionUpdated(const QGeoPositionInfo &update);
- void errorOccurred(QGeoPositionInfoSource::Error);
- void supportedPositioningMethodsChanged();
-
-protected:
- explicit QGeoPositionInfoSource(QGeoPositionInfoSourcePrivate &dd, QObject *parent);
-
-private:
- Q_DISABLE_COPY(QGeoPositionInfoSource)
- Q_DECLARE_PRIVATE(QGeoPositionInfoSource)
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoPositionInfoSource::PositioningMethods)
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeopositioninfosource_p.h b/src/positioning/qgeopositioninfosource_p.h
deleted file mode 100644
index 8021250b..00000000
--- a/src/positioning/qgeopositioninfosource_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCE_P_H
-#define QGEOPOSITIONINFOSOURCE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/private/qobject_p.h>
-#include <QtCore/private/qproperty_p.h>
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include "qgeopositioninfosource.h"
-#include "qgeopositioninfosourcefactory.h"
-#include <QJsonObject>
-#include <QString>
-#include <QMultiHash>
-#include <QList>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoPositionInfoSourcePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QGeoPositionInfoSource)
-public:
- virtual ~QGeoPositionInfoSourcePrivate();
-
- static QGeoPositionInfoSourceFactory *loadFactory(const QJsonObject &meta);
- static QGeoPositionInfoSource *createSourceReal(const QJsonObject &meta,
- const QVariantMap &parameters,
- QObject *parent);
-
- void setPositioningMethods(QGeoPositionInfoSource::PositioningMethods methods)
- {
- q_func()->setPreferredPositioningMethods(methods);
- }
-
- Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QGeoPositionInfoSourcePrivate, int, interval, 0)
- Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QGeoPositionInfoSourcePrivate,
- QGeoPositionInfoSource::PositioningMethods, methods,
- &QGeoPositionInfoSourcePrivate::setPositioningMethods,
- QGeoPositionInfoSource::NoPositioningMethods)
- QString sourceName;
-
- static QMultiHash<QString, QJsonObject> plugins(bool reload = false);
- static void loadPluginMetadata(QMultiHash<QString, QJsonObject> &list);
- static QList<QJsonObject> pluginsSorted();
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCE_P_H
diff --git a/src/positioning/qgeopositioninfosourcefactory.cpp b/src/positioning/qgeopositioninfosourcefactory.cpp
deleted file mode 100644
index 673ee60e..00000000
--- a/src/positioning/qgeopositioninfosourcefactory.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosourcefactory.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoPositionInfoSourceFactory
- \inmodule QtPositioning
- \since 5.2
-
- \brief The QGeoPositionInfoSourceFactory class is a factory class used
- as the plugin interface for external providers of positioning data.
-
- Each factory method takes a parameters argument, which allows to configure
- the created source.
-*/
-
-/*!
- \fn QGeoPositionInfoSource *QGeoPositionInfoSourceFactory::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-
- Returns a new QGeoPositionInfoSource associated with this plugin
- with parent \a parent, and using \a parameters as configuration parameters.
- Can also return 0, in which case the plugin loader will use the factory with
- the next highest priority.
-*/
-
-/*!
- \fn QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactory::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-
- Returns a new QGeoSatelliteInfoSource associated with this plugin
- with parent \a parent, and using \a parameters as configuration parameters.
- Can also return 0, in which case the plugin loader will use the factory with
- the next highest priority.
-*/
-
-/*!
- \fn QGeoAreaMonitorSource *QGeoPositionInfoSourceFactory::areaMonitor(QObject *parent, const QVariantMap &parameters);
-
- Returns a new QGeoAreaMonitorSource associated with this plugin with parent
- \a parent, and using \a parameters as configuration parameters.
- Can also return 0, in which case the plugin loader will use the factory with
- the next highest priority.
-*/
-
-/*!
- Destroys the position info source factory.
-*/
-QGeoPositionInfoSourceFactory::~QGeoPositionInfoSourceFactory()
-{}
-
-QT_END_NAMESPACE
-
diff --git a/src/positioning/qgeopositioninfosourcefactory.h b/src/positioning/qgeopositioninfosourcefactory.h
deleted file mode 100644
index dc98bc85..00000000
--- a/src/positioning/qgeopositioninfosourcefactory.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEFACTORY_H
-#define QGEOPOSITIONINFOSOURCEFACTORY_H
-
-#include <QtPositioning/QGeoPositionInfoSource>
-#include <QtPositioning/QGeoSatelliteInfoSource>
-#include <QtPositioning/QGeoAreaMonitorSource>
-#include <QtCore/QList>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONING_EXPORT QGeoPositionInfoSourceFactory
-{
-public:
- virtual ~QGeoPositionInfoSourceFactory();
-
- virtual QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) = 0;
- virtual QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) = 0;
- virtual QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) = 0;
-};
-
-#define QT_POSITION_SOURCE_INTERFACE
-Q_DECLARE_INTERFACE(QGeoPositionInfoSourceFactory,
- "org.qt-project.qt.position.sourcefactory/6.0")
-
-QT_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEFACTORY_H
diff --git a/src/positioning/qgeorectangle.cpp b/src/positioning/qgeorectangle.cpp
deleted file mode 100644
index b92ca17c..00000000
--- a/src/positioning/qgeorectangle.cpp
+++ /dev/null
@@ -1,1031 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeorectangle.h"
-#include "qgeorectangle_p.h"
-
-#include "qwebmercator_p.h"
-#include "qdoublevector2d_p.h"
-#include "qgeocoordinate.h"
-#include "qnumeric.h"
-#include "qlocationutils_p.h"
-#include <QList>
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoRectangle
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QGeoRectangle class defines a rectangular geographic area.
-
- The rectangle is defined in terms of a QGeoCoordinate which specifies the
- top left coordinate of the rectangle and a QGeoCoordinate which specifies
- the bottom right coordinate of the rectangle.
-
- A geo rectangle is considered invalid if the top left or bottom right
- coordinates are invalid or if the top left coordinate is south of the
- bottom right coordinate.
-
- Geo rectangles can never cross the poles.
-
- Several methods behave as though the geo rectangle is defined in terms of a
- center coordinate, the width of the geo rectangle in degrees and the height
- of the geo rectangle in degrees.
-
- If the height or center of a geo rectangle is adjusted such that it would
- cross one of the poles the height is modified such that the geo rectangle
- touches but does not cross the pole and that the center coordinate is still
- in the center of the geo rectangle.
-
- This class is a \l Q_GADGET since Qt 5.5. It can be
- \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.
-*/
-
-/*!
- \property QGeoRectangle::bottomLeft
- \brief This property holds the bottom left coorindate of this geo rectangle.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoRectangle::bottomRight
- \brief This property holds the bottom right coordinate of this geo rectangle.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoRectangle::topLeft
- \brief This property holds the top left coordinate of this geo rectangle.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoRectangle::topRight
- \brief This property holds the top right coordinate of this geo rectangle.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoRectangle::center
- \brief This property holds the center of this geo rectangle.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \sa QGeoShape::center
-
- \since 5.5
-*/
-
-/*!
- \property QGeoRectangle::width
- \brief This property holds the width of this geo rectangle in degrees.
-
- The property value is undefined if this geo rectangle is invalid.
-
- If the new width is less than 0.0 or if this geo rectangle is invalid, this
- function does nothing. To set up the values of an invalid
- geo rectangle based on the center, width, and height, you should use
- \l setCenter() first to make the geo rectangle valid.
-
- 360.0 is the width used only if the new width is equal or greater than 360.
- In such cases the leftmost longitude of the geo rectangle is set to -180.0
- degrees and the rightmost longitude of the geo rectangle is set to 180.0
- degrees.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoRectangle::height
- \brief This property holds the height of this geo rectangle in degrees.
-
- The property value is undefined if this geo rectangle is invalid.
-
- If the new height is less than 0.0 or if this geo rectangle is invalid,
- the property is not changed. To set up the values of an invalid
- geo rectangle based on the center, width, and height, you should use
- \l setCenter() first to make the geo rectangle valid.
-
- If the change in height would cause the geo rectangle to cross a pole,
- the height is adjusted such that the geo rectangle only touches the pole.
-
- This change is done such that the center coordinate is still at the
- center of the geo rectangle, which may result in a geo rectangle with
- a smaller height than expected.
-
- 180.0 is the height used only if the new height is greater or equal than 180.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-inline QGeoRectanglePrivate *QGeoRectangle::d_func()
-{
- return static_cast<QGeoRectanglePrivate *>(d_ptr.data());
-}
-
-inline const QGeoRectanglePrivate *QGeoRectangle::d_func() const
-{
- return static_cast<const QGeoRectanglePrivate *>(d_ptr.constData());
-}
-
-struct RectangleVariantConversions
-{
- RectangleVariantConversions()
- {
- QMetaType::registerConverter<QGeoRectangle, QGeoShape>();
- QMetaType::registerConverter<QGeoShape, QGeoRectangle>();
- }
-};
-
-
-Q_GLOBAL_STATIC(RectangleVariantConversions, initRectangleConversions)
-
-/*!
- Constructs a new, invalid geo rectangle.
-*/
-QGeoRectangle::QGeoRectangle()
-: QGeoShape(new QGeoRectanglePrivate)
-{
- initRectangleConversions();
-}
-
-/*!
- Constructs a new geo rectangle centered at \a center with a
- width in degrees of \a degreesWidth and a height in degrees of \a degreesHeight.
-
- If \a degreesHeight would take the geo rectangle beyond one of the poles,
- the height of the geo rectangle will be truncated such that the geo rectangle
- only extends up to the pole. The center of the geo rectangle will be
- unchanged, and the height will be adjusted such that the center point is at
- the center of the truncated geo rectangle.
-*/
-QGeoRectangle::QGeoRectangle(const QGeoCoordinate &center, double degreesWidth, double degreesHeight)
-{
- initRectangleConversions();
- d_ptr = new QGeoRectanglePrivate(center, center);
- setWidth(degreesWidth);
- setHeight(degreesHeight);
-}
-
-/*!
- Constructs a new geo rectangle with a top left coordinate \a topLeft and a bottom right
- coordinate \a bottomRight.
-*/
-QGeoRectangle::QGeoRectangle(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight)
-{
- initRectangleConversions();
- d_ptr = new QGeoRectanglePrivate(topLeft, bottomRight);
-}
-
-/*!
- Constructs a new geo rectangle, of minimum size, containing all of the \a coordinates.
-*/
-QGeoRectangle::QGeoRectangle(const QList<QGeoCoordinate> &coordinates)
-{
- initRectangleConversions();
- if (coordinates.isEmpty()) {
- d_ptr = new QGeoRectanglePrivate;
- } else {
- const QGeoCoordinate &startCoordinate = coordinates.first();
- d_ptr = new QGeoRectanglePrivate(startCoordinate, startCoordinate);
-
- foreach (const QGeoCoordinate &coordinate, coordinates) {
- d_func()->extendRectangle(coordinate);
- }
- }
-}
-
-/*!
- Constructs a geo rectangle from the contents of \a other.
-*/
-QGeoRectangle::QGeoRectangle(const QGeoRectangle &other)
-: QGeoShape(other)
-{
- initRectangleConversions();
-}
-
-/*!
- Constructs a geo rectangle from the contents of \a other.
-*/
-QGeoRectangle::QGeoRectangle(const QGeoShape &other)
-: QGeoShape(other)
-{
- initRectangleConversions();
- if (type() != QGeoShape::RectangleType)
- d_ptr = new QGeoRectanglePrivate;
-}
-
-/*!
- Destroys this geo rectangle.
-*/
-QGeoRectangle::~QGeoRectangle()
-{
-}
-
-/*!
- Assigns \a other to this geo rectangle and returns a reference to this geo rectangle.
-*/
-QGeoRectangle &QGeoRectangle::operator=(const QGeoRectangle &other)
-{
- QGeoShape::operator=(other);
- return *this;
-}
-
-bool QGeoRectanglePrivate::isValid() const
-{
- return topLeft.isValid() && bottomRight.isValid() &&
- topLeft.latitude() >= bottomRight.latitude();
-}
-
-bool QGeoRectanglePrivate::isEmpty() const
-{
- if (!isValid())
- return true;
-
- return topLeft.latitude() == bottomRight.latitude() ||
- topLeft.longitude() == bottomRight.longitude();
-}
-
-/*!
- Sets the top left coordinate of this geo rectangle to \a topLeft.
-*/
-void QGeoRectangle::setTopLeft(const QGeoCoordinate &topLeft)
-{
- Q_D(QGeoRectangle);
-
- d->topLeft = topLeft;
-}
-
-/*!
- Returns the top left coordinate of this geo rectangle.
-*/
-QGeoCoordinate QGeoRectangle::topLeft() const
-{
- Q_D(const QGeoRectangle);
-
- return d->topLeft;
-}
-
-/*!
- Sets the top right coordinate of this geo rectangle to \a topRight.
-*/
-void QGeoRectangle::setTopRight(const QGeoCoordinate &topRight)
-{
- Q_D(QGeoRectangle);
-
- d->topLeft.setLatitude(topRight.latitude());
- d->bottomRight.setLongitude(topRight.longitude());
-}
-
-/*!
- Returns the top right coordinate of this geo rectangle.
-*/
-QGeoCoordinate QGeoRectangle::topRight() const
-{
- // TODO remove?
- if (!isValid())
- return QGeoCoordinate();
-
- Q_D(const QGeoRectangle);
-
- return QGeoCoordinate(d->topLeft.latitude(), d->bottomRight.longitude());
-}
-
-/*!
- Sets the bottom left coordinate of this geo rectangle to \a bottomLeft.
-*/
-void QGeoRectangle::setBottomLeft(const QGeoCoordinate &bottomLeft)
-{
- Q_D(QGeoRectangle);
-
- d->bottomRight.setLatitude(bottomLeft.latitude());
- d->topLeft.setLongitude(bottomLeft.longitude());
-}
-
-/*!
- Returns the bottom left coordinate of this geo rectangle.
-*/
-QGeoCoordinate QGeoRectangle::bottomLeft() const
-{
- // TODO remove?
- if (!isValid())
- return QGeoCoordinate();
-
- Q_D(const QGeoRectangle);
-
- return QGeoCoordinate(d->bottomRight.latitude(), d->topLeft.longitude());
-}
-
-/*!
- Sets the bottom right coordinate of this geo rectangle to \a bottomRight.
-*/
-void QGeoRectangle::setBottomRight(const QGeoCoordinate &bottomRight)
-{
- Q_D(QGeoRectangle);
-
- d->bottomRight = bottomRight;
-}
-
-/*!
- Returns the bottom right coordinate of this geo rectangle.
-*/
-QGeoCoordinate QGeoRectangle::bottomRight() const
-{
- Q_D(const QGeoRectangle);
-
- return d->bottomRight;
-}
-
-/*!
- Sets the center of this geo rectangle to \a center.
-
- If this causes the geo rectangle to cross on of the poles the height of the
- geo rectangle will be truncated such that the geo rectangle only extends up
- to the pole. The center of the geo rectangle will be unchanged, and the
- height will be adjusted such that the center point is at the center of the
- truncated geo rectangle.
-
-*/
-void QGeoRectangle::setCenter(const QGeoCoordinate &center)
-{
- Q_D(QGeoRectangle);
-
- if (!isValid()) {
- d->topLeft = center;
- d->bottomRight = center;
- return;
- }
- double width = this->width();
- double height = this->height();
-
- double tlLat = center.latitude() + height / 2.0;
- double tlLon = center.longitude() - width / 2.0;
- double brLat = center.latitude() - height / 2.0;
- double brLon = center.longitude() + width / 2.0;
- tlLon = QLocationUtils::wrapLong(tlLon);
- brLon = QLocationUtils::wrapLong(brLon);
-
- if (tlLat > 90.0) {
- brLat = 2 * center.latitude() - 90.0;
- tlLat = 90.0;
- }
-
- if (tlLat < -90.0) {
- brLat = -90.0;
- tlLat = -90.0;
- }
-
- if (brLat > 90.0) {
- tlLat = 90.0;
- brLat = 90.0;
- }
-
- if (brLat < -90.0) {
- tlLat = 2 * center.latitude() + 90.0;
- brLat = -90.0;
- }
-
- if (width == 360.0) {
- tlLon = -180.0;
- brLon = 180.0;
- }
-
- d->topLeft = QGeoCoordinate(tlLat, tlLon);
- d->bottomRight = QGeoCoordinate(brLat, brLon);
-}
-
-/*!
- Returns the center of this geo rectangle. Equivalent to QGeoShape::center().
-*/
-QGeoCoordinate QGeoRectangle::center() const
-{
- Q_D(const QGeoRectangle);
-
- return d->center();
-}
-
-/*!
- Sets the width of this geo rectangle in degrees to \a degreesWidth.
-*/
-void QGeoRectangle::setWidth(double degreesWidth)
-{
- if (!isValid())
- return;
-
- if (degreesWidth < 0.0)
- return;
-
- Q_D(QGeoRectangle);
-
- if (degreesWidth >= 360.0) {
- d->topLeft.setLongitude(-180.0);
- d->bottomRight.setLongitude(180.0);
- return;
- }
-
- double tlLat = d->topLeft.latitude();
- double brLat = d->bottomRight.latitude();
-
- QGeoCoordinate c = center();
-
- double tlLon = c.longitude() - degreesWidth / 2.0;
- tlLon = QLocationUtils::wrapLong(tlLon);
-
- double brLon = c.longitude() + degreesWidth / 2.0;
- brLon = QLocationUtils::wrapLong(brLon);
-
- d->topLeft = QGeoCoordinate(tlLat, tlLon);
- d->bottomRight = QGeoCoordinate(brLat, brLon);
-}
-
-/*!
- Returns the width of this geo rectangle in degrees.
-
- The return value is undefined if this geo rectangle is invalid.
-*/
-double QGeoRectangle::width() const
-{
- if (!isValid())
- return qQNaN();
-
- Q_D(const QGeoRectangle);
-
- double result = d->bottomRight.longitude() - d->topLeft.longitude();
- if (result < 0.0)
- result += 360.0;
- if (result > 360.0)
- result -= 360.0;
-
- return result;
-}
-
-/*!
- Sets the height of this geo rectangle in degrees to \a degreesHeight.
-*/
-void QGeoRectangle::setHeight(double degreesHeight)
-{
- if (!isValid())
- return;
-
- if (degreesHeight < 0.0)
- return;
-
- if (degreesHeight >= 180.0) {
- degreesHeight = 180.0;
- }
-
- Q_D(QGeoRectangle);
-
- double tlLon = d->topLeft.longitude();
- double brLon = d->bottomRight.longitude();
-
- QGeoCoordinate c = center();
-
- double tlLat = c.latitude() + degreesHeight / 2.0;
- double brLat = c.latitude() - degreesHeight / 2.0;
-
- if (tlLat > 90.0) {
- brLat = 2* c.latitude() - 90.0;
- tlLat = 90.0;
- }
-
- if (tlLat < -90.0) {
- brLat = -90.0;
- tlLat = -90.0;
- }
-
- if (brLat > 90.0) {
- tlLat = 90.0;
- brLat = 90.0;
- }
-
- if (brLat < -90.0) {
- tlLat = 2 * c.latitude() + 90.0;
- brLat = -90.0;
- }
-
- d->topLeft = QGeoCoordinate(tlLat, tlLon);
- d->bottomRight = QGeoCoordinate(brLat, brLon);
-}
-
-/*!
- Returns the height of this geo rectangle in degrees.
-
- The return value is undefined if this geo rectangle is invalid.
-*/
-double QGeoRectangle::height() const
-{
- if (!isValid())
- return qQNaN();
-
- Q_D(const QGeoRectangle);
-
- return d->topLeft.latitude() - d->bottomRight.latitude();
-}
-
-bool QGeoRectanglePrivate::contains(const QGeoCoordinate &coordinate) const
-{
- if (!isValid() || !coordinate.isValid())
- return false;
-
- double left = topLeft.longitude();
- double right = bottomRight.longitude();
- double top = topLeft.latitude();
- double bottom = bottomRight.latitude();
-
- double lon = coordinate.longitude();
- double lat = coordinate.latitude();
-
- if (lat > top)
- return false;
- if (lat < bottom)
- return false;
-
- if ((lat == 90.0) && (top == 90.0))
- return true;
-
- if ((lat == -90.0) && (bottom == -90.0))
- return true;
-
- if (left <= right) {
- if ((lon < left) || (lon > right))
- return false;
- } else {
- if ((lon < left) && (lon > right))
- return false;
- }
-
- return true;
-}
-
-QGeoCoordinate QGeoRectanglePrivate::center() const
-{
- if (!isValid())
- return QGeoCoordinate();
-
- double cLat = (topLeft.latitude() + bottomRight.latitude()) / 2.0;
- double cLon = (bottomRight.longitude() + topLeft.longitude()) / 2.0;
-
- if (topLeft.longitude() > bottomRight.longitude())
- cLon = cLon - 180.0;
-
- cLon = QLocationUtils::wrapLong(cLon);
- return QGeoCoordinate(cLat, cLon);
-}
-
-QGeoRectangle QGeoRectanglePrivate::boundingGeoRectangle() const
-{
- return QGeoRectangle(topLeft, bottomRight);
-}
-
-/*!
- Returns whether the geo rectangle \a rectangle is contained within this
- geo rectangle.
-*/
-bool QGeoRectangle::contains(const QGeoRectangle &rectangle) const
-{
- Q_D(const QGeoRectangle);
-
- return (d->contains(rectangle.topLeft())
- && d->contains(rectangle.topRight())
- && d->contains(rectangle.bottomLeft())
- && d->contains(rectangle.bottomRight()));
-}
-
-/*!
- Returns whether the geo rectangle \a rectangle intersects this geo rectangle.
-
- If the top or bottom edges of both geo rectangles are at one of the poles
- the geo rectangles are considered to be intersecting, since the longitude
- is irrelevant when the edges are at the pole.
-*/
-bool QGeoRectangle::intersects(const QGeoRectangle &rectangle) const
-{
- Q_D(const QGeoRectangle);
-
- double left1 = d->topLeft.longitude();
- double right1 = d->bottomRight.longitude();
- double top1 = d->topLeft.latitude();
- double bottom1 = d->bottomRight.latitude();
-
- double left2 = rectangle.d_func()->topLeft.longitude();
- double right2 = rectangle.d_func()->bottomRight.longitude();
- double top2 = rectangle.d_func()->topLeft.latitude();
- double bottom2 = rectangle.d_func()->bottomRight.latitude();
-
- if (top1 < bottom2)
- return false;
-
- if (bottom1 > top2)
- return false;
-
- if ((top1 == 90.0) && (top1 == top2))
- return true;
-
- if ((bottom1 == -90.0) && (bottom1 == bottom2))
- return true;
-
- if (left1 < right1) {
- if (left2 < right2) {
- if ((left1 > right2) || (right1 < left2))
- return false;
- } else {
- if ((left1 > right2) && (right1 < left2))
- return false;
- }
- } else {
- if (left2 < right2) {
- if ((left2 > right1) && (right2 < left1))
- return false;
- } else {
- // if both wrap then they have to intersect
- }
- }
-
- return true;
-}
-
-/*!
- Translates this geo rectangle by \a degreesLatitude northwards and \a
- degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-
- If the translation would have caused the geo rectangle to cross a pole the
- geo rectangle will be translated until the top or bottom edge of the geo rectangle
- touches the pole but not further.
-*/
-void QGeoRectangle::translate(double degreesLatitude, double degreesLongitude)
-{
- // TODO handle dlat, dlon larger than 360 degrees
-
- Q_D(QGeoRectangle);
-
- double tlLat = d->topLeft.latitude();
- double tlLon = d->topLeft.longitude();
- double brLat = d->bottomRight.latitude();
- double brLon = d->bottomRight.longitude();
-
- if (degreesLatitude >= 0.0)
- degreesLatitude = qMin(degreesLatitude, 90.0 - tlLat);
- else
- degreesLatitude = qMax(degreesLatitude, -90.0 - brLat);
-
- if ( (tlLon != -180.0) || (brLon != 180.0) ) {
- tlLon = QLocationUtils::wrapLong(tlLon + degreesLongitude);
- brLon = QLocationUtils::wrapLong(brLon + degreesLongitude);
- }
-
- tlLat += degreesLatitude;
- brLat += degreesLatitude;
-
- d->topLeft = QGeoCoordinate(tlLat, tlLon);
- d->bottomRight = QGeoCoordinate(brLat, brLon);
-}
-
-/*!
- Returns a copy of this geo rectangle translated by \a degreesLatitude northwards and \a
- degreesLongitude eastwards.
-
- Negative values of \a degreesLatitude and \a degreesLongitude correspond to
- southward and westward translation respectively.
-
- \sa translate()
-*/
-QGeoRectangle QGeoRectangle::translated(double degreesLatitude, double degreesLongitude) const
-{
- QGeoRectangle result(*this);
- result.translate(degreesLatitude, degreesLongitude);
- return result;
-}
-
-/*!
- Extends the geo rectangle to also cover the coordinate \a coordinate
-
- \since 5.9
-*/
-void QGeoRectangle::extendRectangle(const QGeoCoordinate &coordinate)
-{
- Q_D(QGeoRectangle);
- d->extendRectangle(coordinate);
-}
-
-/*!
- Returns the smallest geo rectangle which contains both this geo rectangle and \a rectangle.
-
- If the centers of the two geo rectangles are separated by exactly 180.0 degrees then the
- width is set to 360.0 degrees with the leftmost longitude set to -180.0 degrees and the
- rightmost longitude set to 180.0 degrees. This is done to ensure that the result is
- independent of the order of the operands.
-
-*/
-QGeoRectangle QGeoRectangle::united(const QGeoRectangle &rectangle) const
-{
- QGeoRectangle result(*this);
- if (rectangle.isValid())
- result |= rectangle;
- return result;
-}
-
-/*!
- Extends the rectangle in the smallest possible way to include \a coordinate in
- the shape.
-
- Both the rectangle and coordinate needs to be valid. If the rectangle already covers
- the coordinate noting happens.
-
-*/
-void QGeoRectanglePrivate::extendRectangle(const QGeoCoordinate &coordinate)
-{
- if (!isValid() || !coordinate.isValid() || contains(coordinate))
- return;
-
- double left = topLeft.longitude();
- double right = bottomRight.longitude();
- double top = topLeft.latitude();
- double bottom = bottomRight.latitude();
-
- double inputLat = coordinate.latitude();
- double inputLon = coordinate.longitude();
-
- top = qMax(top, inputLat);
- bottom = qMin(bottom, inputLat);
-
- bool wrap = left > right;
-
- if (wrap && inputLon > right && inputLon < left) {
- if (qAbs(left - inputLon) < qAbs(right - inputLon))
- left = inputLon;
- else
- right = inputLon;
- } else if (!wrap) {
- if (inputLon < left) {
- if (360 - (right - inputLon) < left - inputLon)
- right = inputLon;
- else
- left = inputLon;
- } else if (inputLon > right) {
- if (360 - (inputLon - left) < inputLon - right)
- left = inputLon;
- else
- right = inputLon;
- }
- }
- topLeft = QGeoCoordinate(top, left);
- bottomRight = QGeoCoordinate(bottom, right);
-}
-
-/*!
- \fn QGeoRectangle QGeoRectangle::operator|(const QGeoRectangle &rectangle) const
-
- Returns the smallest geo rectangle which contains both this geo rectangle and \a rectangle.
-
- If the centers of the two geo rectangles are separated by exactly 180.0 degrees then the
- width is set to 360.0 degrees with the leftmost longitude set to -180.0 degrees and the
- rightmost longitude set to 180.0 degrees. This is done to ensure that the result is
- independent of the order of the operands.
-
-*/
-
-/*!
- Returns the smallest geo rectangle which contains both this geo rectangle and \a rectangle.
-
- If the centers of the two geo rectangles are separated by exactly 180.0 degrees then the
- width is set to 360.0 degrees with the leftmost longitude set to -180.0 degrees and the
- rightmost longitude set to 180.0 degrees. This is done to ensure that the result is
- independent of the order of the operands.
-
-*/
-QGeoRectangle &QGeoRectangle::operator|=(const QGeoRectangle &rectangle)
-{
- // If non-intersecting goes for most narrow box
-
- Q_D(QGeoRectangle);
-
- double left1 = d->topLeft.longitude();
- double right1 = d->bottomRight.longitude();
- double top1 = d->topLeft.latitude();
- double bottom1 = d->bottomRight.latitude();
-
- double left2 = rectangle.d_func()->topLeft.longitude();
- double right2 = rectangle.d_func()->bottomRight.longitude();
- double top2 = rectangle.d_func()->topLeft.latitude();
- double bottom2 = rectangle.d_func()->bottomRight.latitude();
-
- double top = qMax(top1, top2);
- double bottom = qMin(bottom1, bottom2);
-
- double left = 0.0;
- double right = 0.0;
-
- bool wrap1 = (left1 > right1);
- bool wrap2 = (left2 > right2);
-
- if ((wrap1 && wrap2) || (!wrap1 && !wrap2)) {
-
- double w = qAbs((left1 + right1 - left2 - right2) / 2.0);
-
- if (w < 180.0) {
- left = qMin(left1, left2);
- right = qMax(right1, right2);
- } else if (w > 180.0) {
- left = qMax(left1, left2);
- right = qMin(right1, right2);
- } else {
- left = -180.0;
- right = 180.0;
- }
-
- } else {
- double wrapLeft = 0.0;
- double wrapRight = 0.0;
- double nonWrapLeft = 0.0;
- double nonWrapRight = 0.0;
-
- if (wrap1) {
- wrapLeft = left1;
- wrapRight = right1;
- nonWrapLeft = left2;
- nonWrapRight = right2;
- } else {
- wrapLeft = left2;
- wrapRight = right2;
- nonWrapLeft = left1;
- nonWrapRight = right1;
- }
-
- bool joinWrapLeft = (nonWrapRight >= wrapLeft);
- bool joinWrapRight = (nonWrapLeft <= wrapRight);
-
- if (wrapLeft <= nonWrapLeft) { // The wrapping rectangle contains the non-wrapping one entirely
- left = wrapLeft;
- right = wrapRight;
- } else {
- if (joinWrapLeft) {
- if (joinWrapRight) {
- left = -180.0;
- right = 180.0;
- } else {
- left = nonWrapLeft;
- right = wrapRight;
- }
- } else {
- if (joinWrapRight) {
- left = wrapLeft;
- right = nonWrapRight;
- } else {
- double wrapRightDistance = nonWrapLeft - wrapRight;
- double wrapLeftDistance = wrapLeft - nonWrapRight;
-
- if (wrapLeftDistance == wrapRightDistance) {
- left = -180.0;
- right = 180.0;
- } else if (wrapLeftDistance < wrapRightDistance) {
- left = nonWrapLeft;
- right = wrapRight;
- } else {
- left = wrapLeft;
- right = nonWrapRight;
- }
- }
- }
- }
- }
-
- if (((left1 == -180) && (right1 == 180.0))
- || ((left2 == -180) && (right2 == 180.0))) {
- left = -180;
- right = 180;
- }
-
- d->topLeft = QGeoCoordinate(top, left);
- d->bottomRight = QGeoCoordinate(bottom, right);
-
- return *this;
-}
-
-/*!
- Returns the geo rectangle properties as a string.
-
- \since 5.5
-*/
-QString QGeoRectangle::toString() const
-{
- if (type() != QGeoShape::RectangleType) {
- qWarning("Not a rectangle a %d\n", type());
- return QStringLiteral("QGeoRectangle(not a rectangle)");
- }
-
- return QStringLiteral("QGeoRectangle({%1, %2}, {%3, %4})")
- .arg(topLeft().latitude())
- .arg(topLeft().longitude())
- .arg(bottomRight().latitude())
- .arg(bottomRight().longitude());
-}
-
-/*******************************************************************************
-*******************************************************************************/
-
-QGeoRectanglePrivate::QGeoRectanglePrivate()
-: QGeoShapePrivate(QGeoShape::RectangleType)
-{
-}
-
-QGeoRectanglePrivate::QGeoRectanglePrivate(const QGeoCoordinate &topLeft,
- const QGeoCoordinate &bottomRight)
-: QGeoShapePrivate(QGeoShape::RectangleType), topLeft(topLeft), bottomRight(bottomRight)
-{
-}
-
-QGeoRectanglePrivate::QGeoRectanglePrivate(const QGeoRectanglePrivate &other)
-: QGeoShapePrivate(QGeoShape::RectangleType), topLeft(other.topLeft),
- bottomRight(other.bottomRight)
-{
-}
-
-QGeoRectanglePrivate::~QGeoRectanglePrivate() {}
-
-QGeoShapePrivate *QGeoRectanglePrivate::clone() const
-{
- return new QGeoRectanglePrivate(*this);
-}
-
-bool QGeoRectanglePrivate::operator==(const QGeoShapePrivate &other) const
-{
- if (!QGeoShapePrivate::operator==(other))
- return false;
-
- const QGeoRectanglePrivate &otherBox = static_cast<const QGeoRectanglePrivate &>(other);
-
- return topLeft == otherBox.topLeft && bottomRight == otherBox.bottomRight;
-}
-
-size_t QGeoRectanglePrivate::hash(size_t seed) const
-{
- return qHashMulti(seed, topLeft, bottomRight);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/positioning/qgeorectangle.h b/src/positioning/qgeorectangle.h
deleted file mode 100644
index e900ccd4..00000000
--- a/src/positioning/qgeorectangle.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEORECTANGLE_H
-#define QGEORECTANGLE_H
-
-#include <QtPositioning/QGeoShape>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoRectanglePrivate;
-
-class Q_POSITIONING_EXPORT QGeoRectangle : public QGeoShape
-{
- Q_GADGET
- Q_PROPERTY(QGeoCoordinate bottomLeft READ bottomLeft WRITE setBottomLeft)
- Q_PROPERTY(QGeoCoordinate bottomRight READ bottomRight WRITE setBottomRight)
- Q_PROPERTY(QGeoCoordinate topLeft READ topLeft WRITE setTopLeft)
- Q_PROPERTY(QGeoCoordinate topRight READ topRight WRITE setTopRight)
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
- Q_PROPERTY(double height READ height WRITE setHeight)
- Q_PROPERTY(double width READ width WRITE setWidth)
-
-public:
- QGeoRectangle();
- QGeoRectangle(const QGeoCoordinate &center, double degreesWidth, double degreesHeight);
- QGeoRectangle(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
- QGeoRectangle(const QList<QGeoCoordinate> &coordinates);
- QGeoRectangle(const QGeoRectangle &other);
- QGeoRectangle(const QGeoShape &other);
-
- ~QGeoRectangle();
-
- QGeoRectangle &operator=(const QGeoRectangle &other);
-
- void setTopLeft(const QGeoCoordinate &topLeft);
- QGeoCoordinate topLeft() const;
-
- void setTopRight(const QGeoCoordinate &topRight);
- QGeoCoordinate topRight() const;
-
- void setBottomLeft(const QGeoCoordinate &bottomLeft);
- QGeoCoordinate bottomLeft() const;
-
- void setBottomRight(const QGeoCoordinate &bottomRight);
- QGeoCoordinate bottomRight() const;
-
- void setCenter(const QGeoCoordinate &center);
- QGeoCoordinate center() const;
-
- void setWidth(double degreesWidth);
- double width() const;
-
- void setHeight(double degreesHeight);
- double height() const;
-
- using QGeoShape::contains;
- bool contains(const QGeoRectangle &rectangle) const;
- Q_INVOKABLE bool intersects(const QGeoRectangle &rectangle) const;
-
- Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude);
- Q_INVOKABLE QGeoRectangle translated(double degreesLatitude, double degreesLongitude) const;
- Q_INVOKABLE void extendRectangle(const QGeoCoordinate &coordinate);
-
- Q_INVOKABLE QGeoRectangle united(const QGeoRectangle &rectangle) const;
- QGeoRectangle operator|(const QGeoRectangle &rectangle) const;
- QGeoRectangle &operator|=(const QGeoRectangle &rectangle);
-
- Q_INVOKABLE QString toString() const;
-
-private:
- inline QGeoRectanglePrivate *d_func();
- inline const QGeoRectanglePrivate *d_func() const;
-};
-
-Q_DECLARE_TYPEINFO(QGeoRectangle, Q_RELOCATABLE_TYPE);
-
-inline QGeoRectangle QGeoRectangle::operator|(const QGeoRectangle &rectangle) const
-{
- return united(rectangle);
-}
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoRectangle)
-
-#endif
diff --git a/src/positioning/qgeorectangle_p.h b/src/positioning/qgeorectangle_p.h
deleted file mode 100644
index 79a267f5..00000000
--- a/src/positioning/qgeorectangle_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEORECTANGLE_P_H
-#define QGEORECTANGLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgeoshape_p.h"
-#include "qgeocoordinate.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoRectanglePrivate : public QGeoShapePrivate
-{
-public:
- QGeoRectanglePrivate();
- QGeoRectanglePrivate(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
- QGeoRectanglePrivate(const QGeoRectanglePrivate &other);
- ~QGeoRectanglePrivate();
-
- bool isValid() const override;
- bool isEmpty() const override;
- bool contains(const QGeoCoordinate &coordinate) const override;
-
- QGeoCoordinate center() const override;
-
- QGeoRectangle boundingGeoRectangle() const override;
-
- void extendRectangle(const QGeoCoordinate &coordinate);
-
- QGeoShapePrivate *clone() const override;
-
- bool operator==(const QGeoShapePrivate &other) const override;
-
- size_t hash(size_t seed) const override;
-
- QGeoCoordinate topLeft;
- QGeoCoordinate bottomRight;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeosatelliteinfo.cpp b/src/positioning/qgeosatelliteinfo.cpp
deleted file mode 100644
index f9f242fe..00000000
--- a/src/positioning/qgeosatelliteinfo.cpp
+++ /dev/null
@@ -1,435 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qgeosatelliteinfo.h"
-#include "private/qgeosatelliteinfo_p.h"
-
-#include <QHash>
-#include <QDebug>
-#include <QDataStream>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoSatelliteInfo
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \ingroup shared
- \since 5.2
-
- \brief The QGeoSatelliteInfo class contains basic information about a satellite.
-
- \sa QGeoSatelliteInfoSource
-*/
-
-/*!
- \enum QGeoSatelliteInfo::Attribute
- Defines the attributes for the satellite information.
- \value Elevation The elevation of the satellite, in degrees.
- \value Azimuth The azimuth to true north, in degrees.
-*/
-
-/*!
- \enum QGeoSatelliteInfo::SatelliteSystem
- Defines the GNSS system of the satellite.
- \value Undefined Not defined.
- \value GPS Global Positioning System (USA).
- \value GLONASS Global Positioning System (Russia).
- \value GALILEO Global navigation satellite system (EU).
- \value BEIDOU BeiDou navigation satellite system (China).
- \value QZSS Quasi-Zenith Satellite System (Japan).
- \value Multiple This type normally indicates that the information is
- received from a device that supports multiple satellite systems, and
- the satellite system is not explicitly specified. Depending on the
- data source, you might use other information to determine the actual
- system type. One example of the usage of this type is an NMEA $GNGSA
- message, which contains the IDs of the satellites being used, but
- does not explicitly mention their system types.
- \value CustomType The first type that can be used for user purposes. For
- example when reimplementing NMEA data parsing in
- \l QNmeaSatelliteInfoSource. User can add more types using
- \c {CustomType + 1}, \c {CustomType + 2} and so on.
-*/
-
-/*!
- Creates a satellite information object.
-*/
-QGeoSatelliteInfo::QGeoSatelliteInfo()
- : d(new QGeoSatelliteInfoPrivate)
-{
- d->signal = -1;
- d->satId = -1;
- d->system = QGeoSatelliteInfo::Undefined;
-}
-
-/*!
- Creates a satellite information object with the values of \a other.
-*/
-
-QGeoSatelliteInfo::QGeoSatelliteInfo(const QGeoSatelliteInfo &other)
- : d(other.d)
-{
-}
-
-QGeoSatelliteInfo::QGeoSatelliteInfo(QGeoSatelliteInfoPrivate &dd) : d(&dd)
-{
-}
-
-/*!
- \fn QGeoSatelliteInfo::QGeoSatelliteInfo(QGeoSatelliteInfo &&other) noexcept
- \since 6.2
-
- Creates a satellite information object by moving from \a other.
-
- Note that a moved-from QGeoSatelliteInfo can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- Destroys a satellite information object.
-*/
-QGeoSatelliteInfo::~QGeoSatelliteInfo()
-{
-}
-
-QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QGeoSatelliteInfoPrivate)
-
-/*!
- Assigns the values from \a other to this object.
-*/
-QGeoSatelliteInfo &QGeoSatelliteInfo::operator=(const QGeoSatelliteInfo & other)
-{
- if (this == &other)
- return *this;
-
- d = other.d;
- return *this;
-}
-
-/*!
- \fn QGeoSatelliteInfo &QGeoSatelliteInfo::operator=(QGeoSatelliteInfo &&other) noexcept
- \since 6.2
-
- Move-assigns the value from \a other to this object
-
- Note that a moved-from QGeoSatelliteInfo can only be destroyed or
- assigned to. The effect of calling other functions than the destructor
- or one of the assignment operators is undefined.
-*/
-
-/*!
- \fn bool QGeoSatelliteInfo::operator==(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs)
-
- Returns \c true if all the parameters of the \a lhs satellite are the same
- as those of \a rhs. Otherwise returns \c false.
-*/
-
-/*!
- \fn bool QGeoSatelliteInfo::operator!=(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs)
-
- Returns \c true if any of the parameters of the \a lhs satellite are not
- the same as those of \a rhs. Otherwise returns \c false.
-*/
-
-/*!
- Sets the Satellite System (GPS, GLONASS, ...) to \a system.
-*/
-void QGeoSatelliteInfo::setSatelliteSystem(SatelliteSystem system)
-{
- d.detach();
- d->system = system;
-}
-
-/*!
- Returns the Satellite System (GPS, GLONASS, ...)
-
- \note This value can be used together with \l satelliteIdentifier()
- to uniquely identify a satellite.
-
- \sa satelliteIdentifier()
-*/
-QGeoSatelliteInfo::SatelliteSystem QGeoSatelliteInfo::satelliteSystem() const
-{
- return d->system;
-}
-
-/*!
- Sets the satellite identifier number to \a satId.
-
- The satellite identifier number can be used to identify a satellite within
- the satellite system.
-
- The actual value may vary, depending on the platform and the selected
- backend.
-
- For example, if \e nmea plugin is used, the satellite identifier for GPS
- satellite system represents the PRN (Pseudo-random noise) number, and the
- satellite identifier for GLONASS satellite system represents the slot
- number.
-*/
-void QGeoSatelliteInfo::setSatelliteIdentifier(int satId)
-{
- d.detach();
- d->satId = satId;
-}
-
-/*!
- Returns the satellite identifier number.
-
- The satellite identifier number can be used to identify a satellite within
- the satellite system.
-
- The actual value may vary, depending on the platform and the selected
- backend.
-
- For example, if \e nmea plugin is used, the satellite identifier for GPS
- satellite system represents the PRN (Pseudo-random noise) number, and the
- satellite identifier for GLONASS satellite system represents the slot
- number.
-
- For NMEA-based backends the satellite identifier can be used to determine
- the satellite system type if it is not available from other sources.
- You can refer to \l {https://gpsd.gitlab.io/gpsd/NMEA.html#_satellite_ids}
- {satellite IDs list} to check the ID ranges for different satellite systems.
-
- \note Depending on the platform and the selected backend, the satellite
- identifier ranges for different satellite systems may intersect. To uniquely
- identify a satellite, a combination of satelliteIndetifier() and
- \l satelliteSystem() must be used.
-
- \sa satelliteSystem()
-*/
-int QGeoSatelliteInfo::satelliteIdentifier() const
-{
- return d->satId;
-}
-
-/*!
- Sets the signal strength to \a signalStrength, in decibels.
-*/
-void QGeoSatelliteInfo::setSignalStrength(int signalStrength)
-{
- d.detach();
- d->signal = signalStrength;
-}
-
-/*!
- Returns the signal strength, or -1 if the value has not been set.
-*/
-int QGeoSatelliteInfo::signalStrength() const
-{
- return d->signal;
-}
-
-/*!
- Sets the value for \a attribute to \a value.
-*/
-void QGeoSatelliteInfo::setAttribute(Attribute attribute, qreal value)
-{
- d.detach();
- d->doubleAttribs[int(attribute)] = value;
-}
-
-/*!
- Returns the value of the specified \a attribute as a qreal value.
-
- Returns -1 if the value has not been set.
-
- \sa hasAttribute(), setAttribute()
-*/
-qreal QGeoSatelliteInfo::attribute(Attribute attribute) const
-{
- if (d->doubleAttribs.contains(int(attribute)))
- return d->doubleAttribs[int(attribute)];
- return -1;
-}
-
-/*!
- Removes the specified \a attribute and its value.
-*/
-void QGeoSatelliteInfo::removeAttribute(Attribute attribute)
-{
- d.detach();
- d->doubleAttribs.remove(int(attribute));
-}
-
-/*!
- Returns true if the specified \a attribute is present in this update.
-*/
-bool QGeoSatelliteInfo::hasAttribute(Attribute attribute) const
-{
- return d->doubleAttribs.contains(int(attribute));
-}
-
-/*!
- \internal
-*/
-void QGeoSatelliteInfo::detach()
-{
- if (d)
- d.detach();
- else
- d = new QGeoSatelliteInfoPrivate;
-}
-
-bool QGeoSatelliteInfo::equals(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs)
-{
- return *lhs.d == *rhs.d;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug QGeoSatelliteInfo::debugStreaming(QDebug dbg, const QGeoSatelliteInfo &info)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "QGeoSatelliteInfo(system=" << info.d->system;
- dbg << ", satId=" << info.d->satId;
- dbg << ", signal-strength=" << info.d->signal;
-
-
- QList<int> attribs = info.d->doubleAttribs.keys();
- for (int i = 0; i < attribs.count(); ++i) {
- dbg << ", ";
- switch (attribs[i]) {
- case QGeoSatelliteInfo::Elevation:
- dbg << "Elevation=";
- break;
- case QGeoSatelliteInfo::Azimuth:
- dbg << "Azimuth=";
- break;
- }
- dbg << info.d->doubleAttribs[attribs[i]];
- }
- dbg << ')';
- return dbg;
-}
-#endif // QT_NO_DEBUG_STREAM
-
-#ifndef QT_NO_DATASTREAM
-/*!
- \fn QDataStream &QGeoSatelliteInfo::operator<<(QDataStream &stream, const QGeoSatelliteInfo &info)
-
- Writes the given \a info to the specified \a stream.
-
- \sa {Serializing Qt Data Types}
-
-*/
-
-QDataStream &QGeoSatelliteInfo::dataStreamOut(QDataStream &stream, const QGeoSatelliteInfo &info)
-{
- stream << info.d->signal;
- stream << info.d->doubleAttribs;
- stream << info.d->satId;
- stream << int(info.d->system);
- return stream;
-}
-#endif // QT_NO_DATASTREAM
-
-#ifndef QT_NO_DATASTREAM
-/*!
- \fn QDataStream &QGeoSatelliteInfo::operator>>(QDataStream &stream, QGeoSatelliteInfo &info)
-
- Reads satellite information from the specified \a stream into the given
- \a info.
-
- \sa {Serializing Qt Data Types}
-*/
-
-QDataStream &QGeoSatelliteInfo::dataStreamIn(QDataStream &stream, QGeoSatelliteInfo &info)
-{
- int system;
- stream >> info.d->signal;
- stream >> info.d->doubleAttribs;
- stream >> info.d->satId;
- stream >> system;
- info.d->system = (QGeoSatelliteInfo::SatelliteSystem)system;
- return stream;
-}
-#endif // QT_NO_DATASTREAM
-
-QGeoSatelliteInfoPrivate::QGeoSatelliteInfoPrivate() : QSharedData()
-{
-
-}
-
-QGeoSatelliteInfoPrivate::QGeoSatelliteInfoPrivate(const QGeoSatelliteInfoPrivate &other)
- : QSharedData(other)
-{
- signal = other.signal;
- satId = other.satId;
- system = other.system;
- doubleAttribs = other.doubleAttribs;
-}
-
-QGeoSatelliteInfoPrivate::~QGeoSatelliteInfoPrivate() {}
-
-bool QGeoSatelliteInfoPrivate::operator==(const QGeoSatelliteInfoPrivate &other) const
-{
- return signal == other.signal
- && satId == other.satId
- && system == other.system
- && doubleAttribs == other.doubleAttribs;
-}
-
-QGeoSatelliteInfoPrivate *QGeoSatelliteInfoPrivate::get(const QGeoSatelliteInfo &info)
-{
- return info.d.data();
-}
-
-size_t qHash(const QGeoSatelliteInfo &key, size_t seed) noexcept
-{
- // Other properties and attributes might change
- return qHashMulti(seed, key.d->satId, key.d->system);
-}
-
-namespace QTest
-{
-
-char *toString(const QGeoSatelliteInfo &info)
-{
- QString result;
- QDebug dbg(&result);
- dbg << info;
-
- return qstrdup(qPrintable(result));
-}
-
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeosatelliteinfo.h b/src/positioning/qgeosatelliteinfo.h
deleted file mode 100644
index cb4c7b25..00000000
--- a/src/positioning/qgeosatelliteinfo.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QGEOSATELLITEINFO_H
-#define QGEOSATELLITEINFO_H
-
-#include <QtPositioning/qpositioningglobal.h>
-#include <QtCore/QSharedData>
-#include <QtCore/QMetaType>
-#include <QtCore/QDebug>
-
-QT_BEGIN_NAMESPACE
-
-class QDebug;
-class QDataStream;
-
-class QGeoSatelliteInfo;
-Q_POSITIONING_EXPORT size_t qHash(const QGeoSatelliteInfo &key, size_t seed = 0) noexcept;
-namespace QTest
-{
-
-Q_POSITIONING_EXPORT char *toString(const QGeoSatelliteInfo &info);
-
-} // namespace QTest
-
-class QGeoSatelliteInfoPrivate;
-QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QGeoSatelliteInfoPrivate, Q_POSITIONING_EXPORT)
-
-class Q_POSITIONING_EXPORT QGeoSatelliteInfo
-{
-public:
- enum Attribute {
- Elevation,
- Azimuth
- };
-
- enum SatelliteSystem {
- Undefined = 0x00,
- GPS = 0x01,
- GLONASS = 0x02,
- GALILEO = 0x03,
- BEIDOU = 0x04,
- QZSS = 0x05,
- Multiple = 0xFF,
- CustomType = 0x100
- };
-
- QGeoSatelliteInfo();
- QGeoSatelliteInfo(const QGeoSatelliteInfo &other);
- QGeoSatelliteInfo(QGeoSatelliteInfoPrivate &dd);
- QGeoSatelliteInfo(QGeoSatelliteInfo &&other) noexcept = default;
- ~QGeoSatelliteInfo();
-
- QGeoSatelliteInfo &operator=(const QGeoSatelliteInfo &other);
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QGeoSatelliteInfo)
-
- void swap(QGeoSatelliteInfo &other) noexcept { d.swap(other.d); }
-
- friend bool operator==(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs)
- {
- return equals(lhs, rhs);
- }
- friend bool operator!=(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs)
- {
- return !equals(lhs, rhs);
- }
-
- void setSatelliteSystem(SatelliteSystem system);
- SatelliteSystem satelliteSystem() const;
-
- void setSatelliteIdentifier(int satId);
- int satelliteIdentifier() const;
-
- void setSignalStrength(int signalStrength);
- int signalStrength() const;
-
- void setAttribute(Attribute attribute, qreal value);
- qreal attribute(Attribute attribute) const;
- void removeAttribute(Attribute attribute);
-
- bool hasAttribute(Attribute attribute) const;
-
- void detach();
-
-private:
- static bool equals(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs);
-#ifndef QT_NO_DEBUG_STREAM
- friend QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info)
- {
- return debugStreaming(dbg, info);
- }
- static QDebug debugStreaming(QDebug dbg, const QGeoSatelliteInfo &info);
-#endif
-#ifndef QT_NO_DATASTREAM
- friend QDataStream &operator<<(QDataStream &stream, const QGeoSatelliteInfo &info)
- {
- return dataStreamOut(stream, info);
- }
- friend QDataStream &operator>>(QDataStream &stream, QGeoSatelliteInfo &info)
- {
- return dataStreamIn(stream, info);
- }
- static QDataStream &dataStreamOut(QDataStream &stream, const QGeoSatelliteInfo &info);
- static QDataStream &dataStreamIn(QDataStream &stream, QGeoSatelliteInfo &info);
-#endif
- QExplicitlySharedDataPointer<QGeoSatelliteInfoPrivate> d;
- friend class QGeoSatelliteInfoPrivate;
-
- friend Q_POSITIONING_EXPORT size_t qHash(const QGeoSatelliteInfo &key, size_t seed) noexcept;
- friend Q_POSITIONING_EXPORT char *QTest::toString(const QGeoSatelliteInfo &info);
-};
-
-Q_DECLARE_SHARED(QGeoSatelliteInfo)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoSatelliteInfo)
-
-#endif
diff --git a/src/positioning/qgeosatelliteinfo_p.h b/src/positioning/qgeosatelliteinfo_p.h
deleted file mode 100644
index 98da1caa..00000000
--- a/src/positioning/qgeosatelliteinfo_p.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOSATELLITEINFO_P_H
-#define QGEOSATELLITEINFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include <QtPositioning/qgeosatelliteinfo.h>
-#include <QHash>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoSatelliteInfoPrivate : public QSharedData
-{
-public:
- QGeoSatelliteInfoPrivate();
- QGeoSatelliteInfoPrivate(const QGeoSatelliteInfoPrivate &other);
- virtual ~QGeoSatelliteInfoPrivate();
- bool operator==(const QGeoSatelliteInfoPrivate &other) const;
- static QGeoSatelliteInfoPrivate *get(const QGeoSatelliteInfo &info);
-
- int signal;
- int satId;
- QGeoSatelliteInfo::SatelliteSystem system;
- QHash<int, qreal> doubleAttribs;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOSATELLITEINFO_P_H
diff --git a/src/positioning/qgeosatelliteinfosource.cpp b/src/positioning/qgeosatelliteinfosource.cpp
deleted file mode 100644
index b109e839..00000000
--- a/src/positioning/qgeosatelliteinfosource.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qgeosatelliteinfosource.h>
-#include <qgeosatelliteinfosource_p.h>
-#include "qgeopositioninfosourcefactory.h"
-#include "qgeopositioninfosource_p.h"
-#include <QPluginLoader>
-#include <QStringList>
-#include <QCryptographicHash>
-#include <QtCore/private/qfactoryloader_p.h>
-#include <QFile>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGeoSatelliteInfoSource
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QGeoSatelliteInfoSource class is an abstract base class for the distribution of satellite information updates.
-
- The static function QGeoSatelliteInfoSource::createDefaultSource() creates a default
- satellite data source that is appropriate for the platform, if one is
- available. Otherwise, available QGeoPositionInfoSourceFactory plugins will
- be checked for one that has a satellite data source available.
-
- Call startUpdates() and stopUpdates() to start and stop regular updates,
- or requestUpdate() to request a single update.
- When an update is available, satellitesInViewUpdated() and/or
- satellitesInUseUpdated() will be emitted.
-
- If regular satellite updates are required, setUpdateInterval() can be used
- to specify how often these updates should be emitted. If no interval is
- specified, updates are simply provided whenever they are available.
- For example:
-
- \code
- // Emit updates every 10 seconds if available
- QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createDefaultSource(0);
- if (source)
- source->setUpdateInterval(10000);
- \endcode
-
- To remove an update interval that was previously set, call
- setUpdateInterval() with a value of 0.
-
- \note The satellite source may have a minimum value requirement for
- update intervals, as returned by minimumUpdateInterval().
-
- \note To use this class from Android service, see
- \l {Qt Positioning on Android}.
-*/
-
-/*!
- Creates a satellite source with the specified \a parent.
-*/
-
-QGeoSatelliteInfoSourcePrivate::~QGeoSatelliteInfoSourcePrivate()
-{
-
-}
-
-QGeoSatelliteInfoSource::QGeoSatelliteInfoSource(QObject *parent)
- : QObject(*new QGeoSatelliteInfoSourcePrivate, parent)
-{
-}
-
-QGeoSatelliteInfoSource::QGeoSatelliteInfoSource(QGeoSatelliteInfoSourcePrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-
-}
-
-/*!
- Destroys the satellite source.
-*/
-QGeoSatelliteInfoSource::~QGeoSatelliteInfoSource()
-{
-}
-
-/*!
- Returns the unique name of the satellite source implementation in use.
-
- This is the same name that can be passed to createSource() in order to
- create a new instance of a particular satellite source implementation.
-*/
-QString QGeoSatelliteInfoSource::sourceName() const
-{
- Q_D(const QGeoSatelliteInfoSource);
- return d->providerName;
-}
-
-
-/*!
- \property QGeoSatelliteInfoSource::updateInterval
- \brief This property holds the requested interval in milliseconds between each update.
-
- If the update interval is not set (or is set to 0) the
- source will provide updates as often as necessary.
-
- If the update interval is set, the source will provide updates at an
- interval as close to the requested interval as possible. If the requested
- interval is less than the minimumUpdateInterval(),
- the minimum interval is used instead.
-
- Changes to the update interval will happen as soon as is practical, however the
- time the change takes may vary between implementations. Whether or not the elapsed
- time from the previous interval is counted as part of the new interval is also
- implementation dependent.
-
- The default value for this property is 0.
-
- \note Subclass implementations must call the base implementation of
- setUpdateInterval() so that updateInterval() returns the correct value.
-*/
-void QGeoSatelliteInfoSource::setUpdateInterval(int msec)
-{
- Q_D(QGeoSatelliteInfoSource);
- d->interval = msec;
-}
-
-int QGeoSatelliteInfoSource::updateInterval() const
-{
- Q_D(const QGeoSatelliteInfoSource);
- return d->interval.value();
-}
-
-QBindable<int> QGeoSatelliteInfoSource::bindableUpdateInterval()
-{
- Q_D(QGeoSatelliteInfoSource);
- return QBindable<int>(&d->interval);
-}
-
-/*!
- \since 6.2
- Sets the backend-specific property named \a name to \a value.
- Returns \c true on success, \c false otherwise.
- Backend-specific properties can be used to configure the satellite info
- subsystem behavior at runtime.
-
- \sa backendProperty
-*/
-bool QGeoSatelliteInfoSource::setBackendProperty(const QString &name, const QVariant &value)
-{
- Q_UNUSED(name)
- Q_UNUSED(value)
- return false;
-}
-
-/*!
- \since 6.2
- Returns the value of the backend-specific property named \a name,
- if present. Otherwise the returned value will be invalid.
-
- \sa setBackendProperty
-*/
-QVariant QGeoSatelliteInfoSource::backendProperty(const QString &name) const
-{
- Q_UNUSED(name)
- return QVariant();
-}
-
-QGeoSatelliteInfoSource *QGeoSatelliteInfoSourcePrivate::createSourceReal(const QJsonObject &meta, const QVariantMap &parameters, QObject *parent)
-{
- QGeoSatelliteInfoSource *s = nullptr;
- auto factory = QGeoPositionInfoSourcePrivate::loadFactory(meta);
- if (factory)
- s = factory->satelliteInfoSource(parent, parameters);
- if (s)
- s->d_func()->providerName = meta.value(QStringLiteral("Provider")).toString();
-
- return s;
-}
-
-/*!
- Creates and returns a source with the specified \a parent that reads
- from the system's default source of satellite update information, or the
- highest priority available plugin.
-
- Returns \c nullptr if the system has no default satellite source, no valid
- plugins could be found or the user does not have the permission to access
- the satellite data.
-*/
-QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *parent)
-{
- return createDefaultSource(QVariantMap(), parent);
-}
-
-/*!
- Creates and returns a source with the given \a parent,
- by loading the plugin named \a sourceName.
-
- Returns \c nullptr if the plugin cannot be found.
-*/
-QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createSource(const QString &sourceName, QObject *parent)
-{
- return createSource(sourceName, QVariantMap(), parent);
-}
-
-/*!
- Creates and returns a satellite source with the given \a parent that
- reads from the system's default sources of satellite data, or the plugin
- with the highest available priority.
-
- Returns \c nullptr if the system has no default satellite source, no valid
- plugins could be found or the user does not have the permission to access
- the satellite information.
-
- This method passes \a parameters to the factory to configure the source.
-
- \since Qt 5.14
-*/
-QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(const QVariantMap &parameters, QObject *parent)
-{
- QList<QJsonObject> plugins = QGeoPositionInfoSourcePrivate::pluginsSorted();
- foreach (const QJsonObject &obj, plugins) {
- if (obj.value(QStringLiteral("Satellite")).isBool()
- && obj.value(QStringLiteral("Satellite")).toBool())
- {
- const QString testableKey = QStringLiteral("Testable");
- if (obj.contains(testableKey) && !obj.value(testableKey).toBool()) {
- static bool inTest = qEnvironmentVariableIsSet("QT_QTESTLIB_RUNNING");
- if (inTest)
- continue;
- }
- return QGeoSatelliteInfoSourcePrivate::createSourceReal(obj, parameters, parent);
- }
- }
-
- return nullptr;
-}
-
-/*!
- Creates and returns a satellite source with the given \a parent,
- by loading the plugin named \a sourceName.
-
- Returns \c nullptr if the plugin cannot be found.
-
- This method passes \a parameters to the factory to configure the source.
-
- \since Qt 5.14
-*/
-QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createSource(const QString &sourceName, const QVariantMap &parameters, QObject *parent)
-{
- auto plugins = QGeoPositionInfoSourcePrivate::plugins();
- if (plugins.contains(sourceName))
- return QGeoSatelliteInfoSourcePrivate::createSourceReal(plugins.value(sourceName), parameters, parent);
- return nullptr;
-}
-
-/*!
- Returns a list of available source plugins, including the default system
- backend if one is available.
-*/
-QStringList QGeoSatelliteInfoSource::availableSources()
-{
- QStringList plugins;
- const auto meta = QGeoPositionInfoSourcePrivate::plugins();
- for (auto it = meta.cbegin(), end = meta.cend(); it != end; ++it) {
- if (it.value().value(QStringLiteral("Satellite")).isBool()
- && it.value().value(QStringLiteral("Satellite")).toBool()) {
- plugins << it.key();
- }
- }
-
- return plugins;
-}
-
-/*!
- \fn void QGeoSatelliteInfoSource::satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
-
- If startUpdates() or requestUpdate() is called, this signal is emitted
- when an update is available on the satellites that are
- currently in view.
-
- The \a satellites parameter holds the satellites currently in view.
-*/
-
-/*!
- \fn void QGeoSatelliteInfoSource::satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
-
- If startUpdates() or requestUpdate() is called, this signal is emitted
- when an update is available on the number of satellites that are
- currently in use.
-
- These are the satellites that are used to get a "fix" - that
- is, those used to determine the current position.
-
- The \a satellites parameter holds the satellites currently in use.
-*/
-
-/*!
- \property QGeoSatelliteInfoSource::minimumUpdateInterval
- \brief This property holds the minimum time (in milliseconds) required to retrieve a satellite update.
-
- This is the minimum value accepted by setUpdateInterval() and
- requestUpdate().
-*/
-
-
-/*!
- \fn virtual void QGeoSatelliteInfoSource::startUpdates() = 0;
-
- Starts emitting updates at regular intervals. The updates will be
- provided whenever new satellite information becomes available.
-
- If satellite information cannot be retrieved or some other
- form of timeout has occurred the satellitesInViewUpdated()
- and satellitesInUseUpdated() signals may be emitted with
- empty parameter lists.
-
- \note Since Qt6 this method always resets the last error to
- \l {QGeoSatelliteInfoSource::}{NoError} before starting
- the updates.
-
- \note To understand how to use this method from an Android service, see
- \l {Qt Positioning on Android}.
-
- \sa satellitesInViewUpdated(), satellitesInUseUpdated()
-*/
-
-/*!
- \fn virtual void QGeoSatelliteInfoSource::stopUpdates() = 0;
-
- Stops emitting updates at regular intervals.
-*/
-
-/*!
- \fn virtual void QGeoSatelliteInfoSource::requestUpdate(int timeout = 0);
-
- Attempts to get the current satellite information and emit
- satellitesInViewUpdated() and satellitesInUseUpdated() with this
- information. If the current satellite information cannot be found
- within the given \a timeout (in milliseconds) or if \a timeout is less than
- the value returned by minimumUpdateInterval(), an errorOccurred() signal
- with \l {QGeoSatelliteInfoSource::UpdateTimeoutError}
- {UpdateTimeoutError} is emitted.
-
- If the timeout is zero, the timeout defaults to a reasonable timeout
- period as appropriate for the source.
-
- This does nothing if another update request is in progress. However
- it can be called even if startUpdates() has already been called and
- regular updates are in progress.
-
- \note Since Qt6 this method always resets the last error to
- \l {QGeoSatelliteInfoSource::}{NoError} before requesting
- the satellite information.
-
- \note To understand how to use this method from an Android service, see
- \l {Qt Positioning on Android}.
-*/
-
-/*!
- \fn QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSource::error() const = 0
-
- Returns the last error that occurred.
-
- \note Since Qt6 the last error is always reset when calling startUpdates()
- or requestUpdate().
-*/
-
-/*!
- \fn void QGeoSatelliteInfoSource::errorOccurred(QGeoSatelliteInfoSource::Error satelliteError)
-
- This signal is emitted after an error occurred. The \a satelliteError
- parameter describes the type of error that occurred.
-*/
-
-/*!
- \enum QGeoSatelliteInfoSource::Error
-
- The Error enumeration represents the errors which can occur.
-
- \value AccessError The connection setup to the satellite backend failed because the
- application lacked the required privileges.
- \value ClosedError The satellite backend closed the connection, which happens for example in case
- the user is switching location services to off. This object becomes invalid and should be deleted.
- A new satellite source can be created by calling createDefaultSource() later on.
- \value NoError No error has occurred.
- \value UnknownSourceError An unidentified error occurred.
- \value UpdateTimeoutError The current satellite information could not be
- retrieved within the specified timeout.
- */
-
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qgeosatelliteinfosource.h b/src/positioning/qgeosatelliteinfosource.h
deleted file mode 100644
index 9d6603bb..00000000
--- a/src/positioning/qgeosatelliteinfosource.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QGEOSATELLITEINFOSOURCE_H
-#define QGEOSATELLITEINFOSOURCE_H
-
-#include <QtPositioning/QGeoSatelliteInfo>
-
-#include <QtCore/QObject>
-#include <QtCore/QList>
-
-QT_BEGIN_NAMESPACE
-
-class QGeoSatelliteInfoSourcePrivate;
-class Q_POSITIONING_EXPORT QGeoSatelliteInfoSource : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval BINDABLE
- bindableUpdateInterval)
- Q_PROPERTY(int minimumUpdateInterval READ minimumUpdateInterval)
-
-public:
- enum Error {
- AccessError = 0,
- ClosedError = 1,
- NoError = 2,
- UnknownSourceError = -1,
- UpdateTimeoutError = 3,
- };
- Q_ENUM(Error)
-
- explicit QGeoSatelliteInfoSource(QObject *parent);
- virtual ~QGeoSatelliteInfoSource();
-
- static QGeoSatelliteInfoSource *createDefaultSource(QObject *parent);
- static QGeoSatelliteInfoSource *createSource(const QString &sourceName, QObject *parent);
- static QGeoSatelliteInfoSource *createDefaultSource(const QVariantMap &parameters, QObject *parent);
- static QGeoSatelliteInfoSource *createSource(const QString &sourceName, const QVariantMap &parameters, QObject *parent);
- static QStringList availableSources();
-
- QString sourceName() const;
-
- virtual void setUpdateInterval(int msec);
- int updateInterval() const;
- QBindable<int> bindableUpdateInterval();
-
- virtual int minimumUpdateInterval() const = 0;
- virtual Error error() const = 0;
-
- virtual bool setBackendProperty(const QString &name, const QVariant &value);
- virtual QVariant backendProperty(const QString &name) const;
-
-public Q_SLOTS:
- virtual void startUpdates() = 0;
- virtual void stopUpdates() = 0;
-
- virtual void requestUpdate(int timeout = 0) = 0;
-
-Q_SIGNALS:
- void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
- void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
- void errorOccurred(QGeoSatelliteInfoSource::Error);
-
-protected:
- explicit QGeoSatelliteInfoSource(QGeoSatelliteInfoSourcePrivate &dd, QObject *parent);
-
-private:
- Q_DISABLE_COPY(QGeoSatelliteInfoSource)
- Q_DECLARE_PRIVATE(QGeoSatelliteInfoSource)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qgeosatelliteinfosource_p.h b/src/positioning/qgeosatelliteinfosource_p.h
deleted file mode 100644
index 48eb6be1..00000000
--- a/src/positioning/qgeosatelliteinfosource_p.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOSATELLITEINFOSOURCE_P_H
-#define QGEOSATELLITEINFOSOURCE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/private/qobject_p.h>
-#include <QtPositioning/private/qpositioningglobal_p.h>
-#include <QString>
-
-QT_BEGIN_NAMESPACE
-class QGeoSatelliteInfoSource;
-class QGeoSatelliteInfoSourcePrivate : public QObjectPrivate
-{
-public:
- virtual ~QGeoSatelliteInfoSourcePrivate();
- static QGeoSatelliteInfoSource *createSourceReal(const QJsonObject &meta,
- const QVariantMap &parameters,
- QObject *parent);
- Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QGeoSatelliteInfoSourcePrivate, int, interval, 0)
- QString providerName;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGEOSATELLITEINFOSOURCE_P_H
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp
deleted file mode 100644
index 7ab32b60..00000000
--- a/src/positioning/qgeoshape.cpp
+++ /dev/null
@@ -1,449 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeoshape.h"
-#include "qgeoshape_p.h"
-#include "qgeorectangle.h"
-#include "qgeocircle.h"
-#include "qgeopath.h"
-#include "qgeopolygon.h"
-
-
-#ifndef QT_NO_DEBUG_STREAM
-#include <QtCore/QDebug>
-#endif
-
-#ifndef QT_NO_DATASTREAM
-#include <QtCore/QDataStream>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QGeoShapePrivate::QGeoShapePrivate(QGeoShape::ShapeType type)
-: type(type)
-{
-}
-
-QGeoShapePrivate::~QGeoShapePrivate()
-{
-}
-
-bool QGeoShapePrivate::operator==(const QGeoShapePrivate &other) const
-{
- return type == other.type;
-}
-
-/*!
- \class QGeoShape
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QGeoShape class defines a geographic area.
-
- This class is the base class for classes which specify a geographic
- area.
-
- For the sake of consistency, subclasses should describe the specific
- details of the associated areas in terms of QGeoCoordinate instances
- and distances in meters.
-
- This class is a \l Q_GADGET since Qt 5.5. It can be
- \l{Cpp_value_integration_positioning}{directly used from C++ and QML}.
-*/
-
-/*!
- \enum QGeoShape::ShapeType
-
- Describes the type of the shape.
-
- \value UnknownType A shape of unknown type
- \value RectangleType A rectangular shape
- \value CircleType A circular shape
- \value PathType A path type
- \value PolygonType A polygon type
-*/
-
-/*!
- \property QGeoShape::type
- \brief This property holds the type of this geo shape.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoShape::isValid
- \brief This property holds the validity of the geo shape.
-
- A geo shape is considered to be invalid if some of the data that is required to
- unambiguously describe the geo shape has not been set or has been set to an
- unsuitable value depending on the subclass of this object. The default constructed
- objects of this type are invalid.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-
-/*!
- \property QGeoShape::isEmpty
- \brief This property defines whether this geo shape is empty.
-
- An empty geo shape is a region which has a geometrical area of 0.
-
- While this property is introduced in Qt 5.5, the related accessor functions
- exist since the first version of this class.
-
- \since 5.5
-*/
-inline QGeoShapePrivate *QGeoShape::d_func()
-{
- return static_cast<QGeoShapePrivate *>(d_ptr.data());
-}
-
-inline const QGeoShapePrivate *QGeoShape::d_func() const
-{
- return static_cast<const QGeoShapePrivate *>(d_ptr.constData());
-}
-
-/*!
- Constructs a new invalid geo shape of \l UnknownType.
-*/
-QGeoShape::QGeoShape()
-{
-}
-
-/*!
- Constructs a new geo shape which is a copy of \a other.
-*/
-QGeoShape::QGeoShape(const QGeoShape &other)
-: d_ptr(other.d_ptr)
-{
-}
-
-/*!
- \internal
-*/
-QGeoShape::QGeoShape(QGeoShapePrivate *d)
-: d_ptr(d)
-{
-}
-
-bool QGeoShape::equals(const QGeoShape &lhs, const QGeoShape &rhs)
-{
- if (lhs.d_func() == rhs.d_func())
- return true;
-
- if (!lhs.d_func() || !rhs.d_func())
- return false;
-
- return *lhs.d_func() == *rhs.d_func();
-}
-
-/*!
- Destroys this geo shape.
-*/
-QGeoShape::~QGeoShape()
-{
-}
-
-/*!
- Returns the type of this geo shape.
-*/
-QGeoShape::ShapeType QGeoShape::type() const
-{
- Q_D(const QGeoShape);
-
- if (d)
- return d->type;
- else
- return UnknownType;
-}
-
-/*!
- Returns whether this geo shape is valid.
-
-*/
-bool QGeoShape::isValid() const
-{
- Q_D(const QGeoShape);
-
- if (d)
- return d->isValid();
- else
- return false;
-}
-
-/*!
- Returns whether this geo shape is empty.
-
- An empty geo shape is a region which has a geometrical area of 0.
-*/
-bool QGeoShape::isEmpty() const
-{
- Q_D(const QGeoShape);
-
- if (d)
- return d->isEmpty();
- else
- return true;
-}
-
-/*!
- Returns whether the coordinate \a coordinate is contained within this geo shape.
-*/
-bool QGeoShape::contains(const QGeoCoordinate &coordinate) const
-{
- Q_D(const QGeoShape);
-
- if (d)
- return d->contains(coordinate);
- else
- return false;
-}
-
-/*!
- Returns a QGeoRectangle representing the geographical bounding rectangle of the
- geo shape, that defines the latitudinal/longitudinal bounds of the geo shape.
-
- \since 5.9
-*/
-QGeoRectangle QGeoShape::boundingGeoRectangle() const
-{
- Q_D(const QGeoShape);
-
- if (d)
- return d->boundingGeoRectangle();
- else
- return QGeoRectangle();
-}
-
-/*!
- Returns the coordinate located at the geometric center of the geo shape.
-
- \since 5.5
-*/
-QGeoCoordinate QGeoShape::center() const
-{
- Q_D(const QGeoShape);
-
- if (d)
- return d->center();
- else
- return QGeoCoordinate();
-}
-
-/*!
- \fn bool QGeoShape::operator==(const QGeoShape &lhs, const QGeoShape &rhs)
-
- Returns \c true if the \a lhs geo shape is equivalent to the \a rhs geo
- shape, otherwise returns \c false.
-*/
-
-/*!
- \fn bool QGeoShape::operator!=(const QGeoShape &lhs, const QGeoShape &rhs)
-
- Returns \c true if the \a lhs geo shape is not equivalent to the \a rhs geo
- shape, otherwise returns \c false.
-*/
-
-/*!
- Assigns \a other to this geo shape and returns a reference to this geo shape.
-*/
-QGeoShape &QGeoShape::operator=(const QGeoShape &other)
-{
- if (this == &other)
- return *this;
-
- d_ptr = other.d_ptr;
- return *this;
-}
-
-/*!
- Returns a string representation of this geo shape.
-
- \since 5.5
-*/
-QString QGeoShape::toString() const
-{
- return QStringLiteral("QGeoShape(%1)").arg(type());
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug QGeoShape::debugStreaming(QDebug dbg, const QGeoShape &shape)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace() << "QGeoShape(";
- switch (shape.type()) {
- case QGeoShape::UnknownType:
- dbg << "Unknown";
- break;
- case QGeoShape::RectangleType:
- dbg << "Rectangle";
- break;
- case QGeoShape::PathType:
- dbg << "Path";
- break;
- case QGeoShape::PolygonType:
- dbg << "Polygon";
- break;
- case QGeoShape::CircleType:
- dbg << "Circle";
- }
-
- dbg << ')';
-
- return dbg;
-}
-#endif
-
-#ifndef QT_NO_DATASTREAM
-QDataStream &QGeoShape::dataStreamOut(QDataStream &stream, const QGeoShape &shape)
-{
- stream << quint32(shape.type());
- switch (shape.type()) {
- case QGeoShape::UnknownType:
- break;
- case QGeoShape::RectangleType: {
- QGeoRectangle r = shape;
- stream << r.topLeft() << r.bottomRight();
- break;
- }
- case QGeoShape::CircleType: {
- QGeoCircle c = shape;
- stream << c.center() << c.radius();
- break;
- }
- case QGeoShape::PathType: {
- QGeoPath p = shape;
- stream << p.width();
- stream << p.path().size();
- for (const auto &c: p.path())
- stream << c;
- break;
- }
- case QGeoShape::PolygonType: {
- QGeoPolygon p = shape;
- stream << p.perimeter().size();
- for (const auto &c: p.perimeter())
- stream << c;
- break;
- }
- }
-
- return stream;
-}
-
-QDataStream &QGeoShape::dataStreamIn(QDataStream &stream, QGeoShape &shape)
-{
- quint32 type;
- stream >> type;
-
- switch (type) {
- case QGeoShape::UnknownType:
- shape = QGeoShape();
- break;
- case QGeoShape::RectangleType: {
- QGeoCoordinate tl;
- QGeoCoordinate br;
- stream >> tl >> br;
- shape = QGeoRectangle(tl, br);
- break;
- }
- case QGeoShape::CircleType: {
- QGeoCoordinate c;
- qreal r;
- stream >> c >> r;
- shape = QGeoCircle(c, r);
- break;
- }
- case QGeoShape::PathType: {
- QList<QGeoCoordinate> l;
- QGeoCoordinate c;
- qreal width;
- stream >> width;
- qsizetype sz;
- stream >> sz;
- for (qsizetype i = 0; i < sz; i++) {
- stream >> c;
- l.append(c);
- }
- shape = QGeoPath(l, width);
- break;
- }
- case QGeoShape::PolygonType: {
- QList<QGeoCoordinate> l;
- QGeoCoordinate c;
- qsizetype sz;
- stream >> sz;
- for (qsizetype i = 0; i < sz; i++) {
- stream >> c;
- l.append(c);
- }
- shape = QGeoPolygon(l);
- break;
- }
- }
-
- return stream;
-}
-#endif
-
-/*!
- \relates QGeoShape
-
- Returns the hash value for the \a shape, using \a seed for the
- calculation.
-*/
-size_t qHash(const QGeoShape &shape, size_t seed) noexcept
-{
- if (shape.d_ptr)
- return shape.d_ptr->hash(seed);
- else
- return qHashMulti(seed, shape.type());
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qgeoshape.cpp"
-
diff --git a/src/positioning/qgeoshape.h b/src/positioning/qgeoshape.h
deleted file mode 100644
index f2a9166c..00000000
--- a/src/positioning/qgeoshape.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOSHAPE_H
-#define QGEOSHAPE_H
-
-#include <QtCore/QSharedDataPointer>
-#include <QtPositioning/QGeoCoordinate>
-
-QT_BEGIN_NAMESPACE
-
-class QDebug;
-class QGeoShapePrivate;
-class QGeoRectangle;
-
-class Q_POSITIONING_EXPORT QGeoShape
-{
- Q_GADGET
- Q_PROPERTY(ShapeType type READ type)
- Q_PROPERTY(bool isValid READ isValid)
- Q_PROPERTY(bool isEmpty READ isEmpty)
- Q_PROPERTY(QGeoCoordinate center READ center)
- Q_ENUMS(ShapeType)
-
-public:
- QGeoShape();
- QGeoShape(const QGeoShape &other);
- ~QGeoShape();
-
- enum ShapeType {
- UnknownType,
- RectangleType,
- CircleType,
- PathType,
- PolygonType
- };
-
- ShapeType type() const;
-
- bool isValid() const;
- bool isEmpty() const;
- Q_INVOKABLE bool contains(const QGeoCoordinate &coordinate) const;
- Q_INVOKABLE QGeoRectangle boundingGeoRectangle() const;
- QGeoCoordinate center() const;
-
- friend bool operator==(const QGeoShape &lhs, const QGeoShape &rhs)
- {
- return equals(lhs, rhs);
- }
- friend bool operator!=(const QGeoShape &lhs, const QGeoShape &rhs)
- {
- return !equals(lhs, rhs);
- }
-
- QGeoShape &operator=(const QGeoShape &other);
-
- Q_INVOKABLE QString toString() const;
-protected:
- QGeoShape(QGeoShapePrivate *d);
-
- QSharedDataPointer<QGeoShapePrivate> d_ptr;
-
-private:
- static bool equals(const QGeoShape &lhs, const QGeoShape &rhs);
- inline QGeoShapePrivate *d_func();
- inline const QGeoShapePrivate *d_func() const;
-#ifndef QT_NO_DEBUG_STREAM
- friend QDebug operator<<(QDebug dbg, const QGeoShape &shape)
- {
- return debugStreaming(dbg, shape);
- }
- static QDebug debugStreaming(QDebug dbg, const QGeoShape &shape);
-#endif
-#ifndef QT_NO_DATASTREAM
- friend QDataStream &operator<<(QDataStream &stream, const QGeoShape &shape)
- {
- return dataStreamOut(stream, shape);
- }
- friend QDataStream &operator>>(QDataStream &stream, QGeoShape &shape)
- {
- return dataStreamIn(stream, shape);
- }
- static QDataStream &dataStreamOut(QDataStream &stream, const QGeoShape &shape);
- static QDataStream &dataStreamIn(QDataStream &stream, QGeoShape &shape);
-#endif
- friend Q_POSITIONING_EXPORT size_t qHash(const QGeoShape &key, size_t seed) noexcept;
-};
-
-Q_POSITIONING_EXPORT size_t qHash(const QGeoShape &shape, size_t seed = 0) noexcept;
-
-Q_DECLARE_TYPEINFO(QGeoShape, Q_RELOCATABLE_TYPE);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGeoShape)
-
-#endif
diff --git a/src/positioning/qgeoshape_p.h b/src/positioning/qgeoshape_p.h
deleted file mode 100644
index 94551c89..00000000
--- a/src/positioning/qgeoshape_p.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOSHAPE_P_H
-#define QGEOSHAPE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QSharedData>
-
-#include "qgeorectangle.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoShapePrivate : public QSharedData
-{
-public:
- explicit QGeoShapePrivate(QGeoShape::ShapeType type);
- virtual ~QGeoShapePrivate();
-
- virtual bool isValid() const = 0;
- virtual bool isEmpty() const = 0;
- virtual bool contains(const QGeoCoordinate &coordinate) const = 0;
-
- virtual QGeoCoordinate center() const = 0;
-
- virtual QGeoRectangle boundingGeoRectangle() const = 0;
-
- virtual QGeoShapePrivate *clone() const = 0;
-
- virtual bool operator==(const QGeoShapePrivate &other) const;
-
- virtual size_t hash(size_t seed) const = 0;
-
- QGeoShape::ShapeType type;
-};
-
-// don't use the copy constructor when detaching from a QSharedDataPointer, use virtual clone()
-// call instead.
-template <>
-Q_INLINE_TEMPLATE QGeoShapePrivate *QSharedDataPointer<QGeoShapePrivate>::clone()
-{
- return d->clone();
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qlocationutils.cpp b/src/positioning/qlocationutils.cpp
deleted file mode 100644
index 04f94c2e..00000000
--- a/src/positioning/qlocationutils.cpp
+++ /dev/null
@@ -1,635 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Jolla Ltd.
-** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qlocationutils_p.h"
-#include "qgeopositioninfo.h"
-#include "qgeosatelliteinfo.h"
-
-#include <QTime>
-#include <QList>
-#include <QByteArray>
-#include <QDebug>
-
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-// converts e.g. 15306.0235 from NMEA sentence to 153.100392
-static double qlocationutils_nmeaDegreesToDecimal(double nmeaDegrees)
-{
- double deg;
- double min = 100.0 * modf(nmeaDegrees / 100.0, &deg);
- return deg + (min / 60.0);
-}
-
-static void qlocationutils_readGga(const char *data, int size, QGeoPositionInfo *info, double uere,
- bool *hasFix)
-{
- QByteArray sentence(data, size);
- QList<QByteArray> parts = sentence.split(',');
- QGeoCoordinate coord;
-
- if (hasFix && parts.count() > 6 && parts[6].count() > 0)
- *hasFix = parts[6].toInt() > 0;
-
- if (parts.count() > 1 && parts[1].count() > 0) {
- QTime time;
- if (QLocationUtils::getNmeaTime(parts[1], &time))
- info->setTimestamp(QDateTime(QDate(), time, Qt::UTC));
- }
-
- if (parts.count() > 5 && parts[3].count() == 1 && parts[5].count() == 1) {
- double lat;
- double lng;
- if (QLocationUtils::getNmeaLatLong(parts[2], parts[3][0], parts[4], parts[5][0], &lat, &lng)) {
- coord.setLatitude(lat);
- coord.setLongitude(lng);
- }
- }
-
- if (parts.count() > 8 && !parts[8].isEmpty()) {
- bool hasHdop = false;
- double hdop = parts[8].toDouble(&hasHdop);
- if (hasHdop)
- info->setAttribute(QGeoPositionInfo::HorizontalAccuracy, 2 * hdop * uere);
- }
-
- if (parts.count() > 9 && parts[9].count() > 0) {
- bool hasAlt = false;
- double alt = parts[9].toDouble(&hasAlt);
- if (hasAlt)
- coord.setAltitude(alt);
- }
-
- if (coord.type() != QGeoCoordinate::InvalidCoordinate)
- info->setCoordinate(coord);
-}
-
-static void qlocationutils_readGsa(const char *data, int size, QGeoPositionInfo *info, double uere,
- bool *hasFix)
-{
- QList<QByteArray> parts = QByteArray::fromRawData(data, size).split(',');
-
- if (hasFix && parts.count() > 2 && !parts[2].isEmpty())
- *hasFix = parts[2].toInt() > 0;
-
- if (parts.count() > 16 && !parts[16].isEmpty()) {
- bool hasHdop = false;
- double hdop = parts[16].toDouble(&hasHdop);
- if (hasHdop)
- info->setAttribute(QGeoPositionInfo::HorizontalAccuracy, 2 * hdop * uere);
- }
-
- if (parts.count() > 17 && !parts[17].isEmpty()) {
- bool hasVdop = false;
- double vdop = parts[17].toDouble(&hasVdop);
- if (hasVdop)
- info->setAttribute(QGeoPositionInfo::VerticalAccuracy, 2 * vdop * uere);
- }
-}
-
-static void qlocationutils_readGsa(const char *data,
- int size,
- QList<int> &pnrsInUse)
-{
- QList<QByteArray> parts = QByteArray::fromRawData(data, size).split(',');
- pnrsInUse.clear();
- if (parts.count() <= 2)
- return;
- bool ok;
- for (int i = 3; i <= qMin(14, parts.size()); ++i) {
- const QByteArray &pnrString = parts.at(i);
- if (pnrString.isEmpty())
- continue;
- int pnr = pnrString.toInt(&ok);
- if (ok)
- pnrsInUse.append(pnr);
- }
-}
-
-static void qlocationutils_readGll(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
-{
- QByteArray sentence(data, size);
- QList<QByteArray> parts = sentence.split(',');
- QGeoCoordinate coord;
-
- if (hasFix && parts.count() > 6 && parts[6].count() > 0)
- *hasFix = (parts[6][0] == 'A');
-
- if (parts.count() > 5 && parts[5].count() > 0) {
- QTime time;
- if (QLocationUtils::getNmeaTime(parts[5], &time))
- info->setTimestamp(QDateTime(QDate(), time, Qt::UTC));
- }
-
- if (parts.count() > 4 && parts[2].count() == 1 && parts[4].count() == 1) {
- double lat;
- double lng;
- if (QLocationUtils::getNmeaLatLong(parts[1], parts[2][0], parts[3], parts[4][0], &lat, &lng)) {
- coord.setLatitude(lat);
- coord.setLongitude(lng);
- }
- }
-
- if (coord.type() != QGeoCoordinate::InvalidCoordinate)
- info->setCoordinate(coord);
-}
-
-static void qlocationutils_readRmc(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
-{
- QByteArray sentence(data, size);
- QList<QByteArray> parts = sentence.split(',');
- QGeoCoordinate coord;
- QDate date;
- QTime time;
-
- if (hasFix && parts.count() > 2 && parts[2].count() > 0)
- *hasFix = (parts[2][0] == 'A');
-
- if (parts.count() > 9 && parts[9].count() == 6) {
- date = QDate::fromString(QString::fromLatin1(parts[9]), QStringLiteral("ddMMyy"));
- if (date.isValid())
- date = date.addYears(100); // otherwise starts from 1900
- else
- date = QDate();
- }
-
- if (parts.count() > 1 && parts[1].count() > 0)
- QLocationUtils::getNmeaTime(parts[1], &time);
-
- if (parts.count() > 6 && parts[4].count() == 1 && parts[6].count() == 1) {
- double lat;
- double lng;
- if (QLocationUtils::getNmeaLatLong(parts[3], parts[4][0], parts[5], parts[6][0], &lat, &lng)) {
- coord.setLatitude(lat);
- coord.setLongitude(lng);
- }
- }
-
- bool parsed = false;
- double value = 0.0;
- if (parts.count() > 7 && parts[7].count() > 0) {
- value = parts[7].toDouble(&parsed);
- if (parsed)
- info->setAttribute(QGeoPositionInfo::GroundSpeed, qreal(value * 1.852 / 3.6)); // knots -> m/s
- }
- if (parts.count() > 8 && parts[8].count() > 0) {
- value = parts[8].toDouble(&parsed);
- if (parsed)
- info->setAttribute(QGeoPositionInfo::Direction, qreal(value));
- }
- if (parts.count() > 11 && parts[11].count() == 1
- && (parts[11][0] == 'E' || parts[11][0] == 'W')) {
- value = parts[10].toDouble(&parsed);
- if (parsed) {
- if (parts[11][0] == 'W')
- value *= -1;
- info->setAttribute(QGeoPositionInfo::MagneticVariation, qreal(value));
- }
- }
-
- if (coord.type() != QGeoCoordinate::InvalidCoordinate)
- info->setCoordinate(coord);
-
- info->setTimestamp(QDateTime(date, time, Qt::UTC));
-}
-
-static void qlocationutils_readVtg(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
-{
- if (hasFix)
- *hasFix = false;
-
- QByteArray sentence(data, size);
- QList<QByteArray> parts = sentence.split(',');
-
- bool parsed = false;
- double value = 0.0;
- if (parts.count() > 1 && parts[1].count() > 0) {
- value = parts[1].toDouble(&parsed);
- if (parsed)
- info->setAttribute(QGeoPositionInfo::Direction, qreal(value));
- }
- if (parts.count() > 7 && parts[7].count() > 0) {
- value = parts[7].toDouble(&parsed);
- if (parsed)
- info->setAttribute(QGeoPositionInfo::GroundSpeed, qreal(value / 3.6)); // km/h -> m/s
- }
-}
-
-static void qlocationutils_readZda(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
-{
- if (hasFix)
- *hasFix = false;
-
- QByteArray sentence(data, size);
- QList<QByteArray> parts = sentence.split(',');
- QDate date;
- QTime time;
-
- if (parts.count() > 1 && parts[1].count() > 0)
- QLocationUtils::getNmeaTime(parts[1], &time);
-
- if (parts.count() > 4 && parts[2].count() > 0 && parts[3].count() > 0
- && parts[4].count() == 4) { // must be full 4-digit year
- int day = parts[2].toUInt();
- int month = parts[3].toUInt();
- int year = parts[4].toUInt();
- if (day > 0 && month > 0 && year > 0)
- date.setDate(year, month, day);
- }
-
- info->setTimestamp(QDateTime(date, time, Qt::UTC));
-}
-
-QLocationUtils::NmeaSentence QLocationUtils::getNmeaSentenceType(const char *data, int size)
-{
- if (size < 6 || data[0] != '$' || !hasValidNmeaChecksum(data, size))
- return NmeaSentenceInvalid;
-
- if (data[3] == 'G' && data[4] == 'G' && data[5] == 'A')
- return NmeaSentenceGGA;
-
- if (data[3] == 'G' && data[4] == 'S' && data[5] == 'A')
- return NmeaSentenceGSA;
-
- if (data[3] == 'G' && data[4] == 'S' && data[5] == 'V')
- return NmeaSentenceGSV;
-
- if (data[3] == 'G' && data[4] == 'L' && data[5] == 'L')
- return NmeaSentenceGLL;
-
- if (data[3] == 'R' && data[4] == 'M' && data[5] == 'C')
- return NmeaSentenceRMC;
-
- if (data[3] == 'V' && data[4] == 'T' && data[5] == 'G')
- return NmeaSentenceVTG;
-
- if (data[3] == 'Z' && data[4] == 'D' && data[5] == 'A')
- return NmeaSentenceZDA;
-
- return NmeaSentenceInvalid;
-}
-
-QGeoSatelliteInfo::SatelliteSystem QLocationUtils::getSatelliteSystem(const char *data, int size)
-{
- if (size < 6 || data[0] != '$' || !hasValidNmeaChecksum(data, size))
- return QGeoSatelliteInfo::Undefined;
-
- // GPS: GP
- if (data[1] == 'G' && data[2] == 'P')
- return QGeoSatelliteInfo::GPS;
-
- // GLONASS: GL
- if (data[1] == 'G' && data[2] == 'L')
- return QGeoSatelliteInfo::GLONASS;
-
- // GALILEO: GA
- if (data[1] == 'G' && data[2] == 'A')
- return QGeoSatelliteInfo::GALILEO;
-
- // BeiDou: BD or GB
- if ((data[1] == 'B' && data[2] == 'D') || (data[1] == 'G' && data[2] == 'B'))
- return QGeoSatelliteInfo::BEIDOU;
-
- // QZSS: GQ, PQ, QZ
- if ((data[1] == 'G' && data[2] == 'Q') || (data[1] == 'P' && data[2] == 'Q')
- || (data[1] == 'Q' && data[2] == 'Z')) {
- return QGeoSatelliteInfo::QZSS;
- }
-
- // Multiple: GN
- if (data[1] == 'G' && data[2] == 'N')
- return QGeoSatelliteInfo::Multiple;
-
- return QGeoSatelliteInfo::Undefined;
-}
-
-QGeoSatelliteInfo::SatelliteSystem QLocationUtils::getSatelliteSystemBySatelliteId(int satId)
-{
- if (satId >= 1 && satId <= 32)
- return QGeoSatelliteInfo::GPS;
-
- if (satId >= 65 && satId <= 96) // including future extensions
- return QGeoSatelliteInfo::GLONASS;
-
- if (satId >= 193 && satId <= 200) // including future extensions
- return QGeoSatelliteInfo::QZSS;
-
- if ((satId >= 201 && satId <= 235) || (satId >= 401 && satId <= 437))
- return QGeoSatelliteInfo::BEIDOU;
-
- if (satId >= 301 && satId <= 336)
- return QGeoSatelliteInfo::GALILEO;
-
- return QGeoSatelliteInfo::Undefined;
-}
-
-bool QLocationUtils::getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info,
- double uere, bool *hasFix)
-{
- if (!info)
- return false;
-
- if (hasFix)
- *hasFix = false;
-
- NmeaSentence nmeaType = getNmeaSentenceType(data, size);
- if (nmeaType == NmeaSentenceInvalid)
- return false;
-
- // Adjust size so that * and following characters are not parsed by the following functions.
- for (int i = 0; i < size; ++i) {
- if (data[i] == '*') {
- size = i;
- break;
- }
- }
-
- switch (nmeaType) {
- case NmeaSentenceGGA:
- qlocationutils_readGga(data, size, info, uere, hasFix);
- return true;
- case NmeaSentenceGSA:
- qlocationutils_readGsa(data, size, info, uere, hasFix);
- return true;
- case NmeaSentenceGLL:
- qlocationutils_readGll(data, size, info, hasFix);
- return true;
- case NmeaSentenceRMC:
- qlocationutils_readRmc(data, size, info, hasFix);
- return true;
- case NmeaSentenceVTG:
- qlocationutils_readVtg(data, size, info, hasFix);
- return true;
- case NmeaSentenceZDA:
- qlocationutils_readZda(data, size, info, hasFix);
- return true;
- default:
- return false;
- }
-}
-
-QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
-QLocationUtils::getSatInfoFromNmea(const char *data, int size, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system)
-{
- if (!data || !size)
- return QNmeaSatelliteInfoSource::NotParsed;
-
- NmeaSentence nmeaType = getNmeaSentenceType(data, size);
- if (nmeaType != NmeaSentenceGSV)
- return QNmeaSatelliteInfoSource::NotParsed;
-
- // Standard forbids using $GN talker id for GSV messages, so the system
- // type here will be uniquely identified.
- system = getSatelliteSystem(data, size);
-
- // Adjust size so that * and following characters are not parsed by the
- // following code.
- for (int i = 0; i < size; ++i) {
- if (data[i] == '*') {
- size = i;
- break;
- }
- }
-
- QList<QByteArray> parts = QByteArray::fromRawData(data, size).split(',');
-
- if (parts.count() <= 3) {
- infos.clear();
- return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
- }
- bool ok;
- const int totalSentences = parts.at(1).toInt(&ok);
- if (!ok) {
- infos.clear();
- return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
- }
-
- const int sentence = parts.at(2).toInt(&ok);
- if (!ok) {
- infos.clear();
- return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
- }
-
- const int totalSats = parts.at(3).toInt(&ok);
- if (!ok) {
- infos.clear();
- return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
- }
-
- if (sentence == 1)
- infos.clear();
-
- const int numSatInSentence = qMin(sentence * 4, totalSats) - (sentence - 1) * 4;
-
- int field = 4;
- for (int i = 0; i < numSatInSentence; ++i) {
- QGeoSatelliteInfo info;
- info.setSatelliteSystem(system);
- int prn = parts.at(field++).toInt(&ok);
- // Quote from: https://gpsd.gitlab.io/gpsd/NMEA.html#_satellite_ids
- // GLONASS satellite numbers come in two flavors. If a sentence has a GL
- // talker ID, expect the skyviews to be GLONASS-only and in the range
- // 1-32; you must add 64 to get a globally-unique NMEA ID. If the
- // sentence has a GN talker ID, the device emits a multi-constellation
- // skyview with GLONASS IDs already in the 65-96 range.
- //
- // However I don't observe such behavior with my device. So implementing
- // a safe scenario.
- if (ok && (system == QGeoSatelliteInfo::GLONASS)) {
- if (prn <= 64)
- prn += 64;
- }
- info.setSatelliteIdentifier((ok) ? prn : 0);
- const int elevation = parts.at(field++).toInt(&ok);
- info.setAttribute(QGeoSatelliteInfo::Elevation, (ok) ? elevation : 0);
- const int azimuth = parts.at(field++).toInt(&ok);
- info.setAttribute(QGeoSatelliteInfo::Azimuth, (ok) ? azimuth : 0);
- const int snr = parts.at(field++).toInt(&ok);
- info.setSignalStrength((ok) ? snr : -1);
- infos.append(info);
- }
-
- if (sentence == totalSentences)
- return QNmeaSatelliteInfoSource::FullyParsed;
-
- return QNmeaSatelliteInfoSource::PartiallyParsed;
-}
-
-QGeoSatelliteInfo::SatelliteSystem QLocationUtils::getSatInUseFromNmea(const char *data, int size,
- QList<int> &pnrsInUse)
-{
- if (!data || !size)
- return QGeoSatelliteInfo::Undefined;
-
- NmeaSentence nmeaType = getNmeaSentenceType(data, size);
- if (nmeaType != NmeaSentenceGSA)
- return QGeoSatelliteInfo::Undefined;
-
- auto systemType = getSatelliteSystem(data, size);
- if (systemType == QGeoSatelliteInfo::Undefined)
- return systemType;
-
- // The documentation states that we do not modify pnrsInUse if we could not
- // parse the data
- pnrsInUse.clear();
-
- // Adjust size so that * and following characters are not parsed by the following functions.
- for (int i = 0; i < size; ++i) {
- if (data[i] == '*') {
- size = i;
- break;
- }
- }
- qlocationutils_readGsa(data, size, pnrsInUse);
-
- // Quote from: https://gpsd.gitlab.io/gpsd/NMEA.html#_satellite_ids
- // GLONASS satellite numbers come in two flavors. If a sentence has a GL
- // talker ID, expect the skyviews to be GLONASS-only and in the range 1-32;
- // you must add 64 to get a globally-unique NMEA ID. If the sentence has a
- // GN talker ID, the device emits a multi-constellation skyview with
- // GLONASS IDs already in the 65-96 range.
- //
- // However I don't observe such behavior with my device. So implementing a
- // safe scenario.
- if (systemType == QGeoSatelliteInfo::GLONASS) {
- std::for_each(pnrsInUse.begin(), pnrsInUse.end(), [](int &id) {
- if (id <= 64)
- id += 64;
- });
- }
-
- if ((systemType == QGeoSatelliteInfo::Multiple) && !pnrsInUse.isEmpty()) {
- // Standard claims that in case of multiple system types we will receive
- // several GSA messages, each containing data from only one satellite
- // system, so we can pick the first id to determine the system type.
- auto tempSystemType = getSatelliteSystemBySatelliteId(pnrsInUse.front());
- if (tempSystemType != QGeoSatelliteInfo::Undefined)
- systemType = tempSystemType;
- }
-
- return systemType;
-}
-
-bool QLocationUtils::hasValidNmeaChecksum(const char *data, int size)
-{
- int asteriskIndex = -1;
- for (int i = 0; i < size; ++i) {
- if (data[i] == '*') {
- asteriskIndex = i;
- break;
- }
- }
-
- const int CSUM_LEN = 2;
- if (asteriskIndex < 0 || asteriskIndex + CSUM_LEN >= size)
- return false;
-
- // XOR byte value of all characters between '$' and '*'
- int result = 0;
- for (int i = 1; i < asteriskIndex; ++i)
- result ^= data[i];
- /*
- char calc[CSUM_LEN + 1];
- ::snprintf(calc, CSUM_LEN + 1, "%02x", result);
- return ::strncmp(calc, &data[asteriskIndex+1], 2) == 0;
- */
-
- QByteArray checkSumBytes(&data[asteriskIndex + 1], 2);
- bool ok = false;
- int checksum = checkSumBytes.toInt(&ok,16);
- return ok && checksum == result;
-}
-
-bool QLocationUtils::getNmeaTime(const QByteArray &bytes, QTime *time)
-{
- int dotIndex = bytes.indexOf('.');
- QTime tempTime;
-
- if (dotIndex < 0) {
- tempTime = QTime::fromString(QString::fromLatin1(bytes.constData()),
- QStringLiteral("hhmmss"));
- } else {
- tempTime = QTime::fromString(QString::fromLatin1(bytes.mid(0, dotIndex)),
- QStringLiteral("hhmmss"));
- bool hasMsecs = false;
- int midLen = qMin(3, bytes.size() - dotIndex - 1);
- int msecs = bytes.mid(dotIndex + 1, midLen).toUInt(&hasMsecs);
- if (hasMsecs)
- tempTime = tempTime.addMSecs(msecs*(midLen == 3 ? 1 : midLen == 2 ? 10 : 100));
- }
-
- if (tempTime.isValid()) {
- *time = tempTime;
- return true;
- }
- return false;
-}
-
-bool QLocationUtils::getNmeaLatLong(const QByteArray &latString, char latDirection, const QByteArray &lngString, char lngDirection, double *lat, double *lng)
-{
- if ((latDirection != 'N' && latDirection != 'S')
- || (lngDirection != 'E' && lngDirection != 'W')) {
- return false;
- }
-
- bool hasLat = false;
- bool hasLong = false;
- double tempLat = latString.toDouble(&hasLat);
- double tempLng = lngString.toDouble(&hasLong);
- if (hasLat && hasLong) {
- tempLat = qlocationutils_nmeaDegreesToDecimal(tempLat);
- if (latDirection == 'S')
- tempLat *= -1;
- tempLng = qlocationutils_nmeaDegreesToDecimal(tempLng);
- if (lngDirection == 'W')
- tempLng *= -1;
-
- if (isValidLat(tempLat) && isValidLong(tempLng)) {
- *lat = tempLat;
- *lng = tempLng;
- return true;
- }
- }
- return false;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/positioning/qlocationutils_p.h b/src/positioning/qlocationutils_p.h
deleted file mode 100644
index 0db855a5..00000000
--- a/src/positioning/qlocationutils_p.h
+++ /dev/null
@@ -1,350 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QLOCATIONUTILS_P_H
-#define QLOCATIONUTILS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QtGlobal>
-#include <math.h> // needed for non-std:: versions of functions
-#include <qmath.h>
-#include <QtPositioning/QGeoCoordinate>
-#include <QtPositioning/QNmeaSatelliteInfoSource>
-#include <QtPositioning/private/qpositioningglobal_p.h>
-
-static const double offsetEpsilon = 1e-12; // = 0.000000000001
-static const double leftOffset = -180.0 + offsetEpsilon;
-static const double rightOffset = 180.0 - offsetEpsilon;
-
-QT_BEGIN_NAMESPACE
-class QTime;
-class QByteArray;
-
-class QGeoPositionInfo;
-class QGeoSatelliteInfo;
-class Q_POSITIONING_PRIVATE_EXPORT QLocationUtils
-{
-public:
- enum CardinalDirection {
- CardinalN,
- CardinalE,
- CardinalS,
- CardinalW,
- CardinalNE,
- CardinalSE,
- CardinalSW,
- CardinalNW,
- CardinalNNE,
- CardinalENE,
- CardinalESE,
- CardinalSSE,
- CardinalSSW,
- CardinalWSW,
- CardinalWNW,
- CardinalNNW
- };
-
- enum NmeaSentence {
- NmeaSentenceInvalid,
- NmeaSentenceGGA, // Fix information
- NmeaSentenceGSA, // Overall Satellite data, such as HDOP and VDOP
- NmeaSentenceGLL, // Lat/Lon data
- NmeaSentenceRMC, // Recommended minimum data for gps
- NmeaSentenceVTG, // Vector track an Speed over the Ground
- NmeaSentenceZDA, // Date and Time
- NmeaSentenceGSV // Per-Satellite Info
- };
-
- inline static bool isValidLat(double lat) {
- return lat >= -90.0 && lat <= 90.0;
- }
- inline static bool isValidLong(double lng) {
- return lng >= -180.0 && lng <= 180.0;
- }
-
- inline static double clipLat(double lat, double clipValue = 90.0) {
- if (lat > clipValue)
- lat = clipValue;
- else if (lat < -clipValue)
- lat = -clipValue;
- return lat;
- }
-
- inline static double wrapLong(double lng) {
- if (lng > 180.0)
- lng -= 360.0;
- else if (lng < -180.0)
- lng += 360.0;
- return lng;
- }
-
- inline static CardinalDirection azimuthToCardinalDirection4(double azimuth)
- {
- azimuth = fmod(azimuth, 360.0);
- if (azimuth < 45.0 || azimuth > 315.0 )
- return CardinalN;
- else if (azimuth < 135.0)
- return CardinalE;
- else if (azimuth < 225.0)
- return CardinalS;
- else
- return CardinalW;
- }
-
- inline static CardinalDirection azimuthToCardinalDirection8(double azimuth)
- {
- azimuth = fmod(azimuth, 360.0);
- if (azimuth < 22.5 || azimuth > 337.5 )
- return CardinalN;
- else if (azimuth < 67.5)
- return CardinalNE;
- else if (azimuth < 112.5)
- return CardinalE;
- else if (azimuth < 157.5)
- return CardinalSE;
- else if (azimuth < 202.5)
- return CardinalS;
-
- else if (azimuth < 247.5)
- return CardinalSW;
- else if (azimuth < 292.5)
- return CardinalW;
- else
- return CardinalNW;
- }
-
- inline static CardinalDirection azimuthToCardinalDirection16(double azimuth)
- {
- azimuth = fmod(azimuth, 360.0);
- if (azimuth < 11.5 || azimuth > 348.75 )
- return CardinalN;
- else if (azimuth < 33.75)
- return CardinalNNE;
- else if (azimuth < 56.25)
- return CardinalNE;
- else if (azimuth < 78.75)
- return CardinalENE;
- else if (azimuth < 101.25)
- return CardinalE;
- else if (azimuth < 123.75)
- return CardinalESE;
- else if (azimuth < 146.25)
- return CardinalSE;
- else if (azimuth < 168.75)
- return CardinalSSE;
- else if (azimuth < 191.25)
- return CardinalS;
-
- else if (azimuth < 213.75)
- return CardinalSSW;
- else if (azimuth < 236.25)
- return CardinalSW;
- else if (azimuth < 258.75)
- return CardinalWSW;
- else if (azimuth < 281.25)
- return CardinalW;
- else if (azimuth < 303.75)
- return CardinalWNW;
- else if (azimuth < 326.25)
- return CardinalNW;
- else
- return CardinalNNW;
- }
-
- // For values exceeding +- 720.0
- inline static double wrapLongExt(double lng) {
- double remainder = fmod(lng + 180.0, 360.0);
- return fmod(remainder + 360.0, 360.0) - 180.0;
- }
-
- // Mirrors the azimuth against the X axis. Azimuth assumed to be in [0,360[
- inline static double mirrorAzimuthX(double azimuth) {
- if (azimuth <= 90.0)
- return 180.0 - azimuth;
- else
- return 180.0 + (360.0 - azimuth);
- }
-
- // Mirrors the azimuth against the Y axis. Azimuth assumed to be in [0,360[
- inline static double mirrorAzimuthY(double azimuth) {
- if (azimuth == 0.0)
- return 0.0;
- return 360.0 - azimuth;
- }
-
- inline static double radians(double degrees)
- {
- return qDegreesToRadians(degrees);
- }
-
- inline static double degrees(double radians)
- {
- return qRadiansToDegrees(radians);
- }
-
- inline static double earthMeanRadius()
- {
- return 6371007.2;
- }
-
- inline static double earthMeanCircumference()
- {
- return earthMeanRadius() * 2.0 * M_PI;
- }
-
- inline static double mercatorMaxLatitude()
- {
- return 85.05113;
- }
-
- inline static QGeoCoordinate antipodalPoint(const QGeoCoordinate &p)
- {
- return QGeoCoordinate(-p.latitude(), wrapLong(p.longitude() + 180.0));
- }
-
- // Leftmost longitude before wrapping kicks in
- inline static double mapLeftLongitude(double centerLongitude)
- {
- return wrapLong(centerLongitude + leftOffset);
- }
-
- // Rightmost longitude before wrapping kicks in
- inline static double mapRightLongitude(double centerLongitude)
- {
- return wrapLong(centerLongitude - leftOffset);
- }
-
- inline static void split_double(double input, float *hipart, float *lopart)
- {
- *hipart = (float) input;
- double delta = input - ((double) *hipart);
- *lopart = (float) delta;
- }
-
- static qreal metersPerPixel(qreal zoomLevel, const QGeoCoordinate &coordinate)
- {
- const qreal metersPerTile = earthMeanCircumference() * std::cos(radians(coordinate.latitude())) / std::pow(2, zoomLevel);
- return metersPerTile / 256.0;
- }
-
- /*
- returns the NMEA sentence type.
- */
- static NmeaSentence getNmeaSentenceType(const char *data, int size);
-
- /*
- Returns the satellite system type based on the message type.
- See https://gpsd.gitlab.io/gpsd/NMEA.html#_talker_ids for reference
- */
- static QGeoSatelliteInfo::SatelliteSystem getSatelliteSystem(const char *data, int size);
-
- /*
- Returns the satellite system type based on the satellite id.
- See https://gpsd.gitlab.io/gpsd/NMEA.html#_satellite_ids for reference
- */
- static QGeoSatelliteInfo::SatelliteSystem getSatelliteSystemBySatelliteId(int satId);
-
- /*
- Creates a QGeoPositionInfo from a GGA, GLL, RMC, VTG or ZDA sentence.
-
- Note:
- - GGA and GLL sentences have time but not date so the update's
- QDateTime object will have an invalid date.
- - RMC reports date with a two-digit year so in this case the year
- is assumed to be after the year 2000.
- */
- static bool getPosInfoFromNmea(const char *data,
- int size,
- QGeoPositionInfo *info, double uere,
- bool *hasFix = nullptr);
-
- /*
- Retruns a list of QGeoSatelliteInfo in the view.
-
- Note: this function has to be called repeatedly until it returns
- QNmeaSatelliteInfoSource::FullyParsed.
- Reason being that GSV sentences can be split into multiple samples, so
- getting the full data requires parsing multiple sentences.
- */
- static QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
- getSatInfoFromNmea(const char *data, int size, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system);
-
- /*
- Parses GSA for satellites in use.
-
- Returns satellite system type or QGeoSatelliteInfo::Undefined if parsing
- failed
- */
- static QGeoSatelliteInfo::SatelliteSystem getSatInUseFromNmea(const char *data, int size,
- QList<int> &pnrsInUse);
-
- /*
- Returns true if the given NMEA sentence has a valid checksum.
- */
- static bool hasValidNmeaChecksum(const char *data, int size);
-
- /*
- Returns time from a string in hhmmss or hhmmss.z+ format.
- */
- static bool getNmeaTime(const QByteArray &bytes, QTime *time);
-
- /*
- Accepts for example ("2734.7964", 'S', "15306.0124", 'E') and returns the
- lat-long values. Fails if lat or long fail isValidLat() or isValidLong().
- */
- static bool getNmeaLatLong(const QByteArray &latString,
- char latDirection,
- const QByteArray &lngString,
- char lngDirection,
- double *lat,
- double *lon);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qnmeapositioninfosource.cpp b/src/positioning/qnmeapositioninfosource.cpp
deleted file mode 100644
index 91f72241..00000000
--- a/src/positioning/qnmeapositioninfosource.cpp
+++ /dev/null
@@ -1,962 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Jolla Ltd.
-** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qnmeapositioninfosource_p.h"
-#include "qgeopositioninfo_p.h"
-#include "qlocationutils_p.h"
-
-#include <QIODevice>
-#include <QBasicTimer>
-#include <QTimerEvent>
-#include <QTimer>
-#include <array>
-#include <QDebug>
-#include <QtCore/QtNumeric>
-
-
-QT_BEGIN_NAMESPACE
-
-#define USE_NMEA_PIMPL 0
-
-#if USE_NMEA_PIMPL
-class QGeoPositionInfoPrivateNmea : public QGeoPositionInfoPrivate
-{
-public:
- virtual ~QGeoPositionInfoPrivateNmea();
-
- QList<QByteArray> nmeaSentences;
-};
-
-
-QGeoPositionInfoPrivateNmea::~QGeoPositionInfoPrivateNmea()
-{
-
-}
-#else
-typedef QGeoPositionInfoPrivate QGeoPositionInfoPrivateNmea;
-#endif
-
-static bool propagateCoordinate(QGeoPositionInfo &dst, const QGeoPositionInfo &src, bool force = true)
-{
- bool updated = false;
- QGeoCoordinate c = dst.coordinate();
- const QGeoCoordinate & srcCoordinate = src.coordinate();
- if (qIsFinite(src.coordinate().latitude())
- && (!qIsFinite(dst.coordinate().latitude()) || force)) {
- updated |= (c.latitude() != srcCoordinate.latitude());
- c.setLatitude(src.coordinate().latitude());
- }
- if (qIsFinite(src.coordinate().longitude())
- && (!qIsFinite(dst.coordinate().longitude()) || force)) {
- updated |= (c.longitude() != srcCoordinate.longitude());
- c.setLongitude(src.coordinate().longitude());
- }
- if (qIsFinite(src.coordinate().altitude())
- && (!qIsFinite(dst.coordinate().altitude()) || force)) {
- updated |= (c.altitude() != srcCoordinate.altitude());
- c.setAltitude(src.coordinate().altitude());
- }
- dst.setCoordinate(c);
- return updated;
-}
-
-static bool propagateDate(QGeoPositionInfo &dst, const QGeoPositionInfo &src)
-{
- if (!dst.timestamp().date().isValid() && src.timestamp().isValid()) { // time was supposed to be set/the same already. Date can be overwritten.
- dst.setTimestamp(src.timestamp());
- return true;
- }
- return false;
-}
-
-static bool propagateAttributes(QGeoPositionInfo &dst, const QGeoPositionInfo &src, bool force = true)
-{
- bool updated = false;
- static Q_DECL_CONSTEXPR std::array<QGeoPositionInfo::Attribute, 6> attrs {
- { QGeoPositionInfo::GroundSpeed
- ,QGeoPositionInfo::HorizontalAccuracy
- ,QGeoPositionInfo::VerticalAccuracy
- ,QGeoPositionInfo::Direction
- ,QGeoPositionInfo::VerticalSpeed
- ,QGeoPositionInfo::MagneticVariation} };
- for (const auto a: attrs) {
- if (src.hasAttribute(a) && (!dst.hasAttribute(a) || force)) {
- updated |= (dst.attribute(a) != src.attribute(a));
- dst.setAttribute(a, src.attribute(a));
- }
- }
-
- return updated;
-}
-
-// returns false if src does not contain any additional or different data than dst,
-// true otherwise.
-static bool mergePositions(QGeoPositionInfo &dst, const QGeoPositionInfo &src, QByteArray nmeaSentence)
-{
- bool updated = false;
-
- updated |= propagateCoordinate(dst, src);
- updated |= propagateDate(dst, src);
- updated |= propagateAttributes(dst, src);
-
-#if USE_NMEA_PIMPL
- QGeoPositionInfoPrivateNmea *dstPimpl = static_cast<QGeoPositionInfoPrivateNmea *>(QGeoPositionInfoPrivate::get(dst));
- dstPimpl->nmeaSentences.append(nmeaSentence);
-#else
- Q_UNUSED(nmeaSentence);
-#endif
- return updated;
-}
-
-static qint64 msecsTo(const QDateTime &from, const QDateTime &to)
-{
- if (!from.time().isValid() || !to.time().isValid())
- return 0;
-
- if (!from.date().isValid() || !to.date().isValid()) // use only time
- return from.time().msecsTo(to.time());
-
- return from.msecsTo(to);
-}
-
-QNmeaRealTimeReader::QNmeaRealTimeReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
- : QNmeaReader(sourcePrivate), m_update(*new QGeoPositionInfoPrivateNmea)
-{
- // An env var controlling the number of milliseconds to use to withold
- // an update and wait for additional data to combine.
- // The update will be pushed earlier than this if a newer update will be received.
- // The update will be withold longer than this amount of time if additional
- // valid data will keep arriving within this time frame.
- QByteArray pushDelay = qgetenv("QT_NMEA_PUSH_DELAY");
- if (!pushDelay.isEmpty())
- m_pushDelay = qBound(-1, QString::fromLatin1(pushDelay).toInt(), 1000);
- else
- m_pushDelay = 20;
-
- if (m_pushDelay >= 0) {
- m_timer.setSingleShot(true);
- m_timer.setInterval(m_pushDelay);
- m_timer.connect(&m_timer, &QTimer::timeout, [this]() {
- this->notifyNewUpdate();
- });
- }
-}
-
-void QNmeaRealTimeReader::readAvailableData()
-{
- while (m_proxy->m_device->canReadLine()) {
- const QTime infoTime = m_update.timestamp().time(); // if update has been set, time must be valid.
- const QDate infoDate = m_update.timestamp().date(); // this one might not be valid, as some sentences do not contain it
-
- QGeoPositionInfoPrivateNmea *pimpl = new QGeoPositionInfoPrivateNmea;
- QGeoPositionInfo pos(*pimpl);
-
- char buf[1024];
- qint64 size = m_proxy->m_device->readLine(buf, sizeof(buf));
- const bool oldFix = m_hasFix;
- bool hasFix;
- const bool parsed = m_proxy->parsePosInfoFromNmeaData(buf, size, &pos, &hasFix);
-
- if (!parsed) {
- // got garbage, don't stop the timer
- continue;
- }
-
- m_hasFix |= hasFix;
- m_updateParsed = true;
-
- // Date may or may not be valid, as some packets do not have date.
- // If date isn't valid, match is performed on time only.
- // Hence, make sure that packet blocks are generated with
- // the sentences containing the full timestamp (e.g., GPRMC) *first* !
- if (infoTime.isValid()) {
- if (pos.timestamp().time().isValid()) {
- const bool newerTime = infoTime < pos.timestamp().time();
- const bool newerDate = (infoDate.isValid() // if time is valid but one date or both are not,
- && pos.timestamp().date().isValid()
- && infoDate < pos.timestamp().date());
- if (newerTime || newerDate) {
- // Effectively read data for different update, that is also newer,
- // so flush retained update, and copy the new pos into m_update
- const QDate updateDate = m_update.timestamp().date();
- const QDate lastPushedDate = m_lastPushedTS.date();
- const bool newerTimestampSinceLastPushed = m_update.timestamp() > m_lastPushedTS;
- const bool invalidDate = !(updateDate.isValid() && lastPushedDate.isValid());
- const bool newerTimeSinceLastPushed = m_update.timestamp().time() > m_lastPushedTS.time();
- if ( newerTimestampSinceLastPushed || (invalidDate && newerTimeSinceLastPushed)) {
- m_proxy->notifyNewUpdate(&m_update, oldFix);
- m_lastPushedTS = m_update.timestamp();
- }
- m_timer.stop();
- // next update data
- propagateAttributes(pos, m_update, false);
- m_update = pos;
- m_hasFix = hasFix;
- } else {
- if (infoTime == pos.timestamp().time())
- // timestamps match -- merge into m_update
- if (mergePositions(m_update, pos, QByteArray(buf, size))) {
- // Reset the timer only if new info has been received.
- // Else the source might be keep repeating outdated info until
- // new info become available.
- m_timer.stop();
- }
- // else discard out of order outdated info.
- }
- } else {
- // no timestamp available in parsed update-- merge into m_update
- if (mergePositions(m_update, pos, QByteArray(buf, size)))
- m_timer.stop();
- }
- } else {
- // there was no info with valid TS. Overwrite with whatever is parsed.
-#if USE_NMEA_PIMPL
- pimpl->nmeaSentences.append(QByteArray(buf, size));
-#endif
- propagateAttributes(pos, m_update);
- m_update = pos;
- m_timer.stop();
- }
- }
-
- if (m_updateParsed) {
- if (m_pushDelay < 0)
- notifyNewUpdate();
- else
- m_timer.start();
- }
-}
-
-void QNmeaRealTimeReader::notifyNewUpdate()
-{
- const bool newerTime = m_update.timestamp().time() > m_lastPushedTS.time();
- const bool newerDate = (m_update.timestamp().date().isValid()
- && m_lastPushedTS.date().isValid()
- && m_update.timestamp().date() > m_lastPushedTS.date());
- if (newerTime || newerDate) {
- m_proxy->notifyNewUpdate(&m_update, m_hasFix);
- m_lastPushedTS = m_update.timestamp();
- }
- m_timer.stop();
-}
-
-
-//============================================================
-
-QNmeaSimulatedReader::QNmeaSimulatedReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
- : QNmeaReader(sourcePrivate),
- m_currTimerId(-1),
- m_hasValidDateTime(false)
-{
-}
-
-QNmeaSimulatedReader::~QNmeaSimulatedReader()
-{
- if (m_currTimerId > 0)
- killTimer(m_currTimerId);
-}
-
-void QNmeaSimulatedReader::readAvailableData()
-{
- if (m_currTimerId > 0) // we are already reading
- return;
-
- if (!m_hasValidDateTime) { // first update
- Q_ASSERT(m_proxy->m_device && (m_proxy->m_device->openMode() & QIODevice::ReadOnly));
-
- if (!setFirstDateTime()) {
- //m_proxy->notifyReachedEndOfFile();
- qWarning("QNmeaPositionInfoSource: cannot find NMEA sentence with valid date & time");
- return;
- }
-
- m_hasValidDateTime = true;
- simulatePendingUpdate();
-
- } else {
- // previously read to EOF, but now new data has arrived
- processNextSentence();
- }
-}
-
-static int processSentence(QGeoPositionInfo &info,
- QByteArray &m_nextLine,
- QNmeaPositionInfoSourcePrivate *m_proxy,
- QQueue<QPendingGeoPositionInfo> &m_pendingUpdates,
- bool &hasFix)
-{
- int timeToNextUpdate = -1;
- QDateTime prevTs;
- if (m_pendingUpdates.size() > 0)
- prevTs = m_pendingUpdates.head().info.timestamp();
-
- // find the next update with a valid time (as long as the time is valid,
- // we can calculate when the update should be emitted)
- while (m_nextLine.size() || (m_proxy->m_device && m_proxy->m_device->bytesAvailable() > 0)) {
- char static_buf[1024];
- char *buf = static_buf;
- QByteArray nextLine;
- qint64 size = 0;
- if (m_nextLine.size()) {
- // Read something in the previous call, but TS was later.
- size = m_nextLine.size();
- nextLine = m_nextLine;
- m_nextLine.clear();
- buf = nextLine.data();
- } else {
- size = m_proxy->m_device->readLine(buf, sizeof(static_buf));
- }
-
- if (size <= 0)
- continue;
-
- const QTime infoTime = info.timestamp().time(); // if info has been set, time must be valid.
- const QDate infoDate = info.timestamp().date(); // this one might not be valid, as some sentences do not contain it
-
- /*
- Packets containing time information are GGA, RMC, ZDA, GLL:
-
- GGA : GPS fix data - only time
- GLL : geographic latitude and longitude - only time
- RMC : recommended minimum FPOS/transit data - date and time
- ZDA : only timestamp - date and time
-
- QLocationUtils is currently also capable of parsing VTG and GSA sentences:
-
- VTG: containing Track made good and ground speed
- GSA: overall satellite data, w. accuracies (ends up into PositionInfo)
-
- Since these sentences contain no timestamp, their content will be merged with the content
- from any prior sentence that had timestamp info, if any is available.
- */
-
- QGeoPositionInfoPrivateNmea *pimpl = new QGeoPositionInfoPrivateNmea;
- QGeoPositionInfo pos(*pimpl);
- if (m_proxy->parsePosInfoFromNmeaData(buf, size, &pos, &hasFix)) {
- // Date may or may not be valid, as some packets do not have date.
- // If date isn't valid, match is performed on time only.
- // Hence, make sure that packet blocks are generated with
- // the sentences containing the full timestamp (e.g., GPRMC) *first* !
- if (infoTime.isValid()) {
- if (pos.timestamp().time().isValid()) {
- const bool newerTime = infoTime < pos.timestamp().time();
- const bool newerDate = (infoDate.isValid() // if time is valid but one date or both are not,
- && pos.timestamp().date().isValid()
- && infoDate < pos.timestamp().date());
- if (newerTime || newerDate) {
- // Effectively read data for different update, that is also newer, so copy buf into m_nextLine
- m_nextLine = QByteArray(buf, size);
- break;
- } else {
- if (infoTime == pos.timestamp().time())
- // timestamps match -- merge into info
- mergePositions(info, pos, QByteArray(buf, size));
- // else discard out of order outdated info.
- }
- } else {
- // no timestamp available -- merge into info
- mergePositions(info, pos, QByteArray(buf, size));
- }
- } else {
- // there was no info with valid TS. Overwrite with whatever is parsed.
-#if USE_NMEA_PIMPL
- pimpl->nmeaSentences.append(QByteArray(buf, size));
-#endif
- info = pos;
- }
-
- if (prevTs.time().isValid()) {
- timeToNextUpdate = msecsTo(prevTs, info.timestamp());
- if (timeToNextUpdate < 0) // Somehow parsing expired packets, reset info
- info = QGeoPositionInfo(*new QGeoPositionInfoPrivateNmea);
- }
- }
- }
-
- return timeToNextUpdate;
-}
-
-bool QNmeaSimulatedReader::setFirstDateTime()
-{
- // find the first update with valid date and time
- QGeoPositionInfo info(*new QGeoPositionInfoPrivateNmea);
- bool hasFix = false;
- processSentence(info, m_nextLine, m_proxy, m_pendingUpdates, hasFix);
-
- if (info.timestamp().time().isValid()) { // NMEA may have sentences with only time and no date. These would generate invalid positions
- QPendingGeoPositionInfo pending;
- pending.info = info;
- pending.hasFix = hasFix;
- m_pendingUpdates.enqueue(pending);
- return true;
- }
- return false;
-}
-
-void QNmeaSimulatedReader::simulatePendingUpdate()
-{
- if (m_pendingUpdates.size() > 0) {
- // will be dequeued in processNextSentence()
- QPendingGeoPositionInfo &pending = m_pendingUpdates.head();
- m_proxy->notifyNewUpdate(&pending.info, pending.hasFix);
- }
-
- processNextSentence();
-}
-
-void QNmeaSimulatedReader::timerEvent(QTimerEvent *event)
-{
- killTimer(event->timerId());
- m_currTimerId = -1;
- simulatePendingUpdate();
-}
-
-void QNmeaSimulatedReader::processNextSentence()
-{
- QGeoPositionInfo info(*new QGeoPositionInfoPrivateNmea);
- bool hasFix = false;
-
- int timeToNextUpdate = processSentence(info, m_nextLine, m_proxy, m_pendingUpdates, hasFix);
- if (timeToNextUpdate < 0)
- return;
-
- m_pendingUpdates.dequeue();
-
- QPendingGeoPositionInfo pending;
- pending.info = info;
- pending.hasFix = hasFix;
- m_pendingUpdates.enqueue(pending);
- m_currTimerId = startTimer(timeToNextUpdate);
-}
-
-
-//============================================================
-
-
-QNmeaPositionInfoSourcePrivate::QNmeaPositionInfoSourcePrivate(QNmeaPositionInfoSource *parent, QNmeaPositionInfoSource::UpdateMode updateMode)
- : QObject(parent),
- m_updateMode(updateMode),
- m_device(0),
- m_invokedStart(false),
- m_positionError(QGeoPositionInfoSource::UnknownSourceError),
- m_userEquivalentRangeError(qQNaN()),
- m_source(parent),
- m_nmeaReader(0),
- m_updateTimer(0),
- m_requestTimer(0),
- m_horizontalAccuracy(qQNaN()),
- m_verticalAccuracy(qQNaN()),
- m_noUpdateLastInterval(false),
- m_updateTimeoutSent(false),
- m_connectedReadyRead(false)
-{
-}
-
-QNmeaPositionInfoSourcePrivate::~QNmeaPositionInfoSourcePrivate()
-{
- delete m_nmeaReader;
- delete m_updateTimer;
-}
-
-bool QNmeaPositionInfoSourcePrivate::openSourceDevice()
-{
- if (!m_device) {
- qWarning("QNmeaPositionInfoSource: no QIODevice data source, call setDevice() first");
- return false;
- }
-
- if (!m_device->isOpen() && !m_device->open(QIODevice::ReadOnly)) {
- qWarning("QNmeaPositionInfoSource: cannot open QIODevice data source");
- return false;
- }
-
- connect(m_device, SIGNAL(aboutToClose()), SLOT(sourceDataClosed()));
- connect(m_device, SIGNAL(readChannelFinished()), SLOT(sourceDataClosed()));
- connect(m_device, SIGNAL(destroyed()), SLOT(sourceDataClosed()));
-
- return true;
-}
-
-void QNmeaPositionInfoSourcePrivate::sourceDataClosed()
-{
- if (m_nmeaReader && m_device && m_device->bytesAvailable())
- m_nmeaReader->readAvailableData();
-}
-
-void QNmeaPositionInfoSourcePrivate::readyRead()
-{
- if (m_nmeaReader)
- m_nmeaReader->readAvailableData();
-}
-
-bool QNmeaPositionInfoSourcePrivate::initialize()
-{
- if (m_nmeaReader)
- return true;
-
- if (!openSourceDevice())
- return false;
-
- if (m_updateMode == QNmeaPositionInfoSource::RealTimeMode)
- m_nmeaReader = new QNmeaRealTimeReader(this);
- else
- m_nmeaReader = new QNmeaSimulatedReader(this);
-
- return true;
-}
-
-void QNmeaPositionInfoSourcePrivate::prepareSourceDevice()
-{
- // some data may already be available
- if (m_updateMode == QNmeaPositionInfoSource::SimulationMode) {
- if (m_nmeaReader && m_device->bytesAvailable())
- m_nmeaReader->readAvailableData();
- }
-
- if (!m_connectedReadyRead) {
- connect(m_device, SIGNAL(readyRead()), SLOT(readyRead()));
- m_connectedReadyRead = true;
- }
-}
-
-bool QNmeaPositionInfoSourcePrivate::parsePosInfoFromNmeaData(const char *data, int size,
- QGeoPositionInfo *posInfo, bool *hasFix)
-{
- return m_source->parsePosInfoFromNmeaData(data, size, posInfo, hasFix);
-}
-
-void QNmeaPositionInfoSourcePrivate::startUpdates()
-{
- if (m_invokedStart)
- return;
-
- m_positionError = QGeoPositionInfoSource::NoError;
-
- m_invokedStart = true;
- m_pendingUpdate = QGeoPositionInfo();
- m_noUpdateLastInterval = false;
-
- bool initialized = initialize();
- if (!initialized) {
- m_source->setError(QGeoPositionInfoSource::AccessError);
- return;
- }
-
- if (m_updateMode == QNmeaPositionInfoSource::RealTimeMode) {
- // skip over any buffered data - we only want the newest data.
- // Don't do this in requestUpdate. In that case bufferedData is good to have/use.
- if (m_device->bytesAvailable()) {
- if (m_device->isSequential())
- m_device->readAll();
- else
- m_device->seek(m_device->bytesAvailable());
- }
- }
-
- if (m_updateTimer)
- m_updateTimer->stop();
-
- if (m_source->updateInterval() > 0) {
- if (!m_updateTimer)
- m_updateTimer = new QBasicTimer;
- m_updateTimer->start(m_source->updateInterval(), this);
- }
-
- if (initialized)
- prepareSourceDevice();
-}
-
-void QNmeaPositionInfoSourcePrivate::stopUpdates()
-{
- m_invokedStart = false;
- if (m_updateTimer)
- m_updateTimer->stop();
- m_pendingUpdate = QGeoPositionInfo();
- m_noUpdateLastInterval = false;
-}
-
-void QNmeaPositionInfoSourcePrivate::requestUpdate(int msec)
-{
- if (m_requestTimer && m_requestTimer->isActive())
- return;
-
- m_positionError = QGeoPositionInfoSource::NoError;
-
- if (msec <= 0 || msec < m_source->minimumUpdateInterval()) {
- m_source->setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- if (!m_requestTimer) {
- m_requestTimer = new QTimer(this);
- connect(m_requestTimer, SIGNAL(timeout()), SLOT(updateRequestTimeout()));
- }
-
- bool initialized = initialize();
- if (!initialized) {
- m_source->setError(QGeoPositionInfoSource::UpdateTimeoutError);
- return;
- }
-
- m_requestTimer->start(msec);
- prepareSourceDevice();
-}
-
-void QNmeaPositionInfoSourcePrivate::updateRequestTimeout()
-{
- m_requestTimer->stop();
- m_source->setError(QGeoPositionInfoSource::UpdateTimeoutError);
-}
-
-void QNmeaPositionInfoSourcePrivate::notifyNewUpdate(QGeoPositionInfo *update, bool hasFix)
-{
- // include <QDebug> before uncommenting
- //qDebug() << "QNmeaPositionInfoSourcePrivate::notifyNewUpdate()" << update->timestamp() << hasFix << m_invokedStart << (m_requestTimer && m_requestTimer->isActive());
-
- QDate date = update->timestamp().date();
- if (date.isValid()) {
- m_currentDate = date;
- } else {
- // some sentence have time but no date
- QTime time = update->timestamp().time();
- if (time.isValid() && m_currentDate.isValid())
- update->setTimestamp(QDateTime(m_currentDate, time, Qt::UTC));
- }
-
- // Some attributes are sent in separate NMEA sentences. Save and restore the accuracy
- // measurements.
- if (update->hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
- m_horizontalAccuracy = update->attribute(QGeoPositionInfo::HorizontalAccuracy);
- else if (!qIsNaN(m_horizontalAccuracy))
- update->setAttribute(QGeoPositionInfo::HorizontalAccuracy, m_horizontalAccuracy);
-
- if (update->hasAttribute(QGeoPositionInfo::VerticalAccuracy))
- m_verticalAccuracy = update->attribute(QGeoPositionInfo::VerticalAccuracy);
- else if (!qIsNaN(m_verticalAccuracy))
- update->setAttribute(QGeoPositionInfo::VerticalAccuracy, m_verticalAccuracy);
-
- if (hasFix && update->isValid()) {
- if (m_requestTimer && m_requestTimer->isActive()) { // User called requestUpdate()
- m_requestTimer->stop();
- emitUpdated(*update);
- } else if (m_invokedStart) { // user called startUpdates()
- if (m_updateTimer && m_updateTimer->isActive()) { // update interval > 0
- // for periodic updates, only want the most recent update
- m_pendingUpdate = *update; // Set what to send in timerEvent()
- if (m_noUpdateLastInterval) {
- // if the update was invalid when timerEvent was last called, a valid update
- // should be sent ASAP
- emitPendingUpdate();
- m_noUpdateLastInterval = false;
- }
- } else { // update interval <= 0
- emitUpdated(*update);
- }
- }
- m_lastUpdate = *update; // Set in any case, if update is valid. Used in lastKnownPosition().
- }
-}
-
-void QNmeaPositionInfoSourcePrivate::timerEvent(QTimerEvent *)
-{
- emitPendingUpdate();
-}
-
-void QNmeaPositionInfoSourcePrivate::emitPendingUpdate()
-{
- if (m_pendingUpdate.isValid()) {
- m_updateTimeoutSent = false;
- m_noUpdateLastInterval = false;
- emitUpdated(m_pendingUpdate);
- m_pendingUpdate = QGeoPositionInfo();
- } else { // invalid update
- if (m_noUpdateLastInterval && !m_updateTimeoutSent) {
- m_updateTimeoutSent = true;
- m_pendingUpdate = QGeoPositionInfo(); // Invalid already, but clear just in case.
- m_source->setError(QGeoPositionInfoSource::UpdateTimeoutError);
- }
- m_noUpdateLastInterval = true;
- }
-}
-
-void QNmeaPositionInfoSourcePrivate::emitUpdated(const QGeoPositionInfo &update)
-{
- // check for duplication already done in QNmeaRealTimeReader::notifyNewUpdate
- // and QNmeaRealTimeReader::readAvailableData
- m_lastUpdate = update;
- emit m_source->positionUpdated(update);
-}
-
-//=========================================================
-
-/*!
- \class QNmeaPositionInfoSource
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 5.2
-
- \brief The QNmeaPositionInfoSource class provides positional information using a NMEA data source.
-
- NMEA is a commonly used protocol for the specification of one's global
- position at a certain point in time. The QNmeaPositionInfoSource class reads NMEA
- data and uses it to provide positional data in the form of
- QGeoPositionInfo objects.
-
- A QNmeaPositionInfoSource instance operates in either \l {RealTimeMode} or
- \l {SimulationMode}. These modes allow NMEA data to be read from either a
- live source of positional data, or replayed for simulation purposes from
- previously recorded NMEA data.
-
- The source of NMEA data is set with setDevice().
-
- Use startUpdates() to start receiving regular position updates and stopUpdates() to stop these
- updates. If you only require updates occasionally, you can call requestUpdate() to request a
- single update.
-
- In both cases the position information is received via the positionUpdated() signal and the
- last known position can be accessed with lastKnownPosition().
-
- QNmeaPositionInfoSource supports reporting the accuracy of the horizontal and vertical position.
- To enable position accuracy reporting an estimate of the User Equivalent Range Error associated
- with the NMEA source must be set with setUserEquivalentRangeError().
-*/
-
-
-/*!
- \enum QNmeaPositionInfoSource::UpdateMode
- Defines the available update modes.
-
- \value RealTimeMode Positional data is read and distributed from the data source as it becomes available. Use this mode if you are using a live source of positional data (for example, a GPS hardware device).
- \value SimulationMode The data and time information in the NMEA source data is used to provide positional updates at the rate at which the data was originally recorded. Use this mode if the data source contains previously recorded NMEA data and you want to replay the data for simulation purposes.
-*/
-
-
-/*!
- Constructs a QNmeaPositionInfoSource instance with the given \a parent
- and \a updateMode.
-*/
-QNmeaPositionInfoSource::QNmeaPositionInfoSource(UpdateMode updateMode, QObject *parent)
- : QGeoPositionInfoSource(parent),
- d(new QNmeaPositionInfoSourcePrivate(this, updateMode))
-{
-}
-
-/*!
- Destroys the position source.
-*/
-QNmeaPositionInfoSource::~QNmeaPositionInfoSource()
-{
- delete d;
-}
-
-/*!
- Sets the User Equivalent Range Error (UERE) to \a uere. The UERE is used in calculating an
- estimate of the accuracy of the position information reported by the position info source. The
- UERE should be set to a value appropriate for the GPS device which generated the NMEA stream.
-
- The true UERE value is calculated from multiple error sources including errors introduced by
- the satellites and signal propogation delays through the atmosphere as well as errors
- introduced by the receiving GPS equipment. For details on GPS accuracy see
- \l {https://web.archive.org/web/20161212144906if_/http://edu-observatory.org/gps/gps_accuracy.html} {Sam J. Wormley, GPS Errors & Estimating Your Reveiver's Accuracy}.
-
- A typical value for UERE is approximately 5.1.
-
- \since 5.3
-
- \sa userEquivalentRangeError()
-*/
-void QNmeaPositionInfoSource::setUserEquivalentRangeError(double uere)
-{
- d->m_userEquivalentRangeError = uere;
-}
-
-/*!
- Returns the current User Equivalent Range Error (UERE). The UERE is used in calculating an
- estimate of the accuracy of the position information reported by the position info source. The
- default value is NaN which means no accuracy information will be provided.
-
- \since 5.3
-
- \sa setUserEquivalentRangeError()
-*/
-double QNmeaPositionInfoSource::userEquivalentRangeError() const
-{
- return d->m_userEquivalentRangeError;
-}
-
-/*!
- Parses an NMEA sentence string into a QGeoPositionInfo.
-
- The default implementation will parse standard NMEA sentences.
- This method should be reimplemented in a subclass whenever the need to deal with non-standard
- NMEA sentences arises.
-
- The parser reads \a size bytes from \a data and uses that information to setup \a posInfo and
- \a hasFix. If \a hasFix is set to false then \a posInfo may contain only the time or the date
- and the time.
-
- Returns true if the sentence was successfully parsed, otherwise returns false and should not
- modifiy \a posInfo or \a hasFix.
-*/
-bool QNmeaPositionInfoSource::parsePosInfoFromNmeaData(const char *data, int size,
- QGeoPositionInfo *posInfo, bool *hasFix)
-{
- return QLocationUtils::getPosInfoFromNmea(data, size, posInfo, d->m_userEquivalentRangeError,
- hasFix);
-}
-
-/*!
- Returns the update mode.
-*/
-QNmeaPositionInfoSource::UpdateMode QNmeaPositionInfoSource::updateMode() const
-{
- return d->m_updateMode;
-}
-
-/*!
- Sets the NMEA data source to \a device. If the device is not open, it
- will be opened in QIODevice::ReadOnly mode.
-
- The source device can only be set once and must be set before calling
- startUpdates() or requestUpdate().
-
- \b {Note:} The \a device must emit QIODevice::readyRead() for the
- source to be notified when data is available for reading.
- QNmeaPositionInfoSource does not assume the ownership of the device,
- and hence does not deallocate it upon destruction.
-*/
-void QNmeaPositionInfoSource::setDevice(QIODevice *device)
-{
- if (device != d->m_device) {
- if (!d->m_device)
- d->m_device = device;
- else
- qWarning("QNmeaPositionInfoSource: source device has already been set");
- }
-}
-
-/*!
- Returns the NMEA data source.
-*/
-QIODevice *QNmeaPositionInfoSource::device() const
-{
- return d->m_device;
-}
-
-/*!
- \reimp
-*/
-void QNmeaPositionInfoSource::setUpdateInterval(int msec)
-{
- int interval = msec;
- if (interval != 0)
- interval = qMax(msec, minimumUpdateInterval());
- QGeoPositionInfoSource::setUpdateInterval(interval);
- if (d->m_invokedStart) {
- d->stopUpdates();
- d->startUpdates();
- }
-}
-
-/*!
- \reimp
-*/
-void QNmeaPositionInfoSource::startUpdates()
-{
- d->startUpdates();
-}
-
-/*!
- \reimp
-*/
-void QNmeaPositionInfoSource::stopUpdates()
-{
- d->stopUpdates();
-}
-
-/*!
- \reimp
-*/
-void QNmeaPositionInfoSource::requestUpdate(int msec)
-{
- d->requestUpdate(msec == 0 ? 60000 * 5 : msec); // 5min default timeout
-}
-
-/*!
- \reimp
-*/
-QGeoPositionInfo QNmeaPositionInfoSource::lastKnownPosition(bool) const
-{
- // the bool value does not matter since we only use satellite positioning
- return d->m_lastUpdate;
-}
-
-/*!
- \reimp
-*/
-QGeoPositionInfoSource::PositioningMethods QNmeaPositionInfoSource::supportedPositioningMethods() const
-{
- return SatellitePositioningMethods;
-}
-
-/*!
- \reimp
-*/
-int QNmeaPositionInfoSource::minimumUpdateInterval() const
-{
- return 2; // Some chips are capable of over 100 updates per seconds.
-}
-
-/*!
- \reimp
-*/
-QGeoPositionInfoSource::Error QNmeaPositionInfoSource::error() const
-{
- return d->m_positionError;
-}
-
-void QNmeaPositionInfoSource::setError(QGeoPositionInfoSource::Error positionError)
-{
- d->m_positionError = positionError;
- if (d->m_positionError != QGeoPositionInfoSource::NoError)
- emit QGeoPositionInfoSource::errorOccurred(positionError);
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qnmeapositioninfosource.h b/src/positioning/qnmeapositioninfosource.h
deleted file mode 100644
index 79a52361..00000000
--- a/src/positioning/qnmeapositioninfosource.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QNMEAPOSITIONINFOSOURCE_H
-#define QNMEAPOSITIONINFOSOURCE_H
-
-#include <QtPositioning/QGeoPositionInfoSource>
-
-QT_BEGIN_NAMESPACE
-
-class QIODevice;
-
-class QNmeaPositionInfoSourcePrivate;
-class Q_POSITIONING_EXPORT QNmeaPositionInfoSource : public QGeoPositionInfoSource
-{
- Q_OBJECT
-public:
- enum UpdateMode {
- RealTimeMode = 1,
- SimulationMode
- };
-
- explicit QNmeaPositionInfoSource(UpdateMode updateMode, QObject *parent = nullptr);
- ~QNmeaPositionInfoSource();
-
- void setUserEquivalentRangeError(double uere);
- double userEquivalentRangeError() const;
-
- UpdateMode updateMode() const;
-
- void setDevice(QIODevice *source);
- QIODevice *device() const;
-
- void setUpdateInterval(int msec) override;
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
- PositioningMethods supportedPositioningMethods() const override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
-
-public Q_SLOTS:
- void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 0) override;
-
-protected:
- virtual bool parsePosInfoFromNmeaData(const char *data,
- int size,
- QGeoPositionInfo *posInfo,
- bool *hasFix);
- void setError(QGeoPositionInfoSource::Error positionError);
-
-private:
- Q_DISABLE_COPY(QNmeaPositionInfoSource)
- friend class QNmeaPositionInfoSourcePrivate;
- QNmeaPositionInfoSourcePrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qnmeapositioninfosource_p.h b/src/positioning/qnmeapositioninfosource_p.h
deleted file mode 100644
index 9874f3fd..00000000
--- a/src/positioning/qnmeapositioninfosource_p.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QNMEAPOSITIONINFOSOURCE_P_H
-#define QNMEAPOSITIONINFOSOURCE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qnmeapositioninfosource.h"
-#include "qgeopositioninfo.h"
-
-#include <QObject>
-#include <QQueue>
-#include <QPointer>
-#include <QtCore/qtimer.h>
-
-QT_BEGIN_NAMESPACE
-
-class QBasicTimer;
-class QTimerEvent;
-class QTimer;
-
-class QNmeaReader;
-struct QPendingGeoPositionInfo
-{
- QGeoPositionInfo info;
- bool hasFix;
-};
-
-
-class QNmeaPositionInfoSourcePrivate : public QObject
-{
- Q_OBJECT
-public:
- QNmeaPositionInfoSourcePrivate(QNmeaPositionInfoSource *parent, QNmeaPositionInfoSource::UpdateMode updateMode);
- ~QNmeaPositionInfoSourcePrivate();
-
- void startUpdates();
- void stopUpdates();
- void requestUpdate(int msec);
-
- bool parsePosInfoFromNmeaData(const char *data,
- int size,
- QGeoPositionInfo *posInfo,
- bool *hasFix);
-
- void notifyNewUpdate(QGeoPositionInfo *update, bool fixStatus);
-
- QNmeaPositionInfoSource::UpdateMode m_updateMode;
- QPointer<QIODevice> m_device;
- QGeoPositionInfo m_lastUpdate;
- bool m_invokedStart;
- QGeoPositionInfoSource::Error m_positionError;
- double m_userEquivalentRangeError;
-
-public Q_SLOTS:
- void readyRead();
-
-protected:
- void timerEvent(QTimerEvent *event) override;
-
-private Q_SLOTS:
- void emitPendingUpdate();
- void sourceDataClosed();
- void updateRequestTimeout();
-
-private:
- bool openSourceDevice();
- bool initialize();
- void prepareSourceDevice();
- void emitUpdated(const QGeoPositionInfo &update);
-
- QNmeaPositionInfoSource *m_source;
- QNmeaReader *m_nmeaReader;
- QGeoPositionInfo m_pendingUpdate;
- QDate m_currentDate;
- QBasicTimer *m_updateTimer; // the timer used in startUpdates()
- QTimer *m_requestTimer; // the timer used in requestUpdate()
- qreal m_horizontalAccuracy;
- qreal m_verticalAccuracy;
- bool m_noUpdateLastInterval;
- bool m_updateTimeoutSent;
- bool m_connectedReadyRead;
-};
-
-
-class QNmeaReader
-{
-public:
- explicit QNmeaReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
- : m_proxy(sourcePrivate) {}
- virtual ~QNmeaReader() {}
-
- virtual void readAvailableData() = 0;
-
-protected:
- QNmeaPositionInfoSourcePrivate *m_proxy;
-};
-
-
-class QNmeaRealTimeReader : public QNmeaReader
-{
-public:
- explicit QNmeaRealTimeReader(QNmeaPositionInfoSourcePrivate *sourcePrivate);
- void readAvailableData() override;
- void notifyNewUpdate();
-
- // Data members
- QGeoPositionInfo m_update;
- QDateTime m_lastPushedTS;
- bool m_updateParsed = false;
- bool m_hasFix = false;
- QTimer m_timer;
- int m_pushDelay = -1;
-};
-
-
-class QNmeaSimulatedReader : public QObject, public QNmeaReader
-{
- Q_OBJECT
-public:
- explicit QNmeaSimulatedReader(QNmeaPositionInfoSourcePrivate *sourcePrivate);
- ~QNmeaSimulatedReader();
- void readAvailableData() override;
-
-protected:
- void timerEvent(QTimerEvent *event) override;
-
-private Q_SLOTS:
- void simulatePendingUpdate();
-
-private:
- bool setFirstDateTime();
- void processNextSentence();
-
- QQueue<QPendingGeoPositionInfo> m_pendingUpdates;
- QByteArray m_nextLine;
- int m_currTimerId;
- bool m_hasValidDateTime;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qnmeasatelliteinfosource.cpp b/src/positioning/qnmeasatelliteinfosource.cpp
deleted file mode 100644
index a27ac2b0..00000000
--- a/src/positioning/qnmeasatelliteinfosource.cpp
+++ /dev/null
@@ -1,909 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qnmeasatelliteinfosource.h"
-#include "private/qnmeasatelliteinfosource_p.h"
-#include <QtPositioning/private/qgeosatelliteinfo_p.h>
-#include <QtPositioning/private/qgeosatelliteinfosource_p.h>
-#include <QtPositioning/private/qlocationutils_p.h>
-
-#include <QIODevice>
-#include <QBasicTimer>
-#include <QTimerEvent>
-#include <QTimer>
-#include <array>
-#include <QDebug>
-#include <QtCore/QtNumeric>
-
-QT_BEGIN_NAMESPACE
-
-#if USE_NMEA_PIMPL
-class QGeoSatelliteInfoPrivateNmea : public QGeoSatelliteInfoPrivate
-{
-public:
- QGeoSatelliteInfoPrivateNmea(const QGeoSatelliteInfoPrivate &other);
- QGeoSatelliteInfoPrivateNmea(const QGeoSatelliteInfoPrivateNmea &other);
- virtual ~QGeoSatelliteInfoPrivateNmea();
-
- QList<QByteArray> nmeaSentences;
-};
-
-QGeoSatelliteInfoPrivateNmea::QGeoSatelliteInfoPrivateNmea(const QGeoSatelliteInfoPrivate &other)
- : QGeoSatelliteInfoPrivate(other)
-{
-}
-
-QGeoSatelliteInfoPrivateNmea::QGeoSatelliteInfoPrivateNmea(const QGeoSatelliteInfoPrivateNmea &other)
- : QGeoSatelliteInfoPrivate(other)
-{
- nmeaSentences = other.nmeaSentences;
-}
-
-QGeoSatelliteInfoPrivateNmea::~QGeoSatelliteInfoPrivateNmea() {}
-#else
-typedef QGeoSatelliteInfoPrivate QGeoSatelliteInfoPrivateNmea;
-#endif
-
-QNmeaSatelliteInfoSourcePrivate::QNmeaSatelliteInfoSourcePrivate(QNmeaSatelliteInfoSource *parent, QNmeaSatelliteInfoSource::UpdateMode updateMode)
- : m_source(parent),
- m_updateMode(updateMode)
-{
-}
-
-void QNmeaSatelliteInfoSourcePrivate::notifyNewUpdate()
-{
- if (m_pendingUpdate.isValid() && m_pendingUpdate.isFresh()) {
- if (m_requestTimer && m_requestTimer->isActive()) { // User called requestUpdate()
- m_requestTimer->stop();
- emitUpdated(m_pendingUpdate, true);
- } else if (m_invokedStart) { // user called startUpdates()
- if (m_updateTimer && m_updateTimer->isActive()) { // update interval > 0
- // for periodic updates, only want the most recent update
- if (m_noUpdateLastInterval) {
- // if the update was invalid when timerEvent was last called, a valid update
- // should be sent ASAP
- emitPendingUpdate(); // m_noUpdateLastInterval handled in there.
- }
- } else { // update interval <= 0, send anything new ASAP
- m_noUpdateLastInterval = !emitUpdated(m_pendingUpdate, false);
- }
- }
- }
-}
-
-void QNmeaSatelliteInfoSourcePrivate::processNmeaData(QNmeaSatelliteInfoUpdate &updateInfo)
-{
- char buf[1024];
- qint64 size = m_device->readLine(buf, sizeof(buf));
- QList<int> satInUse;
- const auto satSystemType = m_source->parseSatellitesInUseFromNmea(buf, size, satInUse);
- if (satSystemType != QGeoSatelliteInfo::Undefined) {
- const bool res = updateInfo.setSatellitesInUse(satSystemType, satInUse);
-#if USE_NMEA_PIMPL
- if (res) {
- updateInfo.gsa = QByteArray(buf, size);
- auto &info = updateInfo.m_satellites[satSystemType];
- if (info.satellitesInUse.size()) {
- for (auto &s : info.satellitesInUse) {
- static_cast<QGeoSatelliteInfoPrivateNmea *>(QGeoSatelliteInfoPrivate::get(s))
- ->nmeaSentences.append(updateInfo.gsa);
- }
- for (auto &s : info.satellitesInView) {
- static_cast<QGeoSatelliteInfoPrivateNmea *>(QGeoSatelliteInfoPrivate::get(s))
- ->nmeaSentences.append(updateInfo.gsa);
- }
- }
- }
-#else
- Q_UNUSED(res)
-#endif // USE_NMEA_PIMPL
- } else {
- // Here we have the assumption that multiple parts of GSV sentence
- // come one after another. At least this is how it should be.
- auto systemType = QGeoSatelliteInfo::Undefined;
- const auto parserStatus = m_source->parseSatelliteInfoFromNmea(
- buf, size, updateInfo.m_satellitesInViewParsed, systemType);
- if (parserStatus == QNmeaSatelliteInfoSource::PartiallyParsed) {
- updateInfo.m_satellites[systemType].updatingGSV = true;
-#if USE_NMEA_PIMPL
- updateInfo.gsv.append(QByteArray(buf, size));
-#endif
- } else if (parserStatus == QNmeaSatelliteInfoSource::FullyParsed) {
-#if USE_NMEA_PIMPL
- updateInfo.gsv.append(QByteArray(buf, size));
- for (int i = 0; i < updateInfo.m_satellitesInViewParsed.size(); i++) {
- const QGeoSatelliteInfo &s = updateInfo.m_satellitesInViewParsed.at(i);
- QGeoSatelliteInfoPrivateNmea *pimpl =
- new QGeoSatelliteInfoPrivateNmea(*QGeoSatelliteInfoPrivate::get(s));
- pimpl->nmeaSentences.append(updateInfo.gsa);
- pimpl->nmeaSentences.append(updateInfo.gsv);
- updateInfo.m_satellitesInViewParsed.replace(i, QGeoSatelliteInfo(*pimpl));
- }
- updateInfo.gsv.clear();
-#endif
- updateInfo.setSatellitesInView(systemType, updateInfo.m_satellitesInViewParsed);
- }
- }
-}
-
-QNmeaSatelliteInfoSourcePrivate::~QNmeaSatelliteInfoSourcePrivate()
-{
- delete m_updateTimer;
-}
-
-void QNmeaSatelliteInfoSourcePrivate::startUpdates()
-{
- if (m_invokedStart)
- return;
-
- m_satelliteError = QGeoSatelliteInfoSource::NoError;
-
- m_invokedStart = true;
- m_pendingUpdate.clear();
- m_noUpdateLastInterval = false;
-
- bool initialized = initialize();
- if (!initialized)
- return;
-
- if (m_updateMode == QNmeaSatelliteInfoSource::UpdateMode::RealTimeMode) {
- // skip over any buffered data - we only want the newest data.
- // Don't do this in requestUpdate. In that case bufferedData is good to have/use.
- if (m_device->bytesAvailable()) {
- if (m_device->isSequential())
- m_device->readAll();
- else
- m_device->seek(m_device->bytesAvailable());
- }
- }
-
- if (m_updateTimer)
- m_updateTimer->stop();
-
- if (m_source->updateInterval() > 0) {
- if (!m_updateTimer)
- m_updateTimer = new QBasicTimer;
- m_updateTimer->start(m_source->updateInterval(), this);
- }
-
- if (initialized)
- prepareSourceDevice();
-}
-
-void QNmeaSatelliteInfoSourcePrivate::stopUpdates()
-{
- m_invokedStart = false;
- if (m_updateTimer)
- m_updateTimer->stop();
- m_pendingUpdate.clear();
- m_noUpdateLastInterval = false;
-}
-
-void QNmeaSatelliteInfoSourcePrivate::requestUpdate(int msec)
-{
- if (m_requestTimer && m_requestTimer->isActive())
- return;
-
- m_satelliteError = QGeoSatelliteInfoSource::NoError;
-
- if (msec <= 0 || msec < m_source->minimumUpdateInterval()) {
- m_source->setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
-
- if (!m_requestTimer) {
- m_requestTimer = new QTimer(this);
- connect(m_requestTimer, SIGNAL(timeout()), SLOT(updateRequestTimeout()));
- }
-
- bool initialized = initialize();
- if (!initialized) {
- m_source->setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- return;
- }
-
- m_requestTimer->start(msec);
- prepareSourceDevice();
-}
-
-void QNmeaSatelliteInfoSourcePrivate::readyRead()
-{
- if (m_nmeaReader)
- m_nmeaReader->readAvailableData();
-}
-
-void QNmeaSatelliteInfoSourcePrivate::emitPendingUpdate()
-{
- if (m_pendingUpdate.isValid() && m_pendingUpdate.isFresh()) {
- m_updateTimeoutSent = false;
- m_noUpdateLastInterval = false;
- if (!emitUpdated(m_pendingUpdate, false))
- m_noUpdateLastInterval = true;
- // m_pendingUpdate.clear(); // Do not clear, it will be incrementally updated
- } else { // invalid or not fresh update
- if (m_noUpdateLastInterval && !m_updateTimeoutSent) {
- m_updateTimeoutSent = true;
- m_source->setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
- }
- m_noUpdateLastInterval = true;
- }
-}
-
-void QNmeaSatelliteInfoSourcePrivate::sourceDataClosed()
-{
- if (m_nmeaReader && m_device && m_device->bytesAvailable())
- m_nmeaReader->readAvailableData();
-}
-
-void QNmeaSatelliteInfoSourcePrivate::updateRequestTimeout()
-{
- m_requestTimer->stop();
- m_source->setError(QGeoSatelliteInfoSource::UpdateTimeoutError);
-}
-
-bool QNmeaSatelliteInfoSourcePrivate::openSourceDevice()
-{
- if (!m_device) {
- qWarning("QNmeaSatelliteInfoSource: no QIODevice data source, call setDevice() first");
- return false;
- }
-
- if (!m_device->isOpen() && !m_device->open(QIODevice::ReadOnly)) {
- qWarning("QNmeaSatelliteInfoSource: cannot open QIODevice data source");
- return false;
- }
-
- connect(m_device, SIGNAL(aboutToClose()), SLOT(sourceDataClosed()));
- connect(m_device, SIGNAL(readChannelFinished()), SLOT(sourceDataClosed()));
- connect(m_device, SIGNAL(destroyed()), SLOT(sourceDataClosed()));
-
- return true;
-}
-
-bool QNmeaSatelliteInfoSourcePrivate::initialize()
-{
- if (m_nmeaReader)
- return true;
-
- if (!openSourceDevice())
- return false;
-
- if (m_updateMode == QNmeaSatelliteInfoSource::UpdateMode::RealTimeMode)
- m_nmeaReader.reset(new QNmeaSatelliteRealTimeReader(this));
- else
- m_nmeaReader.reset(new QNmeaSatelliteSimulationReader(this));
-
- return true;
-}
-
-void QNmeaSatelliteInfoSourcePrivate::prepareSourceDevice()
-{
- // some data may already be available
- if (m_updateMode == QNmeaSatelliteInfoSource::UpdateMode::SimulationMode) {
- if (m_nmeaReader && m_device->bytesAvailable())
- m_nmeaReader->readAvailableData();
- }
-
- if (!m_connectedReadyRead) {
- connect(m_device, SIGNAL(readyRead()), SLOT(readyRead()));
- m_connectedReadyRead = true;
- }
-}
-
-bool QNmeaSatelliteInfoSourcePrivate::emitUpdated(QNmeaSatelliteInfoUpdate &update,
- bool fromRequestUpdate)
-{
- bool emitted = false;
- if (!update.isFresh())
- return emitted;
-
- update.consume();
- bool inUseUpdated = false;
- bool inViewUpdated = false;
- if (!fromRequestUpdate) {
- // we need to send update if information from at least one satellite
- // systems has changed
- for (auto it = update.m_satellites.cbegin(); it != update.m_satellites.cend(); ++it) {
- inUseUpdated |=
- it->satellitesInUse != m_lastUpdate.m_satellites[it.key()].satellitesInUse;
- inViewUpdated |=
- it->satellitesInView != m_lastUpdate.m_satellites[it.key()].satellitesInView;
- }
- } else {
- // if we come here from requestUpdate(), we need to emit, even if the data
- // didn't really change
- inUseUpdated = true;
- inViewUpdated = true;
- }
-
- m_lastUpdate = update;
- if (update.m_validInUse && inUseUpdated) {
- emit m_source->satellitesInUseUpdated(update.allSatellitesInUse());
- emitted = true;
- }
- if (update.m_validInView && inViewUpdated) {
- emit m_source->satellitesInViewUpdated(update.allSatellitesInView());
- emitted = true;
- }
- return emitted;
-}
-
-void QNmeaSatelliteInfoSourcePrivate::timerEvent(QTimerEvent * /*event*/)
-{
- emitPendingUpdate();
-}
-
-/*!
- \class QNmeaSatelliteInfoSource
- \inmodule QtPositioning
- \ingroup QtPositioning-positioning
- \since 6.2
-
- \brief The \l QNmeaSatelliteInfoSource class provides satellite information
- using an NMEA data source.
-
- NMEA is a commonly used protocol for the specification of one's global
- position at a certain point in time. The \l QNmeaSatelliteInfoSource class
- reads NMEA data and uses it to provide information about satellites in view
- and satellites in use in form of lists of \l QGeoSatelliteInfo objects.
-
- A \l QNmeaSatelliteInfoSource instance operates in either \l {RealTimeMode}
- or \l {SimulationMode}. These modes allow NMEA data to be read from either a
- live source of data, or replayed for simulation purposes from previously
- recorded NMEA data.
-
- The source of NMEA data is set via \l setDevice().
-
- Use \l startUpdates() to start receiving regular satellite information
- updates and \l stopUpdates() to stop these updates. If you only require
- updates occasionally, you can call \l requestUpdate() to request a single
- update of both satellites in view and satellites in use.
-
- The information about satellites in view is received via the
- \l satellitesInViewUpdated() signal.
-
- The information about satellites in use is received via the
- \l satellitesInUseUpdated() signal.
-*/
-
-/*!
- \enum QNmeaSatelliteInfoSource::UpdateMode
- Defines the available update modes.
-
- \value RealTimeMode Satellite information is read and distributed from the
- data source as it becomes available. Use this mode if you are using
- a live source of NMEA data (for example a GPS hardware device).
- \value SimulationMode Satellite information is read and distributed from the
- data source at the given rate. The rate is determined by the
- \l {QNmeaSatelliteInfoSource::}{SimulationUpdateInterval} parameter.
- Use this mode if the data source contains previously recorded NMEA
- data and you want to replay the data for simulation purposes.
-*/
-
-/*!
- \variable QNmeaSatelliteInfoSource::SimulationUpdateInterval
- \brief The backend property name for data read rate in the
- \l SimulationMode. The value for this property is the integer number
- representing the amount of milliseconds between the subsequent reads.
- Use this parameter in the \l {QNmeaSatelliteInfoSource::}
- {setBackendProperty()} and \l {QNmeaSatelliteInfoSource::}{backendProperty()}
- methods.
-
- \note This property is different from the interval that can be set via
- \l {setUpdateInterval()}. The value set via \l {setUpdateInterval()}
- denotes an interval for the user notification, while this parameter
- specifies the internal frequency of reading the data from source file. It
- means that one can have multiple (or none) reads during the
- \l {updateInterval()} period.
-*/
-QString QNmeaSatelliteInfoSource::SimulationUpdateInterval =
- QStringLiteral("nmea.satellite_info_simulation_interval");
-
-/*!
- Constructs a \l QNmeaSatelliteInfoSource instance with the given \a parent
- and \a mode.
-*/
-QNmeaSatelliteInfoSource::QNmeaSatelliteInfoSource(UpdateMode mode, QObject *parent)
- : QGeoSatelliteInfoSource(parent),
- d(new QNmeaSatelliteInfoSourcePrivate(this, mode))
-{
-}
-
-/*!
- Destroys the satellite information source.
-*/
-QNmeaSatelliteInfoSource::~QNmeaSatelliteInfoSource()
-{
- delete d;
-}
-
-/*!
- Returns the update mode.
-*/
-QNmeaSatelliteInfoSource::UpdateMode QNmeaSatelliteInfoSource::updateMode() const
-{
- return d->m_updateMode;
-}
-
-/*!
- Sets the NMEA data source to \a device. If the device is not open, it
- will be opened in QIODevice::ReadOnly mode.
-
- The source device can only be set once and must be set before calling
- \l startUpdates() or \l requestUpdate().
-
- \note The \a device must emit \l {QIODevice::readyRead()} for the
- source to be notified when data is available for reading.
- \l QNmeaSatelliteInfoSource does not assume the ownership of the device,
- and hence does not deallocate it upon destruction.
-*/
-void QNmeaSatelliteInfoSource::setDevice(QIODevice *device)
-{
- if (device != d->m_device) {
- if (!d->m_device)
- d->m_device = device;
- else
- qWarning("QNmeaSatelliteInfoSource: source device has already been set");
- }
-}
-
-/*!
- Returns the NMEA data source.
-*/
-QIODevice *QNmeaSatelliteInfoSource::device() const
-{
- return d->m_device;
-}
-
-/*!
- \reimp
-*/
-void QNmeaSatelliteInfoSource::setUpdateInterval(int msec)
-{
- int interval = msec;
- if (interval != 0)
- interval = qMax(msec, minimumUpdateInterval());
- QGeoSatelliteInfoSource::setUpdateInterval(interval);
- if (d->m_invokedStart) {
- d->stopUpdates();
- d->startUpdates();
- }
-}
-
-/*!
- \reimp
-*/
-int QNmeaSatelliteInfoSource::minimumUpdateInterval() const
-{
- return 2; // Some chips are capable of over 100 updates per seconds.
-}
-
-/*!
- \reimp
-*/
-QGeoSatelliteInfoSource::Error QNmeaSatelliteInfoSource::error() const
-{
- return d->m_satelliteError;
-}
-
-/*!
- \reimp
-*/
-bool QNmeaSatelliteInfoSource::setBackendProperty(const QString &name, const QVariant &value)
-{
- if (name == SimulationUpdateInterval && d->m_updateMode == UpdateMode::SimulationMode) {
- bool ok = false;
- const int interval = value.toInt(&ok);
- if (ok) {
- auto *reader = dynamic_cast<QNmeaSatelliteSimulationReader *>(d->m_nmeaReader.get());
- if (reader) {
- reader->setUpdateInterval(interval);
- } else {
- // d->m_nmeaReader will use it in constructor
- d->m_simulationUpdateInterval = interval;
- }
- return true;
- }
- }
- return false;
-}
-
-/*!
- \reimp
-*/
-QVariant QNmeaSatelliteInfoSource::backendProperty(const QString &name) const
-{
- if (name == SimulationUpdateInterval && d->m_updateMode == UpdateMode::SimulationMode) {
- auto *reader = dynamic_cast<QNmeaSatelliteSimulationReader *>(d->m_nmeaReader.get());
- if (reader)
- return reader->updateInterval();
- else
- return d->m_simulationUpdateInterval;
- }
- return QVariant();
-}
-
-/*!
- \reimp
-*/
-void QNmeaSatelliteInfoSource::startUpdates()
-{
- d->startUpdates();
-}
-
-/*!
- \reimp
-*/
-void QNmeaSatelliteInfoSource::stopUpdates()
-{
- d->stopUpdates();
-}
-
-/*!
- \reimp
-*/
-void QNmeaSatelliteInfoSource::requestUpdate(int msec)
-{
- d->requestUpdate(msec == 0 ? 60000 * 5 : msec); // 5min default timeout
-}
-
-/*!
- Parses an NMEA sentence string to extract the IDs of satelites in use.
-
- The default implementation will parse standard NMEA $GPGSA sentences.
- This method should be reimplemented in a subclass whenever the need to deal
- with non-standard NMEA sentences arises.
-
- The parser reads \a size bytes from \a data and uses that information to
- fill \a pnrsInUse list.
-
- Returns system type if the sentence was successfully parsed, otherwise
- returns \l QGeoSatelliteInfo::Undefined and should not modifiy \a pnrsInUse.
-*/
-QGeoSatelliteInfo::SatelliteSystem
-QNmeaSatelliteInfoSource::parseSatellitesInUseFromNmea(const char *data, int size,
- QList<int> &pnrsInUse)
-{
- return QLocationUtils::getSatInUseFromNmea(data, size, pnrsInUse);
-}
-
-/*!
- \enum QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
- Defines the parse status of satellite information. The satellite information
- can be split into multiple sentences, and we need to parse all of them.
- \value NotParsed The data does not contain information about satellites.
- \value PartiallyParsed A valid satellite information is received and parsed,
- but it's not complete, so we need to wait for another NMEA sentence.
- \value FullyParsed Satellite information was fully collected and parsed.
-*/
-
-/*!
- Parses an NMEA sentence string to extract the information about satellites
- in view.
-
- The default implementation will parse standard NMEA $GPGSV sentences.
- This method should be reimplemented in a subclass whenever the need to deal
- with non-standard NMEA sentences arises.
-
- The parser reads \a size bytes from \a data and uses that information to
- fill \a infos list.
-
- Returns \l SatelliteInfoParseStatus with parse result.
- Modifies \a infos list in case \l {QNmeaSatelliteInfoSource::}
- {PartiallyParsed} or \l {QNmeaSatelliteInfoSource::}{FullyParsed} is
- returned.
- Also sets the \a system to correct satellite system type. This is required
- to determine the system type in case there are no satellites in view.
-*/
-QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
-QNmeaSatelliteInfoSource::parseSatelliteInfoFromNmea(const char *data, int size,
- QList<QGeoSatelliteInfo> &infos,
- QGeoSatelliteInfo::SatelliteSystem &system)
-{
- return static_cast<SatelliteInfoParseStatus>(
- QLocationUtils::getSatInfoFromNmea(data, size, infos, system));
-}
-
-void QNmeaSatelliteInfoSource::setError(QGeoSatelliteInfoSource::Error satelliteError)
-{
- d->m_satelliteError = satelliteError;
- if (d->m_satelliteError != QGeoSatelliteInfoSource::NoError)
- emit QGeoSatelliteInfoSource::errorOccurred(satelliteError);
-}
-
-QList<QGeoSatelliteInfo> QNmeaSatelliteInfoUpdate::allSatellitesInUse() const
-{
- QList<QGeoSatelliteInfo> result;
- for (const auto &s : m_satellites)
- result.append(s.satellitesInUse);
- return result;
-}
-
-QList<QGeoSatelliteInfo> QNmeaSatelliteInfoUpdate::allSatellitesInView() const
-{
- QList<QGeoSatelliteInfo> result;
- for (const auto &s : m_satellites)
- result.append(s.satellitesInView);
- return result;
-}
-
-void QNmeaSatelliteInfoUpdate::setSatellitesInView(QGeoSatelliteInfo::SatelliteSystem system,
- const QList<QGeoSatelliteInfo> &inView)
-{
- auto &info = m_satellites[system];
- info.updatingGSV = false;
-
- info.satellitesInView = inView;
- info.validInView = true;
-
- if (!info.satellitesInUseReceived) {
- // Normally a GSA message should come after a GSV message. If this flag
- // is not set, we have received 2 consecutive GSV messages for this
- // system without a GSA in between.
- // This means that we could actually receive a $GNGSA empty message for
- // this specific type. As it had no ids and GN talker id, we could not
- // determine system type. This most probably means that we have no
- // satellites in use for this system type.
- // Clear satellites in use, if any.
- info.satellitesInUse.clear();
- info.inUseIds.clear();
- info.validInUse = true;
- }
- info.satellitesInUseReceived = false;
-
- if (info.satellitesInView.isEmpty()) {
- // If we received an empty list of satellites in view, then the list of
- // satellites in use will also be empty, so we would not be able to
- // match it with correct system type in case of $GNGSA message. Clear
- // the list in advance.
- info.satellitesInUse.clear();
- info.inUseIds.clear();
- info.validInUse = true;
- } else if (!info.inUseIds.isEmpty()) {
- // We have some satellites in use cached. Check if we have received the
- // proper GSV for them.
- info.satellitesInUse.clear();
- info.validInUse = false;
- bool corrupt = false;
- for (const auto id : info.inUseIds) {
- bool found = false;
- for (const auto &s : info.satellitesInView) {
- if (s.satelliteIdentifier() == id) {
- info.satellitesInUse.append(s);
- found = true;
- break;
- }
- }
- if (!found) {
- // The previoulsy received GSA is incorrect or not related to
- // this GSV
- info.satellitesInUse.clear();
- corrupt = true;
- break;
- }
- }
- info.validInUse = !corrupt;
- info.inUseIds.clear();
- }
-
- m_validInUse = calculateValidInUse();
- m_validInView = calculateValidInView();
- m_fresh = true;
-}
-
-bool QNmeaSatelliteInfoUpdate::setSatellitesInUse(QGeoSatelliteInfo::SatelliteSystem system,
- const QList<int> &inUse)
-{
- if (system == QGeoSatelliteInfo::Undefined || system == QGeoSatelliteInfo::Multiple)
- return false; // No way to determine satellite system
-
- SatelliteInfo &info = m_satellites[system];
- info.satellitesInUse.clear();
-
- info.satellitesInUseReceived = true;
- info.inUseIds = inUse;
-
- if (info.updatingGSV) {
- info.validInView = false;
- m_validInView = false;
- return false;
- }
-
- for (const auto id : inUse) {
- bool found = false;
- for (const auto &s : info.satellitesInView) {
- if (s.satelliteIdentifier() == id) {
- info.satellitesInUse.append(s);
- found = true;
- break;
- }
- }
- if (!found) {
- // satellites in use are not in view -> related GSV is not yet received
- info.satellitesInView.clear();
- info.validInView = false;
- m_validInView = false;
- return false;
- }
- }
-
- info.inUseIds.clear(); // make sure we remove all obsolete cache
-
- info.validInUse = true;
- m_fresh = true;
- m_validInUse = calculateValidInUse();
-
- return true;
-}
-
-void QNmeaSatelliteInfoUpdate::consume()
-{
- m_fresh = false;
-}
-
-bool QNmeaSatelliteInfoUpdate::isFresh() const
-{
- return m_fresh;
-}
-
-void QNmeaSatelliteInfoUpdate::clear()
-{
- m_satellites.clear();
- m_satellitesInViewParsed.clear();
- m_validInView = false;
- m_validInUse = false;
- m_fresh = false;
-#if USE_NMEA_PIMPL
- gsa.clear();
- gsv.clear();
-#endif
-}
-
-bool QNmeaSatelliteInfoUpdate::isValid() const
-{
- // GSV without GSA is valid. GSA with outdated but still matching GSV also valid.
- return m_validInView || m_validInUse;
-}
-
-bool QNmeaSatelliteInfoUpdate::calculateValidInUse() const
-{
- for (const auto &s : m_satellites) {
- if (!s.validInUse)
- return false;
- }
- return true;
-}
-
-bool QNmeaSatelliteInfoUpdate::calculateValidInView() const
-{
- for (const auto &s : m_satellites) {
- if (!s.validInView)
- return false;
- }
- return true;
-}
-
-QNmeaSatelliteReader::QNmeaSatelliteReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate)
- : m_proxy(sourcePrivate)
-{
-}
-
-QNmeaSatelliteReader::~QNmeaSatelliteReader()
-{
-}
-
-QNmeaSatelliteRealTimeReader::QNmeaSatelliteRealTimeReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate)
- : QNmeaSatelliteReader(sourcePrivate)
-{
-}
-
-void QNmeaSatelliteRealTimeReader::readAvailableData()
-{
- while (m_proxy->m_device->canReadLine())
- m_proxy->processNmeaData(m_proxy->m_pendingUpdate);
- m_proxy->notifyNewUpdate();
-}
-
-QNmeaSatelliteSimulationReader::QNmeaSatelliteSimulationReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate)
- : QNmeaSatelliteReader(sourcePrivate)
-{
- m_timer.reset(new QTimer);
- QObject::connect(m_timer.get(), &QTimer::timeout, [this]() {
- readAvailableData();
- });
- m_updateInterval =
- qMax(m_proxy->m_simulationUpdateInterval, m_proxy->m_source->minimumUpdateInterval());
-}
-
-void QNmeaSatelliteSimulationReader::readAvailableData()
-{
- if (!m_timer->isActive()) {
- // At the very first start we just start a timer to simulate a short
- // delay for overlapping requestUpdate() calls.
- // See TestQGeoSatelliteInfoSource::requestUpdate_overlappingCalls and
- // TestQGeoSatelliteInfoSource::requestUpdate_overlappingCallsWithTimeout
- m_timer->start(m_updateInterval);
- } else {
- // Here we try to get both satellites in view and satellites in use.
- // We behave like that because according to the QGeoSatelliteInfoSource
- // tests each call to requestUpdate() should return both satellites in
- // view and satellites in use. Same is expected on each interval for
- // startUpdates().
- // However user-provided NMEA logs might not contain some of the
- // messages, so we will try not to get stuck here infinitely.
- int numSatInUseMsgs = 0;
- int numSatInViewMsgs = 0;
- while (!numSatInUseMsgs || !numSatInViewMsgs) {
- m_proxy->processNmeaData(m_proxy->m_pendingUpdate);
- if (m_proxy->m_pendingUpdate.m_validInUse)
- numSatInUseMsgs++;
- if (m_proxy->m_pendingUpdate.m_validInView)
- numSatInViewMsgs++;
- // if we got the second message for one of them, but still didn't
- // receive any for the other - break.
- // We use 2 in the comparison, because, as soon as the m_validIn*
- // flag is set, it will stay true until we receive invalid message.
- if (numSatInUseMsgs > 2 || numSatInViewMsgs > 2) {
- const QString msgType = (numSatInUseMsgs > numSatInViewMsgs)
- ? QStringLiteral("GSA")
- : QStringLiteral("GSV");
- qWarning() << "nmea simulation reader: possibly incorrect message order. Got too "
- "many consecutive"
- << msgType << "messages";
- break;
- }
- }
- m_proxy->notifyNewUpdate();
- }
-}
-
-void QNmeaSatelliteSimulationReader::setUpdateInterval(int msec)
-{
- // restart the timer with new interval
- m_updateInterval = qMax(msec, m_proxy->m_source->minimumUpdateInterval());
- if (m_timer->isActive())
- m_timer->start(m_updateInterval);
-}
-
-int QNmeaSatelliteSimulationReader::updateInterval() const
-{
- return m_updateInterval;
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qnmeasatelliteinfosource.h b/src/positioning/qnmeasatelliteinfosource.h
deleted file mode 100644
index 538edfee..00000000
--- a/src/positioning/qnmeasatelliteinfosource.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QNMEASATELLITEINFOSOURCE_H
-#define QNMEASATELLITEINFOSOURCE_H
-
-#include <QtPositioning/QGeoSatelliteInfoSource>
-
-QT_BEGIN_NAMESPACE
-
-class QIODevice;
-
-class QNmeaSatelliteInfoSourcePrivate;
-class Q_POSITIONING_EXPORT QNmeaSatelliteInfoSource : public QGeoSatelliteInfoSource
-{
- Q_OBJECT
-public:
- enum class UpdateMode {
- RealTimeMode = 1,
- SimulationMode
- };
-
- static QString SimulationUpdateInterval;
-
- explicit QNmeaSatelliteInfoSource(UpdateMode mode, QObject *parent = nullptr);
- ~QNmeaSatelliteInfoSource() override;
-
- UpdateMode updateMode() const;
-
- void setDevice(QIODevice *source);
- QIODevice *device() const;
-
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
- bool setBackendProperty(const QString &name, const QVariant &value) override;
- QVariant backendProperty(const QString &name) const override;
-
-public Q_SLOTS:
- void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 0) override;
-
-protected:
- virtual QGeoSatelliteInfo::SatelliteSystem
- parseSatellitesInUseFromNmea(const char *data, int size, QList<int> &pnrsInUse);
- enum SatelliteInfoParseStatus {
- NotParsed = 0,
- PartiallyParsed,
- FullyParsed
- };
- virtual SatelliteInfoParseStatus parseSatelliteInfoFromNmea(const char *data, int size,
- QList<QGeoSatelliteInfo> &infos,
- QGeoSatelliteInfo::SatelliteSystem &system);
-
- QNmeaSatelliteInfoSourcePrivate *d;
- void setError(QGeoSatelliteInfoSource::Error satelliteError);
-
- friend class QNmeaSatelliteInfoSourcePrivate;
- Q_DISABLE_COPY(QNmeaSatelliteInfoSource)
-
- // for using the SatelliteInfoParseStatus enum
- friend class QLocationUtils;
-};
-
-QT_END_NAMESPACE
-
-#endif // QNMEASATELLITEINFOSOURCE_H
diff --git a/src/positioning/qnmeasatelliteinfosource_p.h b/src/positioning/qnmeasatelliteinfosource_p.h
deleted file mode 100644
index 4234d121..00000000
--- a/src/positioning/qnmeasatelliteinfosource_p.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNMESATELLITEINFOSOURCE_P_H
-#define QNMESATELLITEINFOSOURCE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qnmeasatelliteinfosource.h"
-#include <QtPositioning/qgeosatelliteinfo.h>
-
-#include <QObject>
-#include <QQueue>
-#include <QPointer>
-#include <QMap>
-#include <QtCore/qiodevice.h>
-#include <QtCore/qtimer.h>
-
-QT_BEGIN_NAMESPACE
-
-#define USE_NMEA_PIMPL 1
-
-struct SatelliteInfo
-{
- QList<QGeoSatelliteInfo> satellitesInView;
- QList<QGeoSatelliteInfo> satellitesInUse;
- QList<int> inUseIds; // temp buffer for GSA received before GSV
- bool satellitesInUseReceived = false;
- bool updatingGSV = false;
- bool validInView = false;
- bool validInUse = false;
-};
-
-struct QNmeaSatelliteInfoUpdate
-{
- QMap<QGeoSatelliteInfo::SatelliteSystem, SatelliteInfo> m_satellites;
- QList<QGeoSatelliteInfo> m_satellitesInViewParsed;
- bool m_validInView = false; // global state for all satellite systems
- bool m_validInUse = false; // global state for all satellite systems
- bool m_fresh = false;
-#if USE_NMEA_PIMPL
- QByteArray gsa;
- QList<QByteArray> gsv;
-#endif
- QList<QGeoSatelliteInfo> allSatellitesInUse() const;
- QList<QGeoSatelliteInfo> allSatellitesInView() const;
- void setSatellitesInView(QGeoSatelliteInfo::SatelliteSystem system,
- const QList<QGeoSatelliteInfo> &inView);
- bool setSatellitesInUse(QGeoSatelliteInfo::SatelliteSystem system, const QList<int> &inUse);
- void consume();
- bool isFresh() const;
- void clear();
- bool isValid() const;
- bool calculateValidInUse() const;
- bool calculateValidInView() const;
-};
-
-class QNmeaSatelliteReader;
-class QNmeaSatelliteInfoSourcePrivate : public QObject
-{
- Q_OBJECT
-public:
- QNmeaSatelliteInfoSourcePrivate(QNmeaSatelliteInfoSource *parent, QNmeaSatelliteInfoSource::UpdateMode updateMode);
- ~QNmeaSatelliteInfoSourcePrivate();
-
- void startUpdates();
- void stopUpdates();
- void requestUpdate(int msec);
- void notifyNewUpdate();
- void processNmeaData(QNmeaSatelliteInfoUpdate &updateInfo);
-
-public slots:
- void readyRead();
- void emitPendingUpdate();
- void sourceDataClosed();
- void updateRequestTimeout();
-
-public:
- QNmeaSatelliteInfoSource *m_source = nullptr;
- QGeoSatelliteInfoSource::Error m_satelliteError = QGeoSatelliteInfoSource::NoError;
- QPointer<QIODevice> m_device;
- QNmeaSatelliteInfoUpdate m_pendingUpdate;
- QNmeaSatelliteInfoUpdate m_lastUpdate;
- bool m_invokedStart = false;
- bool m_noUpdateLastInterval = false;
- bool m_updateTimeoutSent = false;
- bool m_connectedReadyRead = false;
- QBasicTimer *m_updateTimer = nullptr; // the timer used in startUpdates()
- QTimer *m_requestTimer = nullptr; // the timer used in requestUpdate()
- QScopedPointer<QNmeaSatelliteReader> m_nmeaReader;
- QNmeaSatelliteInfoSource::UpdateMode m_updateMode;
- int m_simulationUpdateInterval = 100;
-
-protected:
- bool openSourceDevice();
- bool initialize();
- void prepareSourceDevice();
- bool emitUpdated(QNmeaSatelliteInfoUpdate &update, bool fromRequestUpdate);
- void timerEvent(QTimerEvent *event) override;
-};
-
-class QNmeaSatelliteReader
-{
-public:
- QNmeaSatelliteReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate);
- virtual ~QNmeaSatelliteReader();
-
- virtual void readAvailableData() = 0;
-
-protected:
- QNmeaSatelliteInfoSourcePrivate *m_proxy;
-};
-
-class QNmeaSatelliteRealTimeReader : public QNmeaSatelliteReader
-{
-public:
- QNmeaSatelliteRealTimeReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate);
- void readAvailableData() override;
-};
-
-class QNmeaSatelliteSimulationReader : public QNmeaSatelliteReader
-{
-public:
- QNmeaSatelliteSimulationReader(QNmeaSatelliteInfoSourcePrivate *sourcePrivate);
- void readAvailableData() override;
- void setUpdateInterval(int msec);
- int updateInterval() const;
-
-private:
- QScopedPointer<QTimer> m_timer;
- int m_updateInterval;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/positioning/qpositioningglobal.h b/src/positioning/qpositioningglobal.h
deleted file mode 100644
index ea4de299..00000000
--- a/src/positioning/qpositioningglobal.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QPOSITIONINGGLOBAL_H
-#define QPOSITIONINGGLOBAL_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_STATIC
-# if defined(QT_BUILD_POSITIONING_LIB)
-# define Q_POSITIONING_EXPORT Q_DECL_EXPORT
-# else
-# define Q_POSITIONING_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define Q_POSITIONING_EXPORT
-#endif
-
-
-QT_END_NAMESPACE
-
-#endif // QPOSITIONINGGLOBAL_H
-
diff --git a/src/positioning/qpositioningglobal_p.h b/src/positioning/qpositioningglobal_p.h
deleted file mode 100644
index 747e450e..00000000
--- a/src/positioning/qpositioningglobal_p.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QPOSITIONINGGLOBAL_P_H
-#define QPOSITIONINGGLOBAL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qpositioningglobal.h"
-
-QT_BEGIN_NAMESPACE
-
-#define Q_POSITIONING_PRIVATE_EXPORT Q_POSITIONING_EXPORT
-
-QT_END_NAMESPACE
-
-#endif // QPOSITIONINGGLOBAL_P_H
-
diff --git a/src/positioning/qwebmercator.cpp b/src/positioning/qwebmercator.cpp
deleted file mode 100644
index 55b2e600..00000000
--- a/src/positioning/qwebmercator.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qwebmercator_p.h"
-
-#include "qgeocoordinate.h"
-
-#include <qnumeric.h>
-#include <qmath.h>
-
-#include "qdoublevector2d_p.h"
-#include "qdoublevector3d_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QDoubleVector2D QWebMercator::coordToMercator(const QGeoCoordinate &coord)
-{
- const double pi = M_PI;
-
- double lon = coord.longitude() / 360.0 + 0.5;
-
- double lat = coord.latitude();
- lat = 0.5 - (std::log(std::tan((pi / 4.0) + (pi / 2.0) * lat / 180.0)) / pi) / 2.0;
- lat = qBound(0.0, lat, 1.0);
-
- return QDoubleVector2D(lon, lat);
-}
-
-double QWebMercator::realmod(const double a, const double b)
-{
- quint64 div = static_cast<quint64>(a / b);
- return a - static_cast<double>(div) * b;
-}
-
-QGeoCoordinate QWebMercator::mercatorToCoord(const QDoubleVector2D &mercator)
-{
- const double pi = M_PI;
-
- double fx = mercator.x();
- double fy = mercator.y();
-
- if (fy < 0.0)
- fy = 0.0;
- else if (fy > 1.0)
- fy = 1.0;
-
- double lat;
-
- if (fy == 0.0)
- lat = 90.0;
- else if (fy == 1.0)
- lat = -90.0;
- else
- lat = (180.0 / pi) * (2.0 * std::atan(std::exp(pi * (1.0 - 2.0 * fy))) - (pi / 2.0));
-
- double lng;
- if (fx >= 0) {
- lng = realmod(fx, 1.0);
- } else {
- lng = realmod(1.0 - realmod(-1.0 * fx, 1.0), 1.0);
- }
-
- lng = lng * 360.0 - 180.0;
-
- return QGeoCoordinate(lat, lng, 0.0);
-}
-
-QGeoCoordinate QWebMercator::coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
-{
- QDoubleVector2D s = QWebMercator::coordToMercator(from);
- QDoubleVector2D e = QWebMercator::coordToMercator(to);
-
- double x;
-
- if (0.5 < qAbs(e.x() - s.x())) {
- // handle dateline crossing
- double ex = e.x();
- double sx = s.x();
- if (ex < sx)
- sx -= 1.0;
- else if (sx < ex)
- ex -= 1.0;
-
- x = (1.0 - progress) * sx + progress * ex;
-
- if (!qFuzzyIsNull(x) && (x < 0.0))
- x += 1.0;
-
- } else {
- x = (1.0 - progress) * s.x() + progress * e.x();
- }
-
- double y = (1.0 - progress) * s.y() + progress * e.y();
-
- QGeoCoordinate result = QWebMercator::mercatorToCoord(QDoubleVector2D(x, y));
- result.setAltitude((1.0 - progress) * from.altitude() + progress * to.altitude());
-
- return result;
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioning/qwebmercator_p.h b/src/positioning/qwebmercator_p.h
deleted file mode 100644
index 109f0730..00000000
--- a/src/positioning/qwebmercator_p.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QWEBMERCATOR_P_H
-#define QWEBMERCATOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qglobal.h>
-#include <QtCore/qvariant.h>
-#include "qpositioningglobal_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGeoCoordinate;
-class QDoubleVector2D;
-
-class Q_POSITIONING_PRIVATE_EXPORT QWebMercator
-{
-public:
- static QDoubleVector2D coordToMercator(const QGeoCoordinate &coord);
- static QGeoCoordinate mercatorToCoord(const QDoubleVector2D &mercator);
- static QGeoCoordinate coordinateInterpolation(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress);
-
-private:
- static double realmod(const double a, const double b);
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBMERCATOR_P_H
diff --git a/src/positioningquick/CMakeLists.txt b/src/positioningquick/CMakeLists.txt
deleted file mode 100644
index 28375160..00000000
--- a/src/positioningquick/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# Generated from positioningquick.pro.
-
-#####################################################################
-## PositioningQuick Module:
-#####################################################################
-
-qt_internal_add_qml_module(PositioningQuick
- URI QtPositioning
- VERSION ${CMAKE_PROJECT_VERSION}
- PLUGIN_TARGET positioningquickplugin
- NO_GENERATE_PLUGIN_SOURCE
- NO_PLUGIN_OPTIONAL
- CLASS_NAME QtPositioningDeclarativeModule
- SOURCES
- qdeclarativegeoaddress_p.h qdeclarativegeoaddress.cpp
- qdeclarativegeolocation_p.h qdeclarativegeolocation.cpp
- qdeclarativepluginparameter_p.h qdeclarativepluginparameter.cpp
- qdeclarativeposition_p.h qdeclarativeposition.cpp
- qdeclarativepositionsource_p.h qdeclarativepositionsource.cpp
- qquickgeocoordinateanimation_p.h qquickgeocoordinateanimation.cpp
- locationsingleton_p.h locationsingleton.cpp
- qquickgeocoordinateanimation_p_p.h
- qpositioningquickglobal.h
- qpositioningquickglobal_p.h
- qpositioningquickmodule_p.h
- LIBRARIES
- Qt::PositioningPrivate
- Qt::QuickPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::Positioning
- Qt::Qml
- Qt::Quick
- PRIVATE_MODULE_INTERFACE
- Qt::PositioningPrivate
- Qt::QuickPrivate
-)
-
-qt_internal_extend_target(positioningquickplugin
- SOURCES
- positioningplugin.cpp
- LIBRARIES
- Qt::PositioningQuickPrivate
- Qt::Quick
-)
-
diff --git a/src/positioningquick/locationsingleton.cpp b/src/positioningquick/locationsingleton.cpp
deleted file mode 100644
index 81ca3eda..00000000
--- a/src/positioningquick/locationsingleton.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "locationsingleton_p.h"
-#include <QtPositioning/private/qwebmercator_p.h>
-#include <QtPositioning/private/qdoublevector2d_p.h>
-#include <QDebug>
-
-static QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok)
-{
- QGeoCoordinate c;
-
- if (value.isObject()) {
- if (value.hasProperty(QStringLiteral("latitude")))
- c.setLatitude(value.property(QStringLiteral("latitude")).toNumber());
- if (value.hasProperty(QStringLiteral("longitude")))
- c.setLongitude(value.property(QStringLiteral("longitude")).toNumber());
- if (value.hasProperty(QStringLiteral("altitude")))
- c.setAltitude(value.property(QStringLiteral("altitude")).toNumber());
-
- if (ok)
- *ok = true;
- } else if (ok) {
- *ok = false;
- }
-
- return c;
-}
-
-
-/*!
- \qmltype QtPositioning
- \inqmlmodule QtPositioning
- \since 5.2
-
- \brief The QtPositioning global object provides useful functions for working with location-based
- types in QML.
-
- \qml
- import QtPositioning
-
- Item {
- property var coordinate: QtPositioning.coordinate(-27.5, 153.1)
- }
- \endqml
-*/
-
-LocationSingleton::LocationSingleton(QObject *parent)
-: QObject(parent)
-{
-}
-
-/*!
- \qmlmethod coordinate ::QtPositioning::coordinate()
-
- Constructs an invalid coordinate.
-
-*/
-QGeoCoordinate LocationSingleton::coordinate() const
-{
- return QGeoCoordinate();
-}
-
-/*!
- \qmlmethod coordinate QtPositioning::coordinate(real latitude, real longitude, real altitude) const
-
- Constructs a coordinate with the specified \a latitude, \a longitude and optional \a altitude.
- Both \a latitude and \a longitude must be valid, otherwise an invalid coordinate is returned.
-
- \sa {coordinate}
-*/
-QGeoCoordinate LocationSingleton::coordinate(double latitude, double longitude, double altitude) const
-{
- return QGeoCoordinate(latitude, longitude, altitude);
-}
-
-/*!
- \qmlmethod geoshape QtPositioning::shape() const
-
- Constructs an invalid geoshape.
-
- \sa {geoshape}
-*/
-QGeoShape LocationSingleton::shape() const
-{
- return QGeoShape();
-}
-
-/*!
- \qmlmethod georectangle QtPositioning::rectangle() const
-
- Constructs an invalid georectangle.
-
- \sa {georectangle}
-*/
-QGeoRectangle LocationSingleton::rectangle() const
-{
- return QGeoRectangle();
-}
-
-/*!
- \qmlmethod georectangle QtPositioning::rectangle(coordinate center, real width, real height) const
-
- Constructs a georectangle centered at \a center with a width of \a width degrees and a hight of
- \a height degrees.
-
- \sa {georectangle}
-*/
-QGeoRectangle LocationSingleton::rectangle(const QGeoCoordinate &center,
- double width, double height) const
-{
- return QGeoRectangle(center, width, height);
-}
-
-/*!
- \qmlmethod georectangle QtPositioning::rectangle(coordinate topLeft, coordinate bottomRight) const
-
- Constructs a georectangle with its top left corner positioned at \a topLeft and its bottom
- right corner positioned at \a {bottomRight}.
-
- \sa {georectangle}
-*/
-QGeoRectangle LocationSingleton::rectangle(const QGeoCoordinate &topLeft,
- const QGeoCoordinate &bottomRight) const
-{
- return QGeoRectangle(topLeft, bottomRight);
-}
-
-/*!
- \qmlmethod georectangle QtLocation5::QtLocation::rectangle(list<coordinate> coordinates) const
-
- Constructs a georectangle from the list of coordinates, the returned list is the smallest possible
- containing all the coordinates.
-
- \sa {georectangle}
-*/
-QGeoRectangle LocationSingleton::rectangle(const QVariantList &coordinates) const
-{
- QList<QGeoCoordinate> internalCoordinates;
- for (int i = 0; i < coordinates.size(); i++) {
- if (coordinates.at(i).canConvert<QGeoCoordinate>())
- internalCoordinates << coordinates.at(i).value<QGeoCoordinate>();
- }
- return QGeoRectangle(internalCoordinates);
-}
-
-/*!
- \qmlmethod geocircle QtPositioning::circle() const
-
- Constructs an invalid geocircle.
-
- \sa {geocircle}
-*/
-QGeoCircle LocationSingleton::circle() const
-{
- return QGeoCircle();
-}
-
-/*!
- \qmlmethod geocircle QtPositioning::circle(coordinate center, real radius) const
-
- Constructs a geocircle centered at \a center with a radius of \a radius meters.
-*/
-QGeoCircle LocationSingleton::circle(const QGeoCoordinate &center, qreal radius) const
-{
- return QGeoCircle(center, radius);
-}
-
-/*!
- \qmlmethod geopath QtPositioning::path() const
-
- Constructs an empty geopath.
-
- \sa {geopath}
- \since 5.9
-*/
-QGeoPath LocationSingleton::path() const
-{
- return QGeoPath();
-}
-
-/*!
- \qmlmethod geopath QtPositioning::path(list<coordinate> coordinates, real width) const
-
- Constructs a geopath from coordinates and width.
-
- \sa {geopath}
- \since 5.9
-*/
-QGeoPath LocationSingleton::path(const QJSValue &value, qreal width) const
-{
- QList<QGeoCoordinate> pathList;
-
- if (value.isArray()) {
- quint32 length = value.property(QStringLiteral("length")).toUInt();
- for (quint32 i = 0; i < length; ++i) {
- bool ok = false;
- QGeoCoordinate c = parseCoordinate(value.property(i), &ok);
-
- if (!ok || !c.isValid()) {
- pathList.clear(); // aborting
- break;
- }
-
- pathList.append(c);
- }
- }
-
- return QGeoPath(pathList, width);
-}
-
-/*!
- \qmlmethod geopolygon QtPositioning::polygon() const
-
- Constructs an empty polygon.
-
- \sa {geopolygon}
- \since 5.10
-*/
-QGeoPolygon LocationSingleton::polygon() const
-{
- return QGeoPolygon();
-}
-
-/*!
- \qmlmethod geopolygon QtPositioning::polygon(list<coordinate> coordinates) const
-
- Constructs a polygon from coordinates.
-
- \sa {geopolygon}
- \since 5.10
-*/
-QGeoPolygon LocationSingleton::polygon(const QVariantList &coordinates) const
-{
- QList<QGeoCoordinate> internalCoordinates;
- for (int i = 0; i < coordinates.size(); i++) {
- if (coordinates.at(i).canConvert<QGeoCoordinate>())
- internalCoordinates << coordinates.at(i).value<QGeoCoordinate>();
- }
- return QGeoPolygon(internalCoordinates);
-}
-
-/*!
- \qmlmethod geopolygon QtPositioning::polygon(list<coordinate> perimeter, list<list<coordinate>> holes) const
-
- Constructs a polygon from coordinates for perimeter and inner holes.
-
- \sa {geopolygon}
- \since 5.12
-*/
-QGeoPolygon LocationSingleton::polygon(const QVariantList &perimeter, const QVariantList &holes) const
-{
- QList<QGeoCoordinate> internalCoordinates;
- for (int i = 0; i < perimeter.size(); i++) {
- if (perimeter.at(i).canConvert<QGeoCoordinate>())
- internalCoordinates << perimeter.at(i).value<QGeoCoordinate>();
- }
- QGeoPolygon poly(internalCoordinates);
-
- for (int i = 0; i < holes.size(); i++) {
- if (holes.at(i).metaType().id() == QMetaType::QVariantList) {
- QList<QGeoCoordinate> hole;
- const QVariantList &holeData = holes.at(i).toList();
- for (int j = 0; j < holeData.size(); j++) {
- if (holeData.at(j).canConvert<QGeoCoordinate>())
- hole << holeData.at(j).value<QGeoCoordinate>();
- }
- if (hole.size())
- poly.addHole(hole);
- }
- }
-
- return poly;
-}
-
-/*!
- \qmlmethod geocircle QtPositioning::shapeToCircle(geoshape shape) const
-
- Converts \a shape to a geocircle.
-
- \sa {geocircle}
- \since 5.5
-*/
-QGeoCircle LocationSingleton::shapeToCircle(const QGeoShape &shape) const
-{
- return QGeoCircle(shape);
-}
-
-/*!
- \qmlmethod georectangle QtPositioning::shapeToRectangle(geoshape shape) const
-
- Converts \a shape to a georectangle.
-
- \sa {georectangle}
- \since 5.5
-*/
-QGeoRectangle LocationSingleton::shapeToRectangle(const QGeoShape &shape) const
-{
- return QGeoRectangle(shape);
-}
-
-/*!
- \qmlmethod geopath QtPositioning::shapeToPath(geoshape shape) const
-
- Converts \a shape to a geopath.
-
- \sa {geopath}
- \since 5.9
-*/
-QGeoPath LocationSingleton::shapeToPath(const QGeoShape &shape) const
-{
- return QGeoPath(shape);
-}
-
-/*!
- \qmlmethod geopolygon QtPositioning::shapeToPolygon(geoshape shape) const
-
- Converts \a shape to a polygon.
-
- \sa {geopolygon}
- \since 5.10
-*/
-QGeoPolygon LocationSingleton::shapeToPolygon(const QGeoShape &shape) const
-{
- return QGeoPolygon(shape);
-}
-
-/*!
- \qmlmethod coordinate QtPositioning::mercatorToCoord(point mercator) const
-
- Converts a \a mercator coordinate into a latitude-longitude coordinate.
-
- \sa {coordToMercator}
- \since 5.12
-*/
-QGeoCoordinate LocationSingleton::mercatorToCoord(const QPointF &mercator) const
-{
- return QWebMercator::mercatorToCoord(QDoubleVector2D(mercator.x(), mercator.y()));
-}
-
-/*!
- \qmlmethod point QtPositioning::coordToMercator(coordinate coord) const
-
- Converts a coordinate \a coord into a mercator coordinate and returns it.
- \sa {mercatorToCoord}
- \since 5.12
-*/
-QPointF LocationSingleton::coordToMercator(const QGeoCoordinate &coord) const
-{
- return QWebMercator::coordToMercator(coord).toPointF();
-}
diff --git a/src/positioningquick/locationsingleton_p.h b/src/positioningquick/locationsingleton_p.h
deleted file mode 100644
index 75459cb1..00000000
--- a/src/positioningquick/locationsingleton_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef LOCATIONSINGLETON_H
-#define LOCATIONSINGLETON_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QObject>
-#include <QtCore/qnumeric.h>
-#include <QtPositioning/QGeoCoordinate>
-#include <QtPositioning/QGeoShape>
-#include <QtPositioning/QGeoRectangle>
-#include <QtPositioning/QGeoCircle>
-#include <QtPositioning/QGeoPath>
-#include <QtPositioning/QGeoPolygon>
-#include <QtQml/QJSValue>
-#include <QVariant>
-#include <QPointF>
-#include <QQmlEngine>
-#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
-
-class Q_POSITIONINGQUICK_PRIVATE_EXPORT LocationSingleton : public QObject
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(QtPositioning)
- QML_SINGLETON
- QML_ADDED_IN_VERSION(5, 0)
-
-public:
- explicit LocationSingleton(QObject *parent = 0);
-
- Q_INVOKABLE QGeoCoordinate coordinate() const;
- Q_INVOKABLE QGeoCoordinate coordinate(double latitude, double longitude,
- double altitude = qQNaN()) const;
-
- Q_INVOKABLE QGeoShape shape() const;
-
- Q_INVOKABLE QGeoRectangle rectangle() const;
- Q_INVOKABLE QGeoRectangle rectangle(const QGeoCoordinate &center,
- double width, double height) const;
- Q_INVOKABLE QGeoRectangle rectangle(const QGeoCoordinate &topLeft,
- const QGeoCoordinate &bottomRight) const;
- Q_INVOKABLE QGeoRectangle rectangle(const QVariantList &coordinates) const;
-
- Q_INVOKABLE QGeoCircle circle() const;
- Q_INVOKABLE QGeoCircle circle(const QGeoCoordinate &center, qreal radius = -1.0) const;
-
- Q_INVOKABLE QGeoPath path() const;
- Q_INVOKABLE QGeoPath path(const QJSValue &value, qreal width = 0.0) const;
-
- Q_INVOKABLE QGeoPolygon polygon() const;
- Q_INVOKABLE QGeoPolygon polygon(const QVariantList &value) const;
- Q_INVOKABLE QGeoPolygon polygon(const QVariantList &perimeter, const QVariantList &holes) const;
-
- Q_INVOKABLE QGeoCircle shapeToCircle(const QGeoShape &shape) const;
- Q_INVOKABLE QGeoRectangle shapeToRectangle(const QGeoShape &shape) const;
- Q_INVOKABLE QGeoPath shapeToPath(const QGeoShape &shape) const;
- Q_INVOKABLE QGeoPolygon shapeToPolygon(const QGeoShape &shape) const;
-
- Q_REVISION(5, 12) Q_INVOKABLE QGeoCoordinate mercatorToCoord(const QPointF &mercator) const;
- Q_REVISION(5, 12) Q_INVOKABLE QPointF coordToMercator(const QGeoCoordinate &coord) const;
-};
-
-#endif // LOCATIONSINGLETON_H
diff --git a/src/positioningquick/positioningplugin.cpp b/src/positioningquick/positioningplugin.cpp
deleted file mode 100644
index 91a9c943..00000000
--- a/src/positioningquick/positioningplugin.cpp
+++ /dev/null
@@ -1,555 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qpositioningquickglobal_p.h>
-#include <QtPositioningQuick/private/qquickgeocoordinateanimation_p.h>
-#include <QtCore/QVariantAnimation>
-#include <QtQml/QQmlEngineExtensionPlugin>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlbasictype coordinate
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief The coordinate type represents and stores a geographic position.
-
- This type is a QML representation of \l QGeoCoordinate and represents a geographic
- position in the form of \l {latitude}, \l longitude and \l altitude attributes.
- The \l latitude attribute specifies the number of
- decimal degrees above and below the equator. A positive latitude indicates the Northern
- Hemisphere and a negative latitude indicates the Southern Hemisphere. The \l longitude
- attribute specifies the number of decimal degrees east and west. A positive longitude
- indicates the Eastern Hemisphere and a negative longitude indicates the Western Hemisphere.
- The \l altitude attribute specifies the number of meters above sea level. Together, these
- attributes specify a 3-dimensional position anywhere on or near the Earth's surface.
-
- The \l isValid attribute can be used to test if a coordinate is valid. A coordinate is
- considered valid if it has a valid latitude and longitude. A valid altitude is not required.
- The latitude must be between -90 and 90 inclusive and the longitude must be between -180 and
- 180 inclusive.
-
- The \c coordinate type is used by many other types in the Qt Location module, for specifying
- the position of an object on a Map, the current position of a device and many other tasks.
- They also feature a number of important utility methods that make otherwise complex
- calculations simple to use, such as \l {atDistanceAndAzimuth}().
-
- \section1 Accuracy
-
- The latitude, longitude and altitude attributes stored in the coordinate type are represented
- as doubles, giving them approximately 16 decimal digits of precision -- enough to specify
- micrometers. The calculations performed in coordinate's methods such as \l {azimuthTo}() and
- \l {distanceTo}() also use doubles for all intermediate values, but the inherent inaccuracies in
- their spherical Earth model dominate the amount of error in their output.
-
- \section1 Example Usage
-
- Use properties of type \l var to store a \c {coordinate}. To create a \c coordinate use
- one of the methods described below. In all cases, specifying the \l altitude attribute is
- optional.
-
- To create a \c coordinate value, use the \l{QtPositioning::coordinate}{QtPositioning.coordinate()}
- function:
-
- \qml
- import QtPositioning
-
- Location { coordinate: QtPositioning.coordinate(-27.5, 153.1) }
- \endqml
-
- or as separate \l latitude, \l longitude and \l altitude components:
-
- \qml
- Location {
- coordinate {
- latitude: -27.5
- longitude: 153.1
- }
- }
- \endqml
-
- When integrating with C++, note that any QGeoCoordinate value passed into QML from C++ is
- automatically converted into a \c coordinate value, and vice-versa.
-
- \section1 Properties
-
- \section2 latitude
-
- \code
- real latitude
- \endcode
-
- This property holds the latitude value of the geographical position
- (decimal degrees). A positive latitude indicates the Northern Hemisphere,
- and a negative latitude indicates the Southern Hemisphere.
- If the property has not been set, its default value is NaN.
-
- For more details see the \l {QGeoCoordinate::latitude} property
-
- \section2 longitude
-
- \code
- real longitude
- \endcode
-
- This property holds the longitude value of the geographical position
- (decimal degrees). A positive longitude indicates the Eastern Hemisphere,
- and a negative longitude indicates the Western Hemisphere
- If the property has not been set, its default value is NaN.
-
- For more details see the \l {QGeoCoordinate::longitude} property
-
- \section2 altitude
-
- \code
- real altitude
- \endcode
-
- This property holds the altitude value (meters above sea level).
- If the property has not been set, its default value is NaN.
-
- For more details see the \l {QGeoCoordinate::altitude} property
-
- \section2 isValid
-
- \code
- bool isValid
- \endcode
-
- This property holds the current validity of the coordinate. Coordinates
- are considered valid if they have been set with a valid latitude and
- longitude (altitude is not required).
-
- The latitude must be between -90 to 90 inclusive to be considered valid,
- and the longitude must be between -180 to 180 inclusive to be considered
- valid.
-
- This is a read-only property.
-
- \section1 Methods
-
- \section2 distanceTo()
-
- \code
- real distanceTo(coordinate other)
- \endcode
-
- Returns the distance (in meters) from this coordinate to the coordinate specified by \a other.
- Altitude is not used in the calculation.
-
- This calculation returns the great-circle distance between the two coordinates, with an
- assumption that the Earth is spherical for the purpose of this calculation.
-
- \section2 azimuthTo()
-
- \code
- real azimuth(coordinate other)
- \endcode
-
- Returns the azimuth (or bearing) in degrees from this coordinate to the coordinate specified by
- \a other. Altitude is not used in the calculation.
-
- There is an assumption that the Earth is spherical for the purpose of this calculation.
-
- \section2 atDistanceAndAzimuth()
-
- \code
- coordinate atDistanceAndAzimuth(real distance, real azimuth)
- \endcode
-
- Returns the coordinate that is reached by traveling \a distance metres from this coordinate at
- \a azimuth degrees along a great-circle.
-
- There is an assumption that the Earth is spherical for the purpose of this calculation.
-*/
-
-/*!
- \qmlbasictype geoshape
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief A geoshape type represents an abstract geographic area.
-
- This type is a QML representation of \l QGeoShape which is an abstract geographic area.
- It includes attributes and methods common to all geographic areas. To create objects
- that represent a valid geographic area use \l {georectangle} or \l {geocircle}.
-
- The \l isValid attribute can be used to test if the geoshape represents a valid geographic
- area.
-
- The \l isEmpty attribute can be used to test if the geoshape represents a region with a
- geometrical area of 0.
-
- The \l {contains}() method can be used to test if a \l {coordinate} is
- within the geoshape.
-
- \section1 Example Usage
-
- Use properties of type \l var to store a \c {geoshape}. To create a \c geoshape use one
- of the methods described below.
-
- To create a \c geoshape value, specify it as a "shape()" string:
-
- \qml
- import QtPositioning
-
- Item {
- property var region: "shape()"
- }
- \endqml
-
- or with the \l {QtPositioning::shape}{QtPositioning.shape()} function:
-
- \qml
- import QtPositioning
-
- Item {
- property var region: QtPositioning.shape()
- }
- \endqml
-
- When integrating with C++, note that any QGeoShape value passed into QML from C++ is
- automatically converted into a \c geoshape value, and vice-versa.
-
- \section1 Properties
-
- \section2 isEmpty
-
- \code
- bool isEmpty
- \endcode
-
- Returns whether this geoshape is empty. An empty geoshape is a region which has
- a geometrical area of 0.
-
- \section2 isValid
-
- \code
- bool isValid
- \endcode
-
- Returns whether this geoshape is valid.
-
- A geoshape is considered to be invalid if some of the data that is required to
- unambiguously describe the geoshape has not been set or has been set to an
- unsuitable value.
-
- \section2 type
-
- \code
- ShapeType type
- \endcode
-
- Returns the current type of the shape.
-
- \list
- \li \c GeoShape.UnknownType - The shape's type is not known.
- \li \c GeoShape.RectangleType - The shape is a \l georectangle.
- \li \c GeoShape.CircleType - The shape is a \l geocircle.
- \li \c GeoShape.PathType - The shape is a \l geopath. (Since Qt 5.9)
- \li \c GeoShape.PolygonType - The shape is a \l geopolygon. (Since Qt 5.10)
- \endlist
-
- This QML property was introduced by Qt 5.5.
-
- \section1 Methods
-
- \section2 contains()
-
- \code
- bool contains(coordinate coord)
- \endcode
-
- Returns true if the \l {QtPositioning::coordinate}{coordinate} specified by \a coord is within
- this geoshape; Otherwise returns false.
-*/
-
-/*!
- \qmlbasictype georectangle
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief The georectangle type represents a rectangular geographic area.
-
- The \c georectangle type is a \l {geoshape} that represents a
- rectangular geographic area. The type is direct representation of a \l QGeoRectangle.
- It is defined by a pair of \l {coordinate}{coordinates} which represent the top-left
- and bottom-right corners of the \c {georectangle}. The coordinates are accessible
- from the \l topLeft and \l bottomRight attributes.
-
- A \c georectangle is considered invalid if the top-left or bottom-right coordinates are invalid
- or if the top-left coordinate is south of the bottom-right coordinate.
-
- The coordinates of the four corners of the \c georectangle can be accessed with the
- \l {topLeft}, \l {topRight}, \l {bottomLeft} and \l {bottomRight} attributes. The \l center
- attribute can be used to get the coordinate of the center of the \c georectangle. The \l width
- and \l height attributes can be used to get the width and height of the \c georectangle in
- degrees. Setting one of these attributes will cause the other attributes to be adjusted
- accordingly.
-
- \section1 Limitations
-
- A \c georectangle can never cross the poles.
-
- If the height or center of a \c georectangle is adjusted such that it would cross one of the
- poles the height is modified such that the \c georectangle touches but does not cross the pole
- and that the center coordinate is still in the center of the \c georectangle.
-
- \section1 Example Usage
-
- Use properties of type \l var to store a \c {georectangle}. To create a \c georectangle
- value, use the \l {QtPositioning::rectangle}{QtPositioning.rectangle()} function:
-
- \qml
- import QtPositioning
-
- Item {
- property var region: QtPositioning.rectangle(QtPositioning.coordinate(-27.5, 153.1), QtPositioning.coordinate(-27.6, 153.2))
- }
- \endqml
-
- When integrating with C++, note that any QGeoRectangle value passed into QML from C++ is
- automatically converted into a \c georectangle value, and vice-versa.
-
- \section1 Properties
-
- \section2 bottomLeft
-
- \code
- coordinate bottomLeft
- \endcode
-
- This property holds the bottom left coordinate of this georectangle.
-
- \section2 bottomRight
-
- \code
- coordinate bottomRight
- \endcode
-
- This property holds the bottom right coordinate of this georectangle.
-
- \section2 center
-
- \code
- coordinate center
- \endcode
-
- This property holds the center coordinate of this georectangle. For more details
- see \l {QGeoRectangle::setCenter()}.
-
- \section2 height
-
- \code
- double height
- \endcode
-
- This property holds the height of this georectangle (in degrees). For more details
- see \l {QGeoRectangle::setHeight()}.
-
- \note If the georectangle is invalid, it is not possible to set the height. QtPositioning
- releases prior to Qt 5.5 permitted the setting of the height even on invalid georectangles.
-
- \section2 topLeft
-
- \code
- coordinate topLeft
- \endcode
-
- This property holds the top left coordinate of this georectangle.
-
- \section2 topRight
-
- \code
- coordinate topRight
- \endcode
-
- This property holds the top right coordinate of this georectangle.
-
- \section2 width
-
- \code
- double width
- \endcode
-
- This property holds the width of this georectangle (in degrees). For more details
- see \l {QGeoRectangle::setWidth()}.
-
- \note If the georectangle is invalid, it is not possible to set the width. QtPositioning
- releases prior to Qt 5.5 permitted the setting of the width even on invalid georectangles.
-*/
-
-/*!
- \qmlbasictype geocircle
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief The geocircle type represents a circular geographic area.
-
- The \c geocircle type is a \l {geoshape} that represents a circular
- geographic area. It is a direct representation of a \l QGeoCircle and is defined
- in terms of a \l {coordinate} which specifies the \l center of the circle and
- a qreal which specifies the \l radius of the circle in meters.
-
- The circle is considered invalid if the \l center coordinate is invalid or if
- the \l radius is less than zero.
-
- \section1 Example Usage
-
- Use properties of type \l var to store a \c {geocircle}. To create a \c geocircle value,
- use the \l {QtPositioning::circle}{QtPositioning.circle()} function:
-
- \qml
- import QtPositioning
-
- Item {
- property var region: QtPositioning.circle(QtPositioning.coordinate(-27.5, 153.1), 1000)
- }
- \endqml
-
- When integrating with C++, note that any QGeoCircle value passed into QML from C++ is
- automatically converted into a \c geocircle value, and vise-versa.
-
- \section1 Properties
-
- \section2 center
-
- \code
- coordinate radius
- \endcode
-
- This property holds the coordinate of the center of the geocircle.
-
- \section2 radius
-
- \code
- real radius
- \endcode
-
- This property holds the radius of the geocircle in meters.
-
- The default value for the radius is -1 indicating an invalid geocircle area.
-*/
-
-/*!
- \qmlbasictype geopath
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.9
-
- \brief The geopath type represents a geographic path.
-
- The \c geopath type is a \l {geoshape} that represents a geographic
- path. It is a direct representation of a \l QGeoPath and is defined
- in terms of a \l {path} which holds the list of geo coordinates in the
- path.
-
- The path is considered invalid if it is empty.
-
- When integrating with C++, note that any QGeoPath value passed into QML from C++ is
- automatically converted into a \c geopath value, and vice versa.
-
- \section1 Properties
-
- \section2 path
-
- This property holds the list of coordinates defining the path.
-
- \section2 width
-
- This property holds the width of the path in meters. This is currently only used
- when calling the \l {contains}() method.
-
- The default value for the width is 0.
-*/
-
-/*!
- \qmlbasictype geopolygon
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.10
-
- \brief The geopolygon type represents a geographic polygon.
-
- The \c geopolygon type is a \l [QML] geoshape that represents a geographic
- polygon. It is a direct representation of QGeoPolygon and is defined in
- terms of a \l path which holds a list of geo coordinates in the polygon.
-
- The polygon is considered invalid if its path holds less than three
- coordinates.
-
- When integrating with C++, note that any QGeoPolygon value passed into QML
- is automatically converted into a \c geopolygon, and vice versa.
-
- \section1 Properties
-
- \section2 path
-
- This property holds the list of coordinates defining the polygon.
-*/
-
-class QtPositioningDeclarativeModule: public QQmlEngineExtensionPlugin
-{
- Q_OBJECT
-
- Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
-
-public:
- QtPositioningDeclarativeModule(QObject *parent = 0) : QQmlEngineExtensionPlugin(parent)
- {
- volatile auto registration = &qml_register_types_QtPositioning;
- Q_UNUSED(registration)
- }
-};
-
-void QtPositioningDeclarative_initializeModule()
-{
- qRegisterAnimationInterpolator<QGeoCoordinate>(q_coordinateInterpolator);
-}
-
-Q_CONSTRUCTOR_FUNCTION(QtPositioningDeclarative_initializeModule)
-
-QT_END_NAMESPACE
-
-#include "positioningplugin.moc"
diff --git a/src/positioningquick/positioningquick.pro b/src/positioningquick/positioningquick.pro
deleted file mode 100644
index 75bd68a3..00000000
--- a/src/positioningquick/positioningquick.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TARGET = QtPositioningQuick
-QT = quick-private positioning-private qml-private core-private
-CONFIG += simd optimize_full
-
-INCLUDEPATH += $$PWD
-
-SOURCES += $$files(*.cpp)
-HEADERS += $$files(*.h)
-
-load(qt_module)
diff --git a/src/positioningquick/qdeclarativegeoaddress.cpp b/src/positioningquick/qdeclarativegeoaddress.cpp
deleted file mode 100644
index 9954a7b7..00000000
--- a/src/positioningquick/qdeclarativegeoaddress.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-***************************************************************************/
-
-#include "qdeclarativegeoaddress_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype Address
- \inqmlmodule QtPositioning
- \since 5.2
-
- \brief The Address QML type represents a specific location as a street address.
-
- An Address is used as a unit of data for queries such as (Reverse) Geocoding
- or Places searches -- many of these operations either accept an Address
- or return one.
-
- Not all properties of an Address are necessarily available or relevant
- in all parts of the world and all locales. The \l district, \l state and
- \l county properties are particularly area-specific for many data sources,
- and often only one or two of these are available or useful.
-
- The Address has a \l text property which holds a formatted string. It
- is the recommended way to display an address to the user and typically
- takes the format of an address as found on an envelope, but this is not always
- the case. The \l text may be automatically generated from constituent
- address properties such as \l street, \l city and and so on, but can also
- be explicitly assigned. See \l text for details.
-
- \section2 Example Usage
-
- The following code snippet shows the declaration of an Address object.
-
- \code
- Address {
- id: address
- street: "53 Brandl St"
- city: "Eight Mile Plains"
- country: "Australia"
- countryCode: "AUS"
- }
- \endcode
-
- This could then be used, for example, as the value of a geocoding query,
- to get an exact longitude and latitude for the address.
-
- \sa {QGeoAddress}
-*/
-
-QDeclarativeGeoAddress::QDeclarativeGeoAddress(QObject *parent) :
- QObject(parent)
-{
-}
-
-QDeclarativeGeoAddress::QDeclarativeGeoAddress(const QGeoAddress &address, QObject *parent) :
- QObject(parent), m_address(address)
-{
-}
-
-/*!
- \qmlproperty QGeoAddress QtPositioning::Address::address
-
- For details on how to use this property to interface between C++ and QML see
- "\l {Address - QGeoAddress} {Interfaces between C++ and QML Code}".
-*/
-QGeoAddress QDeclarativeGeoAddress::address() const
-{
- return m_address;
-}
-
-void QDeclarativeGeoAddress::setAddress(const QGeoAddress &address)
-{
- // Elaborate but takes care of emiting needed signals
- setText(address.text());
- setCountry(address.country());
- setCountryCode(address.countryCode());
- setState(address.state());
- setCounty(address.county());
- setCity(address.city());
- setDistrict(address.district());
- setStreet(address.street());
- setStreetNumber(address.streetNumber());
- setPostalCode(address.postalCode());
- m_address = address;
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::text
-
- This property holds the address as a single formatted string. It is the recommended
- string to use to display the address to the user. It typically takes the format of
- an address as found on an envelope, but this is not always necessarily the case.
-
- The address \c text is either automatically generated or explicitly assigned,
- this can be determined by checking \l isTextGenerated.
-
- If an empty string is assigned to \c text, then \l isTextGenerated will be set
- to true and \c text will return a string which is locally formatted according to
- \l countryCode and based on the properties of the address. Modifying the address
- properties such as \l street, \l city and so on may cause the contents of \c text to
- change.
-
- If a non-empty string is assigned to \c text, then \l isTextGenerated will be
- set to false and \c text will always return the explicitly assigned string.
- Modifying address properties will not affect the \c text property.
-*/
-QString QDeclarativeGeoAddress::text() const
-{
- return m_address.text();
-}
-
-void QDeclarativeGeoAddress::setText(const QString &address)
-{
- QString oldText = m_address.text();
- bool oldIsTextGenerated = m_address.isTextGenerated();
- m_address.setText(address);
-
- if (oldText != m_address.text())
- emit textChanged();
- if (oldIsTextGenerated != m_address.isTextGenerated())
- emit isTextGeneratedChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::country
-
- This property holds the country of the address as a single formatted string.
-*/
-QString QDeclarativeGeoAddress::country() const
-{
- return m_address.country();
-}
-
-void QDeclarativeGeoAddress::setCountry(const QString &country)
-{
- if (m_address.country() == country)
- return;
- QString oldText = m_address.text();
- m_address.setCountry(country);
- emit countryChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::countryCode
-
- This property holds the country code of the address as a single formatted string.
-*/
-QString QDeclarativeGeoAddress::countryCode() const
-{
- return m_address.countryCode();
-}
-
-void QDeclarativeGeoAddress::setCountryCode(const QString &countryCode)
-{
- if (m_address.countryCode() == countryCode)
- return;
- QString oldText = m_address.text();
- m_address.setCountryCode(countryCode);
- emit countryCodeChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::state
-
- This property holds the state of the address as a single formatted string.
-*/
-QString QDeclarativeGeoAddress::state() const
-{
- return m_address.state();
-}
-
-void QDeclarativeGeoAddress::setState(const QString &state)
-{
- if (m_address.state() == state)
- return;
- QString oldText = m_address.text();
- m_address.setState(state);
- emit stateChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::county
-
- This property holds the county of the address as a single formatted string.
-*/
-QString QDeclarativeGeoAddress::county() const
-{
- return m_address.county();
-}
-
-void QDeclarativeGeoAddress::setCounty(const QString &county)
-{
- if (m_address.county() == county)
- return;
- QString oldText = m_address.text();
- m_address.setCounty(county);
- emit countyChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::city
-
- This property holds the city of the address as a single formatted string.
-*/
-QString QDeclarativeGeoAddress::city() const
-{
- return m_address.city();
-}
-
-void QDeclarativeGeoAddress::setCity(const QString &city)
-{
- if (m_address.city() == city)
- return;
- QString oldText = m_address.text();
- m_address.setCity(city);
- emit cityChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::district
-
- This property holds the district of the address as a single formatted string.
-*/
-QString QDeclarativeGeoAddress::district() const
-{
- return m_address.district();
-}
-
-void QDeclarativeGeoAddress::setDistrict(const QString &district)
-{
- if (m_address.district() == district)
- return;
- QString oldText = m_address.text();
- m_address.setDistrict(district);
- emit districtChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::street
-
- This property holds the street of the address.
-
- \note Before Qt6 this property could also contain things like a unit number,
- a building name, or anything else that might be used to distinguish one
- address from another. Since Qt6 use \l{QtPositioning::Address::}{streetNumber}
- property for such information.
-*/
-QString QDeclarativeGeoAddress::street() const
-{
- return m_address.street();
-}
-
-void QDeclarativeGeoAddress::setStreet(const QString &street)
-{
- if (m_address.street() == street)
- return;
- QString oldText = m_address.text();
- m_address.setStreet(street);
- emit streetChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::streetNumber
- \since QtPositioning 6.2
-
- This property holds the street number of the address like a unit number,
- a building name, or anything else that might be used to distinguish one
- address from another.
-*/
-QString QDeclarativeGeoAddress::streetNumber() const
-{
- return m_address.streetNumber();
-}
-
-void QDeclarativeGeoAddress::setStreetNumber(const QString &streetNumber)
-{
- if (m_address.streetNumber() == streetNumber)
- return;
- QString oldText = m_address.text();
- m_address.setStreetNumber(streetNumber);
- emit streetNumberChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty string QtPositioning::Address::postalCode
-
- This property holds the postal code of the address as a single formatted string.
-*/
-QString QDeclarativeGeoAddress::postalCode() const
-{
- return m_address.postalCode();
-}
-
-void QDeclarativeGeoAddress::setPostalCode(const QString &postalCode)
-{
- if (m_address.postalCode() == postalCode)
- return;
- QString oldText = m_address.text();
- m_address.setPostalCode(postalCode);
- emit postalCodeChanged();
-
- if (m_address.isTextGenerated() && oldText != m_address.text())
- emit textChanged();
-}
-
-/*!
- \qmlproperty bool QtPositioning::Address::isTextGenerated
-
- This property holds a boolean that if true, indicates that \l text is automatically
- generated from address properties. If false, it indicates that the \l text has been
- explicitly assigned.
-
-*/
-bool QDeclarativeGeoAddress::isTextGenerated() const
-{
- return m_address.isTextGenerated();
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioningquick/qdeclarativegeoaddress_p.h b/src/positioningquick/qdeclarativegeoaddress_p.h
deleted file mode 100644
index d98be2e4..00000000
--- a/src/positioningquick/qdeclarativegeoaddress_p.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-***************************************************************************/
-
-#ifndef QDECLARATIVEGEOADDRESS_P_H
-#define QDECLARATIVEGEOADDRESS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QObject>
-#include <QtPositioning/QGeoAddress>
-#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
-#include <QQmlEngine>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativeGeoAddress : public QObject
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(Address)
- QML_ADDED_IN_VERSION(5, 0)
-
- Q_PROPERTY(QGeoAddress address READ address WRITE setAddress)
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
- Q_PROPERTY(QString countryCode READ countryCode WRITE setCountryCode NOTIFY countryCodeChanged)
- Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QString county READ county WRITE setCounty NOTIFY countyChanged)
- Q_PROPERTY(QString city READ city WRITE setCity NOTIFY cityChanged)
- Q_PROPERTY(QString district READ district WRITE setDistrict NOTIFY districtChanged)
- Q_PROPERTY(QString street READ street WRITE setStreet NOTIFY streetChanged)
- Q_PROPERTY(QString streetNumber READ streetNumber WRITE setStreetNumber
- NOTIFY streetNumberChanged REVISION(6, 2))
- Q_PROPERTY(QString postalCode READ postalCode WRITE setPostalCode NOTIFY postalCodeChanged)
- Q_PROPERTY(bool isTextGenerated READ isTextGenerated NOTIFY isTextGeneratedChanged)
-
-public:
- explicit QDeclarativeGeoAddress(QObject *parent = 0);
- QDeclarativeGeoAddress(const QGeoAddress &address, QObject *parent = 0);
- QGeoAddress address() const;
- void setAddress(const QGeoAddress &address);
-
- QString text() const;
- void setText(const QString &address);
-
- QString country() const;
- void setCountry(const QString &country);
- QString countryCode() const;
- void setCountryCode(const QString &countryCode);
- QString state() const;
- void setState(const QString &state);
- QString county() const;
- void setCounty(const QString &county);
- QString city() const;
- void setCity(const QString &city);
- QString district() const;
- void setDistrict(const QString &district);
- QString street() const;
- void setStreet(const QString &street);
- QString streetNumber() const;
- void setStreetNumber(const QString &streetNumber);
- QString postalCode() const;
- void setPostalCode(const QString &postalCode);
- bool isTextGenerated() const;
-
-Q_SIGNALS:
- void textChanged();
- void countryChanged();
- void countryCodeChanged();
- void stateChanged();
- void countyChanged();
- void cityChanged();
- void districtChanged();
- void streetChanged();
- void streetNumberChanged();
- void postalCodeChanged();
- void isTextGeneratedChanged();
-
-private:
- QGeoAddress m_address;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVEGEOADDRESS_P_H
diff --git a/src/positioningquick/qdeclarativegeolocation.cpp b/src/positioningquick/qdeclarativegeolocation.cpp
deleted file mode 100644
index b62ab7ca..00000000
--- a/src/positioningquick/qdeclarativegeolocation.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativegeolocation_p.h"
-
-QT_USE_NAMESPACE
-
-/*!
- \qmltype Location
- \inqmlmodule QtPositioning
- \since 5.2
-
- \brief The Location type holds location data.
-
- Location types represent a geographic "location", in a human sense. This
- consists of a specific \l {coordinate}, an \l {address} and a
- \l {boundingShape}{bounding shape}.
- The \l {boundingShape}{bounding shape} represents the recommended region
- to display when viewing this location.
-
- The Location type is most commonly seen as the contents of a search
- model such as the GeocodeModel. When a GeocodeModel returns the list of
- locations found for a given query, it represents these as Location objects.
-
- \section2 Example Usage
-
- The following example shows a simple Location object being declared:
-
- \code
- Location {
- coordinate {
- latitude: -27.3
- longitude: 153.1
- }
- address: Address {
- ...
- }
- }
- \endcode
-*/
-
-/*!
- \qmlproperty VariantMap QDeclarativeGeoLocation::extendedAttributes
-
- This property holds the extended attributes for this Location.
- Extended attributes are backend-dependent and can be location-dependent.
-
- \since 5.13
-*/
-
-QDeclarativeGeoLocation::QDeclarativeGeoLocation(QObject *parent)
-: QObject(parent)
-
-{
- setLocation(QGeoLocation());
-}
-
-QDeclarativeGeoLocation::QDeclarativeGeoLocation(const QGeoLocation &src, QObject *parent)
-: QObject(parent)
-{
- setLocation(src);
-}
-
-QDeclarativeGeoLocation::~QDeclarativeGeoLocation()
-{
-}
-
-/*!
- \qmlproperty QGeoLocation QtPositioning::Location::location
-
- For details on how to use this property to interface between C++ and QML see
- "\l {Location - QGeoLocation} {Interfaces between C++ and QML Code}".
-
- \note This property updates the whole geo location information, so using it
- will result in breaking of all the bindings for all other properties.
-*/
-void QDeclarativeGeoLocation::setLocation(const QGeoLocation &src)
-{
- if (m_address && m_address->parent() == this) {
- m_address->setAddress(src.address());
- } else if (!m_address || m_address->parent() != this) {
- m_address.setValue(new QDeclarativeGeoAddress(src.address(), this));
- m_address.notify();
- }
-
- setCoordinate(src.coordinate());
- setBoundingShape(src.boundingShape());
- setExtendedAttributes(src.extendedAttributes());
-}
-
-QGeoLocation QDeclarativeGeoLocation::location() const
-{
- QGeoLocation retValue;
- retValue.setAddress(m_address ? m_address->address() : QGeoAddress());
- retValue.setCoordinate(m_coordinate);
- retValue.setBoundingShape(m_boundingShape);
- retValue.setExtendedAttributes(m_extendedAttributes);
- return retValue;
-}
-
-/*!
- \qmlproperty Address QtPositioning::Location::address
-
- This property holds the address of the location which can be use to retrieve address details of the location.
-*/
-void QDeclarativeGeoLocation::setAddress(QDeclarativeGeoAddress *address)
-{
- m_address.removeBindingUnlessInWrapper();
- if (m_address == address)
- return;
-
- // implicitly deleting m_address.value() will force the QML bindings to
- // be reevaluated by the QML engine. So we defer the deletion of the old
- // address until a new value is assigned to the m_address.
- QDeclarativeGeoAddress *oldAddress = nullptr;
- if (m_address && m_address->parent() == this)
- oldAddress = m_address.value();
-
- m_address.setValueBypassingBindings(address);
- m_address.notify();
- delete oldAddress;
-}
-
-QBindable<QDeclarativeGeoAddress *> QDeclarativeGeoLocation::bindableAddress()
-{
- return QBindable<QDeclarativeGeoAddress *>(&m_address);
-}
-
-QDeclarativeGeoAddress *QDeclarativeGeoLocation::address() const
-{
- return m_address;
-}
-
-/*!
- \qmlproperty coordinate QtPositioning::Location::coordinate
-
- This property holds the exact geographical coordinate of the location which can be used to retrieve the latitude, longitude and altitude of the location.
-
- \note this property's changed() signal is currently emitted only if the
- whole object changes, not if only the contents of the object change.
-*/
-void QDeclarativeGeoLocation::setCoordinate(const QGeoCoordinate coordinate)
-{
- m_coordinate = coordinate;
-}
-
-QBindable<QGeoCoordinate> QDeclarativeGeoLocation::bindableCoordinate()
-{
- return QBindable<QGeoCoordinate>(&m_coordinate);
-}
-
-QGeoCoordinate QDeclarativeGeoLocation::coordinate() const
-{
- return m_coordinate;
-}
-
-/*!
- \since QtPositioning 6.2
-
- \qmlproperty geoshape QtPositioning::Location::boundingShape
-
- This property holds the recommended region to use when displaying the location.
- For example, a building's location may have a region centered around the building,
- but the region is large enough to show it's immediate surrounding geographical
- context.
-
- \note This property's changed() signal is currently emitted only if the
- whole object changes, not if only the contents of the object change.
-
- \note This property was introduced in Qt6 instead of boundingBox property.
- It returns a \l geoshape instead of a \l georectangle.
- Use \l QGeoShape::boundingGeoRectangle() to obtain a bounding
- \l georectangle for the shape.
-
- If you need to convert the returned shape to a specific type, use the
- \c type property of \l geoshape together with convenience
- methods from \l [QML]{QtPositioning} like
- \l {QtPositioning::shapeToRectangle}{QtPositioning.shapeToRectangle()}.
-*/
-void QDeclarativeGeoLocation::setBoundingShape(const QGeoShape &boundingShape)
-{
- m_boundingShape = boundingShape;
-}
-
-QBindable<QGeoShape> QDeclarativeGeoLocation::bindableBoundingShape()
-{
- return QBindable<QGeoShape>(&m_boundingShape);
-}
-
-QVariantMap QDeclarativeGeoLocation::extendedAttributes() const
-{
- return m_extendedAttributes;
-}
-
-void QDeclarativeGeoLocation::setExtendedAttributes(const QVariantMap &attributes)
-{
- m_extendedAttributes = attributes;
-}
-
-QBindable<QVariantMap> QDeclarativeGeoLocation::bindableExtendedAttributes()
-{
- return QBindable<QVariantMap>(&m_extendedAttributes);
-}
-
-QGeoShape QDeclarativeGeoLocation::boundingShape() const
-{
- return m_boundingShape;
-}
diff --git a/src/positioningquick/qdeclarativegeolocation_p.h b/src/positioningquick/qdeclarativegeolocation_p.h
deleted file mode 100644
index c1083952..00000000
--- a/src/positioningquick/qdeclarativegeolocation_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEGEOLOCATION_P_H
-#define QDECLARATIVEGEOLOCATION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QObject>
-#include <QtCore/QVariantMap>
-#include <QtCore/private/qproperty_p.h>
-#include <QtPositioning/QGeoLocation>
-#include <QtPositioning/QGeoShape>
-#include <QtPositioningQuick/private/qdeclarativegeoaddress_p.h>
-#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativeGeoLocation : public QObject
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(Location)
- QML_ADDED_IN_VERSION(5, 0)
-
- Q_PROPERTY(QGeoLocation location READ location WRITE setLocation)
- Q_PROPERTY(QDeclarativeGeoAddress *address READ address WRITE setAddress BINDABLE
- bindableAddress)
- Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate BINDABLE
- bindableCoordinate)
- Q_PROPERTY(QGeoShape boundingShape READ boundingShape WRITE setBoundingShape BINDABLE
- bindableBoundingShape REVISION(6, 2))
- Q_PROPERTY(QVariantMap extendedAttributes READ extendedAttributes WRITE setExtendedAttributes
- BINDABLE bindableExtendedAttributes REVISION(5, 13))
-
-public:
- explicit QDeclarativeGeoLocation(QObject *parent = 0);
- explicit QDeclarativeGeoLocation(const QGeoLocation &src, QObject *parent = 0);
- ~QDeclarativeGeoLocation();
-
- QGeoLocation location() const;
- void setLocation(const QGeoLocation &src);
-
- QDeclarativeGeoAddress *address() const;
- void setAddress(QDeclarativeGeoAddress *address);
- QBindable<QDeclarativeGeoAddress *> bindableAddress();
-
- QGeoCoordinate coordinate() const;
- void setCoordinate(const QGeoCoordinate coordinate);
- QBindable<QGeoCoordinate> bindableCoordinate();
-
- QGeoShape boundingShape() const;
- void setBoundingShape(const QGeoShape &boundingShape);
- QBindable<QGeoShape> bindableBoundingShape();
-
- QVariantMap extendedAttributes() const;
- void setExtendedAttributes(const QVariantMap &attributes);
- QBindable<QVariantMap> bindableExtendedAttributes();
-
-private:
- Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QDeclarativeGeoLocation, QDeclarativeGeoAddress *, m_address,
- &QDeclarativeGeoLocation::setAddress, nullptr)
- Q_OBJECT_BINDABLE_PROPERTY(QDeclarativeGeoLocation, QGeoShape, m_boundingShape)
- Q_OBJECT_BINDABLE_PROPERTY(QDeclarativeGeoLocation, QGeoCoordinate, m_coordinate)
- Q_OBJECT_BINDABLE_PROPERTY(QDeclarativeGeoLocation, QVariantMap, m_extendedAttributes)
-};
-
-QT_END_NAMESPACE
-
-#endif // QDECLARATIVELOCATION_P_H
diff --git a/src/positioningquick/qdeclarativepluginparameter.cpp b/src/positioningquick/qdeclarativepluginparameter.cpp
deleted file mode 100644
index 0092777f..00000000
--- a/src/positioningquick/qdeclarativepluginparameter.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepluginparameter_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype PluginParameter
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-common
- \since QtPositioning 5.14
-
- \brief The PluginParameter type describes a parameter for a
- \omit
- plugin, either geoservice \l Plugin, or
- \endomit
- position plugin.
-
- The PluginParameter object is used to provide a parameter of some kind
- to a plugin. Typically, these parameters contain details like an application
- token for access to a service, or a proxy server to use for network access,
- or the serial port to which a serial GPS receiver is connected.
-
- To set such a parameter, declare a PluginParameter inside an element that
- accepts plugin parameters as configuration objects, such as a
- \omit
- \l Plugin object, or a
- \endomit
- \l PositionSource object, and set values for its \l{name} and \l{value}
- properties. A list of valid parameter names for each plugin is available
- from the
- \omit
- \l {Qt Location#Plugin References and Parameters}{plugin reference pages}
- for geoservice plugins, and
- \endomit
- \l {Qt Positioning plugins#Default plugins}{default plugins page} for
- position plugins.
-
- \section2 Example Usage
-
- The following example shows the instantiation of the
- \l {Qt Positioning NMEA plugin}{NMEA} plugin with the \e nmea.source
- parameter that specifies the data source.
-
- \code
- PositionSource {
- name: "nmea"
- PluginParameter { name: "nmea.source"; value: "serial:/dev/ttyACM0" }
- }
- \endcode
-*/
-
-/*!
- \qmlproperty string PluginParameter::name
-
- This property holds the name of the plugin parameter as a single formatted string.
- This property is a write-once property.
-*/
-
-/*!
- \qmlproperty QVariant PluginParameter::value
-
- This property holds the value of the plugin parameter which support different types of values (variant).
- This property is a write-once property.
-*/
-
-QDeclarativePluginParameter::QDeclarativePluginParameter(QObject *parent)
- : QObject(parent) {}
-
-QDeclarativePluginParameter::~QDeclarativePluginParameter() {}
-
-void QDeclarativePluginParameter::setName(const QString &name)
-{
- if (!name_.isEmpty() || name.isEmpty())
- return;
-
- name_ = name;
-
- emit nameChanged(name_);
- if (value_.isValid())
- emit initialized();
-}
-
-QString QDeclarativePluginParameter::name() const
-{
- return name_;
-}
-
-void QDeclarativePluginParameter::setValue(const QVariant &value)
-{
- if (value_.isValid() || !value.isValid() || value.isNull())
- return;
-
- value_ = value;
-
- emit valueChanged(value_);
- if (!name_.isEmpty())
- emit initialized();
-}
-
-QVariant QDeclarativePluginParameter::value() const
-{
- return value_;
-}
-
-bool QDeclarativePluginParameter::isInitialized() const
-{
- return !name_.isEmpty() && value_.isValid();
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioningquick/qdeclarativepluginparameter_p.h b/src/positioningquick/qdeclarativepluginparameter_p.h
deleted file mode 100644
index 2d3b8e2a..00000000
--- a/src/positioningquick/qdeclarativepluginparameter_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtLocation module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEPLUGINPARAMETER_P_H
-#define QDECLARATIVEPLUGINPARAMETER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
-#include <QtQml/qqml.h>
-#include <QtCore/QMap>
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtCore/QVariant>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativePluginParameter : public QObject
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(PluginParameter)
- QML_ADDED_IN_VERSION(5, 14)
-
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
-
-public:
- explicit QDeclarativePluginParameter(QObject *parent = 0);
- ~QDeclarativePluginParameter();
-
- void setName(const QString &name);
- QString name() const;
-
- void setValue(const QVariant &value);
- QVariant value() const;
-
- bool isInitialized() const;
-
-Q_SIGNALS:
- void nameChanged(const QString &name);
- void valueChanged(const QVariant &value);
- void initialized();
-
-private:
- QString name_;
- QVariant value_;
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativePluginParameter)
-
-#endif // QDECLARATIVEPLUGINPARAMETER_P_H
diff --git a/src/positioningquick/qdeclarativeposition.cpp b/src/positioningquick/qdeclarativeposition.cpp
deleted file mode 100644
index 515fef9d..00000000
--- a/src/positioningquick/qdeclarativeposition.cpp
+++ /dev/null
@@ -1,621 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Jolla Ltd.
-** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QtNumeric>
-#include "qdeclarativeposition_p.h"
-#include <QtQml/qqml.h>
-#include <qnmeapositioninfosource.h>
-#include <QFile>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype Position
- //! \instantiates QDeclarativePosition
- \inqmlmodule QtPositioning
- \since 5.2
-
- \brief The Position type holds positional data at a particular point in time,
- such as coordinate (longitude, latitude, altitude) and speed.
-
- The Position type holds values related to geographic location such as
- a \l coordinate (longitude, latitude, and altitude), the \l timestamp when
- the Position was obtained, the \l speed at that time, and the accuracy of
- the data.
-
- Primarily, it is used in the \l{PositionSource::position}{position} property
- of a \l{PositionSource}, as the basic unit of data available from the system
- location data source.
-
- Not all properties of a Position object are necessarily valid or available
- (for example latitude and longitude may be valid, but speed update has not been
- received or set manually). As a result, corresponding "valid" properties
- are available (for example \l{coordinate} and \l{longitudeValid}, \l{latitudeValid}
- etc) to discern whether the data is available and valid in this position
- update.
-
- Position objects are read-only and can only be produced by a PositionSource.
-
- \section2 Example Usage
-
- See the example given for the \l{PositionSource} type, or the
- \l{geoflickr}{GeoFlickr} example application.
-
- \sa PositionSource, coordinate
-*/
-
-namespace
-{
-
-bool equalOrNaN(qreal a, qreal b)
-{
- return a == b || (qIsNaN(a) && qIsNaN(b));
-}
-
-bool exclusiveNaN(qreal a, qreal b)
-{
- return qIsNaN(a) != qIsNaN(b);
-}
-
-}
-
-QDeclarativePosition::QDeclarativePosition(QObject *parent)
-: QObject(parent)
-{
-}
-
-QDeclarativePosition::~QDeclarativePosition()
-{
-}
-
-void QDeclarativePosition::setPosition(const QGeoPositionInfo &info)
-{
- // timestamp
- const QDateTime pTimestamp = m_info.timestamp();
- const QDateTime timestamp = info.timestamp();
- const bool timestampChanged = pTimestamp != timestamp;
-
- // coordinate
- const QGeoCoordinate pCoordinate = m_info.coordinate();
- const QGeoCoordinate coordinate = info.coordinate();
- const bool coordinateChanged = pCoordinate != coordinate;
- const bool latitudeValidChanged = exclusiveNaN(pCoordinate.latitude(), coordinate.latitude());
- const bool longitudeValidChanged =
- exclusiveNaN(pCoordinate.longitude(), coordinate.longitude());
- const bool altitudeValidChanged = exclusiveNaN(pCoordinate.altitude(), coordinate.altitude());
-
- // direction
- const qreal pDirection = m_info.attribute(QGeoPositionInfo::Direction);
- const qreal direction = info.attribute(QGeoPositionInfo::Direction);
- const bool directionChanged = !equalOrNaN(pDirection, direction);
- const bool directionValidChanged = exclusiveNaN(pDirection, direction);
-
- // ground speed
- const qreal pSpeed = m_info.attribute(QGeoPositionInfo::GroundSpeed);
- const qreal speed = info.attribute(QGeoPositionInfo::GroundSpeed);
- const bool speedChanged = !equalOrNaN(pSpeed, speed);
- const bool speedValidChanged = exclusiveNaN(pSpeed, speed);
-
- // vertical speed
- const qreal pVerticalSpeed = m_info.attribute(QGeoPositionInfo::VerticalSpeed);
- const qreal verticalSpeed = info.attribute(QGeoPositionInfo::VerticalSpeed);
- const bool verticalSpeedChanged = !equalOrNaN(pVerticalSpeed, verticalSpeed);
- const bool verticalSpeedValidChanged = exclusiveNaN(pVerticalSpeed, verticalSpeed);
-
- // magnetic variation
- const qreal pMagneticVariation = m_info.attribute(QGeoPositionInfo::MagneticVariation);
- const qreal magneticVariation = info.attribute(QGeoPositionInfo::MagneticVariation);
- const bool magneticVariationChanged = !equalOrNaN(pMagneticVariation, magneticVariation);
- const bool magneticVariationValidChanged = exclusiveNaN(pMagneticVariation, magneticVariation);
-
- // horizontal accuracy
- const qreal pHorizontalAccuracy = m_info.attribute(QGeoPositionInfo::HorizontalAccuracy);
- const qreal horizontalAccuracy = info.attribute(QGeoPositionInfo::HorizontalAccuracy);
- const bool horizontalAccuracyChanged = !equalOrNaN(pHorizontalAccuracy, horizontalAccuracy);
- const bool horizontalAccuracyValidChanged =
- exclusiveNaN(pHorizontalAccuracy, horizontalAccuracy);
-
- // vertical accuracy
- const qreal pVerticalAccuracy = m_info.attribute(QGeoPositionInfo::VerticalAccuracy);
- const qreal verticalAccuracy = info.attribute(QGeoPositionInfo::VerticalAccuracy);
- const bool verticalAccuracyChanged = !equalOrNaN(pVerticalAccuracy, verticalAccuracy);
- const bool verticalAccuracyValidChanged = exclusiveNaN(pVerticalAccuracy, verticalAccuracy);
-
- m_info = info;
-
- if (timestampChanged)
- m_computedTimestamp.notify();
-
- if (coordinateChanged)
- m_computedCoordinate.notify();
- if (latitudeValidChanged)
- m_computedLatitudeValid.notify();
- if (longitudeValidChanged)
- m_computedLongitudeValid.notify();
- if (altitudeValidChanged)
- m_computedAltitudeValid.notify();
-
- if (directionChanged)
- m_computedDirection.notify();
- if (directionValidChanged)
- m_computedDirectionValid.notify();
-
- if (speedChanged)
- m_computedSpeed.notify();
- if (speedValidChanged)
- m_computedSpeedValid.notify();
-
- if (verticalSpeedChanged)
- m_computedVerticalSpeed.notify();
- if (verticalSpeedValidChanged)
- m_computedVerticalSpeedValid.notify();
-
- if (horizontalAccuracyChanged)
- m_computedHorizontalAccuracy.notify();
- if (horizontalAccuracyValidChanged)
- m_computedHorizontalAccuracyValid.notify();
-
- if (verticalAccuracyChanged)
- m_computedVerticalAccuracy.notify();
- if (verticalAccuracyValidChanged)
- m_computedVerticalAccuracyValid.notify();
-
- if (magneticVariationChanged)
- m_computedMagneticVariation.notify();
- if (magneticVariationValidChanged)
- m_computedMagneticVariationValid.notify();
-}
-
-const QGeoPositionInfo &QDeclarativePosition::position() const
-{
- return m_info;
-}
-
-QBindable<bool> QDeclarativePosition::bindableLatitudeValid() const
-{
- return QBindable<bool>(&m_computedLatitudeValid);
-}
-
-QBindable<bool> QDeclarativePosition::bindableLongitudeValid() const
-{
- return QBindable<bool>(&m_computedLongitudeValid);
-}
-
-QBindable<bool> QDeclarativePosition::bindableAltitudeValid() const
-{
- return QBindable<bool>(&m_computedAltitudeValid);
-}
-
-QBindable<QGeoCoordinate> QDeclarativePosition::bindableCoordinate() const
-{
- return QBindable<QGeoCoordinate>(&m_computedCoordinate);
-}
-
-QBindable<QDateTime> QDeclarativePosition::bindableTimestamp() const
-{
- return QBindable<QDateTime>(&m_computedTimestamp);
-}
-
-QBindable<double> QDeclarativePosition::bindableSpeed() const
-{
- return QBindable<double>(&m_computedSpeed);
-}
-
-QBindable<bool> QDeclarativePosition::bindableSpeedValid() const
-{
- return QBindable<bool>(&m_computedSpeedValid);
-}
-
-QBindable<qreal> QDeclarativePosition::bindableHorizontalAccuracy() const
-{
- return QBindable<qreal>(&m_computedHorizontalAccuracy);
-}
-
-QBindable<qreal> QDeclarativePosition::binableVerticalAccuracy() const
-{
- return QBindable<qreal>(&m_computedVerticalAccuracy);
-}
-
-QBindable<bool> QDeclarativePosition::bindableHorizontalAccuracyValid() const
-{
- return QBindable<bool>(&m_computedHorizontalAccuracyValid);
-}
-
-QBindable<bool> QDeclarativePosition::bindableVerticalAccuracyValid() const
-{
- return QBindable<bool>(&m_computedVerticalAccuracyValid);
-}
-
-QBindable<bool> QDeclarativePosition::bindableDirectionValid() const
-{
- return QBindable<bool>(&m_computedDirectionValid);
-}
-
-QBindable<double> QDeclarativePosition::bindableDirection() const
-{
- return QBindable<double>(&m_computedDirection);
-}
-
-QBindable<bool> QDeclarativePosition::bindableVerticalSpeedValid() const
-{
- return QBindable<bool>(&m_computedVerticalSpeedValid);
-}
-
-QBindable<double> QDeclarativePosition::bindableVerticalSpeed() const
-{
- return QBindable<double>(&m_computedVerticalSpeed);
-}
-
-QBindable<double> QDeclarativePosition::bindableMagneticVariation() const
-{
- return QBindable<double>(&m_computedMagneticVariation);
-}
-
-QBindable<bool> QDeclarativePosition::bindableMagneticVariationValid() const
-{
- return QBindable<bool>(&m_computedMagneticVariationValid);
-}
-
-/*!
- \qmlproperty coordinate Position::coordinate
-
- This property holds the latitude, longitude, and altitude value of the Position.
-
- It is a read-only property.
-
- \sa longitudeValid, latitudeValid, altitudeValid
-*/
-QGeoCoordinate QDeclarativePosition::coordinate() const
-{
- return m_computedCoordinate.value();
-}
-
-QGeoCoordinate QDeclarativePosition::coordinateActualCalculation() const
-{
- return m_info.coordinate();
-}
-
-/*!
- \qmlproperty bool Position::latitudeValid
-
- This property is true if coordinate's latitude has been set
- (to indicate whether that data has been received or not, as every update
- does not necessarily contain all data).
-
- \sa coordinate
-*/
-bool QDeclarativePosition::isLatitudeValid() const
-{
- return m_computedLatitudeValid.value();
-}
-
-bool QDeclarativePosition::isLatitudeValidActualCalculation() const
-{
- return !qIsNaN(m_info.coordinate().latitude());
-}
-
-/*!
- \qmlproperty bool Position::longitudeValid
-
- This property is true if coordinate's longitude has been set
- (to indicate whether that data has been received or not, as every update
- does not necessarily contain all data).
-
- \sa coordinate
-*/
-bool QDeclarativePosition::isLongitudeValid() const
-{
- return m_computedLongitudeValid.value();
-}
-
-bool QDeclarativePosition::isLongitudeValidActualCalculation() const
-{
- return !qIsNaN(m_info.coordinate().longitude());
-}
-
-/*!
- \qmlproperty bool Position::speedValid
-
- This property is true if \l speed has been set
- (to indicate whether that data has been received or not, as every update
- does not necessarily contain all data).
-
- \sa speed
-*/
-bool QDeclarativePosition::isSpeedValid() const
-{
- return m_computedSpeedValid.value();
-}
-
-bool QDeclarativePosition::isSpeedValidActualCalculation() const
-{
- return !qIsNaN(m_info.attribute(QGeoPositionInfo::GroundSpeed));
-}
-
-/*!
- \qmlproperty bool Position::altitudeValid
-
- This property is true if coordinate's altitude has been set
- (to indicate whether that data has been received or not, as every update
- does not necessarily contain all data).
-
- \sa coordinate
-*/
-bool QDeclarativePosition::isAltitudeValid() const
-{
- return m_computedAltitudeValid.value();
-}
-
-bool QDeclarativePosition::isAltitudeValidActualCalculation() const
-{
- return !qIsNaN(m_info.coordinate().altitude());
-}
-
-/*!
- \qmlproperty double Position::speed
-
- This property holds the value of speed (groundspeed, meters / second).
-
- It is a read-only property.
-
- \sa speedValid, coordinate
-*/
-double QDeclarativePosition::speed() const
-{
- return m_computedSpeed.value();
-}
-
-double QDeclarativePosition::speedActualCalculation() const
-{
- return m_info.attribute(QGeoPositionInfo::GroundSpeed);
-}
-
-/*!
- \qmlproperty real Position::horizontalAccuracy
-
- This property holds the horizontal accuracy of the coordinate (in meters).
-
- \sa horizontalAccuracyValid, coordinate
-*/
-qreal QDeclarativePosition::horizontalAccuracy() const
-{
- return m_computedHorizontalAccuracy.value();
-}
-
-qreal QDeclarativePosition::horizontalAccuracyActualCalculation() const
-{
- return m_info.attribute(QGeoPositionInfo::HorizontalAccuracy);
-}
-
-/*!
- \qmlproperty bool Position::horizontalAccuracyValid
-
- This property is true if \l horizontalAccuracy has been set
- (to indicate whether that data has been received or not, as every update
- does not necessarily contain all data).
-
- \sa horizontalAccuracy
-*/
-bool QDeclarativePosition::isHorizontalAccuracyValid() const
-{
- return m_computedHorizontalAccuracyValid.value();
-}
-
-bool QDeclarativePosition::isHorizontalAccuracyValidActualCalculation() const
-{
- return !qIsNaN(m_info.attribute(QGeoPositionInfo::HorizontalAccuracy));
-}
-
-/*!
- \qmlproperty real Position::verticalAccuracy
-
- This property holds the vertical accuracy of the coordinate (in meters).
-
- \sa verticalAccuracyValid, coordinate
-*/
-qreal QDeclarativePosition::verticalAccuracy() const
-{
- return m_computedVerticalAccuracy.value();
-}
-
-qreal QDeclarativePosition::verticalAccuracyActualCalculation() const
-{
- return m_info.attribute(QGeoPositionInfo::VerticalAccuracy);
-}
-
-/*!
- \qmlproperty bool Position::verticalAccuracyValid
-
- This property is true if \l verticalAccuracy has been set
- (to indicate whether that data has been received or not, as every update
- does not necessarily contain all data).
-
- \sa verticalAccuracy
-*/
-bool QDeclarativePosition::isVerticalAccuracyValid() const
-{
- return m_computedVerticalAccuracyValid.value();
-}
-
-bool QDeclarativePosition::isVerticalAccuracyValidActualCalculation() const
-{
- return !qIsNaN(m_info.attribute(QGeoPositionInfo::VerticalAccuracy));
-}
-
-/*!
- \qmlproperty date Position::timestamp
-
- This property holds the timestamp when this position
- was received. If the property has not been set, it is invalid.
-
- It is a read-only property.
-*/
-QDateTime QDeclarativePosition::timestamp() const
-{
- return m_computedTimestamp.value();
-}
-
-QDateTime QDeclarativePosition::timestampActualCalculation() const
-{
- return m_info.timestamp();
-}
-
-/*!
- \qmlproperty bool Position::directionValid
- \since Qt Positioning 5.3
-
- This property is true if \l direction has been set (to indicate whether that data has been
- received or not, as every update does not necessarily contain all data).
-
- \sa direction
-*/
-bool QDeclarativePosition::isDirectionValid() const
-{
- return m_computedDirectionValid.value();
-}
-
-bool QDeclarativePosition::isDirectionValidActualCalculation() const
-{
- return !qIsNaN(m_info.attribute(QGeoPositionInfo::Direction));
-}
-
-/*!
- \qmlproperty double Position::direction
- \since Qt Positioning 5.3
-
- This property holds the value of the direction of travel in degrees from true north.
-
- It is a read-only property.
-
- \sa directionValid
-*/
-double QDeclarativePosition::direction() const
-{
- return m_computedDirection.value();
-}
-
-double QDeclarativePosition::directionActualCalculation() const
-{
- return m_info.attribute(QGeoPositionInfo::Direction);
-}
-
-/*!
- \qmlproperty bool Position::verticalSpeedValid
- \since Qt Positioning 5.3
-
- This property is true if \l verticalSpeed has been set (to indicate whether that data has been
- received or not, as every update does not necessarily contain all data).
-
- \sa verticalSpeed
-*/
-bool QDeclarativePosition::isVerticalSpeedValid() const
-{
- return m_computedVerticalSpeedValid.value();
-}
-
-bool QDeclarativePosition::isVerticalSpeedValidActualCalculation() const
-{
- return !qIsNaN(m_info.attribute(QGeoPositionInfo::VerticalSpeed));
-}
-
-/*!
- \qmlproperty double Position::verticalSpeed
- \since Qt Positioning 5.3
-
- This property holds the value of the vertical speed in meters per second.
-
- It is a read-only property.
-
- \sa verticalSpeedValid
-*/
-double QDeclarativePosition::verticalSpeed() const
-{
- return m_computedVerticalSpeed.value();
-}
-
-double QDeclarativePosition::verticalSpeedActualCalculation() const
-{
- return m_info.attribute(QGeoPositionInfo::VerticalSpeed);
-}
-
-/*!
- \qmlproperty bool Position::magneticVariationValid
- \since Qt Positioning 5.4
-
- This property is true if \l magneticVariation has been set (to indicate whether that data has been
- received or not, as every update does not necessarily contain all data).
-
- \sa magneticVariation
-*/
-bool QDeclarativePosition::isMagneticVariationValid() const
-{
- return m_computedMagneticVariationValid.value();
-}
-
-bool QDeclarativePosition::isMagneticVariationValidActualCalculation() const
-{
- return !qIsNaN(m_info.attribute(QGeoPositionInfo::MagneticVariation));
-}
-
-/*!
- \qmlproperty double Position::magneticVariation
- \since Qt Positioning 5.4
-
- This property holds the angle between the horizontal component of the
- magnetic field and true north, in degrees. Also known as magnetic
- declination. A positive value indicates a clockwise direction from
- true north and a negative value indicates a counter-clockwise direction.
-
- It is a read-only property.
-
- \sa magneticVariationValid
-*/
-double QDeclarativePosition::magneticVariation() const
-{
- return m_computedMagneticVariation.value();
-}
-
-double QDeclarativePosition::magneticVariationActualCalculation() const
-{
- return m_info.attribute(QGeoPositionInfo::MagneticVariation);
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioningquick/qdeclarativeposition_p.h b/src/positioningquick/qdeclarativeposition_p.h
deleted file mode 100644
index 174828bf..00000000
--- a/src/positioningquick/qdeclarativeposition_p.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Jolla Ltd.
-** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-***************************************************************************/
-
-#ifndef QDECLARATIVEPOSITION_H
-#define QDECLARATIVEPOSITION_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
-#include <QtPositioning/QGeoPositionInfo>
-#include <QtCore/QObject>
-#include <QtCore/QDateTime>
-#include <QtQml/qqml.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativePosition : public QObject
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(Position)
- QML_ADDED_IN_VERSION(5, 0)
-
- Q_PROPERTY(bool latitudeValid READ isLatitudeValid BINDABLE bindableLatitudeValid)
- Q_PROPERTY(bool longitudeValid READ isLongitudeValid BINDABLE bindableLongitudeValid)
- Q_PROPERTY(bool altitudeValid READ isAltitudeValid BINDABLE bindableAltitudeValid)
- Q_PROPERTY(QGeoCoordinate coordinate READ coordinate BINDABLE bindableCoordinate)
- Q_PROPERTY(QDateTime timestamp READ timestamp BINDABLE bindableTimestamp)
- Q_PROPERTY(double speed READ speed BINDABLE bindableSpeed)
- Q_PROPERTY(bool speedValid READ isSpeedValid BINDABLE bindableSpeedValid)
- Q_PROPERTY(qreal horizontalAccuracy READ horizontalAccuracy BINDABLE bindableHorizontalAccuracy)
- Q_PROPERTY(qreal verticalAccuracy READ verticalAccuracy BINDABLE binableVerticalAccuracy)
- Q_PROPERTY(bool horizontalAccuracyValid READ isHorizontalAccuracyValid BINDABLE
- bindableHorizontalAccuracyValid)
- Q_PROPERTY(bool verticalAccuracyValid READ isVerticalAccuracyValid BINDABLE
- bindableVerticalAccuracyValid)
-
- Q_PROPERTY(bool directionValid READ isDirectionValid BINDABLE bindableDirectionValid
- REVISION(5, 1))
- Q_PROPERTY(double direction READ direction BINDABLE bindableDirection REVISION(5, 1))
- Q_PROPERTY(bool verticalSpeedValid READ isVerticalSpeedValid BINDABLE bindableVerticalSpeedValid
- REVISION(5, 1))
- Q_PROPERTY(double verticalSpeed READ verticalSpeed BINDABLE bindableVerticalSpeed
- REVISION(5, 1))
-
- Q_PROPERTY(double magneticVariation READ magneticVariation BINDABLE bindableMagneticVariation
- REVISION(5, 2))
- Q_PROPERTY(bool magneticVariationValid READ isMagneticVariationValid BINDABLE
- bindableMagneticVariationValid REVISION(5, 2))
-
-public:
- explicit QDeclarativePosition(QObject *parent = 0);
- ~QDeclarativePosition();
-
- bool isLatitudeValid() const;
- bool isLongitudeValid() const;
- bool isAltitudeValid() const;
- QDateTime timestamp() const;
- double speed() const;
- bool isSpeedValid() const;
- QGeoCoordinate coordinate() const;
- bool isHorizontalAccuracyValid() const;
- qreal horizontalAccuracy() const;
- bool isVerticalAccuracyValid() const;
- qreal verticalAccuracy() const;
-
- bool isDirectionValid() const;
- double direction() const;
-
- bool isVerticalSpeedValid() const;
- double verticalSpeed() const;
-
- bool isMagneticVariationValid() const;
- double magneticVariation() const;
-
- void setPosition(const QGeoPositionInfo &info);
- const QGeoPositionInfo &position() const;
-
- QBindable<bool> bindableLatitudeValid() const;
- QBindable<bool> bindableLongitudeValid() const;
- QBindable<bool> bindableAltitudeValid() const;
- QBindable<QGeoCoordinate> bindableCoordinate() const;
- QBindable<QDateTime> bindableTimestamp() const;
- QBindable<double> bindableSpeed() const;
- QBindable<bool> bindableSpeedValid() const;
- QBindable<qreal> bindableHorizontalAccuracy() const;
- QBindable<qreal> binableVerticalAccuracy() const;
- QBindable<bool> bindableHorizontalAccuracyValid() const;
- QBindable<bool> bindableVerticalAccuracyValid() const;
- QBindable<bool> bindableDirectionValid() const;
- QBindable<double> bindableDirection() const;
- QBindable<bool> bindableVerticalSpeedValid() const;
- QBindable<double> bindableVerticalSpeed() const;
- QBindable<double> bindableMagneticVariation() const;
- QBindable<bool> bindableMagneticVariationValid() const;
-
-private:
- bool isLatitudeValidActualCalculation() const;
- bool isLongitudeValidActualCalculation() const;
- bool isAltitudeValidActualCalculation() const;
- QGeoCoordinate coordinateActualCalculation() const;
- QDateTime timestampActualCalculation() const;
- double speedActualCalculation() const;
- bool isSpeedValidActualCalculation() const;
- qreal horizontalAccuracyActualCalculation() const;
- qreal verticalAccuracyActualCalculation() const;
- bool isHorizontalAccuracyValidActualCalculation() const;
- bool isVerticalAccuracyValidActualCalculation() const;
- bool isDirectionValidActualCalculation() const;
- double directionActualCalculation() const;
- bool isVerticalSpeedValidActualCalculation() const;
- double verticalSpeedActualCalculation() const;
- double magneticVariationActualCalculation() const;
- bool isMagneticVariationValidActualCalculation() const;
-
- QGeoPositionInfo m_info;
-
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedLatitudeValid,
- &QDeclarativePosition::isLatitudeValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedLongitudeValid,
- &QDeclarativePosition::isLongitudeValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedAltitudeValid,
- &QDeclarativePosition::isAltitudeValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, QGeoCoordinate, m_computedCoordinate,
- &QDeclarativePosition::coordinateActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, QDateTime, m_computedTimestamp,
- &QDeclarativePosition::timestampActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedSpeed,
- &QDeclarativePosition::speedActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedSpeedValid,
- &QDeclarativePosition::isSpeedValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, qreal, m_computedHorizontalAccuracy,
- &QDeclarativePosition::horizontalAccuracyActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, qreal, m_computedVerticalAccuracy,
- &QDeclarativePosition::verticalAccuracyActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedHorizontalAccuracyValid,
- &QDeclarativePosition::isHorizontalAccuracyValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedVerticalAccuracyValid,
- &QDeclarativePosition::isVerticalAccuracyValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedDirectionValid,
- &QDeclarativePosition::isDirectionValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedDirection,
- &QDeclarativePosition::directionActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedVerticalSpeedValid,
- &QDeclarativePosition::isVerticalSpeedValidActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedVerticalSpeed,
- &QDeclarativePosition::verticalSpeedActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, double, m_computedMagneticVariation,
- &QDeclarativePosition::magneticVariationActualCalculation)
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePosition, bool, m_computedMagneticVariationValid,
- &QDeclarativePosition::isMagneticVariationValidActualCalculation)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativePosition)
-
-#endif
diff --git a/src/positioningquick/qdeclarativepositionsource.cpp b/src/positioningquick/qdeclarativepositionsource.cpp
deleted file mode 100644
index 5a84c788..00000000
--- a/src/positioningquick/qdeclarativepositionsource.cpp
+++ /dev/null
@@ -1,913 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativepositionsource_p.h"
-#include "qdeclarativeposition_p.h"
-
-#include <QtCore/QCoreApplication>
-#include <QtQml/qqmlinfo.h>
-#include <QtQml/qqml.h>
-#include <qdeclarativepluginparameter_p.h>
-#include <QFile>
-#include <QtNetwork/QTcpSocket>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype PositionSource
- //! \instantiates QDeclarativePositionSource
- \inqmlmodule QtPositioning
- \since 5.2
-
- \brief The PositionSource type provides the device's current position.
-
- The PositionSource type provides information about the user device's
- current position. The position is available as a \l{Position} type, which
- contains all the standard parameters typically available from GPS and other
- similar systems, including longitude, latitude, speed and accuracy details.
-
- As different position sources are available on different platforms and
- devices, these are categorized by their basic type (Satellite, NonSatellite,
- and AllPositioningMethods). The available methods for the current platform
- can be enumerated in the \l{supportedPositioningMethods} property.
-
- To indicate which methods are suitable for your application, set the
- \l{preferredPositioningMethods} property. If the preferred methods are not
- available, the default source of location data for the platform will be
- chosen instead. If no default source is available (because none are installed
- for the runtime platform, or because it is disabled), the \l{valid} property
- will be set to false.
-
- The \l updateInterval property can then be used to indicate how often your
- application wishes to receive position updates. The \l{start}(),
- \l{stop}() and \l{update}() methods can be used to control the operation
- of the PositionSource, as well as the \l{active} property, which when set
- is equivalent to calling \l{start}() or \l{stop}().
-
- When the PositionSource is active, position updates can be retrieved
- either by simply using the \l{position} property in a binding (as the
- value of another item's property), or by providing an implementation of
- the \c {onPositionChanged} signal-handler.
-
- \section2 Example Usage
-
- The following example shows a simple PositionSource used to receive
- updates every second and print the longitude and latitude out to
- the console.
-
- \code
- PositionSource {
- id: src
- updateInterval: 1000
- active: true
-
- onPositionChanged: {
- var coord = src.position.coordinate;
- console.log("Coordinate:", coord.longitude, coord.latitude);
- }
- }
- \endcode
-
- The \l{geoflickr}{GeoFlickr} example application shows how to use
- a PositionSource in your application to retrieve local data for users
- from a REST web service.
-
- \section2 Controlling Operation State
-
- As it's mentioned above, PositionSource provides two ways to control its
- operation state:
-
- \list
- \li By using the \l active \l {Qt Bindable Properties}{bindable} property.
- \li By using \l start() and \l stop() methods.
- \endlist
-
- \note It's very important not to mix these approaches. If a bindable
- \l active property is used to control the PositionSource object, but later
- \l start() or \l stop() is called from the other part of the code, the
- binding is broken, which may result in, for example, a UI element that is
- not connected to any underlying object anymore.
-
- Consider the following example of \b {bad code} where the \c active property
- is bound to the CheckBox state, and calling \l stop() in the \c onClicked
- signal handler breaks that binding.
-
- \qml
- Window {
- width: 640
- height: 480
- visible: true
-
- PositionSource {
- id: posSource
- name: "geoclue2"
- active: cb.checked
- }
-
- Column {
- anchors.centerIn: parent
- spacing: 20
- CheckBox {
- id: cb
- }
- Button {
- id: btn
- text: "Stop"
- onClicked: {
- posSource.stop()
- }
- }
- }
- }
- \endqml
-
- Once the \e Stop button is clicked, \l stop() is executed, and the binding
- for the \l active property is broken. At this point the CheckBox UI element
- is no longer controlling the PositionSource object.
-
- A straightforward fix in this case is to update the CheckBox state from
- the \c onClicked handler. As soon as the CheckBox is unchecked, the
- \l active property will be notified, and the PositionSource object's state
- will update accordingly. The UI will also be in a consistent state.
-
- \qml
- Button {
- id: btn
- text: "Stop"
- onClicked: {
- cb.checked = false
- }
- }
- \endqml
-
- \note Using \l update() to request a single position update \e {does not}
- have any effect on the \l active property's bindings, so they can be used
- together without any problems.
-
- \sa {QtPositioning::Position}, {QGeoPositionInfoSource}, {PluginParameter},
- {Qt Bindable Properties}
-
-*/
-
-QDeclarativePositionSource::QDeclarativePositionSource()
-{
- m_position.setValueBypassingBindings(new QDeclarativePosition(this));
-}
-
-QDeclarativePositionSource::~QDeclarativePositionSource()
-{
- delete m_positionSource;
-}
-
-
-/*!
- \qmlproperty string PositionSource::name
-
- This property holds the unique internal name for the plugin currently
- providing position information.
-
- Setting the property causes the PositionSource to use a particular positioning provider. If
- the PositionSource is active at the time that the name property is changed, it will become
- inactive. If the specified positioning provider cannot be loaded the position source will
- become invalid.
-
- Changing the name property may cause the \l {updateInterval}, \l {supportedPositioningMethods}
- and \l {preferredPositioningMethods} properties to change as well.
-*/
-
-
-QString QDeclarativePositionSource::name() const
-{
- return m_sourceName;
-}
-
-void QDeclarativePositionSource::setName(const QString &newName)
-{
- m_sourceName.removeBindingUnlessInWrapper();
- if (m_positionSource && m_positionSource->sourceName() == newName)
- return;
-
- if (newName.isEmpty() && m_defaultSourceUsed)
- return; // previously attached to a default source, now requesting the same.
-
- const QString previousName = name();
-
- if (!m_componentComplete || !m_parametersInitialized) {
- if (previousName != newName) {
- m_sourceName.setValueBypassingBindings(newName);
- m_sourceName.notify();
- }
- return;
- }
-
- // tryAttach() will update the m_sourceName correctly
- tryAttach(newName, false);
-}
-
-QBindable<QString> QDeclarativePositionSource::bindableName()
-{
- return QBindable<QString>(&m_sourceName);
-}
-
-QBindable<QDeclarativePosition *> QDeclarativePositionSource::bindablePosition() const
-{
- return QBindable<QDeclarativePosition *>(&m_position);
-}
-
-/*!
- \internal
-*/
-void QDeclarativePositionSource::tryAttach(const QString &newName, bool useFallback)
-{
- const QString previousName = name();
- const bool sourceExisted = (m_positionSource != nullptr);
-
- int previousUpdateInterval = updateInterval();
- PositioningMethods previousPositioningMethods = supportedPositioningMethods();
- PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods();
-
- m_defaultSourceUsed = false;
-
- if (newName.isEmpty()) {
- setSource(QGeoPositionInfoSource::createDefaultSource(parameterMap(), this));
- m_defaultSourceUsed = true;
- } else {
- setSource(QGeoPositionInfoSource::createSource(newName, parameterMap(), this));
- if (!m_positionSource && useFallback) {
- setSource(QGeoPositionInfoSource::createDefaultSource(parameterMap(), this));
- m_defaultSourceUsed = true;
- }
- }
-
- if (m_positionSource) {
- m_sourceName.setValueBypassingBindings(m_positionSource->sourceName());
-
- connect(m_positionSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
- this, SLOT(positionUpdateReceived(QGeoPositionInfo)));
- connect(m_positionSource, SIGNAL(errorOccurred(QGeoPositionInfoSource::Error)),
- this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error)));
-
- m_positionSource->setUpdateInterval(m_updateInterval);
- m_positionSource->setPreferredPositioningMethods(
- static_cast<QGeoPositionInfoSource::PositioningMethods>(int(m_preferredPositioningMethods)));
-
- const QGeoPositionInfo &lastKnown = m_positionSource->lastKnownPosition();
- if (lastKnown.isValid())
- setPosition(lastKnown);
- } else {
- m_sourceName.setValueBypassingBindings(newName);
- m_defaultSourceUsed = false;
- if (m_active) {
- // We do not want to break the binding here, because we just want to
- // give the user an opportunity to select another plugin and keep
- // working.
- m_active.setValueBypassingBindings(false);
- m_active.notify();
- }
- }
-
- if (previousUpdateInterval != updateInterval())
- emit updateIntervalChanged();
-
- if (previousPreferredPositioningMethods != preferredPositioningMethods())
- emit preferredPositioningMethodsChanged();
-
- if (previousPositioningMethods != supportedPositioningMethods())
- notifySupportedPositioningMethodsChanged();
-
- const bool sourceCurrentlyExists = (m_positionSource != nullptr);
- if (sourceExisted != sourceCurrentlyExists) {
- m_isValid.notify();
- emit validityChanged();
- }
-
- if (m_active) { // implies m_positionSource
- if (!sourceExisted) {
- // delay ensures all properties have been set
- QTimer::singleShot(0, this, [this]() { executeStart(); });
- } else {
- // New source is set. It should be inactive by default.
- // But we do not want to break the binding.
- m_active.setValueBypassingBindings(false);
- m_active.notify();
- }
- }
-
- if (previousName != m_sourceName)
- m_sourceName.notify();
-}
-
-/*!
- \qmlproperty bool PositionSource::valid
-
- This property is true if the PositionSource object has acquired a valid
- backend plugin to provide data. If false, other methods on the PositionSource
- will have no effect.
-
- Applications should check this property to determine whether positioning is
- available and enabled on the runtime platform, and react accordingly.
-*/
-bool QDeclarativePositionSource::isValid() const
-{
- return m_isValid.value();
-}
-
-QBindable<bool> QDeclarativePositionSource::bindableIsValid() const
-{
- return QBindable<bool>(&m_isValid);
-}
-
-bool QDeclarativePositionSource::isValidActualComputation() const
-{
- return m_positionSource != nullptr;
-}
-
-void QDeclarativePositionSource::handleUpdateTimeout()
-{
- // notify will be called by the calling method
- m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::UpdateTimeoutError);
-
- if (!m_active)
- return;
-
- if (m_singleUpdate) {
- m_singleUpdate = false;
-
- if (!m_regularUpdates) {
- // only singleUpdate based timeouts change activity
- // continuous updates may resume again
- // (see QGeoPositionInfoSource::startUpdates())
- m_active.setValueBypassingBindings(false);
- m_active.notify();
- }
- }
-}
-
-/*!
- \internal
-*/
-void QDeclarativePositionSource::onParameterInitialized()
-{
- m_parametersInitialized = true;
- for (QDeclarativePluginParameter *p: qAsConst(m_parameters)) {
- if (!p->isInitialized()) {
- m_parametersInitialized = false;
- break;
- }
- }
-
- // If here, componentComplete has been called.
- if (m_parametersInitialized)
- tryAttach(m_sourceName.value());
-}
-
-void QDeclarativePositionSource::notifySupportedPositioningMethodsChanged()
-{
- m_supportedPositioningMethods.notify();
- emit supportedPositioningMethodsChanged();
-}
-
-void QDeclarativePositionSource::setPosition(const QGeoPositionInfo &pi)
-{
- m_position.value()->setPosition(pi);
- m_position.notify();
- emit positionChanged();
-}
-
-void QDeclarativePositionSource::setSource(QGeoPositionInfoSource *source)
-{
- if (m_positionSource)
- delete m_positionSource;
-
- if (!source) {
- m_positionSource = nullptr;
- } else {
- m_positionSource = source;
- connect(m_positionSource, &QGeoPositionInfoSource::supportedPositioningMethodsChanged,
- this, &QDeclarativePositionSource::notifySupportedPositioningMethodsChanged);
- }
-}
-
-bool QDeclarativePositionSource::parametersReady()
-{
- for (const QDeclarativePluginParameter *p: qAsConst(m_parameters)) {
- if (!p->isInitialized())
- return false;
- }
- return true;
-}
-
-/*!
- \internal
-*/
-QVariantMap QDeclarativePositionSource::parameterMap() const
-{
- QVariantMap map;
-
- for (int i = 0; i < m_parameters.size(); ++i) {
- QDeclarativePluginParameter *parameter = m_parameters.at(i);
- map.insert(parameter->name(), parameter->value());
- }
-
- return map;
-}
-
-/*!
- \internal
-*/
-void QDeclarativePositionSource::setUpdateInterval(int updateInterval)
-{
- if (m_positionSource) {
- int previousUpdateInterval = m_positionSource->updateInterval();
-
- m_updateInterval = updateInterval;
-
- if (previousUpdateInterval != updateInterval) {
- m_positionSource->setUpdateInterval(updateInterval);
- if (previousUpdateInterval != m_positionSource->updateInterval())
- emit updateIntervalChanged();
- }
- } else {
- if (m_updateInterval != updateInterval) {
- m_updateInterval = updateInterval;
- emit updateIntervalChanged();
- }
- }
-}
-
-/*!
- \qmlproperty int PositionSource::updateInterval
-
- This property holds the desired interval between updates (milliseconds).
-
- \sa {QGeoPositionInfoSource::updateInterval()}
-*/
-
-int QDeclarativePositionSource::updateInterval() const
-{
- if (!m_positionSource)
- return m_updateInterval;
-
- return m_positionSource->updateInterval();
-}
-
-/*!
- \qmlproperty enumeration PositionSource::supportedPositioningMethods
-
- This property holds the supported positioning methods of the
- current source.
-
- \list
- \li PositionSource.NoPositioningMethods - No positioning methods supported (no source).
- \li PositionSource.SatellitePositioningMethods - Satellite-based positioning methods such as GPS are supported.
- \li PositionSource.NonSatellitePositioningMethods - Non-satellite-based methods are supported.
- \li PositionSource.AllPositioningMethods - Both satellite-based and non-satellite positioning methods are supported.
- \endlist
-
-*/
-
-QDeclarativePositionSource::PositioningMethods
-QDeclarativePositionSource::supportedPositioningMethods() const
-{
- return m_supportedPositioningMethods.value();
-}
-
-QDeclarativePositionSource::PositioningMethods
-QDeclarativePositionSource::supportedMethodsActualComputation() const
-{
- if (m_positionSource) {
- return static_cast<QDeclarativePositionSource::PositioningMethods>(
- int(m_positionSource->supportedPositioningMethods()));
- }
- return QDeclarativePositionSource::NoPositioningMethods;
-}
-
-QBindable<QDeclarativePositionSource::PositioningMethods>
-QDeclarativePositionSource::bindableSupportedPositioningMethods() const
-{
- return QBindable<PositioningMethods>(&m_supportedPositioningMethods);
-}
-
-/*!
- \qmlproperty enumeration PositionSource::preferredPositioningMethods
-
- This property holds the preferred positioning methods of the
- current source.
-
- \list
- \li PositionSource.NoPositioningMethods - No positioning method is preferred.
- \li PositionSource.SatellitePositioningMethods - Satellite-based positioning methods such as GPS should be preferred.
- \li PositionSource.NonSatellitePositioningMethods - Non-satellite-based methods should be preferred.
- \li PositionSource.AllPositioningMethods - Any positioning methods are acceptable.
- \endlist
-
-*/
-
-void QDeclarativePositionSource::setPreferredPositioningMethods(PositioningMethods methods)
-{
- if (m_positionSource) {
- PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods();
-
- m_preferredPositioningMethods = methods;
-
- if (previousPreferredPositioningMethods != methods) {
- m_positionSource->setPreferredPositioningMethods(
- static_cast<QGeoPositionInfoSource::PositioningMethods>(int(methods)));
- if (previousPreferredPositioningMethods != m_positionSource->preferredPositioningMethods())
- emit preferredPositioningMethodsChanged();
- }
- } else {
- if (m_preferredPositioningMethods != methods) {
- m_preferredPositioningMethods = methods;
- emit preferredPositioningMethodsChanged();
- }
- }
-}
-
-QDeclarativePositionSource::PositioningMethods QDeclarativePositionSource::preferredPositioningMethods() const
-{
- if (m_positionSource) {
- return static_cast<QDeclarativePositionSource::PositioningMethods>(
- int(m_positionSource->preferredPositioningMethods()));
- }
- return m_preferredPositioningMethods;
-}
-
-/*!
- \qmlmethod PositionSource::start()
-
- Requests updates from the location source.
- Uses \l updateInterval if set, default interval otherwise.
- If there is no source available, this method has no effect.
-
- \note Calling this method breaks the bindings of
- \l {PositionSource::}{active} property.
-
- \sa stop, update, active
-*/
-
-void QDeclarativePositionSource::start()
-{
- if (m_positionSource) {
- m_active.removeBindingUnlessInWrapper();
- executeStart();
- }
-}
-
-/*!
- \qmlmethod PositionSource::update(int timeout)
-
- A convenience method to request single update from the location source.
- If there is no source available, this method has no effect.
-
- If the position source is not active, it will be activated for as
- long as it takes to receive an update, or until the request times
- out. The request timeout period is source-specific.
-
- The \a timeout is specified in milliseconds. If the \a timeout is zero
- (the default value), it defaults to a reasonable timeout period as
- appropriate for the source.
-
- \sa start, stop, active
-*/
-
-void QDeclarativePositionSource::update(int timeout)
-{
- if (m_positionSource) {
- m_singleUpdate = true;
- if (!m_active) {
- // Questionable: we do not want this method to break the binding.
- // Mostly because it can be called while the updates are already
- // running.
- m_active.setValueBypassingBindings(true);
- m_active.notify();
- }
- // Use default timeout value. Set active before calling the
- // update request because on some platforms there may
- // be results immediately.
- m_positionSource->requestUpdate(timeout);
- }
-}
-
-/*!
- \qmlmethod PositionSource::stop()
-
- Stops updates from the location source.
- If there is no source available or it is not active,
- this method has no effect.
-
- \note Calling this method breaks the bindings of
- \l {PositionSource::}{active} property.
-
- \sa start, update, active
-*/
-
-void QDeclarativePositionSource::stop()
-{
- if (m_positionSource) {
- m_positionSource->stopUpdates();
- m_regularUpdates = false;
- // Try to break the binding even if we do not actually need to update
- // the active state. The m_active can be updated later, when the
- // single update request finishes.
- m_active.removeBindingUnlessInWrapper();
- if (m_active && !m_singleUpdate) {
- m_active.setValueBypassingBindings(false);
- m_active.notify();
- }
- }
-}
-
-/*!
- \qmlproperty bool PositionSource::active
-
- This property indicates whether the position source is active.
- Setting this property to false equals calling \l stop, and
- setting this property true equals calling \l start.
-
- \sa start, stop, update
-*/
-void QDeclarativePositionSource::setActive(bool active)
-{
- // We need to remove binding, if this method is called explicitly.
- // Other changes to m_active are done inside start() and stop() methods.
- m_active.removeBindingUnlessInWrapper();
- if (active == m_active)
- return;
-
- if (active) {
- // delay ensures all properties have been set
- QTimer::singleShot(0, this, [this]() { executeStart(); });
- } else {
- stop();
- }
-}
-
-bool QDeclarativePositionSource::isActive() const
-{
- return m_active;
-}
-
-/*!
- \qmlproperty Position PositionSource::position
-
- This property holds the last known positional data.
- It is a read-only property.
-
- The Position type has different positional member variables,
- whose validity can be checked with appropriate validity functions
- (for example sometimes an update does not have speed or altitude data).
-
- However, whenever a \c {positionChanged} signal has been received, at least
- position::coordinate::latitude, position::coordinate::longitude, and position::timestamp can
- be assumed to be valid.
-
- \sa start, stop, update
-*/
-
-QDeclarativePosition *QDeclarativePositionSource::position()
-{
- return m_position.value();
-}
-
-void QDeclarativePositionSource::positionUpdateReceived(const QGeoPositionInfo &update)
-{
- setPosition(update);
-
- if (m_singleUpdate && m_active) {
- // we need to reset m_singleUpdate because we got one
- m_singleUpdate = false;
- if (!m_regularUpdates) {
- // but we change the active state only if the regular updates are
- // also stopped
- m_active.setValueBypassingBindings(false);
- m_active.notify();
- }
- }
-}
-
-
-/*!
- \qmlproperty enumeration PositionSource::sourceError
-
- This property holds the error which last occurred with the PositionSource.
-
- \list
- \li PositionSource.AccessError - The connection setup to the remote positioning backend failed because the
- application lacked the required privileges.
- \li PositionSource.ClosedError - The positioning backend closed the connection, which happens for example in case
- the user is switching location services to off. As soon as the location service is re-enabled
- regular updates will resume.
- \li PositionSource.NoError - No error has occurred.
- \li PositionSource.UnknownSourceError - An unidentified error occurred.
- \li PositionSource.UpdateTimeoutError - The current position could not be
- retrieved within the specified timeout, or this PositionSource determined
- that it will not be able to provide further regular updates.
- \endlist
-
-*/
-
-QDeclarativePositionSource::SourceError QDeclarativePositionSource::sourceError() const
-{
- return m_sourceError;
-}
-
-QBindable<QDeclarativePositionSource::SourceError>
-QDeclarativePositionSource::bindableSourceError() const
-{
- return QBindable<QDeclarativePositionSource::SourceError>(&m_sourceError);
-}
-
-QGeoPositionInfoSource *QDeclarativePositionSource::positionSource() const
-{
- return m_positionSource;
-}
-
-/*!
- \qmlproperty list<PluginParameter> PositionSource::parameters
- \qmldefault
-
- This property holds the list of plugin parameters.
-
- \since QtPositioning 5.14
-*/
-QQmlListProperty<QDeclarativePluginParameter> QDeclarativePositionSource::parameters()
-{
- return QQmlListProperty<QDeclarativePluginParameter>(this,
- 0,
- parameter_append,
- parameter_count,
- parameter_at,
- parameter_clear);
-}
-
-/*!
- \internal
-*/
-void QDeclarativePositionSource::parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *parameter)
-{
- QDeclarativePositionSource *p = static_cast<QDeclarativePositionSource *>(prop->object);
- p->m_parameters.append(parameter);
-}
-
-/*!
- \internal
-*/
-qsizetype QDeclarativePositionSource::parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop)
-{
- return static_cast<QDeclarativePositionSource *>(prop->object)->m_parameters.count();
-}
-
-/*!
- \internal
-*/
-QDeclarativePluginParameter *QDeclarativePositionSource::parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, qsizetype index)
-{
- return static_cast<QDeclarativePositionSource *>(prop->object)->m_parameters[index];
-}
-
-/*!
- \internal
-*/
-void QDeclarativePositionSource::parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop)
-{
- QDeclarativePositionSource *p = static_cast<QDeclarativePositionSource *>(prop->object);
- p->m_parameters.clear();
-}
-
-void QDeclarativePositionSource::executeStart()
-{
- if (m_positionSource) {
- m_positionSource->startUpdates();
-
- // If this method is called directly from start(), the binding is
- // already broken there (for the consistency with stop()).
- // If this method is called by a timer, started in setActive(), we do
- // not need to break the binding, because it was already done (if
- // needed).
-
- m_regularUpdates = true;
- if (!m_active) {
- m_active.setValueBypassingBindings(true);
- m_active.notify();
- }
- }
-}
-
-void QDeclarativePositionSource::componentComplete()
-{
- m_componentComplete = true;
- m_parametersInitialized = true;
- for (QDeclarativePluginParameter *p: qAsConst(m_parameters)) {
- if (!p->isInitialized()) {
- m_parametersInitialized = false;
- connect(p, &QDeclarativePluginParameter::initialized,
- this, &QDeclarativePositionSource::onParameterInitialized);
- }
- }
-
- if (m_parametersInitialized)
- tryAttach(m_sourceName.value());
-}
-
-/*!
- \qmlmethod bool PositionSource::setBackendProperty(string name, Variant value)
-
- Sets the backend-specific property named \a name to \a value.
- Returns true on success, false otherwise, including if called on an uninitialized PositionSource.
- Supported backend-specific properties are listed and described in
- \l {Qt Positioning plugins#Default plugins}.
-
- \since Qt Positioning 5.14
-
- \sa backendProperty, QGeoPositionInfoSource::setBackendProperty
-*/
-bool QDeclarativePositionSource::setBackendProperty(const QString &name, const QVariant &value)
-{
- if (m_positionSource)
- return m_positionSource->setBackendProperty(name, value);
- return false;
-}
-
-/*!
- \qmlmethod Variant PositionSource::backendProperty(string name)
-
- Returns the value of the backend-specific property named \a name, if present.
- Otherwise, including if called on an uninitialized PositionSource, the return value will be invalid.
- Supported backend-specific properties are listed and described in
- \l {Qt Positioning plugins#Default plugins}.
-
- \since Qt Positioning 5.14
-
- \sa backendProperty, QGeoPositionInfoSource::setBackendProperty
-*/
-QVariant QDeclarativePositionSource::backendProperty(const QString &name) const
-{
- if (m_positionSource)
- return m_positionSource->backendProperty(name);
- return QVariant();
-}
-
-QBindable<bool> QDeclarativePositionSource::bindableActive()
-{
- return QBindable<bool>(&m_active);
-}
-
-/*!
- \internal
-*/
-void QDeclarativePositionSource::sourceErrorReceived(const QGeoPositionInfoSource::Error error)
-{
- if (error == QGeoPositionInfoSource::AccessError)
- m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::AccessError);
- else if (error == QGeoPositionInfoSource::ClosedError)
- m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::ClosedError);
- else if (error == QGeoPositionInfoSource::UpdateTimeoutError)
- handleUpdateTimeout(); // also sets m_sourceError
- else if (error == QGeoPositionInfoSource::NoError)
- return; //nothing to do
- else
- m_sourceError.setValueBypassingBindings(QDeclarativePositionSource::UnknownSourceError);
-
- m_sourceError.notify();
- emit sourceErrorChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioningquick/qdeclarativepositionsource_p.h b/src/positioningquick/qdeclarativepositionsource_p.h
deleted file mode 100644
index 5651a266..00000000
--- a/src/positioningquick/qdeclarativepositionsource_p.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-***************************************************************************/
-
-#ifndef QDECLARATIVEPOSITIONSOURCE_H
-#define QDECLARATIVEPOSITIONSOURCE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
-#include <QtPositioningQuick/private/qdeclarativeposition_p.h>
-#include <QtCore/QObject>
-#include <QtNetwork/QAbstractSocket>
-#include <QtQml/QQmlParserStatus>
-#include <QtPositioning/qgeopositioninfosource.h>
-#include <QtPositioningQuick/private/qdeclarativepluginparameter_p.h>
-#include <QtCore/private/qproperty_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QFile;
-class QTcpSocket;
-
-class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativePositionSource : public QObject, public QQmlParserStatus
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(PositionSource)
- QML_ADDED_IN_VERSION(5, 0)
-
- Q_PROPERTY(QDeclarativePosition *position READ position NOTIFY positionChanged
- BINDABLE bindablePosition)
- Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged
- BINDABLE bindableActive)
- Q_PROPERTY(bool valid READ isValid NOTIFY validityChanged BINDABLE bindableIsValid)
- Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval
- NOTIFY updateIntervalChanged)
- Q_PROPERTY(PositioningMethods supportedPositioningMethods READ supportedPositioningMethods
- NOTIFY supportedPositioningMethodsChanged
- BINDABLE bindableSupportedPositioningMethods)
- Q_PROPERTY(PositioningMethods preferredPositioningMethods READ preferredPositioningMethods
- WRITE setPreferredPositioningMethods NOTIFY preferredPositioningMethodsChanged)
- Q_PROPERTY(SourceError sourceError READ sourceError NOTIFY sourceErrorChanged
- BINDABLE bindableSourceError)
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged BINDABLE bindableName)
- Q_PROPERTY(QQmlListProperty<QDeclarativePluginParameter> parameters READ parameters REVISION(5, 14))
- Q_ENUMS(PositioningMethod)
-
- Q_CLASSINFO("DefaultProperty", "parameters")
- Q_INTERFACES(QQmlParserStatus)
-
-public:
- enum PositioningMethod {
- NoPositioningMethods = QGeoPositionInfoSource::NoPositioningMethods,
- SatellitePositioningMethods = QGeoPositionInfoSource::SatellitePositioningMethods,
- NonSatellitePositioningMethods = QGeoPositionInfoSource::NonSatellitePositioningMethods,
- AllPositioningMethods = QGeoPositionInfoSource::AllPositioningMethods
- };
-
- Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)
- Q_FLAGS(PositioningMethods)
-
- enum SourceError {
- AccessError = QGeoPositionInfoSource::AccessError,
- ClosedError = QGeoPositionInfoSource::ClosedError,
- UnknownSourceError = QGeoPositionInfoSource::UnknownSourceError,
- NoError = QGeoPositionInfoSource::NoError,
- UpdateTimeoutError = QGeoPositionInfoSource::UpdateTimeoutError,
- };
- Q_ENUMS(SourceError)
-
- QDeclarativePositionSource();
- ~QDeclarativePositionSource();
- void setUpdateInterval(int updateInterval);
- void setActive(bool active);
- void setPreferredPositioningMethods(PositioningMethods methods);
-
- QString name() const;
- void setName(const QString &name);
-
- int updateInterval() const;
- bool isActive() const;
- bool isValid() const;
- QDeclarativePosition *position();
- PositioningMethods supportedPositioningMethods() const;
- PositioningMethods preferredPositioningMethods() const;
- SourceError sourceError() const;
- QGeoPositionInfoSource *positionSource() const;
- QQmlListProperty<QDeclarativePluginParameter> parameters();
- QVariantMap parameterMap() const;
-
- // Virtuals from QQmlParserStatus
- void classBegin() override { }
- void componentComplete() override;
-
- Q_REVISION(5, 14) Q_INVOKABLE bool setBackendProperty(const QString &name, const QVariant &value);
- Q_REVISION(5, 14) Q_INVOKABLE QVariant backendProperty(const QString &name) const;
-
- QBindable<PositioningMethods> bindableSupportedPositioningMethods() const;
- QBindable<SourceError> bindableSourceError() const;
- QBindable<bool> bindableIsValid() const;
- QBindable<QString> bindableName();
- QBindable<QDeclarativePosition *> bindablePosition() const;
- QBindable<bool> bindableActive();
-
-public Q_SLOTS:
- void update(int timeout = 0);
- void start();
- void stop();
-
-Q_SIGNALS:
- void positionChanged();
- void activeChanged();
- void updateIntervalChanged();
- void supportedPositioningMethodsChanged();
- void preferredPositioningMethodsChanged();
- void sourceErrorChanged();
- void nameChanged();
- void validityChanged();
-
-private Q_SLOTS:
- void positionUpdateReceived(const QGeoPositionInfo &update);
- void sourceErrorReceived(const QGeoPositionInfoSource::Error error);
- void onParameterInitialized();
- void notifySupportedPositioningMethodsChanged();
-
-private:
- void handleUpdateTimeout();
- void setPosition(const QGeoPositionInfo &pi);
- void setSource(QGeoPositionInfoSource *source);
- bool parametersReady();
- void tryAttach(const QString &name, bool useFallback = true);
-
- static void parameter_append(QQmlListProperty<QDeclarativePluginParameter> *prop, QDeclarativePluginParameter *mapObject);
- static qsizetype parameter_count(QQmlListProperty<QDeclarativePluginParameter> *prop);
- static QDeclarativePluginParameter *parameter_at(QQmlListProperty<QDeclarativePluginParameter> *prop, qsizetype index);
- static void parameter_clear(QQmlListProperty<QDeclarativePluginParameter> *prop);
-
- bool isValidActualComputation() const;
- PositioningMethods supportedMethodsActualComputation() const;
-
- void executeStart();
-
- QGeoPositionInfoSource *m_positionSource = nullptr;
- PositioningMethods m_preferredPositioningMethods = AllPositioningMethods;
- bool m_singleUpdate = false;
- bool m_regularUpdates = false;
- int m_updateInterval = 0;
- QList<QDeclarativePluginParameter *> m_parameters;
- bool m_componentComplete = false;
- bool m_parametersInitialized = false;
-
- bool m_defaultSourceUsed = false;
- Q_OBJECT_COMPAT_PROPERTY(QDeclarativePositionSource, QString, m_sourceName,
- &QDeclarativePositionSource::setName,
- &QDeclarativePositionSource::nameChanged)
-
- Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QDeclarativePositionSource, bool, m_active,
- &QDeclarativePositionSource::setActive,
- &QDeclarativePositionSource::activeChanged, false)
-
- Q_OBJECT_BINDABLE_PROPERTY(QDeclarativePositionSource, QDeclarativePosition *, m_position)
-
- Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QDeclarativePositionSource, SourceError, m_sourceError,
- NoError)
-
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePositionSource, PositioningMethods,
- m_supportedPositioningMethods,
- &QDeclarativePositionSource::supportedMethodsActualComputation)
-
- Q_OBJECT_COMPUTED_PROPERTY(QDeclarativePositionSource, bool, m_isValid,
- &QDeclarativePositionSource::isValidActualComputation)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativePositionSource)
-
-#endif
diff --git a/src/positioningquick/qpositioningquickglobal.h b/src/positioningquick/qpositioningquickglobal.h
deleted file mode 100644
index 214e4628..00000000
--- a/src/positioningquick/qpositioningquickglobal.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QPOSITIONINGQUICKGLOBAL_H
-#define QPOSITIONINGQUICKGLOBAL_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_STATIC
-# if defined(QT_BUILD_POSITIONINGQUICK_LIB)
-# define Q_POSITIONINGQUICK_EXPORT Q_DECL_EXPORT
-# else
-# define Q_POSITIONINGQUICK_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define Q_POSITIONINGQUICK_EXPORT
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QPOSITIONINGQUICKGLOBAL_H
diff --git a/src/positioningquick/qpositioningquickglobal_p.h b/src/positioningquick/qpositioningquickglobal_p.h
deleted file mode 100644
index ce284106..00000000
--- a/src/positioningquick/qpositioningquickglobal_p.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QPOSITIONINGQUICKGLOBAL_P_H
-#define QPOSITIONINGQUICKGLOBAL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qpositioningquickglobal.h"
-
-QT_BEGIN_NAMESPACE
-
-#define Q_POSITIONINGQUICK_PRIVATE_EXPORT Q_POSITIONINGQUICK_EXPORT
-
-QT_END_NAMESPACE
-
-void Q_POSITIONINGQUICK_PRIVATE_EXPORT qml_register_types_QtPositioning();
-
-#endif // QPOSITIONINGQUICKGLOBAL_P_H
diff --git a/src/positioningquick/qpositioningquickmodule_p.h b/src/positioningquick/qpositioningquickmodule_p.h
deleted file mode 100644
index 6d8aed91..00000000
--- a/src/positioningquick/qpositioningquickmodule_p.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT_POSITIONINGQUICKMODULE_P_H
-#define QT_POSITIONINGQUICKMODULE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtQml/qqml.h>
-#include "qpositioningquickglobal_p.h"
-
-#include <QtPositioning/QGeoCoordinate>
-#include <QtPositioning/QGeoAddress>
-#include <QtPositioning/QGeoRectangle>
-#include <QtPositioning/QGeoCircle>
-#include <QtPositioning/QGeoPath>
-#include <QtPositioning/QGeoPolygon>
-#include <QtPositioning/QGeoLocation>
-#include <QtPositioning/QGeoShape>
-#include <QtPositioning/QGeoPositionInfo>
-#include <QtPositioning/private/qgeocoordinateobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QGeoCoordinateForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoCoordinate)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoAddressForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoAddress)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoRectangleForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoRectangle)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoCircleForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoCircle)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoPathForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoPath)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoPolygonForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoPolygon)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoLocationForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoLocation)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoShapeForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoShape)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoCoordinateObjectForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoCoordinateObject)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-struct QGeoPositionInfoForeign
-{
- Q_GADGET
- QML_FOREIGN(QGeoPositionInfo)
- QML_ANONYMOUS
- QML_ADDED_IN_VERSION(5, 0)
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_POSITIONINGQUICKMODULE_P_H
diff --git a/src/positioningquick/qquickgeocoordinateanimation.cpp b/src/positioningquick/qquickgeocoordinateanimation.cpp
deleted file mode 100644
index 3f5cef8d..00000000
--- a/src/positioningquick/qquickgeocoordinateanimation.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickgeocoordinateanimation_p.h"
-#include "qquickgeocoordinateanimation_p_p.h"
-#include <QtQuick/private/qquickanimation_p_p.h>
-#include <QtPositioning/private/qdoublevector2d_p.h>
-#include <QtPositioning/private/qwebmercator_p.h>
-#include <QtPositioning/private/qgeocoordinate_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype CoordinateAnimation
- \inherits PropertyAnimation
- \inqmlmodule QtPositioning
- \since 5.3
-
- \brief A PropertyAnimation for geo coordinate properties.
-
- A specialized \l{PropertyAnimation} that defines an animation
- between two \l{coordinate}{coordinates}.
-
- By default, a \l{latitude} of the \l{coordinate} is animated in the direction of shortest
- (geodesic) distance between those coordinates. Since CoordinateAnimation uses Mercator
- map projection, the \l{latitude} animation is always between -90 and 90 degrees.
- The \l{longitude} animation path is not limited and can go over 180 degrees
- in both west and east directions.
-
- The \l{direction} property can be set to specify the direction in which the \l{longitude}
- animation should occur.
-
- \sa {Animation and Transitions in Qt Quick}
-*/
-
-QVariant q_coordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
-{
- if (from == to) {
- if (progress < 0.5) {
- return QVariant::fromValue(from);
- } else {
- return QVariant::fromValue(to);
- }
- }
-
- QGeoCoordinate result = QWebMercator::coordinateInterpolation(from, to, progress);
-
- return QVariant::fromValue(result);
-}
-
-QVariant q_coordinateShortestInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
-{
- const QGeoMercatorCoordinatePrivate* fromMercator =
- static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&from));
- const QGeoMercatorCoordinatePrivate* toMercator =
- static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&to));
-
- double toX = toMercator->m_mercatorX;
- double toY = toMercator->m_mercatorY;
- double fromX = fromMercator->m_mercatorX;
- double fromY = fromMercator->m_mercatorY;
- double x;
- if (0.5 < qAbs(toX - fromX)) {
- // handle dateline crossing
- double ex = toX;
- double sx = fromX;
- if (ex < sx)
- sx -= 1.0;
- else if (sx < ex)
- ex -= 1.0;
-
- x = sx + (ex - sx) * progress;
-
- if (x < 0.0)
- x += 1.0;
-
- } else {
- x = fromX + (toX - fromX) * progress;
- }
-
- double y = fromY + (toY - fromY) * progress;
-
- QGeoCoordinate result = QWebMercator::mercatorToCoord(QDoubleVector2D(x, y));
- result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress);
- return QVariant::fromValue(result);
-}
-
-QVariant q_coordinateEastInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
-{
- const QGeoMercatorCoordinatePrivate* fromMercator =
- static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&from));
- const QGeoMercatorCoordinatePrivate* toMercator =
- static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&to));
-
- double toX = toMercator->m_mercatorX;
- double toY = toMercator->m_mercatorY;
- double fromX = fromMercator->m_mercatorX;
- double fromY = fromMercator->m_mercatorY;
- double diff = toX - fromX;
-
- while (diff < 0.0) {
- toX += 1.0;
- diff += 1.0;
- }
-
- double x = fromX + (toX - fromX) * progress;
- double y = fromY + (toY - fromY) * progress;
-
- while (x > 1.0)
- x -= 1.0;
-
- QGeoCoordinate result = QWebMercator::mercatorToCoord(QDoubleVector2D(x, y));
- result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress);
-
- return QVariant::fromValue(result);
-}
-
-QVariant q_coordinateWestInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
-{
- const QGeoMercatorCoordinatePrivate* fromMercator =
- static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&from));
- const QGeoMercatorCoordinatePrivate* toMercator =
- static_cast<const QGeoMercatorCoordinatePrivate*>(QGeoCoordinatePrivate::get(&to));
-
- double toX = toMercator->m_mercatorX;
- double toY = toMercator->m_mercatorY;
- double fromX = fromMercator->m_mercatorX;
- double fromY = fromMercator->m_mercatorY;
- double diff = toX - fromX;
-
- while (diff > 0.0) {
- toX -= 1.0;
- diff -= 1.0;
- }
-
- double x = fromX + (toX - fromX) * progress;
- double y = fromY + (toY - fromY) * progress;
-
- while (x < 0.0)
- x += 1.0;
-
- QGeoCoordinate result = QWebMercator::mercatorToCoord(QDoubleVector2D(x, y));
- result.setAltitude(from.altitude() + (to.altitude() - from.altitude()) * progress);
-
- return QVariant::fromValue(result);
-}
-
-QQuickGeoCoordinateAnimation::QQuickGeoCoordinateAnimation(QObject *parent)
- : QQuickPropertyAnimation(*(new QQuickGeoCoordinateAnimationPrivate), parent)
-
-{
- Q_D(QQuickGeoCoordinateAnimation);
- d->interpolatorType = qMetaTypeId<QGeoCoordinate>();
- d->defaultToInterpolatorType = true;
- d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
-}
-
-QQuickGeoCoordinateAnimation::~QQuickGeoCoordinateAnimation()
-{
-}
-
-/*!
- \qmlproperty coordinate CoordinateAnimation::from
- This property holds the coordinate where the animation should begin.
-*/
-QGeoCoordinate QQuickGeoCoordinateAnimation::from() const
-{
- Q_D(const QQuickGeoCoordinateAnimation);
- return d->from.value<QGeoCoordinate>();
-}
-
-void QQuickGeoCoordinateAnimation::setFrom(const QGeoCoordinate &f)
-{
- QGeoMercatorCoordinatePrivate *mercator = new QGeoMercatorCoordinatePrivate();
- QDoubleVector2D fromVector = QWebMercator::coordToMercator(f);
- mercator->lat = f.latitude();
- mercator->lng = f.longitude();
- mercator->alt = f.altitude();
- mercator->m_mercatorX = fromVector.x();
- mercator->m_mercatorY = fromVector.y();
- QGeoCoordinate from(*mercator);
- QQuickPropertyAnimation::setFrom(QVariant::fromValue(from));
-}
-
-/*!
- \qmlproperty coordinate CoordinateAnimation::to
- This property holds the coordinate where the animation should end.
-*/
-QGeoCoordinate QQuickGeoCoordinateAnimation::to() const
-{
- Q_D(const QQuickGeoCoordinateAnimation);
- return d->to.value<QGeoCoordinate>();
-}
-
-void QQuickGeoCoordinateAnimation::setTo(const QGeoCoordinate &t)
-{
- QGeoMercatorCoordinatePrivate *mercator = new QGeoMercatorCoordinatePrivate();
- QDoubleVector2D toVector = QWebMercator::coordToMercator(t);
- mercator->lat = t.latitude();
- mercator->lng = t.longitude();
- mercator->alt = t.altitude();
- mercator->m_mercatorX = toVector.x();
- mercator->m_mercatorY = toVector.y();
- QGeoCoordinate to(*mercator);
- QQuickPropertyAnimation::setTo(QVariant::fromValue(to));
-}
-
-/*!
- \qmlproperty enumeration CoordinateAnimation::direction
- This property holds the direction of the \l{longitude} animation of the \l{coordinate}.
-
- Possible values are:
-
- \list
- \li CoordinateAnimation.Shortest (default) - the longitude animation goes in the direction
- that produces the shortest animation path.
- \li CoordinateAnimation.West - the longitude animation always goes into western direction
- and may cross the date line.
- \li CoordinateAnimation.East - the longitude animation always goes into eastern direction
- and may cross the date line.
- \endlist
- \since 5.5
-*/
-
-
-QQuickGeoCoordinateAnimation::Direction QQuickGeoCoordinateAnimation::direction() const
-{
- Q_D(const QQuickGeoCoordinateAnimation);
- return d->m_direction.value();
-}
-
-void QQuickGeoCoordinateAnimation::setDirection(QQuickGeoCoordinateAnimation::Direction direction)
-{
- Q_D( QQuickGeoCoordinateAnimation);
- d->m_direction.removeBindingUnlessInWrapper();
- if (d->m_direction.value() == direction)
- return;
-
- d->m_direction.setValueBypassingBindings(direction);
- switch (direction) {
- case West:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateWestInterpolator));
- break;
- case East:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateEastInterpolator));
- break;
- case Shortest:
- default:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&q_coordinateShortestInterpolator));
- break;
- }
- d->m_direction.notify();
-}
-
-QBindable<QQuickGeoCoordinateAnimation::Direction> QQuickGeoCoordinateAnimation::bindableDirection()
-{
- Q_D(QQuickGeoCoordinateAnimation);
- return QBindable<Direction>(&d->m_direction);
-}
-
-QT_END_NAMESPACE
diff --git a/src/positioningquick/qquickgeocoordinateanimation_p.h b/src/positioningquick/qquickgeocoordinateanimation_p.h
deleted file mode 100644
index 4cd8f567..00000000
--- a/src/positioningquick/qquickgeocoordinateanimation_p.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKGEOCOORDINATEANIMATION_P_H
-#define QQUICKGEOCOORDINATEANIMATION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
-#include <QtQuick/private/qquickanimation_p.h>
-#include <QtPositioning/qgeocoordinate.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickGeoCoordinateAnimationPrivate;
-
-class Q_POSITIONINGQUICK_PRIVATE_EXPORT QQuickGeoCoordinateAnimation : public QQuickPropertyAnimation
-{
- Q_OBJECT
- QML_NAMED_ELEMENT(CoordinateAnimation)
- QML_ADDED_IN_VERSION(5, 3)
- Q_DECLARE_PRIVATE(QQuickGeoCoordinateAnimation)
- Q_PROPERTY(QGeoCoordinate from READ from WRITE setFrom)
- Q_PROPERTY(QGeoCoordinate to READ to WRITE setTo)
- Q_PROPERTY(Direction direction READ direction WRITE setDirection NOTIFY directionChanged
- BINDABLE bindableDirection)
-
-public:
- enum Direction {
- Shortest,
- West,
- East
- };
- Q_ENUM(Direction)
-
- QQuickGeoCoordinateAnimation(QObject *parent=0);
- ~QQuickGeoCoordinateAnimation();
-
- QGeoCoordinate from() const;
- void setFrom(const QGeoCoordinate &);
-
- QGeoCoordinate to() const;
- void setTo(const QGeoCoordinate &);
-
- Direction direction() const;
- void setDirection(Direction direction);
- QBindable<Direction> bindableDirection();
-
-Q_SIGNALS:
- void directionChanged();
-};
-
-QVariant Q_POSITIONINGQUICK_PRIVATE_EXPORT q_coordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress);
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QQuickGeoCoordinateAnimation)
-
-#endif // QQUICKCOORDINATEANIMATION_P_H
diff --git a/src/positioningquick/qquickgeocoordinateanimation_p_p.h b/src/positioningquick/qquickgeocoordinateanimation_p_p.h
deleted file mode 100644
index c2d714b1..00000000
--- a/src/positioningquick/qquickgeocoordinateanimation_p_p.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKGEOCOORDINATEANIMATION_P_P_H
-#define QQUICKGEOCOORDINATEANIMATION_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qquickgeocoordinateanimation_p.h"
-#include <QtQuick/private/qquickanimation_p_p.h>
-#include <QtCore/private/qproperty_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickGeoCoordinateAnimationPrivate : public QQuickPropertyAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QQuickGeoCoordinateAnimation)
-public:
- void setDirection(QQuickGeoCoordinateAnimation::Direction direction)
- {
- q_func()->setDirection(direction);
- }
- void directionChanged()
- {
- Q_EMIT q_func()->directionChanged();
- }
-
- Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QQuickGeoCoordinateAnimationPrivate,
- QQuickGeoCoordinateAnimation::Direction, m_direction,
- &QQuickGeoCoordinateAnimationPrivate::setDirection,
- &QQuickGeoCoordinateAnimationPrivate::directionChanged,
- QQuickGeoCoordinateAnimation::Shortest)
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKGEOCOORDINATEANIMATION_P_P_H