MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
custom_geometry_source.hpp
Go to the documentation of this file.
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>
8 
9 namespace mbgl {
10 
11 class OverscaledTileID;
12 class CanonicalTileID;
13 template <class T>
14 class Actor;
15 class ThreadPool;
16 
17 namespace style {
18 
19 using TileFunction = std::function<void(const CanonicalTileID&)>;
20 
21 class CustomTileLoader;
22 
23 class CustomGeometrySource final : public Source {
24 public:
25  struct TileOptions {
26  double tolerance = 0.375;
28  uint16_t buffer = 128;
29  bool clip = false;
30  bool wrap = false;
31  };
32 
33  struct Options {
38  };
39 public:
43  void setTileData(const CanonicalTileID&, const GeoJSON&);
46  // Private implementation
47  class Impl;
48  const Impl& impl() const;
49  bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;
50  mapbox::base::WeakPtr<Source> makeWeakPtr() override {
51  return weakFactory.makeWeakPtr();
52  }
53 
54 protected:
55  Mutable<Source::Impl> createMutable() const noexcept final;
56 
57 private:
58  std::shared_ptr<ThreadPool> threadPool;
59  std::unique_ptr<Actor<CustomTileLoader>> loader;
60  mapbox::base::WeakPtrFactory<Source> weakFactory {this};
61 };
62 
63 template <>
64 inline bool Source::is<CustomGeometrySource>() const {
65  return getType() == SourceType::CustomVector;
66 }
67 
68 } // namespace style
69 } // namespace mbgl
void setTileData(const CanonicalTileID &, const GeoJSON &)
Mutable< Source::Impl > createMutable() const noexcept final
CustomGeometrySource(std::string id, const CustomGeometrySource::Options &options)
void invalidateRegion(const LatLngBounds &)
bool supportsLayerType(const mbgl::style::LayerTypeInfo *) const override
void invalidateTile(const CanonicalTileID &)
void loadDescription(FileSource &) final
mapbox::base::WeakPtr< Source > makeWeakPtr() override
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
std::function< void(const CanonicalTileID &)> TileFunction
constexpr uint16_t tileSize_I
Definition: constants.hpp:14
Definition: actor.hpp:15
mapbox::geojson::geojson GeoJSON
Definition: geojson.hpp:8
Definition: tile_id.hpp:256