1 #pragma once 2 3 #include <mbgl/style/source.hpp> 4 #include <mbgl/util/geo.hpp> 5 #include <mbgl/util/geojson.hpp> 6 #include <mbgl/util/range.hpp> 7 #include <mbgl/util/constants.hpp> 8 9 namespace mbgl { 10 11 class OverscaledTileID; 12 class CanonicalTileID; 13 template <class T> 14 class Actor; 15 16 namespace style { 17 18 using TileFunction = std::function<void(const CanonicalTileID&)>; 19 20 class CustomTileLoader; 21 22 class CustomGeometrySource : public Source { 23 public: 24 struct TileOptions { 25 double tolerance = 0.375; 26 uint16_t tileSize = util::tileSize; 27 uint16_t buffer = 128; 28 bool clip = false; 29 bool wrap = false; 30 }; 31 32 struct Options { 33 TileFunction fetchTileFunction; 34 TileFunction cancelTileFunction; 35 Range<uint8_t> zoomRange = { 0, 18}; 36 TileOptions tileOptions; 37 }; 38 public: 39 CustomGeometrySource(std::string id, CustomGeometrySource::Options options); 40 ~CustomGeometrySource() final; 41 void loadDescription(FileSource&) final; 42 void setTileData(const CanonicalTileID&, const GeoJSON&); 43 void invalidateTile(const CanonicalTileID&); 44 void invalidateRegion(const LatLngBounds&); 45 // Private implementation 46 class Impl; 47 const Impl& impl() const; 48 private: 49 std::unique_ptr<Actor<CustomTileLoader>> loader; 50 }; 51 52 template <> is() const53inline bool Source::is<CustomGeometrySource>() const { 54 return getType() == SourceType::CustomVector; 55 } 56 57 } // namespace style 58 } // namespace mbgl 59