summaryrefslogtreecommitdiff
path: root/platform/default/mbgl/map/map_snapshotter.cpp
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/map_snapshotter.cpp
parentd928908ec849097440fd028454c538f1c1632a1e (diff)
downloadqtlocation-mapboxgl-6cc0d52fdc8f317e90e30937732272a355e53119.tar.gz
Diffstat (limited to 'platform/default/mbgl/map/map_snapshotter.cpp')
-rw-r--r--platform/default/mbgl/map/map_snapshotter.cpp27
1 files changed, 23 insertions, 4 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);
}