diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2018-10-18 10:54:24 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2018-12-12 15:08:18 +0200 |
commit | 664ceb43980cb7d90a0d8b5fa1a48f83662322c9 (patch) | |
tree | d662d782fe4875a8a1b7f780a3d34f659f79acd3 /src/mbgl/style | |
parent | 8a03d16990b6fdde0f117def3a1b4bb2c9c92d4c (diff) | |
download | qtlocation-mapboxgl-664ceb43980cb7d90a0d8b5fa1a48f83662322c9.tar.gz |
[core] Share GeoJSONData pointer as weak_ptr instead of raw ptr
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.hpp | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 10fd7cacea..24ac1d7976 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -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 9984bbdd62..b88ab35ee0 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -31,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 |