blob: c65a9992d8ef1533a6dd9bc33b9bdf0609a149de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#pragma once
#include <mbgl/style/source.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/geojson.hpp>
#include <mbgl/actor/actor_ref.hpp>
namespace mbgl {
class OverscaledTileID;
namespace style {
struct Error { std::string message; };
using SetTileDataFunction = std::function<void(const mapbox::geojson::geojson&)>;
using TileFunction = std::function<void(const CanonicalTileID&)>;
class CustomTileLoader : private util::noncopyable {
public:
CustomTileLoader(TileFunction&& fetchTileFn, TileFunction&& cancelTileFn);
~CustomTileLoader();
void fetchTile(const OverscaledTileID& tileID, ActorRef<SetTileDataFunction> callbackRef);
void cancelTile(const OverscaledTileID& tileID);
void removeTile(const OverscaledTileID& tileID);
void setTileData(const CanonicalTileID& tileID, const mapbox::geojson::geojson& data);
private:
class Impl;
Impl* impl = nullptr;
};
class CustomVectorSource : public Source {
public:
CustomVectorSource(std::string id,
GeoJSONOptions options,
TileFunction fetchTile,
TileFunction cancelTile);
void loadDescription(FileSource&) final;
void setTileData(const CanonicalTileID&, const mapbox::geojson::geojson& geojson);
// Private implementation
class Impl;
const Impl& impl() const;
private:
std::shared_ptr<Mailbox> mailbox;
CustomTileLoader loader;
};
template <>
inline bool Source::is<CustomVectorSource>() const {
return getType() == SourceType::CustomVector;
}
} // namespace style
} // namespace mbgl
|