summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2016-07-28 19:21:35 +0200
committerMichal Klocek <michal.klocek@theqtcompany.com>2016-07-28 19:21:47 +0200
commit1a1d2e3fff5856dc9d1283b510a9f325c6fb8a93 (patch)
tree2c16537e3321cde9ca9730f871f47ed32668e120 /src/location
parent4e1008b4ac1eea776585ca41a6a3db127cf500ff (diff)
parent75dd424e11964d8755abdb1b12b27a8479353b37 (diff)
downloadqtlocation-1a1d2e3fff5856dc9d1283b510a9f325c6fb8a93.tar.gz
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I37542960aa091ab2074914a2cebb8c5114237a26
Diffstat (limited to 'src/location')
-rw-r--r--src/location/doc/images/api-map.pngbin62031 -> 0 bytes
-rw-r--r--src/location/doc/src/plugins/osm.qdoc25
-rw-r--r--src/location/maps/qgeomap_p.h5
-rw-r--r--src/location/maps/qgeotiledmap.cpp14
-rw-r--r--src/location/maps/qgeotiledmap_p.h5
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine.cpp12
-rw-r--r--src/location/maps/qgeotilefetcher.cpp9
-rw-r--r--src/location/maps/qgeotilefetcher_p.h1
8 files changed, 62 insertions, 9 deletions
diff --git a/src/location/doc/images/api-map.png b/src/location/doc/images/api-map.png
deleted file mode 100644
index 6e7255d4..00000000
--- a/src/location/doc/images/api-map.png
+++ /dev/null
Binary files differ
diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc
index 1c924fd3..2fd9e7c4 100644
--- a/src/location/doc/src/plugins/osm.qdoc
+++ b/src/location/doc/src/plugins/osm.qdoc
@@ -60,15 +60,30 @@ a prefix.
\li User agent string set when making network requests. This parameter should be set to a
value that uniquely identifies the application.
\row
- \li osm.mapping.host
+ \li osm.mapping.custom.host
\li Url string set when making network requests to the tile server. This parameter should be set to a
valid server url with the correct osm api and the \l{Map::activeMapType} to the corresponding \l{MapType}.CustomMap.
The CustomMap will only be available if this parameter is set.
- \note Setting the mapping.host parameter to a new server renders the map tile cache useless for the old custommap style.
+ \note Setting the mapping.custom.host parameter to a new server renders the map tile cache useless for the old custommap style.
\row
- \li osm.mapping.copyright
- \li Custom copryright string is used when setting the \l{Map::activeMapType} to \l{MapType}.CustomMap via urlprefix parameter.
- This copyright will only be used when using the CustomMap from above. If empty no copyright will be displayed for the custom map.
+ \li osm.mapping.custom.mapcopyright
+ \li Custom map copryright string is used when setting the \l{Map::activeMapType} to \l{MapType}.CustomMap via urlprefix parameter.
+ This copyright will only be used when using the CustomMap from above. If empty no map copyright will be displayed for the custom map.
+\row
+ \li osm.mapping.custom.datacopyright
+ \li Custom data copryright string is used when setting the \l{Map::activeMapType} to \l{MapType}.CustomMap via urlprefix parameter.
+ This copyright will only be used when using the CustomMap from above. If empty no data copyright will be displayed for the custom map.
+\row
+ \li osm.mapping.providersrepository.address
+ \li The OpenStreetMap plugin retrieves the provider's information from a remote repository. This is done to prevent using hardcoded
+ servers by default, which may become unavailable. By default this information is fetched from \l {http://maps-redirect.qt.io} {maps-redirect.qt.io}.
+ Setting this parameter changes the provider repository address to a user-specified one, which must contain the files
+ \tt{street}, \tt{satellite}, \tt{cycle}, \tt{transit}, \tt{night-transit}, \tt{terrain} and \tt{hiking}.
+\row
+ \li osm.mapping.providersrepository.disabled
+ \li By default, the OpenStreetMap plugin retrieves the provider's information from a remote repository to avoid a loss of service due to unavailability of hardcoded services.
+ The plugin, however, still contains fallback hardcoded provider data, in case the provider repository becomes unreachable.
+ Setting this parameter to \b true makes the plugin use the hardcoded urls only and therefore prevents the plugin from fetching provider data from the remote repository.
\row
\li osm.routing.host
\li Url string set when making network requests to the routing server. This parameter should be set to a
diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h
index 8f7642d4..021c440b 100644
--- a/src/location/maps/qgeomap_p.h
+++ b/src/location/maps/qgeomap_p.h
@@ -84,8 +84,13 @@ public:
virtual QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const = 0;
virtual QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const = 0;
+
virtual double minimumZoomForMapSize(int width, int height) const = 0;
virtual double maximumLatitudeForZoom(double zoomLevel) const = 0;
+
+ virtual QDoubleVector2D referenceCoordinateToItemPosition(const QGeoCoordinate &coordinate) const = 0;
+ virtual QGeoCoordinate referenceItemPositionToCoordinate(const QDoubleVector2D &pos) const = 0;
+
virtual void prefetchData();
virtual void clearData();
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp
index 99af8ab5..a6cbb294 100644
--- a/src/location/maps/qgeotiledmap.cpp
+++ b/src/location/maps/qgeotiledmap.cpp
@@ -194,6 +194,20 @@ double QGeoTiledMap::maximumLatitudeForZoom(double zoomLevel) const
return topMost.latitude();
}
+QDoubleVector2D QGeoTiledMap::referenceCoordinateToItemPosition(const QGeoCoordinate &coordinate) const
+{
+ Q_D(const QGeoTiledMap);
+ QDoubleVector2D point = QGeoProjection::coordToMercator(coordinate);
+ return point * std::pow(2.0, d->m_cameraData.zoomLevel()) * d->m_visibleTiles->tileSize();
+}
+
+QGeoCoordinate QGeoTiledMap::referenceItemPositionToCoordinate(const QDoubleVector2D &pos) const
+{
+ Q_D(const QGeoTiledMap);
+ QDoubleVector2D point = pos / (std::pow(2.0, d->m_cameraData.zoomLevel()) * d->m_visibleTiles->tileSize());
+ return QGeoProjection::mercatorToCoord(point);
+}
+
QGeoTiledMapPrivate::QGeoTiledMapPrivate(QGeoTiledMappingManagerEngine *engine)
: QGeoMapPrivate(engine),
m_cache(engine->tileCache()),
diff --git a/src/location/maps/qgeotiledmap_p.h b/src/location/maps/qgeotiledmap_p.h
index 6c735e86..813e342d 100644
--- a/src/location/maps/qgeotiledmap_p.h
+++ b/src/location/maps/qgeotiledmap_p.h
@@ -86,8 +86,13 @@ public:
QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const Q_DECL_OVERRIDE;
QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const Q_DECL_OVERRIDE;
+
double minimumZoomForMapSize(int width, int height) const Q_DECL_OVERRIDE;
double maximumLatitudeForZoom(double zoomLevel) const Q_DECL_OVERRIDE;
+
+ QDoubleVector2D referenceCoordinateToItemPosition(const QGeoCoordinate &coordinate) const Q_DECL_OVERRIDE;
+ QGeoCoordinate referenceItemPositionToCoordinate(const QDoubleVector2D &pos) const Q_DECL_OVERRIDE;
+
void prefetchData() Q_DECL_OVERRIDE;
void clearData() Q_DECL_OVERRIDE;
diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp
index 4e777ab2..dc5f1889 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine.cpp
+++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp
@@ -65,11 +65,16 @@ QGeoTiledMappingManagerEngine::~QGeoTiledMappingManagerEngine()
delete d_ptr;
}
-
+/*!
+ Sets the tile fetcher. Takes ownership of the QObject.
+*/
void QGeoTiledMappingManagerEngine::setTileFetcher(QGeoTileFetcher *fetcher)
{
Q_D(QGeoTiledMappingManagerEngine);
+ if (d->fetcher_)
+ d->fetcher_->deleteLater();
+ fetcher->setParent(this);
d->fetcher_ = fetcher;
qRegisterMetaType<QGeoTileSpec>();
@@ -275,10 +280,14 @@ void QGeoTiledMappingManagerEngine::setCacheHint(QGeoTiledMappingManagerEngine::
d->cacheHint_ = cacheHint;
}
+/*!
+ Sets the tile cache. Takes ownership of the QObject.
+*/
void QGeoTiledMappingManagerEngine::setTileCache(QAbstractGeoTileCache *cache)
{
Q_D(QGeoTiledMappingManagerEngine);
Q_ASSERT_X(!d->tileCache_, Q_FUNC_INFO, "This should be called only once");
+ cache->setParent(this);
d->tileCache_ = cache;
}
@@ -312,7 +321,6 @@ QGeoTiledMappingManagerEnginePrivate::QGeoTiledMappingManagerEnginePrivate()
QGeoTiledMappingManagerEnginePrivate::~QGeoTiledMappingManagerEnginePrivate()
{
- delete tileCache_;
}
#include "moc_qgeotiledmappingmanagerengine_p.cpp"
diff --git a/src/location/maps/qgeotilefetcher.cpp b/src/location/maps/qgeotilefetcher.cpp
index 40a1a721..0e0e81ca 100644
--- a/src/location/maps/qgeotilefetcher.cpp
+++ b/src/location/maps/qgeotilefetcher.cpp
@@ -73,7 +73,7 @@ void QGeoTileFetcher::updateTileRequests(const QSet<QGeoTileSpec> &tilesAdded,
d->queue_ += tilesAdded.toList();
- if (d->enabled_ && !d->queue_.isEmpty() && !d->timer_.isActive())
+ if (d->enabled_ && initialized() && !d->queue_.isEmpty() && !d->timer_.isActive())
d->timer_.start(0, this);
}
@@ -158,7 +158,7 @@ void QGeoTileFetcher::timerEvent(QTimerEvent *event)
return;
}
- if (d->queue_.isEmpty()) {
+ if (d->queue_.isEmpty() || !initialized()) {
d->timer_.stop();
return;
}
@@ -166,6 +166,11 @@ void QGeoTileFetcher::timerEvent(QTimerEvent *event)
requestNextTile();
}
+bool QGeoTileFetcher::initialized() 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 cabab050..cbd8b995 100644
--- a/src/location/maps/qgeotilefetcher_p.h
+++ b/src/location/maps/qgeotilefetcher_p.h
@@ -85,6 +85,7 @@ Q_SIGNALS:
protected:
void timerEvent(QTimerEvent *event);
QGeoTiledMappingManagerEngine::CacheAreas cacheHint() const;
+ virtual bool initialized() const;
private:
QGeoTileFetcherPrivate *d_ptr;