diff options
Diffstat (limited to 'src/location')
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeomapitemview.cpp | 3 | ||||
-rw-r--r-- | src/location/declarativemaps/qdeclarativepolygonmapitem.cpp | 13 | ||||
-rw-r--r-- | src/location/declarativemaps/qdeclarativepolygonmapitem_p.h | 1 | ||||
-rw-r--r-- | src/location/declarativemaps/qquickgeomapgesturearea.cpp | 1 | ||||
-rw-r--r-- | src/location/maps/qgeorouteparser.cpp | 16 | ||||
-rw-r--r-- | src/location/maps/qgeorouteparser_p.h | 15 | ||||
-rw-r--r-- | src/location/maps/qgeorouteparser_p_p.h | 2 | ||||
-rw-r--r-- | src/location/maps/qgeorouteparserosrmv4.cpp | 21 | ||||
-rw-r--r-- | src/location/maps/qgeorouteparserosrmv5.cpp | 16 |
9 files changed, 62 insertions, 26 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp index 41ab3453..d404fd47 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp @@ -175,6 +175,9 @@ void QDeclarativeGeoMapItemView::createdItem(int index, QObject */*object*/) void QDeclarativeGeoMapItemView::modelUpdated(const QQmlChangeSet &changeSet, bool reset) { + if (!m_map) // everything will be done in instantiateAllItems. Removal is done by declarativegeomap. + return; + // move changes are expressed as one remove + one insert, with the same moveId. // For simplicity, they will be treated as remove + insert. // Changes will be also ignored, as they represent only data changes, not layout changes diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index b692bc76..f4cdc6bf 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp @@ -320,18 +320,9 @@ QDeclarativePolygonMapItem::QDeclarativePolygonMapItem(QQuickItem *parent) { setFlag(ItemHasContents, true); QObject::connect(&border_, SIGNAL(colorChanged(QColor)), - this, SLOT(handleBorderUpdated())); + this, SLOT(markSourceDirtyAndUpdate())); QObject::connect(&border_, SIGNAL(widthChanged(qreal)), - this, SLOT(handleBorderUpdated())); -} - -/*! - \internal -*/ -void QDeclarativePolygonMapItem::handleBorderUpdated() -{ - borderGeometry_.markSourceDirty(); - polishAndUpdate(); + this, SLOT(markSourceDirtyAndUpdate())); } QDeclarativePolygonMapItem::~QDeclarativePolygonMapItem() diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h index a68b6315..87d72307 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem_p.h @@ -120,7 +120,6 @@ protected: protected Q_SLOTS: void markSourceDirtyAndUpdate(); - void handleBorderUpdated(); virtual void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override; private: diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp index b15dbc4d..88a766f5 100644 --- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp +++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp @@ -1087,6 +1087,7 @@ void QQuickGeoMapGestureArea::update() m_allPoints << m_touchPoints; if (m_allPoints.isEmpty() && !m_mousePoint.isNull()) m_allPoints << *m_mousePoint.data(); + std::sort(m_allPoints.begin(), m_allPoints.end(), [](const QTouchEvent::TouchPoint &tp1, const QTouchEvent::TouchPoint &tp2) { return tp1.id() < tp2.id(); }); touchPointStateMachine(); diff --git a/src/location/maps/qgeorouteparser.cpp b/src/location/maps/qgeorouteparser.cpp index 646902e0..51b839dd 100644 --- a/src/location/maps/qgeorouteparser.cpp +++ b/src/location/maps/qgeorouteparser.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE Private class implementations */ -QGeoRouteParserPrivate::QGeoRouteParserPrivate() : QObjectPrivate() +QGeoRouteParserPrivate::QGeoRouteParserPrivate() : QObjectPrivate(), trafficSide(QGeoRouteParser::RightHandTraffic) { } @@ -85,6 +85,20 @@ QUrl QGeoRouteParser::requestUrl(const QGeoRouteRequest &request, const QString return d->requestUrl(request, prefix); } +QGeoRouteParser::TrafficSide QGeoRouteParser::trafficSide() const +{ + Q_D(const QGeoRouteParser); + return d->trafficSide; +} + +void QGeoRouteParser::setTrafficSide(QGeoRouteParser::TrafficSide trafficSide) +{ + Q_D(QGeoRouteParser); + if (d->trafficSide == trafficSide) return; + d->trafficSide = trafficSide; + Q_EMIT trafficSideChanged(trafficSide); +} + QT_END_NAMESPACE diff --git a/src/location/maps/qgeorouteparser_p.h b/src/location/maps/qgeorouteparser_p.h index 33c3a4db..053dadb1 100644 --- a/src/location/maps/qgeorouteparser_p.h +++ b/src/location/maps/qgeorouteparser_p.h @@ -61,12 +61,25 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoRouteParser : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QGeoRouteParser) - + Q_PROPERTY(TrafficSide trafficSide READ trafficSide WRITE setTrafficSide NOTIFY trafficSideChanged) + Q_ENUMS(TrafficSide) public: + enum TrafficSide { + RightHandTraffic, + LeftHandTraffic + }; virtual ~QGeoRouteParser(); QGeoRouteReply::Error parseReply(QList<QGeoRoute> &routes, QString &errorString, const QByteArray &reply) const; QUrl requestUrl(const QGeoRouteRequest &request, const QString &prefix) const; + TrafficSide trafficSide() const; + +public Q_SLOTS: + void setTrafficSide(TrafficSide trafficSide); + +Q_SIGNALS: + void trafficSideChanged(TrafficSide trafficSide); + protected: QGeoRouteParser(QGeoRouteParserPrivate &dd, QObject *parent = nullptr); diff --git a/src/location/maps/qgeorouteparser_p_p.h b/src/location/maps/qgeorouteparser_p_p.h index 63c773eb..c0080437 100644 --- a/src/location/maps/qgeorouteparser_p_p.h +++ b/src/location/maps/qgeorouteparser_p_p.h @@ -64,6 +64,8 @@ public: virtual QGeoRouteReply::Error parseReply(QList<QGeoRoute> &routes, QString &errorString, const QByteArray &reply) const = 0; virtual QUrl requestUrl(const QGeoRouteRequest &request, const QString &prefix) const = 0; + + QGeoRouteParser::TrafficSide trafficSide; }; QT_END_NAMESPACE diff --git a/src/location/maps/qgeorouteparserosrmv4.cpp b/src/location/maps/qgeorouteparserosrmv4.cpp index bd36e7f3..24c920b0 100644 --- a/src/location/maps/qgeorouteparserosrmv4.cpp +++ b/src/location/maps/qgeorouteparserosrmv4.cpp @@ -86,7 +86,7 @@ static QList<QGeoCoordinate> parsePolyline(const QByteArray &data) return path; } -static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString &instructionCode) +static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString &instructionCode, QGeoRouteParser::TrafficSide trafficSide) { if (instructionCode == QLatin1String("0")) return QGeoManeuver::NoDirection; @@ -98,9 +98,15 @@ static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString return QGeoManeuver::DirectionRight; else if (instructionCode == QLatin1String("4")) return QGeoManeuver::DirectionHardRight; - else if (instructionCode == QLatin1String("5")) + else if (instructionCode == QLatin1String("5")) { + switch (trafficSide) { + case QGeoRouteParser::RightHandTraffic: + return QGeoManeuver::DirectionUTurnLeft; + case QGeoRouteParser::LeftHandTraffic: + return QGeoManeuver::DirectionUTurnRight; + } return QGeoManeuver::DirectionUTurnLeft; - else if (instructionCode == QLatin1String("6")) + } else if (instructionCode == QLatin1String("6")) return QGeoManeuver::DirectionHardLeft; else if (instructionCode == QLatin1String("7")) return QGeoManeuver::DirectionLeft; @@ -240,7 +246,7 @@ static QString osrmInstructionText(const QString &instructionCode, const QString } static QGeoRoute constructRoute(const QByteArray &geometry, const QJsonArray &instructions, - const QJsonObject &summary) + const QJsonObject &summary, QGeoRouteParser::TrafficSide trafficSide) { QGeoRoute route; @@ -272,7 +278,7 @@ static QGeoRoute constructRoute(const QByteArray &geometry, const QJsonArray &in segment.setDistance(segmentLength); QGeoManeuver maneuver; - maneuver.setDirection(osrmInstructionDirection(instructionCode)); + maneuver.setDirection(osrmInstructionDirection(instructionCode, trafficSide)); maneuver.setDistanceToNextInstruction(segmentLength); maneuver.setInstructionText(osrmInstructionText(instructionCode, wayname)); maneuver.setPosition(path.at(position)); @@ -349,7 +355,7 @@ QGeoRouteReply::Error QGeoRouteParserOsrmV4Private::parseReply(QList<QGeoRoute> QJsonArray routeInstructions = object.value(QStringLiteral("route_instructions")).toArray(); - QGeoRoute route = constructRoute(routeGeometry, routeInstructions, routeSummary); + QGeoRoute route = constructRoute(routeGeometry, routeInstructions, routeSummary, trafficSide); routes.append(route); @@ -365,7 +371,8 @@ QGeoRouteReply::Error QGeoRouteParserOsrmV4Private::parseReply(QList<QGeoRoute> for (int i = 0; i < alternativeSummaries.count(); ++i) { route = constructRoute(alternativeGeometries.at(i).toString().toLatin1(), alternativeInstructions.at(i).toArray(), - alternativeSummaries.at(i).toObject()); + alternativeSummaries.at(i).toObject(), + trafficSide); //routes.append(route); } } diff --git a/src/location/maps/qgeorouteparserosrmv5.cpp b/src/location/maps/qgeorouteparserosrmv5.cpp index 39910229..cc39158f 100644 --- a/src/location/maps/qgeorouteparserosrmv5.cpp +++ b/src/location/maps/qgeorouteparserosrmv5.cpp @@ -769,7 +769,7 @@ static QString instructionText(const QJsonObject &step, const QJsonObject &maneu return maneuverType + QLatin1String(" to/onto ") + wayName; } -static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject &maneuver) +static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject &maneuver, QGeoRouteParser::TrafficSide trafficSide) { QString modifier; if (maneuver.value(QLatin1String("modifier")).isString()) @@ -785,9 +785,15 @@ static QGeoManeuver::InstructionDirection instructionDirection(const QJsonObject return QGeoManeuver::DirectionHardRight; else if (modifier == QLatin1String("slight right")) return QGeoManeuver::DirectionLightRight; - else if (modifier == QLatin1String("uturn")) - return QGeoManeuver::DirectionUTurnLeft; // This should rather be country-specific. In UK, f.ex. one should rather UTurn Right - else if (modifier == QLatin1String("left")) + else if (modifier == QLatin1String("uturn")) { + switch (trafficSide) { + case QGeoRouteParser::RightHandTraffic: + return QGeoManeuver::DirectionUTurnLeft; + case QGeoRouteParser::LeftHandTraffic: + return QGeoManeuver::DirectionUTurnRight; + } + return QGeoManeuver::DirectionUTurnLeft; + } else if (modifier == QLatin1String("left")) return QGeoManeuver::DirectionLeft; else if (modifier == QLatin1String("sharp left")) return QGeoManeuver::DirectionHardLeft; @@ -855,7 +861,7 @@ QGeoRouteSegment QGeoRouteParserOsrmV5Private::parseStep(const QJsonObject &step QString geometry = step.value(QLatin1String("geometry")).toString(); QList<QGeoCoordinate> path = decodePolyline(geometry); - QGeoManeuver::InstructionDirection maneuverInstructionDirection = instructionDirection(maneuver); + QGeoManeuver::InstructionDirection maneuverInstructionDirection = instructionDirection(maneuver, trafficSide); QString maneuverInstructionText = instructionText(step, maneuver, maneuverInstructionDirection); |