summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/positioning/qgeopath.cpp10
-rw-r--r--tests/auto/declarative_geoshape/tst_locationsingleton.qml39
2 files changed, 46 insertions, 3 deletions
diff --git a/src/positioning/qgeopath.cpp b/src/positioning/qgeopath.cpp
index 592933a9..94a14ad1 100644
--- a/src/positioning/qgeopath.cpp
+++ b/src/positioning/qgeopath.cpp
@@ -73,15 +73,19 @@ QT_BEGIN_NAMESPACE
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.
- The path is both invalid and empty if it contains no coordinate.
-
- A default constructed QGeoPath is therefore invalid.
+ \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()
diff --git a/tests/auto/declarative_geoshape/tst_locationsingleton.qml b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
index 6ebee62a..645aedb6 100644
--- a/tests/auto/declarative_geoshape/tst_locationsingleton.qml
+++ b/tests/auto/declarative_geoshape/tst_locationsingleton.qml
@@ -228,6 +228,10 @@ Item {
]
}
+ MapPolyline {
+ id: mapPolylineGeopath
+ }
+
TestCase {
name: "MapPolyline path"
function test_path_operations() {
@@ -274,4 +278,39 @@ Item {
compare(mapPolyline.path.length, mapPolyline.pathLength())
}
}
+
+ TestCase {
+ name: "GeoPath path"
+ function test_qgeopath_path_operations() {
+ var geopath = QtPositioning.path()
+
+ geopath.path = trace2
+ compare(geopath.path.length, trace2.length)
+
+ geopath.path = mapPolyline.path
+ compare(geopath.path.length, mapPolyline.pathLength())
+ compare(geopath.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
+
+ mapPolylineGeopath.path = mapPolyline.path
+ compare(mapPolylineGeopath.pathLength(), mapPolyline.pathLength())
+ compare(mapPolylineGeopath.geoShape.boundingGeoRectangle(), mapPolyline.geoShape.boundingGeoRectangle())
+
+ try {
+ var err = false;
+ mapPolylineGeopath.geoShape = geopath
+ } catch (e) {
+ if (e.message != 'Cannot assign to read-only property "geoShape"')
+ fail('Expected Cannot assign to read-only property "geoShape", got: ' + e.message);
+ err = true;
+ } finally {
+ verify(err, 'should throw Cannot assign to read-only property "geoShape"');
+ }
+
+ geopath.path = trace2
+ geopath.path[0].longitude = 11.0
+ compare(geopath.path.length, trace2.length)
+ compare(geopath.coordinateAt(0).latitude, trace2[0].latitude)
+ compare(geopath.coordinateAt(0).longitude, 11) // This fails
+ }
+ }
}