summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/location/geojson_viewer/GeoJsonDelegate.qml11
-rw-r--r--examples/positioning/weatherinfo/appmodel.cpp6
-rw-r--r--src/3rdparty/earcut/earcut.hpp198
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp44
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap_p.h4
-rw-r--r--src/location/declarativemaps/qgeomapobject.cpp6
-rw-r--r--src/location/declarativemaps/qparameterizableobject.cpp41
-rw-r--r--src/location/declarativemaps/qparameterizableobject_p.h4
-rw-r--r--src/location/labs/qmapcircleobject.cpp2
-rw-r--r--src/location/labs/qmapobjectview.cpp14
-rw-r--r--src/location/labs/qmappolygonobject.cpp2
-rw-r--r--src/location/labs/qmappolygonobject_p.h2
-rw-r--r--src/location/labs/qmappolygonobject_p_p.h2
-rw-r--r--src/location/labs/qmappolylineobject.cpp2
-rw-r--r--src/location/maps/qgeotiledmapscene.cpp2
-rw-r--r--src/plugins/geoservices/esri/geocodereply_esri.cpp2
-rw-r--r--src/plugins/geoservices/esri/georoutereply_esri.cpp2
-rw-r--r--src/plugins/geoservices/esri/geotiledmapreply_esri.cpp2
-rw-r--r--src/plugins/geoservices/esri/placesearchreply_esri.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp2
-rw-r--r--src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp2
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp2
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp2
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp2
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp2
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp4
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp8
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeocodereplyosm.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeomapreplyosm.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeoroutereplyosm.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeotileproviderosm.cpp4
-rw-r--r--src/plugins/geoservices/osm/qplacesearchreplyosm.cpp2
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp2
-rw-r--r--src/positioning/qgeocoordinate.h1
-rw-r--r--src/positioning/qgeopath.cpp24
-rw-r--r--src/positioning/qgeopath_p.h1
-rw-r--r--src/positioning/qgeopolygon.cpp78
-rw-r--r--src/positioning/qgeopositioninfosource.cpp2
-rw-r--r--src/positioningquick/qdeclarativepositionsource.cpp4
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/declarative_geoshape/tst_locationsingleton.qml4
-rw-r--r--tests/auto/nokia_services/routing/tst_routing.cpp4
49 files changed, 355 insertions, 167 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 189e3fb6..ad4261de 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -3,7 +3,7 @@ CONFIG += warning_clean
DEFINES += QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST
-MODULE_VERSION = 5.14.2
+MODULE_VERSION = 5.15.0
# Adds a way to debug location. The define is needed for multiple subprojects as they
# include the essential headers.
diff --git a/examples/location/geojson_viewer/GeoJsonDelegate.qml b/examples/location/geojson_viewer/GeoJsonDelegate.qml
index d3e8db93..ff0fbffa 100644
--- a/examples/location/geojson_viewer/GeoJsonDelegate.qml
+++ b/examples/location/geojson_viewer/GeoJsonDelegate.qml
@@ -98,6 +98,17 @@ DelegateChooser {
opacity: dc.defaultOpacity
color: (props && props.color) || (parent && parent.props && parent.props.color) || dc.defaultColor
border.width: 0
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (props !== undefined)
+ console.log(props.name)
+ else if (parent.parent.geojsonType == "MultiPolygon")
+ console.log(parent.parent.props.name)
+ else
+ console.log("NO NAME!", props)
+ }
+ }
}
}
diff --git a/examples/positioning/weatherinfo/appmodel.cpp b/examples/positioning/weatherinfo/appmodel.cpp
index d07a5980..93186aea 100644
--- a/examples/positioning/weatherinfo/appmodel.cpp
+++ b/examples/positioning/weatherinfo/appmodel.cpp
@@ -347,7 +347,7 @@ void AppModel::handleGeoNetworkData(QNetworkReply *networkReply)
return;
}
- if (!networkReply->error()) {
+ if (!networkReply->networkError()) {
d->nErrors = 0;
if (!d->throttle.isValid())
d->throttle.start();
@@ -403,7 +403,7 @@ void AppModel::handleWeatherNetworkData(QNetworkReply *networkReply)
if (!networkReply)
return;
- if (!networkReply->error()) {
+ if (!networkReply->networkError()) {
foreach (WeatherData *inf, d->forecast)
delete inf;
d->forecast.clear();
@@ -455,7 +455,7 @@ void AppModel::handleForecastNetworkData(QNetworkReply *networkReply)
if (!networkReply)
return;
- if (!networkReply->error()) {
+ if (!networkReply->networkError()) {
QJsonDocument document = QJsonDocument::fromJson(networkReply->readAll());
QJsonObject jo;
diff --git a/src/3rdparty/earcut/earcut.hpp b/src/3rdparty/earcut/earcut.hpp
index ba3fb17a..d0b0c41e 100644
--- a/src/3rdparty/earcut/earcut.hpp
+++ b/src/3rdparty/earcut/earcut.hpp
@@ -1,8 +1,29 @@
+/****************************************************************************
+** earcut.hpp v2.2.1
+**
+** ISC License
+**
+** Copyright (c) 2015, Mapbox
+**
+** Permission to use, copy, modify, and/or distribute this software for any purpose
+** with or without fee is hereby granted, provided that the above copyright notice
+** and this permission notice appear in all copies.
+**
+** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+** REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+** FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+** INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+** OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+** THIS SOFTWARE.
+****************************************************************************/
+
#pragma once
#ifndef EARCUT_HPP
#define EARCUT_HPP
-#include <array>
+#pragma once
+
#include <algorithm>
#include <cassert>
#include <cmath>
@@ -14,12 +35,10 @@ namespace qt_mapbox {
namespace util {
template <std::size_t I, typename T> struct nth {
-
inline static typename std::tuple_element<I, T>::type
- get(const T& t) { return std::get<I>(t); }
+ get(const T& t) { return std::get<I>(t); };
};
-
}
namespace detail {
@@ -28,7 +47,7 @@ template <typename N = uint32_t>
class Earcut {
public:
std::vector<N> indices;
- N vertices = 0;
+ std::size_t vertices = 0;
template <typename Polygon>
void operator()(const Polygon& points);
@@ -70,6 +89,7 @@ private:
template <typename Polygon> Node* eliminateHoles(const Polygon& points, Node* outerNode);
void eliminateHole(Node* hole, Node* outerNode);
Node* findHoleBridge(Node* hole, Node* outerNode);
+ bool sectorContainsSector(const Node* m, const Node* p);
void indexCurve(Node* start);
Node* sortLinked(Node* list);
int32_t zOrder(const double x_, const double y_);
@@ -79,17 +99,19 @@ private:
double area(const Node* p, const Node* q, const Node* r) const;
bool equals(const Node* p1, const Node* p2);
bool intersects(const Node* p1, const Node* q1, const Node* p2, const Node* q2);
+ bool onSegment(const Node* p, const Node* q, const Node* r);
+ int sign(double val);
bool intersectsPolygon(const Node* a, const Node* b);
bool locallyInside(const Node* a, const Node* b);
bool middleInside(const Node* a, const Node* b);
Node* splitPolygon(Node* a, Node* b);
- template <typename Point> Node* insertNode(N i, const Point& p, Node* last);
+ template <typename Point> Node* insertNode(std::size_t i, const Point& p, Node* last);
void removeNode(Node* p);
bool hashing;
double minX, maxX;
double minY, maxY;
- double size;
+ double inv_size = 0;
template <typename T, typename Alloc = std::allocator<T>>
class ObjectPool {
@@ -104,16 +126,18 @@ private:
template <typename... Args>
T* construct(Args&&... args) {
if (currentIndex >= blockSize) {
- currentBlock = alloc.allocate(blockSize);
+ currentBlock = alloc_traits::allocate(alloc, blockSize);
allocations.emplace_back(currentBlock);
currentIndex = 0;
}
T* object = &currentBlock[currentIndex++];
- alloc.construct(object, std::forward<Args>(args)...);
+ alloc_traits::construct(alloc, object, std::forward<Args>(args)...);
return object;
}
void reset(std::size_t newBlockSize) {
- for (auto allocation : allocations) alloc.deallocate(allocation, blockSize);
+ for (auto allocation : allocations) {
+ alloc_traits::deallocate(alloc, allocation, blockSize);
+ }
allocations.clear();
blockSize = std::max<std::size_t>(1, newBlockSize);
currentBlock = nullptr;
@@ -126,6 +150,7 @@ private:
std::size_t blockSize = 1;
std::vector<T*> allocations;
Alloc alloc;
+ typedef typename std::allocator_traits<Alloc> alloc_traits;
};
ObjectPool<Node> nodes;
};
@@ -140,7 +165,6 @@ void Earcut<N>::operator()(const Polygon& points) {
double x;
double y;
- size = 0;
int threshold = 80;
std::size_t len = 0;
@@ -154,7 +178,7 @@ void Earcut<N>::operator()(const Polygon& points) {
indices.reserve(len + points[0].size());
Node* outerNode = linkedList(points[0], true);
- if (!outerNode) return;
+ if (!outerNode || outerNode->prev == outerNode->next) return;
if (points.size() > 1) outerNode = eliminateHoles(points, outerNode);
@@ -162,20 +186,21 @@ void Earcut<N>::operator()(const Polygon& points) {
hashing = threshold < 0;
if (hashing) {
Node* p = outerNode->next;
- minX = maxX = p->x;
- minY = maxY = p->y;
+ minX = maxX = outerNode->x;
+ minY = maxY = outerNode->y;
do {
x = p->x;
y = p->y;
- minX = (std::min)(minX, x);
- minY = (std::min)(minY, y);
- maxX = (std::max)(maxX, x);
- maxY = (std::max)(maxY, y);
+ minX = std::min<double>(minX, x);
+ minY = std::min<double>(minY, y);
+ maxX = std::max<double>(maxX, x);
+ maxY = std::max<double>(maxY, y);
p = p->next;
} while (p != outerNode);
// minX, minY and size are later used to transform coords into integers for z-order calculation
- size = (std::max)(maxX - minX, maxY - minY);
+ inv_size = std::max<double>(maxX - minX, maxY - minY);
+ inv_size = inv_size != .0 ? (1. / inv_size) : .0;
}
earcutLinked(outerNode);
@@ -189,15 +214,14 @@ typename Earcut<N>::Node*
Earcut<N>::linkedList(const Ring& points, const bool clockwise) {
using Point = typename Ring::value_type;
double sum = 0;
- const int len = static_cast<int>(points.size());
- int i, j;
- Point p1, p2;
+ const std::size_t len = points.size();
+ std::size_t i, j;
Node* last = nullptr;
// calculate original winding order of a polygon ring
- for (i = 0, j = len - 1; i < len; j = i++) {
- p1 = points[i];
- p2 = points[j];
+ for (i = 0, j = len > 0 ? len - 1 : 0; i < len; j = i++) {
+ const auto& p1 = points[i];
+ const auto& p2 = points[j];
const double p20 = util::nth<0, Point>::get(p2);
const double p10 = util::nth<0, Point>::get(p1);
const double p11 = util::nth<1, Point>::get(p1);
@@ -209,7 +233,7 @@ Earcut<N>::linkedList(const Ring& points, const bool clockwise) {
if (clockwise == (sum > 0)) {
for (i = 0; i < len; i++) last = insertNode(vertices + i, points[i], last);
} else {
- for (i = len - 1; i >= 0; i--) last = insertNode(vertices + i, points[i], last);
+ for (i = len; i-- > 0;) last = insertNode(vertices + i, points[i], last);
}
if (last && equals(last, last->next)) {
@@ -237,7 +261,7 @@ Earcut<N>::filterPoints(Node* start, Node* end) {
removeNode(p);
p = end = p->prev;
- if (p == p->next) return nullptr;
+ if (p == p->next) break;
again = true;
} else {
@@ -292,10 +316,10 @@ void Earcut<N>::earcutLinked(Node* ear, int pass) {
// if this didn't work, try curing all small self-intersections locally
else if (pass == 1) {
- ear = cureLocalIntersections(ear);
+ ear = cureLocalIntersections(filterPoints(ear));
earcutLinked(ear, 2);
- // as a last resort, try splitting the remaining polygon into two
+ // as a last resort, try splitting the remaining polygon into two
} else if (pass == 2) splitEarcut(ear);
break;
@@ -317,7 +341,7 @@ bool Earcut<N>::isEar(Node* ear) {
while (p != ear->prev) {
if (pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) &&
- area(p->prev, p, p->next) >= 0) return false;
+ area(p->prev, p, p->next) >= 0) return false;
p = p->next;
}
@@ -333,10 +357,10 @@ bool Earcut<N>::isEarHashed(Node* ear) {
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
// triangle bbox; min & max are calculated like this for speed
- const double minTX = (std::min)(a->x, (std::min)(b->x, c->x));
- const double minTY = (std::min)(a->y, (std::min)(b->y, c->y));
- const double maxTX = (std::max)(a->x, (std::max)(b->x, c->x));
- const double maxTY = (std::max)(a->y, (std::max)(b->y, c->y));
+ const double minTX = std::min<double>(a->x, std::min<double>(b->x, c->x));
+ const double minTY = std::min<double>(a->y, std::min<double>(b->y, c->y));
+ const double maxTX = std::max<double>(a->x, std::max<double>(b->x, c->x));
+ const double maxTY = std::max<double>(a->y, std::max<double>(b->y, c->y));
// z-order range for the current triangle bbox;
const int32_t minZ = zOrder(minTX, minTY);
@@ -347,8 +371,8 @@ bool Earcut<N>::isEarHashed(Node* ear) {
while (p && p->z <= maxZ) {
if (p != ear->prev && p != ear->next &&
- pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) &&
- area(p->prev, p, p->next) >= 0) return false;
+ pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) &&
+ area(p->prev, p, p->next) >= 0) return false;
p = p->nextZ;
}
@@ -357,8 +381,8 @@ bool Earcut<N>::isEarHashed(Node* ear) {
while (p && p->z >= minZ) {
if (p != ear->prev && p != ear->next &&
- pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) &&
- area(p->prev, p, p->next) >= 0) return false;
+ pointInTriangle(a->x, a->y, b->x, b->y, c->x, c->y, p->x, p->y) &&
+ area(p->prev, p, p->next) >= 0) return false;
p = p->prevZ;
}
@@ -389,7 +413,7 @@ Earcut<N>::cureLocalIntersections(Node* start) {
p = p->next;
} while (p != start);
- return p;
+ return filterPoints(p);
}
// try splitting polygon into two and triangulate them independently
@@ -470,22 +494,22 @@ Earcut<N>::findHoleBridge(Node* hole, Node* outerNode) {
// segment's endpoint with lesser x will be potential connection Vertex
do {
if (hy <= p->y && hy >= p->next->y && p->next->y != p->y) {
- double x = p->x + (hy - p->y) * (p->next->x - p->x) / (p->next->y - p->y);
- if (x <= hx && x > qx) {
- qx = x;
- if (x == hx) {
- if (hy == p->y) return p;
- if (hy == p->next->y) return p->next;
+ double x = p->x + (hy - p->y) * (p->next->x - p->x) / (p->next->y - p->y);
+ if (x <= hx && x > qx) {
+ qx = x;
+ if (x == hx) {
+ if (hy == p->y) return p;
+ if (hy == p->next->y) return p->next;
+ }
+ m = p->x < p->next->x ? p : p->next;
}
- m = p->x < p->next->x ? p : p->next;
- }
}
p = p->next;
} while (p != outerNode);
if (!m) return 0;
- if (hx == qx) return m->prev;
+ if (hx == qx) return m; // hole touches outer segment; pick leftmost endpoint
// look for points inside the triangle of hole Vertex, segment intersection and endpoint;
// if there are no points found, we have a valid connection;
@@ -495,28 +519,35 @@ Earcut<N>::findHoleBridge(Node* hole, Node* outerNode) {
double tanMin = std::numeric_limits<double>::infinity();
double tanCur = 0;
- p = m->next;
+ p = m;
double mx = m->x;
double my = m->y;
- while (p != stop) {
+ do {
if (hx >= p->x && p->x >= mx && hx != p->x &&
- pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p->x, p->y)) {
+ pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p->x, p->y)) {
tanCur = std::abs(hy - p->y) / (hx - p->x); // tangential
- if ((tanCur < tanMin || (tanCur == tanMin && p->x > m->x)) && locallyInside(p, hole)) {
+ if (locallyInside(p, hole) &&
+ (tanCur < tanMin || (tanCur == tanMin && (p->x > m->x || sectorContainsSector(m, p))))) {
m = p;
tanMin = tanCur;
}
}
p = p->next;
- }
+ } while (p != stop);
return m;
}
+// whether sector in vertex m contains sector in vertex p in the same coordinates
+template <typename N>
+bool Earcut<N>::sectorContainsSector(const Node* m, const Node* p) {
+ return area(m->prev, m, p->prev) < 0 && area(p->next, m, m->next) < 0;
+}
+
// interlink polygon nodes in z-order
template <typename N>
void Earcut<N>::indexCurve(Node* start) {
@@ -549,7 +580,7 @@ Earcut<N>::sortLinked(Node* list) {
int i, numMerges, pSize, qSize;
int inSize = 1;
- while (true) {
+ for (;;) {
p = list;
list = nullptr;
tail = nullptr;
@@ -609,8 +640,8 @@ Earcut<N>::sortLinked(Node* list) {
template <typename N>
int32_t Earcut<N>::zOrder(const double x_, const double y_) {
// coords are transformed into non-negative 15-bit integer range
- int32_t x = static_cast<int32_t>(32767.0 * (x_ - minX) / size);
- int32_t y = static_cast<int32_t>(32767.0 * (y_ - minY) / size);
+ int32_t x = static_cast<int32_t>(32767.0 * (x_ - minX) * inv_size);
+ int32_t y = static_cast<int32_t>(32767.0 * (y_ - minY) * inv_size);
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
@@ -632,7 +663,8 @@ Earcut<N>::getLeftmost(Node* start) {
Node* p = start;
Node* leftmost = start;
do {
- if (p->x < leftmost->x) leftmost = p;
+ if (p->x < leftmost->x || (p->x == leftmost->x && p->y < leftmost->y))
+ leftmost = p;
p = p->next;
} while (p != start);
@@ -643,15 +675,17 @@ Earcut<N>::getLeftmost(Node* start) {
template <typename N>
bool Earcut<N>::pointInTriangle(double ax, double ay, double bx, double by, double cx, double cy, double px, double py) const {
return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
- (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
- (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
+ (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
+ (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
}
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
template <typename N>
bool Earcut<N>::isValidDiagonal(Node* a, Node* b) {
- return a->next->i != b->i && a->prev->i != b->i && !intersectsPolygon(a, b) &&
- locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
+ return a->next->i != b->i && a->prev->i != b->i && !intersectsPolygon(a, b) && // dones't intersect other edges
+ ((locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
+ (area(a->prev, a, b->prev) != 0.0 || area(a, b->prev, b) != 0.0)) || // does not create opposite-facing sectors
+ (equals(a, b) && area(a->prev, a, a->next) > 0 && area(b->prev, b, b->next) > 0)); // special zero-length case
}
// signed area of a triangle
@@ -669,10 +703,33 @@ bool Earcut<N>::equals(const Node* p1, const Node* p2) {
// check if two segments intersect
template <typename N>
bool Earcut<N>::intersects(const Node* p1, const Node* q1, const Node* p2, const Node* q2) {
- if ((equals(p1, q1) && equals(p2, q2)) ||
- (equals(p1, q2) && equals(p2, q1))) return true;
- return (area(p1, q1, p2) > 0) != (area(p1, q1, q2) > 0) &&
- (area(p2, q2, p1) > 0) != (area(p2, q2, q1) > 0);
+ int o1 = sign(area(p1, q1, p2));
+ int o2 = sign(area(p1, q1, q2));
+ int o3 = sign(area(p2, q2, p1));
+ int o4 = sign(area(p2, q2, q1));
+
+ if (o1 != o2 && o3 != o4) return true; // general case
+
+ if (o1 == 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
+ if (o2 == 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
+ if (o3 == 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
+ if (o4 == 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
+
+ return false;
+}
+
+// for collinear points p, q, r, check if point q lies on segment pr
+template <typename N>
+bool Earcut<N>::onSegment(const Node* p, const Node* q, const Node* r) {
+ return q->x <= std::max<double>(p->x, r->x) &&
+ q->x >= std::min<double>(p->x, r->x) &&
+ q->y <= std::max<double>(p->y, r->y) &&
+ q->y >= std::min<double>(p->y, r->y);
+}
+
+template <typename N>
+int Earcut<N>::sign(double val) {
+ return (0.0 < val) - (val < 0.0);
}
// check if a polygon diagonal intersects any polygon segments
@@ -692,8 +749,8 @@ bool Earcut<N>::intersectsPolygon(const Node* a, const Node* b) {
template <typename N>
bool Earcut<N>::locallyInside(const Node* a, const Node* b) {
return area(a->prev, a, a->next) < 0 ?
- area(a, b, a->next) >= 0 && area(a, a->prev, b) >= 0 :
- area(a, b, a->prev) < 0 || area(a, a->next, b) < 0;
+ area(a, b, a->next) >= 0 && area(a, a->prev, b) >= 0 :
+ area(a, b, a->prev) < 0 || area(a, a->next, b) < 0;
}
// check if the middle Vertex of a polygon diagonal is inside the polygon
@@ -742,8 +799,8 @@ Earcut<N>::splitPolygon(Node* a, Node* b) {
// create a node and util::optionally link it with previous one (in a circular doubly linked list)
template <typename N> template <typename Point>
typename Earcut<N>::Node*
-Earcut<N>::insertNode(N i, const Point& pt, Node* last) {
- Node* p = nodes.construct(i, util::nth<0, Point>::get(pt), util::nth<1, Point>::get(pt));
+Earcut<N>::insertNode(std::size_t i, const Point& pt, Node* last) {
+ Node* p = nodes.construct(static_cast<N>(i), util::nth<0, Point>::get(pt), util::nth<1, Point>::get(pt));
if (!last) {
p->prev = p;
@@ -773,7 +830,8 @@ template <typename N = uint32_t, typename Polygon>
std::vector<N> earcut(const Polygon& poly) {
qt_mapbox::detail::Earcut<N> earcut;
earcut(poly);
- return earcut.indices;
+ return std::move(earcut.indices);
}
}
+
#endif //EARCUT_HPP
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 7fd5f78a..6a2d82e8 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -2289,17 +2289,31 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF
}
/*!
- \qmlmethod void QtLocation::Map::fitViewportToMapItems()
+ \qmlmethod void QtLocation::Map::fitViewportToMapItems(list<MapItems> items = {})
- Fits the current viewport to the boundary of all map items. The camera is positioned
- in the center of the map items, and at the largest integral zoom level possible which
- allows all map items to be visible on screen.
+ If no argument is provided, fits the current viewport to the boundary of all map items.
+ The camera is positioned in the center of the map items, and at the largest integral zoom level
+ possible which allows all map items to be visible on screen.
+ If \a items is provided, fits the current viewport to the boundary of the specified map items only.
+
+ \note This method gained the optional \a items argument since Qt 5.15.
+ In previous releases, this method fitted the map to all map items.
\sa fitViewportToVisibleMapItems
*/
-void QDeclarativeGeoMap::fitViewportToMapItems()
+void QDeclarativeGeoMap::fitViewportToMapItems(const QVariantList &items)
{
- fitViewportToMapItemsRefine(true, false);
+ if (items.size()) {
+ QList<QPointer<QDeclarativeGeoMapItemBase> > itms;
+ for (const QVariant &i: items) {
+ QDeclarativeGeoMapItemBase *itm = qobject_cast<QDeclarativeGeoMapItemBase *>(i.value<QObject *>());
+ if (itm)
+ itms.append(itm);
+ }
+ fitViewportToMapItemsRefine(itms, true, false);
+ } else {
+ fitViewportToMapItemsRefine(m_mapItems, true, false);
+ }
}
/*!
@@ -2313,18 +2327,20 @@ void QDeclarativeGeoMap::fitViewportToMapItems()
*/
void QDeclarativeGeoMap::fitViewportToVisibleMapItems()
{
- fitViewportToMapItemsRefine(true, true);
+ fitViewportToMapItemsRefine(m_mapItems, true, true);
}
/*!
\internal
*/
-void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisible)
+void QDeclarativeGeoMap::fitViewportToMapItemsRefine(const QList<QPointer<QDeclarativeGeoMapItemBase> > &mapItems,
+ bool refine,
+ bool onlyVisible)
{
if (!m_map)
return;
- if (m_mapItems.size() == 0)
+ if (mapItems.size() == 0)
return;
double minX = qInf();
@@ -2339,10 +2355,10 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib
// find bounds of all map items
int itemCount = 0;
- for (int i = 0; i < m_mapItems.count(); ++i) {
- if (!m_mapItems.at(i))
+ for (int i = 0; i < mapItems.count(); ++i) {
+ if (!mapItems.at(i))
continue;
- QDeclarativeGeoMapItemBase *item = m_mapItems.at(i).data();
+ QDeclarativeGeoMapItemBase *item = mapItems.at(i).data();
if (!item || (onlyVisible && (!item->isVisible() || item->mapItemOpacity() <= 0.0)))
continue;
@@ -2393,7 +2409,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib
if (itemCount == 0) {
if (haveQuickItem)
- fitViewportToMapItemsRefine(false, onlyVisible);
+ fitViewportToMapItemsRefine(mapItems, false, onlyVisible);
return;
}
double bboxWidth = maxX - minX;
@@ -2423,7 +2439,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine, bool onlyVisib
// as map quick items retain the same screen size after the camera zooms in/out
// we refine the viewport again to achieve better results
if (refine)
- fitViewportToMapItemsRefine(false, onlyVisible);
+ fitViewportToMapItemsRefine(mapItems, false, onlyVisible);
}
/*!
diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h
index c97c3622..ee9f8ec2 100644
--- a/src/location/declarativemaps/qdeclarativegeomap_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomap_p.h
@@ -193,7 +193,7 @@ public:
QQuickGeoMapGestureArea *gesture();
- Q_INVOKABLE void fitViewportToMapItems();
+ Q_INVOKABLE void fitViewportToMapItems(const QVariantList &items = {});
Q_INVOKABLE void fitViewportToVisibleMapItems();
Q_INVOKABLE void pan(int dx, int dy);
Q_INVOKABLE void prefetchData(); // optional hint for prefetch
@@ -280,7 +280,7 @@ private:
void setupMapView(QDeclarativeGeoMapItemView *view);
void populateMap();
void populateParameters();
- void fitViewportToMapItemsRefine(bool refine, bool onlyVisible);
+ void fitViewportToMapItemsRefine(const QList<QPointer<QDeclarativeGeoMapItemBase> > &mapItems, bool refine, bool onlyVisible);
bool isInteractive();
void attachCopyrightNotice(bool initialVisibility);
void detachCopyrightNotice(bool currentVisibility);
diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp
index 00faac9b..b0a10806 100644
--- a/src/location/declarativemaps/qgeomapobject.cpp
+++ b/src/location/declarativemaps/qgeomapobject.cpp
@@ -193,8 +193,10 @@ void QGeoMapObject::setMap(QGeoMap *map)
if (map) {
bool oldVisible = d_ptr->m_visible;
bool oldCmponentCompleted = d_ptr->m_componentCompleted;
- if (!map->createMapObjectImplementation(this))
- qWarning() << "Unsupported type " << type();
+ if (!map->createMapObjectImplementation(this)) {
+ if (type() != ViewType)
+ qWarning() << "Unsupported type " << type();
+ }
// old implementation gets destroyed if/when d_ptr gets replaced
d_ptr->m_componentCompleted = oldCmponentCompleted;
d_ptr->setVisible(oldVisible);
diff --git a/src/location/declarativemaps/qparameterizableobject.cpp b/src/location/declarativemaps/qparameterizableobject.cpp
index 0e138b86..26d9a11e 100644
--- a/src/location/declarativemaps/qparameterizableobject.cpp
+++ b/src/location/declarativemaps/qparameterizableobject.cpp
@@ -37,13 +37,10 @@
#include "qparameterizableobject_p.h"
#include "qdeclarativegeomapparameter_p.h"
#include <QtLocation/private/qgeomapparameter_p.h>
+#include <private/qobject_p.h>
QT_BEGIN_NAMESPACE
-QParameterizableObject::QParameterizableObject(QObject *parent)
- : QObject(parent)
-{}
-
void QParameterizableObject::appendChild(QObject *v)
{
m_children.append(v);
@@ -85,4 +82,40 @@ void QParameterizableObject::clear(QQmlListProperty<QObject> *p)
object->clearChildren();
}
+class QParameterizableObjectData: public QAbstractDeclarativeData
+{
+public:
+ QParameterizableObjectData()
+ {
+ init();
+ }
+
+ static inline void init() {
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ QAbstractDeclarativeData::parentChanged = parentChanged;
+ }
+ }
+
+ static void parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p);
+};
+
+Q_GLOBAL_STATIC(QParameterizableObjectData, parametrizableObjectData)
+
+QParameterizableObject::QParameterizableObject(QObject *parent)
+ : QObject(parent)
+{
+ QObjectPrivate::get(this)->declarativeData = parametrizableObjectData;
+}
+
+void QParameterizableObjectData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p)
+{
+ Q_UNUSED(p)
+ Q_UNUSED(d)
+ QParameterizableObject *po = qobject_cast<QParameterizableObject *>(o);
+ if (po)
+ po->parentChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qparameterizableobject_p.h b/src/location/declarativemaps/qparameterizableobject_p.h
index e450c6ec..cf393aee 100644
--- a/src/location/declarativemaps/qparameterizableobject_p.h
+++ b/src/location/declarativemaps/qparameterizableobject_p.h
@@ -58,6 +58,7 @@ class QGeoMapParameter;
class Q_LOCATION_PRIVATE_EXPORT QParameterizableObject : public QObject
{
Q_OBJECT
+ Q_PROPERTY(QObject *parent READ parent NOTIFY parentChanged DESIGNABLE false FINAL)
Q_PROPERTY(QQmlListProperty<QObject> quickChildren READ declarativeChildren DESIGNABLE false)
Q_CLASSINFO("DefaultProperty", "quickChildren")
@@ -76,6 +77,9 @@ public:
return res;
}
+Q_SIGNALS:
+ void parentChanged();
+
protected:
virtual void appendChild(QObject *v);
virtual void clearChildren();
diff --git a/src/location/labs/qmapcircleobject.cpp b/src/location/labs/qmapcircleobject.cpp
index 5f0db29d..fdfc834d 100644
--- a/src/location/labs/qmapcircleobject.cpp
+++ b/src/location/labs/qmapcircleobject.cpp
@@ -250,7 +250,7 @@ QColor QMapCircleObject::color() const
QDeclarativeMapLineProperties *QMapCircleObject::border()
{
if (!m_border) {
- m_border = new QDeclarativeMapLineProperties;
+ m_border = new QDeclarativeMapLineProperties(this);
connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){
static_cast<QMapCircleObjectPrivate*>(d_ptr.data())->setBorderColor(color);
});
diff --git a/src/location/labs/qmapobjectview.cpp b/src/location/labs/qmapobjectview.cpp
index 8cbf8ded..54d384fb 100644
--- a/src/location/labs/qmapobjectview.cpp
+++ b/src/location/labs/qmapobjectview.cpp
@@ -339,8 +339,10 @@ void QMapObjectView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
for (int idx = c.start(); idx < c.end(); idx++) {
m_instantiatedMapObjects.insert(idx, nullptr);
QGeoMapObject *mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(idx, incubationMode));
- if (mo) // if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect.
+ if (mo) {// if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect.
+ mo->setParent(this);
addMapObjectToMap(mo, idx);
+ }
}
}
}
@@ -395,10 +397,12 @@ void QMapObjectView::createdItem(int index, QObject * /*object*/)
// or else, it will be destroyed exiting this scope
QGeoMapObject *mo = nullptr;
mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(index, incubationMode));
- if (mo)
+ if (mo) {
+ mo->setParent(this);
addMapObjectToMap(mo, index);
- else
+ } else {
qWarning() << "QQmlDelegateModel::object called in createdItem for " << index << " produced a null object";
+ }
}
@@ -436,7 +440,11 @@ void QMapObjectView::setMap(QGeoMap *map)
// Map was set, now it has ben re-set to NULL
flushDelegateModel();
flushUserAddedMapObjects();
+ bool oldVisible = d_ptr->m_visible;
+ bool oldCmponentCompleted = d_ptr->m_componentCompleted;
d_ptr = new QMapObjectViewPrivateDefault(*d);
+ d_ptr->m_componentCompleted = oldCmponentCompleted;
+ d_ptr->setVisible(oldVisible);
} else if (d->m_componentCompleted) {
// Map was null, now it's set AND delegateModel is already complete.
// some delegates may have been incubated but not added to the map.
diff --git a/src/location/labs/qmappolygonobject.cpp b/src/location/labs/qmappolygonobject.cpp
index 6ccba748..5a8ce228 100644
--- a/src/location/labs/qmappolygonobject.cpp
+++ b/src/location/labs/qmappolygonobject.cpp
@@ -250,7 +250,7 @@ QColor QMapPolygonObject::color() const
QDeclarativeMapLineProperties *QMapPolygonObject::border()
{
if (!m_border) {
- m_border = new QDeclarativeMapLineProperties;
+ m_border = new QDeclarativeMapLineProperties(this);
connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){
static_cast<QMapPolygonObjectPrivate*>(d_ptr.data())->setBorderColor(color);
});
diff --git a/src/location/labs/qmappolygonobject_p.h b/src/location/labs/qmappolygonobject_p.h
index 03eef587..e924afab 100644
--- a/src/location/labs/qmappolygonobject_p.h
+++ b/src/location/labs/qmappolygonobject_p.h
@@ -82,7 +82,7 @@ signals:
void colorChanged();
protected:
- QDeclarativeMapLineProperties *m_border;
+ QDeclarativeMapLineProperties *m_border = nullptr;
};
QT_END_NAMESPACE
diff --git a/src/location/labs/qmappolygonobject_p_p.h b/src/location/labs/qmappolygonobject_p_p.h
index 767765df..52bbaf4c 100644
--- a/src/location/labs/qmappolygonobject_p_p.h
+++ b/src/location/labs/qmappolygonobject_p_p.h
@@ -103,7 +103,7 @@ public:
public:
QGeoPolygon m_path; // small overhead compared to plain QList<QGeoCoordinate>
- QColor m_borderColor;
+ QColor m_borderColor = Qt::transparent;
QColor m_fillColor = Qt::transparent;
qreal m_borderWidth = 0;
diff --git a/src/location/labs/qmappolylineobject.cpp b/src/location/labs/qmappolylineobject.cpp
index c6d3cdaf..81390d7c 100644
--- a/src/location/labs/qmappolylineobject.cpp
+++ b/src/location/labs/qmappolylineobject.cpp
@@ -191,7 +191,7 @@ QVariantList QMapPolylineObject::path() const
QDeclarativeMapLineProperties *QMapPolylineObject::border()
{
if (!m_border) {
- m_border = new QDeclarativeMapLineProperties;
+ m_border = new QDeclarativeMapLineProperties(this);
connect(m_border, &QDeclarativeMapLineProperties::colorChanged, this, [this](const QColor &color){
static_cast<QMapPolylineObjectPrivate*>(d_ptr.data())->setColor(color);
});
diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp
index a8bee156..18d92b00 100644
--- a/src/location/maps/qgeotiledmapscene.cpp
+++ b/src/location/maps/qgeotiledmapscene.cpp
@@ -515,7 +515,7 @@ void QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode *root,
bool ok = d->buildGeometry(it.key(), node, overzooming)
&& qgeotiledmapscene_isTileInViewport(node->rect(), root->matrix(), straight);
- QSGNode::DirtyState dirtyBits = 0;
+ QSGNode::DirtyState dirtyBits = {};
if (!ok) {
#ifdef QT_LOCATION_DEBUG
diff --git a/src/plugins/geoservices/esri/geocodereply_esri.cpp b/src/plugins/geoservices/esri/geocodereply_esri.cpp
index eca3def1..05f941d1 100644
--- a/src/plugins/geoservices/esri/geocodereply_esri.cpp
+++ b/src/plugins/geoservices/esri/geocodereply_esri.cpp
@@ -84,7 +84,7 @@ void GeoCodeReplyEsri::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/esri/georoutereply_esri.cpp b/src/plugins/geoservices/esri/georoutereply_esri.cpp
index a47db6fb..78e14a9b 100644
--- a/src/plugins/geoservices/esri/georoutereply_esri.cpp
+++ b/src/plugins/geoservices/esri/georoutereply_esri.cpp
@@ -70,7 +70,7 @@ void GeoRouteReplyEsri::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp b/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp
index 78f6c69a..2f4016a9 100644
--- a/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp
+++ b/src/plugins/geoservices/esri/geotiledmapreply_esri.cpp
@@ -71,7 +71,7 @@ void GeoTiledMapReplyEsri::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QByteArray const& imageData = reply->readAll();
diff --git a/src/plugins/geoservices/esri/placesearchreply_esri.cpp b/src/plugins/geoservices/esri/placesearchreply_esri.cpp
index a5a3585a..b674c136 100644
--- a/src/plugins/geoservices/esri/placesearchreply_esri.cpp
+++ b/src/plugins/geoservices/esri/placesearchreply_esri.cpp
@@ -109,7 +109,7 @@ void PlaceSearchReplyEsri::replyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp
index bb84b531..7e94e6e0 100644
--- a/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp
@@ -76,7 +76,7 @@ void QGeoCodeReplyMapbox::onNetworkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QList<QGeoLocation> locations;
diff --git a/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp
index 4b60231d..c10aba19 100644
--- a/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp
@@ -61,7 +61,7 @@ void QGeoMapReplyMapbox::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
setMapImageData(reply->readAll());
diff --git a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp
index 86da24ab..f10b0086 100644
--- a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp
@@ -116,7 +116,7 @@ void QGeoRouteReplyMapbox::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QGeoRoutingManagerEngineMapbox *engine = qobject_cast<QGeoRoutingManagerEngineMapbox *>(parent());
diff --git a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
index 8d34d2ec..7284b67a 100644
--- a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp
@@ -167,7 +167,7 @@ void QPlaceSearchReplyMapbox::onReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp
index 8c0bfdc1..95296172 100644
--- a/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp
@@ -86,7 +86,7 @@ void QPlaceSearchSuggestionReplyMapbox::onReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
index f67fa5bb..196b68d3 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
@@ -81,7 +81,7 @@ void QPlaceContentReplyImpl::replyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
index 1e7f2d2f..677efddc 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
@@ -118,7 +118,7 @@ void QPlaceDetailsReplyImpl::replyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp
index 28aa930f..49574084 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyhere.cpp
@@ -87,7 +87,7 @@ void QPlaceSearchReplyHere::replyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp
index 9882545d..236af184 100644
--- a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp
@@ -77,7 +77,7 @@ void QPlaceSearchSuggestionReplyImpl::replyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp
index 2a8549ff..2b302a76 100644
--- a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp
@@ -83,7 +83,7 @@ void QGeoCodeReplyNokia::networkFinished()
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QGeoCodeJsonParser *parser = new QGeoCodeJsonParser; // QRunnable, autoDelete = true.
diff --git a/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
index 6e1a1e85..1ae32004 100644
--- a/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
@@ -70,7 +70,7 @@ void QGeoMapReplyNokia::networkFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
setMapImageData(reply->readAll());
diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
index 941a0200..6aed85cc 100644
--- a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp
@@ -80,8 +80,8 @@ void QGeoRouteReplyNokia::networkFinished()
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError
- && reply->error() != QNetworkReply::UnknownContentError) {
+ if (reply->networkError() != QNetworkReply::NoError
+ && reply->networkError() != QNetworkReply::UnknownContentError) {
return;
}
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
index d07a93ba..2e16a5d8 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
@@ -247,7 +247,7 @@ QString QGeoTileFetcherNokia::applicationId() const
void QGeoTileFetcherNokia::copyrightsFetched()
{
- if (m_engineNokia && m_copyrightsReply->error() == QNetworkReply::NoError) {
+ if (m_engineNokia && m_copyrightsReply->networkError() == QNetworkReply::NoError) {
QMetaObject::invokeMethod(m_engineNokia.data(),
"loadCopyrightsDescriptorsFromJson",
Qt::QueuedConnection,
@@ -259,7 +259,7 @@ void QGeoTileFetcherNokia::copyrightsFetched()
void QGeoTileFetcherNokia::versionFetched()
{
- if (m_engineNokia && m_versionReply->error() == QNetworkReply::NoError) {
+ if (m_engineNokia && m_versionReply->networkError() == QNetworkReply::NoError) {
QMetaObject::invokeMethod(m_engineNokia.data(),
"parseNewVersionInfo",
Qt::QueuedConnection,
@@ -288,7 +288,7 @@ void QGeoTileFetcherNokia::fetchCopyrightsData()
QNetworkRequest netRequest((QUrl(copyrightUrl)));
m_copyrightsReply = m_networkManager->get(netRequest);
- if (m_copyrightsReply->error() != QNetworkReply::NoError) {
+ if (m_copyrightsReply->networkError() != QNetworkReply::NoError) {
qWarning() << __FUNCTION__ << m_copyrightsReply->errorString();
m_copyrightsReply->deleteLater();
return;
@@ -321,7 +321,7 @@ void QGeoTileFetcherNokia::fetchVersionData()
QNetworkRequest netRequest((QUrl(versionUrl)));
m_versionReply = m_networkManager->get(netRequest);
- if (m_versionReply->error() != QNetworkReply::NoError) {
+ if (m_versionReply->networkError() != QNetworkReply::NoError) {
qWarning() << __FUNCTION__ << m_versionReply->errorString();
m_versionReply->deleteLater();
return;
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
index 3b507ff2..acf43a01 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
@@ -777,7 +777,7 @@ void QPlaceManagerEngineNokiaV2::categoryReplyFinished()
QString categoryId;
- if (reply->error() == QNetworkReply::NoError) {
+ if (reply->networkError() == QNetworkReply::NoError) {
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
if (!document.isObject()) {
if (m_categoryReply) {
diff --git a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp
index b4733d69..145a26ca 100644
--- a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp
@@ -129,7 +129,7 @@ void QGeoCodeReplyOsm::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QList<QGeoLocation> locations;
diff --git a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
index a06f91f3..b83d9015 100644
--- a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
@@ -68,7 +68,7 @@ void QGeoMapReplyOsm::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError) // Already handled in networkReplyError
+ if (reply->networkError() != QNetworkReply::NoError) // Already handled in networkReplyError
return;
QByteArray a = reply->readAll();
diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
index e60dc068..45e6b2c3 100644
--- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
@@ -66,7 +66,7 @@ void QGeoRouteReplyOsm::networkReplyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QGeoRoutingManagerEngineOsm *engine = qobject_cast<QGeoRoutingManagerEngineOsm *>(parent());
diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp
index 1eedddb1..13b9f47e 100644
--- a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp
@@ -383,8 +383,8 @@ void TileProvider::onNetworkReplyFinished()
QObject errorEmitter;
QMetaObject::Connection errorEmitterConnection = connect(&errorEmitter, &QObject::destroyed, [this](){ this->resolutionError(this); });
- if (reply->error() != QNetworkReply::NoError) {
- handleError(reply->error());
+ if (reply->networkError() != QNetworkReply::NoError) {
+ handleError(reply->networkError());
return;
}
m_status = Invalid;
diff --git a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp
index 366ff852..ba6eb81c 100644
--- a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp
+++ b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp
@@ -99,7 +99,7 @@ void QPlaceSearchReplyOsm::replyFinished()
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
reply->deleteLater();
- if (reply->error() != QNetworkReply::NoError)
+ if (reply->networkError() != QNetworkReply::NoError)
return;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
diff --git a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
index bbc70f0a..414d2f34 100644
--- a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
+++ b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
@@ -437,7 +437,7 @@ QList<QGeoAreaMonitorInfo> QGeoAreaMonitorPolling::activeMonitors(const QGeoShap
QGeoAreaMonitorSource::AreaMonitorFeatures QGeoAreaMonitorPolling::supportedAreaMonitorFeatures() const
{
- return 0;
+ return {};
}
void QGeoAreaMonitorPolling::connectNotify(const QMetaMethod &/*signal*/)
diff --git a/src/positioning/qgeocoordinate.h b/src/positioning/qgeocoordinate.h
index ddb6274e..007f7e06 100644
--- a/src/positioning/qgeocoordinate.h
+++ b/src/positioning/qgeocoordinate.h
@@ -54,6 +54,7 @@ class QGeoCoordinatePrivate;
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)
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index 1225d7c8..b6513bc7 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -475,6 +475,9 @@ bool QGeoPathPrivate::lineContains(const QGeoCoordinate &coordinate) const
// 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())
@@ -482,23 +485,21 @@ bool QGeoPathPrivate::lineContains(const QGeoCoordinate &coordinate) const
else if (m_path.size() == 1)
return (m_path[0].distanceTo(coordinate) <= lineRadius);
- double leftBoundMercator = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
-
QDoubleVector2D p = QWebMercator::coordToMercator(coordinate);
- if (p.x() < leftBoundMercator)
- p.setX(p.x() + leftBoundMercator); // unwrap X
+ 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() < leftBoundMercator)
- a.setX(a.x() + leftBoundMercator); // unwrap X
+ if (a.x() < m_leftBoundWrapped)
+ a.setX(a.x() + m_leftBoundWrapped); // unwrap X
}
for (int i = 1; i < m_path.size(); i++) {
b = QWebMercator::coordToMercator(m_path[i]);
- if (b.x() < leftBoundMercator)
- b.setX(b.x() + leftBoundMercator); // unwrap X
+ if (b.x() < m_leftBoundWrapped)
+ b.setX(b.x() + m_leftBoundWrapped); // unwrap X
if (b == a)
continue;
@@ -513,7 +514,7 @@ bool QGeoPathPrivate::lineContains(const QGeoCoordinate &coordinate) const
if (candidate.x() > 1.0)
- candidate.setX(candidate.x() - leftBoundMercator); // wrap X
+ candidate.setX(candidate.x() - m_leftBoundWrapped); // wrap X
QGeoCoordinate closest = QWebMercator::mercatorToCoord(candidate);
@@ -600,6 +601,7 @@ void QGeoPathPrivate::translate(double degreesLatitude, double degreesLongitude)
p.setLongitude(QLocationUtils::wrapLong(p.longitude() + degreesLongitude));
}
m_bbox.translate(degreesLatitude, degreesLongitude);
+ m_leftBoundWrapped = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
}
QGeoRectangle QGeoPathPrivate::boundingGeoRectangle() const
@@ -673,6 +675,7 @@ void QGeoPathPrivate::computeBoundingBox()
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()
@@ -715,6 +718,7 @@ void QGeoPathPrivateEager::translate(double degreesLatitude, double degreesLongi
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)
@@ -729,11 +733,13 @@ void QGeoPathPrivateEager::addCoordinate(const QGeoCoordinate &coordinate)
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()
diff --git a/src/positioning/qgeopath_p.h b/src/positioning/qgeopath_p.h
index be73994f..6dd17b09 100644
--- a/src/positioning/qgeopath_p.h
+++ b/src/positioning/qgeopath_p.h
@@ -220,6 +220,7 @@ public:
QList<QGeoCoordinate> m_path;
qreal m_width = 0;
QGeoRectangle m_bbox; // cached
+ double m_leftBoundWrapped; // cached
bool m_bboxDirty = false;
};
diff --git a/src/positioning/qgeopolygon.cpp b/src/positioning/qgeopolygon.cpp
index e8fdda76..301759df 100644
--- a/src/positioning/qgeopolygon.cpp
+++ b/src/positioning/qgeopolygon.cpp
@@ -39,6 +39,8 @@
#include "qgeopolygon.h"
#include "qgeopolygon_p.h"
+#include "qgeopath_p.h"
+#include "qgeocircle.h"
#include "qgeocoordinate.h"
#include "qnumeric.h"
@@ -135,6 +137,41 @@ QGeoPolygon::QGeoPolygon(const QGeoPolygon &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.
*/
@@ -142,8 +179,22 @@ QGeoPolygon::QGeoPolygon(const QGeoShape &other)
: QGeoShape(other)
{
initPolygonConversions();
- if (type() != QGeoShape::PolygonType)
- d_ptr = new QGeoPolygonPrivate();
+ 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;
+ }
}
/*!
@@ -504,10 +555,11 @@ void QGeoPolygonPrivate::translate(double degreesLatitude, double degreesLongitu
// Need min/maxLati, so update bbox
QVector<double> m_deltaXs;
double m_minX, m_maxX, m_minLati, m_maxLati;
- m_bboxDirty = false;
+ 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
@@ -557,10 +609,11 @@ bool QGeoPolygonPrivate::polygonContains(const QGeoCoordinate &coordinate) const
const_cast<QGeoPolygonPrivate *>(this)->updateClipperPath(); // this one updates bbox too if needed
QDoubleVector2D coord = QWebMercator::coordToMercator(coordinate);
- double tlx = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
- if (coord.x() < tlx)
+
+ 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;
@@ -570,12 +623,7 @@ bool QGeoPolygonPrivate::polygonContains(const QGeoCoordinate &coordinate) const
// ToDo: cache these
QGeoPolygon holePolygon;
holePolygon.setPath(holePath);
- // QGeoPath holeBoundary;
- // holeBoundary.setPath(holePath);
-
- if (holePolygon.contains(coordinate)
- // && !(holeBoundary.contains(coordinate))
- )
+ if (holePolygon.contains(coordinate))
return false;
}
return true;
@@ -591,11 +639,11 @@ void QGeoPolygonPrivate::updateClipperPath()
if (m_bboxDirty)
computeBoundingBox();
m_clipperDirty = false;
- double tlx = QWebMercator::coordToMercator(m_bbox.topLeft()).x();
+
QList<QDoubleVector2D> preservedPath;
for (const QGeoCoordinate &c : m_path) {
QDoubleVector2D crd = QWebMercator::coordToMercator(c);
- if (crd.x() < tlx)
+ if (crd.x() < m_leftBoundWrapped)
crd.setX(crd.x() + 1.0);
preservedPath << crd;
}
@@ -625,6 +673,7 @@ QGeoShapePrivate *QGeoPolygonPrivateEager::clone() const
void QGeoPolygonPrivateEager::translate(double degreesLatitude, double degreesLongitude)
{
translatePoly(m_path, m_holesList, m_bbox, degreesLatitude, degreesLongitude, m_maxLati, m_minLati);
+ m_clipperDirty = true;
}
void QGeoPolygonPrivateEager::markDirty()
@@ -645,6 +694,7 @@ void QGeoPolygonPrivateEager::addCoordinate(const QGeoCoordinate &coordinate)
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()
diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp
index 0610bd79..1f9abec1 100644
--- a/src/positioning/qgeopositioninfosource.cpp
+++ b/src/positioning/qgeopositioninfosource.cpp
@@ -206,7 +206,7 @@ QGeoPositionInfoSource::QGeoPositionInfoSource(QObject *parent)
{
qRegisterMetaType<QGeoPositionInfo>();
d->interval = 0;
- d->methods = 0;
+ d->methods = {};
}
/*!
diff --git a/src/positioningquick/qdeclarativepositionsource.cpp b/src/positioningquick/qdeclarativepositionsource.cpp
index 6e042d9f..d6c62147 100644
--- a/src/positioningquick/qdeclarativepositionsource.cpp
+++ b/src/positioningquick/qdeclarativepositionsource.cpp
@@ -404,8 +404,8 @@ void QDeclarativePositionSource::socketConnected()
*/
void QDeclarativePositionSource::socketError(QAbstractSocket::SocketError error)
{
- delete m_nmeaSocket;
- m_nmeaSocket = 0;
+ m_nmeaSocket->deleteLater();
+ m_nmeaSocket = nullptr;
switch (error) {
case QAbstractSocket::UnknownSocketError:
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 2b04d110..390e9135 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -93,9 +93,7 @@ SUBDIRS += \
qgeolocation \
qgeopositioninfo \
qgeosatelliteinfo \
- qgeosatelliteinfosource \
- qgeojson \
- qnmeapositioninfosource
+ qgeojson
!android: SUBDIRS += \
positionplugin \
diff --git a/tests/auto/declarative_geoshape/tst_locationsingleton.qml b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
index 096a72e9..b58eedfd 100644
--- a/tests/auto/declarative_geoshape/tst_locationsingleton.qml
+++ b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
@@ -222,11 +222,11 @@ Item {
polygon = QtPositioning.shapeToPolygon(QtPositioning.circle())
verify(!polygon.isValid)
polygon = QtPositioning.shapeToPolygon(QtPositioning.circle(tl, 10000))
- verify(!polygon.isValid)
+ verify(polygon.isValid) // fixed, polygon copy constructor can now initialize from a circle.
polygon = QtPositioning.shapeToPolygon(QtPositioning.rectangle())
verify(!polygon.isValid)
polygon = QtPositioning.shapeToPolygon(QtPositioning.rectangle(tl, br))
- verify(!polygon.isValid)
+ verify(polygon.isValid) // fixed, polygon copy constructor can now initialize from a rectangle.
polygon = QtPositioning.shapeToPolygon(QtPositioning.polygon())
verify(!polygon.isValid)
diff --git a/tests/auto/nokia_services/routing/tst_routing.cpp b/tests/auto/nokia_services/routing/tst_routing.cpp
index 833c95af..ff3fd6ac 100644
--- a/tests/auto/nokia_services/routing/tst_routing.cpp
+++ b/tests/auto/nokia_services/routing/tst_routing.cpp
@@ -102,8 +102,8 @@ void MockGeoNetworkReply::setFile(QFile* file)
void MockGeoNetworkReply::complete()
{
- if (error() != QNetworkReply::NoError)
- emit error(error());
+ if (networkError() != QNetworkReply::NoError)
+ emit error(networkError());
setFinished(true);
emit finished();
}