summaryrefslogtreecommitdiff
path: root/platform/default/mbgl/map
diff options
context:
space:
mode:
authorŁukasz Paczos <lukasz.paczos@mapbox.com>2018-06-04 18:15:33 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-06-05 12:28:42 +0200
commit6cc0d52fdc8f317e90e30937732272a355e53119 (patch)
tree49cbf13bc23c81afde2c3402a4671e2419bdba3f /platform/default/mbgl/map
parentd928908ec849097440fd028454c538f1c1632a1e (diff)
downloadqtlocation-mapboxgl-6cc0d52fdc8f317e90e30937732272a355e53119.tar.gz
Diffstat (limited to 'platform/default/mbgl/map')
-rw-r--r--platform/default/mbgl/map/map_snapshotter.cpp27
-rw-r--r--platform/default/mbgl/map/map_snapshotter.hpp9
2 files changed, 30 insertions, 6 deletions
diff --git a/platform/default/mbgl/map/map_snapshotter.cpp b/platform/default/mbgl/map/map_snapshotter.cpp
index a909e3fe9b..9358d76a18 100644
--- a/platform/default/mbgl/map/map_snapshotter.cpp
+++ b/platform/default/mbgl/map/map_snapshotter.cpp
@@ -2,6 +2,7 @@
#include <mbgl/actor/actor_ref.hpp>
#include <mbgl/gl/headless_frontend.hpp>
+#include <mbgl/renderer/renderer.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/storage/file_source.hpp>
@@ -37,7 +38,9 @@ public:
void setRegion(LatLngBounds);
LatLngBounds getRegion() const;
- void snapshot(ActorRef<MapSnapshotter::Callback>);
+ void snapshot(ActorRef<MapSnapshotter::SnapshotCallback>);
+
+ void queryFeatures(ActorRef<MapSnapshotter::QueryFeaturesCallback>, const ScreenBox&, const RenderedQueryOptions&);
private:
HeadlessFrontend frontend;
@@ -71,7 +74,7 @@ MapSnapshotter::Impl::Impl(FileSource& fileSource,
}
}
-void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback) {
+void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::SnapshotCallback> callback) {
map.renderStill([this, callback = std::move(callback)] (std::exception_ptr error) mutable {
// Create lambda that captures the current transform state
@@ -96,7 +99,7 @@ void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback)
// Invoke callback
callback.invoke(
- &MapSnapshotter::Callback::operator(),
+ &MapSnapshotter::SnapshotCallback::operator(),
error,
error ? PremultipliedImage() : frontend.readStillImage(),
std::move(attributions),
@@ -105,6 +108,17 @@ void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback)
});
}
+void MapSnapshotter::Impl::queryFeatures(ActorRef<MapSnapshotter::QueryFeaturesCallback> callback,
+ const ScreenBox& box, const RenderedQueryOptions& options) {
+ map.renderStill([this, callback = std::move(callback), box, options] (std::exception_ptr error) mutable {
+ callback.invoke(
+ &MapSnapshotter::QueryFeaturesCallback::operator(),
+ error,
+ error ? std::vector<Feature>() : frontend.getRenderer()->queryRenderedFeatures(box, options)
+ );
+ });
+}
+
void MapSnapshotter::Impl::setStyleURL(std::string styleURL) {
map.getStyle().loadURL(styleURL);
}
@@ -162,10 +176,15 @@ MapSnapshotter::MapSnapshotter(FileSource& fileSource,
MapSnapshotter::~MapSnapshotter() = default;
-void MapSnapshotter::snapshot(ActorRef<MapSnapshotter::Callback> callback) {
+void MapSnapshotter::snapshot(ActorRef<MapSnapshotter::SnapshotCallback> callback) {
impl->actor().invoke(&Impl::snapshot, std::move(callback));
}
+void MapSnapshotter::queryFeatures(ActorRef<MapSnapshotter::QueryFeaturesCallback> callback,
+ const ScreenBox& box, const RenderedQueryOptions& options) {
+ impl->actor().invoke(&Impl::queryFeatures, std::move(callback), box, options);
+}
+
void MapSnapshotter::setStyleURL(const std::string& styleURL) {
impl->actor().invoke(&Impl::setStyleURL, styleURL);
}
diff --git a/platform/default/mbgl/map/map_snapshotter.hpp b/platform/default/mbgl/map/map_snapshotter.hpp
index b9e6307664..bc69a92a4f 100644
--- a/platform/default/mbgl/map/map_snapshotter.hpp
+++ b/platform/default/mbgl/map/map_snapshotter.hpp
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
#include <functional>
+#include <mbgl/renderer/query.hpp>
namespace mbgl {
@@ -53,8 +54,12 @@ public:
using PointForFn = std::function<ScreenCoordinate (const LatLng&)>;
using Attributions = std::vector<std::string>;
- using Callback = std::function<void (std::exception_ptr, PremultipliedImage, Attributions, PointForFn)>;
- void snapshot(ActorRef<Callback>);
+ using SnapshotCallback = std::function<void (std::exception_ptr, PremultipliedImage, Attributions, PointForFn)>;
+ void snapshot(ActorRef<SnapshotCallback>);
+
+ using Features = std::vector<Feature>;
+ using QueryFeaturesCallback = std::function<void (std::exception_ptr, Features)>;
+ void queryFeatures(ActorRef<QueryFeaturesCallback>, const ScreenBox& box, const RenderedQueryOptions& options);
private:
class Impl;