summaryrefslogtreecommitdiff
path: root/include/mbgl/style/sources/custom_vector_source.hpp
blob: a256c8e7f74c1227c059c9e27f35bd56243c28cb (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
#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/util/variant.hpp>

namespace mbgl {
namespace style {

struct Error { std::string message; };

using FetchTileResult = variant<
    mapbox::geojson::geojson,
    Error>;

using FetchTileCallback = std::function<void(const CanonicalTileID& tileID, const FetchTileResult&)>;
using FetchTileFunction = std::function<void(const CanonicalTileID&, FetchTileCallback)>;

class CustomVectorSource : public Source {
public:
    CustomVectorSource(std::string id,
                       GeoJSONOptions options,
                       FetchTileFunction fetchTile);

    void loadDescription(FileSource&) final;

    // Private implementation
    class Impl;
    const Impl& impl() const;
};

template <>
inline bool Source::is<CustomVectorSource>() const {
    return getType() == SourceType::CustomVector;
}

} // namespace style
} // namespace mbgl