summaryrefslogtreecommitdiff
path: root/src/mbgl/style/sources/geojson_source_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/sources/geojson_source_impl.cpp')
-rw-r--r--src/mbgl/style/sources/geojson_source_impl.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp
index e73876b429..bb5445f02b 100644
--- a/src/mbgl/style/sources/geojson_source_impl.cpp
+++ b/src/mbgl/style/sources/geojson_source_impl.cpp
@@ -13,8 +13,7 @@
namespace mbgl {
namespace style {
-class GeoJSONVTData : public GeoJSONData {
-public:
+class GeoJSONVTData final : public GeoJSONData {
void getTile(const CanonicalTileID& id, const std::function<void(TileFeatures)>& fn) final {
assert(fn);
scheduler->scheduleAndReplyValue(
@@ -29,18 +28,21 @@ public:
return 0;
}
-private:
+ std::shared_ptr<Scheduler> getScheduler() final { return scheduler; }
+
friend GeoJSONData;
- GeoJSONVTData(const GeoJSON& geoJSON, const mapbox::geojsonvt::Options& options)
- : impl(std::make_shared<mapbox::geojsonvt::GeoJSONVT>(geoJSON, options)),
- scheduler(Scheduler::GetSequenced()) {}
+ GeoJSONVTData(const GeoJSON& geoJSON,
+ const mapbox::geojsonvt::Options& options,
+ std::shared_ptr<Scheduler> scheduler_)
+ : impl(std::make_shared<mapbox::geojsonvt::GeoJSONVT>(geoJSON, options)), scheduler(std::move(scheduler_)) {
+ assert(scheduler);
+ }
std::shared_ptr<mapbox::geojsonvt::GeoJSONVT> impl; // Accessed on worker thread.
std::shared_ptr<Scheduler> scheduler;
};
-class SuperclusterData : public GeoJSONData {
-public:
+class SuperclusterData final : public GeoJSONData {
void getTile(const CanonicalTileID& id, const std::function<void(TileFeatures)>& fn) final {
assert(fn);
fn(impl.getTile(id.z, id.x, id.y));
@@ -56,7 +58,6 @@ public:
return impl.getClusterExpansionZoom(cluster_id);
}
-private:
friend GeoJSONData;
SuperclusterData(const Features& features, const mapbox::supercluster::Options& options)
: impl(features, options) {}
@@ -78,7 +79,9 @@ T evaluateFeature(const mapbox::feature::feature<double>& f,
}
// static
-std::shared_ptr<GeoJSONData> GeoJSONData::create(const GeoJSON& geoJSON, Immutable<GeoJSONOptions> options) {
+std::shared_ptr<GeoJSONData> GeoJSONData::create(const GeoJSON& geoJSON,
+ Immutable<GeoJSONOptions> options,
+ std::shared_ptr<Scheduler> scheduler) {
constexpr double scale = util::EXTENT / util::tileSize;
if (options->cluster && geoJSON.is<Features>() && !geoJSON.get<Features>().empty()) {
mapbox::supercluster::Options clusterOptions;
@@ -114,7 +117,8 @@ std::shared_ptr<GeoJSONData> GeoJSONData::create(const GeoJSON& geoJSON, Immutab
vtOptions.buffer = ::round(scale * options->buffer);
vtOptions.tolerance = scale * options->tolerance;
vtOptions.lineMetrics = options->lineMetrics;
- return std::shared_ptr<GeoJSONData>(new GeoJSONVTData(geoJSON, vtOptions));
+ if (!scheduler) scheduler = Scheduler::GetSequenced();
+ return std::shared_ptr<GeoJSONData>(new GeoJSONVTData(geoJSON, vtOptions, std::move(scheduler)));
}
GeoJSONSource::Impl::Impl(std::string id_, Immutable<GeoJSONOptions> options_)