#pragma once #include #include #include #include #include #include namespace mln { class OverscaledTileID; class CanonicalTileID; template class Actor; namespace style { using TileFunction = std::function; class CustomVectorTileLoader; enum class TileDataFormat : uint8_t { MVT = 0, }; class CustomVectorSource final : public Source { public: struct Options { TileFunction fetchTileFunction; TileFunction cancelTileFunction; Range zoomRange = {0, 18}; }; CustomVectorSource(std::string id, const Options& options); ~CustomVectorSource() final; void loadDescription(FileSource&) final; void setTileData(const CanonicalTileID&, const std::shared_ptr& data, TileDataFormat format = TileDataFormat::MVT); void setTileError(const CanonicalTileID&, std::exception_ptr error); void invalidateTile(const CanonicalTileID&); class Impl; const Impl& impl() const; bool supportsLayerType(const mln::style::LayerTypeInfo*) const override; mapbox::base::WeakPtr makeWeakPtr() override { return weakFactory.makeWeakPtr(); } protected: Mutable createMutable() const noexcept final; private: std::unique_ptr> loader; mapbox::base::WeakPtrFactory weakFactory{this}; }; template <> inline bool Source::is() const { return getType() == SourceType::CustomMVTVector; } } // namespace style } // namespace mln