diff options
Diffstat (limited to 'include/mbgl/style/sources')
-rw-r--r-- | include/mbgl/style/sources/custom_geometry_source.hpp | 6 | ||||
-rw-r--r-- | include/mbgl/style/sources/geojson_source.hpp | 20 | ||||
-rw-r--r-- | include/mbgl/style/sources/image_source.hpp | 7 | ||||
-rw-r--r-- | include/mbgl/style/sources/raster_source.hpp | 5 | ||||
-rw-r--r-- | include/mbgl/style/sources/vector_source.hpp | 7 |
5 files changed, 39 insertions, 6 deletions
diff --git a/include/mbgl/style/sources/custom_geometry_source.hpp b/include/mbgl/style/sources/custom_geometry_source.hpp index 3f29d0c0fb..a5e545f445 100644 --- a/include/mbgl/style/sources/custom_geometry_source.hpp +++ b/include/mbgl/style/sources/custom_geometry_source.hpp @@ -20,7 +20,7 @@ using TileFunction = std::function<void(const CanonicalTileID&)>; class CustomTileLoader; -class CustomGeometrySource : public Source { +class CustomGeometrySource final : public Source { public: struct TileOptions { double tolerance = 0.375; @@ -46,9 +46,13 @@ public: // Private implementation class Impl; const Impl& impl() const; + mapbox::base::WeakPtr<Source> makeWeakPtr() override { + return weakFactory.makeWeakPtr(); + } private: std::shared_ptr<ThreadPool> threadPool; std::unique_ptr<Actor<CustomTileLoader>> loader; + mapbox::base::WeakPtrFactory<Source> weakFactory {this}; }; template <> diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index a03b910279..c99687fad6 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -1,9 +1,14 @@ #pragma once +#include <mbgl/style/expression/expression.hpp> #include <mbgl/style/source.hpp> +#include <mbgl/util/constants.hpp> #include <mbgl/util/geojson.hpp> #include <mbgl/util/optional.hpp> -#include <mbgl/util/constants.hpp> + +#include <memory> +#include <unordered_map> +#include <utility> namespace mbgl { @@ -24,11 +29,15 @@ struct GeoJSONOptions { bool cluster = false; uint16_t clusterRadius = 50; uint8_t clusterMaxZoom = 17; + using ClusterExpression = std::pair<std::shared_ptr<mbgl::style::expression::Expression>, + std::shared_ptr<mbgl::style::expression::Expression>>; + using ClusterProperties = std::unordered_map<std::string, ClusterExpression>; + ClusterProperties clusterProperties; }; -class GeoJSONSource : public Source { +class GeoJSONSource final : public Source { public: - GeoJSONSource(const std::string& id, const GeoJSONOptions& = {}); + GeoJSONSource(const std::string& id, optional<GeoJSONOptions> = nullopt); ~GeoJSONSource() final; void setURL(const std::string& url); @@ -41,9 +50,14 @@ public: void loadDescription(FileSource&) final; + mapbox::base::WeakPtr<Source> makeWeakPtr() override { + return weakFactory.makeWeakPtr(); + } + private: optional<std::string> url; std::unique_ptr<AsyncRequest> req; + mapbox::base::WeakPtrFactory<Source> weakFactory {this}; }; template <> diff --git a/include/mbgl/style/sources/image_source.hpp b/include/mbgl/style/sources/image_source.hpp index 009764291f..84faab33c9 100644 --- a/include/mbgl/style/sources/image_source.hpp +++ b/include/mbgl/style/sources/image_source.hpp @@ -10,7 +10,7 @@ class AsyncRequest; namespace style { -class ImageSource : public Source { +class ImageSource final : public Source { public: ImageSource(std::string id, const std::array<LatLng, 4>); ~ImageSource() override; @@ -27,9 +27,14 @@ public: const Impl& impl() const; void loadDescription(FileSource&) final; + + mapbox::base::WeakPtr<Source> makeWeakPtr() override { + return weakFactory.makeWeakPtr(); + } private: optional<std::string> url; std::unique_ptr<AsyncRequest> req; + mapbox::base::WeakPtrFactory<Source> weakFactory {this}; }; template <> diff --git a/include/mbgl/style/sources/raster_source.hpp b/include/mbgl/style/sources/raster_source.hpp index 5aa81aa979..1bdced8da7 100644 --- a/include/mbgl/style/sources/raster_source.hpp +++ b/include/mbgl/style/sources/raster_source.hpp @@ -25,9 +25,14 @@ public: void loadDescription(FileSource&) final; + mapbox::base::WeakPtr<Source> makeWeakPtr() final { + return weakFactory.makeWeakPtr(); + } + private: const variant<std::string, Tileset> urlOrTileset; std::unique_ptr<AsyncRequest> req; + mapbox::base::WeakPtrFactory<Source> weakFactory {this}; }; template <> diff --git a/include/mbgl/style/sources/vector_source.hpp b/include/mbgl/style/sources/vector_source.hpp index 6f16974b40..ece7f5615a 100644 --- a/include/mbgl/style/sources/vector_source.hpp +++ b/include/mbgl/style/sources/vector_source.hpp @@ -10,7 +10,7 @@ class AsyncRequest; namespace style { -class VectorSource : public Source { +class VectorSource final : public Source { public: VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset); ~VectorSource() final; @@ -23,9 +23,14 @@ public: void loadDescription(FileSource&) final; + mapbox::base::WeakPtr<Source> makeWeakPtr() override { + return weakFactory.makeWeakPtr(); + } + private: const variant<std::string, Tileset> urlOrTileset; std::unique_ptr<AsyncRequest> req; + mapbox::base::WeakPtrFactory<Source> weakFactory {this}; }; template <> |