summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-02-01 18:23:10 +0100
committerIvan Solovev <ivan.solovev@qt.io>2021-02-09 18:26:24 +0100
commit8efcfef59f6e18aba734dadfab82d13f26bc69c7 (patch)
treea186151ed72eb12e391a8d4b8f9d9dd0af0c9a29
parentbcf34e70cf790903bef50766dd27f581f34d803e (diff)
downloadqtlocation-8efcfef59f6e18aba734dadfab82d13f26bc69c7.tar.gz
QtPositioning: update QGeoLocation to use QGeoShape
QGeoLocation and QDeclarativeGeoLocation now use QGeoShape for bounding shape. The boundingBox() and setBoundingBox() methods are renamed to boundingShape() and setBoundingshape() respectively. Added tests for declarative geolocation. [ChangeLog][QtPositioning][QGeoLocation][QDeclarativeGeoLocation] Replaced QGeoLocation::boundingBox(), QGeoLocation::setBoundingBox(), QDeclarativeGeoLocation::boundingBox() and QDeclarativeGeoLocation::setBoundingBox() with QGeoLocation::boundingShape(), QGeoLocation::setBoundingShape(), QDeclarativeGeoLocation::boundingShape() and QDeclarativeGeoLocation::setBoundingShape() respectively. New methods use QGeoShape instead of QGeoRectangle. QML Location::boundingBox property is also replaced with Location::boundingShape. Task-number: QTBUG-90491 Change-Id: Ic609fde5de402fa6fea707baf18e5bd4e451aaa0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/positioning/qgeolocation.cpp25
-rw-r--r--src/positioning/qgeolocation.h6
-rw-r--r--src/positioning/qgeolocation_p.h4
-rw-r--r--src/positioningquick/qdeclarativegeolocation.cpp37
-rw-r--r--src/positioningquick/qdeclarativegeolocation_p.h12
-rw-r--r--tests/auto/CMakeLists.txt1
-rw-r--r--tests/auto/declarative_geolocation/CMakeLists.txt16
-rw-r--r--tests/auto/declarative_geolocation/main.cpp48
-rw-r--r--tests/auto/declarative_geolocation/tst_declarativegeolocation.qml144
-rw-r--r--tests/auto/declarative_positioning_core/tst_coordinate.qml21
-rw-r--r--tests/auto/qgeolocation/tst_qgeolocation.cpp50
-rw-r--r--tests/auto/qgeolocation/tst_qgeolocation.h2
12 files changed, 316 insertions, 50 deletions
diff --git a/src/positioning/qgeolocation.cpp b/src/positioning/qgeolocation.cpp
index 7d826e84..086529da 100644
--- a/src/positioning/qgeolocation.cpp
+++ b/src/positioning/qgeolocation.cpp
@@ -174,24 +174,33 @@ void QGeoLocation::setCoordinate(const QGeoCoordinate &coordinate)
}
/*!
- Returns a bounding box which represents the recommended region
+ \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.
+ 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.
*/
-QGeoRectangle QGeoLocation::boundingBox() const
+QGeoShape QGeoLocation::boundingShape() const
{
return d->viewport;
}
/*!
- Sets the \a boundingBox of the location.
+ \since 6.2
+
+ Sets the \a boundingShape of the location.
*/
-void QGeoLocation::setBoundingBox(const QGeoRectangle &boundingBox)
+void QGeoLocation::setBoundingShape(const QGeoShape &boundingShape)
{
- d->viewport = boundingBox;
+ d->viewport = boundingShape;
}
/*!
diff --git a/src/positioning/qgeolocation.h b/src/positioning/qgeolocation.h
index bff4b552..8aee0d23 100644
--- a/src/positioning/qgeolocation.h
+++ b/src/positioning/qgeolocation.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
class QGeoAddress;
class QGeoCoordinate;
-class QGeoRectangle;
+class QGeoShape;
class QGeoLocationPrivate;
class Q_POSITIONING_EXPORT QGeoLocation
@@ -70,8 +70,8 @@ public:
void setAddress(const QGeoAddress &address);
QGeoCoordinate coordinate() const;
void setCoordinate(const QGeoCoordinate &position);
- QGeoRectangle boundingBox() const; // ### Qt6: change this into QGeoShape geometry
- void setBoundingBox(const QGeoRectangle &box);
+ QGeoShape boundingShape() const;
+ void setBoundingShape(const QGeoShape &shape);
QVariantMap extendedAttributes() const;
void setExtendedAttributes(const QVariantMap &data);
diff --git a/src/positioning/qgeolocation_p.h b/src/positioning/qgeolocation_p.h
index a9ce639d..f402afe2 100644
--- a/src/positioning/qgeolocation_p.h
+++ b/src/positioning/qgeolocation_p.h
@@ -54,7 +54,7 @@
#include <QtCore/QSharedData>
#include <QtPositioning/QGeoAddress>
#include <QtPositioning/QGeoCoordinate>
-#include <QtPositioning/QGeoRectangle>
+#include <QtPositioning/QGeoShape>
#include <QVariantMap>
QT_BEGIN_NAMESPACE
@@ -73,7 +73,7 @@ public:
QGeoAddress address;
QGeoCoordinate coordinate;
- QGeoRectangle viewport;
+ QGeoShape viewport;
QVariantMap extendedAttributes;
};
diff --git a/src/positioningquick/qdeclarativegeolocation.cpp b/src/positioningquick/qdeclarativegeolocation.cpp
index 3ad8854a..200b5ed4 100644
--- a/src/positioningquick/qdeclarativegeolocation.cpp
+++ b/src/positioningquick/qdeclarativegeolocation.cpp
@@ -49,8 +49,9 @@ QT_USE_NAMESPACE
\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 {boundingBox}{bounding box}.
- The \l {boundingBox}{bounding box} represents the recommended region
+ 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
@@ -116,7 +117,7 @@ void QDeclarativeGeoLocation::setLocation(const QGeoLocation &src)
}
setCoordinate(src.coordinate());
- setBoundingBox(src.boundingBox());
+ setBoundingShape(src.boundingShape());
setProperty("extendedAttributes", src.extendedAttributes());
}
@@ -125,7 +126,7 @@ QGeoLocation QDeclarativeGeoLocation::location() const
QGeoLocation retValue;
retValue.setAddress(m_address ? m_address->address() : QGeoAddress());
retValue.setCoordinate(m_coordinate);
- retValue.setBoundingBox(m_boundingBox);
+ retValue.setBoundingShape(m_boundingShape);
retValue.setExtendedAttributes(m_extendedAttributes);
return retValue;
}
@@ -175,26 +176,38 @@ QGeoCoordinate QDeclarativeGeoLocation::coordinate() const
}
/*!
- \qmlproperty georectangle QtPositioning::Location::boundingBox
+ \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
+ \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 {ShapeType type} property of \l geoshape together with convenience
+ methods from \l [QML]{QtPositioning} like
+ \l {QtPositioning::shapeToRectangle}{QtPositioning.shapeToRectangle()}.
*/
-void QDeclarativeGeoLocation::setBoundingBox(const QGeoRectangle &boundingBox)
+void QDeclarativeGeoLocation::setBoundingShape(const QGeoShape &boundingShape)
{
- if (m_boundingBox == boundingBox)
+ if (m_boundingShape == boundingShape)
return;
- m_boundingBox = boundingBox;
- emit boundingBoxChanged();
+ m_boundingShape = boundingShape;
+ emit boundingShapeChanged();
}
-QGeoRectangle QDeclarativeGeoLocation::boundingBox() const
+QGeoShape QDeclarativeGeoLocation::boundingShape() const
{
- return m_boundingBox;
+ return m_boundingShape;
}
diff --git a/src/positioningquick/qdeclarativegeolocation_p.h b/src/positioningquick/qdeclarativegeolocation_p.h
index bb5f90a4..afb36ac6 100644
--- a/src/positioningquick/qdeclarativegeolocation_p.h
+++ b/src/positioningquick/qdeclarativegeolocation_p.h
@@ -54,7 +54,7 @@
#include <QtCore/QObject>
#include <QtCore/QVariantMap>
#include <QtPositioning/QGeoLocation>
-#include <QtPositioning/qgeorectangle.h>
+#include <QtPositioning/QGeoShape>
#include <QtPositioningQuick/private/qdeclarativegeoaddress_p.h>
#include <QtPositioningQuick/private/qpositioningquickglobal_p.h>
@@ -69,7 +69,7 @@ class Q_POSITIONINGQUICK_PRIVATE_EXPORT QDeclarativeGeoLocation : public QObject
Q_PROPERTY(QGeoLocation location READ location WRITE setLocation)
Q_PROPERTY(QDeclarativeGeoAddress *address READ address WRITE setAddress NOTIFY addressChanged)
Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
- Q_PROPERTY(QGeoRectangle boundingBox READ boundingBox WRITE setBoundingBox NOTIFY boundingBoxChanged)
+ Q_PROPERTY(QGeoShape boundingShape READ boundingShape WRITE setBoundingShape NOTIFY boundingShapeChanged REVISION(6, 0))
Q_PROPERTY(QVariantMap extendedAttributes MEMBER m_extendedAttributes NOTIFY extendedAttributesChanged REVISION(5, 13))
public:
@@ -85,18 +85,18 @@ public:
QGeoCoordinate coordinate() const;
void setCoordinate(const QGeoCoordinate coordinate);
- QGeoRectangle boundingBox() const;
- void setBoundingBox(const QGeoRectangle &boundingBox);
+ QGeoShape boundingShape() const;
+ void setBoundingShape(const QGeoShape &boundingShape);
Q_SIGNALS:
void addressChanged();
void coordinateChanged();
- void boundingBoxChanged();
+ void boundingShapeChanged();
void extendedAttributesChanged();
private:
QDeclarativeGeoAddress *m_address = nullptr;
- QGeoRectangle m_boundingBox;
+ QGeoShape m_boundingShape;
QGeoCoordinate m_coordinate;
QVariantMap m_extendedAttributes;
};
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
index 88cbc5ac..10bac2f9 100644
--- a/tests/auto/CMakeLists.txt
+++ b/tests/auto/CMakeLists.txt
@@ -74,6 +74,7 @@ add_subdirectory(qgeosatelliteinfo)
# endif()
if(TARGET Qt::Quick AND NOT ANDROID)
add_subdirectory(declarative_positioning_core)
+ add_subdirectory(declarative_geolocation)
endif()
if(NOT ANDROID)
add_subdirectory(positionplugin)
diff --git a/tests/auto/declarative_geolocation/CMakeLists.txt b/tests/auto/declarative_geolocation/CMakeLists.txt
new file mode 100644
index 00000000..366884c4
--- /dev/null
+++ b/tests/auto/declarative_geolocation/CMakeLists.txt
@@ -0,0 +1,16 @@
+# special case begin
+
+# Collect test data
+
+qt_internal_add_test(tst_declarative_geolocation
+ QMLTEST
+ SOURCES
+ main.cpp
+ PUBLIC_LIBRARIES
+ Qt::Positioning
+ Qt::Quick
+ TESTDATA
+ tst_declarativegeolocation.qml
+)
+
+# special case end
diff --git a/tests/auto/declarative_geolocation/main.cpp b/tests/auto/declarative_geolocation/main.cpp
new file mode 100644
index 00000000..86521a45
--- /dev/null
+++ b/tests/auto/declarative_geolocation/main.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** 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-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QCoreApplication>
+#include <QtQuickTest/quicktest.h>
+
+static void initializeLibraryPath()
+{
+#if QT_CONFIG(library)
+ // Set custom path since CI doesn't install test plugins
+#ifdef Q_OS_WIN
+ QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() +
+ QStringLiteral("/../../../../plugins"));
+#else
+ QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() +
+ QStringLiteral("/../../../plugins"));
+#endif
+#endif
+}
+
+Q_COREAPP_STARTUP_FUNCTION(initializeLibraryPath)
+
+QUICK_TEST_MAIN(declarative_geolocation)
diff --git a/tests/auto/declarative_geolocation/tst_declarativegeolocation.qml b/tests/auto/declarative_geolocation/tst_declarativegeolocation.qml
new file mode 100644
index 00000000..f7e2cf34
--- /dev/null
+++ b/tests/auto/declarative_geolocation/tst_declarativegeolocation.qml
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** 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-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtPositioning 6.0
+
+Item {
+ id: testCase
+
+ property var topLeft: QtPositioning.coordinate(1.0, 2.0)
+ property var bottomRight: QtPositioning.coordinate(2.0, 1.0)
+ property var centerPoint: QtPositioning.coordinate(1.5, 1.5)
+
+ Location {
+ id: defaultConstructed
+ }
+
+ Location {
+ id: location
+ }
+
+ SignalSpy { id: addressSpy; target: location; signalName: "addressChanged" }
+ SignalSpy { id: coordinateSpy; target: location; signalName: "coordinateChanged" }
+ SignalSpy { id: boundingShapeSpy; target: location; signalName: "boundingShapeChanged" }
+ SignalSpy { id: attributesSpy; target: location; signalName: "extendedAttributesChanged" }
+
+ Address {
+ id: emptyAddress
+ }
+
+ Address {
+ id: addr1
+ country: "Germany"
+ city: "Berlin"
+ street: "Erich-Thilo-Str"
+ postalCode: "12489"
+ }
+
+ Location {
+ id: completeLocation
+ address: addr1
+ coordinate: centerPoint
+ boundingShape: QtPositioning.rectangle(topLeft, bottomRight)
+ }
+
+ Location {
+ id: fromGeoLocation
+ }
+
+ TestCase {
+ name: "DeclarativeGeoLocation"
+
+ function test_default_construction() {
+ compare(defaultConstructed.address.address, emptyAddress.address)
+ compare(defaultConstructed.coordinate, QtPositioning.coordinate())
+ compare(defaultConstructed.boundingShape, QtPositioning.shape())
+ }
+
+ function test_address_changed() {
+ verify(addressSpy.valid)
+ addressSpy.clear()
+ location.address = addr1
+ compare(addressSpy.count, 1)
+ compare(location.address.address, addr1.address)
+ }
+
+ function test_coordinate_changed() {
+ var coord1 = QtPositioning.coordinate(1.0, 2.0)
+ var emptyCoord = QtPositioning.coordinate()
+ verify(coordinateSpy.valid)
+ coordinateSpy.clear()
+ compare(location.coordinate, emptyCoord)
+ location.coordinate = coord1
+ compare(coordinateSpy.count, 1)
+ compare(location.coordinate, coord1)
+ }
+
+ function test_bounding_box_changed() {
+ var emptyShape = QtPositioning.shape()
+ verify(boundingShapeSpy.valid)
+ boundingShapeSpy.clear()
+ compare(location.boundingShape, emptyShape)
+
+ var box = QtPositioning.rectangle(topLeft, bottomRight)
+ location.boundingShape = box
+ compare(boundingShapeSpy.count, 1)
+ compare(QtPositioning.shapeToRectangle(location.boundingShape), box)
+ // verify that shape's boundingGeoRectangle() matches the box.
+ compare(location.boundingShape.boundingGeoRectangle(), box)
+
+ var circle = QtPositioning.circle(centerPoint, 100)
+ location.boundingShape = circle
+ compare(boundingShapeSpy.count, 2)
+ compare(QtPositioning.shapeToCircle(location.boundingShape), circle)
+ }
+
+ function test_from_geolocation() {
+ fromGeoLocation.location = completeLocation.location
+ compare(fromGeoLocation.location, completeLocation.location)
+ compare(fromGeoLocation.address.address, completeLocation.address.address)
+ compare(fromGeoLocation.coordinate, completeLocation.coordinate)
+ compare(fromGeoLocation.boundingShape, completeLocation.boundingShape)
+ }
+
+ function test_extended_attributes() {
+ verify(attributesSpy.valid)
+ attributesSpy.clear()
+
+ var attributes = { "foo" : 42 }
+ location.extendedAttributes = attributes;
+ compare(location.extendedAttributes, attributes)
+ compare(attributesSpy.count, 1)
+
+ attributes["bar"] = 41
+ verify(location.extendedAttributes !== attributes)
+ }
+ }
+}
diff --git a/tests/auto/declarative_positioning_core/tst_coordinate.qml b/tests/auto/declarative_positioning_core/tst_coordinate.qml
index 00c8570b..e6502c85 100644
--- a/tests/auto/declarative_positioning_core/tst_coordinate.qml
+++ b/tests/auto/declarative_positioning_core/tst_coordinate.qml
@@ -28,7 +28,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtPositioning 5.5
+import QtPositioning 6.0
Item {
id: item
@@ -60,7 +60,7 @@ Item {
Location {
id: testLocation
coordinate: inside
- boundingBox: box
+ boundingShape: box
address: validTestAddress
}
@@ -103,12 +103,13 @@ Item {
compare (testLocation.coordinate.longitude, inside.longitude)
compare (testLocation.coordinate.latitude, inside.latitude)
- compare (testLocation.boundingBox.contains(inside), true)
- compare (testLocation.boundingBox.contains(outside), false)
- compare (testLocation.boundingBox.bottomRight.longitude, br.longitude)
- compare (testLocation.boundingBox.bottomRight.latitude, br.latitude)
- compare (testLocation.boundingBox.topLeft.longitude, tl.longitude)
- compare (testLocation.boundingBox.topLeft.latitude, tl.latitude)
+ compare (testLocation.boundingShape.contains(inside), true)
+ compare (testLocation.boundingShape.contains(outside), false)
+ var shapeRectangle = testLocation.boundingShape.boundingGeoRectangle()
+ compare (shapeRectangle.bottomRight.longitude, br.longitude)
+ compare (shapeRectangle.bottomRight.latitude, br.latitude)
+ compare (shapeRectangle.topLeft.longitude, tl.longitude)
+ compare (shapeRectangle.topLeft.latitude, tl.latitude)
compare (testLocation.address.country, "Australia")
compare (testLocation.address.countryCode, "AUS")
@@ -119,8 +120,8 @@ Item {
function test_Location_invalid()
{
compare(invalidLocation.coordinate.isValid, false)
- compare(invalidLocation.boundingBox.isEmpty, true)
- compare(invalidLocation.boundingBox.isValid, false)
+ compare(invalidLocation.boundingShape.isEmpty, true)
+ compare(invalidLocation.boundingShape.isValid, false)
compare(invalidLocation.address.city, "")
}
}
diff --git a/tests/auto/qgeolocation/tst_qgeolocation.cpp b/tests/auto/qgeolocation/tst_qgeolocation.cpp
index bb1f47f9..aae62c9a 100644
--- a/tests/auto/qgeolocation/tst_qgeolocation.cpp
+++ b/tests/auto/qgeolocation/tst_qgeolocation.cpp
@@ -27,6 +27,8 @@
****************************************************************************/
#include "tst_qgeolocation.h"
+#include <QtPositioning/QGeoCircle>
+#include <QtPositioning/QGeoPolygon>
QT_USE_NAMESPACE
@@ -56,7 +58,7 @@ void tst_QGeoLocation::constructor()
{
QCOMPARE(m_location.address(), m_address);
QCOMPARE(m_location.coordinate(), m_coordinate);
- QCOMPARE(m_location.boundingBox(), m_viewport);
+ QCOMPARE(m_location.boundingShape(), m_viewport);
QCOMPARE(m_location.extendedAttributes(), m_extendedAttributes);
}
@@ -114,14 +116,46 @@ void tst_QGeoLocation::viewport()
m_coordinate.setLatitude(13.3851);
m_coordinate.setLongitude(52.5312);
+ // rectangle bounding box
QGeoRectangle qgeoboundingboxcopy(m_coordinate, 0.4, 0.4);
- m_location.setBoundingBox(qgeoboundingboxcopy);
+ m_location.setBoundingShape(qgeoboundingboxcopy);
- QCOMPARE(m_location.boundingBox(),qgeoboundingboxcopy);
+ QCOMPARE(m_location.boundingShape(), qgeoboundingboxcopy);
+ // test that QGeoShape::boundingGeoRectangle() matches with
+ // the qgeoboundingboxcopy. It simplifies code porting
+ QCOMPARE(m_location.boundingShape().boundingGeoRectangle(), qgeoboundingboxcopy);
qgeoboundingboxcopy.setHeight(1);
- QVERIFY(m_location.boundingBox() != qgeoboundingboxcopy);
+ QVERIFY(m_location.boundingShape() != qgeoboundingboxcopy);
+
+ // circle bounding box
+ QGeoCircle circle(m_coordinate, 10);
+ m_location.setBoundingShape(circle);
+
+ QCOMPARE(m_location.boundingShape(), circle);
+
+ auto point = QGeoCoordinate(0.5, 0.5);
+ QVERIFY(!circle.contains(point));
+ circle.extendCircle(point);
+
+ QVERIFY(m_location.boundingShape() != circle);
+ QVERIFY(!m_location.boundingShape().contains(point));
+
+ // polygon bounding box
+ const QList<QGeoCoordinate> points = {QGeoCoordinate(1.0, 1.0), QGeoCoordinate(1.0, 2.0), QGeoCoordinate(2.0, 2.0)};
+ QGeoPolygon polygon(points);
+
+ point = QGeoCoordinate(1.75, 1.25);
+ QVERIFY(!polygon.contains(point));
+
+ m_location.setBoundingShape(polygon);
+ QCOMPARE(m_location.boundingShape(), polygon);
+
+ polygon.addCoordinate(QGeoCoordinate(2.0, 1.0));
+ QVERIFY(m_location.boundingShape() != polygon);
+ QVERIFY(polygon.contains(point));
+ QVERIFY(!m_location.boundingShape().contains(point));
}
void tst_QGeoLocation::extendedAttributes()
@@ -200,7 +234,7 @@ void tst_QGeoLocation::comparison()
location.setCoordinate(QGeoCoordinate(5,10));
//set viewport
- location.setBoundingBox(QGeoRectangle(QGeoCoordinate(5,5),0.4,0.4));
+ location.setBoundingShape(QGeoRectangle(QGeoCoordinate(5,5),0.4,0.4));
QGeoLocation otherLocation(location);
@@ -215,7 +249,7 @@ void tst_QGeoLocation::comparison()
} else if (dataField == "coordinate") {
otherLocation.setCoordinate(QGeoCoordinate(12,13));
} else if (dataField == "viewport"){
- otherLocation.setBoundingBox(QGeoRectangle(QGeoCoordinate(1,2), 0.5,0.5));
+ otherLocation.setBoundingShape(QGeoRectangle(QGeoCoordinate(1,2), 0.5,0.5));
} else if (dataField == "extendedAttributes"){
otherLocation.setExtendedAttributes(QVariantMap({{"foo", 44}}));
} else {
@@ -265,9 +299,9 @@ void tst_QGeoLocation::isEmpty()
QVERIFY(location.isEmpty());
// bounding box
- location.setBoundingBox(boundingBox);
+ location.setBoundingShape(boundingBox);
QVERIFY(!location.isEmpty());
- location.setBoundingBox(QGeoRectangle());
+ location.setBoundingShape(QGeoRectangle());
QVERIFY(location.isEmpty());
// extended attributes
diff --git a/tests/auto/qgeolocation/tst_qgeolocation.h b/tests/auto/qgeolocation/tst_qgeolocation.h
index a2bf6649..1b281c24 100644
--- a/tests/auto/qgeolocation/tst_qgeolocation.h
+++ b/tests/auto/qgeolocation/tst_qgeolocation.h
@@ -74,7 +74,7 @@ private:
QGeoAddress m_address;
QGeoCoordinate m_coordinate;
- QGeoRectangle m_viewport;
+ QGeoShape m_viewport;
QVariantMap m_extendedAttributes;
};