diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-01-11 14:49:00 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-01-11 14:49:00 +0100 |
commit | 17b4d7ed60e4a9e521ae74a74ea084a21633955e (patch) | |
tree | 05dc1dda6ef318e35e4a7ffefdf541608e7bd33a /src/location | |
parent | 5edef5e181e0f3cf2e04182d06b3c781717e6f87 (diff) | |
parent | 8014727e52c65bf6496ad4adf6c8e7ec33250bb7 (diff) | |
download | qtlocation-17b4d7ed60e4a9e521ae74a74ea084a21633955e.tar.gz |
Merge remote-tracking branch 'origin/dev' into wip/navigation
Conflicts:
src/location/maps/qgeomaneuver.cpp
src/location/maps/qgeomaneuver.h
src/location/maps/qgeomaneuver_p.h
tests/auto/declarative_core/tst_routing.qml
Change-Id: Iedf10d678a9129797f9aae872e09f78ef0a32de1
Diffstat (limited to 'src/location')
54 files changed, 1311 insertions, 218 deletions
diff --git a/src/location/configure.json b/src/location/configure.json index 4de6e865..bfa3d6f2 100644 --- a/src/location/configure.json +++ b/src/location/configure.json @@ -37,7 +37,7 @@ "condition": [ "features.opengl", "features.c++14", - "!config.qnx && (!config.win32 || config.mingw)" + "!config.qnx && !config.intel_icc && (!config.win32 || config.mingw)" ], "output": [ "privateFeature" ] }, diff --git a/src/location/declarativemaps/locationvaluetypehelper.cpp b/src/location/declarativemaps/locationvaluetypehelper.cpp index 4f39e0b4..5f75e225 100644 --- a/src/location/declarativemaps/locationvaluetypehelper.cpp +++ b/src/location/declarativemaps/locationvaluetypehelper.cpp @@ -35,11 +35,14 @@ ****************************************************************************/ #include "locationvaluetypehelper_p.h" +#include <QVariantMap> QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok) { QGeoCoordinate c; + if (ok) + *ok = false; if (value.isObject()) { if (value.hasProperty(QStringLiteral("latitude"))) @@ -56,6 +59,33 @@ QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok) return c; } +QGeoCoordinate parseCoordinate(const QVariant &value, bool *ok) +{ + QGeoCoordinate c; + if (ok) + *ok = false; + + if (value.canConvert<QGeoCoordinate>()) { + c = value.value<QGeoCoordinate>(); + if (ok) + *ok = true; + } else if (value.type() == QVariant::Map) { + const QVariantMap &map = value.toMap(); + + if (map.contains(QStringLiteral("latitude"))) + c.setLatitude(map.value(QStringLiteral("latitude")).toDouble()); + if (map.contains(QStringLiteral("longitude"))) + c.setLongitude(map.value(QStringLiteral("longitude")).toDouble()); + if (map.contains(QStringLiteral("altitude"))) + c.setAltitude(map.value(QStringLiteral("altitude")).toDouble()); + + if (ok) + *ok = c.isValid(); // Not considering the case where the map is valid but containing NaNs. + } + + return c; +} + QGeoRectangle parseRectangle(const QJSValue &value, bool *ok) { QGeoRectangle r; diff --git a/src/location/declarativemaps/locationvaluetypehelper_p.h b/src/location/declarativemaps/locationvaluetypehelper_p.h index 50038e88..09f3ab06 100644 --- a/src/location/declarativemaps/locationvaluetypehelper_p.h +++ b/src/location/declarativemaps/locationvaluetypehelper_p.h @@ -49,11 +49,13 @@ // #include <QJSValue> +#include <QVariant> #include <QGeoCoordinate> #include <QGeoRectangle> #include <QGeoCircle> -QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok); +QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok = nullptr); +QGeoCoordinate parseCoordinate(const QVariant &value, bool *ok = nullptr); QGeoRectangle parseRectangle(const QJSValue &value, bool *ok); QGeoCircle parseCircle(const QJSValue &value, bool *ok); diff --git a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp index 3e2a1aea..b64b2545 100644 --- a/src/location/declarativemaps/qdeclarativegeocodemodel.cpp +++ b/src/location/declarativemaps/qdeclarativegeocodemodel.cpp @@ -42,6 +42,7 @@ #include <QtPositioning/QGeoCircle> #include <QtLocation/QGeoServiceProvider> #include <QtLocation/QGeoCodingManager> +#include <QtPositioning/QGeoPolygon> QT_BEGIN_NAMESPACE @@ -374,6 +375,8 @@ QVariant QDeclarativeGeocodeModel::bounds() const return QVariant::fromValue(QGeoRectangle(boundingArea_)); else if (boundingArea_.type() == QGeoShape::CircleType) return QVariant::fromValue(QGeoCircle(boundingArea_)); + else if (boundingArea_.type() == QGeoShape::PolygonType) + return QVariant::fromValue(QGeoPolygon(boundingArea_)); else return QVariant::fromValue(boundingArea_); } diff --git a/src/location/declarativemaps/qdeclarativegeomaneuver.cpp b/src/location/declarativemaps/qdeclarativegeomaneuver.cpp index b1c67167..ef3639af 100644 --- a/src/location/declarativemaps/qdeclarativegeomaneuver.cpp +++ b/src/location/declarativemaps/qdeclarativegeomaneuver.cpp @@ -185,6 +185,36 @@ QGeoCoordinate QDeclarativeGeoManeuver::waypoint() const } /*! + \qmlproperty Object RouteManeuver::extendedAttributes + + This property holds the extended attributes of the maneuver and is a map. + These attributes are plugin specific, and can be empty. + + Consult the \l {Qt Location#Plugin References and Parameters}{plugin documentation} + for what attributes are supported and how they should be used. + + Note, due to limitations of the QQmlPropertyMap, it is not possible + to declaratively specify the attributes in QML, assignment of attributes keys + and values can only be accomplished by JavaScript. + + \since QtLocation 5.11 +*/ +QQmlPropertyMap *QDeclarativeGeoManeuver::extendedAttributes() const +{ + if (!m_extendedAttributes) { + QDeclarativeGeoManeuver *self = const_cast<QDeclarativeGeoManeuver *>(this); + self->m_extendedAttributes = new QQmlPropertyMap(self); + // Fill it + const QStringList keys = maneuver_.extendedAttributes().keys(); + for (const QString &key: keys) { + self->m_extendedAttributes->insert(key, + maneuver_.extendedAttributes().value(key)); + } + } + return m_extendedAttributes; +} + +/*! \qmlproperty bool RouteManeuver::waypointValid This read-only property holds whether this \l waypoint, associated with this diff --git a/src/location/declarativemaps/qdeclarativegeomaneuver_p.h b/src/location/declarativemaps/qdeclarativegeomaneuver_p.h index 0e957a1f..f321c133 100644 --- a/src/location/declarativemaps/qdeclarativegeomaneuver_p.h +++ b/src/location/declarativemaps/qdeclarativegeomaneuver_p.h @@ -50,7 +50,7 @@ #include <QtLocation/private/qlocationglobal_p.h> #include <QtLocation/qgeomaneuver.h> - +#include <QtQml/QQmlPropertyMap> #include <QtPositioning/QGeoCoordinate> #include <QObject> @@ -71,6 +71,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoManeuver : public QObject Q_PROPERTY(qreal distanceToNextInstruction READ distanceToNextInstruction CONSTANT) Q_PROPERTY(QGeoCoordinate waypoint READ waypoint CONSTANT) Q_PROPERTY(bool waypointValid READ waypointValid CONSTANT) + Q_PROPERTY(QObject *extendedAttributes READ extendedAttributes NOTIFY extendedAttributesChanged) public: enum Direction { @@ -101,9 +102,15 @@ public: int timeToNextInstruction() const; qreal distanceToNextInstruction() const; QGeoCoordinate waypoint() const; + QQmlPropertyMap *extendedAttributes() const; + +Q_SIGNALS: + void extendedAttributesChanged(); //in practice is never emitted since parameters cannot be re-assigned + //the declaration is needed to avoid warnings about non-notifyable properties private: QGeoManeuver maneuver_; + QQmlPropertyMap *m_extendedAttributes = nullptr; }; QT_END_NAMESPACE diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp index 9b19a0ac..34885f54 100644 --- a/src/location/declarativemaps/qdeclarativegeomap.cpp +++ b/src/location/declarativemaps/qdeclarativegeomap.cpp @@ -46,6 +46,7 @@ #include <QtPositioning/QGeoCircle> #include <QtPositioning/QGeoRectangle> #include <QtPositioning/QGeoPath> +#include <QtPositioning/QGeoPolygon> #include <QtQuick/QQuickWindow> #include <QtQuick/QSGRectangleNode> #include <QtQuick/private/qquickwindow_p.h> @@ -1341,22 +1342,22 @@ QGeoShape QDeclarativeGeoMap::visibleRegion() const return m_visibleRegion; const QList<QDoubleVector2D> &visibleRegion = m_map->geoProjection().visibleRegion(); - QGeoPath path; + QGeoPolygon poly; for (int i = 0; i < visibleRegion.size(); ++i) { const QDoubleVector2D &c = visibleRegion.at(i); // If a segment spans more than half of the map longitudinally, split in 2. if (i && qAbs(visibleRegion.at(i-1).x() - c.x()) >= 0.5) { // This assumes a segment is never >= 1.0 (whole map span) QDoubleVector2D extraPoint = (visibleRegion.at(i-1) + c) * 0.5; - path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint)); + poly.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint)); } - path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(c)); + poly.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(c)); } if (visibleRegion.size() >= 2 && qAbs(visibleRegion.last().x() - visibleRegion.first().x()) >= 0.5) { QDoubleVector2D extraPoint = (visibleRegion.last() + visibleRegion.first()) * 0.5; - path.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint)); + poly.addCoordinate(m_map->geoProjection().wrappedMapProjectionToGeo(extraPoint)); } - return path.boundingGeoRectangle(); + return poly; } /*! @@ -1480,6 +1481,8 @@ QQmlListProperty<QDeclarativeGeoMapType> QDeclarativeGeoMap::supportedMapTypes() If the Plugin used for the Map does not support bearing, or if the map is tilted and \a coordinate happens to be behind the camera, or if the map is not ready (see \l mapReady), calling this method will have no effect. + The release of this API with Qt 5.10 is a Technology Preview. + \since 5.10 */ void QDeclarativeGeoMap::setBearing(qreal bearing, const QGeoCoordinate &coordinate) @@ -1511,6 +1514,8 @@ void QDeclarativeGeoMap::setBearing(qreal bearing, const QGeoCoordinate &coordin If the map is tilted, and \a coordinate happens to be behind the camera, or if the map is not ready (see \l mapReady), calling this method will have no effect. + The release of this API with Qt 5.10 is a Technology Preview. + \sa center \since 5.10 @@ -2266,7 +2271,7 @@ bool QDeclarativeGeoMap::sendTouchEvent(QTouchEvent *event) auto touchPointGrabberItem = [touchDevice, windowPriv](const QTouchEvent::TouchPoint &point) -> QQuickItem* { if (QQuickEventPoint *eventPointer = windowPriv->pointerEventInstance(touchDevice)->pointById(point.id())) - return eventPointer->grabber(); + return eventPointer->grabberItem(); return nullptr; }; diff --git a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp index d8c19528..24ed6700 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp @@ -378,7 +378,7 @@ void QDeclarativeGeoMapItemView::setAutoFitViewport(const bool &fitViewport) */ void QDeclarativeGeoMapItemView::fitViewport() { - if (!map_ || !fitViewport_ || m_repopulating) + if (!map_ || !map_->mapReady() || !fitViewport_ || m_repopulating) return; if (map_->mapItems().size() > 0) diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp index 0383c0c4..8066d917 100644 --- a/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp +++ b/src/location/declarativemaps/qdeclarativegeoroutemodel.cpp @@ -45,9 +45,63 @@ #include <QtQml/private/qqmlengine_p.h> #include <QtLocation/QGeoRoutingManager> #include <QtPositioning/QGeoRectangle> +#include "qdeclarativegeomapparameter_p.h" QT_BEGIN_NAMESPACE +static bool compareFloats(qreal a, qreal b) +{ + return (qIsNaN(a) && qIsNaN(b)) + || a == b; +} + +static bool compareParameterList(const QList<QDeclarativeGeoMapParameter *> &a, const QList<QDeclarativeGeoMapParameter *> &b) +{ + if (a.size() != b.size()) + return false; + if (a != b) { + for (int i = 0; i < a.size(); ++i) { + if (! (*a.at(i) == *b.at(i))) + return false; + } + } + return true; +} + +static int findWaypoint(const QList<QDeclarativeGeoWaypoint *> &waypoints, const QDeclarativeGeoWaypoint *w) +{ + for (int i = waypoints.size() - 1; i >= 0; --i) { + if (waypoints.at(i) == w || *waypoints.at(i) == *w) + return i; + } + return -1; +} + +static int findWaypoint(const QList<QDeclarativeGeoWaypoint *> &waypoints, const QGeoCoordinate &c) +{ + for (int i = waypoints.size() - 1; i >= 0; --i) { + if (waypoints.at(i)->coordinate() == c) + return i; + } + return -1; +} + +static QList<QGeoCoordinate> waypointCoordinates(const QList<QDeclarativeGeoWaypoint *> &waypoints) +{ + QList<QGeoCoordinate> res; + for (const QDeclarativeGeoWaypoint *w: waypoints) + res << w->coordinate(); + return res; +} + +static QList<QVariantMap> waypointMetadata(const QList<QDeclarativeGeoWaypoint *> &waypoints) +{ + QList<QVariantMap> res; + for (QDeclarativeGeoWaypoint *w: waypoints) + res << w->metadata(); + return res; +} + /*! \qmltype RouteModel \instantiates QDeclarativeGeoRouteModel @@ -653,7 +707,7 @@ void QDeclarativeGeoRouteModel::routingError(QGeoRouteReply *reply, \brief The RouteQuery type is used to provide query parameters to a RouteModel. - A RouteQuery contains all the parameters necessary to make a request + A RouteQuery is used to pack all the parameters necessary to make a request to a routing service, which can then populate the contents of a RouteModel. These parameters describe key details of the route, such as \l waypoints to @@ -665,6 +719,10 @@ void QDeclarativeGeoRouteModel::routingError(QGeoRouteReply *reply, RouteModel's \l{RouteModel::query}{query} property, which can then begin the retrieval process to populate the model. + Some plugins might allow or require specific parameters to operate. + In order to specify these plugin-specific parameters, MapParameter elements + can be nested inside a RouteQuery. + \section2 Example Usage The following snipped shows an incomplete example of creating a RouteQuery @@ -768,60 +826,93 @@ void QDeclarativeGeoRouteQuery::setNumberAlternativeRoutes(int numberAlternative \qmlproperty list<coordinate> RouteQuery::waypoints - The waypoint coordinates of the desired route. + The coordinates of the waypoints for the desired route. The waypoints should be given in order from origin to destination. Two or more coordinates are needed. Waypoints can be set as part of the RouteQuery type declaration or dynamically with the functions provided. - \sa addWaypoint, removeWaypoint, clearWaypoints + When setting this property to a list of waypoints, each waypoint + can be either a \l coordinate or a \l Waypoint, interchangeably. + If a \l coordinate is passed, it will be internally converted to a + \l Waypoint. + + This property, however, always contains a list of coordinates. + + \sa waypointObjects, addWaypoint, removeWaypoint, clearWaypoints */ -QJSValue QDeclarativeGeoRouteQuery::waypoints() +QVariantList QDeclarativeGeoRouteQuery::waypoints() { - QQmlContext *context = QQmlEngine::contextForObject(parent()); - QQmlEngine *engine = context->engine(); - QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine); + QVariantList res; - QV4::Scope scope(v4); - QV4::Scoped<QV4::ArrayObject> waypointArray(scope, v4->newArrayObject(request_.waypoints().length())); - for (int i = 0; i < request_.waypoints().length(); ++i) { - const QGeoCoordinate &c = request_.waypoints().at(i); + for (const auto &w : m_waypoints) + res << QVariant::fromValue(w->coordinate()); - QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c))); - waypointArray->putIndexed(i, cv); - } + return res; +} + +/*! + \qmlmethod list<Waypoint> QtLocation::RouteQuery::waypointObjects() + + This method can be used to retrieve the list of Waypoint objects + relative to RouteQuery::waypoints. - return QJSValue(v4, waypointArray.asReturnedValue()); + \sa waypointObjects, addWaypoint, removeWaypoint, clearWaypoints +*/ +QVariantList QDeclarativeGeoRouteQuery::waypointObjects() +{ + QVariantList res; + + for (const auto &w : m_waypoints) + res << QVariant::fromValue(w); + + return res; } -void QDeclarativeGeoRouteQuery::setWaypoints(const QJSValue &value) +void QDeclarativeGeoRouteQuery::setWaypoints(const QVariantList &value) { - if (!value.isArray()) - return; + QList<QDeclarativeGeoWaypoint *> waypointList; + bool allWaypoints = true; + + for (const auto &w: value) { + // First, test if this is already a QDeclarativeGeoWaypoint + // From QVariant to QObject * + QDeclarativeGeoWaypoint *waypoint = nullptr; + QObject *obj = qvariant_cast<QObject *>(w); + waypoint = qobject_cast<QDeclarativeGeoWaypoint *>(obj); + + if (waypoint) { + waypointList << waypoint; + continue; + } - QList<QGeoCoordinate> waypointList; - quint32 length = value.property(QStringLiteral("length")).toUInt(); - for (quint32 i = 0; i < length; ++i) { - bool ok; - QGeoCoordinate c = parseCoordinate(value.property(i), &ok); + // if here, w is not a Waypoint, so either a QGeoCoordinate or a variant map, so a waypoint has to be instantiated. + allWaypoints = false; - if (!ok || !c.isValid()) { - qmlWarning(this) << "Unsupported waypoint type"; + QGeoCoordinate c = parseCoordinate(w); + if (!c.isValid()) { + qmlWarning(this) << QStringLiteral("Invalid waypoint"); + flushWaypoints(waypointList); return; } - waypointList.append(c); + waypoint = new QDeclarativeGeoWaypoint(this); + waypoint->setCoordinate(c); + waypointList << waypoint; + } - if (request_.waypoints() == waypointList) + if (allWaypoints && m_waypoints == waypointList) return; - request_.setWaypoints(waypointList); + flushWaypoints(m_waypoints); + m_waypoints = waypointList; + for (const QDeclarativeGeoWaypoint *w: qAsConst(m_waypoints)) + connect(w, &QDeclarativeGeoWaypoint::waypointDetailsChanged, this, &QDeclarativeGeoRouteQuery::waypointChanged); - emit waypointsChanged(); - emit queryDetailsChanged(); + waypointChanged(); } /*! @@ -864,7 +955,7 @@ void QDeclarativeGeoRouteQuery::setExcludedAreas(const QJSValue &value) QGeoRectangle r = parseRectangle(value.property(i), &ok); if (!ok || !r.isValid()) { - qmlWarning(this) << "Unsupported area type"; + qmlWarning(this) << QStringLiteral("Unsupported area type"); return; } @@ -876,8 +967,10 @@ void QDeclarativeGeoRouteQuery::setExcludedAreas(const QJSValue &value) request_.setExcludeAreas(excludedAreasList); - emit excludedAreasChanged(); - emit queryDetailsChanged(); + if (complete_) { + emit excludedAreasChanged(); + emit queryDetailsChanged(); + } } /*! @@ -933,8 +1026,10 @@ void QDeclarativeGeoRouteQuery::removeExcludedArea(const QGeoRectangle &area) excludedAreas.removeAt(index); request_.setExcludeAreas(excludedAreas); - emit excludedAreasChanged(); - emit queryDetailsChanged(); + if (complete_) { + emit excludedAreasChanged(); + emit queryDetailsChanged(); + } } /*! @@ -952,8 +1047,10 @@ void QDeclarativeGeoRouteQuery::clearExcludedAreas() request_.setExcludeAreas(QList<QGeoRectangle>()); - emit excludedAreasChanged(); - emit queryDetailsChanged(); + if (complete_) { + emit excludedAreasChanged(); + emit queryDetailsChanged(); + } } /*! @@ -961,24 +1058,43 @@ void QDeclarativeGeoRouteQuery::clearExcludedAreas() Appends a coordinate to the list of waypoints. Same coordinate can be set multiple times. + The \a coordinate argument can be a \l coordinate or a \l Waypoint. + If a \l coordinate is used, it will be internally converted to a + \l Waypoint. \sa removeWaypoint, clearWaypoints */ -void QDeclarativeGeoRouteQuery::addWaypoint(const QGeoCoordinate &waypoint) +void QDeclarativeGeoRouteQuery::addWaypoint(const QVariant &waypoint) { - if (!waypoint.isValid()) { - qmlWarning(this) << QStringLiteral("Not adding invalid waypoint."); + QDeclarativeGeoWaypoint *w = nullptr; + QObject *obj = qvariant_cast<QObject *>(waypoint); + w = qobject_cast<QDeclarativeGeoWaypoint *>(obj); + + if (w) { + if (! w->isValid()) { + qmlWarning(this) << QStringLiteral("Invalid waypoint"); + return; + } + + m_waypoints << w; + connect(w, &QDeclarativeGeoWaypoint::waypointDetailsChanged, this, &QDeclarativeGeoRouteQuery::waypointChanged); + waypointChanged(); return; } - QList<QGeoCoordinate> waypoints = request_.waypoints(); - waypoints.append(waypoint); - request_.setWaypoints(waypoints); + // if here, waypoint is not a Waypoint, so either a QGeoCoordinate or a variant map, so a waypoint has to be instantiated. - if (complete_) { - emit waypointsChanged(); - emit queryDetailsChanged(); + QGeoCoordinate c = parseCoordinate(waypoint); + if (!c.isValid()) { + qmlWarning(this) << QStringLiteral("Invalid coordinate as waypoint"); + return; } + + w = new QDeclarativeGeoWaypoint(this); + w->setCoordinate(c); + m_waypoints << w; + connect(w, &QDeclarativeGeoWaypoint::waypointDetailsChanged, this, &QDeclarativeGeoRouteQuery::waypointChanged); + waypointChanged(); } /*! @@ -990,22 +1106,49 @@ void QDeclarativeGeoRouteQuery::addWaypoint(const QGeoCoordinate &waypoint) \sa addWaypoint, clearWaypoints */ -void QDeclarativeGeoRouteQuery::removeWaypoint(const QGeoCoordinate &waypoint) +void QDeclarativeGeoRouteQuery::removeWaypoint(const QVariant &waypoint) { - QList<QGeoCoordinate> waypoints = request_.waypoints(); + QDeclarativeGeoWaypoint *w = nullptr; + QObject *obj = qvariant_cast<QObject *>(waypoint); + w = qobject_cast<QDeclarativeGeoWaypoint *>(obj); - int index = waypoints.lastIndexOf(waypoint); - if (index == -1) { - qmlWarning(this) << QStringLiteral("Cannot remove nonexistent waypoint."); + if (w) { + if (!w->isValid()) { + qmlWarning(this) << QStringLiteral("Invalid waypoint"); + return; + } + + int idx = findWaypoint(m_waypoints, w); + if (idx >= 0) { + QDeclarativeGeoWaypoint *toRemove = m_waypoints.takeAt(idx); + toRemove->disconnect(this); + if (toRemove->parent() == this) + delete toRemove; + + waypointChanged(); + } else { + qmlWarning(this) << QStringLiteral("Cannot remove nonexistent waypoint."); + } return; } - waypoints.removeAt(index); + QGeoCoordinate c = parseCoordinate(waypoint); + if (!c.isValid()) { + qmlWarning(this) << QStringLiteral("Invalid coordinate as waypoint"); + return; + } - request_.setWaypoints(waypoints); + int idx = findWaypoint(m_waypoints, c); + if (idx >= 0) { + QDeclarativeGeoWaypoint *toRemove = m_waypoints.takeAt(idx); + toRemove->disconnect(this); + if (toRemove->parent() == this) + delete toRemove; - emit waypointsChanged(); - emit queryDetailsChanged(); + waypointChanged(); + } else { + qmlWarning(this) << QStringLiteral("Cannot remove nonexistent waypoint."); + } } /*! @@ -1017,13 +1160,21 @@ void QDeclarativeGeoRouteQuery::removeWaypoint(const QGeoCoordinate &waypoint) */ void QDeclarativeGeoRouteQuery::clearWaypoints() { - if (request_.waypoints().isEmpty()) + if (m_waypoints.isEmpty()) return; - request_.setWaypoints(QList<QGeoCoordinate>()); + flushWaypoints(m_waypoints); + waypointChanged(); +} - emit waypointsChanged(); - emit queryDetailsChanged(); +void QDeclarativeGeoRouteQuery::flushWaypoints(QList<QDeclarativeGeoWaypoint *> &waypoints) +{ + for (const QDeclarativeGeoWaypoint *w : qAsConst(waypoints)) { + w->disconnect(this); + if (w->parent() == this) // w has been created internally as a result of adding a QGeoCoordinate + delete w; + } + waypoints.clear(); } /*! @@ -1285,8 +1436,23 @@ void QDeclarativeGeoRouteQuery::setRouteOptimizations(QDeclarativeGeoRouteQuery: /*! \internal */ -QGeoRouteRequest QDeclarativeGeoRouteQuery::routeRequest() const +QGeoRouteRequest QDeclarativeGeoRouteQuery::routeRequest() { + if (m_extraParametersChanged) { + m_extraParametersChanged = false; + // Update extra params into request + const QList<QDeclarativeGeoMapParameter *> params = quickChildren<QDeclarativeGeoMapParameter>(); + QMap<QString, QVariantMap> extraParameters; + for (const QDeclarativeGeoMapParameter *p: params) + extraParameters[p->type()] = p->toVariantMap(); + request_.setExtraParameters(extraParameters); + } + if (m_waypointsChanged) { + m_waypointsChanged = false; + // Update waypoints and metadata into request + request_.setWaypoints(waypointCoordinates(m_waypoints)); + request_.setWaypointsMetadata(waypointMetadata(m_waypoints)); + } return request_; } @@ -1298,10 +1464,385 @@ void QDeclarativeGeoRouteQuery::excludedAreaCoordinateChanged() } } +void QDeclarativeGeoRouteQuery::extraParameterChanged() +{ + m_extraParametersChanged = true; + if (complete_) { + emit extraParametersChanged(); + emit queryDetailsChanged(); + } +} + +void QDeclarativeGeoRouteQuery::waypointChanged() +{ + m_waypointsChanged = true; + if (complete_) { + emit waypointsChanged(); + emit queryDetailsChanged(); + } +} + +void QDeclarativeGeoRouteQuery::append(QQmlListProperty<QObject> *p, QObject *v) +{ + QDeclarativeGeoRouteQuery *query = static_cast<QDeclarativeGeoRouteQuery*>(p->object); + query->m_children.append(v); + + QDeclarativeGeoMapParameter *param = qobject_cast<QDeclarativeGeoMapParameter *>(v); + if (param) { + query->m_extraParametersChanged = true; + query->connect(param, &QGeoMapParameter::propertyUpdated, + query, &QDeclarativeGeoRouteQuery::extraParameterChanged); + if (query->complete_) { + emit query->extraParametersChanged(); + emit query->queryDetailsChanged(); + } + } +} + +int QDeclarativeGeoRouteQuery::count(QQmlListProperty<QObject> *p) +{ + return static_cast<QDeclarativeGeoRouteQuery*>(p->object)->m_children.count(); +} + +QObject *QDeclarativeGeoRouteQuery::at(QQmlListProperty<QObject> *p, int idx) +{ + return static_cast<QDeclarativeGeoRouteQuery*>(p->object)->m_children.at(idx); +} + +void QDeclarativeGeoRouteQuery::clear(QQmlListProperty<QObject> *p) +{ + QDeclarativeGeoRouteQuery *query = static_cast<QDeclarativeGeoRouteQuery*>(p->object); + for (auto kid : qAsConst(query->m_children)) { + auto val = qobject_cast<QDeclarativeGeoMapParameter *>(kid); + if (val) { + val->disconnect(val, nullptr, query, nullptr); + query->m_extraParametersChanged = true; + } + } + query->m_children.clear(); + if (query->m_extraParametersChanged && query->complete_) { + emit query->extraParametersChanged(); + emit query->queryDetailsChanged(); + } +} + +QQmlListProperty<QObject> QDeclarativeGeoRouteQuery::declarativeChildren() +{ + return QQmlListProperty<QObject>(this, nullptr, + &QDeclarativeGeoRouteQuery::append, + &QDeclarativeGeoRouteQuery::count, + &QDeclarativeGeoRouteQuery::at, + &QDeclarativeGeoRouteQuery::clear); +} + void QDeclarativeGeoRouteQuery::doCoordinateChanged() { m_excludedAreaCoordinateChanged = false; - emit queryDetailsChanged(); + if (complete_) + emit queryDetailsChanged(); +} + +/*! + \qmltype Waypoint + \instantiates QDeclarativeGeoWaypoint + \inqmlmodule QtLocation + \ingroup qml-QtLocation5-routing + \since Qt Location 5.11 + + \brief The Waypoint type provides a mean to specify a waypoint in a \l RouteQuery + in a more detailed way than by using a simple \l coordinate. + + A Waypoint is a type that allows to specify properties of a waypoint in a \l RouteQuery, + such as the waypoint coordinate, or the angle of approach to the waypoint. + + Additional information that are backend-specific can be specified by nesting \l MapParameter + elements. + + Changing properties of the waypoint or of its nested MapParameteters will cause the containing + \l RouteQuery to emit the queryDetailsChanged signal. + + \section2 Example Usage + + The following snippet is two-part, showing firstly the declaration of + objects, and secondly a short piece of procedural code using it. We set + the routeModel's \l{autoUpdate} property to false, and call \l{update} once + the query is set up, to avoid useless extra requests halfway through the + set up of the query. + + \code + Plugin { + id: aPlugin + name: "osm" + } + + Waypoint { + id: waypointStart + coordinate: ... + bearing: ... + } + Waypoint { + id: waypointFinish + coordinate: ... + bearing: ... + } + + RouteQuery { + id: aQuery + Component.onCompleted: { + travelModes = RouteQuery.CarTravel + addWaypoint(waypointStart) + var aWaypoint = Qt.createQmlObject ('import QtLocation 5.11; Waypoint { ... }', ...) + addWaypoint(aWaypoint) + addWaypoint(waypointFinish) + } + } + + RouteModel { + id: routeModel + plugin: aPlugin + query: aQuery + autoUpdate: true + } + \endcode + + \sa RouteQuery +*/ + + +/* + * + At the time of adding this class (2017.11), 3 routing services are natively supported in Qt: Esri, Here and OSRM. + Waypoint documentation for each of these: + Esri: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000 , called "stop" + HERE: https://developer.here.com/documentation/routing/topics/resource-param-type-waypoint.html + OSRM: https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md , under Request Options + * + */ + + +static QGeoCoordinate convertWaypointToCoordinate(const QDeclarativeGeoWaypoint *value) +{ + return QGeoCoordinate(value); +} + +struct WaypointVariantConversions +{ + WaypointVariantConversions() + { + QMetaType::registerConverter<QDeclarativeGeoWaypoint *, QGeoCoordinate>(convertWaypointToCoordinate); + } +}; + +Q_GLOBAL_STATIC(WaypointVariantConversions, initWaypointConversions) + + +QDeclarativeGeoWaypoint::QDeclarativeGeoWaypoint(QObject *parent) : QGeoCoordinateObject(parent) +{ + initWaypointConversions(); + connect(this, &QGeoCoordinateObject::coordinateChanged, + this, &QDeclarativeGeoWaypoint::waypointDetailsChanged); +} + +QDeclarativeGeoWaypoint::~QDeclarativeGeoWaypoint() +{ + +} + +bool QDeclarativeGeoWaypoint::operator==(const QDeclarativeGeoWaypoint &other) const +{ + const QList<QDeclarativeGeoMapParameter *> params = quickChildren<QDeclarativeGeoMapParameter>(); + const QList<QDeclarativeGeoMapParameter *> otherParams = other.quickChildren<QDeclarativeGeoMapParameter>(); + + return coordinate() == other.coordinate() && + compareFloats(m_bearing, other.bearing()) && + compareParameterList(params, otherParams); +} + +/*! + \qmlproperty coordinate Waypoint::coordinate + + The waypoint's coordinate. The default value is undefined. +*/ + + +/*! + \qmlproperty real Waypoint::latitude + + The latitude of the waypoint's coordinate. The default value is NaN. + Changing this property will affect the \l Waypoint::coordinate property as well. +*/ +qreal QDeclarativeGeoWaypoint::latitude() const +{ + return m_coordinate.latitude(); +} + +void QDeclarativeGeoWaypoint::setLatitude(qreal latitude) +{ + if (compareFloats(latitude, m_coordinate.latitude())) + return; + + m_coordinate.setLatitude(latitude); + if (m_complete) { + emit coordinateChanged(); + emit waypointDetailsChanged(); + } +} + +/*! + \qmlproperty real Waypoint::longitude + + The longitude of the waypoint's coordinate. The default value is NaN. + Changing this property will affect the \l Waypoint::coordinate property as well. +*/ +qreal QDeclarativeGeoWaypoint::longitude() const +{ + return m_coordinate.longitude(); +} + +void QDeclarativeGeoWaypoint::setLongitude(qreal longitude) +{ + if (compareFloats(longitude, m_coordinate.longitude())) + return; + + m_coordinate.setLongitude(longitude); + if (m_complete) { + emit coordinateChanged(); + emit waypointDetailsChanged(); + } +} + +/*! + \qmlproperty real Waypoint::altitude + + The altitude of the waypoint's coordinate. The default value is NaN. + Changing this property will affect the \l Waypoint::coordinate property as well. +*/ +qreal QDeclarativeGeoWaypoint::altitude() const +{ + return m_coordinate.altitude(); +} + +void QDeclarativeGeoWaypoint::setAltitude(qreal altitude) +{ + if (compareFloats(altitude, m_coordinate.altitude())) + return; + + m_coordinate.setAltitude(altitude); + if (m_complete) { + emit coordinateChanged(); + emit waypointDetailsChanged(); + } +} + +bool QDeclarativeGeoWaypoint::isValid() const +{ + return m_coordinate.isValid(); +} + +/*! + \qmlproperty real Waypoint::bearing + + The bearing specifying the angle of approach of the waypoint, that is the bearing with which the waypoint is to be approached. + This information may be used by the provider to filter the road segment the waypoint will be placed on, and, + depending on the provider and the \l {QGeoRouteRequest::TravelMode} {travel mode} used, to restrict the maneuvers + allowed at the waypoint, potentially making the provider calculating and returning a different route. + + If set to NaN, this value will not be considered. + + The default value is NaN. +*/ +qreal QDeclarativeGeoWaypoint::bearing() const +{ + return m_bearing; +} + +void QDeclarativeGeoWaypoint::setBearing(qreal bearing) +{ + if (compareFloats(bearing, m_bearing)) + return; + + m_bearing = bearing; + + // Bearing is actually packed into QGeoRouteRequest::waypointMetadata() together with the extra parameters + m_metadataChanged = true; + if (m_complete) { + emit bearingChanged(); + emit waypointDetailsChanged(); + } +} + +QVariantMap QDeclarativeGeoWaypoint::metadata() +{ + if (m_metadataChanged) { + m_metadataChanged = false; + m_metadata.clear(); + // Update metadata + const QList<QDeclarativeGeoMapParameter *> params = quickChildren<QDeclarativeGeoMapParameter>(); + QVariantMap extraParameters; + for (const QDeclarativeGeoMapParameter *p: params) + extraParameters[p->type()] = p->toVariantMap(); + m_metadata[QStringLiteral("extra")] = extraParameters; + m_metadata[QStringLiteral("bearing")] = m_bearing; + } + return m_metadata; +} + +void QDeclarativeGeoWaypoint::extraParameterChanged() +{ + m_metadataChanged = true; + if (m_complete) { + emit extraParametersChanged(); + emit waypointDetailsChanged(); + } +} + +void QDeclarativeGeoWaypoint::append(QQmlListProperty<QObject> *p, QObject *v) +{ + QDeclarativeGeoWaypoint *waypoint = static_cast<QDeclarativeGeoWaypoint*>(p->object); + waypoint->m_children.append(v); + + QDeclarativeGeoMapParameter *param = qobject_cast<QDeclarativeGeoMapParameter *>(v); + if (param) { + waypoint->connect(param, &QGeoMapParameter::propertyUpdated, + waypoint, &QDeclarativeGeoWaypoint::extraParameterChanged); + waypoint->extraParameterChanged(); + } +} + +int QDeclarativeGeoWaypoint::count(QQmlListProperty<QObject> *p) +{ + return static_cast<QDeclarativeGeoWaypoint*>(p->object)->m_children.count(); +} + +QObject *QDeclarativeGeoWaypoint::at(QQmlListProperty<QObject> *p, int idx) +{ + return static_cast<QDeclarativeGeoWaypoint*>(p->object)->m_children.at(idx); +} + +void QDeclarativeGeoWaypoint::clear(QQmlListProperty<QObject> *p) +{ + QDeclarativeGeoWaypoint *waypoint = static_cast<QDeclarativeGeoWaypoint*>(p->object); + for (auto kid : qAsConst(waypoint->m_children)) { + auto val = qobject_cast<QDeclarativeGeoMapParameter *>(kid); + if (val) { + val->disconnect(waypoint); + waypoint->m_metadataChanged = true; + } + } + waypoint->m_children.clear(); + if (waypoint->m_metadataChanged && waypoint->m_complete) { + emit waypoint->extraParametersChanged(); + emit waypoint->waypointDetailsChanged(); + } +} + +QQmlListProperty<QObject> QDeclarativeGeoWaypoint::declarativeChildren() +{ + return QQmlListProperty<QObject>(this, nullptr, + &QDeclarativeGeoWaypoint::append, + &QDeclarativeGeoWaypoint::count, + &QDeclarativeGeoWaypoint::at, + &QDeclarativeGeoWaypoint::clear); } QT_END_NAMESPACE diff --git a/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h b/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h index 18486ac8..5d8d1803 100644 --- a/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h +++ b/src/location/declarativemaps/qdeclarativegeoroutemodel_p.h @@ -53,6 +53,7 @@ #include <QtPositioning/QGeoCoordinate> #include <QtPositioning/QGeoRectangle> +#include <QtPositioning/private/qgeocoordinateobject_p.h> #include <qgeorouterequest.h> #include <qgeoroutereply.h> @@ -185,6 +186,90 @@ private: RouteError error_; }; + + +// purpose of this class is to be convertible to a QGeoCoordinate (through QGeoWaypoint), but also +// to behave like it, so that in QML source compatibility would be preserved. This is, however, not possible to achieve at the present. +class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoWaypoint : public QGeoCoordinateObject, public QQmlParserStatus +{ + Q_OBJECT + + Q_PROPERTY(double latitude READ latitude WRITE setLatitude STORED false) + Q_PROPERTY(double longitude READ longitude WRITE setLongitude STORED false) + Q_PROPERTY(double altitude READ altitude WRITE setAltitude STORED false) + Q_PROPERTY(bool isValid READ isValid STORED false) + + Q_PROPERTY(qreal bearing READ bearing WRITE setBearing NOTIFY bearingChanged) + Q_PROPERTY(QQmlListProperty<QObject> quickChildren READ declarativeChildren DESIGNABLE false) + Q_CLASSINFO("DefaultProperty", "quickChildren") + +public: + QDeclarativeGeoWaypoint(QObject *parent = 0); + virtual ~QDeclarativeGeoWaypoint(); + + bool operator==(const QDeclarativeGeoWaypoint &other) const; + + qreal latitude() const; + void setLatitude(qreal latitude); + + qreal longitude() const; + void setLongitude(qreal longitude); + + qreal altitude() const; + void setAltitude(qreal altitude); + + bool isValid() const; + + qreal bearing() const; + void setBearing(qreal bearing); + + template <typename T = QObject> + QList<T*> quickChildren() const + { + QList<T*> res; + for (auto kid : qAsConst(m_children)) { + auto val = qobject_cast<T*>(kid); + if (val) + res.push_back(val); + } + return res; + } + + QVariantMap metadata(); + +Q_SIGNALS: + void completed(); + void waypointDetailsChanged(); + void bearingChanged(); + void extraParametersChanged(); + +private Q_SLOTS: + void extraParameterChanged(); + +protected: + // From QQmlParserStatus + void classBegin() override {} + void componentComplete() override { m_complete = true; emit completed(); } + + // For quickChildren + static void append(QQmlListProperty<QObject> *p, QObject *v); + static int count(QQmlListProperty<QObject> *p); + static QObject *at(QQmlListProperty<QObject> *p, int idx); + static void clear(QQmlListProperty<QObject> *p); + QQmlListProperty<QObject> declarativeChildren(); + QList<QObject*> m_children; + + // other data members + bool m_metadataChanged = false; + bool m_complete = false; + + qreal m_bearing = Q_QNAN; + QVariantMap m_metadata; +}; + + + + class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRouteQuery : public QObject, public QQmlParserStatus { Q_OBJECT @@ -204,9 +289,11 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoRouteQuery : public QObject, publ Q_PROPERTY(RouteOptimizations routeOptimizations READ routeOptimizations WRITE setRouteOptimizations NOTIFY routeOptimizationsChanged) Q_PROPERTY(SegmentDetail segmentDetail READ segmentDetail WRITE setSegmentDetail NOTIFY segmentDetailChanged) Q_PROPERTY(ManeuverDetail maneuverDetail READ maneuverDetail WRITE setManeuverDetail NOTIFY maneuverDetailChanged) - Q_PROPERTY(QJSValue waypoints READ waypoints WRITE setWaypoints NOTIFY waypointsChanged) + Q_PROPERTY(QVariantList waypoints READ waypoints WRITE setWaypoints NOTIFY waypointsChanged) Q_PROPERTY(QJSValue excludedAreas READ excludedAreas WRITE setExcludedAreas NOTIFY excludedAreasChanged) Q_PROPERTY(QList<int> featureTypes READ featureTypes NOTIFY featureTypesChanged) + Q_PROPERTY(QQmlListProperty<QObject> quickChildren READ declarativeChildren DESIGNABLE false) + Q_CLASSINFO("DefaultProperty", "quickChildren") Q_INTERFACES(QQmlParserStatus) public: @@ -218,7 +305,7 @@ public: void classBegin() {} void componentComplete(); - QGeoRouteRequest routeRequest() const; + QGeoRouteRequest routeRequest(); enum TravelMode { CarTravel = QGeoRouteRequest::CarTravel, @@ -279,16 +366,18 @@ public: QList<int> featureTypes(); - QJSValue waypoints(); - void setWaypoints(const QJSValue &value); + QVariantList waypoints(); + Q_INVOKABLE QVariantList waypointObjects(); + void setWaypoints(const QVariantList &value); // READ functions for list properties QJSValue excludedAreas() const; void setExcludedAreas(const QJSValue &value); - Q_INVOKABLE void addWaypoint(const QGeoCoordinate &waypoint); - Q_INVOKABLE void removeWaypoint(const QGeoCoordinate &waypoint); + Q_INVOKABLE void addWaypoint(const QVariant &w); + Q_INVOKABLE void removeWaypoint(const QVariant &waypoint); Q_INVOKABLE void clearWaypoints(); + void flushWaypoints(QList<QDeclarativeGeoWaypoint *> &waypoints); Q_INVOKABLE void addExcludedArea(const QGeoRectangle &area); Q_INVOKABLE void removeExcludedArea(const QGeoRectangle &area); @@ -314,6 +403,18 @@ public: void setRouteOptimizations(RouteOptimizations optimization); RouteOptimizations routeOptimizations() const; + template <typename T = QObject> + QList<T*> quickChildren() const + { + QList<T*> res; + for (auto kid : qAsConst(m_children)) { + auto val = qobject_cast<T*>(kid); + if (val) + res.push_back(val); + } + return res; + } + Q_SIGNALS: void numberAlternativeRoutesChanged(); void travelModesChanged(); @@ -327,9 +428,21 @@ Q_SIGNALS: void segmentDetailChanged(); void queryDetailsChanged(); + void extraParametersChanged(); private Q_SLOTS: void excludedAreaCoordinateChanged(); + void extraParameterChanged(); + void waypointChanged(); + +protected: + static void append(QQmlListProperty<QObject> *p, QObject *v); + static int count(QQmlListProperty<QObject> *p); + static QObject *at(QQmlListProperty<QObject> *p, int idx); + static void clear(QQmlListProperty<QObject> *p); + + QQmlListProperty<QObject> declarativeChildren(); + QList<QObject*> m_children; private: Q_INVOKABLE void doCoordinateChanged(); @@ -337,9 +450,13 @@ private: QGeoRouteRequest request_; bool complete_; bool m_excludedAreaCoordinateChanged; - + bool m_extraParametersChanged = false; + bool m_waypointsChanged = false; + QList<QDeclarativeGeoWaypoint *> m_waypoints; }; QT_END_NAMESPACE +Q_DECLARE_METATYPE(QDeclarativeGeoWaypoint*) + #endif diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index 48f66423..7460a376 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp @@ -286,10 +286,10 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map) if (e.isMoveTo() || i == ppi.elementCount() - 1 || (qAbs(e.x - poly.front()[0]) < 0.1 && qAbs(e.y - poly.front()[1]) < 0.1)) { - Point p = { e.x, e.y }; + Point p = {{ e.x, e.y }}; poly.push_back( p ); } else if (e.isLineTo()) { - Point p = { e.x, e.y }; + Point p = {{ e.x, e.y }}; poly.push_back( p ); } else { qWarning("Unhandled element type in polygon painterpath"); @@ -374,6 +374,7 @@ void QDeclarativePolygonMapItem::setMap(QDeclarativeGeoMap *quickMap, QGeoMap *m This property holds the ordered list of coordinates which define the polygon. + Having less than 3 different coordinates in the path results in undefined behavior. \sa addCoordinate, removeCoordinate */ diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp index b1878f00..2f095ee0 100644 --- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp +++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp @@ -552,7 +552,7 @@ QQuickGeoMapGestureArea::~QQuickGeoMapGestureArea() \qmlproperty enumeration QtLocation::MapGestureArea::acceptedGestures This property holds the gestures that will be active. By default - the zoom, pan and flick gestures are enabled. + all gestures are enabled. \list \li MapGestureArea.NoGesture - Don't support any additional gestures (value: 0x0000). diff --git a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp index 4dfdd25d..92e298d3 100644 --- a/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp +++ b/src/location/declarativeplaces/qdeclarativesearchmodelbase.cpp @@ -45,6 +45,7 @@ #include <QtLocation/QPlaceSearchRequest> #include <QtLocation/QPlaceSearchReply> #include <QtPositioning/QGeoCircle> +#include <QtPositioning/QGeoPolygon> QT_BEGIN_NAMESPACE @@ -89,6 +90,8 @@ QVariant QDeclarativeSearchModelBase::searchArea() const return QVariant::fromValue(QGeoRectangle(s)); else if (s.type() == QGeoShape::CircleType) return QVariant::fromValue(QGeoCircle(s)); + else if (s.type() == QGeoShape::PolygonType) + return QVariant::fromValue(QGeoPolygon(s)); else return QVariant::fromValue(s); } diff --git a/src/location/doc/qtlocation.qdocconf b/src/location/doc/qtlocation.qdocconf index 58eeaef7..464e8e76 100644 --- a/src/location/doc/qtlocation.qdocconf +++ b/src/location/doc/qtlocation.qdocconf @@ -43,6 +43,8 @@ sourcedirs += .. \ examplesinstallpath = location +manifestmeta.highlighted.names = "QtLocation/Map Viewer (QML)" + exampledirs += ../../../examples/location \ snippets/ diff --git a/src/location/doc/snippets/cpp/cppqml.cpp b/src/location/doc/snippets/cpp/cppqml.cpp index 48a50071..43fcdf94 100644 --- a/src/location/doc/snippets/cpp/cppqml.cpp +++ b/src/location/doc/snippets/cpp/cppqml.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:BSD$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/cpp/main.cpp b/src/location/doc/snippets/cpp/main.cpp index 1cc1184b..4904db83 100644 --- a/src/location/doc/snippets/cpp/main.cpp +++ b/src/location/doc/snippets/cpp/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:BSD$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/declarative/content/Cell.qml b/src/location/doc/snippets/declarative/content/Cell.qml index 0391e0b6..7d7e07bc 100644 --- a/src/location/doc/snippets/declarative/content/Cell.qml +++ b/src/location/doc/snippets/declarative/content/Cell.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Mobility Components. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/declarative/declarative-location.qml b/src/location/doc/snippets/declarative/declarative-location.qml index 8eb18e2a..2cdb8fe4 100644 --- a/src/location/doc/snippets/declarative/declarative-location.qml +++ b/src/location/doc/snippets/declarative/declarative-location.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Mobility Components. ** ** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/declarative/maps.qml b/src/location/doc/snippets/declarative/maps.qml index 3378ee06..e5770c97 100644 --- a/src/location/doc/snippets/declarative/maps.qml +++ b/src/location/doc/snippets/declarative/maps.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/declarative/places.qml b/src/location/doc/snippets/declarative/places.qml index 7dab804c..ce6bda25 100644 --- a/src/location/doc/snippets/declarative/places.qml +++ b/src/location/doc/snippets/declarative/places.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/declarative/places_loader.qml b/src/location/doc/snippets/declarative/places_loader.qml index a52a4b04..8422ad5c 100644 --- a/src/location/doc/snippets/declarative/places_loader.qml +++ b/src/location/doc/snippets/declarative/places_loader.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/declarative/plugin.qml b/src/location/doc/snippets/declarative/plugin.qml index 44282102..8f4dacae 100644 --- a/src/location/doc/snippets/declarative/plugin.qml +++ b/src/location/doc/snippets/declarative/plugin.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/declarative/routing.qml b/src/location/doc/snippets/declarative/routing.qml index 643722bf..ae564704 100644 --- a/src/location/doc/snippets/declarative/routing.qml +++ b/src/location/doc/snippets/declarative/routing.qml @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/places/main.cpp b/src/location/doc/snippets/places/main.cpp index 8820fbc4..ab34a3cd 100644 --- a/src/location/doc/snippets/places/main.cpp +++ b/src/location/doc/snippets/places/main.cpp @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:BSD$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/snippets/places/requesthandler.h b/src/location/doc/snippets/places/requesthandler.h index 04b1b055..e5ee0d00 100644 --- a/src/location/doc/snippets/places/requesthandler.h +++ b/src/location/doc/snippets/places/requesthandler.h @@ -1,12 +1,22 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:BSD$ -** You may use this file under the terms of the BSD license as follows: +** 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 diff --git a/src/location/doc/src/cpp-qml.qdoc b/src/location/doc/src/cpp-qml.qdoc index f20e1479..b8a49fa5 100644 --- a/src/location/doc/src/cpp-qml.qdoc +++ b/src/location/doc/src/cpp-qml.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/maps.qdoc b/src/location/doc/src/maps.qdoc index 759394e2..d929b125 100644 --- a/src/location/doc/src/maps.qdoc +++ b/src/location/doc/src/maps.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/places.qdoc b/src/location/doc/src/places.qdoc index 72e31c9c..9c01fba7 100644 --- a/src/location/doc/src/places.qdoc +++ b/src/location/doc/src/places.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/plugins/itemsoverlay.qdoc b/src/location/doc/src/plugins/itemsoverlay.qdoc index 7a2d1dec..ddb4de99 100644 --- a/src/location/doc/src/plugins/itemsoverlay.qdoc +++ b/src/location/doc/src/plugins/itemsoverlay.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/plugins/mapbox.qdoc b/src/location/doc/src/plugins/mapbox.qdoc index 8f83ae55..3933b107 100644 --- a/src/location/doc/src/plugins/mapbox.qdoc +++ b/src/location/doc/src/plugins/mapbox.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -66,6 +66,10 @@ The following table lists optional parameters that can be passed to the Mapbox p \li Parameter \li Description \row + \li mapbox.enterprise + \li Boolean representing whether the access token comes from a + \l{https://www.mapbox.com/enterprise}{Mapbox Enterprise} account. +\row \li mapbox.mapping.map_id, mapbox.map_id (\b deprecated) \li \l{https://www.mapbox.com/help/define-map-id/}{ID} of the Mapbox map to show. An example ID is "examples.map-zr0njcqy". If this parameter is present, the specified map type will be used by default, unless another is selected. @@ -149,5 +153,19 @@ The following table lists optional parameters that can be passed to the Mapbox p \tt{OneNeighbourLayer} only prefetches the one layer closest to the current zoom level. Finally, \tt{NoPrefetching} allows to disable the prefetching, so only tiles that are visible will be fetched. Note that, depending on the active map type, this hint might be ignored. +\row + \li mapbox.routing.use_mapbox_text_instructions + \li Whether to use the instruction text that came with the response from the server (true) or the + text generated by the plugin. The default value is true. + Note that if instructions in a language that is not directly supported by Mapbox are needed (see + \l{https://www.mapbox.com/api-documentation/#instructions-languages}{here} for the supported languages), + it is possible to use the \l{Qt Linguist} to translate QtLocation to the desired language, and set this parameter to + false in order to use the translated built-in instructions. \endtable + +\section1 Extra routing attributes + +When using this plugin, the RouteManeuver objects in the returned route may contain additional extended attributes (see \l RouteManeuver::extendedAttributes), +where available. +These attributes are described in detail in the official \l{https://www.mapbox.com/api-documentation/#stepmaneuver-object}{Mapbox direction API documentation}. */ diff --git a/src/location/doc/src/plugins/mapboxgl.qdoc b/src/location/doc/src/plugins/mapboxgl.qdoc index 4084e4c6..8ad6a9c2 100644 --- a/src/location/doc/src/plugins/mapboxgl.qdoc +++ b/src/location/doc/src/plugins/mapboxgl.qdoc @@ -3,7 +3,7 @@ ** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2017 Mapbox, Inc. ** Copyright (C) 2014 Canonical Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -13,8 +13,8 @@ ** 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. +** 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 @@ -22,7 +22,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -60,7 +60,7 @@ and tiles hosted by Mapbox. To create a Mapbox account visit \l{https://www.mapb Qt Location Mapbox GL Plugin has the following support for platforms: \list - \li Microsoft Windows (win32) - Supported, requires MinGW 5.0+ and ANGLE as OpenGL backend + \li Microsoft Windows (win32) - Supported, requires MinGW 5.0+ \li Linux X11 - Supported, requires GCC 4.9+ \li macOS - Supported \li Android - Supported @@ -109,6 +109,12 @@ The following table lists optional parameters that can be passed to the Mapbox p but the offline database must be populated using the \l {https://github.com/mapbox/mapbox-gl-native/blob/master/bin/offline.cpp} {offline tool}. The offline database will work alongside with the ambient cache in the same file. Make sure to comply with Mapbox Terms of Service before creating an offline database. + + \b {Note:} The map tile cache file name must be "mapboxgl.db". When using the offline tool, the default + output is "offline.db". For using the generated output from the offline tool, you must move that to the + proper directory, and rename it as "mapboxgl.db". The offline tool also provides the "--output" + parameter for specifying the name of the generated output. + \row \li mapboxgl.mapping.cache.memory \li Whether or not the cache should be in-memory only. Valid values are \b true and \b false. The default diff --git a/src/location/doc/src/plugins/nokia.qdoc b/src/location/doc/src/plugins/nokia.qdoc index 30fd43f1..79bd728f 100644 --- a/src/location/doc/src/plugins/nokia.qdoc +++ b/src/location/doc/src/plugins/nokia.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc index c65c4abb..dc0bb256 100644 --- a/src/location/doc/src/plugins/osm.qdoc +++ b/src/location/doc/src/plugins/osm.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/plugins/places-backend.qdoc b/src/location/doc/src/plugins/places-backend.qdoc index b6de60e3..9187531e 100644 --- a/src/location/doc/src/plugins/places-backend.qdoc +++ b/src/location/doc/src/plugins/places-backend.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/qml-maps.qdoc b/src/location/doc/src/qml-maps.qdoc index 72cf6ee9..87dd2412 100644 --- a/src/location/doc/src/qml-maps.qdoc +++ b/src/location/doc/src/qml-maps.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/qtlocation-changes.qdoc b/src/location/doc/src/qtlocation-changes.qdoc index 1330412d..458c9e99 100644 --- a/src/location/doc/src/qtlocation-changes.qdoc +++ b/src/location/doc/src/qtlocation-changes.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/qtlocation-cpp.qdoc b/src/location/doc/src/qtlocation-cpp.qdoc index 82ac766e..c2c29b34 100644 --- a/src/location/doc/src/qtlocation-cpp.qdoc +++ b/src/location/doc/src/qtlocation-cpp.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/qtlocation-examples.qdoc b/src/location/doc/src/qtlocation-examples.qdoc index 052db15b..02938c0e 100644 --- a/src/location/doc/src/qtlocation-examples.qdoc +++ b/src/location/doc/src/qtlocation-examples.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/qtlocation-geoservices.qdoc b/src/location/doc/src/qtlocation-geoservices.qdoc index 008f98a8..cc67e231 100644 --- a/src/location/doc/src/qtlocation-geoservices.qdoc +++ b/src/location/doc/src/qtlocation-geoservices.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/qtlocation-qml.qdoc b/src/location/doc/src/qtlocation-qml.qdoc index 37d21dce..c0879d2d 100644 --- a/src/location/doc/src/qtlocation-qml.qdoc +++ b/src/location/doc/src/qtlocation-qml.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/doc/src/qtlocation.qdoc b/src/location/doc/src/qtlocation.qdoc index 5a3fb937..96564ecb 100644 --- a/src/location/doc/src/qtlocation.qdoc +++ b/src/location/doc/src/qtlocation.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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. +** 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 @@ -20,7 +20,7 @@ ** 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: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp index d40ad825..df89c889 100644 --- a/src/location/maps/qgeofiletilecache.cpp +++ b/src/location/maps/qgeofiletilecache.cpp @@ -88,6 +88,7 @@ QGeoCachedTileDisk::~QGeoCachedTileDisk() QGeoFileTileCache::QGeoFileTileCache(const QString &directory, QObject *parent) : QAbstractGeoTileCache(parent), directory_(directory), minTextureUsage_(0), extraTextureUsage_(0) ,costStrategyDisk_(ByteSize), costStrategyMemory_(ByteSize), costStrategyTexture_(ByteSize) + ,isDiskCostSet_(false), isMemoryCostSet_(false), isTextureCostSet_(false) { } @@ -120,21 +121,21 @@ void QGeoFileTileCache::init() QDir::root().mkpath(directory_); // default values - if (!diskCache_.maxCost()) { // If setMaxDiskUsage has not been called yet + if (!isDiskCostSet_) { // If setMaxDiskUsage has not been called yet if (costStrategyDisk_ == ByteSize) setMaxDiskUsage(50 * 1024 * 1024); else setMaxDiskUsage(1000); } - if (!memoryCache_.maxCost()) { // If setMaxMemoryUsage has not been called yet + if (!isMemoryCostSet_) { // If setMaxMemoryUsage has not been called yet if (costStrategyMemory_ == ByteSize) setMaxMemoryUsage(3 * 1024 * 1024); else setMaxMemoryUsage(100); } - if (!textureCache_.maxCost()) { // If setExtraTextureUsage has not been called yet + if (!isTextureCostSet_) { // If setExtraTextureUsage has not been called yet if (costStrategyTexture_ == ByteSize) setExtraTextureUsage(6 * 1024 * 1024); else @@ -240,6 +241,7 @@ void QGeoFileTileCache::printStats() void QGeoFileTileCache::setMaxDiskUsage(int diskUsage) { diskCache_.setMaxCost(diskUsage); + isDiskCostSet_ = true; } int QGeoFileTileCache::maxDiskUsage() const @@ -255,6 +257,7 @@ int QGeoFileTileCache::diskUsage() const void QGeoFileTileCache::setMaxMemoryUsage(int memoryUsage) { memoryCache_.setMaxCost(memoryUsage); + isMemoryCostSet_ = true; } int QGeoFileTileCache::maxMemoryUsage() const @@ -271,6 +274,7 @@ void QGeoFileTileCache::setExtraTextureUsage(int textureUsage) { extraTextureUsage_ = textureUsage; textureCache_.setMaxCost(minTextureUsage_ + extraTextureUsage_); + isTextureCostSet_ = true; } void QGeoFileTileCache::setMinTextureUsage(int textureUsage) @@ -384,12 +388,7 @@ void QGeoFileTileCache::insert(const QGeoTileSpec &spec, if (areas & QAbstractGeoTileCache::DiskCache) { QString filename = tileSpecToFilename(spec, format, directory_); - QFile file(filename); - file.open(QIODevice::WriteOnly); - file.write(bytes); - file.close(); - - addToDiskCache(spec, filename); + addToDiskCache(spec, filename, bytes); } if (areas & QAbstractGeoTileCache::MemoryCache) { @@ -491,6 +490,27 @@ QSharedPointer<QGeoCachedTileDisk> QGeoFileTileCache::addToDiskCache(const QGeoT return td; } +bool QGeoFileTileCache::addToDiskCache(const QGeoTileSpec &spec, const QString &filename, const QByteArray &bytes) +{ + QSharedPointer<QGeoCachedTileDisk> td(new QGeoCachedTileDisk); + td->spec = spec; + td->filename = filename; + td->cache = this; + + int cost = 1; + if (costStrategyDisk_ == ByteSize) + cost = bytes.size(); + + if (diskCache_.insert(spec, td, cost)) { + QFile file(filename); + file.open(QIODevice::WriteOnly); + file.write(bytes); + file.close(); + return true; + } + return false; +} + void QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format) { if (isTileBogus(bytes)) diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h index e319e2a2..1712a9e3 100644 --- a/src/location/maps/qgeofiletilecache_p.h +++ b/src/location/maps/qgeofiletilecache_p.h @@ -147,6 +147,7 @@ protected: QString directory() const; QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename); + bool addToDiskCache(const QGeoTileSpec &spec, const QString &filename, const QByteArray &bytes); void addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format); QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image); QSharedPointer<QGeoTileTexture> getFromMemory(const QGeoTileSpec &spec); @@ -167,6 +168,9 @@ protected: CostStrategy costStrategyDisk_; CostStrategy costStrategyMemory_; CostStrategy costStrategyTexture_; + bool isDiskCostSet_; + bool isMemoryCostSet_; + bool isTextureCostSet_; }; QT_END_NAMESPACE diff --git a/src/location/maps/qgeomaneuver.cpp b/src/location/maps/qgeomaneuver.cpp index 9d6a4bf0..fb019130 100644 --- a/src/location/maps/qgeomaneuver.cpp +++ b/src/location/maps/qgeomaneuver.cpp @@ -293,6 +293,26 @@ QGeoCoordinate QGeoManeuver::waypoint() const QGeoManeuver::QGeoManeuver(const QSharedDataPointer<QGeoManeuverPrivate> &dd) : d_ptr(dd) {} +/*! + Sets the extended attributes associated with this maneuver. + + \since QtLocation 5.11 +*/ +void QGeoManeuver::setExtendedAttributes(const QVariantMap &extendedAttributes) +{ + d_ptr->setValid(true); + d_ptr->setExtendedAttributes(extendedAttributes); +} + +/*! + Returns the extended attributes associated with this maneuver. + + \since QtLocation 5.11 +*/ +QVariantMap QGeoManeuver::extendedAttributes() const +{ + return d_ptr->extendedAttributes(); +} /******************************************************************************* *******************************************************************************/ @@ -409,6 +429,16 @@ void QGeoManeuverPrivate::setWaypoint(const QGeoCoordinate &waypoint) Q_UNUSED(waypoint) } +QVariantMap QGeoManeuverPrivate::extendedAttributes() const +{ + return QVariantMap(); +} + +void QGeoManeuverPrivate::setExtendedAttributes(const QVariantMap &extendedAttributes) +{ + Q_UNUSED(extendedAttributes) +} + /******************************************************************************* @@ -517,4 +547,14 @@ void QGeoManeuverPrivateDefault::setWaypoint(const QGeoCoordinate &waypoint) m_waypoint = waypoint; } +QVariantMap QGeoManeuverPrivateDefault::extendedAttributes() const +{ + return m_extendedAttributes; +} + +void QGeoManeuverPrivateDefault::setExtendedAttributes(const QVariantMap &extendedAttributes) +{ + m_extendedAttributes = extendedAttributes; +} + QT_END_NAMESPACE diff --git a/src/location/maps/qgeomaneuver.h b/src/location/maps/qgeomaneuver.h index 1e4bff24..76c5421e 100644 --- a/src/location/maps/qgeomaneuver.h +++ b/src/location/maps/qgeomaneuver.h @@ -39,6 +39,7 @@ #include <QtCore/qshareddata.h> #include <QtLocation/qlocationglobal.h> +#include <QVariantMap> QT_BEGIN_NAMESPACE @@ -95,9 +96,13 @@ public: void setWaypoint(const QGeoCoordinate &coordinate); QGeoCoordinate waypoint() const; + void setExtendedAttributes(const QVariantMap &extendedAttributes); + QVariantMap extendedAttributes() const; + protected: QGeoManeuver(const QSharedDataPointer<QGeoManeuverPrivate> &dd); +private: QSharedDataPointer<QGeoManeuverPrivate> d_ptr; }; diff --git a/src/location/maps/qgeomaneuver_p.h b/src/location/maps/qgeomaneuver_p.h index e17bf880..8f2e7eca 100644 --- a/src/location/maps/qgeomaneuver_p.h +++ b/src/location/maps/qgeomaneuver_p.h @@ -91,6 +91,9 @@ public: virtual QGeoCoordinate waypoint() const; virtual void setWaypoint(const QGeoCoordinate &waypoint); + virtual QVariantMap extendedAttributes() const; + virtual void setExtendedAttributes(const QVariantMap &extendedAttributes); + protected: virtual bool equals(const QGeoManeuverPrivate &other) const; }; @@ -127,6 +130,9 @@ public: virtual QGeoCoordinate waypoint() const override; virtual void setWaypoint(const QGeoCoordinate &waypoint) override; + virtual QVariantMap extendedAttributes() const override; + virtual void setExtendedAttributes(const QVariantMap &extendedAttributes) override; + bool m_valid; QString m_id; QGeoCoordinate m_position; @@ -135,6 +141,7 @@ public: int m_timeToNextInstruction; qreal m_distanceToNextInstruction; QGeoCoordinate m_waypoint; + QVariantMap m_extendedAttributes; }; QT_END_NAMESPACE diff --git a/src/location/maps/qgeomapparameter.cpp b/src/location/maps/qgeomapparameter.cpp index b8f9561f..b1d6f060 100644 --- a/src/location/maps/qgeomapparameter.cpp +++ b/src/location/maps/qgeomapparameter.cpp @@ -37,6 +37,8 @@ #include "qgeomapparameter_p.h" #include <QtCore/QVariant> +#include <QDebug> +#include <QMetaProperty> QT_BEGIN_NAMESPACE @@ -45,10 +47,25 @@ QGeoMapParameter::QGeoMapParameter(QObject *parent) : QObject(parent) } +QGeoMapParameter::QGeoMapParameter(const QList<QPair<QLatin1String, QVariant> > &properties, QObject *parent) : QObject(parent) +{ + for (const auto &p: properties) { + if (p.first == QLatin1String("type")) + setType(p.second.toString()); + else + updateProperty(p.first.data(), p.second); + } +} + QGeoMapParameter::~QGeoMapParameter() { } +bool QGeoMapParameter::operator==(const QGeoMapParameter &other) const +{ + return (other.toVariantMap() == toVariantMap()); +} + QString QGeoMapParameter::type() const { return m_type; @@ -70,5 +87,16 @@ void QGeoMapParameter::updateProperty(const char *propertyName, QVariant value) emit propertyUpdated(this, propertyName); } +QVariantMap QGeoMapParameter::toVariantMap() const +{ + QVariantMap res; + const QMetaObject *metaObj = metaObject(); + for (int i = 2; i < metaObj->propertyCount(); ++i) { // 0 is objectName, 1 is type, we want to skip both of them here. + const char *propName = metaObj->property(i).name(); + res[QLatin1String(propName)] = property(propName); + } + return res; +} + QT_END_NAMESPACE diff --git a/src/location/maps/qgeomapparameter_p.h b/src/location/maps/qgeomapparameter_p.h index bc39c14a..413b420e 100644 --- a/src/location/maps/qgeomapparameter_p.h +++ b/src/location/maps/qgeomapparameter_p.h @@ -52,6 +52,7 @@ #include <QObject> #include <QString> #include <QtLocation/private/qlocationglobal_p.h> +#include <QVariantMap> QT_BEGIN_NAMESPACE @@ -62,13 +63,18 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoMapParameter : public QObject Q_PROPERTY(QString type READ type WRITE setType) public: explicit QGeoMapParameter(QObject *parent = 0); + QGeoMapParameter(const QList<QPair<QLatin1String, QVariant>> &properties, QObject *parent = 0); virtual ~QGeoMapParameter(); - QString type() const; - void setType(const QString &type); + bool operator==(const QGeoMapParameter &other) const; + + virtual QString type() const; + virtual void setType(const QString &type); void updateProperty(const char *propertyName, QVariant value); + QVariantMap toVariantMap() const; + Q_SIGNALS: void propertyUpdated(QGeoMapParameter *param, const char *propertyName); diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp index 218d806b..1df174fb 100644 --- a/src/location/maps/qgeoprojection.cpp +++ b/src/location/maps/qgeoprojection.cpp @@ -236,6 +236,9 @@ QDoubleVector2D QGeoProjectionWebMercator::itemPositionToWrappedMapProjection(co /* Default implementations */ QGeoCoordinate QGeoProjectionWebMercator::itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const { + if (qIsNaN(pos.x()) || qIsNaN(pos.y())) + return QGeoCoordinate(); + if (clipToViewport) { int w = m_viewportWidth; int h = m_viewportHeight; @@ -253,7 +256,14 @@ QGeoCoordinate QGeoProjectionWebMercator::itemPositionToCoordinate(const QDouble QDoubleVector2D QGeoProjectionWebMercator::coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const { - QDoubleVector2D pos = wrappedMapProjectionToItemPosition(wrapMapProjection(geoToMapProjection(coordinate))); + if (!coordinate.isValid()) + return QDoubleVector2D(qQNaN(), qQNaN()); + + QDoubleVector2D wrappedProjection = wrapMapProjection(geoToMapProjection(coordinate)); + if (!isProjectable(wrappedProjection)) + return QDoubleVector2D(qQNaN(), qQNaN()); + + QDoubleVector2D pos = wrappedMapProjectionToItemPosition(wrappedProjection); if (clipToViewport) { int w = m_viewportWidth; @@ -350,10 +360,10 @@ QDoubleVector2D QGeoProjectionWebMercator::viewportToWrappedMapProjection(const pos *= QDoubleVector2D(m_halfWidth, m_halfHeight); QDoubleVector3D p = m_centerNearPlane; - p -= m_up * pos.y(); - p -= m_side * pos.x(); + p += m_up * pos.y(); + p += m_side * pos.x(); - QDoubleVector3D ray = p - m_eye; + QDoubleVector3D ray = m_eye - p; ray.normalize(); return (xyPlane.lineIntersection(m_eye, ray, s) / m_sideLength).toVector2D(); @@ -472,7 +482,7 @@ void QGeoProjectionWebMercator::setupCamera() m_quickItemTransformation = m_transformation; m_transformation.scale(m_sideLength, m_sideLength, 1.0); - m_centerNearPlane = m_eye + m_viewNormalized; + m_centerNearPlane = m_eye - m_viewNormalized; m_centerNearPlaneMercator = m_eyeMercator - m_viewNormalized * m_nearPlaneMercator; // The method does not support tilting angles >= 90.0 or < 0. diff --git a/src/location/maps/qgeorouteparserosrmv5.cpp b/src/location/maps/qgeorouteparserosrmv5.cpp index 75daefda..e47901b7 100644 --- a/src/location/maps/qgeorouteparserosrmv5.cpp +++ b/src/location/maps/qgeorouteparserosrmv5.cpp @@ -782,7 +782,7 @@ static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject else if (modifier == QLatin1String("slight right")) return QGeoManeuver::DirectionLightRight; else if (modifier == QLatin1String("uturn")) - return QGeoManeuver::DirectionUTurnRight; + return QGeoManeuver::DirectionUTurnLeft; // This should rather be country-specific. In UK, f.ex. one should rather UTurn Right else if (modifier == QLatin1String("left")) return QGeoManeuver::DirectionLeft; else if (modifier == QLatin1String("sharp left")) @@ -793,8 +793,10 @@ static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject return QGeoManeuver::NoDirection; } -static QGeoRouteSegment parseStep(const QJsonObject &step) { - // OSRM Instructions documentation: https://github.com/Project-OSRM/osrm-text-instructions/blob/master/instructions.json +static QGeoRouteSegment parseStep(const QJsonObject &step, bool useServerText) { + // OSRM Instructions documentation: https://github.com/Project-OSRM/osrm-text-instructions + // This goes on top of OSRM: https://github.com/Project-OSRM/osrm-backend/blob/master/docs/http.md + // Mapbox however, includes this in the reply, under "instruction". QGeoRouteSegment segment; if (!step.value(QLatin1String("maneuver")).isObject()) return segment; @@ -808,6 +810,10 @@ static QGeoRouteSegment parseStep(const QJsonObject &step) { if (!maneuver.value(QLatin1String("location")).isArray()) return segment; + QString instruction_text; + if (maneuver.value(QLatin1String("instruction")).isString()) + instruction_text = maneuver.value(QLatin1String("instruction")).toString(); + double time = step.value(QLatin1String("duration")).toDouble(); double distance = step.value(QLatin1String("distance")).toDouble(); @@ -825,10 +831,18 @@ static QGeoRouteSegment parseStep(const QJsonObject &step) { geoManeuver.setDirection(instructionDirection(maneuver)); geoManeuver.setDistanceToNextInstruction(distance); geoManeuver.setTimeToNextInstruction(time); - geoManeuver.setInstructionText(instructionText(step, maneuver, geoManeuver.direction())); + geoManeuver.setInstructionText((useServerText && !instruction_text.isEmpty()) ? instruction_text : instructionText(step, maneuver, geoManeuver.direction())); geoManeuver.setPosition(coord); geoManeuver.setWaypoint(coord); + QVariantMap extraAttributes; + static const QStringList extras { "bearing_before", "bearing_after", "instruction", "type", "modifier" }; + for (const QString &e: extras) { + if (maneuver.find(e) != maneuver.end()) + extraAttributes.insert(e, maneuver.value(e).toVariant()); + } + geoManeuver.setExtendedAttributes(extraAttributes); + segment.setDistance(distance); segment.setPath(path); segment.setTravelTime(time); @@ -845,6 +859,9 @@ public: QGeoRouteReply::Error parseReply(QList<QGeoRoute> &routes, QString &errorString, const QByteArray &reply) const Q_DECL_OVERRIDE; QUrl requestUrl(const QGeoRouteRequest &request, const QString &prefix) const Q_DECL_OVERRIDE; + + bool m_useServerText = false; + QString m_accessToken; }; QGeoRouteParserOsrmV5Private::QGeoRouteParserOsrmV5Private() : QGeoRouteParserPrivate() @@ -906,7 +923,7 @@ QGeoRouteReply::Error QGeoRouteParserOsrmV5Private::parseReply(QList<QGeoRoute> error = true; break; } - QGeoRouteSegment segment = parseStep(s.toObject()); + QGeoRouteSegment segment = parseStep(s.toObject(), m_useServerText); if (segment.isValid()) { segments.append(segment); } else { @@ -950,10 +967,23 @@ QUrl QGeoRouteParserOsrmV5Private::requestUrl(const QGeoRouteRequest &request, c { QString routingUrl = prefix; int notFirst = 0; - foreach (const QGeoCoordinate &c, request.waypoints()) { - if (notFirst) + QString bearings; + const QList<QVariantMap> metadata = request.waypointsMetadata(); + const QList<QGeoCoordinate> waypoints = request.waypoints(); + for (int i = 0; i < waypoints.size(); i++) { + const QGeoCoordinate &c = waypoints.at(i); + if (notFirst) { routingUrl.append(QLatin1Char(';')); + bearings.append(QLatin1Char(';')); + } routingUrl.append(QString::number(c.longitude())).append(QLatin1Char(',')).append(QString::number(c.latitude())); + if (metadata.size() > i) { + const QVariantMap &meta = metadata.at(i); + if (meta.contains(QStringLiteral("bearing"))) { + qreal bearing = meta.value(QStringLiteral("bearing")).toDouble(); + bearings.append(QString::number(int(bearing))).append(QLatin1Char(',')).append(QStringLiteral("90")); // 90 is the angle of maneuver allowed. + } + } ++notFirst; } @@ -963,16 +993,27 @@ QUrl QGeoRouteParserOsrmV5Private::requestUrl(const QGeoRouteRequest &request, c query.addQueryItem(QStringLiteral("steps"), QStringLiteral("true")); query.addQueryItem(QStringLiteral("geometries"), QStringLiteral("polyline")); query.addQueryItem(QStringLiteral("alternatives"), QStringLiteral("true")); + query.addQueryItem(QStringLiteral("bearings"), bearings); + if (!m_accessToken.isEmpty()) + query.addQueryItem(QStringLiteral("access_token"), m_accessToken); url.setQuery(query); return url; } -QGeoRouteParserOsrmV5::QGeoRouteParserOsrmV5(QObject *parent) : QGeoRouteParser(*new QGeoRouteParserOsrmV5Private(), parent) +QGeoRouteParserOsrmV5::QGeoRouteParserOsrmV5(QObject *parent, bool useServerText) : QGeoRouteParser(*new QGeoRouteParserOsrmV5Private(), parent) { + Q_D(QGeoRouteParserOsrmV5); + d->m_useServerText = useServerText; } QGeoRouteParserOsrmV5::~QGeoRouteParserOsrmV5() { } +void QGeoRouteParserOsrmV5::setAccessToken(const QString &token) +{ + Q_D(QGeoRouteParserOsrmV5); + d->m_accessToken = token; +} + QT_END_NAMESPACE diff --git a/src/location/maps/qgeorouteparserosrmv5_p.h b/src/location/maps/qgeorouteparserosrmv5_p.h index d2c59165..c6ad0367 100644 --- a/src/location/maps/qgeorouteparserosrmv5_p.h +++ b/src/location/maps/qgeorouteparserosrmv5_p.h @@ -60,9 +60,11 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoRouteParserOsrmV5 : public QGeoRouteParser Q_DECLARE_PRIVATE(QGeoRouteParserOsrmV5) public: - QGeoRouteParserOsrmV5(QObject *parent = Q_NULLPTR); + QGeoRouteParserOsrmV5(QObject *parent = Q_NULLPTR, bool useServerText = false); virtual ~QGeoRouteParserOsrmV5(); + void setAccessToken(const QString &token); + private: Q_DISABLE_COPY(QGeoRouteParserOsrmV5) }; diff --git a/src/location/maps/qgeorouterequest.cpp b/src/location/maps/qgeorouterequest.cpp index a1b32d85..ab0a3109 100644 --- a/src/location/maps/qgeorouterequest.cpp +++ b/src/location/maps/qgeorouterequest.cpp @@ -296,6 +296,27 @@ QList<QGeoCoordinate> QGeoRouteRequest::waypoints() const } /*! + Sets \a waypoint metadata as the metadata for the waypoints set in this request. + The metadata are intended as one QVariantMap per waypoint, given in the same order as + the waypoints. + + The content of the QVariantMap is somehow backend-specific, but properties that can be specified using + \l Waypoint elements in QML can be assumed to be named and to work the same way across plugins, where supported. +*/ +void QGeoRouteRequest::setWaypointsMetadata(const QList<QVariantMap> &waypointMetadata) +{ + d_ptr->waypointMetadata = waypointMetadata; +} + +/*! + Returns the metadata for the waypoints in this request. +*/ +QList<QVariantMap> QGeoRouteRequest::waypointsMetadata() const +{ + return d_ptr->waypointMetadata; +} + +/*! Sets \a areas as excluded areas that the route must not cross. */ void QGeoRouteRequest::setExcludeAreas(const QList<QGeoRectangle> &areas) @@ -446,6 +467,27 @@ QGeoRouteRequest::ManeuverDetail QGeoRouteRequest::maneuverDetail() const return d_ptr->maneuverDetail; } +/*! + Sets the extra parameters for the route request. + The format of the extra parameters is plugin specific, and documented per plugin. + + \since 5.11 +*/ +void QGeoRouteRequest::setExtraParameters(const QMap<QString, QVariantMap> &extraParameters) +{ + d_ptr->extraParameters = extraParameters; +} + +/*! + Returns the extra parameters set for this route request. + + \since 5.11 +*/ +QMap<QString, QVariantMap> QGeoRouteRequest::extraParameters() const +{ + return d_ptr->extraParameters; +} + /******************************************************************************* *******************************************************************************/ @@ -460,26 +502,30 @@ QGeoRouteRequestPrivate::QGeoRouteRequestPrivate() QGeoRouteRequestPrivate::QGeoRouteRequestPrivate(const QGeoRouteRequestPrivate &other) : QSharedData(other), waypoints(other.waypoints), + waypointMetadata(other.waypointMetadata), excludeAreas(other.excludeAreas), numberAlternativeRoutes(other.numberAlternativeRoutes), travelModes(other.travelModes), featureWeights(other.featureWeights), routeOptimization(other.routeOptimization), segmentDetail(other.segmentDetail), - maneuverDetail(other.maneuverDetail) {} + maneuverDetail(other.maneuverDetail), + extraParameters(other.extraParameters) {} QGeoRouteRequestPrivate::~QGeoRouteRequestPrivate() {} bool QGeoRouteRequestPrivate::operator ==(const QGeoRouteRequestPrivate &other) const { return ((waypoints == other.waypoints) + && (waypointMetadata == other.waypointMetadata) && (excludeAreas == other.excludeAreas) && (numberAlternativeRoutes == other.numberAlternativeRoutes) && (travelModes == other.travelModes) && (featureWeights == other.featureWeights) && (routeOptimization == other.routeOptimization) && (segmentDetail == other.segmentDetail) - && (maneuverDetail == other.maneuverDetail)); + && (maneuverDetail == other.maneuverDetail) + && (extraParameters == other.extraParameters)); } QT_END_NAMESPACE diff --git a/src/location/maps/qgeorouterequest.h b/src/location/maps/qgeorouterequest.h index cf89d13d..2c34479b 100644 --- a/src/location/maps/qgeorouterequest.h +++ b/src/location/maps/qgeorouterequest.h @@ -119,6 +119,9 @@ public: void setWaypoints(const QList<QGeoCoordinate> &waypoints); QList<QGeoCoordinate> waypoints() const; + void setWaypointsMetadata(const QList<QVariantMap> &waypointMetadata); + QList<QVariantMap> waypointsMetadata() const; + void setExcludeAreas(const QList<QGeoRectangle> &areas); QList<QGeoRectangle> excludeAreas() const; @@ -146,6 +149,9 @@ public: void setManeuverDetail(ManeuverDetail maneuverDetail); ManeuverDetail maneuverDetail() const; + void setExtraParameters(const QMap<QString, QVariantMap> &extraParameters); + QMap<QString, QVariantMap> extraParameters() const; + private: QExplicitlySharedDataPointer<QGeoRouteRequestPrivate> d_ptr; }; diff --git a/src/location/maps/qgeorouterequest_p.h b/src/location/maps/qgeorouterequest_p.h index ea0b1428..7b3a8499 100644 --- a/src/location/maps/qgeorouterequest_p.h +++ b/src/location/maps/qgeorouterequest_p.h @@ -54,6 +54,7 @@ #include <QSharedData> #include <QDateTime> #include <QMap> +#include <QVariantMap> QT_BEGIN_NAMESPACE @@ -67,6 +68,7 @@ public: bool operator ==(const QGeoRouteRequestPrivate &other) const; QList<QGeoCoordinate> waypoints; + QList<QVariantMap> waypointMetadata; QList<QGeoRectangle> excludeAreas; int numberAlternativeRoutes; QGeoRouteRequest::TravelModes travelModes; @@ -75,6 +77,7 @@ public: QGeoRouteRequest::RouteOptimizations routeOptimization; QGeoRouteRequest::SegmentDetail segmentDetail; QGeoRouteRequest::ManeuverDetail maneuverDetail; + QMap<QString, QVariantMap> extraParameters; }; QT_END_NAMESPACE |