summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp4
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp2
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp20
-rw-r--r--src/imports/location/location.cpp20
-rw-r--r--src/imports/location/qdeclarativecirclemapitem.cpp32
-rw-r--r--src/imports/location/qdeclarativegeocodemodel.cpp2
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp221
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h27
-rw-r--r--src/imports/location/qdeclarativegeomapcopyrightsnotice.cpp87
-rw-r--r--src/imports/location/qdeclarativegeomapcopyrightsnotice_p.h22
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea.cpp191
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea_p.h23
-rw-r--r--src/imports/location/qdeclarativegeomapitembase.cpp2
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem.cpp2
-rw-r--r--src/imports/location/qdeclarativegeomaptype.cpp1
-rw-r--r--src/imports/location/qdeclarativegeomaptype_p.h1
-rw-r--r--src/imports/location/qdeclarativegeoroute.cpp14
-rw-r--r--src/imports/location/qdeclarativegeoroute_p.h1
-rw-r--r--src/imports/location/qdeclarativegeoroutemodel.cpp27
-rw-r--r--src/imports/location/qdeclarativegeoroutemodel_p.h2
-rw-r--r--src/imports/location/qdeclarativegeoroutesegment.cpp14
-rw-r--r--src/imports/location/qdeclarativegeoroutesegment_p.h2
-rw-r--r--src/imports/location/qdeclarativegeoserviceprovider.cpp4
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp28
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem_p.h1
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem.cpp28
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem_p.h2
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem.cpp8
-rw-r--r--src/imports/location/qgeomapitemgeometry.cpp7
-rw-r--r--src/imports/positioning/locationvaluetypeprovider.cpp223
-rw-r--r--src/imports/positioning/locationvaluetypeprovider.h156
-rw-r--r--src/imports/positioning/positioning.cpp452
-rw-r--r--src/imports/positioning/positioning.pro11
-rw-r--r--src/imports/positioning/qdeclarativecoordinate.cpp312
-rw-r--r--src/imports/positioning/qdeclarativegeocircle.cpp198
-rw-r--r--src/imports/positioning/qdeclarativegeocoordinateanimation_p.h2
-rw-r--r--src/imports/positioning/qdeclarativegeorectangle.cpp349
-rw-r--r--src/imports/positioning/qdeclarativegeorectangle.h81
-rw-r--r--src/imports/positioning/qdeclarativegeoshape.cpp212
-rw-r--r--src/location/doc/qtlocation.qdocconf7
-rw-r--r--src/location/doc/snippets/declarative/places_loader.qml2
-rw-r--r--src/location/doc/src/examples/places-map.qdoc20
-rw-r--r--src/location/doc/src/places.qdoc2
-rw-r--r--src/location/doc/src/plugins/mapbox.qdoc81
-rw-r--r--src/location/doc/src/plugins/osm.qdoc7
-rw-r--r--src/location/doc/src/qtlocation-qml.qdoc55
-rw-r--r--src/location/doc/src/qtlocation.qdoc111
-rw-r--r--src/location/maps/qgeomap.cpp11
-rw-r--r--src/location/maps/qgeomap_p.h7
-rw-r--r--src/location/maps/qgeomapcontroller.cpp2
-rw-r--r--src/location/maps/qgeomapdata_p.h7
-rw-r--r--src/location/maps/qgeomapscene.cpp30
-rw-r--r--src/location/maps/qgeomapscene_p.h4
-rw-r--r--src/location/maps/qgeomaptype_p.h1
-rw-r--r--src/location/maps/qgeoserviceprovider.cpp33
-rw-r--r--src/location/maps/qgeoserviceprovider.h2
-rw-r--r--src/location/maps/qgeotiledmapdata.cpp16
-rw-r--r--src/location/maps/qgeotiledmapdata_p.h4
-rw-r--r--src/location/maps/qgeotiledmapdata_p_p.h4
-rw-r--r--src/location/places/qplacemanager.cpp8
-rw-r--r--src/location/places/qplacemanagerengine.cpp8
-rw-r--r--src/location/places/unsupportedreplies_p.h5
-rw-r--r--src/plugins/geoservices/geoservices.pro2
-rw-r--r--src/plugins/geoservices/mapbox/mapbox.pro22
-rw-r--r--src/plugins/geoservices/mapbox/mapbox_plugin.json9
-rw-r--r--src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp94
-rw-r--r--src/plugins/geoservices/mapbox/qgeomapreplymapbox.h (renamed from src/imports/positioning/qdeclarativegeoshape.h)52
-rw-r--r--src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.cpp87
-rw-r--r--src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.h66
-rw-r--r--src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp90
-rw-r--r--src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.h57
-rw-r--r--src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp99
-rw-r--r--src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h (renamed from src/imports/positioning/qdeclarativecoordinate_p.h)56
-rw-r--r--src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp11
-rw-r--r--src/plugins/geoservices/nokia/qgeomapreply_nokia.h4
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp11
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h1
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp28
-rw-r--r--src/plugins/geoservices/osm/osm.pro13
-rw-r--r--src/plugins/geoservices/osm/osm_plugin.json3
-rw-r--r--src/plugins/geoservices/osm/qgeomapreplyosm.cpp17
-rw-r--r--src/plugins/geoservices/osm/qgeomapreplyosm.h4
-rw-r--r--src/plugins/geoservices/osm/qgeoroutereplyosm.cpp2
-rw-r--r--src/plugins/geoservices/osm/qgeoserviceproviderpluginosm.cpp9
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp84
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmapdataosm.h (renamed from src/imports/positioning/qdeclarativegeocircle.h)36
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp13
-rw-r--r--src/plugins/geoservices/osm/qgeotilefetcherosm.cpp45
-rw-r--r--src/plugins/geoservices/osm/qplacecategoriesreplyimpl.cpp59
-rw-r--r--src/plugins/geoservices/osm/qplacecategoriesreplyimpl.h55
-rw-r--r--src/plugins/geoservices/osm/qplacemanagerengineosm.cpp354
-rw-r--r--src/plugins/geoservices/osm/qplacemanagerengineosm.h90
-rw-r--r--src/plugins/geoservices/osm/qplacesearchreplyimpl.cpp213
-rw-r--r--src/plugins/geoservices/osm/qplacesearchreplyimpl.h68
-rw-r--r--src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp4
-rw-r--r--src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp21
-rw-r--r--src/positioning/doc/qtpositioning.qdocconf7
-rw-r--r--src/positioning/qdoublevector2d_p.h6
-rw-r--r--src/positioning/qdoublevector3d_p.h6
-rw-r--r--src/positioning/qgeoareamonitorinfo.cpp3
-rw-r--r--src/positioning/qgeocircle.cpp44
-rw-r--r--src/positioning/qgeocircle.h8
-rw-r--r--src/positioning/qgeocircle_p.h4
-rw-r--r--src/positioning/qgeocoordinate.cpp17
-rw-r--r--src/positioning/qgeocoordinate.h18
-rw-r--r--src/positioning/qgeopositioninfo.cpp23
-rw-r--r--src/positioning/qgeorectangle.cpp54
-rw-r--r--src/positioning/qgeorectangle.h13
-rw-r--r--src/positioning/qgeorectangle_p.h2
-rw-r--r--src/positioning/qgeosatelliteinfo.cpp15
-rw-r--r--src/positioning/qgeoshape.cpp32
-rw-r--r--src/positioning/qgeoshape.h13
-rw-r--r--src/positioning/qgeoshape_p.h2
113 files changed, 2973 insertions, 2291 deletions
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
index fe70509b..b5a65e91 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchresultmodel.cpp
@@ -315,8 +315,8 @@ QT_USE_NAMESPACE
/*!
\qmlmethod string PlaceSearchModel::errorString() const
- This read-only property holds the textual presentation of latest place search model error.
- If no error has occurred or if the model was cleared an empty string is returned.
+ This read-only property holds the textual presentation of the latest place search model error.
+ If no error has occurred or if the model was cleared, an empty string is returned.
An empty string may also be returned if an error occurred which has no associated
textual representation.
diff --git a/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp
index 2f83e2f9..74238a52 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesearchsuggestionmodel.cpp
@@ -208,7 +208,7 @@ QT_USE_NAMESPACE
/*!
\qmlmethod string QtLocation::PlaceSearchSuggestionModel::errorString() const
- This read-only property holds the textual presentation of latest search suggestion model error.
+ This read-only property holds the textual presentation of the latest search suggestion model error.
If no error has occurred, or if the model was cleared, an empty string is returned.
An empty string may also be returned if an error occurred which has no associated
diff --git a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
index 507a4e14..2ff2ff5a 100644
--- a/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativesupportedcategoriesmodel.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2014 Aaron McCarthy <mccarthy.aaron@gmail.com>
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -109,7 +110,7 @@ QT_USE_NAMESPACE
/*!
\qmlmethod string QtLocation::CategoryModel::errorString() const
- This read-only property holds the textual presentation of latest category model error.
+ This read-only property holds the textual presentation of the latest category model error.
If no error has occurred, an empty string is returned.
An empty string may also be returned if an error occurred which has no associated
@@ -319,21 +320,21 @@ void QDeclarativeSupportedCategoriesModel::replyFinished()
if (!m_response)
return;
+ m_response->deleteLater();
+
if (m_response->error() == QPlaceReply::NoError) {
m_errorString.clear();
- m_response->deleteLater();
m_response = 0;
updateLayout();
setStatus(QDeclarativeSupportedCategoriesModel::Ready);
} else {
- m_errorString = m_response->errorString();
+ const QString errorString = m_response->errorString();
- m_response->deleteLater();
m_response = 0;
- setStatus(QDeclarativeSupportedCategoriesModel::Error);
+ setStatus(Error, errorString);
}
}
@@ -343,6 +344,9 @@ void QDeclarativeSupportedCategoriesModel::replyFinished()
void QDeclarativeSupportedCategoriesModel::addedCategory(const QPlaceCategory &category,
const QString &parentId)
{
+ if (m_response)
+ return;
+
if (!m_categoriesTree.contains(parentId))
return;
@@ -376,6 +380,9 @@ void QDeclarativeSupportedCategoriesModel::addedCategory(const QPlaceCategory &c
void QDeclarativeSupportedCategoriesModel::updatedCategory(const QPlaceCategory &category,
const QString &parentId)
{
+ if (m_response)
+ return;
+
QString categoryId = category.categoryId();
if (!m_categoriesTree.contains(parentId))
@@ -440,6 +447,9 @@ void QDeclarativeSupportedCategoriesModel::updatedCategory(const QPlaceCategory
*/
void QDeclarativeSupportedCategoriesModel::removedCategory(const QString &categoryId, const QString &parentId)
{
+ if (m_response)
+ return;
+
if (!m_categoriesTree.contains(categoryId) || !m_categoriesTree.contains(parentId))
return;
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index 0e3f3cd1..68a35c4a 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -63,10 +63,6 @@
#include "error_messages.h"
#include <QtQml/qqmlextensionplugin.h>
-#include <QtQml/qqml.h>
-#include <QtQml/private/qqmlvaluetype_p.h>
-#include <QtQml/private/qqmlglobal_p.h>
-#include <QtQml/private/qqmlmetatype_p.h>
#include <QtCore/QDebug>
@@ -154,14 +150,14 @@ public:
QStringLiteral("MapType is not intended instantiable by developer."));
//registrations below are version independent
- qRegisterMetaType<QPlaceCategory>("QPlaceCategory");
- qRegisterMetaType<QPlace>("QPlace");
- qRegisterMetaType<QPlaceIcon>("QPlaceIcon");
- qRegisterMetaType<QPlaceRatings>("QPlaceRatings");
- qRegisterMetaType<QPlaceSupplier>("QPlaceSupplier");
- qRegisterMetaType<QPlaceUser>("QPlaceUser");
- qRegisterMetaType<QPlaceAttribute>("QPlaceAttribute");
- qRegisterMetaType<QPlaceContactDetail>("QPlaceContactDetail");
+ qRegisterMetaType<QPlaceCategory>();
+ qRegisterMetaType<QPlace>();
+ qRegisterMetaType<QPlaceIcon>();
+ qRegisterMetaType<QPlaceRatings>();
+ qRegisterMetaType<QPlaceSupplier>();
+ qRegisterMetaType<QPlaceUser>();
+ qRegisterMetaType<QPlaceAttribute>();
+ qRegisterMetaType<QPlaceContactDetail>();
} else {
qDebug() << "Unsupported URI given to load location QML plugin: " << QLatin1String(uri);
}
diff --git a/src/imports/location/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp
index 226e844c..51486f06 100644
--- a/src/imports/location/qdeclarativecirclemapitem.cpp
+++ b/src/imports/location/qdeclarativecirclemapitem.cpp
@@ -145,7 +145,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
return;
}
- QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false).toPointF();
+ QPointF origin = map.coordinateToItemPosition(srcOrigin_, false).toPointF();
QPainterPath ppi = srcPath_;
@@ -164,9 +164,9 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
// calculate actual width of map on screen in pixels
QGeoCoordinate mapCenter(0, map.cameraData().center().longitude());
- QDoubleVector2D midPoint = map.coordinateToScreenPosition(mapCenter, false);
+ QDoubleVector2D midPoint = map.coordinateToItemPosition(mapCenter, false);
QDoubleVector2D midPointPlusOne = QDoubleVector2D(midPoint.x() + 1.0, midPoint.y());
- QGeoCoordinate coord1 = map.screenPositionToCoordinate(midPointPlusOne, false);
+ QGeoCoordinate coord1 = map.itemPositionToCoordinate(midPointPlusOne, false);
double geoDistance = coord1.longitude() - map.cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360.0;
@@ -268,20 +268,20 @@ static void calculatePeripheralPoints(QList<QGeoCoordinate> &path, const QGeoCoo
// pre-calculate
qreal latRad = qgeocoordinate_degToRad(center.latitude());
qreal lonRad = qgeocoordinate_degToRad(center.longitude());
- qreal cosLatRad = cos(latRad);
- qreal sinLatRad = sin(latRad);
+ qreal cosLatRad = std::cos(latRad);
+ qreal sinLatRad = std::sin(latRad);
qreal ratio = (distance / (qgeocoordinate_EARTH_MEAN_RADIUS * 1000.0));
- qreal cosRatio = cos(ratio);
- qreal sinRatio = sin(ratio);
+ qreal cosRatio = std::cos(ratio);
+ qreal sinRatio = std::sin(ratio);
qreal sinLatRad_x_cosRatio = sinLatRad * cosRatio;
qreal cosLatRad_x_sinRatio = cosLatRad * sinRatio;
for (int i = 0; i < steps; ++i) {
qreal azimuthRad = 2 * M_PI * i / steps;
- qreal resultLatRad = asin(sinLatRad_x_cosRatio
- + cosLatRad_x_sinRatio * cos(azimuthRad));
- qreal resultLonRad = lonRad + atan2(sin(azimuthRad) * cosLatRad_x_sinRatio,
- cosRatio - sinLatRad * sin(resultLatRad));
+ qreal resultLatRad = std::asin(sinLatRad_x_cosRatio
+ + cosLatRad_x_sinRatio * std::cos(azimuthRad));
+ qreal resultLonRad = lonRad + std::atan2(std::sin(azimuthRad) * cosLatRad_x_sinRatio,
+ cosRatio - sinLatRad * std::sin(resultLatRad));
qreal lat2 = qgeocoordinate_radToDeg(resultLatRad);
qreal lon2 = qgeocoordinate_radToDeg(resultLonRad);
if (lon2 < -180.0) {
@@ -560,7 +560,7 @@ void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(width(), height()) / 2;
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid())
setCenter(newCoordinate);
@@ -605,19 +605,19 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinat
return;
QList<int> wrapPathIndex;
// calculate actual width of map on screen in pixels
- QDoubleVector2D midPoint = map()->coordinateToScreenPosition(map()->cameraData().center(), false);
+ QDoubleVector2D midPoint = map()->coordinateToItemPosition(map()->cameraData().center(), false);
QDoubleVector2D midPointPlusOne(midPoint.x() + 1.0, midPoint.y());
- QGeoCoordinate coord1 = map()->screenPositionToCoordinate(midPointPlusOne, false);
+ QGeoCoordinate coord1 = map()->itemPositionToCoordinate(midPointPlusOne, false);
qreal geoDistance = coord1.longitude() - map()->cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360;
qreal mapWidth = 360.0 / geoDistance;
mapWidth = qMin(static_cast<int>(mapWidth), map()->width());
- QDoubleVector2D prev = map()->coordinateToScreenPosition(path.at(0), false);
+ QDoubleVector2D prev = map()->coordinateToItemPosition(path.at(0), false);
// find the points in path where wrapping occurs
for (int i = 1; i <= path.count(); ++i) {
int index = i % path.count();
- QDoubleVector2D point = map()->coordinateToScreenPosition(path.at(index), false);
+ QDoubleVector2D point = map()->coordinateToItemPosition(path.at(index), false);
if ( (qAbs(point.x() - prev.x())) >= mapWidth/2.0 ) {
wrapPathIndex << index;
if (wrapPathIndex.size() == 2 || !(crossNorthPole && crossSouthPole))
diff --git a/src/imports/location/qdeclarativegeocodemodel.cpp b/src/imports/location/qdeclarativegeocodemodel.cpp
index df3f17fb..6a6ca9f7 100644
--- a/src/imports/location/qdeclarativegeocodemodel.cpp
+++ b/src/imports/location/qdeclarativegeocodemodel.cpp
@@ -442,7 +442,7 @@ void QDeclarativeGeocodeModel::setError(GeocodeError error)
/*!
\qmlproperty string QtLocation::GeocodeModel::errorString
- This read-only property holds the textual presentation of latest geocoding error.
+ This read-only property holds the textual presentation of the latest geocoding error.
If no error has occurred or the model has been reset, an empty string is returned.
An empty string may also be returned if an error occurred which has no associated
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 4fef83e6..a2d139e9 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -58,7 +58,6 @@
#include <QtQml/QQmlContext>
#include <QtQml/qqmlinfo.h>
#include <QModelIndex>
-#include <QtQuick/QQuickWindow>
#include <QtQuick/QSGSimpleRectNode>
#include <QtGui/QGuiApplication>
#include <QCoreApplication>
@@ -102,7 +101,7 @@ QT_BEGIN_NAMESPACE
When the map is displayed, each possible geographic coordinate that is
visible will map to some pixel X and Y coordinate on the screen. To perform
conversions between these two, Map provides the \l toCoordinate and
- \l toScreenPosition functions, which are of general utility.
+ \l fromCoordinate functions, which are of general utility.
\section2 Map Objects
@@ -173,6 +172,13 @@ QT_BEGIN_NAMESPACE
\image api-map.png
*/
+/*!
+ \qmlsignal QtLocation::Map::copyrightLinkActivated(string link)
+
+ This signal is emitted when the user clicks on a \a link in the copyright notice. The
+ application should open the link in a browser or display its contents to the user.
+*/
+
QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
: QQuickItem(parent),
plugin_(0),
@@ -184,11 +190,12 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
componentCompleted_(false),
mappingManagerInitialized_(false),
touchTimer_(-1),
- map_(0)
+ map_(0),
+ error_(QGeoServiceProvider::NoError)
{
QLOC_TRACE0;
setAcceptHoverEvents(false);
- setAcceptedMouseButtons(Qt::LeftButton | Qt::MidButton | Qt::RightButton);
+ setAcceptedMouseButtons(Qt::LeftButton);
setFlags(QQuickItem::ItemHasContents | QQuickItem::ItemClipsChildrenToShape);
setFiltersChildMouseEvents(true);
@@ -218,7 +225,7 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap()
*/
void QDeclarativeGeoMap::onMapChildrenChanged()
{
- if (!componentCompleted_)
+ if (!componentCompleted_ || !mappingManagerInitialized_)
return;
int maxChildZ = 0;
@@ -246,10 +253,12 @@ void QDeclarativeGeoMap::onMapChildrenChanged()
// create a new one and set its parent, re-assign it to the weak pointer, then connect the copyrights-change signal
copyrightsWPtr_ = new QDeclarativeGeoMapCopyrightNotice(this);
copyrights = copyrightsWPtr_.data();
- connect(map_,
- SIGNAL(copyrightsChanged(QImage,QPoint)),
- copyrights,
- SLOT(copyrightsChanged(QImage,QPoint)));
+ connect(map_, SIGNAL(copyrightsChanged(QImage)),
+ copyrights, SLOT(copyrightsChanged(QImage)));
+ connect(map_, SIGNAL(copyrightsChanged(QString)),
+ copyrights, SLOT(copyrightsChanged(QString)));
+ connect(copyrights, SIGNAL(linkActivated(QString)),
+ this, SIGNAL(copyrightLinkActivated(QString)));
} else {
// just re-set its parent.
copyrights->setParent(this);
@@ -260,6 +269,16 @@ void QDeclarativeGeoMap::onMapChildrenChanged()
copyrights->setCopyrightsZ(maxChildZ + 1);
}
+
+void QDeclarativeGeoMap::setError(QGeoServiceProvider::Error error, const QString &errorString)
+{
+ if (error_ == error && errorString_ == errorString)
+ return;
+ error_ = error;
+ errorString_ = errorString;
+ emit errorChanged();
+}
+
/*!
\internal
*/
@@ -268,6 +287,8 @@ void QDeclarativeGeoMap::pluginReady()
serviceProvider_ = plugin_->sharedGeoServiceProvider();
mappingManager_ = serviceProvider_->mappingManager();
+ setError(serviceProvider_->error(), serviceProvider_->errorString());
+
if (!mappingManager_ || serviceProvider_->error() != QGeoServiceProvider::NoError) {
qmlInfo(this) << QStringLiteral("Error: Plugin does not support mapping.\nError message:")
<< serviceProvider_->errorString();
@@ -300,8 +321,7 @@ void QDeclarativeGeoMap::componentComplete()
*/
void QDeclarativeGeoMap::mousePressEvent(QMouseEvent *event)
{
- if (!mouseEvent(event))
- event->ignore();
+ event->setAccepted(gestureArea_->mousePressEvent(event));
}
/*!
@@ -309,8 +329,7 @@ void QDeclarativeGeoMap::mousePressEvent(QMouseEvent *event)
*/
void QDeclarativeGeoMap::mouseMoveEvent(QMouseEvent *event)
{
- if (!mouseEvent(event))
- event->ignore();
+ event->setAccepted(gestureArea_->mouseMoveEvent(event));
}
/*!
@@ -318,31 +337,17 @@ void QDeclarativeGeoMap::mouseMoveEvent(QMouseEvent *event)
*/
void QDeclarativeGeoMap::mouseReleaseEvent(QMouseEvent *event)
{
- if (!mouseEvent(event))
- event->ignore();
+ event->setAccepted(gestureArea_->mouseReleaseEvent(event));
}
/*!
\internal
- returns whether flickable used the event
*/
-bool QDeclarativeGeoMap::mouseEvent(QMouseEvent *event)
+void QDeclarativeGeoMap::mouseUngrabEvent()
{
- if (!mappingManagerInitialized_)
- return false;
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- return gestureArea_->mousePressEvent(event);
- case QEvent::MouseButtonRelease:
- return gestureArea_->mouseReleaseEvent(event);
- case QEvent::MouseMove:
- return gestureArea_->mouseMoveEvent(event);
- default:
- return false;
- }
+ gestureArea_->mouseUngrabEvent();
}
-
/*!
\qmlproperty MapGestureArea QtLocation::Map::gesture
@@ -449,6 +454,10 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
map_ = mappingManager_->createMap(this);
gestureArea_->setMap(map_);
+ // once mappingManagerInitilized_ is set zoomLevel() returns the default initialised
+ // zoom level of the map controller. Overwrite it here to whatever the user chose.
+ map_->mapController()->setZoom(zoomLevel_);
+
//The zoom level limits are only restricted by the plugins values, if the user has set a more
//strict zoom level limit before initialization nothing is done here.
if (mappingManager_->cameraCapabilities().minimumZoomLevel() > gestureArea_->minimumZoomLevel())
@@ -461,10 +470,12 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
map_->setActiveMapType(QGeoMapType());
copyrightsWPtr_ = new QDeclarativeGeoMapCopyrightNotice(this);
- connect(map_,
- SIGNAL(copyrightsChanged(QImage,QPoint)),
- copyrightsWPtr_.data(),
- SLOT(copyrightsChanged(QImage,QPoint)));
+ connect(map_, SIGNAL(copyrightsChanged(QImage)),
+ copyrightsWPtr_.data(), SLOT(copyrightsChanged(QImage)));
+ connect(map_, SIGNAL(copyrightsChanged(QString)),
+ copyrightsWPtr_.data(), SLOT(copyrightsChanged(QString)));
+ connect(copyrightsWPtr_.data(), SIGNAL(linkActivated(QString)),
+ this, SIGNAL(copyrightLinkActivated(QString)));
connect(map_,
SIGNAL(updateRequired()),
@@ -480,7 +491,6 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
SLOT(mapZoomLevelChanged(qreal)));
map_->mapController()->setCenter(center_);
- map_->mapController()->setZoom(zoomLevel_);
QList<QGeoMapType> types = mappingManager_->supportedMapTypes();
for (int i = 0; i < types.size(); ++i) {
@@ -692,42 +702,48 @@ QQmlListProperty<QDeclarativeGeoMapType> QDeclarativeGeoMap::supportedMapTypes()
}
/*!
- \qmlmethod QtLocation::Map::toCoordinate(QPointF screenPosition)
+ \qmlmethod QtLocation::Map::toCoordinate(QPointF position)
- Returns the coordinate which corresponds to the screen position
- \a screenPosition.
+ Returns the coordinate which corresponds to the \a position relative to the map item.
- Returns an invalid coordinate if \a screenPosition is not within
- the current viewport.
+ Returns an invalid coordinate if \a position is not within the current viewport.
*/
-
-QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &screenPosition) const
+QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &position) const
{
if (map_)
- return map_->screenPositionToCoordinate(QDoubleVector2D(screenPosition));
+ return map_->itemPositionToCoordinate(QDoubleVector2D(position));
else
return QGeoCoordinate();
}
/*!
-\qmlmethod QtLocation::Map::toScreenPosition(coordinate coordinate)
+ \qmlmethod QtLocation::Map::fromCoordinate(coordinate coordinate)
- Returns the screen position which corresponds to the coordinate
- \a coordinate.
+ Returns the position relative to the map item which corresponds to the \a coordinate.
- Returns an invalid QPointF if \a coordinate is not within the
- current viewport.
+ Returns an invalid QPointF if \a coordinate is not within the current viewport.
*/
-
-QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) const
+QPointF QDeclarativeGeoMap::fromCoordinate(const QGeoCoordinate &coordinate) const
{
if (map_)
- return map_->coordinateToScreenPosition(coordinate).toPointF();
+ return map_->coordinateToItemPosition(coordinate).toPointF();
else
return QPointF(qQNaN(), qQNaN());
}
/*!
+ \qmlmethod QtLocation::Map::toScreenPosition(coordinate coordinate)
+ \obsolete
+
+ This function is missed named and is equilavent to \l {fromCoordinate}, which should be used
+ instead.
+*/
+QPointF QDeclarativeGeoMap::toScreenPosition(const QGeoCoordinate &coordinate) const
+{
+ return fromCoordinate(coordinate);
+}
+
+/*!
\qmlmethod void QtLocation::Map::pan(int dx, int dy)
Starts panning the map by \a dx pixels along the x-axis and
@@ -759,6 +775,44 @@ void QDeclarativeGeoMap::cameraStopped()
}
/*!
+ \qmlproperty string QtLocation::Map::errorString
+
+ This read-only property holds the textual presentation of the latest mapping provider error.
+ If no error has occurred, an empty string is returned.
+
+ An empty string may also be returned if an error occurred which has no associated
+ textual representation.
+
+ \sa QGeoServiceProvider::errorString()
+*/
+
+QString QDeclarativeGeoMap::errorString() const
+{
+ return errorString_;
+}
+
+/*!
+ \qmlproperty enumeration QtLocation::Map::error
+
+ This read-only property holds the last occurred mapping service provider error.
+
+ \list
+ \li Map.NoError - No error has occurred.
+ \li Map.NotSupportedError -The plugin does not support mapping functionality.
+ \li Map.UnknownParameterError -The plugin did not recognize one of the parameters it was given.
+ \li Map.MissingRequiredParameterError - The plugin did not find one of the parameters it was expecting.
+ \li Map.ConnectionError - The plugin could not connect to its backend service or database.
+ \endlist
+
+ \sa QGeoServiceProvider::Error
+*/
+
+QGeoServiceProvider::Error QDeclarativeGeoMap::error() const
+{
+ return error_;
+}
+
+/*!
\internal
*/
void QDeclarativeGeoMap::touchEvent(QTouchEvent *event)
@@ -768,8 +822,7 @@ void QDeclarativeGeoMap::touchEvent(QTouchEvent *event)
return;
}
QLOC_TRACE0;
- event->accept();
- gestureArea_->touchEvent(event);
+ event->setAccepted(gestureArea_->touchEvent(event));
}
/*!
@@ -788,29 +841,51 @@ void QDeclarativeGeoMap::wheelEvent(QWheelEvent *event)
*/
bool QDeclarativeGeoMap::childMouseEventFilter(QQuickItem *item, QEvent *event)
{
- Q_UNUSED(item)
+ if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseMove ||
+ event->type() == QEvent::MouseButtonRelease ||
+ event->type() == QEvent::MouseButtonDblClick) {
+ // Check if we have already grabbed input. This can happen if the previous touch event
+ // immediately triggers a gesture, the synthesized mouse event is still generated. Filter
+ // these events so that child items do no receive them.
+ if (gestureArea_->hasGrabbedInput())
+ return true;
+
+ // Ignore synthesized mouse events, but don't filter them, as child items may not handle
+ // touch events directly. After a gesture is recognized and an input grab obtained these
+ // events should cease to be generated, except for the case above.
+ QMouseEvent *me = static_cast<QMouseEvent *>(event);
+ if (me->source() != Qt::MouseEventNotSynthesized)
+ return false;
+ } else if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate ||
+ event->type() == QEvent::TouchEnd) {
+ // Check if already grabbed mouse, if so filter out touch events.
+ // FIXME: Returning true here gives priority to touch input, which is not what is intended.
+ // In response to returning true ungrabMouse() is called and touch input will be handled
+ // thereafter.
+ if (gestureArea_->hasGrabbedInput())
+ return true;
+ }
+
QLOC_TRACE0;
switch (event->type()) {
case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
if (item->keepMouseGrab())
return false;
- if (!gestureArea_->filterMapChildMouseEvent(static_cast<QMouseEvent *>(event)))
- return false;
- grabMouse();
- return true;
- case QEvent::UngrabMouse:
return gestureArea_->filterMapChildMouseEvent(static_cast<QMouseEvent *>(event));
+ case QEvent::MouseButtonRelease:
+ return gestureArea_->filterMapChildMouseEvent(static_cast<QMouseEvent *>(event));
+ case QEvent::UngrabMouse:
+ // Never filter ungrab mouse events. This event notifies 'item' that the mouse has been
+ // grabbed and it should cancel any outstanding input event processing. For example, press
+ // and hold timers.
+ return false;
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
if (item->keepMouseGrab())
return false;
- if (!gestureArea_->filterMapChildTouchEvent(static_cast<QTouchEvent *>(event)))
- return false;
- grabMouse();
- return true;
+ return gestureArea_->filterMapChildTouchEvent(static_cast<QTouchEvent *>(event));
case QEvent::Wheel:
return gestureArea_->wheelEvent(static_cast<QWheelEvent *>(event));
default:
@@ -988,8 +1063,8 @@ void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
case QGeoShape::RectangleType:
{
QGeoRectangle rect = shape;
- QDoubleVector2D topLeftPoint = map_->coordinateToScreenPosition(rect.topLeft(), false);
- QDoubleVector2D botRightPoint = map_->coordinateToScreenPosition(rect.bottomRight(), false);
+ QDoubleVector2D topLeftPoint = map_->coordinateToItemPosition(rect.topLeft(), false);
+ QDoubleVector2D botRightPoint = map_->coordinateToItemPosition(rect.bottomRight(), false);
bboxWidth = qAbs(topLeftPoint.x() - botRightPoint.x());
bboxHeight = qAbs(topLeftPoint.y() - botRightPoint.y());
centerCoordinate = rect.center();
@@ -1000,8 +1075,8 @@ void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
QGeoCircle circle = shape;
centerCoordinate = circle.center();
QGeoCoordinate edge = centerCoordinate.atDistanceAndAzimuth(circle.radius(), 90);
- QDoubleVector2D centerPoint = map_->coordinateToScreenPosition(centerCoordinate, false);
- QDoubleVector2D edgePoint = map_->coordinateToScreenPosition(edge, false);
+ QDoubleVector2D centerPoint = map_->coordinateToItemPosition(centerCoordinate, false);
+ QDoubleVector2D edgePoint = map_->coordinateToItemPosition(edge, false);
bboxWidth = qAbs(centerPoint.x() - edgePoint.x()) * 2;
bboxHeight = bboxWidth;
break;
@@ -1029,8 +1104,8 @@ void QDeclarativeGeoMap::fitViewportToGeoShape(const QVariant &variantShape)
else
zoomRatio = bboxHeight / height();
- qreal newZoom = log10(zoomRatio) / log10(0.5);
- newZoom = floor(qMax(minimumZoomLevel(), (map_->mapController()->zoom() + newZoom)));
+ qreal newZoom = std::log10(zoomRatio) / std::log10(0.5);
+ newZoom = std::floor(qMax(minimumZoomLevel(), (map_->mapController()->zoom() + newZoom)));
setProperty("zoomLevel", QVariant::fromValue(newZoom));
}
@@ -1117,7 +1192,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
// position camera to the center of bounding box
QGeoCoordinate coordinate;
- coordinate = map_->screenPositionToCoordinate(QDoubleVector2D(bboxCenterX, bboxCenterY), false);
+ coordinate = map_->itemPositionToCoordinate(QDoubleVector2D(bboxCenterX, bboxCenterY), false);
setProperty("center", QVariant::fromValue(coordinate));
// adjust zoom
@@ -1130,8 +1205,8 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
else
zoomRatio = bboxHeight / height();
- qreal newZoom = log10(zoomRatio) / log10(0.5);
- newZoom = floor(qMax(minimumZoomLevel(), (map_->mapController()->zoom() + newZoom)));
+ qreal newZoom = std::log10(zoomRatio) / std::log10(0.5);
+ newZoom = std::floor(qMax(minimumZoomLevel(), (map_->mapController()->zoom() + newZoom)));
setProperty("zoomLevel", QVariant::fromValue(newZoom));
// as map quick items retain the same screen size after the camera zooms in/out
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index e06d9b36..ce66acaa 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -44,6 +44,7 @@
#include <QtQuick/QSGTexture>
#include <QtQuick/QQuickPaintedItem>
#include <QtQml/QQmlParserStatus>
+#include "qgeoserviceprovider.h"
#include "qdeclarativegeomapitemview_p.h"
#include "qdeclarativegeomapgesturearea_p.h"
#include "qgeomapcontroller_p.h"
@@ -87,7 +88,7 @@ class QDeclarativeGeoMapType;
class QDeclarativeGeoMap : public QQuickItem
{
Q_OBJECT
-
+ Q_ENUMS(QGeoServiceProvider::Error)
Q_PROPERTY(QDeclarativeGeoMapGestureArea *gesture READ gesture CONSTANT)
Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
Q_PROPERTY(qreal minimumZoomLevel READ minimumZoomLevel WRITE setMinimumZoomLevel NOTIFY minimumZoomLevelChanged)
@@ -97,6 +98,8 @@ class QDeclarativeGeoMap : public QQuickItem
Q_PROPERTY(QQmlListProperty<QDeclarativeGeoMapType> supportedMapTypes READ supportedMapTypes NOTIFY supportedMapTypesChanged)
Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter NOTIFY centerChanged)
Q_PROPERTY(QList<QObject *> mapItems READ mapItems NOTIFY mapItemsChanged)
+ Q_PROPERTY(QGeoServiceProvider::Error error READ error NOTIFY errorChanged)
+ Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -136,11 +139,12 @@ public:
Q_INVOKABLE void clearMapItems();
QList<QObject *> mapItems();
- Q_INVOKABLE QGeoCoordinate toCoordinate(const QPointF &screenPosition) const;
- Q_INVOKABLE QPointF toScreenPosition(const QGeoCoordinate &coordinate) const;
+ Q_INVOKABLE QGeoCoordinate toCoordinate(const QPointF &position) const;
+ Q_INVOKABLE QPointF fromCoordinate(const QGeoCoordinate &coordinate) const;
- // callback for map mouse areas
- bool mouseEvent(QMouseEvent *event);
+#if QT_DEPRECATED_SINCE(5,5)
+ QT_DEPRECATED Q_INVOKABLE QPointF toScreenPosition(const QGeoCoordinate &coordinate) const;
+#endif
QDeclarativeGeoMapGestureArea *gesture();
@@ -149,10 +153,14 @@ public:
Q_INVOKABLE void pan(int dx, int dy);
Q_INVOKABLE void cameraStopped(); // optional hint for prefetch
+ QString errorString() const;
+ QGeoServiceProvider::Error error() const;
+
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
+ void mouseUngrabEvent();
void touchEvent(QTouchEvent *event);
void wheelEvent(QWheelEvent *event);
@@ -169,6 +177,8 @@ Q_SIGNALS:
void minimumZoomLevelChanged();
void maximumZoomLevelChanged();
void mapItemsChanged();
+ void errorChanged();
+ void copyrightLinkActivated(const QString &link);
private Q_SLOTS:
void updateMapDisplay(const QRectF &target);
@@ -177,6 +187,9 @@ private Q_SLOTS:
void pluginReady();
void onMapChildrenChanged();
+protected:
+ void setError(QGeoServiceProvider::Error error, const QString &errorString);
+
private:
void setupMapView(QDeclarativeGeoMapItemView *view);
void populateMap();
@@ -207,6 +220,10 @@ private:
QList<QPointer<QDeclarativeGeoMapItemBase> > mapItems_;
QMutex updateMutex_;
+
+ QString errorString_;
+ QGeoServiceProvider::Error error_;
+
friend class QDeclarativeGeoMapItem;
friend class QDeclarativeGeoMapItemView;
friend class QDeclarativeGeoMapGestureArea;
diff --git a/src/imports/location/qdeclarativegeomapcopyrightsnotice.cpp b/src/imports/location/qdeclarativegeomapcopyrightsnotice.cpp
index 6dd01f99..845164c4 100644
--- a/src/imports/location/qdeclarativegeomapcopyrightsnotice.cpp
+++ b/src/imports/location/qdeclarativegeomapcopyrightsnotice.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2014 Aaron McCarthy <mccarthy.aaron@gmail.com>
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -31,15 +32,25 @@
**
****************************************************************************/
-#include <QPainter>
-#include <QPoint>
-
#include "qdeclarativegeomapcopyrightsnotice_p.h"
+#include <QtGui/QTextDocument>
+#include <QtGui/QAbstractTextDocumentLayout>
+#include <QtGui/QPainter>
+#include <QtQuick/private/qquickanchors_p.h>
+#include <QtQuick/private/qquickanchors_p_p.h>
+
QT_BEGIN_NAMESPACE
QDeclarativeGeoMapCopyrightNotice::QDeclarativeGeoMapCopyrightNotice(QQuickItem *parent)
- : QQuickPaintedItem(parent) {}
+: QQuickPaintedItem(parent), m_copyrightsHtml(0)
+{
+ QQuickAnchors *anchors = property("anchors").value<QQuickAnchors *>();
+ if (anchors) {
+ anchors->setLeft(QQuickAnchorLine(parent, QQuickAnchorLine::Left));
+ anchors->setBottom(QQuickAnchorLine(parent, QQuickAnchorLine::Bottom));
+ }
+}
QDeclarativeGeoMapCopyrightNotice::~QDeclarativeGeoMapCopyrightNotice()
{
@@ -50,7 +61,29 @@ QDeclarativeGeoMapCopyrightNotice::~QDeclarativeGeoMapCopyrightNotice()
*/
void QDeclarativeGeoMapCopyrightNotice::paint(QPainter *painter)
{
- painter->drawImage(0, 0, copyrightsImage_);
+ painter->drawImage(0, 0, m_copyrightsImage);
+}
+
+void QDeclarativeGeoMapCopyrightNotice::mousePressEvent(QMouseEvent *event)
+{
+ if (m_copyrightsHtml) {
+ m_activeAnchor = m_copyrightsHtml->documentLayout()->anchorAt(event->pos());
+ if (!m_activeAnchor.isEmpty())
+ return;
+ }
+
+ QQuickPaintedItem::mousePressEvent(event);
+}
+
+void QDeclarativeGeoMapCopyrightNotice::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (m_copyrightsHtml) {
+ QString anchor = m_copyrightsHtml->documentLayout()->anchorAt(event->pos());
+ if (anchor == m_activeAnchor && !anchor.isEmpty()) {
+ emit linkActivated(anchor);
+ m_activeAnchor.clear();
+ }
+ }
}
/*!
@@ -65,13 +98,45 @@ void QDeclarativeGeoMapCopyrightNotice::setCopyrightsZ(int copyrightsZ)
/*!
\internal
*/
-void QDeclarativeGeoMapCopyrightNotice::copyrightsChanged(const QImage &copyrightsImage, const QPoint &copyrightsPos)
+void QDeclarativeGeoMapCopyrightNotice::copyrightsChanged(const QImage &copyrightsImage)
{
- setX(copyrightsPos.x());
- setY(copyrightsPos.y());
- setWidth(copyrightsImage.width());
- setHeight(copyrightsImage.height());
- copyrightsImage_ = copyrightsImage;
+ delete m_copyrightsHtml;
+ m_copyrightsHtml = 0;
+
+ m_copyrightsImage = copyrightsImage;
+
+ setWidth(m_copyrightsImage.width());
+ setHeight(m_copyrightsImage.height());
+
+ setKeepMouseGrab(false);
+ setAcceptedMouseButtons(Qt::NoButton);
+
+ update();
+}
+
+void QDeclarativeGeoMapCopyrightNotice::copyrightsChanged(const QString &copyrightsHtml)
+{
+ if (!m_copyrightsHtml)
+ m_copyrightsHtml = new QTextDocument(this);
+
+ m_copyrightsHtml->setHtml(copyrightsHtml);
+
+ m_copyrightsImage = QImage(m_copyrightsHtml->size().toSize(),
+ QImage::Format_ARGB32_Premultiplied);
+ m_copyrightsImage.fill(qPremultiply(qRgba(255, 255, 255, 128)));
+
+ QPainter painter(&m_copyrightsImage);
+ m_copyrightsHtml->drawContents(&painter);
+
+ setWidth(m_copyrightsImage.width());
+ setHeight(m_copyrightsImage.height());
+
+ setContentsSize(m_copyrightsImage.size());
+
+ setKeepMouseGrab(true);
+ setAcceptedMouseButtons(Qt::LeftButton);
+
+ update();
}
QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapcopyrightsnotice_p.h b/src/imports/location/qdeclarativegeomapcopyrightsnotice_p.h
index 3a5dbd55..873ec444 100644
--- a/src/imports/location/qdeclarativegeomapcopyrightsnotice_p.h
+++ b/src/imports/location/qdeclarativegeomapcopyrightsnotice_p.h
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2014 Aaron McCarthy <mccarthy.aaron@gmail.com>
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -34,14 +35,17 @@
#ifndef QDECLARATIVEGEOMAPCOPYRIGHTSNOTICE_H
#define QDECLARATIVEGEOMAPCOPYRIGHTSNOTICE_H
-#include <QQuickPaintedItem>
-#include <QImage>
+#include <QtGui/QImage>
+#include <QtQuick/QQuickPaintedItem>
QT_BEGIN_NAMESPACE
+class QTextDocument;
+
class QDeclarativeGeoMapCopyrightNotice : public QQuickPaintedItem
{
Q_OBJECT
+
public:
explicit QDeclarativeGeoMapCopyrightNotice(QQuickItem *parent);
~QDeclarativeGeoMapCopyrightNotice();
@@ -49,13 +53,21 @@ public:
void setCopyrightsZ(int copyrightsZ);
public Q_SLOTS:
- void copyrightsChanged(const QImage &copyrightsImage, const QPoint &copyrightsPos);
+ void copyrightsChanged(const QImage &copyrightsImage);
+ void copyrightsChanged(const QString &copyrightsHtml);
+
+signals:
+ void linkActivated(const QString &link);
protected:
- void paint(QPainter *painter);
+ void paint(QPainter *painter) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
private:
- QImage copyrightsImage_;
+ QTextDocument *m_copyrightsHtml;
+ QImage m_copyrightsImage;
+ QString m_activeAnchor;
};
QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp
index 9f1c1691..9ac86a6e 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea.cpp
+++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp
@@ -40,6 +40,7 @@
#include <QtGui/QWheelEvent>
#include <QtGui/QStyleHints>
#include <QtQml/qqmlinfo.h>
+#include <QtQuick/QQuickWindow>
#include <QPropertyAnimation>
#include <QDebug>
#include "math.h"
@@ -241,7 +242,7 @@ QT_BEGIN_NAMESPACE
It is an indicative measure calculated from the dimensions of the
map area, roughly corresponding how much zoom level could change with
- maximum pinch zoom. Default value is 2.0, maximum value is 10.0
+ maximum pinch zoom. Default value is 4.0, maximum value is 10.0
*/
/*!
@@ -329,6 +330,8 @@ QDeclarativeGeoMapGestureArea::QDeclarativeGeoMapGestureArea(QDeclarativeGeoMap
: QObject(parent),
declarativeMap_(map),
enabled_(true),
+ hasGrab_(false),
+ activeInput_(NoInput),
activeGestures_(ZoomGesture | PanGesture | FlickGesture)
{
map_ = 0;
@@ -339,8 +342,8 @@ QDeclarativeGeoMapGestureArea::QDeclarativeGeoMapGestureArea(QDeclarativeGeoMap
touchPointState_ = touchPoints0;
pinchState_ = pinchInactive;
panState_ = panInactive;
-
}
+
/*!
\internal
*/
@@ -356,6 +359,11 @@ void QDeclarativeGeoMapGestureArea::setMap(QGeoMap *map)
map_, SLOT(cameraStopped()));
}
+bool QDeclarativeGeoMapGestureArea::hasGrabbedInput() const
+{
+ return hasGrab_;
+}
+
QDeclarativeGeoMapGestureArea::~QDeclarativeGeoMapGestureArea()
{
}
@@ -563,6 +571,11 @@ bool QDeclarativeGeoMapGestureArea::mousePressEvent(QMouseEvent *event)
if (!(enabled_ && activeGestures_))
return false;
+ if (activeInput_ == TouchInput)
+ return false;
+
+ activeInput_ = MouseInput;
+
touchPoints_.clear();
touchPoints_ << makeTouchPointFromMouseEvent(event, Qt::TouchPointPressed);
@@ -578,6 +591,9 @@ bool QDeclarativeGeoMapGestureArea::mouseMoveEvent(QMouseEvent *event)
if (!(enabled_ && activeGestures_))
return false;
+ if (activeInput_ != MouseInput)
+ return false;
+
touchPoints_.clear();
touchPoints_ << makeTouchPointFromMouseEvent(event, Qt::TouchPointMoved);
@@ -593,23 +609,63 @@ bool QDeclarativeGeoMapGestureArea::mouseReleaseEvent(QMouseEvent *)
if (!(enabled_ && activeGestures_))
return false;
+ if (activeInput_ == TouchInput)
+ return false;
+
touchPoints_.clear();
update();
+
+ activeInput_ = NoInput;
+
return true;
}
/*!
\internal
*/
-void QDeclarativeGeoMapGestureArea::touchEvent(QTouchEvent *event)
+void QDeclarativeGeoMapGestureArea::mouseUngrabEvent()
{
+ touchPoints_.clear();
+ hasGrab_ = false;
+ if (activeInput_ == MouseInput)
+ activeInput_ = NoInput;
+ update();
+}
+
+/*!
+ \internal
+*/
+bool QDeclarativeGeoMapGestureArea::touchEvent(QTouchEvent *event)
+{
+ if (!(enabled_ && activeGestures_))
+ return false;
+
+ if (activeInput_ == MouseInput)
+ return false;
+
switch (event->type()) {
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
- touchPoints_.clear();
- for (int i = 0; i < event->touchPoints().count(); ++i) {
- if (!(event->touchPoints().at(i).state() & Qt::TouchPointReleased)) {
- touchPoints_ << event->touchPoints().at(i);
+ activeInput_ = TouchInput;
+ foreach (const QTouchEvent::TouchPoint &p, event->touchPoints()) {
+ QList<QTouchEvent::TouchPoint>::iterator i;
+ for (i = touchPoints_.begin(); i != touchPoints_.end(); ++i) {
+ if (i->id() == p.id()) {
+ i = touchPoints_.erase(i);
+ break;
+ }
+ }
+ switch (p.state()) {
+ case Qt::TouchPointPressed:
+ case Qt::TouchPointMoved:
+ case Qt::TouchPointStationary:
+ touchPoints_.insert(i, p);
+ break;
+ case Qt::TouchPointReleased:
+ // already removed
+ break;
+ default:
+ break;
}
}
update();
@@ -617,11 +673,14 @@ void QDeclarativeGeoMapGestureArea::touchEvent(QTouchEvent *event)
case QEvent::TouchEnd:
touchPoints_.clear();
update();
+ activeInput_ = NoInput;
break;
default:
// no-op
break;
}
+
+ return true;
}
bool QDeclarativeGeoMapGestureArea::wheelEvent(QWheelEvent *event)
@@ -635,26 +694,25 @@ bool QDeclarativeGeoMapGestureArea::wheelEvent(QWheelEvent *event)
*/
bool QDeclarativeGeoMapGestureArea::filterMapChildMouseEvent(QMouseEvent *event)
{
- bool used = false;
+ if (!(enabled_ && activeGestures_))
+ return false;
+
+ // We have not grabbed the mouse yet. Process it but don't filter it so the child can use it
+ // (until we grab it).
switch (event->type()) {
case QEvent::MouseButtonPress:
- used = mousePressEvent(event);
+ mousePressEvent(event);
break;
case QEvent::MouseButtonRelease:
- used = mouseReleaseEvent(event);
+ mouseReleaseEvent(event);
break;
case QEvent::MouseMove:
- used = mouseMoveEvent(event);
- break;
- case QEvent::UngrabMouse:
- touchPoints_.clear();
- update();
+ mouseMoveEvent(event);
break;
default:
- used = false;
break;
}
- return used && (isPanActive() || isPinchActive());
+ return false;
}
/*!
@@ -662,8 +720,13 @@ bool QDeclarativeGeoMapGestureArea::filterMapChildMouseEvent(QMouseEvent *event)
*/
bool QDeclarativeGeoMapGestureArea::filterMapChildTouchEvent(QTouchEvent *event)
{
+ if (!(enabled_ && activeGestures_))
+ return false;
+
+ // We have not grabbed the touch id associated with this touch event yet. Process it but don't
+ // filter it so the child can use it (until we grab it).
touchEvent(event);
- return isPanActive() || isPinchActive();
+ return false;
}
/*!
@@ -710,6 +773,7 @@ void QDeclarativeGeoMapGestureArea::updateVelocityList(const QPointF &pos)
// simplify the gestures by using a state-machine format (easy to move to a future state machine)
void QDeclarativeGeoMapGestureArea::update()
{
+ if (!map_) return;
// First state machine is for the number of touch points
touchPointStateMachine();
@@ -723,6 +787,31 @@ void QDeclarativeGeoMapGestureArea::update()
// the whole gesture (enabled_ flag), this keeps the enabled_ consistent with the pinch
if (isPanActive() || (enabled_ && pan_.enabled_ && (activeGestures_ & (PanGesture | FlickGesture))))
panStateMachine();
+
+ if (pinchState_ != pinchInactive || panState_ == panActive) {
+ if (!hasGrab_) {
+ if (activeInput_ == MouseInput) {
+ hasGrab_ = true;
+ declarativeMap_->grabMouse();
+ } else if (activeInput_ == TouchInput) {
+ hasGrab_ = true;
+ QVector<int> ids;
+ foreach (const QTouchEvent::TouchPoint &tp, touchPoints_)
+ ids.append(tp.id());
+ declarativeMap_->grabTouchPoints(ids);
+ }
+ }
+ } else {
+ if (hasGrab_) {
+ if (activeInput_ == MouseInput) {
+ hasGrab_ = false;
+ declarativeMap_->ungrabMouse();
+ } else if (activeInput_ == TouchInput) {
+ hasGrab_ = false;
+ declarativeMap_->ungrabTouchPoints();
+ }
+ }
+ }
}
/*!
@@ -737,7 +826,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
clearTouchData();
startOneTouchPoint();
touchPointState_ = touchPoints1;
- } else if (touchPoints_.count() == 2) {
+ } else if (touchPoints_.count() >= 2) {
clearTouchData();
startTwoTouchPoints();
touchPointState_ = touchPoints2;
@@ -747,7 +836,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
if (touchPoints_.count() == 0) {
touchPointState_ = touchPoints0;
} else if (touchPoints_.count() == 2) {
- touchCenterCoord_ = map_->screenPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
+ touchCenterCoord_ = map_->itemPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
startTwoTouchPoints();
touchPointState_ = touchPoints2;
}
@@ -756,7 +845,7 @@ void QDeclarativeGeoMapGestureArea::touchPointStateMachine()
if (touchPoints_.count() == 0) {
touchPointState_ = touchPoints0;
} else if (touchPoints_.count() == 1) {
- touchCenterCoord_ = map_->screenPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
+ touchCenterCoord_ = map_->itemPositionToCoordinate(QDoubleVector2D(sceneCenter_), false);
startOneTouchPoint();
touchPointState_ = touchPoints1;
}
@@ -784,7 +873,7 @@ void QDeclarativeGeoMapGestureArea::startOneTouchPoint()
sceneStartPoint1_ = declarativeMap_->mapFromScene(touchPoints_.at(0).scenePos());
lastPos_ = sceneStartPoint1_;
lastPosTime_.start();
- QGeoCoordinate startCoord = map_->screenPositionToCoordinate(QDoubleVector2D(sceneStartPoint1_), false);
+ QGeoCoordinate startCoord = map_->itemPositionToCoordinate(QDoubleVector2D(sceneStartPoint1_), false);
// ensures a smooth transition for panning
startCoord_.setLongitude(startCoord_.longitude() + startCoord.longitude() -
touchCenterCoord_.longitude());
@@ -812,7 +901,7 @@ void QDeclarativeGeoMapGestureArea::startTwoTouchPoints()
QPointF startPos = (sceneStartPoint1_ + sceneStartPoint2_) * 0.5;
lastPos_ = startPos;
lastPosTime_.start();
- QGeoCoordinate startCoord = map_->screenPositionToCoordinate(QDoubleVector2D(startPos), false);
+ QGeoCoordinate startCoord = map_->itemPositionToCoordinate(QDoubleVector2D(startPos), false);
startCoord_.setLongitude(startCoord_.longitude() + startCoord.longitude() -
touchCenterCoord_.longitude());
startCoord_.setLatitude(startCoord_.latitude() + startCoord.latitude() -
@@ -841,43 +930,49 @@ void QDeclarativeGeoMapGestureArea::updateTwoTouchPoints()
/*!
\internal
*/
-void QDeclarativeGeoMapGestureArea::setPinchActive(bool active)
-{
- if ((active && pinchState_ == pinchActive) || (!active && pinchState_ != pinchActive))
- return;
- pinchState_ = active ? pinchActive : pinchInactive;
- emit pinchActiveChanged();
-}
-
-
-/*!
- \internal
-*/
void QDeclarativeGeoMapGestureArea::pinchStateMachine()
{
PinchState lastState = pinchState_;
// Transitions:
switch (pinchState_) {
case pinchInactive:
- if (canStartPinch()) {
- startPinch();
- setPinchActive(true);
+ if (touchPoints_.count() >= 2) {
+ if (canStartPinch()) {
+ startPinch();
+ pinchState_ = pinchActive;
+ } else {
+ pinchState_ = pinchInactiveTwoPoints;
+ }
+ }
+ break;
+ case pinchInactiveTwoPoints:
+ if (touchPoints_.count() <= 1) {
+ pinchState_ = pinchInactive;
+ } else {
+ if (canStartPinch()) {
+ startPinch();
+ pinchState_ = pinchActive;
+ }
}
break;
case pinchActive:
if (touchPoints_.count() <= 1) {
endPinch();
- setPinchActive(false);
+ pinchState_ = pinchInactive;
}
break;
}
// This line implements an exclusive state machine, where the transitions and updates don't
// happen on the same frame
- if (pinchState_ != lastState)
- return;
+ if (pinchState_ != lastState) {
+ emit pinchActiveChanged();
+ return;
+ }
+
// Update
switch (pinchState_) {
case pinchInactive:
+ case pinchInactiveTwoPoints:
break; // do nothing
case pinchActive:
updatePinch();
@@ -998,7 +1093,7 @@ void QDeclarativeGeoMapGestureArea::panStateMachine()
case panInactive:
if (canStartPan()) {
// Update startCoord_ to ensure smooth start for panning when going over startDragDistance
- QGeoCoordinate newStartCoord = map_->screenPositionToCoordinate(QDoubleVector2D(lastPos_), false);
+ QGeoCoordinate newStartCoord = map_->itemPositionToCoordinate(QDoubleVector2D(lastPos_), false);
startCoord_.setLongitude(newStartCoord.longitude());
startCoord_.setLatitude(newStartCoord.latitude());
panState_ = panActive;
@@ -1025,6 +1120,10 @@ void QDeclarativeGeoMapGestureArea::panStateMachine()
}
break;
}
+
+ if (panState_ != lastState)
+ emit panActiveChanged();
+
// Update
switch (panState_) {
case panInactive: // do nothing
@@ -1063,13 +1162,13 @@ bool QDeclarativeGeoMapGestureArea::canStartPan()
*/
void QDeclarativeGeoMapGestureArea::updatePan()
{
- QPointF startPoint = map_->coordinateToScreenPosition(startCoord_, false).toPointF();
+ QPointF startPoint = map_->coordinateToItemPosition(startCoord_, false).toPointF();
int dx = static_cast<int>(sceneCenter_.x() - startPoint.x());
int dy = static_cast<int>(sceneCenter_.y() - startPoint.y());
QPointF mapCenterPoint;
mapCenterPoint.setY(map_->height() / 2.0 - dy);
mapCenterPoint.setX(map_->width() / 2.0 - dx);
- QGeoCoordinate animationStartCoordinate = map_->screenPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
+ QGeoCoordinate animationStartCoordinate = map_->itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
map_->mapController()->setCenter(animationStartCoordinate);
}
@@ -1146,10 +1245,11 @@ void QDeclarativeGeoMapGestureArea::stopPan()
if (panState_ == panFlick) {
endFlick();
} else if (panState_ == panActive) {
+ panState_ = panInactive;
emit panFinished();
+ emit panActiveChanged();
emit movementStopped();
}
- panState_ = panInactive;
}
/*!
@@ -1162,6 +1262,7 @@ void QDeclarativeGeoMapGestureArea::endFlick()
pan_.animation_->stop();
emit flickFinished();
panState_ = panInactive;
+ emit panActiveChanged();
emit movementStopped();
}
diff --git a/src/imports/location/qdeclarativegeomapgesturearea_p.h b/src/imports/location/qdeclarativegeomapgesturearea_p.h
index 24b209d3..40899526 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea_p.h
+++ b/src/imports/location/qdeclarativegeomapgesturearea_p.h
@@ -109,7 +109,7 @@ class QDeclarativeGeoMapGestureArea: public QObject
Q_PROPERTY(bool pinchEnabled READ pinchEnabled WRITE setPinchEnabled NOTIFY pinchEnabledChanged)
Q_PROPERTY(bool panEnabled READ panEnabled WRITE setPanEnabled NOTIFY panEnabledChanged)
Q_PROPERTY(bool isPinchActive READ isPinchActive NOTIFY pinchActiveChanged)
- Q_PROPERTY(bool isPanActive READ isPanActive)
+ Q_PROPERTY(bool isPanActive READ isPanActive NOTIFY panActiveChanged)
Q_PROPERTY(ActiveGestures activeGestures READ activeGestures WRITE setActiveGestures NOTIFY activeGesturesChanged)
Q_PROPERTY(qreal maximumZoomLevelChange READ maximumZoomLevelChange WRITE setMaximumZoomLevelChange NOTIFY maximumZoomLevelChangeChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
@@ -129,7 +129,6 @@ public:
void setActiveGestures(ActiveGestures activeGestures);
bool isPinchActive() const;
- void setPinchActive(bool active);
bool isPanActive() const;
bool enabled() const;
@@ -147,13 +146,14 @@ public:
qreal flickDeceleration() const;
void setFlickDeceleration(qreal deceleration);
- void touchEvent(QTouchEvent *event);
+ bool touchEvent(QTouchEvent *event);
bool wheelEvent(QWheelEvent *event);
bool mousePressEvent(QMouseEvent *event);
bool mouseMoveEvent(QMouseEvent *event);
bool mouseReleaseEvent(QMouseEvent *event);
+ void mouseUngrabEvent();
bool filterMapChildMouseEvent(QMouseEvent *event);
bool filterMapChildTouchEvent(QTouchEvent *event);
@@ -166,7 +166,10 @@ public:
void setMap(QGeoMap *map);
+ bool hasGrabbedInput() const;
+
Q_SIGNALS:
+ void panActiveChanged();
void pinchActiveChanged();
void enabledChanged();
void maximumZoomLevelChangeChanged();
@@ -222,6 +225,15 @@ private:
QGeoMap *map_;
QDeclarativeGeoMap *declarativeMap_;
bool enabled_;
+ bool hasGrab_;
+
+ enum InputType
+ {
+ NoInput,
+ MouseInput,
+ TouchInput
+ };
+ InputType activeInput_;
struct Pinch
{
@@ -232,7 +244,7 @@ private:
struct Zoom
{
Zoom() : minimum(-1.0), maximum(-1.0), start(0.0), previous(0.0),
- maximumChange(2.0) {}
+ maximumChange(4.0) {}
qreal minimum;
qreal maximum;
qreal start;
@@ -283,6 +295,7 @@ private:
enum PinchState
{
pinchInactive,
+ pinchInactiveTwoPoints,
pinchActive
} pinchState_;
@@ -295,6 +308,6 @@ private:
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QDeclarativeGeoMapGestureArea);
+QML_DECLARE_TYPE(QDeclarativeGeoMapGestureArea)
#endif // QDECLARATIVEGEOMAPGESTUREAREA_P_H
diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp
index 3657ea10..64df17cb 100644
--- a/src/imports/location/qdeclarativegeomapitembase.cpp
+++ b/src/imports/location/qdeclarativegeomapitembase.cpp
@@ -171,7 +171,7 @@ void QDeclarativeGeoMapItemBase::setPositionOnMap(const QGeoCoordinate &coordina
if (!map_ || !quickMap_)
return;
- QPointF topLeft = map_->coordinateToScreenPosition(coordinate, false).toPointF() - offset;
+ QPointF topLeft = map_->coordinateToItemPosition(coordinate, false).toPointF() - offset;
setPosition(topLeft);
}
diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp
index 89fc47f2..c0bd3db1 100644
--- a/src/imports/location/qdeclarativegeomapquickitem.cpp
+++ b/src/imports/location/qdeclarativegeomapquickitem.cpp
@@ -173,7 +173,7 @@ void QDeclarativeGeoMapQuickItem::geometryChanged(const QRectF &newGeometry, con
return;
}
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false);
if (newCoordinate.isValid())
setCoordinate(newCoordinate);
diff --git a/src/imports/location/qdeclarativegeomaptype.cpp b/src/imports/location/qdeclarativegeomaptype.cpp
index 02f59f17..2bbd8fe9 100644
--- a/src/imports/location/qdeclarativegeomaptype.cpp
+++ b/src/imports/location/qdeclarativegeomaptype.cpp
@@ -73,6 +73,7 @@ QDeclarativeGeoMapType::~QDeclarativeGeoMapType() {}
\li MapType.GrayStreetMap - A gray-shaded street map.
\li MapType::PedestrianMap - A street map suitable for pedestriants.
\li MapType::CarNavigationMap - A street map suitable for car navigation.
+ \li MapType::CycleMap - A street map suitable for cyclists.
\li MapType.CustomMap - A custom map type.
\endlist
*/
diff --git a/src/imports/location/qdeclarativegeomaptype_p.h b/src/imports/location/qdeclarativegeomaptype_p.h
index 3750887b..70834402 100644
--- a/src/imports/location/qdeclarativegeomaptype_p.h
+++ b/src/imports/location/qdeclarativegeomaptype_p.h
@@ -63,6 +63,7 @@ public:
GrayStreetMap = QGeoMapType::GrayStreetMap,
PedestrianMap = QGeoMapType::PedestrianMap,
CarNavigationMap = QGeoMapType::CarNavigationMap,
+ CycleMap = QGeoMapType::CycleMap,
CustomMap = 100
};
diff --git a/src/imports/location/qdeclarativegeoroute.cpp b/src/imports/location/qdeclarativegeoroute.cpp
index ce920f96..180cc347 100644
--- a/src/imports/location/qdeclarativegeoroute.cpp
+++ b/src/imports/location/qdeclarativegeoroute.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtLocation module of the Qt Toolkit.
@@ -33,11 +33,8 @@
#include "qdeclarativegeoroute_p.h"
#include "locationvaluetypehelper_p.h"
-#include <private/qjsvalue_p.h>
-#include <private/qqmlvaluetypewrapper_p.h>
#include <QtQml/QQmlEngine>
-#include <QtQml/QQmlContext>
#include <QtQml/qqmlinfo.h>
#include <QtQml/private/qqmlengine_p.h>
#include <QtPositioning/QGeoRectangle>
@@ -161,21 +158,18 @@ QJSValue QDeclarativeGeoRoute::path() const
{
QQmlContext *context = QQmlEngine::contextForObject(parent());
QQmlEngine *engine = context->engine();
- QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(engine);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
QV4::Scope scope(v4);
QV4::Scoped<QV4::ArrayObject> pathArray(scope, v4->newArrayObject(route_.path().length()));
for (int i = 0; i < route_.path().length(); ++i) {
const QGeoCoordinate &c = route_.path().at(i);
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
- QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
-
+ QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c)));
pathArray->putIndexed(i, cv);
}
- return new QJSValuePrivate(v4, QV4::ValueRef(pathArray));
+ return QJSValue(v4, pathArray.asReturnedValue());
}
void QDeclarativeGeoRoute::setPath(const QJSValue &value)
diff --git a/src/imports/location/qdeclarativegeoroute_p.h b/src/imports/location/qdeclarativegeoroute_p.h
index fd023a98..c6c0f5f6 100644
--- a/src/imports/location/qdeclarativegeoroute_p.h
+++ b/src/imports/location/qdeclarativegeoroute_p.h
@@ -38,7 +38,6 @@
#include <QtCore/QObject>
#include <QtQml/QQmlListProperty>
-#include <QtQml/private/qv8engine_p.h>
#include <QtLocation/QGeoRoute>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeoroutemodel.cpp b/src/imports/location/qdeclarativegeoroutemodel.cpp
index ce89c076..90d07f03 100644
--- a/src/imports/location/qdeclarativegeoroutemodel.cpp
+++ b/src/imports/location/qdeclarativegeoroutemodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtLocation module of the Qt Toolkit.
@@ -35,12 +35,9 @@
#include "qdeclarativegeoroute_p.h"
#include "error_messages.h"
#include "locationvaluetypehelper_p.h"
-#include <private/qqmlvaluetypewrapper_p.h>
-#include <private/qjsvalue_p.h>
#include <QtCore/QCoreApplication>
#include <QtQml/QQmlEngine>
-#include <QtQml/QQmlContext>
#include <QtQml/qqmlinfo.h>
#include <QtQml/private/qqmlengine_p.h>
#include <QtLocation/QGeoRoutingManager>
@@ -89,7 +86,7 @@ QT_BEGIN_NAMESPACE
\code
Plugin {
id: aPlugin
- name: "nokia"
+ name: "osm"
}
RouteQuery {
@@ -516,7 +513,7 @@ void QDeclarativeGeoRouteModel::setErrorString(const QString &error)
/*!
\qmlproperty string QtLocation::RouteModel::errorString
- This read-only property holds the textual presentation of latest routing error.
+ This read-only property holds the textual presentation of the latest routing error.
If no error has occurred or the model has been reset, an empty string is returned.
An empty string may also be returned if an error occurred which has no associated
@@ -795,21 +792,18 @@ QJSValue QDeclarativeGeoRouteQuery::waypoints()
{
QQmlContext *context = QQmlEngine::contextForObject(parent());
QQmlEngine *engine = context->engine();
- QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(engine);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
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);
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
- QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
-
+ QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c)));
waypointArray->putIndexed(i, cv);
}
- return new QJSValuePrivate(v4, QV4::ValueRef(waypointArray));
+ return QJSValue(v4, waypointArray.asReturnedValue());
}
void QDeclarativeGeoRouteQuery::setWaypoints(const QJSValue &value)
@@ -854,21 +848,18 @@ QJSValue QDeclarativeGeoRouteQuery::excludedAreas() const
{
QQmlContext *context = QQmlEngine::contextForObject(parent());
QQmlEngine *engine = context->engine();
- QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(engine);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
QV4::Scope scope(v4);
QV4::Scoped<QV4::ArrayObject> excludedAreasArray(scope, v4->newArrayObject(request_.excludeAreas().length()));
for (int i = 0; i < request_.excludeAreas().length(); ++i) {
const QGeoRectangle &r = request_.excludeAreas().at(i);
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoRectangle>());
- QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(r), vt));
-
+ QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(r)));
excludedAreasArray->putIndexed(i, cv);
}
- return new QJSValuePrivate(v4, QV4::ValueRef(excludedAreasArray));
+ return QJSValue(v4, excludedAreasArray.asReturnedValue());
}
void QDeclarativeGeoRouteQuery::setExcludedAreas(const QJSValue &value)
diff --git a/src/imports/location/qdeclarativegeoroutemodel_p.h b/src/imports/location/qdeclarativegeoroutemodel_p.h
index 3dfb99f8..c005f5fb 100644
--- a/src/imports/location/qdeclarativegeoroutemodel_p.h
+++ b/src/imports/location/qdeclarativegeoroutemodel_p.h
@@ -44,7 +44,7 @@
#include <QtQml/qqml.h>
#include <QtQml/QQmlParserStatus>
-#include <QtQml/private/qv8engine_p.h>
+#include <QtQml/private/qv4engine_p.h>
#include <QAbstractListModel>
#include <QObject>
diff --git a/src/imports/location/qdeclarativegeoroutesegment.cpp b/src/imports/location/qdeclarativegeoroutesegment.cpp
index a2bc11e9..0dfd839e 100644
--- a/src/imports/location/qdeclarativegeoroutesegment.cpp
+++ b/src/imports/location/qdeclarativegeoroutesegment.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtLocation module of the Qt Toolkit.
@@ -34,10 +34,7 @@
#include "qdeclarativegeoroutesegment_p.h"
#include <QtQml/QQmlEngine>
-#include <QtQml/QQmlContext>
#include <QtQml/private/qqmlengine_p.h>
-#include <private/qqmlvaluetypewrapper_p.h>
-#include <private/qjsvalue_p.h>
QT_BEGIN_NAMESPACE
@@ -145,21 +142,18 @@ QJSValue QDeclarativeGeoRouteSegment::path() const
{
QQmlContext *context = QQmlEngine::contextForObject(parent());
QQmlEngine *engine = context->engine();
- QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(engine);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
QV4::Scope scope(v4);
QV4::Scoped<QV4::ArrayObject> pathArray(scope, v4->newArrayObject(segment_.path().length()));
for (int i = 0; i < segment_.path().length(); ++i) {
const QGeoCoordinate &c = segment_.path().at(i);
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
- QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
-
+ QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c)));
pathArray->putIndexed(i, cv);
}
- return new QJSValuePrivate(v4, QV4::ValueRef(pathArray));
+ return QJSValue(v4, pathArray.asReturnedValue());
}
#include "moc_qdeclarativegeoroutesegment_p.cpp"
diff --git a/src/imports/location/qdeclarativegeoroutesegment_p.h b/src/imports/location/qdeclarativegeoroutesegment_p.h
index d838c766..f83b2f41 100644
--- a/src/imports/location/qdeclarativegeoroutesegment_p.h
+++ b/src/imports/location/qdeclarativegeoroutesegment_p.h
@@ -37,7 +37,7 @@
#include "qdeclarativegeomaneuver_p.h"
#include <QtCore/QObject>
-#include <QtQml/private/qv8engine_p.h>
+#include <QtQml/qjsvalue.h>
#include <QtLocation/QGeoRouteSegment>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeoserviceprovider.cpp b/src/imports/location/qdeclarativegeoserviceprovider.cpp
index 8bdac880..082464ea 100644
--- a/src/imports/location/qdeclarativegeoserviceprovider.cpp
+++ b/src/imports/location/qdeclarativegeoserviceprovider.cpp
@@ -68,12 +68,12 @@ QT_BEGIN_NAMESPACE
The following snippet shows a Plugin object being created with the
\l required and \l preferred properties set. This Plugin will attach to the
first plugin found plugin that supports both mapping and geocoding, and will
- prefer plugins named "nokia" or "foo" to any others.
+ prefer plugins named "nokia" or "osm" to any others.
\code
Plugin {
id: plugin
- preferred: ["nokia", "foo"]
+ preferred: ["nokia", "osm"]
required: Plugin.AnyMappingFeatures | Plugin.AnyGeocodingFeatures
}
\endcode
diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp
index b795394b..4832c662 100644
--- a/src/imports/location/qdeclarativepolygonmapitem.cpp
+++ b/src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
- ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ ** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtLocation module of the Qt Toolkit.
@@ -40,10 +40,7 @@
#include <QtCore/QScopedValueRollback>
#include <QtGui/private/qtriangulator_p.h>
#include <QtQml/QQmlInfo>
-#include <QtQml/QQmlContext>
#include <QtQml/private/qqmlengine_p.h>
-#include <private/qqmlvaluetypewrapper_p.h>
-#include <private/qjsvalue_p.h>
#include <QPainter>
#include <QPainterPath>
#include <qnumeric.h>
@@ -160,7 +157,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
double unwrapBelowX = 0;
if (preserveGeometry_ )
- unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
+ unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
for (int i = 0; i < path.size(); ++i) {
const QGeoCoordinate &coord = path.at(i);
@@ -168,7 +165,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QDoubleVector2D point = map.coordinateToScreenPosition(coord, false);
+ QDoubleVector2D point = map.coordinateToItemPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -176,7 +173,9 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
return;
// unwrap x to preserve geometry if moved to border of map
- if (preserveGeometry_ && point.x() < unwrapBelowX && !qFuzzyCompare(point.x(), unwrapBelowX))
+ if (preserveGeometry_ && point.x() < unwrapBelowX
+ && !qFuzzyCompare(point.x(), unwrapBelowX)
+ && !qFuzzyCompare(geoLeftBound_.longitude(), coord.longitude()))
point.setX(unwrapBelowX + geoDistanceToScreenWidth(map, geoLeftBound_, coord));
if (i == 0) {
@@ -202,7 +201,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
srcPath_ = srcPath_.simplified();
sourceBounds_ = srcPath_.boundingRect();
- geoLeftBound_ = map.screenPositionToCoordinate(QDoubleVector2D(minX, 0), false);
+ geoLeftBound_ = map.itemPositionToCoordinate(QDoubleVector2D(minX, 0), false);
}
/*!
@@ -218,7 +217,7 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
return;
}
- QDoubleVector2D origin = map.coordinateToScreenPosition(srcOrigin_, false);
+ QDoubleVector2D origin = map.coordinateToItemPosition(srcOrigin_, false);
// Create the viewport rect in the same coordinate system
// as the actual points
@@ -381,21 +380,18 @@ QJSValue QDeclarativePolygonMapItem::path() const
{
QQmlContext *context = QQmlEngine::contextForObject(parent());
QQmlEngine *engine = context->engine();
- QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(engine);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
QV4::Scope scope(v4);
QV4::Scoped<QV4::ArrayObject> pathArray(scope, v4->newArrayObject(path_.length()));
for (int i = 0; i < path_.length(); ++i) {
const QGeoCoordinate &c = path_.at(i);
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
- QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
-
+ QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c)));
pathArray->putIndexed(i, cv);
}
- return new QJSValuePrivate(v4, QV4::ValueRef(pathArray));
+ return QJSValue(v4, pathArray.asReturnedValue());
}
void QDeclarativePolygonMapItem::setPath(const QJSValue &value)
@@ -612,7 +608,7 @@ void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, cons
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid()) {
double firstLongitude = path_.at(0).longitude();
double firstLatitude = path_.at(0).latitude();
diff --git a/src/imports/location/qdeclarativepolygonmapitem_p.h b/src/imports/location/qdeclarativepolygonmapitem_p.h
index 1a41d154..19a79be6 100644
--- a/src/imports/location/qdeclarativepolygonmapitem_p.h
+++ b/src/imports/location/qdeclarativepolygonmapitem_p.h
@@ -38,7 +38,6 @@
#include "qdeclarativepolylinemapitem_p.h"
#include "qgeomapitemgeometry_p.h"
-#include <QtQml/private/qv8engine_p.h>
#include <QSGGeometryNode>
#include <QSGFlatColorMaterial>
diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp
index 667b7f28..d8088dfe 100644
--- a/src/imports/location/qdeclarativepolylinemapitem.cpp
+++ b/src/imports/location/qdeclarativepolylinemapitem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
- ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+ ** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtLocation module of the Qt Toolkit.
@@ -40,10 +40,7 @@
#include <QtCore/QScopedValueRollback>
#include <QtQml/QQmlInfo>
-#include <QtQml/QQmlContext>
#include <QtQml/private/qqmlengine_p.h>
-#include <private/qqmlvaluetypewrapper_p.h>
-#include <private/qjsvalue_p.h>
#include <QPainter>
#include <QPainterPath>
#include <QPainterPathStroker>
@@ -201,7 +198,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
double unwrapBelowX = 0;
if (preserveGeometry_)
- unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
+ unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
for (int i = 0; i < path.size(); ++i) {
const QGeoCoordinate &coord = path.at(i);
@@ -209,7 +206,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QDoubleVector2D point = map.coordinateToScreenPosition(coord, false);
+ QDoubleVector2D point = map.coordinateToItemPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -217,7 +214,9 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
return;
// unwrap x to preserve geometry if moved to border of map
- if (preserveGeometry_ && point.x() < unwrapBelowX && !qFuzzyCompare(point.x(), unwrapBelowX))
+ if (preserveGeometry_ && point.x() < unwrapBelowX
+ && !qFuzzyCompare(geoLeftBound_.longitude(), coord.longitude())
+ && !qFuzzyCompare(point.x(), unwrapBelowX))
point.setX(unwrapBelowX + geoDistanceToScreenWidth(map, geoLeftBound_, coord));
if (!foundValid) {
@@ -254,7 +253,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
}
sourceBounds_ = QRectF(QPointF(minX, minY), QPointF(maxX, maxY));
- geoLeftBound_ = map.screenPositionToCoordinate(
+ geoLeftBound_ = map.itemPositionToCoordinate(
QDoubleVector2D(minX + origin.x(), minY + origin.y()), false);
}
@@ -381,7 +380,7 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
if (!screenDirty_)
return;
- QPointF origin = map.coordinateToScreenPosition(srcOrigin_, false).toPointF();
+ QPointF origin = map.coordinateToItemPosition(srcOrigin_, false).toPointF();
if (!qIsFinite(origin.x()) || !qIsFinite(origin.y())) {
clear();
@@ -488,21 +487,18 @@ QJSValue QDeclarativePolylineMapItem::path() const
{
QQmlContext *context = QQmlEngine::contextForObject(parent());
QQmlEngine *engine = context->engine();
- QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(engine);
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
QV4::Scope scope(v4);
QV4::Scoped<QV4::ArrayObject> pathArray(scope, v4->newArrayObject(path_.length()));
for (int i = 0; i < path_.length(); ++i) {
const QGeoCoordinate &c = path_.at(i);
- QQmlValueType *vt = QQmlValueTypeFactory::valueType(qMetaTypeId<QGeoCoordinate>());
- QV4::ScopedValue cv(scope, QV4::QmlValueTypeWrapper::create(v8Engine, QVariant::fromValue(c), vt));
-
+ QV4::ScopedValue cv(scope, v4->fromVariant(QVariant::fromValue(c)));
pathArray->putIndexed(i, cv);
}
- return new QJSValuePrivate(v4, QV4::ValueRef(pathArray));
+ return QJSValue(v4, pathArray.asReturnedValue());
}
void QDeclarativePolylineMapItem::setPath(const QJSValue &value)
@@ -610,7 +606,7 @@ void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, con
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
- QGeoCoordinate newCoordinate = map()->screenPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid()) {
double firstLongitude = path_.at(0).longitude();
double firstLatitude = path_.at(0).latitude();
diff --git a/src/imports/location/qdeclarativepolylinemapitem_p.h b/src/imports/location/qdeclarativepolylinemapitem_p.h
index 5767e652..7484cc11 100644
--- a/src/imports/location/qdeclarativepolylinemapitem_p.h
+++ b/src/imports/location/qdeclarativepolylinemapitem_p.h
@@ -37,8 +37,6 @@
#include "qdeclarativegeomapitembase_p.h"
#include "qgeomapitemgeometry_p.h"
-#include <QtQml/private/qv8engine_p.h>
-
#include <QSGGeometryNode>
#include <QSGFlatColorMaterial>
diff --git a/src/imports/location/qdeclarativerectanglemapitem.cpp b/src/imports/location/qdeclarativerectanglemapitem.cpp
index 8898be15..49ae6cc2 100644
--- a/src/imports/location/qdeclarativerectanglemapitem.cpp
+++ b/src/imports/location/qdeclarativerectanglemapitem.cpp
@@ -128,8 +128,8 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
if (!screenDirty_ && !sourceDirty_)
return;
- QDoubleVector2D tl = map.coordinateToScreenPosition(topLeft, false);
- QDoubleVector2D br = map.coordinateToScreenPosition(bottomRight, false);
+ QDoubleVector2D tl = map.coordinateToItemPosition(topLeft, false);
+ QDoubleVector2D br = map.coordinateToItemPosition(bottomRight, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -139,7 +139,7 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
return;
if ( preserveGeometry_ ) {
- double unwrapBelowX = map.coordinateToScreenPosition(geoLeftBound_, false).x();
+ double unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
if (br.x() < unwrapBelowX)
br.setX(tl.x() + screenBounds_.width());
}
@@ -423,7 +423,7 @@ void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, co
}
QDoubleVector2D newTopLeftPoint = QDoubleVector2D(x(),y());
- QGeoCoordinate newTopLeft = map()->screenPositionToCoordinate(newTopLeftPoint, false);
+ QGeoCoordinate newTopLeft = map()->itemPositionToCoordinate(newTopLeftPoint, false);
if (newTopLeft.isValid()) {
// calculate new geo width while checking for dateline crossing
const double lonW = bottomRight_.longitude() > topLeft_.longitude() ?
diff --git a/src/imports/location/qgeomapitemgeometry.cpp b/src/imports/location/qgeomapitemgeometry.cpp
index db8a4db0..28117e25 100644
--- a/src/imports/location/qgeomapitemgeometry.cpp
+++ b/src/imports/location/qgeomapitemgeometry.cpp
@@ -119,14 +119,17 @@ double QGeoMapItemGeometry::geoDistanceToScreenWidth(const QGeoMap &map,
const QGeoCoordinate &fromCoord,
const QGeoCoordinate &toCoord)
{
- QGeoCoordinate mapMid = map.screenPositionToCoordinate(QDoubleVector2D(map.width()/2.0, 0));
+ // Do not wrap around half the globe
+ Q_ASSERT(!qFuzzyCompare(fromCoord.longitude(), toCoord.longitude()));
+
+ QGeoCoordinate mapMid = map.itemPositionToCoordinate(QDoubleVector2D(map.width()/2.0, 0));
double halfGeoDist = toCoord.longitude() - fromCoord.longitude();
if (toCoord.longitude() < fromCoord.longitude())
halfGeoDist += 360;
halfGeoDist /= 2.0;
QGeoCoordinate geoDelta = QGeoCoordinate(0,
QLocationUtils::wrapLong(mapMid.longitude() + halfGeoDist));
- QDoubleVector2D halfScreenDist = map.coordinateToScreenPosition(geoDelta, false)
+ QDoubleVector2D halfScreenDist = map.coordinateToItemPosition(geoDelta, false)
- QDoubleVector2D(map.width()/2.0, 0);
return halfScreenDist.x() * 2.0;
}
diff --git a/src/imports/positioning/locationvaluetypeprovider.cpp b/src/imports/positioning/locationvaluetypeprovider.cpp
deleted file mode 100644
index 6a7007f6..00000000
--- a/src/imports/positioning/locationvaluetypeprovider.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "locationvaluetypeprovider.h"
-#include "qdeclarativecoordinate_p.h"
-#include "qdeclarativegeoshape.h"
-#include "qdeclarativegeorectangle.h"
-#include "qdeclarativegeocircle.h"
-#include <QtPositioning/QGeoRectangle>
-#include <QtPositioning/QGeoCircle>
-
-QT_BEGIN_NAMESPACE
-
-LocationValueTypeProvider::LocationValueTypeProvider()
-: QQmlValueTypeProvider()
-{
-}
-
-bool LocationValueTypeProvider::create(int type, QQmlValueType *&v)
-{
- if (type == qMetaTypeId<QGeoCoordinate>())
- return typedCreate<CoordinateValueType>(v);
- else if (type == qMetaTypeId<QGeoShape>())
- return typedCreate<GeoShapeValueType>(v);
- else if (type == qMetaTypeId<QGeoRectangle>())
- return typedCreate<GeoRectangleValueType>(v);
- else if (type == qMetaTypeId<QGeoCircle>())
- return typedCreate<GeoCircleValueType>(v);
-
- return false;
-}
-
-bool LocationValueTypeProvider::init(int type, void *data, size_t dataSize)
-{
- if (type == qMetaTypeId<QGeoCoordinate>())
- return typedInit<QGeoCoordinate>(data, dataSize);
- else if (type == qMetaTypeId<QGeoShape>())
- return typedInit<QGeoShape>(data, dataSize);
- else if (type == qMetaTypeId<QGeoRectangle>())
- return typedInit<QGeoRectangle>(data, dataSize);
- else if (type == qMetaTypeId<QGeoCircle>())
- return typedInit<QGeoCircle>(data, dataSize);
-
- return false;
-}
-
-bool LocationValueTypeProvider::destroy(int type, void *data, size_t dataSize)
-{
- if (type == qMetaTypeId<QGeoCoordinate>())
- return typedDestroy<QGeoCoordinate>(data, dataSize);
- else if (type == qMetaTypeId<QGeoShape>())
- return typedDestroy<QGeoShape>(data, dataSize);
- else if (type == qMetaTypeId<QGeoRectangle>())
- return typedDestroy<QGeoRectangle>(data, dataSize);
- else if (type == qMetaTypeId<QGeoCircle>())
- return typedDestroy<QGeoCircle>(data, dataSize);
-
- return false;
-}
-
-bool LocationValueTypeProvider::copy(int type, const void *src, void *dst, size_t dstSize)
-{
- if (type == qMetaTypeId<QGeoCoordinate>())
- return typedCopyConstruct<QGeoCoordinate>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoShape>())
- return typedCopyConstruct<QGeoShape>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoRectangle>())
- return typedCopyConstruct<QGeoRectangle>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoCircle>())
- return typedCopyConstruct<QGeoCircle>(src, dst, dstSize);
-
- return false;
-}
-
-bool LocationValueTypeProvider::create(int type, int argc, const void *argv[], QVariant *v)
-{
- if (type == qMetaTypeId<QGeoCoordinate>()) {
- if (argc == 2) {
- const float *a = reinterpret_cast<const float *>(argv[0]);
- const float *b = reinterpret_cast<const float *>(argv[1]);
- *v = QVariant::fromValue(QGeoCoordinate(*a, *b));
- return true;
- } else if (argc == 3) {
- const float *a = reinterpret_cast<const float *>(argv[0]);
- const float *b = reinterpret_cast<const float *>(argv[1]);
- const float *c = reinterpret_cast<const float *>(argv[2]);
- *v = QVariant::fromValue(QGeoCoordinate(*a, *b, *c));
- return true;
- }
- }
-
- return false;
-}
-
-bool LocationValueTypeProvider::createFromString(int type, const QString &s, void *data, size_t dataSize)
-{
- Q_UNUSED(data)
- Q_UNUSED(dataSize)
-
- if (type == qMetaTypeId<QGeoCoordinate>() || type == qMetaTypeId<QGeoShape>() ||
- type == qMetaTypeId<QGeoRectangle>() || type == qMetaTypeId<QGeoCircle>()) {
- qWarning("Cannot create value type %d from string '%s'", type, qPrintable(s));
- }
-
- return false;
-}
-
-bool LocationValueTypeProvider::createStringFrom(int type, const void *data, QString *s)
-{
- Q_UNUSED(data)
- Q_UNUSED(s)
-
- if (type == qMetaTypeId<QGeoCoordinate>() || type == qMetaTypeId<QGeoShape>() ||
- type == qMetaTypeId<QGeoRectangle>() || type == qMetaTypeId<QGeoCircle>()) {
- qWarning("Cannot create string from value type %d", type);
- }
-
- return false;
-}
-
-bool LocationValueTypeProvider::variantFromJsObject(int type, QQmlV4Handle h, QV8Engine *e, QVariant *v)
-{
- Q_UNUSED(h)
- Q_UNUSED(e)
- Q_UNUSED(v)
-
- if (type == qMetaTypeId<QGeoCoordinate>() || type == qMetaTypeId<QGeoShape>() ||
- type == qMetaTypeId<QGeoRectangle>() || type == qMetaTypeId<QGeoCircle>()) {
- qWarning("Cannot create variant from js object for type %d", type);
- }
-
- return false;
-}
-
-bool LocationValueTypeProvider::equal(int type, const void *lhs, const void *rhs, size_t rhsSize)
-{
- Q_UNUSED(rhsSize)
-
- if (type == qMetaTypeId<QGeoCoordinate>())
- return typedEqual<QGeoCoordinate>(lhs, rhs);
- else if (type == qMetaTypeId<QGeoShape>())
- return typedEqual<QGeoShape>(lhs, rhs);
- else if (type == qMetaTypeId<QGeoRectangle>())
- return typedEqual<QGeoRectangle>(lhs, rhs);
- else if (type == qMetaTypeId<QGeoCircle>())
- return typedEqual<QGeoCircle>(lhs, rhs);
-
- return false;
-}
-
-bool LocationValueTypeProvider::store(int type, const void *src, void *dst, size_t dstSize)
-{
- if (type == qMetaTypeId<QGeoCoordinate>())
- return typedStore<QGeoCoordinate>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoShape>())
- return typedStore<QGeoShape>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoRectangle>())
- return typedStore<QGeoRectangle>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoCircle>())
- return typedStore<QGeoCircle>(src, dst, dstSize);
-
- return false;
-}
-
-bool LocationValueTypeProvider::read(int srcType, const void *src, size_t srcSize, int dstType, void *dst)
-{
- if (srcType == qMetaTypeId<QGeoCoordinate>())
- return typedRead<QGeoCoordinate>(srcType, src, srcSize, dstType, dst);
- else if (srcType == qMetaTypeId<QGeoShape>())
- return typedRead<QGeoShape>(srcType, src, srcSize, dstType, dst);
- else if (srcType == qMetaTypeId<QGeoRectangle>())
- return typedRead<QGeoRectangle>(srcType, src, srcSize, dstType, dst);
- else if (srcType == qMetaTypeId<QGeoCircle>())
- return typedRead<QGeoCircle>(srcType, src, srcSize, dstType, dst);
-
- return false;
-}
-
-bool LocationValueTypeProvider::write(int type, const void *src, void *dst, size_t dstSize)
-{
- if (type == qMetaTypeId<QGeoCoordinate>())
- return typedWrite<QGeoCoordinate>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoShape>())
- return typedWrite<QGeoShape>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoRectangle>())
- return typedWrite<QGeoRectangle>(src, dst, dstSize);
- else if (type == qMetaTypeId<QGeoCircle>())
- return typedWrite<QGeoCircle>(src, dst, dstSize);
-
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/positioning/locationvaluetypeprovider.h b/src/imports/positioning/locationvaluetypeprovider.h
deleted file mode 100644
index c6cc3fe5..00000000
--- a/src/imports/positioning/locationvaluetypeprovider.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef LOCATIONVALUETYPEPROVIDER_H
-#define LOCATIONVALUETYPEPROVIDER_H
-
-#include <QtQml/private/qqmlglobal_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class LocationValueTypeProvider : public QQmlValueTypeProvider
-{
-public:
- LocationValueTypeProvider();
-
-private:
- template<typename T>
- bool typedCreate(QQmlValueType *&v)
- {
- v = new T;
- return true;
- }
-
- bool create(int type, QQmlValueType *&v) Q_DECL_OVERRIDE;
-
- template<typename T>
- bool typedInit(void *data, size_t dataSize)
- {
- Q_ASSERT(dataSize >= sizeof(T));
- Q_UNUSED(dataSize);
- T *t = reinterpret_cast<T *>(data);
- new (t) T();
- return true;
- }
-
- bool init(int type, void *data, size_t dataSize) Q_DECL_OVERRIDE;
-
- template<typename T>
- bool typedDestroy(void *data, size_t dataSize)
- {
- Q_ASSERT(dataSize >= sizeof(T));
- Q_UNUSED(dataSize);
- T *t = reinterpret_cast<T *>(data);
- t->~T();
- return true;
- }
-
- bool destroy(int type, void *data, size_t dataSize) Q_DECL_OVERRIDE;
-
- template<typename T>
- bool typedCopyConstruct(const void *src, void *dst, size_t dstSize)
- {
- Q_ASSERT(dstSize >= sizeof(T));
- Q_UNUSED(dstSize);
- const T *srcT = reinterpret_cast<const T *>(src);
- T *dstT = reinterpret_cast<T *>(dst);
- new (dstT) T(*srcT);
- return true;
- }
-
- bool copy(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE;
-
- bool create(int type, int argc, const void *argv[], QVariant *v) Q_DECL_OVERRIDE;
- bool createFromString(int type, const QString &s, void *data, size_t dataSize) Q_DECL_OVERRIDE;
- bool createStringFrom(int type, const void *data, QString *s) Q_DECL_OVERRIDE;
-
- bool variantFromJsObject(int type, QQmlV4Handle h, QV8Engine *e, QVariant *v) Q_DECL_OVERRIDE;
-
- template<typename T>
- bool typedEqual(const void *lhs, const void *rhs)
- {
- return *reinterpret_cast<const T *>(lhs) == *reinterpret_cast<const T *>(rhs);
- }
-
- bool equal(int type, const void *lhs, const void *rhs, size_t rhsSize) Q_DECL_OVERRIDE;
-
- template<typename T>
- bool typedStore(const void *src, void *dst, size_t dstSize)
- {
- Q_ASSERT(dstSize >= sizeof(T));
- Q_UNUSED(dstSize);
- const T *srcT = reinterpret_cast<const T *>(src);
- T *dstT = reinterpret_cast<T *>(dst);
- new (dstT) T(*srcT);
- return true;
- }
-
- bool store(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE;
-
- template<typename T>
- bool typedRead(int srcType, const void *src, size_t srcSize, int dstType, void *dst)
- {
- T *dstT = reinterpret_cast<T *>(dst);
- if (srcType == dstType) {
- Q_ASSERT(srcSize >= sizeof(T));
- Q_UNUSED(srcSize);
- const T *srcT = reinterpret_cast<const T *>(src);
- *dstT = *srcT;
- } else {
- *dstT = T();
- }
- return true;
- }
-
- bool read(int srcType, const void *src, size_t srcSize, int dstType, void *dst) Q_DECL_OVERRIDE;
-
- template<typename T>
- bool typedWrite(const void *src, void *dst, size_t dstSize)
- {
- Q_ASSERT(dstSize >= sizeof(T));
- Q_UNUSED(dstSize);
- const T *srcT = reinterpret_cast<const T *>(src);
- T *dstT = reinterpret_cast<T *>(dst);
- if (*dstT != *srcT) {
- *dstT = *srcT;
- return true;
- }
- return false;
- }
-
- bool write(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE;
-};
-
-QT_END_NAMESPACE
-
-#endif // LOCATIONVALUETYPEPROVIDER_H
diff --git a/src/imports/positioning/positioning.cpp b/src/imports/positioning/positioning.cpp
index d7791eb0..e87989a1 100644
--- a/src/imports/positioning/positioning.cpp
+++ b/src/imports/positioning/positioning.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -31,7 +31,6 @@
**
****************************************************************************/
-#include "locationvaluetypeprovider.h"
#include <QtPositioning/private/qdeclarativegeoaddress_p.h>
#include <QtPositioning/private/qdeclarativegeolocation_p.h>
@@ -39,21 +38,13 @@
#include "qdeclarativepositionsource_p.h"
#include "qdeclarativeposition_p.h"
-#include "qdeclarativegeoshape.h"
-#include "qdeclarativegeorectangle.h"
-#include "qdeclarativegeocircle.h"
-#include "qdeclarativecoordinate_p.h"
#include "qdeclarativegeocoordinateanimation_p.h"
-
#include "locationsingleton.h"
#include <QtCore/QVariantAnimation>
#include <QtQml/qqmlextensionplugin.h>
-#include <QtQml/qqml.h>
#include <QtQml/private/qqmlvaluetype_p.h>
-#include <QtQml/private/qqmlglobal_p.h>
-#include <QtQml/private/qqmlmetatype_p.h>
#include <QtPositioning/QGeoRectangle>
#include <QtPositioning/QGeoCircle>
@@ -63,6 +54,423 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmlbasictype coordinate
+ \inqmlmodule QtPositioning
+ \ingroup qml-QtPositioning5-basictypes
+ \since 5.2
+
+ \brief The coordinate type represents and stores a geographic position.
+
+ This type is a QML representation of \l QGeoCoordinate and represents a geographic
+ position in the form of \l {latitude}, \l longitude and \l altitude attributes.
+ The \l latitude attribute specifies the number of
+ decimal degrees above and below the equator. A positive latitude indicates the Northern
+ Hemisphere and a negative latitude indicates the Southern Hemisphere. The \l longitude
+ attribute specifies the number of decimal degrees east and west. A positive longitude
+ indicates the Eastern Hemisphere and a negative longitude indicates the Western Hemisphere.
+ The \l altitude attribute specifies the number of meters above sea level. Together, these
+ attributes specify a 3-dimensional position anywhere on or near the Earth's surface.
+
+ The \l isValid attribute can be used to test if a coordinate is valid. A coordinate is
+ considered valid if it has a valid latitude and longitude. A valid altitude is not required.
+ The latitude must be between -90 and 90 inclusive and the longitude must be between -180 and
+ 180 inclusive.
+
+ The \c coordinate type is used by many other types in the Qt Location module, for specifying
+ the position of an object on a Map, the current position of a device and many other tasks.
+ They also feature a number of important utility methods that make otherwise complex
+ calculations simple to use, such as \l {atDistanceAndAzimuth}().
+
+ \section1 Accuracy
+
+ The latitude, longitude and altitude attributes stored in the coordinate type are represented
+ as doubles, giving them approximately 16 decimal digits of precision -- enough to specify
+ micrometers. The calculations performed in coordinate's methods such as \l azimuthTo() and
+ \l distanceTo() also use doubles for all intermediate values, but the inherent inaccuracies in
+ their spherical Earth model dominate the amount of error in their output.
+
+ \section1 Example Usage
+
+ Use properties of type \l variant to store a \c {coordinate}. To create a \c coordinate use
+ one of the methods described below. In all cases, specifying the \l altitude attribute is
+ optional.
+
+ To create a \c coordinate value, use the \l{QtPositioning::coordinate}{QtPositioning.coordinate()}
+ function:
+
+ \qml
+ import QtPositioning 5.2
+
+ Location { coordinate: QtPositioning.coordinate(-27.5, 153.1) }
+ \endqml
+
+ or as separate \l latitude, \l longitude and \l altitude components:
+
+ \qml
+ Location {
+ coordinate {
+ latitude: -27.5
+ longitude: 153.1
+ }
+ }
+ \endqml
+
+ When integrating with C++, note that any QGeoCoordinate value passed into QML from C++ is
+ automatically converted into a \c coordinate value, and vice-versa.
+
+ \section1 Properties
+
+ \section2 latitude
+
+ \code
+ real latitude
+ \endcode
+
+ This property holds the latitude value of the geographical position
+ (decimal degrees). A positive latitude indicates the Northern Hemisphere,
+ and a negative latitude indicates the Southern Hemisphere.
+ If the property has not been set, its default value is NaN.
+
+ \section2 longitude
+
+ \code
+ real longitude
+ \endcode
+
+ This property holds the longitude value of the geographical position
+ (decimal degrees). A positive longitude indicates the Eastern Hemisphere,
+ and a negative longitude indicates the Western Hemisphere
+ If the property has not been set, its default value is NaN.
+
+ \section2 altitude
+
+ \code
+ real altitude
+ \endcode
+
+ This property holds the altitude value (meters above sea level).
+ If the property has not been set, its default value is NaN.
+
+ \section2 isValid
+
+ \code
+ bool isValid
+ \endcode
+
+ This property holds the current validity of the coordinate. Coordinates
+ are considered valid if they have been set with a valid latitude and
+ longitude (altitude is not required).
+
+ The latitude must be between -90 to 90 inclusive to be considered valid,
+ and the longitude must be between -180 to 180 inclusive to be considered
+ valid.
+
+ This is a read-only property.
+
+ \section1 Methods
+
+ \section2 distanceTo()
+
+ \code
+ real distanceTo(coordinate other)
+ \endcode
+
+ Returns the distance (in meters) from this coordinate to the coordinate specified by \a other.
+ Altitude is not used in the calculation.
+
+ This calculation returns the great-circle distance between the two coordinates, with an
+ assumption that the Earth is spherical for the purpose of this calculation.
+
+ \section2 azimuthTo()
+
+ \code
+ real azimuth(coordinate other)
+ \endcode
+
+ Returns the azimuth (or bearing) in degrees from this coordinate to the coordinate specified by
+ \a other. Altitude is not used in the calculation.
+
+ There is an assumption that the Earth is spherical for the purpose of this calculation.
+
+ \section2 atDistanceAndAzimuth()
+
+ \code
+ coordinate atDistanceAndAzimuth(real distance, real azimuth)
+ \endcode
+
+ Returns the coordinate that is reached by traveling \a distance metres from this coordinate at
+ \a azimuth degrees along a great-circle.
+
+ There is an assumption that the Earth is spherical for the purpose of this calculation.
+*/
+
+/*!
+ \qmlbasictype geoshape
+ \inqmlmodule QtPositioning
+ \ingroup qml-QtPositioning5-basictypes
+ \since 5.2
+
+ \brief A geoshape type represents an abstract geographic area.
+
+ This type is a QML representation of \l QGeoShape which is an abstract geographic area.
+ It includes attributes and methods common to all geographic areas. To create objects
+ that represent a valid geographic area use \l {georectangle} or \l {geocircle}.
+
+ The \l isValid attribute can be used to test if the geoshape represents a valid geographic
+ area.
+
+ The \l isEmpty attribute can be used to test if the geoshape represents a region with a
+ geometrical area of 0.
+
+ The \l {contains}{contains()} method can be used to test if a \l {coordinate} is
+ within the geoshape.
+
+ \section1 Example Usage
+
+ Use properties of type \l variant to store a \c {geoshape}. To create a \c geoshape use one
+ of the methods described below.
+
+ To create a \c geoshape value, specify it as a "shape()" string:
+
+ \qml
+ import QtPositioning
+
+ Item {
+ property variant region: "shape()"
+ }
+ \endqml
+
+ or with the \l {QtPositioning::shape}{QtPositioning.shape()} function:
+
+ \qml
+ import QtPositioning 5.2
+
+ Item {
+ property variant region: QtPositioning.shape()
+ }
+ \endqml
+
+ When integrating with C++, note that any QGeoShape value passed into QML from C++ is
+ automatically converted into a \c geoshape value, and vice-versa.
+
+ \section1 Properties
+
+ \section2 isEmpty
+
+ \code
+ bool isEmpty
+ \endcode
+
+ Returns whether this geoshape is empty. An empty geoshape is a region which has
+ a geometrical area of 0.
+
+ \section2 isValid
+
+ \code
+ bool isValid
+ \endcode
+
+ Returns whether this geoshape is valid.
+
+ A geoshape is considered to be invalid if some of the data that is required to
+ unambiguously describe the geoshape has not been set or has been set to an
+ unsuitable value.
+
+ \code
+ ShapeType type
+ \endcode
+
+ Returns the current type of the shape.
+
+ \list
+ \li GeoShape.UnknownType - The shape's type is not known.
+ \li GeoShape.RectangleType - The shape is a \l georectangle.
+ \li GeoShape.CircleType - The shape is a \l geocircle.
+ \endlist
+
+
+ \section1 Methods
+
+ \section2 contains()
+
+ \code
+ bool contains(coordinate coord)
+ \endcode
+
+ Returns true if the \l {QtPositioning::coordinate}{coordinate} specified by \a coord is within
+ this geoshape; Otherwise returns false.
+*/
+
+/*!
+ \qmlbasictype georectangle
+ \inqmlmodule QtPositioning
+ \ingroup qml-QtPositioning5-basictypes
+ \since 5.2
+
+ \brief The georectangle type represents a rectangular geographic area.
+
+ The \c georectangle type is a \l {geoshape} that represents a
+ rectangular geographic area. The type is direct representation of a \l QGeoRectangle.
+ It is defined by a pair of \l {coordinate}{coordinates} which represent the top-left
+ and bottom-right corners of the \c {georectangle}. The coordinates are accessible
+ from the \l topLeft and \l bottomRight attributes.
+
+ A \c georectangle is considered invalid if the top-left or bottom-right coordinates are invalid
+ or if the top-left coordinate is south of the bottom-right coordinate.
+
+ The coordinates of the four corners of the \c georectangle can be accessed with the
+ \l {topLeft}, \l {topRight}, \l {bottomLeft} and \l {bottomRight} attributes. The \l center
+ attribute can be used to get the coordinate of the center of the \c georectangle. The \l width
+ and \l height attributes can be used to get the width and height of the \c georectangle in
+ degrees. Setting one of these attributes will cause the other attributes to be adjusted
+ accordingly.
+
+ \section1 Limitations
+
+ A \c georectangle can never cross the poles.
+
+ If the height or center of a \c georectangle is adjusted such that it would cross one of the
+ poles the height is modified such that the \c georectangle touches but does not cross the pole
+ and that the center coordinate is still in the center of the \c georectangle.
+
+ \section1 Example Usage
+
+ Use properties of type \l variant to store a \c {georectangle}. To create a \c georectangle
+ value, use the \l {QtPositioning::rectangle}{QtPositioning.rectangle()} function:
+
+ \qml
+ import QtPositioning 5.2
+
+ Item {
+ property variant region: QtPositioning.rectangle(QtPositioning.coordinate(-27.5, 153.1), QtPositioning.coordinate(-27.6, 153.2))
+ }
+ \endqml
+
+ When integrating with C++, note that any QGeoRectangle value passed into QML from C++ is
+ automatically converted into a \c georectangle value, and vice-versa.
+
+ \section1 Properties
+
+ \section2 bottomLeft
+
+ \code
+ coordinate bottomLeft
+ \endcode
+
+ This property holds the bottom left coordinate of this georectangle.
+
+ \section2 bottomRight
+
+ \code
+ coordinate bottomRight
+ \endcode
+
+ This property holds the bottom right coordinate of this georectangle.
+
+ \section2 center
+
+ \code
+ coordinate center
+ \endcode
+
+ This property holds the center coordinate of this georectangle. For more details
+ see \l {QGeoRectangle::setCenter()}.
+
+ \section2 height
+
+ \code
+ double height
+ \endcode
+
+ This property holds the height of this georectangle (in degrees). For more details
+ see \l {QGeoRectangle::setHeight()}.
+
+ \note If the georectangle is invalid, it is not possible to set the height. QtPositioning
+ releases prior to Qt 5.5 permitted the setting of the height even on invalid georectangles.
+
+ \section2 topLeft
+
+ \code
+ coordinate topLeft
+ \endcode
+
+ This property holds the top left coordinate of this georectangle.
+
+ \section2 topRight
+
+ \code
+ coordinate topRight
+ \endcode
+
+ This property holds the top right coordinate of this georectangle.
+
+ \section2 width
+
+ \code
+ double width
+ \endcode
+
+ This property holds the width of this georectangle (in degrees). For more details
+ see \l {QGeoRectangle::setWidth()}.
+
+ \note If the georectangle is invalid, it is not possible to set the width. QtPositioning
+ releases prior to Qt 5.5 permitted the setting of the width even on invalid georectangles.
+*/
+
+/*!
+ \qmlbasictype geocircle
+ \inqmlmodule QtPositioning
+ \ingroup qml-QtPositioning5-basictypes
+ \since 5.2
+
+ \brief The geocircle type represents a circular geographic area.
+
+ The \c geocircle type is a \l {geoshape} that represents a circular
+ geographic area. It is a direct representation of a \l QGeoCircle and is defined
+ in terms of a \l {coordinate} which specifies the \l center of the circle and
+ a qreal which specifies the \l radius of the circle in meters.
+
+ The circle is considered invalid if the \l center coordinate is invalid or if
+ the \l radius is less than zero.
+
+ \section1 Example Usage
+
+ Use properties of type \l variant to store a \c {geocircle}. To create a \c geocircle value,
+ use the \l {QtPositioning::circle}{QtPositioning.circle()} function:
+
+ \qml
+ import QtPositioning 5.2
+
+ Item {
+ property variant region: QtPositioning.circle(QtPositioning.coordinate(-27.5, 153.1), 1000)
+ }
+ \endqml
+
+ When integrating with C++, note that any QGeoCircle value passed into QML from C++ is
+ automatically converted into a \c geocircle value, and vise-versa.
+
+ \section1 Properties
+
+ \section2 center
+
+ \code
+ coordinate radius
+ \endcode
+
+ This property holds the coordinate of the center of the geocircle.
+
+ \section2 radius
+
+ \code
+ real radius
+ \endcode
+
+ This property holds the radius of the geocircle in meters.
+
+ The default value for the radius is -1 indicating an invalid geocircle area.
+*/
+
static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine)
{
Q_UNUSED(engine)
@@ -71,12 +479,6 @@ static QObject *singleton_type_factory(QQmlEngine *engine, QJSEngine *jsEngine)
return new LocationSingleton;
}
-static LocationValueTypeProvider *getValueTypeProvider()
-{
- static LocationValueTypeProvider provider;
- return &provider;
-}
-
class QtPositioningDeclarativeModule: public QQmlExtensionPlugin
{
Q_OBJECT
@@ -94,19 +496,23 @@ public:
int major = 5;
int minor = 0;
- qRegisterMetaType<QGeoCoordinate>("QGeoCoordinate");
- qRegisterMetaType<QGeoAddress>("QGeoAddress");
- qRegisterMetaType<QGeoRectangle>("QGeoRectangle");
- qRegisterMetaType<QGeoCircle>("QGeoCircle");
- qRegisterMetaType<QGeoLocation>("QGeoLocation");
+ qRegisterMetaType<QGeoCoordinate>();
+ QMetaType::registerEqualsComparator<QGeoCoordinate>();
+ qRegisterMetaType<QGeoAddress>();
+ qRegisterMetaType<QGeoRectangle>();
+ QMetaType::registerEqualsComparator<QGeoRectangle>();
+ qRegisterMetaType<QGeoCircle>();
+ QMetaType::registerEqualsComparator<QGeoCircle>();
+ qRegisterMetaType<QGeoLocation>();
+ qRegisterMetaType<QGeoShape>();
+ QMetaType::registerEqualsComparator<QGeoShape>();
qRegisterAnimationInterpolator<QGeoCoordinate>(geoCoordinateInterpolator);
- QQml_addValueTypeProvider(getValueTypeProvider());
// Register the 5.0 types
// 5.0 is silent and not advertised
qmlRegisterSingletonType<LocationSingleton >(uri, major, minor, "QtPositioning", singleton_type_factory);
- qmlRegisterValueTypeEnums<GeoShapeValueType >(uri, major, minor, "GeoShape");
+ qmlRegisterValueTypeEnums<QGeoShape >(uri, major, minor, "GeoShape");
qmlRegisterType<QDeclarativePosition >(uri, major, minor, "Position");
qmlRegisterType<QDeclarativePositionSource >(uri, major, minor, "PositionSource");
qmlRegisterType<QDeclarativeGeoAddress >(uri, major, minor, "Address");
diff --git a/src/imports/positioning/positioning.pro b/src/imports/positioning/positioning.pro
index d07dbce9..7e49ec8e 100644
--- a/src/imports/positioning/positioning.pro
+++ b/src/imports/positioning/positioning.pro
@@ -1,26 +1,15 @@
QT += quick-private positioning-private qml-private core-private
INCLUDEPATH *= $$PWD
-DEFINES += TOUCH_EVENT_WORKAROUND
HEADERS += qdeclarativeposition_p.h \
qdeclarativepositionsource_p.h \
- qdeclarativecoordinate_p.h \
- qdeclarativegeoshape.h \
- qdeclarativegeorectangle.h \
- qdeclarativegeocircle.h \
- locationvaluetypeprovider.h \
locationsingleton.h \
qdeclarativegeocoordinateanimation_p.h
SOURCES += qdeclarativeposition.cpp \
positioning.cpp \
qdeclarativepositionsource.cpp \
- qdeclarativecoordinate.cpp \
- qdeclarativegeoshape.cpp \
- qdeclarativegeorectangle.cpp \
- qdeclarativegeocircle.cpp \
- locationvaluetypeprovider.cpp \
locationsingleton.cpp \
qdeclarativegeocoordinateanimation.cpp
diff --git a/src/imports/positioning/qdeclarativecoordinate.cpp b/src/imports/positioning/qdeclarativecoordinate.cpp
deleted file mode 100644
index 37b0a4a3..00000000
--- a/src/imports/positioning/qdeclarativecoordinate.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativecoordinate_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlbasictype coordinate
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief The coordinate type represents and stores a geographic position.
-
- The \c coordinate type represents a geographic position in the form of \l {latitude},
- \l longitude and \l altitude attributes. The \l latitude attribute specifies the number of
- decimal degrees above and below the equator. A positive latitude indicates the Northern
- Hemisphere and a negative latitude indicates the Southern Hemisphere. The \l longitude
- attribute specifies the number of decimal degrees east and west. A positive longitude
- indicates the Eastern Hemisphere and a negative longitude indicates the Western Hemisphere.
- The \l altitude attribute specifies the number of meters above sea level. Together, these
- attributes specify a 3-dimensional position anywhere on or near the Earth's surface.
-
- The \l isValid attribute can be used to test if a coordinate is valid. A coordinate is
- considered valid if it has a valid latitude and longitude. A valid altitude is not required.
- The latitude must be between -90 and 90 inclusive and the longitude must be between -180 and
- 180 inclusive.
-
- The coordinate type is used by many other types in the Qt Location module, for specifying
- the position of an object on a Map, the current position of a device and many other tasks.
- They also feature a number of important utility methods that make otherwise complex
- calculations simple to use, such as \l atDistanceAndAzimuth().
-
- \section1 Accuracy
-
- The latitude, longitude and altitude attributes stored in the coordinate type are represented
- as doubles, giving them approximately 16 decimal digits of precision -- enough to specify
- micrometers. The calculations performed in coordinate's methods such as \l azimuthTo() and
- \l distanceTo() also use doubles for all intermediate values, but the inherent inaccuracies in
- their spherical Earth model dominate the amount of error in their output.
-
- \section1 Example Usage
-
- Use properties of type \l variant to store a \c {coordinate}. To create a \c coordinate use
- one of the methods described below. In all cases, specifying the \l altitude attribute is
- optional.
-
- To create a \c coordinate value, use the \l{QtPositioning::coordinate}{QtPositioning.coordinate()}
- function:
-
- \qml
- import QtPositioning 5.2
-
- Location { coordinate: QtPositioning.coordinate(-27.5, 153.1) }
- \endqml
-
- or as separate \l latitude, \l longitude and \l altitude components:
-
- \qml
- Location {
- coordinate {
- latitude: -27.5
- longitude: 153.1
- }
- }
- \endqml
-
- When integrating with C++, note that any QGeoCoordinate value passed into QML from C++ is
- automatically converted into a \c coordinate value, and vice-versa.
-
- \section1 Properties
-
- \section2 latitude
-
- \code
- real latitude
- \endcode
-
- This property holds latitude value of the geographical position
- (decimal degrees). A positive latitude indicates the Northern Hemisphere,
- and a negative latitude indicates the Southern Hemisphere.
- If the property has not been set, its default value is NaN.
-
- \section2 longitude
-
- \code
- real longitude
- \endcode
-
- This property holds the longitude value of the geographical position
- (decimal degrees). A positive longitude indicates the Eastern Hemisphere,
- and a negative longitude indicates the Western Hemisphere
- If the property has not been set, its default value is NaN.
-
- \section2 altitude
-
- \code
- real altitude
- \endcode
-
- This property holds the value of altitude (meters above sea level).
- If the property has not been set, its default value is NaN.
-
- \section2 isValid
-
- \code
- bool isValid
- \endcode
-
- This property holds the current validity of the coordinate. Coordinates
- are considered valid if they have been set with a valid latitude and
- longitude (altitude is not required).
-
- The latitude must be between -90 to 90 inclusive to be considered valid,
- and the longitude must be between -180 to 180 inclusive to be considered
- valid.
-
- This is a read-only property.
-
- \section1 Methods
-
- \section2 distanceTo()
-
- \code
- real distanceTo(coordinate other)
- \endcode
-
- Returns the distance (in meters) from this coordinate to the coordinate specified by \a other.
- Altitude is not used in the calculation.
-
- This calculation returns the great-circle distance between the two coordinates, with an
- assumption that the Earth is spherical for the purpose of this calculation.
-
- \section2 azimuthTo()
-
- \code
- real azimuth(coordinate other)
- \endcode
-
- Returns the azimuth (or bearing) in degrees from this coordinate to the coordinate specified by
- \a other. Altitude is not used in the calculation.
-
- There is an assumption that the Earth is spherical for the purpose of this calculation.
-
- \section2 atDistanceAndAzimuth()
-
- \code
- coordinate atDistanceAndAzimuth(real distance, real azimuth)
- \endcode
-
- Returns the coordinate that is reached by traveling \a distance metres from this coordinate at
- \a azimuth degrees along a great-circle.
-
- There is an assumption that the Earth is spherical for the purpose of this calculation.
-*/
-
-
-CoordinateValueType::CoordinateValueType(QObject *parent)
-: QQmlValueTypeBase<QGeoCoordinate>(qMetaTypeId<QGeoCoordinate>(), parent)
-{
-}
-
-CoordinateValueType::~CoordinateValueType()
-{
-}
-
-/*
- This property holds the value of altitude (meters above sea level).
- If the property has not been set, its default value is NaN.
-
-*/
-void CoordinateValueType::setAltitude(double altitude)
-{
- v.setAltitude(altitude);
-}
-
-double CoordinateValueType::altitude() const
-{
- return v.altitude();
-}
-
-/*
- This property holds the longitude value of the geographical position
- (decimal degrees). A positive longitude indicates the Eastern Hemisphere,
- and a negative longitude indicates the Western Hemisphere
- If the property has not been set, its default value is NaN.
-*/
-void CoordinateValueType::setLongitude(double longitude)
-{
- v.setLongitude(longitude);
-}
-
-double CoordinateValueType::longitude() const
-{
- return v.longitude();
-}
-
-/*
- This property holds latitude value of the geographical position
- (decimal degrees). A positive latitude indicates the Northern Hemisphere,
- and a negative latitude indicates the Southern Hemisphere.
- If the property has not been set, its default value is NaN.
-*/
-void CoordinateValueType::setLatitude(double latitude)
-{
- v.setLatitude(latitude);
-}
-
-double CoordinateValueType::latitude() const
-{
- return v.latitude();
-}
-
-/*
- This property holds the current validity of the coordinate. Coordinates
- are considered valid if they have been set with a valid latitude and
- longitude (altitude is not required).
-
- The latitude must be between -90 to 90 inclusive to be considered valid,
- and the longitude must be between -180 to 180 inclusive to be considered
- valid.
-*/
-bool CoordinateValueType::isValid() const
-{
- return v.isValid();
-}
-
-QString CoordinateValueType::toString() const
-{
- return QStringLiteral("QGeoCoordinate(%1,%2,%3)")
- .arg(v.latitude()).arg(v.longitude()).arg(v.altitude());
-}
-
-bool CoordinateValueType::isEqual(const QVariant &other) const
-{
- if (other.userType() != qMetaTypeId<QGeoCoordinate>())
- return false;
-
- return v == other.value<QGeoCoordinate>();
-}
-
-/*
- Returns the distance (in meters) from this coordinate to the
- coordinate specified by other. Altitude is not used in the calculation.
-
- This calculation returns the great-circle distance between the two
- coordinates, with an assumption that the Earth is spherical for the
- purpose of this calculation.
-*/
-qreal CoordinateValueType::distanceTo(const QGeoCoordinate &coordinate) const
-{
- return v.distanceTo(coordinate);
-}
-
-/*
- Returns the azimuth (or bearing) in degrees from this coordinate to the
- coordinate specified by other. Altitude is not used in the calculation.
-
- There is an assumption that the Earth is spherical for the purpose of
- this calculation.
-*/
-qreal CoordinateValueType::azimuthTo(const QGeoCoordinate &coordinate) const
-{
- return v.azimuthTo(coordinate);
-}
-
-/*
- Returns the coordinate that is reached by traveling distance metres
- from the current coordinate at azimuth degrees along a great-circle.
-
- There is an assumption that the Earth is spherical for the purpose
- of this calculation.
-*/
-QGeoCoordinate CoordinateValueType::atDistanceAndAzimuth(qreal distance, qreal azimuth) const
-{
- return v.atDistanceAndAzimuth(distance, azimuth);
-}
-
-#include "moc_qdeclarativecoordinate_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativegeocircle.cpp b/src/imports/positioning/qdeclarativegeocircle.cpp
deleted file mode 100644
index d76d404a..00000000
--- a/src/imports/positioning/qdeclarativegeocircle.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-***************************************************************************/
-
-#include "qdeclarativegeocircle.h"
-
-#include <QtCore/qnumeric.h>
-#include <QtPositioning/QGeoCircle>
-
-#include <QtCore/QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlbasictype geocircle
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief The geocircle type represents a circular geographic area.
-
- The \c geocircle type is a \l {geoshape} that represents a circular
- geographic area. It is defined in terms of a \l {coordinate} which
- specifies the \l center of the circle and a qreal which specifies the \l radius of the circle
- in meters.
-
- The circle is considered invalid if the \l center coordinate is invalid or if the \l radius is less
- than zero.
-
- \section1 Example Usage
-
- Use properties of type \l variant to store a \c {geocircle}. To create a \c geocircle value,
- use the \l {QtPositioning::circle}{QtPositioning.circle()} function:
-
- \qml
- import QtPositioning 5.2
-
- Item {
- property variant region: QtPositioning.circle(QtPositioning.coordinate(-27.5, 153.1), 1000)
- }
- \endqml
-
- When integrating with C++, note that any QGeoCircle value passed into QML from C++ is
- automatically converted into a \c geocircle value, and vise-versa.
-
- \section1 Properties
-
- \section2 center
-
- \code
- coordinate radius
- \endcode
-
- This property holds the coordinate of the center of the geocircle.
-
- \section2 radius
-
- \code
- real radius
- \endcode
-
- This property holds the radius of the geocircle in meters.
-
- The default value for the radius is -1 indicating an invalid geocircle area.
-*/
-
-GeoCircleValueType::GeoCircleValueType(QObject *parent)
-: GeoShapeValueType(qMetaTypeId<QGeoCircle>(), parent)
-{
-}
-
-GeoCircleValueType::~GeoCircleValueType()
-{
-}
-
-/*
- This property holds the coordinate of the center of the geocircle.
-*/
-QGeoCoordinate GeoCircleValueType::center()
-{
- return QGeoCircle(v).center();
-}
-
-void GeoCircleValueType::setCenter(const QGeoCoordinate &coordinate)
-{
- QGeoCircle c = v;
-
- if (c.center() == coordinate)
- return;
-
- c.setCenter(coordinate);
- v = c;
-}
-
-/*
- This property holds the radius of the geocircle in meters.
-
- The default value for the radius is -1 indicating an invalid geocircle area.
-*/
-qreal GeoCircleValueType::radius() const
-{
- return QGeoCircle(v).radius();
-}
-
-void GeoCircleValueType::setRadius(qreal radius)
-{
- QGeoCircle c = v;
-
- if (c.radius() == radius)
- return;
-
- c.setRadius(radius);
- v = c;
-}
-
-QString GeoCircleValueType::toString() const
-{
- if (v.type() != QGeoShape::CircleType) {
- qWarning("Not a circle");
- return QStringLiteral("QGeoCircle(not a circle)");
- }
-
- QGeoCircle c = v;
- return QStringLiteral("QGeoCircle({%1, %2}, %3)")
- .arg(c.center().latitude())
- .arg(c.center().longitude())
- .arg(c.radius());
-}
-
-void GeoCircleValueType::setValue(const QVariant &value)
-{
- if (value.userType() == qMetaTypeId<QGeoCircle>())
- v = value.value<QGeoCircle>();
- else if (value.userType() == qMetaTypeId<QGeoShape>())
- v = value.value<QGeoShape>();
- else
- v = QGeoCircle();
-
- onLoad();
-}
-
-QVariant GeoCircleValueType::value()
-{
- return QVariant::fromValue(QGeoCircle(v));
-}
-
-void GeoCircleValueType::write(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags)
-{
- QGeoCircle c = v;
- writeProperty(obj, idx, flags, &c);
-}
-
-void GeoCircleValueType::writeVariantValue(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags, QVariant *from)
-{
- if (from->userType() == qMetaTypeId<QGeoCircle>()) {
- writeProperty(obj, idx, flags, from);
- } else if (from->userType() == qMetaTypeId<QGeoShape>()) {
- QGeoCircle c = from->value<QGeoShape>();
- QVariant v = QVariant::fromValue(c);
- writeProperty(obj, idx, flags, &v);
- } else {
- QVariant v = QVariant::fromValue(QGeoCircle());
- writeProperty(obj, idx, flags, &v);
- }
-}
-
-#include "moc_qdeclarativegeocircle.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h b/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
index 5f2a5b39..5f0bb849 100644
--- a/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
+++ b/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
@@ -35,7 +35,7 @@
#define QDECLARATIVEGEOCOORDINATEANIMATION_P_H
#include <QtQuick/private/qquickanimation_p.h>
-#include "qdeclarativecoordinate_p.h"
+#include <QtPositioning/qgeocoordinate.h>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativegeorectangle.cpp b/src/imports/positioning/qdeclarativegeorectangle.cpp
deleted file mode 100644
index 677e1fe9..00000000
--- a/src/imports/positioning/qdeclarativegeorectangle.cpp
+++ /dev/null
@@ -1,349 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-***************************************************************************/
-
-#include "qdeclarativegeorectangle.h"
-
-#include <QtCore/qnumeric.h>
-#include <QtPositioning/QGeoRectangle>
-
-#include <QtCore/QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlbasictype georectangle
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief The georectangle type represents a rectangular geographic area.
-
- The \c georectangle type is a \l {geoshape} that represents a
- rectangular geographic area. It is defined by a pair of
- \l {coordinate}{coordinates} which represent the top-left and bottom-right corners
- of the \c {georectangle}. The coordinates are accessible from the \l topLeft and
- \l bottomRight attributes.
-
- A \c georectangle is considered invalid if the top-left or bottom-right coordinates are invalid
- or if the top-left coordinate is South of the bottom-right coordinate.
-
- The coordinates of the four corners of the \c georectangle can be accessed with the
- \l {topLeft}, \l {topRight}, \l {bottomLeft} and \l {bottomRight} attributes. The \l center
- attribute can be used to get the coordinate of the center of the \c georectangle. The \l width
- and \l height attributes can be used to get the width and height of the \c georectangle in
- degrees. Setting one of these attributes will cause the other attributes to be adjusted
- accordingly.
-
- \section1 Limitations
-
- A \c georectangle can never cross the poles.
-
- If the height or center of a \c georectangle is adjusted such that it would cross one of the
- poles the height is modified such that the \c georectangle touches but does not cross the pole
- and that the center coordinate is still in the center of the \c georectangle.
-
- \section1 Example Usage
-
- Use properties of type \l variant to store a \c {georectangle}. To create a \c georectangle
- value, use the \l {QtPositioning::rectangle}{QtPositioning.rectangle()} function:
-
- \qml
- import QtPositioning 5.2
-
- Item {
- property variant region: QtPositioning.rectangle(QtPositioning.coordinate(-27.5, 153.1), QtPositioning.coordinate(-27.6, 153.2))
- }
- \endqml
-
- When integrating with C++, note that any QGeoRectangle value passed into QML from C++ is
- automatically converted into a \c georectangle value, and vice-versa.
-
- \section1 Properties
-
- \section2 bottomLeft
-
- \code
- coordinate bottomLeft
- \endcode
-
- This property holds the bottom left coordinate of this georectangle.
-
- \section2 bottomRight
-
- \code
- coordinate bottomRight
- \endcode
-
- This property holds the bottom right coordinate of this georectangle.
-
- \section2 center
-
- \code
- coordinate center
- \endcode
-
- This property holds the center coordinate of this georectangle. For more details
- see \l {QGeoRectangle::setCenter()}.
-
- \section2 height
-
- \code
- double height
- \endcode
-
- This property holds the height of this georectangle (in degrees). For more details
- see \l {QGeoRectangle::setHeight()}.
-
- \section2 topLeft
-
- \code
- coordinate topLeft
- \endcode
-
- This property holds the top left coordinate of this georectangle.
-
- \section2 topRight
-
- \code
- coordinate topRight
- \endcode
-
- This property holds the top right coordinate of this georectangle.
-
- \section2 width
-
- \code
- double width
- \endcode
-
- This property holds the width of this georectangle (in degrees). For more details
- see \l {QGeoRectangle::setWidth()}.
-*/
-
-GeoRectangleValueType::GeoRectangleValueType(QObject *parent)
-: GeoShapeValueType(qMetaTypeId<QGeoRectangle>(), parent)
-{
-}
-
-GeoRectangleValueType::~GeoRectangleValueType()
-{
-}
-
-QGeoCoordinate GeoRectangleValueType::bottomLeft()
-{
- return QGeoRectangle(v).bottomLeft();
-}
-
-/*
- This property holds the bottom left coordinate of this georectangle.
-*/
-void GeoRectangleValueType::setBottomLeft(const QGeoCoordinate &coordinate)
-{
- QGeoRectangle r = v;
-
- if (r.bottomLeft() == coordinate)
- return;
-
- r.setBottomLeft(coordinate);
- v = r;
-}
-
-QGeoCoordinate GeoRectangleValueType::bottomRight()
-{
- return QGeoRectangle(v).bottomRight();
-}
-
-/*
- This property holds the bottom right coordinate of this georectangle.
-*/
-void GeoRectangleValueType::setBottomRight(const QGeoCoordinate &coordinate)
-{
- QGeoRectangle r = v;
-
- if (r.bottomRight() == coordinate)
- return;
-
- r.setBottomRight(coordinate);
- v = r;
-}
-
-QGeoCoordinate GeoRectangleValueType::topLeft()
-{
- return QGeoRectangle(v).topLeft();
-}
-
-/*
- This property holds the top left coordinate of this georectangle.
-*/
-void GeoRectangleValueType::setTopLeft(const QGeoCoordinate &coordinate)
-{
- QGeoRectangle r = v;
-
- if (r.topLeft() == coordinate)
- return;
-
- r.setTopLeft(coordinate);
- v = r;
-}
-
-QGeoCoordinate GeoRectangleValueType::topRight()
-{
- return QGeoRectangle(v).topRight();
-}
-
-/*
- This property holds the top right coordinate of this georectangle.
-*/
-void GeoRectangleValueType::setTopRight(QGeoCoordinate &coordinate)
-{
- QGeoRectangle r = v;
-
- if (r.topRight() == coordinate)
- return;
-
- r.setTopRight(coordinate);
- v = r;
-}
-
-QGeoCoordinate GeoRectangleValueType::center()
-{
- return QGeoRectangle(v).center();
-}
-
-/*
- This property holds the center coordinate of this georectangle.
-*/
-void GeoRectangleValueType::setCenter(const QGeoCoordinate &coordinate)
-{
- QGeoRectangle r = v;
-
- if (r.center() == coordinate)
- return;
-
- r.setCenter(coordinate);
- v = r;
-}
-
-double GeoRectangleValueType::height()
-{
- return QGeoRectangle(v).height();
-}
-
-/*
- This property holds the height of this georectangle (in degrees).
-*/
-void GeoRectangleValueType::setHeight(double height)
-{
- QGeoRectangle r = v;
-
- if (!r.isValid())
- r.setCenter(QGeoCoordinate(0.0, 0.0));
-
- r.setHeight(height);
- v = r;
-}
-
-double GeoRectangleValueType::width()
-{
- return QGeoRectangle(v).width();
-}
-
-/*
- This property holds the width of this georectangle (in degrees).
-*/
-void GeoRectangleValueType::setWidth(double width)
-{
- QGeoRectangle r = v;
-
- if (!r.isValid())
- r.setCenter(QGeoCoordinate(0.0, 0.0));
-
- r.setWidth(width);
- v = r;
-}
-
-QString GeoRectangleValueType::toString() const
-{
- if (v.type() != QGeoShape::RectangleType) {
- qWarning("Not a rectangle a %d\n", v.type());
- return QStringLiteral("QGeoRectangle(not a rectangle)");
- }
-
- QGeoRectangle r = v;
- return QStringLiteral("QGeoRectangle({%1, %2}, {%3, %4})")
- .arg(r.topLeft().latitude())
- .arg(r.topLeft().longitude())
- .arg(r.bottomRight().latitude())
- .arg(r.bottomRight().longitude());
-}
-
-void GeoRectangleValueType::setValue(const QVariant &value)
-{
- if (value.userType() == qMetaTypeId<QGeoRectangle>())
- v = value.value<QGeoRectangle>();
- else if (value.userType() == qMetaTypeId<QGeoShape>())
- v = value.value<QGeoShape>();
- else
- v = QGeoRectangle();
-
- onLoad();
-}
-
-QVariant GeoRectangleValueType::value()
-{
- return QVariant::fromValue(QGeoRectangle(v));
-}
-
-void GeoRectangleValueType::write(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags)
-{
- QGeoRectangle r = v;
- writeProperty(obj, idx, flags, &r);
-}
-
-void GeoRectangleValueType::writeVariantValue(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags, QVariant *from)
-{
- if (from->userType() == qMetaTypeId<QGeoRectangle>()) {
- writeProperty(obj, idx, flags, from);
- } else if (from->userType() == qMetaTypeId<QGeoShape>()) {
- QGeoRectangle r = from->value<QGeoShape>();
- QVariant v = QVariant::fromValue(r);
- writeProperty(obj, idx, flags, &v);
- } else {
- QVariant v = QVariant::fromValue(QGeoRectangle());
- writeProperty(obj, idx, flags, &v);
- }
-}
-
-#include "moc_qdeclarativegeorectangle.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativegeorectangle.h b/src/imports/positioning/qdeclarativegeorectangle.h
deleted file mode 100644
index fce4d5a4..00000000
--- a/src/imports/positioning/qdeclarativegeorectangle.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-***************************************************************************/
-
-#ifndef QDECLARATIVEGEORECTANGLE_H
-#define QDECLARATIVEGEORECTANGLE_H
-
-#include "qdeclarativegeoshape.h"
-
-QT_BEGIN_NAMESPACE
-
-class GeoRectangleValueType : public GeoShapeValueType
-{
- Q_OBJECT
-
- Q_PROPERTY(QGeoCoordinate bottomLeft READ bottomLeft WRITE setBottomLeft)
- Q_PROPERTY(QGeoCoordinate bottomRight READ bottomRight WRITE setBottomRight)
- Q_PROPERTY(QGeoCoordinate topLeft READ topLeft WRITE setTopLeft)
- Q_PROPERTY(QGeoCoordinate topRight READ topRight WRITE setTopRight)
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
- Q_PROPERTY(double height READ height WRITE setHeight)
- Q_PROPERTY(double width READ width WRITE setWidth)
-
-public:
- explicit GeoRectangleValueType(QObject *parent = 0);
- ~GeoRectangleValueType();
-
- QGeoCoordinate bottomLeft();
- void setBottomLeft(const QGeoCoordinate &coordinate);
- QGeoCoordinate bottomRight();
- void setBottomRight(const QGeoCoordinate &coordinate);
- QGeoCoordinate topLeft();
- void setTopLeft(const QGeoCoordinate &coordinate);
- QGeoCoordinate topRight();
- void setTopRight(QGeoCoordinate &coordinate);
- QGeoCoordinate center();
- void setCenter(const QGeoCoordinate &coordinate);
- double height();
- void setHeight(double height);
- double width();
- void setWidth(double width);
-
- QString toString() const Q_DECL_OVERRIDE;
- void setValue(const QVariant &value) Q_DECL_OVERRIDE;
- QVariant value() Q_DECL_OVERRIDE;
- void write(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags) Q_DECL_OVERRIDE;
- void writeVariantValue(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags, QVariant *from) Q_DECL_OVERRIDE;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/imports/positioning/qdeclarativegeoshape.cpp b/src/imports/positioning/qdeclarativegeoshape.cpp
deleted file mode 100644
index 909ea9c7..00000000
--- a/src/imports/positioning/qdeclarativegeoshape.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtPositioning module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** 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 Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativegeoshape.h"
-
-#include <QtPositioning/QGeoRectangle>
-#include <QtPositioning/QGeoCircle>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlbasictype geoshape
- \inqmlmodule QtPositioning
- \ingroup qml-QtPositioning5-basictypes
- \since 5.2
-
- \brief A geoshape type represents an abstract geographic area.
-
- The \c geoshape type represents an abstract geographic area. It includes attributes and
- methods common to all geographic areas. To create objects that represent a valid geographic
- area use \l {georectangle} or \l {geocircle}.
-
- The \l isValid attribute can be used to test if the geoshape represents a valid geographic
- area.
-
- The \l isEmpty attribute can be used to test if the geoshape represents a region with a
- geomatrical area of 0.
-
- The \l {contains}{contains()} method can be used to test if a \l {coordinate} is
- within the geoshape.
-
- \section1 Example Usage
-
- Use properties of type \l variant to store a \c {geoshape}. To create a \c geoshape use one
- of the methods described below.
-
- To create a \c geoshape value, specify it as a "shape()" string:
-
- \qml
- import QtPositioning
-
- Item {
- property variant region: "shape()"
- }
- \endqml
-
- or with the \l {QtPositioning::shape}{QtPositioning.shape()} function:
-
- \qml
- import QtPositioning 5.2
-
- Item {
- property variant region: QtPositioning.shape()
- }
- \endqml
-
- When integrating with C++, note that any QGeoShape value passed into QML from C++ is
- automatically converted into a \c geoshape value, and vice-versa.
-
- \section1 Properties
-
- \section2 isEmpty
-
- \code
- bool isEmpty
- \endcode
-
- Returns whether this geo shape is empty. An empty geo shape is a region which has
- a geometrical area of 0.
-
- \section2 isValid
-
- \code
- bool isValid
- \endcode
-
- Returns whether this geo shape is valid.
-
- A geo shape is considered to be invalid if some of the data that is required to
- unambiguously describe the geo shape has not been set or has been set to an
- unsuitable value.
-
-
- \section1 Methods
-
- \section2 contains()
-
- \code
- bool contains(coordinate coord)
- \endcode
-
- Returns true if the \l {QtPositioning::coordinate}{coordinate} specified by \a coord is within
- this geoshape; Otherwise returns false.
-*/
-
-GeoShapeValueType::GeoShapeValueType(QObject *parent)
-: QQmlValueTypeBase<QGeoShape>(qMetaTypeId<QGeoShape>(), parent)
-{
-}
-
-GeoShapeValueType::~GeoShapeValueType()
-{
-}
-
-GeoShapeValueType::ShapeType GeoShapeValueType::type() const
-{
- return static_cast<GeoShapeValueType::ShapeType>(v.type());
-}
-
-bool GeoShapeValueType::isValid() const
-{
- return v.isValid();
-}
-
-bool GeoShapeValueType::isEmpty() const
-{
- return v.isEmpty();
-}
-
-bool GeoShapeValueType::contains(const QGeoCoordinate &coordinate) const
-{
- return v.contains(coordinate);
-}
-
-QString GeoShapeValueType::toString() const
-{
- switch (v.type()) {
- case QGeoShape::UnknownType:
- return QStringLiteral("QGeoShape()");
- case QGeoShape::RectangleType: {
- QGeoRectangle r = v;
- return QStringLiteral("QGeoRectangle({%1, %2}, {%3, %4})")
- .arg(r.topLeft().latitude())
- .arg(r.topLeft().longitude())
- .arg(r.bottomRight().latitude())
- .arg(r.bottomRight().longitude());
- }
- case QGeoShape::CircleType: {
- QGeoCircle c = v;
- return QStringLiteral("QGeoCircle({%1, %2}, %3)")
- .arg(c.center().latitude())
- .arg(c.center().longitude())
- .arg(c.radius());
- }
- }
-
- return QStringLiteral("QGeoShape(%1)").arg(v.type());
-}
-
-void GeoShapeValueType::setValue(const QVariant &value)
-{
- if (value.userType() == qMetaTypeId<QGeoShape>())
- v = value.value<QGeoShape>();
- else if (value.userType() == qMetaTypeId<QGeoRectangle>())
- v = value.value<QGeoRectangle>();
- else if (value.userType() == qMetaTypeId<QGeoCircle>())
- v = value.value<QGeoCircle>();
- else
- v = QGeoShape();
-
- onLoad();
-}
-
-bool GeoShapeValueType::isEqual(const QVariant &other) const
-{
- if (other.userType() == qMetaTypeId<QGeoShape>())
- return v == other.value<QGeoShape>();
- else if (other.userType() == qMetaTypeId<QGeoRectangle>())
- return v == other.value<QGeoRectangle>();
- else if (other.userType() == qMetaTypeId<QGeoCircle>())
- return v == other.value<QGeoCircle>();
- else
- return false;
-}
-
-GeoShapeValueType::GeoShapeValueType(int userType, QObject *parent)
-: QQmlValueTypeBase<QGeoShape>(userType, parent)
-{
- QMetaType::construct(userType, &v, 0);
-}
-
-QT_END_NAMESPACE
diff --git a/src/location/doc/qtlocation.qdocconf b/src/location/doc/qtlocation.qdocconf
index fc78d8f5..09a200f7 100644
--- a/src/location/doc/qtlocation.qdocconf
+++ b/src/location/doc/qtlocation.qdocconf
@@ -17,18 +17,15 @@ qhp.QtLocation.indexRoot =
qhp.QtLocation.filterAttributes = qtlocation $QT_VERSION qtrefdoc
qhp.QtLocation.customFilters.Qt.name = QtLocation $QT_VERSION
qhp.QtLocation.customFilters.Qt.filterAttributes = qtLocation $QT_VERSION
-qhp.QtLocation.subprojects = overviews classes qml examples
+qhp.QtLocation.subprojects = classes qml examples
qhp.QtLocation.subprojects.classes.title = C++ Classes
qhp.QtLocation.subprojects.classes.indexTitle = Qt Location C++ Classes
qhp.QtLocation.subprojects.classes.selectors = class fake:headerfile
qhp.QtLocation.subprojects.classes.sortPages = true
qhp.QtLocation.subprojects.qml.title = QML Types
qhp.QtLocation.subprojects.qml.indexTitle = Qt Location QML Types
-qhp.QtLocation.subprojects.qml.selectors = fake:headerfile
+qhp.QtLocation.subprojects.qml.selectors = qmlclass
qhp.QtLocation.subprojects.qml.sortPages = true
-qhp.QtLocation.subprojects.overviews.title = Overviews
-qhp.QtLocation.subprojects.overviews.indexTitle = Qt Location Overview
-qhp.QtLocation.subprojects.overviews.selectors = fake:page,group,module
qhp.QtLocation.subprojects.examples.title = Qt Location Examples
qhp.QtLocation.subprojects.examples.indexTitle = Qt Location Examples
qhp.QtLocation.subprojects.examples.selectors = fake:example
diff --git a/src/location/doc/snippets/declarative/places_loader.qml b/src/location/doc/snippets/declarative/places_loader.qml
index d14223fd..6eea0194 100644
--- a/src/location/doc/snippets/declarative/places_loader.qml
+++ b/src/location/doc/snippets/declarative/places_loader.qml
@@ -48,7 +48,7 @@ Rectangle {
Plugin {
id: myPlugin
- name: "nokia"
+ name: "osm"
//specify plugin parameters if necessary
//PluginParameter {...}
//PluginParameter {...}
diff --git a/src/location/doc/src/examples/places-map.qdoc b/src/location/doc/src/examples/places-map.qdoc
index 100f030e..0dd7c109 100644
--- a/src/location/doc/src/examples/places-map.qdoc
+++ b/src/location/doc/src/examples/places-map.qdoc
@@ -34,15 +34,20 @@
on a map using a MapItemView
\image places-map.jpg
- To write a QML application that will show places on a map, we start by
+ The example displays a map of the current location or, if no position is
+ available, it uses Brisbane/Australia. Subsequently a search for places
+ matching the term "pizza" is performed and each result shown on the map.
+
+ To write the QML application that will show places on a map, we start by
making the following import declarations.
\snippet places_map/places_map.qml Imports
Instantiate a \l Plugin instance. The \l Plugin is effectively the backend
- from where places are sourced from. Because the \c nokia plugin has been
- specified, some mandatory parameters need to be filled in, see the \l
- {Mandatory Parameters} {Nokia Plugin} documentation for details:
+ from where places are sourced from. Depending on the chosen plugin
+ some manadatory parameters may be needed. In this case the
+ \l {Qt Location Open Street Map Plugin}{OSM plugin} is selected which does not have any mandatory
+ parameters.
\snippet places_map/places_map.qml Initialize Plugin
@@ -64,4 +69,11 @@
Roles} {role}.
\snippet places_map/places_map.qml Places MapItemView
+
+ Finally, a \c PositionSource is used to reset the map to the curent
+ location and find "pizza" places in the new area. The position information
+ is updated every 2 minutes and if the new position is more than 500 meters
+ away from the last pizza search area the place search is retriggered.
+
+ \snippet places_map/places_map.qml Current Location
*/
diff --git a/src/location/doc/src/places.qdoc b/src/location/doc/src/places.qdoc
index 2a853a20..edbd20f4 100644
--- a/src/location/doc/src/places.qdoc
+++ b/src/location/doc/src/places.qdoc
@@ -42,7 +42,7 @@
\section2 Plugin
A \l Plugin is an abstraction for a backend. One \l Plugin might access places from a
REST server while another may access places from a local database. The following
- instantiates a \l Plugin object by providing a name of "nokia". The \l Plugin name
+ instantiates a \l Plugin object by providing a name of "osm". The \l Plugin name
identifies which backend to choose from. Plugins may also be provided with a set of
\l {PluginParameter} {parameters}, which essentially takes the form of a set of
key-value pairs. The \l {PluginParameter} {parameters} that can be specified vary
diff --git a/src/location/doc/src/plugins/mapbox.qdoc b/src/location/doc/src/plugins/mapbox.qdoc
new file mode 100644
index 00000000..67d0e84e
--- /dev/null
+++ b/src/location/doc/src/plugins/mapbox.qdoc
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** 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.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page location-plugin-mapbox.html
+\title Qt Location Mapbox Plugin
+\ingroup QtLocation-plugins
+
+\brief Uses Mapbox for location services.
+
+\section1 Overview
+
+This geo services plugin allows applications to access
+\l {http://mapbox.com}{Mapbox} location based services using the Qt Location API.
+The use of these services is governed by the \l {https://www.mapbox.com/tos}{Mapbox terms of service}.
+An access token is required to use these services.
+Data is provided by \l {https://www.mapbox.com/about/maps}{OpenStreetMap and others}.
+
+The Mapbox geo services plugin can be loaded by using the plugin key "mapbox".
+
+\section1 Parameters
+
+\section2 Mandatory parameters
+The following table lists mandatory parameters that \e must be passed to the Mapbox plugin.
+\table
+\header
+ \li Parameter
+ \li Description
+\row
+ \li mapbox.access_token
+ \li \l{https://www.mapbox.com/help/define-access-token/}{Access token} provided by Mapbox.
+\row
+ \li mapbox.map_id
+ \li \l{https://www.mapbox.com/help/define-map-id/}{ID} of the Mapbox map to show. An example ID is "examples.map-zr0njcqy".
+\endtable
+
+The Mapbox geo services plugin requires an access token and map ID to use the
+Mapbox services. To create a Mapbox account visit
+\l{https://www.mapbox.com/#signup}.
+
+\section2 Optional parameters
+The following table lists optional parameters that can be passed to the Mapbox plugin.
+\table
+\header
+ \li Parameter
+ \li Description
+\row
+ \li mapbox.format
+ \li Data format to download tiles in, available values are "png", "png32",
+ "png64", "png128", "png256", (PNG with full, 32, 64, 128 and 256 color palette)
+ "jpg70", "jpg80", "jpg90" (JPEG with 70%, 80% and 90% compression).
+ Defaults to "png".
+\row
+ \li useragent
+ \li User agent string set when making network requests.
+\endtable
+*/
diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc
index ee9b2a48..a92d8422 100644
--- a/src/location/doc/src/plugins/osm.qdoc
+++ b/src/location/doc/src/plugins/osm.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
@@ -37,8 +37,9 @@
This geo services plugin allows applications to access
\l {http://openstreetmap.org}{Open Street Map} location based services using the Qt Location API.
-Data, imagery and map information provided by \l {http://www.mapquest.com}{MapQuest}, OpenStreetMap and
-contributors. The data is available under the \l {http://www.opendatacommons.org/licenses/odbl}{Open Database License}.
+Data, imagery and map information provided by \l {http://www.mapquest.com}{MapQuest},
+\l {http://www.thunderforest.com/}{ThunderForest}, OpenStreetMap and contributors. The data is
+available under the \l {http://www.opendatacommons.org/licenses/odbl}{Open Database License}.
The Open Street Map geo services plugin can be loaded by using the plugin key "osm".
diff --git a/src/location/doc/src/qtlocation-qml.qdoc b/src/location/doc/src/qtlocation-qml.qdoc
index 08cd2164..68b82d30 100644
--- a/src/location/doc/src/qtlocation-qml.qdoc
+++ b/src/location/doc/src/qtlocation-qml.qdoc
@@ -33,23 +33,16 @@
\section1 Overview
-The identifying string for this module is \e QtLocation. To use include the following import
-statement in the QML file.
-
-\snippet declarative/plugin.qml Plugin import
-
-\section2 Location QML Concepts
-
-Provided that a position has been obtained this module can
-add a \l {QtLocation::Map}{Map} with positions of interest and
-\l {QtLocation::Place}{Places}. The user can be made aware of nearby features and related
-information, displayed graphically. Features on the \l Map may be places of business, entertainment
-and so on. They may include paths, roads, or forms of transport leading so that
-navigation optimization and assistance are possible.
+Provided that a position has been obtained, this module can add a
+\l{QtLocation::Map}{Map} with Places of Interest (POI) and
+\l{QtLocation::Place}{Places}. The user can be made aware of nearby features
+and related information, displayed graphically. Features on the \l Map can be
+places of business, entertainment, and so on. They may include paths, roads,
+or forms of transport, enabling navigation optimization and assistance.
To perform navigation we need \l {Route}s from start to destination. These routes
-are made up of segments. Each \l {QtLocation::RouteSegment}{RouteSegment}
-can be considered a navigation sub-task: drive 100 meters, turn left. The beginning and
+are made up of segments, where each \l {QtLocation::RouteSegment}{RouteSegment}
+can be considered a navigation subtask: drive 100 meters, turn left. The beginning and
end of each segment is a \e waypoint, that is, one part of our journey.
A typical use case for the API is a user looking for a particular type of
@@ -61,30 +54,26 @@ environment that can help or hinder the journey. The navigation then
proceeds with the user's progress monitored by means of the current
\l Location. In the context of this API the map application would be aware
of the location and size of various places and the location of the user.
-Plugins would supply the data used by the application to determine routes and
-navigation instructions. The \l Place types would hold information about the
+Plugins would supply the data required by the application to determine routes
+and navigation instructions. The \l Place types would hold information about the
destination and surrounding objects including displayable representations.
The \l Map type would enable this information to be displayed, panned,
zoomed and so on. The \l Route would be determined by a plugin with each
\l RouteSegment holding the navigation instructions guided by the updated
current \l Location.
-\l {Plugin}s are a means of specifying which Location based service to use. For example,
-a plugin may allow connection to a provider's service that handles geocoding and routing
-that the API and application can use. There may be various GeoServices plugins for various tasks
-with some plugins providing more than one service. One QML \l Plugin should be created
-for each required GeoService plugin. Plugins are required for maps, routing and geocoding,
-however the default plugin handles all three of these services. A plugin may
-require online access or may support on-board maps and data. The default "nokia"
-plugin only supports online use. The connection would be managed by QNetworkInfo and
-QNetworkConfigurationManager.
-
-\note: Plugins may not provide various features such as paging or relevance hints.
-Since plugins may be supplied by other providers, support for these aspects is
-dependent on the provider's implementation.
-
-The following table provides links to more detailed information on sections of the Qt Location QML
-API.
+\l {Plugin}s are a means of specifying which location-based service to use. For
+example, a plugin may allow connection to a provider's service that provides
+geocoding and routing information, which can be consumed by the application.
+There may be various GeoServices plugins for various tasks with some plugins
+providing more than one service. One QML \l Plugin must be created for each
+required GeoService plugin. Plugins are required for maps, routing and geocoding,
+and places, however the default plugin handles all four of these services. A plugin may
+require online access or may support on-board maps and data.
+
+\note Plugins may not provide features such as paging or relevance hints.
+
+The following links provide more detailed information about maps and places:
\table
\row
diff --git a/src/location/doc/src/qtlocation.qdoc b/src/location/doc/src/qtlocation.qdoc
index 2be4173a..5f82a423 100644
--- a/src/location/doc/src/qtlocation.qdoc
+++ b/src/location/doc/src/qtlocation.qdoc
@@ -34,25 +34,24 @@
\ingroup modules
\qtvariable location
- \brief Location module provides positioning, mapping, navigation, and place search
- via QML and C++ interfaces.
+ \brief Provides C++ interfaces to retrieve location and navigational
+ information.
- To load the Qt Location module, add the following statement to your .qml files
+ The C++ API provides access to geocoding and navigation information,
+ and also place search. Use the \l{Maps and Navigation (QML)}{QML}
+ API to render this information on an interactive map that supports
+ touch gestures, overlays, and so on.
- \code
- import QtLocation 5.3
- \endcode
-
- For C++ projects include the header appropriate for the current use case,
- for example applications using routes may use
+ Include the appropriate header in your C++ code. For example,
+ applications using routes can include:
\code #include <QGeoRoute> \endcode
- The .pro file should have the \e location keyword added
+ Add the \e location keyword in the project file to link against the
+ Qt Location library:
\code QT += location \endcode
-
See more in the \l{Qt Location}{Qt Location Overview}.
*/
@@ -62,27 +61,23 @@
/*!
\page qtlocation-index.html
\title Qt Location
-\brief The Qt Location API provides mapping, navigation, and place search
- via QML and C++ interfaces.
+\brief Provides QML and C++ interfaces to create location-aware
+applications.
\ingroup technology-apis
-The Qt Location API provides mapping, navigation, and place search via QML
-and C++ interfaces.
-
-The API has not been released yet but due to its platform-independent nature is available
-on all Qt platforms.
+The Qt Location API helps you create viable mapping solutions using the data
+available from some of the popular location services.
\section1 Overview
-The Qt Location API gives developers the ability to determine a position by
-using a variety of possible sources, including satellite, or wifi, or text file,
-and so on. That information can then be used to determine a position in a map
-context with appropriate navigation and to embed, in the map, defined places
-with descriptive metadata. These three parts
-allow a device to know where it is and its location with respect to important
-features. Using features such as roads, destinations, routes,
-and other navigation attributes, applications can specify beginning and end-points
-for navigation and awareness of objects that may aid or hinder a journey.
+The Qt Location API enables you to:
+\list
+ \li access and present map data,
+ \li support touch gesture on a specific area of the map,
+ \li query for a specific geographical location and route,
+ \li add additional layers on top, such as polylines and circles,
+ \li and search for places and related images.
+\endlist
\section1 Getting Started
@@ -101,17 +96,19 @@ The .pro file should have the \e location keyword added
\code QT += location \endcode
-\section2 API Sub-Modules
-The API is split into sub-modules, which each have QML and C++ APIs. It focuses on
-Map and Place information. The required position data can be retrieved via the
-\l {QtPositioning} module.
+\section2 Submodules
+
+The API is split into sub-modules, which provide QML and C++ interfaces for
+specific purposes. They focus mainly on Map and Place information. The required
+position data can be retrieved using the \l {QtPositioning} module.
\section3 Places
-Places is
-the natural complement to Positioning, providing a source of geographic
-data about places of interest (POIs). As well as providing the location,
-size and other vitals about a POI, the Places API can also retrieve images,
-reviews and other rich content related to the place.
+
+The Places submodule is the natural complement to Positioning, providing a
+source of geographical data about Places of Interest (POI). Besides the source
+information, the API provides information about the location, size, and
+other related information about a POI. The Places API can also
+retrieve images, reviews, and other content related to a place.
\table
\row
@@ -121,15 +118,15 @@ reviews and other rich content related to the place.
\endtable
\section3 Maps and Navigation
-Maps and Navigation provides Qt Quick user
-interface components for displaying geographic information on a map, as
-well as allowing user interaction with map objects and the display itself.
-It also contains utilities for geocoding (finding a geographic coordinate
-from a street address) and navigation (including driving and walking
-directions).
+
+The module provides the QML and C++ alternatives for maps and navigation.
+The C++ alternative provides utility classes to get geocoding (finding a geographic
+coordinate from a street address) and navigation (including driving and walking
+directions) information, whereas its QML counterpart provides UI components to render
+the information.
+
\table
\row
-
\li Maps and Navigation introduction:
\li \l{Maps and Navigation (QML)}{for QML}
\li \l{Maps and Navigation (C++)}{for C++}
@@ -137,8 +134,8 @@ directions).
\section1 API References and Examples
-Alphabetized lists of all classes and user interface components in the API, as well as detailed
-example applications to demonstrate their usage.
+The following are lists of the classes and UI components provided by the module,
+with example applications to demonstrate their usage:
\table
\row
@@ -167,7 +164,7 @@ be provided to influence their behavior.
\section2 Implementing New Back-Ends and Porting
-For systems integrators and distributors, information relating to making
+For systems integrators and distributors, information related to making
Qt Location available for a new platform.
\table
@@ -188,15 +185,19 @@ been reworked to be simpler to use.
New features of Qt Location includes
\list
- \li Maps are now part of the Qt Quick scenegraph, and rendered using hardware-accelerated OpenGL
- \li Arbitrary Qt Quick items on the map are supported using \l MapQuickItem
- \li Now possible to create map overlays with a model
- \li Built-in support for pinch-to-zoom gestures, flicking , and panning (see \l MapGestureArea)
- \li Vast performance improvements over Qt Mobility 1.2, especially for large map polylines and objects in general
- \li Full QML API now available for routing and geocoding -- compatible with standard QML model-view design
- \li Service provider feature detection without having to open all the available plugins
- \li Unified \l Plugin QML type used by routing/geocoding/maps etc with easy-to-set \l PluginParameter
- \li Two plugins are supplied with Qt (a Nokia and an OSM plugin for GeoServices).
+ \li Maps are now part of the Qt Quick scenegraph, and rendered using
+ hardware-accelerated OpenGL.
+ \li Arbitrary Qt Quick items on the map are supported using \l MapQuickItem.
+ \li Support for map overlays using a model.
+ \li Built-in support for pinch-to-zoom gestures, flicking , and panning
+ (see \l MapGestureArea).
+ \li Vast performance improvements over Qt Mobility 1.2, especially for
+ large map polylines and objects in general.
+ \li The QML API for routing and geocoding is now available.
+ \li Service provider feature detection without having to open all of the
+ available plugins.
+ \li Unified \l Plugin QML type used by routing, geocoding, maps, and so on,
+ with easy-to-set \l PluginParameter.
\li Landmarks API is replaced by the Places API
\li \l Place supports viewing of richer content such as reviews, images, and editorials
\li \l Place supports locale handling, sponsored search results, and supplier attribution
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 93eafd68..c7def6da 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -67,7 +67,8 @@ QGeoMap::QGeoMap(QGeoMapData *mapData, QObject *parent)
connect(mapData_, SIGNAL(cameraDataChanged(QGeoCameraData)), this, SIGNAL(cameraDataChanged(QGeoCameraData)));
connect(mapData_, SIGNAL(updateRequired()), this, SIGNAL(updateRequired()));
connect(mapData_, SIGNAL(activeMapTypeChanged()), this, SIGNAL(activeMapTypeChanged()));
- connect(mapData_, SIGNAL(copyrightsChanged(QImage,QPoint)), this, SIGNAL(copyrightsChanged(QImage,QPoint)));
+ connect(mapData_, SIGNAL(copyrightsChanged(QImage)), this, SIGNAL(copyrightsChanged(QImage)));
+ connect(mapData_, SIGNAL(copyrightsChanged(QString)), this, SIGNAL(copyrightsChanged(QString)));
}
QGeoMap::~QGeoMap()
@@ -120,14 +121,14 @@ QGeoCameraData QGeoMap::cameraData() const
return mapData_->cameraData();
}
-QGeoCoordinate QGeoMap::screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
+QGeoCoordinate QGeoMap::itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
{
- return mapData_->screenPositionToCoordinate(pos, clipToViewport);
+ return mapData_->itemPositionToCoordinate(pos, clipToViewport);
}
-QDoubleVector2D QGeoMap::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
+QDoubleVector2D QGeoMap::coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
{
- return mapData_->coordinateToScreenPosition(coordinate, clipToViewport);
+ return mapData_->coordinateToItemPosition(coordinate, clipToViewport);
}
void QGeoMap::update()
diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h
index f9d5e2ea..e52c6e5f 100644
--- a/src/location/maps/qgeomap_p.h
+++ b/src/location/maps/qgeomap_p.h
@@ -89,8 +89,8 @@ public:
QGeoCameraData cameraData() const;
QGeoCameraCapabilities cameraCapabilities() const;
- QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
- QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
+ QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
+ QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
void setActiveMapType(const QGeoMapType mapType);
const QGeoMapType activeMapType() const;
@@ -105,7 +105,8 @@ Q_SIGNALS:
void cameraDataChanged(const QGeoCameraData &cameraData);
void updateRequired();
void activeMapTypeChanged();
- void copyrightsChanged(const QImage &copyrightsImage, const QPoint &copyrightsPos);
+ void copyrightsChanged(const QImage &copyrightsImage);
+ void copyrightsChanged(const QString &copyrights);
private:
QGeoMapData *mapData_;
diff --git a/src/location/maps/qgeomapcontroller.cpp b/src/location/maps/qgeomapcontroller.cpp
index be39f136..ae739cb4 100644
--- a/src/location/maps/qgeomapcontroller.cpp
+++ b/src/location/maps/qgeomapcontroller.cpp
@@ -196,7 +196,7 @@ void QGeoMapController::pan(qreal dx, qreal dy)
if (dx == 0 && dy == 0)
return;
QGeoCameraData cd = map_->cameraData();
- QGeoCoordinate coord = map_->screenPositionToCoordinate(
+ QGeoCoordinate coord = map_->itemPositionToCoordinate(
QDoubleVector2D(map_->width() / 2 + dx,
map_->height() / 2 + dy));
diff --git a/src/location/maps/qgeomapdata_p.h b/src/location/maps/qgeomapdata_p.h
index f7d3c059..359b8db2 100644
--- a/src/location/maps/qgeomapdata_p.h
+++ b/src/location/maps/qgeomapdata_p.h
@@ -88,8 +88,8 @@ public:
void setActiveMapType(const QGeoMapType mapType);
const QGeoMapType activeMapType() const;
- virtual QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const = 0;
- virtual QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const = 0;
+ virtual QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const = 0;
+ virtual QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const = 0;
QString pluginString();
QGeoCameraCapabilities cameraCapabilities();
@@ -108,7 +108,8 @@ Q_SIGNALS:
void cameraDataChanged(const QGeoCameraData &cameraData);
void updateRequired();
void activeMapTypeChanged();
- void copyrightsChanged(const QImage &copyrightsImage, const QPoint &copyrightsPos);
+ void copyrightsChanged(const QImage &copyrightsImage);
+ void copyrightsChanged(const QString &copyrightsHtml);
private:
QGeoMapDataPrivate *d_ptr;
diff --git a/src/location/maps/qgeomapscene.cpp b/src/location/maps/qgeomapscene.cpp
index 09f9a9d7..93523f27 100644
--- a/src/location/maps/qgeomapscene.cpp
+++ b/src/location/maps/qgeomapscene.cpp
@@ -88,7 +88,6 @@ public:
int minTileY_;
int maxTileX_;
int maxTileY_;
- int tileZ_; // caches the zoom level for this tile set
int tileXWrapsBelow_; // the wrap point as a tile index
// cameraToGrid transform
@@ -110,8 +109,8 @@ public:
void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
- QDoubleVector2D screenPositionToMercator(const QDoubleVector2D &pos) const;
- QDoubleVector2D mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
+ QDoubleVector2D itemPositionToMercator(const QDoubleVector2D &pos) const;
+ QDoubleVector2D mercatorToItemPosition(const QDoubleVector2D &mercator) const;
void setVisibleTiles(const QSet<QGeoTileSpec> &tiles);
void removeTiles(const QSet<QGeoTileSpec> &oldTiles);
@@ -173,16 +172,16 @@ void QGeoMapScene::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileText
d->addTile(spec, texture);
}
-QDoubleVector2D QGeoMapScene::screenPositionToMercator(const QDoubleVector2D &pos) const
+QDoubleVector2D QGeoMapScene::itemPositionToMercator(const QDoubleVector2D &pos) const
{
Q_D(const QGeoMapScene);
- return d->screenPositionToMercator(pos);
+ return d->itemPositionToMercator(pos);
}
-QDoubleVector2D QGeoMapScene::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QDoubleVector2D QGeoMapScene::mercatorToItemPosition(const QDoubleVector2D &mercator) const
{
Q_D(const QGeoMapScene);
- return d->mercatorToScreenPosition(mercator);
+ return d->mercatorToItemPosition(mercator);
}
bool QGeoMapScene::verticalLock() const
@@ -210,7 +209,6 @@ QGeoMapScenePrivate::QGeoMapScenePrivate(QGeoMapScene *scene)
minTileY_(-1),
maxTileX_(-1),
maxTileY_(-1),
- tileZ_(0),
tileXWrapsBelow_(0),
mercatorCenterX_(0.0),
mercatorCenterY_(0.0),
@@ -229,7 +227,7 @@ QGeoMapScenePrivate::~QGeoMapScenePrivate()
{
}
-QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QDoubleVector2D &pos) const
+QDoubleVector2D QGeoMapScenePrivate::itemPositionToMercator(const QDoubleVector2D &pos) const
{
double x = mercatorWidth_ * (((pos.x() - screenOffsetX_) / screenWidth_) - 0.5);
x += mercatorCenterX_;
@@ -248,7 +246,7 @@ QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QDoubleVecto
return QDoubleVector2D(x, y);
}
-QDoubleVector2D QGeoMapScenePrivate::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QDoubleVector2D QGeoMapScenePrivate::mercatorToItemPosition(const QDoubleVector2D &mercator) const
{
double mx = sideLength_ * mercator.x();
@@ -301,7 +299,7 @@ bool QGeoMapScenePrivate::buildGeometry(const QGeoTileSpec &spec, QSGGeometry::T
|| (maxTileX_ < x)
|| (spec.y() < minTileY_)
|| (maxTileY_ < spec.y())
- || (spec.zoom() != tileZ_)) {
+ || (spec.zoom() != intZoomLevel_)) {
return false;
}
@@ -378,7 +376,6 @@ void QGeoMapScenePrivate::setTileBounds(const QSet<QGeoTileSpec> &tiles)
minTileY_ = -1;
maxTileX_ = -1;
maxTileY_ = -1;
- tileZ_ = -1;
return;
}
@@ -386,8 +383,6 @@ void QGeoMapScenePrivate::setTileBounds(const QSet<QGeoTileSpec> &tiles)
iter i = tiles.constBegin();
iter end = tiles.constEnd();
- tileZ_ = i->zoom();
-
// determine whether the set of map tiles crosses the dateline.
// A gap in the tiles indicates dateline crossing
bool hasFarLeft = false;
@@ -396,6 +391,8 @@ void QGeoMapScenePrivate::setTileBounds(const QSet<QGeoTileSpec> &tiles)
bool hasMidRight = false;
for (; i != end; ++i) {
+ if ((*i).zoom() != intZoomLevel_)
+ continue;
int x = (*i).x();
if (x == 0)
hasFarLeft = true;
@@ -438,6 +435,9 @@ void QGeoMapScenePrivate::setTileBounds(const QSet<QGeoTileSpec> &tiles)
for (; i != end; ++i) {
tile = *i;
+ if (tile.zoom() != intZoomLevel_)
+ continue;
+
int x = tile.x();
if (tile.x() < tileXWrapsBelow_)
x += sideLength_;
@@ -468,7 +468,7 @@ void QGeoMapScenePrivate::setupCamera()
// mercatorWidth_ and mercatorHeight_ define the ratio for
// mercator and screen coordinate conversion,
- // see mercatorToScreenPosition() and screenPositionToMercator()
+ // see mercatorToItemPosition() and itemPositionToMercator()
if (aspectRatio > 1.0) {
mercatorHeight_ = a;
mercatorWidth_ = a * aspectRatio;
diff --git a/src/location/maps/qgeomapscene_p.h b/src/location/maps/qgeomapscene_p.h
index 8164c347..12d5c1bc 100644
--- a/src/location/maps/qgeomapscene_p.h
+++ b/src/location/maps/qgeomapscene_p.h
@@ -85,8 +85,8 @@ public:
void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
- QDoubleVector2D screenPositionToMercator(const QDoubleVector2D &pos) const;
- QDoubleVector2D mercatorToScreenPosition(const QDoubleVector2D &mercator) const;
+ QDoubleVector2D itemPositionToMercator(const QDoubleVector2D &pos) const;
+ QDoubleVector2D mercatorToItemPosition(const QDoubleVector2D &mercator) const;
QSGNode *updateSceneGraph(QSGNode *oldNode, QQuickWindow *window);
diff --git a/src/location/maps/qgeomaptype_p.h b/src/location/maps/qgeomaptype_p.h
index 2b6faa02..d31dca5c 100644
--- a/src/location/maps/qgeomaptype_p.h
+++ b/src/location/maps/qgeomaptype_p.h
@@ -67,6 +67,7 @@ public:
GrayStreetMap,
PedestrianMap,
CarNavigationMap,
+ CycleMap,
CustomMap = 100
};
diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp
index 1cf989ee..d828d62c 100644
--- a/src/location/maps/qgeoserviceprovider.cpp
+++ b/src/location/maps/qgeoserviceprovider.cpp
@@ -104,25 +104,20 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
*/
/*!
-\enum QGeoServiceProvider::Error
-
-Describes an error related to the loading and setup of a service provider
-plugin.
-
-\value NoError
-No error has occurred.
-
-\value NotSupportedError
-The plugin does not support this functionality.
-
-\value UnknownParameterError
-The plugin did not recognize one of the parameters it was given.
-
-\value MissingRequiredParameterError
-The plugin did not find one of the parameters it was expecting.
-
-\value ConnectionError
-The plugin could not connect to its backend service or database.
+ \enum QGeoServiceProvider::Error
+
+ Describes an error related to the loading and setup of a service provider plugin.
+
+ \value NoError
+ No error has occurred.
+ \value NotSupportedError
+ The plugin does not support this functionality.
+ \value UnknownParameterError
+ The plugin did not recognize one of the parameters it was given.
+ \value MissingRequiredParameterError
+ The plugin did not find one of the parameters it was expecting.
+ \value ConnectionError
+ The plugin could not connect to its backend service or database.
*/
/*!
diff --git a/src/location/maps/qgeoserviceprovider.h b/src/location/maps/qgeoserviceprovider.h
index 3c9b96b5..fe9fce4c 100644
--- a/src/location/maps/qgeoserviceprovider.h
+++ b/src/location/maps/qgeoserviceprovider.h
@@ -56,7 +56,7 @@ class QGeoServiceProviderPrivate;
class Q_LOCATION_EXPORT QGeoServiceProvider : public QObject
{
Q_OBJECT
-
+ Q_ENUMS(Error)
public:
enum Error {
NoError,
diff --git a/src/location/maps/qgeotiledmapdata.cpp b/src/location/maps/qgeotiledmapdata.cpp
index c14fe337..7fb5da1b 100644
--- a/src/location/maps/qgeotiledmapdata.cpp
+++ b/src/location/maps/qgeotiledmapdata.cpp
@@ -139,7 +139,7 @@ void QGeoTiledMapData::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles
Q_UNUSED(visibleTiles);
}
-QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
+QGeoCoordinate QGeoTiledMapData::itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport) const
{
Q_D(const QGeoTiledMapData);
if (clipToViewport) {
@@ -150,13 +150,13 @@ QGeoCoordinate QGeoTiledMapData::screenPositionToCoordinate(const QDoubleVector2
return QGeoCoordinate();
}
- return d->screenPositionToCoordinate(pos);
+ return d->itemPositionToCoordinate(pos);
}
-QDoubleVector2D QGeoTiledMapData::coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
+QDoubleVector2D QGeoTiledMapData::coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport) const
{
Q_D(const QGeoTiledMapData);
- QDoubleVector2D pos = d->coordinateToScreenPosition(coordinate);
+ QDoubleVector2D pos = d->coordinateToItemPosition(coordinate);
if (clipToViewport) {
int w = width();
@@ -318,14 +318,14 @@ QSGNode *QGeoTiledMapDataPrivate::updateSceneGraph(QSGNode *oldNode, QQuickWindo
return mapScene_->updateSceneGraph(oldNode, window);
}
-QGeoCoordinate QGeoTiledMapDataPrivate::screenPositionToCoordinate(const QDoubleVector2D &pos) const
+QGeoCoordinate QGeoTiledMapDataPrivate::itemPositionToCoordinate(const QDoubleVector2D &pos) const
{
- return QGeoProjection::mercatorToCoord(mapScene_->screenPositionToMercator(pos));
+ return QGeoProjection::mercatorToCoord(mapScene_->itemPositionToMercator(pos));
}
-QDoubleVector2D QGeoTiledMapDataPrivate::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
+QDoubleVector2D QGeoTiledMapDataPrivate::coordinateToItemPosition(const QGeoCoordinate &coordinate) const
{
- return mapScene_->mercatorToScreenPosition(QGeoProjection::coordToMercator(coordinate));
+ return mapScene_->mercatorToItemPosition(QGeoProjection::coordToMercator(coordinate));
}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeotiledmapdata_p.h b/src/location/maps/qgeotiledmapdata_p.h
index 204e735f..d5438286 100644
--- a/src/location/maps/qgeotiledmapdata_p.h
+++ b/src/location/maps/qgeotiledmapdata_p.h
@@ -80,8 +80,8 @@ public:
void newTileFetched(const QGeoTileSpec &spec);
- QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
- QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
+ QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
+ QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
void prefetchTiles();
// Alternative to exposing this is to make tileFetched a slot, but then requestManager would
diff --git a/src/location/maps/qgeotiledmapdata_p_p.h b/src/location/maps/qgeotiledmapdata_p_p.h
index 9a7760e9..631d52ba 100644
--- a/src/location/maps/qgeotiledmapdata_p_p.h
+++ b/src/location/maps/qgeotiledmapdata_p_p.h
@@ -89,8 +89,8 @@ public:
void changeMapVersion(int mapVersion);
void resized(int width, int height);
- QGeoCoordinate screenPositionToCoordinate(const QDoubleVector2D &pos) const;
- QDoubleVector2D coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
+ QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos) const;
+ QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate) const;
void newTileFetched(const QGeoTileSpec &spec);
QSet<QGeoTileSpec> visibleTiles();
diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp
index b9946b6a..7d1e6f28 100644
--- a/src/location/places/qplacemanager.cpp
+++ b/src/location/places/qplacemanager.cpp
@@ -138,7 +138,7 @@ QPlaceManager::QPlaceManager(QPlaceManagerEngine *engine, QObject *parent)
d->setParent(this);
d->d_ptr->manager = this;
- qRegisterMetaType<QPlaceCategory>("QPlaceCategory");
+ qRegisterMetaType<QPlaceCategory>();
connect(d, SIGNAL(finished(QPlaceReply*)), this, SIGNAL(finished(QPlaceReply*)));
connect(d, SIGNAL(error(QPlaceReply*,QPlaceReply::Error)),
@@ -152,11 +152,11 @@ QPlaceManager::QPlaceManager(QPlaceManagerEngine *engine, QObject *parent)
this, SIGNAL(placeRemoved(QString)), Qt::QueuedConnection);
connect(d, SIGNAL(categoryAdded(QPlaceCategory,QString)),
- this, SIGNAL(categoryAdded(QPlaceCategory,QString)), Qt::QueuedConnection);
+ this, SIGNAL(categoryAdded(QPlaceCategory,QString)));
connect(d, SIGNAL(categoryUpdated(QPlaceCategory,QString)),
- this, SIGNAL(categoryUpdated(QPlaceCategory,QString)), Qt::QueuedConnection);
+ this, SIGNAL(categoryUpdated(QPlaceCategory,QString)));
connect(d, SIGNAL(categoryRemoved(QString,QString)),
- this, SIGNAL(categoryRemoved(QString,QString)), Qt::QueuedConnection);
+ this, SIGNAL(categoryRemoved(QString,QString)));
connect(d, SIGNAL(dataChanged()),
this, SIGNAL(dataChanged()), Qt::QueuedConnection);
} else {
diff --git a/src/location/places/qplacemanagerengine.cpp b/src/location/places/qplacemanagerengine.cpp
index afdfd4ec..9602b021 100644
--- a/src/location/places/qplacemanagerengine.cpp
+++ b/src/location/places/qplacemanagerengine.cpp
@@ -70,8 +70,8 @@ QPlaceManagerEngine::QPlaceManagerEngine(const QVariantMap &parameters,
QObject *parent)
: QObject(parent), d_ptr(new QPlaceManagerEnginePrivate)
{
- qRegisterMetaType<QPlaceReply::Error>("QPlaceReply::Error");
- qRegisterMetaType<QPlaceReply *>("QPlaceReply *");
+ qRegisterMetaType<QPlaceReply::Error>();
+ qRegisterMetaType<QPlaceReply *>();
Q_UNUSED(parameters)
}
@@ -159,8 +159,8 @@ QPlaceSearchReply *QPlaceManagerEngine::search(const QPlaceSearchRequest &reques
{
Q_UNUSED(request)
- return new QPlaceSearchReplyUnsupported(QStringLiteral("Place search is not supported."),
- this);
+ return new QPlaceSearchReplyUnsupported(QPlaceReply::UnsupportedError,
+ QStringLiteral("Place search is not supported."), this);
}
/*!
diff --git a/src/location/places/unsupportedreplies_p.h b/src/location/places/unsupportedreplies_p.h
index 7e431fbe..b915004a 100644
--- a/src/location/places/unsupportedreplies_p.h
+++ b/src/location/places/unsupportedreplies_p.h
@@ -96,10 +96,11 @@ class QPlaceSearchReplyUnsupported : public QPlaceSearchReply
Q_OBJECT
public:
- QPlaceSearchReplyUnsupported(const QString &message, QPlaceManagerEngine *parent)
+ QPlaceSearchReplyUnsupported(QPlaceReply::Error errorCode, const QString &message,
+ QPlaceManagerEngine *parent)
: QPlaceSearchReply(parent)
{
- setError(QPlaceReply::UnsupportedError, message);
+ setError(errorCode, message);
setFinished(true);
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
Q_ARG(QPlaceReply::Error, error()),
diff --git a/src/plugins/geoservices/geoservices.pro b/src/plugins/geoservices/geoservices.pro
index 63c6d792..3d0971f7 100644
--- a/src/plugins/geoservices/geoservices.pro
+++ b/src/plugins/geoservices/geoservices.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS = nokia osm
+SUBDIRS = nokia osm mapbox
diff --git a/src/plugins/geoservices/mapbox/mapbox.pro b/src/plugins/geoservices/mapbox/mapbox.pro
new file mode 100644
index 00000000..7fdfa508
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/mapbox.pro
@@ -0,0 +1,22 @@
+TARGET = qtgeoservices_mapbox
+QT += location-private positioning-private network
+
+PLUGIN_TYPE = geoservices
+PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryMapbox
+load(qt_plugin)
+
+HEADERS += \
+ qgeoserviceproviderpluginmapbox.h \
+ qgeotiledmappingmanagerenginemapbox.h \
+ qgeotilefetchermapbox.h \
+ qgeomapreplymapbox.h
+
+SOURCES += \
+ qgeoserviceproviderpluginmapbox.cpp \
+ qgeotiledmappingmanagerenginemapbox.cpp \
+ qgeotilefetchermapbox.cpp \
+ qgeomapreplymapbox.cpp
+
+OTHER_FILES += \
+ mapbox_plugin.json
+
diff --git a/src/plugins/geoservices/mapbox/mapbox_plugin.json b/src/plugins/geoservices/mapbox/mapbox_plugin.json
new file mode 100644
index 00000000..0b8d08af
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/mapbox_plugin.json
@@ -0,0 +1,9 @@
+{
+ "Keys": ["mapbox"],
+ "Provider": "mapbox",
+ "Version": 100,
+ "Experimental": false,
+ "Features": [
+ "OnlineMappingFeature"
+ ]
+}
diff --git a/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp
new file mode 100644
index 00000000..cbfa40a4
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapreplymapbox.h"
+
+#include <QtLocation/private/qgeotilespec_p.h>
+
+QGeoMapReplyMapbox::QGeoMapReplyMapbox(QNetworkReply *reply, const QGeoTileSpec &spec, const QString &format, QObject *parent)
+: QGeoTiledMapReply(spec, parent), m_reply(reply), m_format (format)
+{
+ connect(m_reply, SIGNAL(finished()), this, SLOT(networkReplyFinished()));
+ connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(networkReplyError(QNetworkReply::NetworkError)));
+}
+
+QGeoMapReplyMapbox::~QGeoMapReplyMapbox()
+{
+ if (m_reply) {
+ m_reply->deleteLater();
+ m_reply = 0;
+ }
+}
+
+void QGeoMapReplyMapbox::abort()
+{
+ if (!m_reply)
+ return;
+
+ m_reply->abort();
+}
+
+QNetworkReply *QGeoMapReplyMapbox::networkReply() const
+{
+ return m_reply;
+}
+
+void QGeoMapReplyMapbox::networkReplyFinished()
+{
+ if (!m_reply)
+ return;
+
+ if (m_reply->error() != QNetworkReply::NoError)
+ return;
+
+ setMapImageData(m_reply->readAll());
+ setMapImageFormat(m_format);
+ setFinished(true);
+
+ m_reply->deleteLater();
+ m_reply = 0;
+}
+
+void QGeoMapReplyMapbox::networkReplyError(QNetworkReply::NetworkError error)
+{
+ if (!m_reply)
+ return;
+
+ if (error != QNetworkReply::OperationCanceledError)
+ setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString());
+
+ setFinished(true);
+ m_reply->deleteLater();
+ m_reply = 0;
+}
diff --git a/src/imports/positioning/qdeclarativegeoshape.h b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.h
index 57c74d53..3a42a7b1 100644
--- a/src/imports/positioning/qdeclarativegeoshape.h
+++ b/src/plugins/geoservices/mapbox/qgeomapreplymapbox.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Canonical Ltd.
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtPositioning module of the Qt Toolkit.
+** This file is part of the QtLocation module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -29,50 +29,38 @@
**
** $QT_END_LICENSE$
**
-***************************************************************************/
+****************************************************************************/
-#ifndef QDECLARATIVEGEOSHAPE_H
-#define QDECLARATIVEGEOSHAPE_H
+#ifndef QGEOMAPREPLYMAPBOX_H
+#define QGEOMAPREPLYMAPBOX_H
-#include <QtQml/private/qqmlvaluetype_p.h>
-#include <QtPositioning/QGeoShape>
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/private/qgeotiledmapreply_p.h>
+#include <QtCore/QPointer>
QT_BEGIN_NAMESPACE
-class GeoShapeValueType : public QQmlValueTypeBase<QGeoShape>
+class QGeoMapReplyMapbox : public QGeoTiledMapReply
{
Q_OBJECT
- Q_PROPERTY(ShapeType type READ type)
- Q_PROPERTY(bool isValid READ isValid)
- Q_PROPERTY(bool isEmpty READ isEmpty)
-
- Q_ENUMS(ShapeType)
-
public:
- explicit GeoShapeValueType(QObject *parent = 0);
- ~GeoShapeValueType();
-
- enum ShapeType {
- UnknownType = QGeoShape::UnknownType,
- RectangleType = QGeoShape::RectangleType,
- CircleType = QGeoShape::CircleType
- };
+ explicit QGeoMapReplyMapbox(QNetworkReply *reply, const QGeoTileSpec &spec, const QString &format, QObject *parent = 0);
+ ~QGeoMapReplyMapbox();
- ShapeType type() const;
- bool isValid() const;
- bool isEmpty() const;
+ void abort();
- Q_INVOKABLE bool contains(const QGeoCoordinate &coordinate) const;
+ QNetworkReply *networkReply() const;
- QString toString() const Q_DECL_OVERRIDE;
- void setValue(const QVariant &value) Q_DECL_OVERRIDE;
- bool isEqual(const QVariant &other) const Q_DECL_OVERRIDE;
+private Q_SLOTS:
+ void networkReplyFinished();
+ void networkReplyError(QNetworkReply::NetworkError error);
-protected:
- explicit GeoShapeValueType(int userType, QObject *parent = 0);
+private:
+ QPointer<QNetworkReply> m_reply;
+ QString m_format;
};
QT_END_NAMESPACE
-#endif
+#endif // QGEOMAPREPLYMAPBOX_H
diff --git a/src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.cpp b/src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.cpp
new file mode 100644
index 00000000..08adb46d
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeoserviceproviderpluginmapbox.h"
+#include "qgeotiledmappingmanagerenginemapbox.h"
+
+#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QGeoCodingManagerEngine *QGeoServiceProviderFactoryMapbox::createGeocodingManagerEngine(
+ const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
+{
+ Q_UNUSED(parameters)
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ return 0;
+}
+
+QGeoMappingManagerEngine *QGeoServiceProviderFactoryMapbox::createMappingManagerEngine(
+ const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
+{
+ const QString mapId = parameters.value(QStringLiteral("mapbox.map_id")).toString();
+ const QString accessToken = parameters.value(QStringLiteral("mapbox.access_token")).toString();
+
+ if (!mapId.isEmpty() && !accessToken.isEmpty()) {
+ return new QGeoTiledMappingManagerEngineMapbox(parameters, error, errorString);
+ } else {
+ *error = QGeoServiceProvider::MissingRequiredParameterError;
+ *errorString = tr("Mapbox plugin requires 'mapbox.map_id' and 'mapbox.access_token' parameters.\n"
+ "Please visit https://www.mapbox.com");
+ return 0;
+ }
+}
+
+QGeoRoutingManagerEngine *QGeoServiceProviderFactoryMapbox::createRoutingManagerEngine(
+ const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
+{
+ Q_UNUSED(parameters)
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ return 0;
+}
+
+QPlaceManagerEngine *QGeoServiceProviderFactoryMapbox::createPlaceManagerEngine(
+ const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
+{
+ Q_UNUSED(parameters)
+ Q_UNUSED(error)
+ Q_UNUSED(errorString)
+
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.h b/src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.h
new file mode 100644
index 00000000..ca32d1c9
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/qgeoserviceproviderpluginmapbox.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOSERVICEPROVIDER_MAPBOX_H
+#define QGEOSERVICEPROVIDER_MAPBOX_H
+
+#include <QtCore/QObject>
+#include <QtLocation/QGeoServiceProviderFactory>
+
+QT_BEGIN_NAMESPACE
+
+class QGeoServiceProviderFactoryMapbox: public QObject, public QGeoServiceProviderFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
+ FILE "mapbox_plugin.json")
+
+public:
+ QGeoCodingManagerEngine *createGeocodingManagerEngine(const QVariantMap &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+ QGeoMappingManagerEngine *createMappingManagerEngine(const QVariantMap &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+ QGeoRoutingManagerEngine *createRoutingManagerEngine(const QVariantMap &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+ QPlaceManagerEngine *createPlaceManagerEngine(const QVariantMap &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString) const;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
new file mode 100644
index 00000000..b944f644
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmappingmanagerenginemapbox.h"
+#include "qgeotilefetchermapbox.h"
+
+#include <QtLocation/private/qgeocameracapabilities_p.h>
+#include <QtLocation/private/qgeomaptype_p.h>
+#include <QtLocation/private/qgeotiledmapdata_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
+: QGeoTiledMappingManagerEngine()
+{
+ QGeoCameraCapabilities cameraCaps;
+ cameraCaps.setMinimumZoomLevel(0.0);
+ cameraCaps.setMaximumZoomLevel(19.0);
+ setCameraCapabilities(cameraCaps);
+
+ setTileSize(QSize(256, 256));
+
+ QList<QGeoMapType> mapTypes;
+ mapTypes << QGeoMapType(QGeoMapType::CustomMap, tr("Custom"), tr("Mapbox custom map"), false, false, 0);
+ setSupportedMapTypes(mapTypes);
+
+ QGeoTileFetcherMapbox *tileFetcher = new QGeoTileFetcherMapbox(this);
+ if (parameters.contains(QStringLiteral("useragent"))) {
+ const QByteArray ua = parameters.value(QStringLiteral("useragent")).toString().toLatin1();
+ tileFetcher->setUserAgent(ua);
+ }
+ if (parameters.contains(QStringLiteral("mapbox.map_id"))) {
+ const QString id = parameters.value(QStringLiteral("mapbox.map_id")).toString();
+ tileFetcher->setMapId(id);
+ }
+ if (parameters.contains(QStringLiteral("mapbox.format"))) {
+ const QString format = parameters.value(QStringLiteral("mapbox.format")).toString();
+ tileFetcher->setFormat(format);
+ }
+ if (parameters.contains(QStringLiteral("mapbox.access_token"))) {
+ const QString token = parameters.value(QStringLiteral("mapbox.access_token")).toString();
+ tileFetcher->setAccessToken(token);
+ }
+
+ setTileFetcher(tileFetcher);
+
+ *error = QGeoServiceProvider::NoError;
+ errorString->clear();
+}
+
+QGeoTiledMappingManagerEngineMapbox::~QGeoTiledMappingManagerEngineMapbox()
+{
+}
+
+QGeoMapData *QGeoTiledMappingManagerEngineMapbox::createMapData()
+{
+ return new QGeoTiledMapData(this, 0);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.h b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.h
new file mode 100644
index 00000000..0d0f7ff7
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOTILEDMAPPINGMANAGERENGINEMAPBOX_H
+#define QGEOTILEDMAPPINGMANAGERENGINEMAPBOX_H
+
+#include <QtLocation/QGeoServiceProvider>
+
+#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGeoTiledMappingManagerEngineMapbox : public QGeoTiledMappingManagerEngine
+{
+ Q_OBJECT
+
+public:
+ QGeoTiledMappingManagerEngineMapbox(const QVariantMap &parameters,
+ QGeoServiceProvider::Error *error, QString *errorString);
+ ~QGeoTiledMappingManagerEngineMapbox();
+
+ QGeoMapData *createMapData();
+};
+
+QT_END_NAMESPACE
+
+#endif // QGEOTILEDMAPPINGMANAGERENGINEMAPBOX_H
diff --git a/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
new file mode 100644
index 00000000..109b6f41
--- /dev/null
+++ b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotilefetchermapbox.h"
+#include "qgeomapreplymapbox.h"
+
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkRequest>
+#include <QtLocation/private/qgeotilespec_p.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QGeoTileFetcherMapbox::QGeoTileFetcherMapbox(QObject *parent)
+: QGeoTileFetcher(parent), m_networkManager(new QNetworkAccessManager(this)),
+ m_userAgent("Qt Location based application"),
+ m_mapId(""),
+ m_format("png"),
+ m_replyFormat("png"),
+ m_accessToken("")
+{
+}
+
+void QGeoTileFetcherMapbox::setUserAgent(const QByteArray &userAgent)
+{
+ m_userAgent = userAgent;
+}
+
+void QGeoTileFetcherMapbox::setMapId(const QString &mapId)
+{
+ m_mapId = mapId;
+}
+
+void QGeoTileFetcherMapbox::setFormat(const QString &format)
+{
+ m_format = format;
+
+ if (m_format == "png" || m_format == "png32" || m_format == "png64" || m_format == "png128" || m_format == "png256")
+ m_replyFormat = "png";
+ else if (m_format == "jpg70" || m_format == "jpg80" || m_format == "jpg90")
+ m_replyFormat = "jpg";
+ else
+ qWarning() << "Unknown map format " << m_format;
+}
+
+void QGeoTileFetcherMapbox::setAccessToken(const QString &accessToken)
+{
+ m_accessToken = accessToken;
+}
+
+QGeoTiledMapReply *QGeoTileFetcherMapbox::getTileImage(const QGeoTileSpec &spec)
+{
+ QNetworkRequest request;
+ request.setRawHeader("User-Agent", m_userAgent);
+
+ request.setUrl(QUrl(QStringLiteral("http://api.tiles.mapbox.com/v4/") +
+ m_mapId + QLatin1Char('/') +
+ QString::number(spec.zoom()) + QLatin1Char('/') +
+ QString::number(spec.x()) + QLatin1Char('/') +
+ QString::number(spec.y()) + QLatin1Char('.') +
+ m_format + QLatin1Char('?') +
+ QStringLiteral("access_token=") + m_accessToken));
+
+ QNetworkReply *reply = m_networkManager->get(request);
+
+ return new QGeoMapReplyMapbox(reply, spec, m_replyFormat);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativecoordinate_p.h b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
index c12548fb..9980b308 100644
--- a/src/imports/positioning/qdeclarativecoordinate_p.h
+++ b/src/plugins/geoservices/mapbox/qgeotilefetchermapbox.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Canonical Ltd.
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtPositioning module of the Qt Toolkit.
+** This file is part of the QtLocation module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -29,49 +29,41 @@
**
** $QT_END_LICENSE$
**
-***************************************************************************/
+****************************************************************************/
-#ifndef QDECLARATIVECOORDINATE_H
-#define QDECLARATIVECOORDINATE_H
+#ifndef QGEOTILEFETCHERMAPBOX_H
+#define QGEOTILEFETCHERMAPBOX_H
-#include <QtQml/private/qqmlvaluetype_p.h>
-#include <QtPositioning/QGeoCoordinate>
+#include <QtLocation/private/qgeotilefetcher_p.h>
QT_BEGIN_NAMESPACE
-class CoordinateValueType : public QQmlValueTypeBase<QGeoCoordinate>
+class QGeoTiledMappingManagerEngine;
+class QNetworkAccessManager;
+
+class QGeoTileFetcherMapbox : public QGeoTileFetcher
{
Q_OBJECT
- Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
- Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
- Q_PROPERTY(double altitude READ altitude WRITE setAltitude)
- Q_PROPERTY(bool isValid READ isValid)
-
public:
- explicit CoordinateValueType(QObject *parent = 0);
- ~CoordinateValueType();
-
- Q_INVOKABLE qreal distanceTo(const QGeoCoordinate &coordinate) const;
- Q_INVOKABLE qreal azimuthTo(const QGeoCoordinate &coordinate) const;
-
- Q_INVOKABLE QGeoCoordinate atDistanceAndAzimuth(qreal distance, qreal azimuth) const;
-
- double latitude() const;
- void setLatitude(double latitude);
-
- double longitude() const;
- void setLongitude(double longitude);
+ QGeoTileFetcherMapbox(QObject *parent = 0);
- double altitude() const;
- void setAltitude(double altitude);
+ void setUserAgent(const QByteArray &userAgent);
+ void setMapId(const QString &mapId);
+ void setFormat(const QString &format);
+ void setAccessToken(const QString &accessToken);
- bool isValid() const;
+private:
+ QGeoTiledMapReply *getTileImage(const QGeoTileSpec &spec);
- QString toString() const Q_DECL_OVERRIDE;
- bool isEqual(const QVariant &other) const Q_DECL_OVERRIDE;
+ QNetworkAccessManager *m_networkManager;
+ QByteArray m_userAgent;
+ QString m_mapId;
+ QString m_format;
+ QString m_replyFormat;
+ QString m_accessToken;
};
QT_END_NAMESPACE
-#endif
+#endif // QGEOTILEFETCHERMAPBOX_H
diff --git a/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
index 865396ba..ec9b18fb 100644
--- a/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeomapreply_nokia.cpp
@@ -49,7 +49,6 @@ QGeoMapReplyNokia::QGeoMapReplyNokia(QNetworkReply *reply, const QGeoTileSpec &s
: QGeoTiledMapReply(spec, parent),
m_reply(reply)
{
- m_reply->setParent(this);
connect(m_reply,
SIGNAL(finished()),
this,
@@ -59,11 +58,6 @@ QGeoMapReplyNokia::QGeoMapReplyNokia(QNetworkReply *reply, const QGeoTileSpec &s
SIGNAL(error(QNetworkReply::NetworkError)),
this,
SLOT(networkError(QNetworkReply::NetworkError)));
-
- connect(m_reply,
- SIGNAL(destroyed()),
- this,
- SLOT(replyDestroyed()));
}
QGeoMapReplyNokia::~QGeoMapReplyNokia()
@@ -83,11 +77,6 @@ void QGeoMapReplyNokia::abort()
m_reply->abort();
}
-void QGeoMapReplyNokia::replyDestroyed()
-{
- m_reply = 0;
-}
-
void QGeoMapReplyNokia::networkFinished()
{
if (!m_reply)
diff --git a/src/plugins/geoservices/nokia/qgeomapreply_nokia.h b/src/plugins/geoservices/nokia/qgeomapreply_nokia.h
index c1c8e245..526bccb0 100644
--- a/src/plugins/geoservices/nokia/qgeomapreply_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeomapreply_nokia.h
@@ -44,6 +44,7 @@
#include <QtNetwork/QNetworkReply>
#include <QtLocation/private/qgeotilespec_p.h>
#include <QtLocation/private/qgeotiledmapreply_p.h>
+#include <QtCore/QPointer>
QT_BEGIN_NAMESPACE
@@ -60,12 +61,11 @@ public:
QNetworkReply *networkReply() const;
private Q_SLOTS:
- void replyDestroyed();
void networkFinished();
void networkError(QNetworkReply::NetworkError error);
private:
- QNetworkReply *m_reply;
+ QPointer<QNetworkReply> m_reply;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
index f3e60deb..3486008d 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.cpp
@@ -67,7 +67,6 @@ QGeoTiledMapDataNokia::~QGeoTiledMapDataNokia() {}
void QGeoTiledMapDataNokia::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles)
{
- const int copyrightsMargin = 10;
const int spaceToLogo = 4;
const int blurRate = 1;
const int fontSize = 10;
@@ -106,18 +105,10 @@ void QGeoTiledMapDataNokia::evaluateCopyrights(const QSet<QGeoTileSpec> &visible
copyrightsString);
painter.end();
- QPoint copyrightsPos(copyrightsMargin, height() - (copyrightsSlab.height() + copyrightsMargin));
- lastCopyrightsPos = copyrightsPos;
- emit copyrightsChanged(copyrightsSlab, copyrightsPos);
-
lastCopyrightsString = copyrightsString;
}
- QPoint copyrightsPos(copyrightsMargin, height() - (copyrightsSlab.height() + copyrightsMargin));
- if (copyrightsPos != lastCopyrightsPos) {
- lastCopyrightsPos = copyrightsPos;
- emit copyrightsChanged(copyrightsSlab, copyrightsPos);
- }
+ emit copyrightsChanged(copyrightsSlab);
}
int QGeoTiledMapDataNokia::mapVersion()
diff --git a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h
index ac9c6530..7c24acfe 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeotiledmapdata_nokia.h
@@ -67,7 +67,6 @@ private:
QImage logo;
QImage copyrightsSlab;
QString lastCopyrightsString;
- QPoint lastCopyrightsPos;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
index d200712e..5da9c3be 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
@@ -329,27 +329,15 @@ QPlaceContentReply *QPlaceManagerEngineNokiaV2::getPlaceContent(const QPlaceCont
static bool addAtForBoundingArea(const QGeoShape &area,
QUrlQuery *queryItems)
{
- QGeoCoordinate center;
- switch (area.type()) {
- case QGeoShape::RectangleType:
- center = QGeoRectangle(area).center();
- break;
- case QGeoShape::CircleType:
- center = QGeoCircle(area).center();
- break;
- case QGeoShape::UnknownType:
- break;
- }
-
- if (!center.isValid()) {
+ QGeoCoordinate center = area.center();
+ if (!center.isValid())
return false;
- } else {
- queryItems->addQueryItem(QStringLiteral("at"),
- QString::number(center.latitude()) +
- QLatin1Char(',') +
- QString::number(center.longitude()));
- return true;
- }
+
+ queryItems->addQueryItem(QStringLiteral("at"),
+ QString::number(center.latitude()) +
+ QLatin1Char(',') +
+ QString::number(center.longitude()));
+ return true;
}
QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest &query)
diff --git a/src/plugins/geoservices/osm/osm.pro b/src/plugins/geoservices/osm/osm.pro
index f8744061..bfae8284 100644
--- a/src/plugins/geoservices/osm/osm.pro
+++ b/src/plugins/geoservices/osm/osm.pro
@@ -8,23 +8,30 @@ load(qt_plugin)
HEADERS += \
qgeoserviceproviderpluginosm.h \
qgeotiledmappingmanagerengineosm.h \
+ qgeotiledmapdataosm.h \
qgeotilefetcherosm.h \
qgeomapreplyosm.h \
qgeocodingmanagerengineosm.h \
qgeocodereplyosm.h \
qgeoroutingmanagerengineosm.h \
- qgeoroutereplyosm.h
-
+ qgeoroutereplyosm.h \
+ qplacemanagerengineosm.h \
+ qplacesearchreplyimpl.h \
+ qplacecategoriesreplyimpl.h
SOURCES += \
qgeoserviceproviderpluginosm.cpp \
qgeotiledmappingmanagerengineosm.cpp \
+ qgeotiledmapdataosm.cpp \
qgeotilefetcherosm.cpp \
qgeomapreplyosm.cpp \
qgeocodingmanagerengineosm.cpp \
qgeocodereplyosm.cpp \
qgeoroutingmanagerengineosm.cpp \
- qgeoroutereplyosm.cpp
+ qgeoroutereplyosm.cpp \
+ qplacemanagerengineosm.cpp \
+ qplacesearchreplyimpl.cpp \
+ qplacecategoriesreplyimpl.cpp
OTHER_FILES += \
osm_plugin.json
diff --git a/src/plugins/geoservices/osm/osm_plugin.json b/src/plugins/geoservices/osm/osm_plugin.json
index 394be376..1aaf6f7f 100644
--- a/src/plugins/geoservices/osm/osm_plugin.json
+++ b/src/plugins/geoservices/osm/osm_plugin.json
@@ -7,6 +7,7 @@
"OnlineMappingFeature",
"OnlineGeocodingFeature",
"ReverseGeocodingFeature",
- "OnlineRoutingFeature"
+ "OnlineRoutingFeature",
+ "OnlinePlacesFeature"
]
}
diff --git a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
index 2970641d..2b644d10 100644
--- a/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeomapreplyosm.cpp
@@ -41,7 +41,6 @@ QGeoMapReplyOsm::QGeoMapReplyOsm(QNetworkReply *reply, const QGeoTileSpec &spec,
connect(m_reply, SIGNAL(finished()), this, SLOT(networkReplyFinished()));
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(networkReplyError(QNetworkReply::NetworkError)));
- connect(m_reply, SIGNAL(destroyed()), this, SLOT(replyDestroyed()));
}
QGeoMapReplyOsm::~QGeoMapReplyOsm()
@@ -65,11 +64,6 @@ QNetworkReply *QGeoMapReplyOsm::networkReply() const
return m_reply;
}
-void QGeoMapReplyOsm::replyDestroyed()
-{
- m_reply = 0;
-}
-
void QGeoMapReplyOsm::networkReplyFinished()
{
if (!m_reply)
@@ -81,16 +75,7 @@ void QGeoMapReplyOsm::networkReplyFinished()
QByteArray a = m_reply->readAll();
setMapImageData(a);
- switch (tileSpec().mapId()) {
- case 1:
- setMapImageFormat("png");
- break;
- case 2:
- setMapImageFormat("png");
- break;
- default:
- qWarning("Unknown map id %d", tileSpec().mapId());
- }
+ setMapImageFormat("png");
setFinished(true);
diff --git a/src/plugins/geoservices/osm/qgeomapreplyosm.h b/src/plugins/geoservices/osm/qgeomapreplyosm.h
index 1672258d..1795ffa9 100644
--- a/src/plugins/geoservices/osm/qgeomapreplyosm.h
+++ b/src/plugins/geoservices/osm/qgeomapreplyosm.h
@@ -36,6 +36,7 @@
#include <QtNetwork/QNetworkReply>
#include <QtLocation/private/qgeotiledmapreply_p.h>
+#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
@@ -52,12 +53,11 @@ public:
QNetworkReply *networkReply() const;
private Q_SLOTS:
- void replyDestroyed();
void networkReplyFinished();
void networkReplyError(QNetworkReply::NetworkError error);
private:
- QNetworkReply *m_reply;
+ QPointer<QNetworkReply> m_reply;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
index f2647f3d..5641bfa4 100644
--- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp
@@ -274,7 +274,7 @@ static QGeoRoute constructRoute(const QByteArray &geometry, const QJsonArray &in
for (int i = instructions.count() - 1; i >= 0; --i) {
QJsonArray instruction = instructions.at(i).toArray();
- if (instruction.count() != 8) {
+ if (instruction.count() < 8) {
qWarning("Instruction does not contain enough fields.");
continue;
}
diff --git a/src/plugins/geoservices/osm/qgeoserviceproviderpluginosm.cpp b/src/plugins/geoservices/osm/qgeoserviceproviderpluginosm.cpp
index 085c2a49..900921d3 100644
--- a/src/plugins/geoservices/osm/qgeoserviceproviderpluginosm.cpp
+++ b/src/plugins/geoservices/osm/qgeoserviceproviderpluginosm.cpp
@@ -35,8 +35,7 @@
#include "qgeotiledmappingmanagerengineosm.h"
#include "qgeocodingmanagerengineosm.h"
#include "qgeoroutingmanagerengineosm.h"
-
-#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
+#include "qplacemanagerengineosm.h"
QT_BEGIN_NAMESPACE
@@ -61,11 +60,7 @@ QGeoRoutingManagerEngine *QGeoServiceProviderFactoryOsm::createRoutingManagerEng
QPlaceManagerEngine *QGeoServiceProviderFactoryOsm::createPlaceManagerEngine(
const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
- Q_UNUSED(parameters)
- Q_UNUSED(error)
- Q_UNUSED(errorString)
-
- return 0;
+ return new QPlaceManagerEngineOsm(parameters, error, errorString);
}
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp b/src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp
new file mode 100644
index 00000000..5b9173cb
--- /dev/null
+++ b/src/plugins/geoservices/osm/qgeotiledmapdataosm.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeotiledmapdataosm.h"
+#include "qgeotiledmappingmanagerengineosm.h"
+
+#include <QtLocation/private/qgeotilespec_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QGeoTiledMapDataOsm::QGeoTiledMapDataOsm(QGeoTiledMappingManagerEngineOsm *engine, QObject *parent)
+: QGeoTiledMapData(engine, parent), m_mapId(-1)
+{
+}
+
+QGeoTiledMapDataOsm::~QGeoTiledMapDataOsm()
+{
+}
+
+void QGeoTiledMapDataOsm::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles)
+{
+ if (visibleTiles.isEmpty())
+ return;
+
+ QGeoTileSpec tile = *visibleTiles.constBegin();
+ if (tile.mapId() == m_mapId)
+ return;
+
+ m_mapId = tile.mapId();
+
+ QString copyrights;
+ switch (m_mapId) {
+ case 1:
+ case 2:
+ // set attribution to Map Quest
+ copyrights = tr("Tiles Courtesy of <a href='http://www.mapquest.com/'>MapQuest</a><br/>Data \u00a9 <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors");
+ break;
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ // set attribution to Thunder Forest
+ copyrights = tr("Maps \u00a9 <a href='http://www.thunderforest.com/'>Thunderforest</a><br/>Data \u00a9 <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors");
+ break;
+ default:
+ // set attribution to OSM
+ copyrights = tr("\u00a9 <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors");
+ }
+
+ emit copyrightsChanged(copyrights);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativegeocircle.h b/src/plugins/geoservices/osm/qgeotiledmapdataosm.h
index d5ad8ec8..ffd24dc2 100644
--- a/src/imports/positioning/qdeclarativegeocircle.h
+++ b/src/plugins/geoservices/osm/qgeotiledmapdataosm.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the QtPositioning module of the Qt Toolkit.
+** This file is part of the QtLocation module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -29,37 +29,29 @@
**
** $QT_END_LICENSE$
**
-***************************************************************************/
+****************************************************************************/
-#ifndef QDECLARATIVEGEOCIRCLE_H
-#define QDECLARATIVEGEOCIRCLE_H
+#ifndef QGEOTILEDMAPDATAOSM_H
+#define QGEOTILEDMAPDATAOSM_H
-#include "qdeclarativegeoshape.h"
+#include <QtLocation/private/qgeotiledmapdata_p.h>
QT_BEGIN_NAMESPACE
-class GeoCircleValueType : public GeoShapeValueType
+class QGeoTiledMappingManagerEngineOsm;
+class QGeoTiledMapDataOsm: public QGeoTiledMapData
{
Q_OBJECT
- Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
- Q_PROPERTY(qreal radius READ radius WRITE setRadius)
-
public:
- explicit GeoCircleValueType(QObject *parent = 0);
- ~GeoCircleValueType();
-
- QGeoCoordinate center();
- void setCenter(const QGeoCoordinate &coordinate);
+ QGeoTiledMapDataOsm(QGeoTiledMappingManagerEngineOsm *engine, QObject *parent = 0);
+ ~QGeoTiledMapDataOsm();
- qreal radius() const;
- void setRadius(qreal radius);
+protected:
+ void evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles) Q_DECL_OVERRIDE;
- QString toString() const Q_DECL_OVERRIDE;
- void setValue(const QVariant &value) Q_DECL_OVERRIDE;
- QVariant value() Q_DECL_OVERRIDE;
- void write(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags flags) Q_DECL_OVERRIDE;
- void writeVariantValue(QObject *obj, int idx, QQmlPropertyPrivate::WriteFlags, QVariant *from) Q_DECL_OVERRIDE;
+private:
+ int m_mapId;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
index e549007f..4e018f51 100644
--- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
@@ -33,6 +33,7 @@
#include "qgeotiledmappingmanagerengineosm.h"
#include "qgeotilefetcherosm.h"
+#include "qgeotiledmapdataosm.h"
#include <QtLocation/private/qgeocameracapabilities_p.h>
#include <QtLocation/private/qgeomaptype_p.h>
@@ -51,8 +52,14 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
setTileSize(QSize(256, 256));
QList<QGeoMapType> mapTypes;
- mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("OpenStreetMap street map"), false, false, 1);
- mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("OpenStreetMap satellite map"), false, false, 2);
+ // See map type implementations in QGeoTiledMapDataOsm and QGeoTileFetcherOsm.
+ mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Street map view in daylight mode"), false, false, 1);
+ mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2);
+ mapTypes << QGeoMapType(QGeoMapType::CycleMap, tr("Cycle Map"), tr("Cycle map view in daylight mode"), false, false, 3);
+ mapTypes << QGeoMapType(QGeoMapType::TransitMap, tr("Transit Map"), tr("Public transit map view in daylight mode"), false, false, 4);
+ mapTypes << QGeoMapType(QGeoMapType::TransitMap, tr("Night Transit Map"), tr("Public transit map view in night mode"), false, true, 5);
+ mapTypes << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view"), false, false, 6);
+ mapTypes << QGeoMapType(QGeoMapType::PedestrianMap, tr("Hiking Map"), tr("Hiking map view"), false, false, 7);
setSupportedMapTypes(mapTypes);
QGeoTileFetcherOsm *tileFetcher = new QGeoTileFetcherOsm(this);
@@ -73,7 +80,7 @@ QGeoTiledMappingManagerEngineOsm::~QGeoTiledMappingManagerEngineOsm()
QGeoMapData *QGeoTiledMappingManagerEngineOsm::createMapData()
{
- return new QGeoTiledMapData(this, 0);
+ return new QGeoTiledMapDataOsm(this);
}
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
index 32f05030..10fd1709 100644
--- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp
@@ -56,25 +56,38 @@ QGeoTiledMapReply *QGeoTileFetcherOsm::getTileImage(const QGeoTileSpec &spec)
QNetworkRequest request;
request.setRawHeader("User-Agent", m_userAgent);
+ QString urlPrefix;
+
switch (spec.mapId()) {
- case 1:
- // opensteetmap.org street map
- request.setUrl(QUrl(QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/map/") +
- QString::number(spec.zoom()) + QLatin1Char('/') +
- QString::number(spec.x()) + QLatin1Char('/') +
- QString::number(spec.y()) + QStringLiteral(".png")));
- break;
- case 2:
- // opensteetmap.org satellite map
- request.setUrl(QUrl(QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/sat/") +
- QString::number(spec.zoom()) + QLatin1Char('/') +
- QString::number(spec.x()) + QLatin1Char('/') +
- QString::number(spec.y()) + QStringLiteral(".png")));
- break;
- default:
- qWarning("Unknown map id %d\n", spec.mapId());
+ case 1:
+ urlPrefix = QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/map/");
+ break;
+ case 2:
+ urlPrefix = QStringLiteral("http://otile1.mqcdn.com/tiles/1.0.0/sat/");
+ break;
+ case 3:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/cycle/");
+ break;
+ case 4:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/transport/");
+ break;
+ case 5:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/transport-dark/");
+ break;
+ case 6:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/landscape/");
+ break;
+ case 7:
+ urlPrefix = QStringLiteral("http://a.tile.thunderforest.com/outdoors/");
+ break;
+ default:
+ qWarning("Unknown map id %d\n", spec.mapId());
}
+ request.setUrl(QUrl(urlPrefix + QString::number(spec.zoom()) + QLatin1Char('/') +
+ QString::number(spec.x()) + QLatin1Char('/') +
+ QString::number(spec.y()) + QStringLiteral(".png")));
+
QNetworkReply *reply = m_networkManager->get(request);
return new QGeoMapReplyOsm(reply, spec);
diff --git a/src/plugins/geoservices/osm/qplacecategoriesreplyimpl.cpp b/src/plugins/geoservices/osm/qplacecategoriesreplyimpl.cpp
new file mode 100644
index 00000000..4ad108f0
--- /dev/null
+++ b/src/plugins/geoservices/osm/qplacecategoriesreplyimpl.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplacecategoriesreplyimpl.h"
+
+QT_BEGIN_NAMESPACE
+
+QPlaceCategoriesReplyImpl::QPlaceCategoriesReplyImpl(QObject *parent)
+: QPlaceReply(parent)
+{
+}
+
+QPlaceCategoriesReplyImpl::~QPlaceCategoriesReplyImpl()
+{
+}
+
+void QPlaceCategoriesReplyImpl::emitFinished()
+{
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceCategoriesReplyImpl::setError(QPlaceReply::Error errorCode, const QString &errorString)
+{
+ QPlaceReply::setError(errorCode, errorString);
+ emit error(errorCode, errorString);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qplacecategoriesreplyimpl.h b/src/plugins/geoservices/osm/qplacecategoriesreplyimpl.h
new file mode 100644
index 00000000..a68290a9
--- /dev/null
+++ b/src/plugins/geoservices/osm/qplacecategoriesreplyimpl.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLACECATEGORIESREPLYIMPL_H
+#define QPLACECATEGORIESREPLYIMPL_H
+
+#include <QtLocation/QPlaceReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceCategoriesReplyImpl : public QPlaceReply
+{
+ Q_OBJECT
+
+public:
+ explicit QPlaceCategoriesReplyImpl(QObject *parent = 0);
+ ~QPlaceCategoriesReplyImpl();
+
+ void emitFinished();
+ void setError(QPlaceReply::Error errorCode, const QString &errorString);
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACECATEGORIESREPLYIMPL_H
diff --git a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp
new file mode 100644
index 00000000..1c59044f
--- /dev/null
+++ b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp
@@ -0,0 +1,354 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtFoo module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplacemanagerengineosm.h"
+#include "qplacesearchreplyimpl.h"
+#include "qplacecategoriesreplyimpl.h"
+
+#include <QtCore/QUrlQuery>
+#include <QtCore/QXmlStreamReader>
+#include <QtCore/QRegularExpression>
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkRequest>
+#include <QtNetwork/QNetworkReply>
+#include <QtPositioning/QGeoCircle>
+#include <QtLocation/private/unsupportedreplies_p.h>
+
+#include <QtCore/QElapsedTimer>
+
+namespace
+{
+QString SpecialPhrasesBaseUrl = QStringLiteral("http://wiki.openstreetmap.org/wiki/Special:Export/Nominatim/Special_Phrases/");
+
+QString nameForTagKey(const QString &tagKey)
+{
+ if (tagKey == QLatin1String("aeroway"))
+ return QPlaceManagerEngineOsm::tr("Aeroway");
+ else if (tagKey == QLatin1String("amenity"))
+ return QPlaceManagerEngineOsm::tr("Amenity");
+ else if (tagKey == QLatin1String("building"))
+ return QPlaceManagerEngineOsm::tr("Building");
+ else if (tagKey == QLatin1String("highway"))
+ return QPlaceManagerEngineOsm::tr("Highway");
+ else if (tagKey == QLatin1String("historic"))
+ return QPlaceManagerEngineOsm::tr("Historic");
+ else if (tagKey == QLatin1String("landuse"))
+ return QPlaceManagerEngineOsm::tr("Land use");
+ else if (tagKey == QLatin1String("leisure"))
+ return QPlaceManagerEngineOsm::tr("Leisure");
+ else if (tagKey == QLatin1String("man_made"))
+ return QPlaceManagerEngineOsm::tr("Man made");
+ else if (tagKey == QLatin1String("natural"))
+ return QPlaceManagerEngineOsm::tr("Natural");
+ else if (tagKey == QLatin1String("place"))
+ return QPlaceManagerEngineOsm::tr("Place");
+ else if (tagKey == QLatin1String("railway"))
+ return QPlaceManagerEngineOsm::tr("Railway");
+ else if (tagKey == QLatin1String("shop"))
+ return QPlaceManagerEngineOsm::tr("Shop");
+ else if (tagKey == QLatin1String("tourism"))
+ return QPlaceManagerEngineOsm::tr("Tourism");
+ else if (tagKey == QLatin1String("waterway"))
+ return QPlaceManagerEngineOsm::tr("Waterway");
+ else
+ return tagKey;
+}
+
+}
+
+QPlaceManagerEngineOsm::QPlaceManagerEngineOsm(const QVariantMap &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString)
+: QPlaceManagerEngine(parameters), m_networkManager(new QNetworkAccessManager(this)),
+ m_categoriesReply(0)
+{
+ if (parameters.contains(QStringLiteral("useragent")))
+ m_userAgent = parameters.value(QStringLiteral("useragent")).toString().toLatin1();
+ else
+ m_userAgent = "Qt Location based application";
+
+ *error = QGeoServiceProvider::NoError;
+ errorString->clear();
+}
+
+QPlaceManagerEngineOsm::~QPlaceManagerEngineOsm()
+{
+}
+
+QPlaceSearchReply *QPlaceManagerEngineOsm::search(const QPlaceSearchRequest &request)
+{
+ bool unsupported = false;
+
+ // Only public visibility supported
+ unsupported |= request.visibilityScope() != QLocation::UnspecifiedVisibility &&
+ request.visibilityScope() != QLocation::PublicVisibility;
+ unsupported |= request.searchTerm().isEmpty() && request.categories().isEmpty();
+
+ if (unsupported)
+ return QPlaceManagerEngine::search(request);
+
+ QUrlQuery queryItems;
+
+ queryItems.addQueryItem(QStringLiteral("format"), QStringLiteral("jsonv2"));
+
+ //queryItems.addQueryItem(QStringLiteral("accept-language"), QStringLiteral("en"));
+
+ QGeoRectangle boundingBox;
+ QGeoShape searchArea = request.searchArea();
+ switch (searchArea.type()) {
+ case QGeoShape::CircleType: {
+ QGeoCircle c(searchArea);
+ qreal radius = c.radius();
+ if (radius < 0)
+ radius = 50000;
+
+ boundingBox = QGeoRectangle(c.center().atDistanceAndAzimuth(radius, -45),
+ c.center().atDistanceAndAzimuth(radius, 135));
+ break;
+ }
+ case QGeoShape::RectangleType:
+ boundingBox = searchArea;
+ break;
+ default:
+ ;
+ }
+
+ if (!boundingBox.isEmpty()) {
+ queryItems.addQueryItem(QStringLiteral("bounded"), QStringLiteral("1"));
+ QString coordinates;
+ coordinates = QString::number(boundingBox.topLeft().longitude()) + QLatin1Char(',') +
+ QString::number(boundingBox.topLeft().latitude()) + QLatin1Char(',') +
+ QString::number(boundingBox.bottomRight().longitude()) + QLatin1Char(',') +
+ QString::number(boundingBox.bottomRight().latitude());
+ queryItems.addQueryItem(QStringLiteral("viewbox"), coordinates);
+ }
+
+ QStringList queryParts;
+ if (!request.searchTerm().isEmpty())
+ queryParts.append(request.searchTerm());
+
+ foreach (const QPlaceCategory &category, request.categories()) {
+ QString id = category.categoryId();
+ int index = id.indexOf(QLatin1Char('='));
+ if (index != -1)
+ id = id.mid(index+1);
+ queryParts.append(QLatin1Char('[') + id + QLatin1Char(']'));
+ }
+
+ queryItems.addQueryItem(QStringLiteral("q"), queryParts.join(QLatin1Char('+')));
+
+ QVariantMap parameters = request.searchContext().toMap();
+
+ QStringList placeIds = parameters.value(QStringLiteral("ExcludePlaceIds")).toStringList();
+ if (!placeIds.isEmpty())
+ queryItems.addQueryItem(QStringLiteral("exclude_place_ids"), placeIds.join(QLatin1Char(',')));
+
+ queryItems.addQueryItem(QStringLiteral("addressdetails"), QStringLiteral("1"));
+
+ QUrl requestUrl(QStringLiteral("http://nominatim.openstreetmap.org/search?"));
+ requestUrl.setQuery(queryItems);
+
+ QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(requestUrl));
+
+ QPlaceSearchReplyImpl *reply = new QPlaceSearchReplyImpl(request, networkReply, this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ return reply;
+}
+
+QPlaceReply *QPlaceManagerEngineOsm::initializeCategories()
+{
+ // Only fetch categories once
+ if (m_categories.isEmpty() && !m_categoriesReply) {
+ m_categoryLocales = m_locales;
+ m_categoryLocales.append(QLocale(QLocale::English));
+ fetchNextCategoryLocale();
+ }
+
+ QPlaceCategoriesReplyImpl *reply = new QPlaceCategoriesReplyImpl(this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ // TODO delayed finished() emission
+ if (!m_categories.isEmpty())
+ reply->emitFinished();
+
+ m_pendingCategoriesReply.append(reply);
+ return reply;
+}
+
+QString QPlaceManagerEngineOsm::parentCategoryId(const QString &categoryId) const
+{
+ Q_UNUSED(categoryId)
+
+ // Only a two category levels
+ return QString();
+}
+
+QStringList QPlaceManagerEngineOsm::childCategoryIds(const QString &categoryId) const
+{
+ return m_subcategories.value(categoryId);
+}
+
+QPlaceCategory QPlaceManagerEngineOsm::category(const QString &categoryId) const
+{
+ return m_categories.value(categoryId);
+}
+
+QList<QPlaceCategory> QPlaceManagerEngineOsm::childCategories(const QString &parentId) const
+{
+ QList<QPlaceCategory> categories;
+ foreach (const QString &id, m_subcategories.value(parentId))
+ categories.append(m_categories.value(id));
+ return categories;
+}
+
+QList<QLocale> QPlaceManagerEngineOsm::locales() const
+{
+ return m_locales;
+}
+
+void QPlaceManagerEngineOsm::setLocales(const QList<QLocale> &locales)
+{
+ m_locales = locales;
+}
+
+void QPlaceManagerEngineOsm::categoryReplyFinished()
+{
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ if (!reply)
+ return;
+
+ reply->deleteLater();
+
+ QXmlStreamReader parser(reply);
+ while (!parser.atEnd() && parser.readNextStartElement()) {
+ if (parser.name() == QLatin1String("mediawiki"))
+ continue;
+ if (parser.name() == QLatin1String("page"))
+ continue;
+ if (parser.name() == QLatin1String("revision"))
+ continue;
+ if (parser.name() == QLatin1String("text")) {
+ // parse
+ QString page = parser.readElementText();
+ QRegularExpression regex(QStringLiteral("\\| ([^|]+) \\|\\| ([^|]+) \\|\\| ([^|]+) \\|\\| ([^|]+) \\|\\| ([\\-YN])"));
+ QRegularExpressionMatchIterator i = regex.globalMatch(page);
+ while (i.hasNext()) {
+ QRegularExpressionMatch match = i.next();
+ QString name = match.capturedRef(1).toString();
+ QString tagKey = match.capturedRef(2).toString();
+ QString tagValue = match.capturedRef(3).toString();
+ QString op = match.capturedRef(4).toString();
+ QString plural = match.capturedRef(5).toString();
+
+ // Only interested in any operator plural forms
+ if (op != QLatin1String("-") || plural != QLatin1String("Y"))
+ continue;
+
+ if (!m_categories.contains(tagKey)) {
+ QPlaceCategory category;
+ category.setCategoryId(tagKey);
+ category.setName(nameForTagKey(tagKey));
+ m_categories.insert(category.categoryId(), category);
+ m_subcategories[QString()].append(tagKey);
+ emit categoryAdded(category, QString());
+ }
+
+ QPlaceCategory category;
+ category.setCategoryId(tagKey + QLatin1Char('=') + tagValue);
+ category.setName(name);
+
+ if (!m_categories.contains(category.categoryId())) {
+ m_categories.insert(category.categoryId(), category);
+ m_subcategories[tagKey].append(category.categoryId());
+ emit categoryAdded(category, tagKey);
+ }
+ }
+ }
+
+ parser.skipCurrentElement();
+ }
+
+ if (m_categories.isEmpty() && !m_categoryLocales.isEmpty()) {
+ fetchNextCategoryLocale();
+ return;
+ } else {
+ m_categoryLocales.clear();
+ }
+
+ foreach (QPlaceCategoriesReplyImpl *reply, m_pendingCategoriesReply)
+ reply->emitFinished();
+ m_pendingCategoriesReply.clear();
+}
+
+void QPlaceManagerEngineOsm::categoryReplyError()
+{
+ foreach (QPlaceCategoriesReplyImpl *reply, m_pendingCategoriesReply)
+ reply->setError(QPlaceReply::CommunicationError, tr("Network request error"));
+}
+
+void QPlaceManagerEngineOsm::replyFinished()
+{
+ QPlaceReply *reply = qobject_cast<QPlaceReply *>(sender());
+ if (reply)
+ emit finished(reply);
+}
+
+void QPlaceManagerEngineOsm::replyError(QPlaceReply::Error errorCode, const QString &errorString)
+{
+ QPlaceReply *reply = qobject_cast<QPlaceReply *>(sender());
+ if (reply)
+ emit error(reply, errorCode, errorString);
+}
+
+void QPlaceManagerEngineOsm::fetchNextCategoryLocale()
+{
+ if (m_categoryLocales.isEmpty()) {
+ qWarning("No locales specified to fetch categories for");
+ return;
+ }
+
+ QLocale locale = m_categoryLocales.takeFirst();
+
+ // FIXME: Categories should be cached.
+ QUrl requestUrl = QUrl(SpecialPhrasesBaseUrl + locale.name().left(2).toUpper());
+
+ m_categoriesReply = m_networkManager->get(QNetworkRequest(requestUrl));
+ connect(m_categoriesReply, SIGNAL(finished()), this, SLOT(categoryReplyFinished()));
+ connect(m_categoriesReply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(categoryReplyError()));
+}
diff --git a/src/plugins/geoservices/osm/qplacemanagerengineosm.h b/src/plugins/geoservices/osm/qplacemanagerengineosm.h
new file mode 100644
index 00000000..305d3abe
--- /dev/null
+++ b/src/plugins/geoservices/osm/qplacemanagerengineosm.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtFoo module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLACEMANAGERENGINEOSM_H
+#define QPLACEMANAGERENGINEOSM_H
+
+#include <QtLocation/QPlaceManagerEngine>
+#include <QtLocation/QGeoServiceProvider>
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkAccessManager;
+class QNetworkReply;
+class QPlaceCategoriesReplyImpl;
+
+class QPlaceManagerEngineOsm : public QPlaceManagerEngine
+{
+ Q_OBJECT
+
+public:
+ QPlaceManagerEngineOsm(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+ QString *errorString);
+ ~QPlaceManagerEngineOsm();
+
+ QPlaceSearchReply *search(const QPlaceSearchRequest &request) Q_DECL_OVERRIDE;
+
+ QPlaceReply *initializeCategories() Q_DECL_OVERRIDE;
+ QString parentCategoryId(const QString &categoryId) const Q_DECL_OVERRIDE;
+ QStringList childCategoryIds(const QString &categoryId) const Q_DECL_OVERRIDE;
+ QPlaceCategory category(const QString &categoryId) const Q_DECL_OVERRIDE;
+
+ QList<QPlaceCategory> childCategories(const QString &parentId) const Q_DECL_OVERRIDE;
+
+ QList<QLocale> locales() const Q_DECL_OVERRIDE;
+ void setLocales(const QList<QLocale> &locales) Q_DECL_OVERRIDE;
+
+private slots:
+ void categoryReplyFinished();
+ void categoryReplyError();
+ void replyFinished();
+ void replyError(QPlaceReply::Error errorCode, const QString &errorString);
+
+private:
+ void fetchNextCategoryLocale();
+
+ QNetworkAccessManager *m_networkManager;
+ QByteArray m_userAgent;
+ QList<QLocale> m_locales;
+
+ QNetworkReply *m_categoriesReply;
+ QList<QPlaceCategoriesReplyImpl *> m_pendingCategoriesReply;
+ QHash<QString, QPlaceCategory> m_categories;
+ QHash<QString, QStringList> m_subcategories;
+
+ QList<QLocale> m_categoryLocales;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACEMANAGERENGINEOSM_H
diff --git a/src/plugins/geoservices/osm/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/osm/qplacesearchreplyimpl.cpp
new file mode 100644
index 00000000..22043c09
--- /dev/null
+++ b/src/plugins/geoservices/osm/qplacesearchreplyimpl.cpp
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtFoo module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplacesearchreplyimpl.h"
+#include "qplacemanagerengineosm.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonArray>
+#include <QtCore/QJsonObject>
+#include <QtNetwork/QNetworkReply>
+#include <QtPositioning/QGeoCircle>
+#include <QtPositioning/QGeoRectangle>
+#include <QtLocation/QPlaceResult>
+#include <QtLocation/QPlaceSearchRequest>
+
+QT_BEGIN_NAMESPACE
+
+QPlaceSearchReplyImpl::QPlaceSearchReplyImpl(const QPlaceSearchRequest &request,
+ QNetworkReply *reply, QPlaceManagerEngineOsm *parent)
+: QPlaceSearchReply(parent), m_reply(reply)
+{
+ Q_ASSERT(parent);
+
+ setRequest(request);
+
+ if (!m_reply)
+ return;
+
+ m_reply->setParent(this);
+ connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+}
+
+QPlaceSearchReplyImpl::~QPlaceSearchReplyImpl()
+{
+}
+
+void QPlaceSearchReplyImpl::abort()
+{
+ if (m_reply)
+ m_reply->abort();
+}
+
+void QPlaceSearchReplyImpl::setError(QPlaceReply::Error errorCode, const QString &errorString)
+{
+ QPlaceReply::setError(errorCode, errorString);
+ emit error(errorCode, errorString);
+ setFinished(true);
+ emit finished();
+}
+
+static QGeoRectangle parseBoundingBox(const QJsonArray &coordinates)
+{
+ if (coordinates.count() != 4)
+ return QGeoRectangle();
+
+ double bottom = coordinates.at(0).toString().toDouble();
+ double top = coordinates.at(1).toString().toDouble();
+ double left = coordinates.at(2).toString().toDouble();
+ double right = coordinates.at(3).toString().toDouble();
+
+ return QGeoRectangle(QGeoCoordinate(top, left), QGeoCoordinate(bottom, right));
+}
+
+void QPlaceSearchReplyImpl::replyFinished()
+{
+ QNetworkReply *reply = m_reply;
+ m_reply->deleteLater();
+ m_reply = 0;
+
+ if (reply->error() != QNetworkReply::NoError) {
+ setError(CommunicationError, tr("Communication error"));
+ return;
+ }
+
+ QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
+ if (!document.isArray()) {
+ setError(ParseError, tr("Response parse error"));
+ return;
+ }
+
+ QJsonArray resultsArray = document.array();
+
+ QGeoCoordinate searchCenter = request().searchArea().center();
+
+ QStringList placeIds;
+
+ QList<QPlaceSearchResult> results;
+ for (int i = 0; i < resultsArray.count(); ++i) {
+ QJsonObject item = resultsArray.at(i).toObject();
+ QPlaceResult pr = parsePlaceResult(item);
+ pr.setDistance(searchCenter.distanceTo(pr.place().location().coordinate()));
+ placeIds.append(pr.place().placeId());
+ results.append(pr);
+ }
+
+ QVariantMap searchContext = request().searchContext().toMap();
+ QStringList excludePlaceIds =
+ searchContext.value(QStringLiteral("ExcludePlaceIds")).toStringList();
+
+ if (!excludePlaceIds.isEmpty()) {
+ QPlaceSearchRequest r = request();
+ QVariantMap parameters = searchContext;
+
+ QStringList epi = excludePlaceIds;
+ epi.removeLast();
+
+ parameters.insert(QStringLiteral("ExcludePlaceIds"), epi);
+ r.setSearchContext(parameters);
+ setPreviousPageRequest(r);
+ }
+
+ if (!placeIds.isEmpty()) {
+ QPlaceSearchRequest r = request();
+ QVariantMap parameters = searchContext;
+
+ QStringList epi = excludePlaceIds;
+ epi.append(placeIds.join(QLatin1Char(',')));
+
+ parameters.insert(QStringLiteral("ExcludePlaceIds"), epi);
+ r.setSearchContext(parameters);
+ setNextPageRequest(r);
+ }
+
+ setResults(results);
+
+ setFinished(true);
+ emit finished();
+}
+
+QPlaceResult QPlaceSearchReplyImpl::parsePlaceResult(const QJsonObject &item) const
+{
+ QPlace place;
+
+ QGeoCoordinate coordinate = QGeoCoordinate(item.value(QStringLiteral("lat")).toString().toDouble(),
+ item.value(QStringLiteral("lon")).toString().toDouble());
+
+ //const QString placeRank = item.value(QStringLiteral("place_rank")).toString();
+ //const QString category = item.value(QStringLiteral("category")).toString();
+ const QString type = item.value(QStringLiteral("type")).toString();
+ //double importance = item.value(QStringLiteral("importance")).toDouble();
+
+ place.setAttribution(item.value(QStringLiteral("licence")).toString());
+ place.setPlaceId(item.value(QStringLiteral("place_id")).toString());
+
+ QVariantMap iconParameters;
+ iconParameters.insert(QPlaceIcon::SingleUrl,
+ QUrl(item.value(QStringLiteral("icon")).toString()));
+ QPlaceIcon icon;
+ icon.setParameters(iconParameters);
+ place.setIcon(icon);
+
+ QJsonObject addressDetails = item.value(QStringLiteral("address")).toObject();
+
+ const QString title = addressDetails.value(type).toString();
+
+ place.setName(title);
+
+ QGeoAddress address;
+ address.setCity(addressDetails.value(QStringLiteral("city")).toString());
+ address.setCountry(addressDetails.value(QStringLiteral("country")).toString());
+ // FIXME: country_code is alpha-2 setCountryCode takes alpha-3
+ //address.setCountryCode(addressDetails.value(QStringLiteral("country_code")).toString());
+ address.setPostalCode(addressDetails.value(QStringLiteral("postcode")).toString());
+ address.setStreet(addressDetails.value(QStringLiteral("road")).toString());
+ address.setState(addressDetails.value(QStringLiteral("state")).toString());
+ address.setDistrict(addressDetails.value(QStringLiteral("suburb")).toString());
+
+ QGeoLocation location;
+ location.setCoordinate(coordinate);
+ location.setAddress(address);
+ location.setBoundingBox(parseBoundingBox(item.value(QStringLiteral("boundingbox")).toArray()));
+
+ place.setLocation(location);
+
+ QPlaceResult result;
+ result.setIcon(icon);
+ result.setPlace(place);
+ result.setTitle(title);
+
+ return result;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/osm/qplacesearchreplyimpl.h b/src/plugins/geoservices/osm/qplacesearchreplyimpl.h
new file mode 100644
index 00000000..b2c67e71
--- /dev/null
+++ b/src/plugins/geoservices/osm/qplacesearchreplyimpl.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtFoo module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLACESEARCHREPLYIMPL_H
+#define QPLACESEARCHREPLYIMPL_H
+
+#include <QtLocation/QPlaceSearchReply>
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkReply;
+class QPlaceManagerEngineOsm;
+class QPlaceResult;
+
+class QPlaceSearchReplyImpl : public QPlaceSearchReply
+{
+ Q_OBJECT
+
+public:
+ QPlaceSearchReplyImpl(const QPlaceSearchRequest &request, QNetworkReply *reply,
+ QPlaceManagerEngineOsm *parent);
+ ~QPlaceSearchReplyImpl();
+
+ void abort();
+
+private slots:
+ void setError(QPlaceReply::Error errorCode, const QString &errorString);
+ void replyFinished();
+
+private:
+ QPlaceResult parsePlaceResult(const QJsonObject &item) const;
+
+ QNetworkReply *m_reply;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACESEARCHREPLYIMPL_H
diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
index c8d2f535..a1103509 100644
--- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
+++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp
@@ -48,6 +48,10 @@
#include <dbus/dbus-glib.h>
+#ifndef QT_NO_DATASTREAM
+#include <QtCore/QDataStream>
+#endif
+
QT_BEGIN_NAMESPACE
#define MINIMUM_UPDATE_INTERVAL 1000
diff --git a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
index 895272f8..3f0acee5 100644
--- a/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
+++ b/src/plugins/position/positionpoll/qgeoareamonitor_polling.cpp
@@ -420,26 +420,7 @@ QList<QGeoAreaMonitorInfo> QGeoAreaMonitorPolling::activeMonitors(const QGeoShap
const MonitorTable list = d->activeMonitors();
foreach (const QGeoAreaMonitorInfo &monitor, list) {
- QGeoCoordinate center;
- switch (monitor.area().type()) {
- case QGeoShape::CircleType:
- {
- QGeoCircle circle(monitor.area());
- center = circle.center();
- break;
- }
- case QGeoShape::RectangleType:
- {
- QGeoRectangle rectangle(monitor.area());
- center = rectangle.center();
- break;
- }
- case QGeoShape::UnknownType:
- {
- break;
- }
- }
- if (region.contains(center))
+ if (region.contains(monitor.area().center()))
results.append(monitor);
}
diff --git a/src/positioning/doc/qtpositioning.qdocconf b/src/positioning/doc/qtpositioning.qdocconf
index 874e5d64..ae258bb4 100644
--- a/src/positioning/doc/qtpositioning.qdocconf
+++ b/src/positioning/doc/qtpositioning.qdocconf
@@ -17,18 +17,15 @@ qhp.QtPositioning.indexRoot =
qhp.QtPositioning.filterAttributes = qtpositioning $QT_VERSION qtrefdoc
qhp.QtPositioning.customFilters.Qt.name = QtPositioning $QT_VERSION
qhp.QtPositioning.customFilters.Qt.filterAttributes = qtpositioning $QT_VERSION
-qhp.QtPositioning.subprojects = overviews classes qml examples
+qhp.QtPositioning.subprojects = classes qml examples
qhp.QtPositioning.subprojects.classes.title = C++ Classes
qhp.QtPositioning.subprojects.classes.indexTitle = Qt Positioning C++ Classes
qhp.QtPositioning.subprojects.classes.selectors = class fake:headerfile
qhp.QtPositioning.subprojects.classes.sortPages = true
qhp.QtPositioning.subprojects.qml.title = QML Types
qhp.QtPositioning.subprojects.qml.indexTitle = Qt Positioning QML Types
-qhp.QtPositioning.subprojects.qml.selectors = fake:headerfile
+qhp.QtPositioning.subprojects.qml.selectors = qmlclass
qhp.QtPositioning.subprojects.qml.sortPages = true
-qhp.QtPositioning.subprojects.overviews.title = Overviews
-qhp.QtPositioning.subprojects.overviews.indexTitle = Qt Positioning Overview
-qhp.QtPositioning.subprojects.overviews.selectors = fake:page,group,module
qhp.QtPositioning.subprojects.examples.title = Qt Positioning Examples
qhp.QtPositioning.subprojects.examples.indexTitle = Qt Positioning Examples
qhp.QtPositioning.subprojects.examples.selectors = fake:example
diff --git a/src/positioning/qdoublevector2d_p.h b/src/positioning/qdoublevector2d_p.h
index 9dc34dd7..85730ce6 100644
--- a/src/positioning/qdoublevector2d_p.h
+++ b/src/positioning/qdoublevector2d_p.h
@@ -229,12 +229,12 @@ Q_DECL_CONSTEXPR inline QPointF QDoubleVector2D::toPointF() const
}
#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QDoubleVector2D &vector);
+Q_POSITIONING_EXPORT QDebug operator<<(QDebug dbg, const QDoubleVector2D &vector);
#endif
#ifndef QT_NO_DATASTREAM
-QDataStream &operator<<(QDataStream &, const QDoubleVector2D &);
-QDataStream &operator>>(QDataStream &, QDoubleVector2D &);
+Q_POSITIONING_EXPORT QDataStream &operator<<(QDataStream &, const QDoubleVector2D &);
+Q_POSITIONING_EXPORT QDataStream &operator>>(QDataStream &, QDoubleVector2D &);
#endif
QT_END_NAMESPACE
diff --git a/src/positioning/qdoublevector3d_p.h b/src/positioning/qdoublevector3d_p.h
index 73623ae0..dbd5a549 100644
--- a/src/positioning/qdoublevector3d_p.h
+++ b/src/positioning/qdoublevector3d_p.h
@@ -283,12 +283,12 @@ Q_DECL_CONSTEXPR inline QDoubleVector2D QDoubleVector3D::toVector2D() const
#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector);
+Q_POSITIONING_EXPORT QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector);
#endif
#ifndef QT_NO_DATASTREAM
-QDataStream &operator<<(QDataStream &, const QDoubleVector3D &);
-QDataStream &operator>>(QDataStream &, QDoubleVector3D &);
+Q_POSITIONING_EXPORT QDataStream &operator<<(QDataStream &, const QDoubleVector3D &);
+Q_POSITIONING_EXPORT QDataStream &operator>>(QDataStream &, QDoubleVector3D &);
#endif
QT_END_NAMESPACE
diff --git a/src/positioning/qgeoareamonitorinfo.cpp b/src/positioning/qgeoareamonitorinfo.cpp
index 672bfbff..e8112672 100644
--- a/src/positioning/qgeoareamonitorinfo.cpp
+++ b/src/positioning/qgeoareamonitorinfo.cpp
@@ -360,11 +360,12 @@ QDataStream &operator>>(QDataStream &ds, QGeoAreaMonitorInfo &monitor)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QGeoAreaMonitorInfo &monitor)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QGeoAreaMonitorInfo(\"" << qPrintable(monitor.name())
<< "\", " << monitor.area()
<< ", persistent: " << monitor.isPersistent()
<< ", expiry: " << monitor.expiration() << ")";
- return dbg.space();
+ return dbg;
}
#endif
diff --git a/src/positioning/qgeocircle.cpp b/src/positioning/qgeocircle.cpp
index 6cacc7bc..c7f7ee6c 100644
--- a/src/positioning/qgeocircle.cpp
+++ b/src/positioning/qgeocircle.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -137,7 +137,7 @@ bool QGeoCircle::operator!=(const QGeoCircle &other) const
bool QGeoCirclePrivate::isValid() const
{
- return center.isValid() && !qIsNaN(radius) && radius >= -1e-7;
+ return m_center.isValid() && !qIsNaN(radius) && radius >= -1e-7;
}
bool QGeoCirclePrivate::isEmpty() const
@@ -152,17 +152,17 @@ void QGeoCircle::setCenter(const QGeoCoordinate &center)
{
Q_D(QGeoCircle);
- d->center = center;
+ d->m_center = center;
}
/*!
- Returns the center coordinate of this geo circle.
+ Returns the center coordinate of this geo circle. Equivalent to QGeoShape::center().
*/
QGeoCoordinate QGeoCircle::center() const
{
Q_D(const QGeoCircle);
- return d->center;
+ return d->center();
}
/*!
@@ -191,13 +191,18 @@ bool QGeoCirclePrivate::contains(const QGeoCoordinate &coordinate) const
return false;
// see QTBUG-41447 for details
- qreal distance = center.distanceTo(coordinate);
+ qreal distance = m_center.distanceTo(coordinate);
if (qFuzzyCompare(distance, radius) || distance <= radius)
return true;
return false;
}
+QGeoCoordinate QGeoCirclePrivate::center() const
+{
+ return m_center;
+}
+
/*!
Extends the circle to include \a coordinate
*/
@@ -206,7 +211,7 @@ void QGeoCirclePrivate::extendShape(const QGeoCoordinate &coordinate)
if (!isValid() || !coordinate.isValid() || contains(coordinate))
return;
- radius = center.distanceTo(coordinate);
+ radius = m_center.distanceTo(coordinate);
}
/*!
@@ -221,8 +226,8 @@ void QGeoCircle::translate(double degreesLatitude, double degreesLongitude)
Q_D(QGeoCircle);
- double lat = d->center.latitude();
- double lon = d->center.longitude();
+ double lat = d->m_center.latitude();
+ double lon = d->m_center.longitude();
lat += degreesLatitude;
lon += degreesLongitude;
@@ -248,7 +253,7 @@ void QGeoCircle::translate(double degreesLatitude, double degreesLongitude)
lon -= 180;
}
- d->center = QGeoCoordinate(lat, lon);
+ d->m_center = QGeoCoordinate(lat, lon);
}
/*!
@@ -267,6 +272,19 @@ QGeoCircle QGeoCircle::translated(double degreesLatitude, double degreesLongitud
return result;
}
+QString QGeoCircle::toString() const
+{
+ if (type() != QGeoShape::CircleType) {
+ qWarning("Not a circle");
+ return QStringLiteral("QGeoCircle(not a circle)");
+ }
+
+ return QStringLiteral("QGeoCircle({%1, %2}, %3)")
+ .arg(center().latitude())
+ .arg(center().longitude())
+ .arg(radius());
+}
+
/*******************************************************************************
*******************************************************************************/
@@ -276,12 +294,12 @@ QGeoCirclePrivate::QGeoCirclePrivate()
}
QGeoCirclePrivate::QGeoCirclePrivate(const QGeoCoordinate &center, qreal radius)
-: QGeoShapePrivate(QGeoShape::CircleType), center(center), radius(radius)
+: QGeoShapePrivate(QGeoShape::CircleType), m_center(center), radius(radius)
{
}
QGeoCirclePrivate::QGeoCirclePrivate(const QGeoCirclePrivate &other)
-: QGeoShapePrivate(QGeoShape::CircleType), center(other.center),
+: QGeoShapePrivate(QGeoShape::CircleType), m_center(other.m_center),
radius(other.radius)
{
}
@@ -300,7 +318,7 @@ bool QGeoCirclePrivate::operator==(const QGeoShapePrivate &other) const
const QGeoCirclePrivate &otherCircle = static_cast<const QGeoCirclePrivate &>(other);
- return radius == otherCircle.radius && center == otherCircle.center;
+ return radius == otherCircle.radius && m_center == otherCircle.m_center;
}
QT_END_NAMESPACE
diff --git a/src/positioning/qgeocircle.h b/src/positioning/qgeocircle.h
index 18817c33..2ff0c4f0 100644
--- a/src/positioning/qgeocircle.h
+++ b/src/positioning/qgeocircle.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -43,6 +43,10 @@ class QGeoCirclePrivate;
class Q_POSITIONING_EXPORT QGeoCircle : public QGeoShape
{
+ Q_GADGET
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
+ Q_PROPERTY(qreal radius READ radius WRITE setRadius)
+
public:
QGeoCircle();
QGeoCircle(const QGeoCoordinate &center, qreal radius = -1.0);
@@ -68,6 +72,8 @@ public:
void translate(double degreesLatitude, double degreesLongitude);
QGeoCircle translated(double degreesLatitude, double degreesLongitude) const;
+ Q_INVOKABLE QString toString() const;
+
private:
inline QGeoCirclePrivate *d_func();
inline const QGeoCirclePrivate *d_func() const;
diff --git a/src/positioning/qgeocircle_p.h b/src/positioning/qgeocircle_p.h
index d6fe37b5..635bd2ec 100644
--- a/src/positioning/qgeocircle_p.h
+++ b/src/positioning/qgeocircle_p.h
@@ -62,13 +62,15 @@ public:
bool isEmpty() const;
bool contains(const QGeoCoordinate &coordinate) const;
+ QGeoCoordinate center() const Q_DECL_OVERRIDE;
+
void extendShape(const QGeoCoordinate &coordinate);
QGeoShapePrivate *clone() const;
bool operator==(const QGeoShapePrivate &other) const;
- QGeoCoordinate center;
+ QGeoCoordinate m_center;
qreal radius;
};
diff --git a/src/positioning/qgeocoordinate.cpp b/src/positioning/qgeocoordinate.cpp
index 629f00c8..b604e8b4 100644
--- a/src/positioning/qgeocoordinate.cpp
+++ b/src/positioning/qgeocoordinate.cpp
@@ -606,24 +606,25 @@ QString QGeoCoordinate::toString(CoordinateFormat format) const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QGeoCoordinate &coord)
{
+ QDebugStateSaver saver(dbg);
double lat = coord.latitude();
double lng = coord.longitude();
dbg.nospace() << "QGeoCoordinate(";
if (qIsNaN(lat))
- dbg.nospace() << '?';
+ dbg << '?';
else
- dbg.nospace() << lat;
- dbg.nospace() << ", ";
+ dbg << lat;
+ dbg << ", ";
if (qIsNaN(lng))
- dbg.nospace() << '?';
+ dbg << '?';
else
- dbg.nospace() << lng;
+ dbg << lng;
if (coord.type() == QGeoCoordinate::Coordinate3D) {
- dbg.nospace() << ", ";
- dbg.nospace() << coord.altitude();
+ dbg << ", ";
+ dbg << coord.altitude();
}
- dbg.nospace() << ')';
+ dbg << ')';
return dbg;
}
#endif
diff --git a/src/positioning/qgeocoordinate.h b/src/positioning/qgeocoordinate.h
index deef67f2..701ba50e 100644
--- a/src/positioning/qgeocoordinate.h
+++ b/src/positioning/qgeocoordinate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -47,7 +47,15 @@ class QDataStream;
class QGeoCoordinatePrivate;
class Q_POSITIONING_EXPORT QGeoCoordinate
{
+ Q_GADGET
+
+ Q_PROPERTY(double latitude READ latitude WRITE setLatitude)
+ Q_PROPERTY(double longitude READ longitude WRITE setLongitude)
+ Q_PROPERTY(double altitude READ altitude WRITE setAltitude)
+ Q_PROPERTY(bool isValid READ isValid)
+
public:
+
enum CoordinateType {
InvalidCoordinate,
Coordinate2D,
@@ -88,12 +96,12 @@ public:
void setAltitude(double altitude);
double altitude() const;
- qreal distanceTo(const QGeoCoordinate &other) const;
- qreal azimuthTo(const QGeoCoordinate &other) const;
+ Q_INVOKABLE qreal distanceTo(const QGeoCoordinate &other) const;
+ Q_INVOKABLE qreal azimuthTo(const QGeoCoordinate &other) const;
- QGeoCoordinate atDistanceAndAzimuth(qreal distance, qreal azimuth, qreal distanceUp = 0.0) const;
+ Q_INVOKABLE QGeoCoordinate atDistanceAndAzimuth(qreal distance, qreal azimuth, qreal distanceUp = 0.0) const;
- QString toString(CoordinateFormat format = DegreesMinutesSecondsWithHemisphere) const;
+ Q_INVOKABLE QString toString(CoordinateFormat format = DegreesMinutesSecondsWithHemisphere) const;
private:
QSharedDataPointer<QGeoCoordinatePrivate> d;
diff --git a/src/positioning/qgeopositioninfo.cpp b/src/positioning/qgeopositioninfo.cpp
index b22bc999..2fde23f9 100644
--- a/src/positioning/qgeopositioninfo.cpp
+++ b/src/positioning/qgeopositioninfo.cpp
@@ -249,37 +249,38 @@ bool QGeoPositionInfo::hasAttribute(Attribute attribute) const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QGeoPositionInfo &info)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QGeoPositionInfo(" << info.d->timestamp;
- dbg.nospace() << ", ";
- dbg.nospace() << info.d->coord;
+ dbg.nospace() << ", "; // timestamp force dbg.space() -> reverting here
+ dbg << info.d->coord;
QList<QGeoPositionInfo::Attribute> attribs = info.d->doubleAttribs.keys();
std::stable_sort(attribs.begin(), attribs.end()); // Output a sorted list from an unsorted hash.
for (int i = 0; i < attribs.count(); ++i) {
- dbg.nospace() << ", ";
+ dbg << ", ";
switch (attribs[i]) {
case QGeoPositionInfo::Direction:
- dbg.nospace() << "Direction=";
+ dbg << "Direction=";
break;
case QGeoPositionInfo::GroundSpeed:
- dbg.nospace() << "GroundSpeed=";
+ dbg << "GroundSpeed=";
break;
case QGeoPositionInfo::VerticalSpeed:
- dbg.nospace() << "VerticalSpeed=";
+ dbg << "VerticalSpeed=";
break;
case QGeoPositionInfo::MagneticVariation:
- dbg.nospace() << "MagneticVariation=";
+ dbg << "MagneticVariation=";
break;
case QGeoPositionInfo::HorizontalAccuracy:
- dbg.nospace() << "HorizontalAccuracy=";
+ dbg << "HorizontalAccuracy=";
break;
case QGeoPositionInfo::VerticalAccuracy:
- dbg.nospace() << "VerticalAccuracy=";
+ dbg << "VerticalAccuracy=";
break;
}
- dbg.nospace() << info.d->doubleAttribs[attribs[i]];
+ dbg << info.d->doubleAttribs[attribs[i]];
}
- dbg.nospace() << ')';
+ dbg << ')';
return dbg;
}
#endif
diff --git a/src/positioning/qgeorectangle.cpp b/src/positioning/qgeorectangle.cpp
index b260bbb2..7edea41a 100644
--- a/src/positioning/qgeorectangle.cpp
+++ b/src/positioning/qgeorectangle.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -354,28 +354,13 @@ void QGeoRectangle::setCenter(const QGeoCoordinate &center)
}
/*!
- Returns the center of this geo rectangle.
+ Returns the center of this geo rectangle. Equivalent to QGeoShape::center().
*/
QGeoCoordinate QGeoRectangle::center() const
{
- if (!isValid())
- return QGeoCoordinate();
-
Q_D(const QGeoRectangle);
- double cLat = (d->topLeft.latitude() + d->bottomRight.latitude()) / 2.0;
-
- double cLon = (d->bottomRight.longitude() + d->topLeft.longitude()) / 2.0;
- if (d->topLeft.longitude() > d->bottomRight.longitude()) {
- cLon = cLon - 180.0;
- }
-
- if (cLon < -180.0)
- cLon += 360.0;
- if (cLon > 180.0)
- cLon -= 360.0;
-
- return QGeoCoordinate(cLat, cLon);
+ return d->center();
}
/*!
@@ -566,6 +551,25 @@ bool QGeoRectanglePrivate::contains(const QGeoCoordinate &coordinate) const
return true;
}
+QGeoCoordinate QGeoRectanglePrivate::center() const
+{
+ if (!isValid())
+ return QGeoCoordinate();
+
+ double cLat = (topLeft.latitude() + bottomRight.latitude()) / 2.0;
+ double cLon = (bottomRight.longitude() + topLeft.longitude()) / 2.0;
+
+ if (topLeft.longitude() > bottomRight.longitude())
+ cLon = cLon - 180.0;
+
+ if (cLon < -180.0)
+ cLon += 360.0;
+ if (cLon > 180.0)
+ cLon -= 360.0;
+
+ return QGeoCoordinate(cLat, cLon);
+}
+
/*!
Returns whether the geo rectangle \a rectangle is contained within this
geo rectangle.
@@ -895,6 +899,20 @@ QGeoRectangle &QGeoRectangle::operator|=(const QGeoRectangle &rectangle)
return *this;
}
+QString QGeoRectangle::toString() const
+{
+ if (type() != QGeoShape::RectangleType) {
+ qWarning("Not a rectangle a %d\n", type());
+ return QStringLiteral("QGeoRectangle(not a rectangle)");
+ }
+
+ return QStringLiteral("QGeoRectangle({%1, %2}, {%3, %4})")
+ .arg(topLeft().latitude())
+ .arg(topLeft().longitude())
+ .arg(bottomRight().latitude())
+ .arg(bottomRight().longitude());
+}
+
/*******************************************************************************
*******************************************************************************/
diff --git a/src/positioning/qgeorectangle.h b/src/positioning/qgeorectangle.h
index de647c92..b6e92b5b 100644
--- a/src/positioning/qgeorectangle.h
+++ b/src/positioning/qgeorectangle.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -43,6 +43,15 @@ class QGeoRectanglePrivate;
class Q_POSITIONING_EXPORT QGeoRectangle : public QGeoShape
{
+ Q_GADGET
+ Q_PROPERTY(QGeoCoordinate bottomLeft READ bottomLeft WRITE setBottomLeft)
+ Q_PROPERTY(QGeoCoordinate bottomRight READ bottomRight WRITE setBottomRight)
+ Q_PROPERTY(QGeoCoordinate topLeft READ topLeft WRITE setTopLeft)
+ Q_PROPERTY(QGeoCoordinate topRight READ topRight WRITE setTopRight)
+ Q_PROPERTY(QGeoCoordinate center READ center WRITE setCenter)
+ Q_PROPERTY(double height READ height WRITE setHeight)
+ Q_PROPERTY(double width READ width WRITE setWidth)
+
public:
QGeoRectangle();
QGeoRectangle(const QGeoCoordinate &center, double degreesWidth, double degreesHeight);
@@ -93,6 +102,8 @@ public:
QGeoRectangle operator|(const QGeoRectangle &rectangle) const;
QGeoRectangle &operator|=(const QGeoRectangle &rectangle);
+ Q_INVOKABLE QString toString() const;
+
private:
inline QGeoRectanglePrivate *d_func();
inline const QGeoRectanglePrivate *d_func() const;
diff --git a/src/positioning/qgeorectangle_p.h b/src/positioning/qgeorectangle_p.h
index 1c5bc6f2..817fd360 100644
--- a/src/positioning/qgeorectangle_p.h
+++ b/src/positioning/qgeorectangle_p.h
@@ -62,6 +62,8 @@ public:
bool isEmpty() const;
bool contains(const QGeoCoordinate &coordinate) const;
+ QGeoCoordinate center() const Q_DECL_OVERRIDE;
+
void extendShape(const QGeoCoordinate &coordinate);
QGeoShapePrivate *clone() const;
diff --git a/src/positioning/qgeosatelliteinfo.cpp b/src/positioning/qgeosatelliteinfo.cpp
index 62528cd8..8f50a371 100644
--- a/src/positioning/qgeosatelliteinfo.cpp
+++ b/src/positioning/qgeosatelliteinfo.cpp
@@ -237,25 +237,26 @@ bool QGeoSatelliteInfo::hasAttribute(Attribute attribute) const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QGeoSatelliteInfo &info)
{
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QGeoSatelliteInfo(system=" << info.d->system;
- dbg.nospace() << ", satId=" << info.d->satId;
- dbg.nospace() << ", signal-strength=" << info.d->signal;
+ dbg << ", satId=" << info.d->satId;
+ dbg << ", signal-strength=" << info.d->signal;
QList<int> attribs = info.d->doubleAttribs.keys();
for (int i = 0; i < attribs.count(); ++i) {
- dbg.nospace() << ", ";
+ dbg << ", ";
switch (attribs[i]) {
case QGeoSatelliteInfo::Elevation:
- dbg.nospace() << "Elevation=";
+ dbg << "Elevation=";
break;
case QGeoSatelliteInfo::Azimuth:
- dbg.nospace() << "Azimuth=";
+ dbg << "Azimuth=";
break;
}
- dbg.nospace() << info.d->doubleAttribs[attribs[i]];
+ dbg << info.d->doubleAttribs[attribs[i]];
}
- dbg.nospace() << ')';
+ dbg << ')';
return dbg;
}
#endif
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp
index 932f7618..dd3f05c7 100644
--- a/src/positioning/qgeoshape.cpp
+++ b/src/positioning/qgeoshape.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -185,6 +185,21 @@ bool QGeoShape::contains(const QGeoCoordinate &coordinate) const
}
/*!
+ Returns the coordinate located at the geometric center of the geo shape.
+
+ \since 5.5
+*/
+QGeoCoordinate QGeoShape::center() const
+{
+ Q_D(const QGeoShape);
+
+ if (d)
+ return d->center();
+ else
+ return QGeoCoordinate();
+}
+
+/*!
Extends the geo shape to also cover the coordinate \a coordinate
*/
void QGeoShape::extendShape(const QGeoCoordinate &coordinate)
@@ -234,23 +249,28 @@ QGeoShape &QGeoShape::operator=(const QGeoShape &other)
return *this;
}
+QString QGeoShape::toString() const
+{
+ return QStringLiteral("QGeoShape(%1)").arg(type());
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QGeoShape &shape)
{
- //dbg << *shape.d_func();
+ QDebugStateSaver saver(dbg);
dbg.nospace() << "QGeoShape(";
switch (shape.type()) {
case QGeoShape::UnknownType:
- dbg.nospace() << "Unknown";
+ dbg << "Unknown";
break;
case QGeoShape::RectangleType:
- dbg.nospace() << "Rectangle";
+ dbg << "Rectangle";
break;
case QGeoShape::CircleType:
- dbg.nospace() << "Circle";
+ dbg << "Circle";
}
- dbg.nospace() << ')';
+ dbg << ')';
return dbg;
}
diff --git a/src/positioning/qgeoshape.h b/src/positioning/qgeoshape.h
index 3704ba6a..3827f561 100644
--- a/src/positioning/qgeoshape.h
+++ b/src/positioning/qgeoshape.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtPositioning module of the Qt Toolkit.
@@ -44,6 +44,12 @@ class QGeoShapePrivate;
class Q_POSITIONING_EXPORT QGeoShape
{
+ Q_GADGET
+ Q_PROPERTY(ShapeType type READ type)
+ Q_PROPERTY(bool isValid READ isValid)
+ Q_PROPERTY(bool isEmpty READ isEmpty)
+ Q_ENUMS(ShapeType)
+
public:
QGeoShape();
QGeoShape(const QGeoShape &other);
@@ -59,7 +65,9 @@ public:
bool isValid() const;
bool isEmpty() const;
- bool contains(const QGeoCoordinate &coordinate) const;
+ Q_INVOKABLE bool contains(const QGeoCoordinate &coordinate) const;
+
+ QGeoCoordinate center() const;
void extendShape(const QGeoCoordinate &coordinate);
@@ -68,6 +76,7 @@ public:
QGeoShape &operator=(const QGeoShape &other);
+ Q_INVOKABLE QString toString() const;
protected:
QGeoShape(QGeoShapePrivate *d);
diff --git a/src/positioning/qgeoshape_p.h b/src/positioning/qgeoshape_p.h
index 62ddd77c..154a4505 100644
--- a/src/positioning/qgeoshape_p.h
+++ b/src/positioning/qgeoshape_p.h
@@ -61,6 +61,8 @@ public:
virtual bool isEmpty() const = 0;
virtual bool contains(const QGeoCoordinate &coordinate) const = 0;
+ virtual QGeoCoordinate center() const = 0;
+
virtual void extendShape(const QGeoCoordinate &coordinate) = 0;
virtual QGeoShapePrivate *clone() const = 0;