diff options
Diffstat (limited to 'src/location/maps')
-rw-r--r-- | src/location/maps/qgeomappingmanagerengine.cpp | 8 | ||||
-rw-r--r-- | src/location/maps/qgeomappingmanagerengine_p.h | 2 | ||||
-rw-r--r-- | src/location/maps/qgeomaptype.cpp | 29 | ||||
-rw-r--r-- | src/location/maps/qgeomaptype_p.h | 10 | ||||
-rw-r--r-- | src/location/maps/qgeomaptype_p_p.h | 9 | ||||
-rw-r--r-- | src/location/maps/qgeoprojection.cpp | 16 | ||||
-rw-r--r-- | src/location/maps/qgeoprojection_p.h | 7 | ||||
-rw-r--r-- | src/location/maps/qgeorouterequest.cpp | 2 | ||||
-rw-r--r-- | src/location/maps/qgeorouterequest.h | 3 | ||||
-rw-r--r-- | src/location/maps/qgeotilefetcher.cpp | 7 | ||||
-rw-r--r-- | src/location/maps/qgeotilefetcher_p.h | 1 |
11 files changed, 80 insertions, 14 deletions
diff --git a/src/location/maps/qgeomappingmanagerengine.cpp b/src/location/maps/qgeomappingmanagerengine.cpp index ffc0f065..187b30eb 100644 --- a/src/location/maps/qgeomappingmanagerengine.cpp +++ b/src/location/maps/qgeomappingmanagerengine.cpp @@ -154,7 +154,13 @@ QGeoCameraCapabilities QGeoMappingManagerEngine::cameraCapabilities(int mapId) c { Q_UNUSED(mapId) Q_D(const QGeoMappingManagerEngine); - return d->capabilities_; + + if (mapId == 0) + return d->capabilities_; + int idx = mapId - 1; + if (idx >= supportedMapTypes().size()) + return d->capabilities_; + return supportedMapTypes().at(idx).cameraCapabilities(); } void QGeoMappingManagerEngine::setCameraCapabilities(const QGeoCameraCapabilities &capabilities) diff --git a/src/location/maps/qgeomappingmanagerengine_p.h b/src/location/maps/qgeomappingmanagerengine_p.h index 0f347d73..dd4aa681 100644 --- a/src/location/maps/qgeomappingmanagerengine_p.h +++ b/src/location/maps/qgeomappingmanagerengine_p.h @@ -90,7 +90,7 @@ public: QList<QGeoMapType> supportedMapTypes() const; // the class is private, so this can be virtual here for now. - virtual QGeoCameraCapabilities cameraCapabilities(int mapId = 0) const; + QGeoCameraCapabilities cameraCapabilities(int mapId = 0) const; void setLocale(const QLocale &locale); QLocale locale() const; diff --git a/src/location/maps/qgeomaptype.cpp b/src/location/maps/qgeomaptype.cpp index 34781451..c4635998 100644 --- a/src/location/maps/qgeomaptype.cpp +++ b/src/location/maps/qgeomaptype.cpp @@ -46,8 +46,11 @@ QGeoMapType::QGeoMapType(const QGeoMapType &other) : d_ptr(other.d_ptr) {} QGeoMapType::QGeoMapType(QGeoMapType::MapStyle style, const QString &name, - const QString &description, bool mobile, bool night, int mapId, QByteArray pluginName) -: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId, pluginName)) + const QString &description, bool mobile, bool night, int mapId, + const QByteArray &pluginName, + const QGeoCameraCapabilities &cameraCapabilities, + const QVariantMap &metadata) +: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId, pluginName, cameraCapabilities, metadata)) { } @@ -107,6 +110,16 @@ QByteArray QGeoMapType::pluginName() const return d_ptr->pluginName_; } +QGeoCameraCapabilities QGeoMapType::cameraCapabilities() const +{ + return d_ptr->cameraCapabilities_; +} + +QVariantMap QGeoMapType::metadata() const +{ + return d_ptr->metadata_; +} + QGeoMapTypePrivate::QGeoMapTypePrivate() : style_(QGeoMapType::NoMap), mobile_(false), night_(false), mapId_(0) { @@ -114,15 +127,18 @@ QGeoMapTypePrivate::QGeoMapTypePrivate() QGeoMapTypePrivate::QGeoMapTypePrivate(const QGeoMapTypePrivate &other) : QSharedData(other), style_(other.style_), name_(other.name_), description_(other.description_), - mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_), pluginName_(other.pluginName_) + mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_), pluginName_(other.pluginName_), + cameraCapabilities_(other.cameraCapabilities_), metadata_(other.metadata_) { } QGeoMapTypePrivate::QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile, bool night, - int mapId, QByteArray pluginName) + int mapId, const QByteArray &pluginName, + const QGeoCameraCapabilities &cameraCapabilities, + const QVariantMap &metadata) : style_(style), name_(name), description_(description), mobile_(mobile), night_(night), - mapId_(mapId), pluginName_(pluginName) + mapId_(mapId), pluginName_(pluginName), cameraCapabilities_(cameraCapabilities), metadata_(metadata) { } @@ -134,7 +150,8 @@ bool QGeoMapTypePrivate::operator==(const QGeoMapTypePrivate &other) const { return pluginName_ == other.pluginName_ && style_ == other.style_ && name_ == other.name_ && description_ == other.description_ && mobile_ == other.mobile_ && night_ == other.night_ && - mapId_ == other.mapId_; + mapId_ == other.mapId_ && cameraCapabilities_ == other.cameraCapabilities_ && + metadata_ == other.metadata_; } QT_END_NAMESPACE diff --git a/src/location/maps/qgeomaptype_p.h b/src/location/maps/qgeomaptype_p.h index 4b5cb0d0..3ce0e95a 100644 --- a/src/location/maps/qgeomaptype_p.h +++ b/src/location/maps/qgeomaptype_p.h @@ -51,6 +51,8 @@ #include <QtCore/QString> #include <QtCore/QSharedDataPointer> #include <QtLocation/private/qlocationglobal_p.h> +#include <QtLocation/private/qgeocameracapabilities_p.h> +#include <QVariantMap> QT_BEGIN_NAMESPACE @@ -59,7 +61,7 @@ class QGeoMapTypePrivate; class Q_LOCATION_PRIVATE_EXPORT QGeoMapType { public: - enum MapStyle { + enum MapStyle { // ### Qt6: change this to be a QFlags instead, or remove. NoMap = 0, StreetMap, SatelliteMapDay, @@ -77,7 +79,9 @@ public: QGeoMapType(); QGeoMapType(const QGeoMapType &other); QGeoMapType(MapStyle style, const QString &name, const QString &description, bool mobile, - bool night, int mapId, QByteArray pluginName); + bool night, int mapId, const QByteArray &pluginName, + const QGeoCameraCapabilities &cameraCapabilities, + const QVariantMap &metadata = QVariantMap()); ~QGeoMapType(); QGeoMapType &operator = (const QGeoMapType &other); @@ -92,6 +96,8 @@ public: bool night() const; int mapId() const; QByteArray pluginName() const; + QGeoCameraCapabilities cameraCapabilities() const; + QVariantMap metadata() const; private: QSharedDataPointer<QGeoMapTypePrivate> d_ptr; diff --git a/src/location/maps/qgeomaptype_p_p.h b/src/location/maps/qgeomaptype_p_p.h index 039c0962..e66991ab 100644 --- a/src/location/maps/qgeomaptype_p_p.h +++ b/src/location/maps/qgeomaptype_p_p.h @@ -50,9 +50,10 @@ #include <QMetaType> #include <QString> +#include <QVariantMap> #include <QByteArray> #include <QSharedData> - +#include "qgeocameracapabilities_p.h" #include "qgeomaptype_p.h" QT_BEGIN_NAMESPACE @@ -62,7 +63,9 @@ class QGeoMapTypePrivate : public QSharedData public: QGeoMapTypePrivate(); QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile, - bool night, int mapId, QByteArray pluginName); + bool night, int mapId, const QByteArray &pluginName, + const QGeoCameraCapabilities &cameraCapabilities, + const QVariantMap &metadata); QGeoMapTypePrivate(const QGeoMapTypePrivate &other); ~QGeoMapTypePrivate(); @@ -77,6 +80,8 @@ public: bool night_; int mapId_; QByteArray pluginName_; + QGeoCameraCapabilities cameraCapabilities_; + QVariantMap metadata_; }; QT_END_NAMESPACE diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp index 013a8c33..218d806b 100644 --- a/src/location/maps/qgeoprojection.cpp +++ b/src/location/maps/qgeoprojection.cpp @@ -73,6 +73,17 @@ QGeoProjection::~QGeoProjection() } +QGeoCoordinate QGeoProjection::anchorCoordinateToPoint(const QGeoCoordinate &coordinate, const QPointF &anchorPoint) const +{ + // Approach: find the displacement in (wrapped) mercator space, and apply that to the center + QDoubleVector2D centerProj = geoToWrappedMapProjection(cameraData().center()); + QDoubleVector2D coordProj = geoToWrappedMapProjection(coordinate); + + QDoubleVector2D anchorProj = itemPositionToWrappedMapProjection(QDoubleVector2D(anchorPoint)); + // Y-clamping done in mercatorToCoord + return wrappedMapProjectionToGeo(centerProj + coordProj - anchorProj); +} + /* * QGeoProjectionWebMercator implementation */ @@ -566,6 +577,11 @@ void QGeoProjectionWebMercator::updateVisibleRegion() } } +QGeoCameraData QGeoProjectionWebMercator::cameraData() const +{ + return m_cameraData; +} + /* * * Line implementation diff --git a/src/location/maps/qgeoprojection_p.h b/src/location/maps/qgeoprojection_p.h index 76e11af0..ca81df3a 100644 --- a/src/location/maps/qgeoprojection_p.h +++ b/src/location/maps/qgeoprojection_p.h @@ -92,6 +92,12 @@ public: virtual QDoubleVector2D geoToWrappedMapProjection(const QGeoCoordinate &coordinate) const = 0; virtual QGeoCoordinate wrappedMapProjectionToGeo(const QDoubleVector2D &wrappedProjection) const = 0; virtual QMatrix4x4 quickItemTransformation(const QGeoCoordinate &coordinate, const QPointF &anchorPoint, qreal zoomLevel) const = 0; + + // Returns the new map center after anchoring coordinate to anchorPoint on the screen + QGeoCoordinate anchorCoordinateToPoint(const QGeoCoordinate &coordinate, const QPointF &anchorPoint) const; + +private: + virtual QGeoCameraData cameraData() const = 0; }; class Q_LOCATION_PRIVATE_EXPORT QGeoProjectionWebMercator : public QGeoProjection @@ -133,6 +139,7 @@ public: private: void setupCamera(); void updateVisibleRegion(); + QGeoCameraData cameraData() const Q_DECL_OVERRIDE; public: struct Line2D diff --git a/src/location/maps/qgeorouterequest.cpp b/src/location/maps/qgeorouterequest.cpp index 753d2ee9..a1b32d85 100644 --- a/src/location/maps/qgeorouterequest.cpp +++ b/src/location/maps/qgeorouterequest.cpp @@ -134,6 +134,8 @@ QT_BEGIN_NAMESPACE Consider parks when planning the route. \value MotorPoolLaneFeature Consider motor pool lanes when planning the route. + \value TrafficFeature + Consider the current traffic situation when planning the route. Since QtLocation 5.10 */ /*! diff --git a/src/location/maps/qgeorouterequest.h b/src/location/maps/qgeorouterequest.h index 6fcc7ad3..cf89d13d 100644 --- a/src/location/maps/qgeorouterequest.h +++ b/src/location/maps/qgeorouterequest.h @@ -70,7 +70,8 @@ public: TunnelFeature = 0x00000010, DirtRoadFeature = 0x00000020, ParksFeature = 0x00000040, - MotorPoolLaneFeature = 0x00000080 + MotorPoolLaneFeature = 0x00000080, + TrafficFeature = 0x00000100 }; Q_DECLARE_FLAGS(FeatureTypes, FeatureType) diff --git a/src/location/maps/qgeotilefetcher.cpp b/src/location/maps/qgeotilefetcher.cpp index 70ebbcd1..bab75034 100644 --- a/src/location/maps/qgeotilefetcher.cpp +++ b/src/location/maps/qgeotilefetcher.cpp @@ -126,7 +126,7 @@ void QGeoTileFetcher::requestNextTile() const QGeoCameraCapabilities & cameraCaps = d->engine_->cameraCapabilities(ts.mapId()); // the ZL in QGeoTileSpec is relative to the native tile size of the provider. // It gets denormalized in QGeoTiledMap. - if (ts.zoom() < cameraCaps.minimumZoomLevel() || ts.zoom() > cameraCaps.maximumZoomLevel()) + if (ts.zoom() < cameraCaps.minimumZoomLevel() || ts.zoom() > cameraCaps.maximumZoomLevel() || !fetchingEnabled()) return; QGeoTiledMapReply *reply = getTileImage(ts); @@ -189,6 +189,11 @@ bool QGeoTileFetcher::initialized() const return true; } +bool QGeoTileFetcher::fetchingEnabled() const +{ + return true; +} + void QGeoTileFetcher::handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &spec) { Q_D(QGeoTileFetcher); diff --git a/src/location/maps/qgeotilefetcher_p.h b/src/location/maps/qgeotilefetcher_p.h index d052a8a8..88880424 100644 --- a/src/location/maps/qgeotilefetcher_p.h +++ b/src/location/maps/qgeotilefetcher_p.h @@ -89,6 +89,7 @@ protected: void timerEvent(QTimerEvent *event); QAbstractGeoTileCache::CacheAreas cacheHint() const; virtual bool initialized() const; + virtual bool fetchingEnabled() const; private: |