diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-01-11 12:04:26 -0500 |
---|---|---|
committer | Julian Rex <julian.rex@mapbox.com> | 2019-01-12 14:36:51 -0500 |
commit | 8ebce7fda579cff81d8cdacf472f5573512baf0c (patch) | |
tree | 3022e16428a96eb561037941362056d998e5df16 | |
parent | 08de82be39d54f6d83353ce5cb5e930caea0d7b1 (diff) | |
download | qtlocation-mapboxgl-8ebce7fda579cff81d8cdacf472f5573512baf0c.tar.gz |
Reverting old core changes.
-rw-r--r-- | include/mbgl/style/sources/geojson_source.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.hpp | 9 |
4 files changed, 13 insertions, 29 deletions
diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index a2c3c8f7d7..a03b910279 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -33,11 +33,8 @@ public: void setURL(const std::string& url); void setGeoJSON(const GeoJSON&); - optional<std::string> getURL() const; - mapbox::feature::feature_collection<double> getChildren(const std::uint32_t) const; - mapbox::feature::feature_collection<double> getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) const; - std::uint8_t getClusterExpansionZoom(std::uint32_t) const; + optional<std::string> getURL() const; class Impl; const Impl& impl() const; diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 0df72f1ed5..4e3478322d 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -40,20 +40,6 @@ optional<std::string> GeoJSONSource::getURL() const { return url; } -mapbox::feature::feature_collection<double> GeoJSONSource::getChildren(const std::uint32_t cluster_id) const { - return impl().getData()->getChildren(cluster_id); -} - -mapbox::feature::feature_collection<double> GeoJSONSource::getLeaves(const std::uint32_t cluster_id, - const std::uint32_t limit = 10, - const std::uint32_t offset = 0) const{ - return impl().getData()->getLeaves(cluster_id, limit, offset); -} - -std::uint8_t GeoJSONSource::getClusterExpansionZoom(std::uint32_t cluster_id) const { - return impl().getData()->getClusterExpansionZoom(cluster_id); -} - void GeoJSONSource::loadDescription(FileSource& fileSource) { if (!url) { loaded = true; diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 2e29317258..24ac1d7976 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -54,8 +54,8 @@ public: } mapbox::feature::feature_collection<double> getLeaves(const std::uint32_t cluster_id, - const std::uint32_t limit = 10, - const std::uint32_t offset = 0) final { + const std::uint32_t limit, + const std::uint32_t offset) final { return impl.getLeaves(cluster_id, limit, offset); } @@ -75,7 +75,7 @@ GeoJSONSource::Impl::Impl(std::string id_, GeoJSONOptions options_) GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) : Source::Impl(other), options(other.options) { - double scale = util::EXTENT / util::tileSize; + constexpr double scale = util::EXTENT / util::tileSize; if (options.cluster && geoJSON.is<mapbox::feature::feature_collection<double>>() @@ -84,7 +84,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) clusterOptions.maxZoom = options.clusterMaxZoom; clusterOptions.extent = util::EXTENT; clusterOptions.radius = ::round(scale * options.clusterRadius); - data = std::make_unique<SuperclusterData>( + data = std::make_shared<SuperclusterData>( geoJSON.get<mapbox::feature::feature_collection<double>>(), clusterOptions); } else { mapbox::geojsonvt::Options vtOptions; @@ -93,7 +93,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) vtOptions.buffer = ::round(scale * options.buffer); vtOptions.tolerance = scale * options.tolerance; vtOptions.lineMetrics = options.lineMetrics; - data = std::make_unique<GeoJSONVTData>(geoJSON, vtOptions); + data = std::make_shared<GeoJSONVTData>(geoJSON, vtOptions); } } @@ -103,8 +103,8 @@ Range<uint8_t> GeoJSONSource::Impl::getZoomRange() const { return { options.minzoom, options.maxzoom }; } -GeoJSONData* GeoJSONSource::Impl::getData() const { - return data.get(); +std::weak_ptr<GeoJSONData> GeoJSONSource::Impl::getData() const { + return data; } optional<std::string> GeoJSONSource::Impl::getAttribution() const { diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index 120e7c2256..b88ab35ee0 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -18,8 +18,9 @@ public: // SuperclusterData virtual mapbox::feature::feature_collection<double> getChildren(const std::uint32_t) = 0; - virtual mapbox::feature::feature_collection<double> getLeaves(const std::uint32_t, const std::uint32_t, - const std::uint32_t) = 0; + virtual mapbox::feature::feature_collection<double> getLeaves(const std::uint32_t, + const std::uint32_t limit = 10u, + const std::uint32_t offset = 0u) = 0; virtual std::uint8_t getClusterExpansionZoom(std::uint32_t) = 0; }; @@ -30,13 +31,13 @@ public: ~Impl() final; Range<uint8_t> getZoomRange() const; - GeoJSONData* getData() const; + std::weak_ptr<GeoJSONData> getData() const; optional<std::string> getAttribution() const final; private: GeoJSONOptions options; - std::unique_ptr<GeoJSONData> data; + std::shared_ptr<GeoJSONData> data; }; } // namespace style |