summaryrefslogtreecommitdiff
path: root/src/location/labs/qgeotiledmaplabs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/labs/qgeotiledmaplabs.cpp')
-rw-r--r--src/location/labs/qgeotiledmaplabs.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/location/labs/qgeotiledmaplabs.cpp b/src/location/labs/qgeotiledmaplabs.cpp
index 22d582c0..7d8d7108 100644
--- a/src/location/labs/qgeotiledmaplabs.cpp
+++ b/src/location/labs/qgeotiledmaplabs.cpp
@@ -44,6 +44,8 @@
#include <QtLocation/private/qmapiconobjectqsg_p_p.h>
#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
#include <QtLocation/private/qgeomapobjectqsgsupport_p.h>
+#include <QtPositioning/private/qlocationutils_p.h>
+#include <math.h>
QT_BEGIN_NAMESPACE
@@ -57,6 +59,7 @@ public:
QGeoMapObjectPrivate *createMapObjectImplementation(QGeoMapObject *obj) override;
virtual QList<QGeoMapObject *> mapObjects() const override;
void removeMapObject(QGeoMapObject *obj);
+ QList<QObject *>mapObjectsAt(const QGeoCoordinate &coordinate) const;
void updateMapObjects(QSGNode *root, QQuickWindow *window);
void updateObjectsGeometry();
@@ -95,6 +98,34 @@ void QGeoTiledMapLabsPrivate::removeMapObject(QGeoMapObject *obj)
m_qsgSupport.removeMapObject(obj);
}
+QList<QObject *> QGeoTiledMapLabsPrivate::mapObjectsAt(const QGeoCoordinate &coordinate) const
+{
+ // ToDo: use a space partitioning strategy
+ QList<QObject *> res;
+ for (const auto o: mapObjects()) {
+ // explicitly handle lines
+ bool contains = false;
+ if (o->type() == QGeoMapObject::PolylineType ) {
+ QMapPolylineObject *mpo = static_cast<QMapPolylineObject *>(o);
+ qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate);
+ QGeoPath path = o->geoShape();
+ path.setWidth(mpp * mpo->border()->width());
+ contains = path.contains(coordinate);
+ } else if (o->type() == QGeoMapObject::RouteType) {
+ qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate);
+ QGeoPath path = o->geoShape();
+ path.setWidth(mpp * 4); // MapRouteObjectQSG has a hardcoded 4 pixels width;
+ contains = path.contains(coordinate);
+ } else {
+ contains = o->geoShape().contains(coordinate);
+ }
+
+ if (contains)
+ res.append(o);
+ }
+ return res;
+}
+
void QGeoTiledMapLabsPrivate::updateMapObjects(QSGNode *root, QQuickWindow *window)
{
m_qsgSupport.updateMapObjects(root, window);
@@ -161,6 +192,12 @@ void QGeoTiledMapLabs::removeMapObject(QGeoMapObject *obj)
d->removeMapObject(obj);
}
+QList<QObject *> QGeoTiledMapLabs::mapObjectsAt(const QGeoCoordinate &coordinate) const
+{
+ Q_D(const QGeoTiledMapLabs);
+ return d->mapObjectsAt(coordinate);
+}
+
QGeoTiledMapLabs::QGeoTiledMapLabs(QGeoTiledMapLabsPrivate &dd, QGeoTiledMappingManagerEngine *engine, QObject *parent)
: QGeoTiledMap(dd, engine, parent)
{