summaryrefslogtreecommitdiff
path: root/src/mbgl/style/sources/geojson_source_impl.hpp
blob: 350045b27c7b2f7f9cf2d999d296fd787a81f774 (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
#pragma once

#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/source_impl.hpp>
#include <mbgl/util/rapidjson.hpp>
#include <mbgl/util/variant.hpp>

namespace mapbox {
namespace geojsonvt {
class GeoJSONVT;
} // namespace geojsonvt
} // namespace mapbox

namespace mbgl {

class AsyncRequest;

namespace style {

class GeoJSONSource::Impl : public Source::Impl {
public:
    using GeoJSON = std::unique_ptr<mapbox::geojsonvt::GeoJSONVT>;

    static std::unique_ptr<GeoJSONSource> parse(const std::string& id, const JSValue&);
    static GeoJSON parseGeoJSON(const JSValue&);

    Impl(std::string id, Source&,
         variant<std::string, GeoJSON> urlOrGeoJSON);
    ~Impl() final;

    void load(FileSource&) final;

    uint16_t getTileSize() const final {
        return util::tileSize;
    }

    const variant<std::string, GeoJSON>& getURLOrGeoJSON() const {
        return urlOrGeoJSON;
    }

private:
    Range<uint8_t> getZoomRange() final;
    std::unique_ptr<Tile> createTile(const OverscaledTileID&, const UpdateParameters&) final;

    variant<std::string, GeoJSON> urlOrGeoJSON;
    std::unique_ptr<AsyncRequest> req;
};

} // namespace style
} // namespace mbgl