Files
MapLibreParticleLab/include/mbgl/style/sources/custom_geometry_source.hpp
Tadej Novak 32ed70c95d [msvc] Fix warnings, mainly casting to smaller types (#270)
If the checks by GitHub Actions checks are met, then it seems good to go.  Thanks for supporting FOSS4G!
2022-04-22 11:40:55 -07:00

70 lines
1.8 KiB
C++

#pragma once
#include <mbgl/style/source.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/geojson.hpp>
#include <mbgl/util/range.hpp>
#include <mbgl/util/constants.hpp>
namespace mbgl {
class OverscaledTileID;
class CanonicalTileID;
template <class T>
class Actor;
class ThreadPool;
namespace style {
using TileFunction = std::function<void(const CanonicalTileID&)>;
class CustomTileLoader;
class CustomGeometrySource final : public Source {
public:
struct TileOptions {
double tolerance = 0.375;
uint16_t tileSize = util::tileSize_I;
uint16_t buffer = 128;
bool clip = false;
bool wrap = false;
};
struct Options {
TileFunction fetchTileFunction;
TileFunction cancelTileFunction;
Range<uint8_t> zoomRange = { 0, 18};
TileOptions tileOptions;
};
public:
CustomGeometrySource(std::string id, const CustomGeometrySource::Options& options);
~CustomGeometrySource() final;
void loadDescription(FileSource&) final;
void setTileData(const CanonicalTileID&, const GeoJSON&);
void invalidateTile(const CanonicalTileID&);
void invalidateRegion(const LatLngBounds&);
// Private implementation
class Impl;
const Impl& impl() const;
bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
mapbox::base::WeakPtr<Source> makeWeakPtr() override {
return weakFactory.makeWeakPtr();
}
protected:
Mutable<Source::Impl> createMutable() const noexcept final;
private:
std::shared_ptr<ThreadPool> threadPool;
std::unique_ptr<Actor<CustomTileLoader>> loader;
mapbox::base::WeakPtrFactory<Source> weakFactory {this};
};
template <>
inline bool Source::is<CustomGeometrySource>() const {
return getType() == SourceType::CustomVector;
}
} // namespace style
} // namespace mbgl