1 #pragma once
2 
3 #include <mbgl/style/source.hpp>
4 #include <mbgl/util/geojson.hpp>
5 #include <mbgl/util/optional.hpp>
6 #include <mbgl/util/constants.hpp>
7 
8 namespace mbgl {
9 
10 class AsyncRequest;
11 
12 namespace style {
13 
14 struct GeoJSONOptions {
15     // GeoJSON-VT options
16     uint8_t minzoom = 0;
17     uint8_t maxzoom = 18;
18     uint16_t tileSize = util::tileSize;
19     uint16_t buffer = 128;
20     double tolerance = 0.375;
21 
22     // Supercluster options
23     bool cluster = false;
24     uint16_t clusterRadius = 50;
25     uint8_t clusterMaxZoom = 17;
26 };
27 
28 class GeoJSONSource : public Source {
29 public:
30     GeoJSONSource(const std::string& id, const GeoJSONOptions& = {});
31     ~GeoJSONSource() final;
32 
33     void setURL(const std::string& url);
34     void setGeoJSON(const GeoJSON&);
35 
36     optional<std::string> getURL() const;
37 
38     class Impl;
39     const Impl& impl() const;
40 
41     void loadDescription(FileSource&) final;
42 
43 private:
44     optional<std::string> url;
45     std::unique_ptr<AsyncRequest> req;
46 };
47 
48 template <>
is() const49 inline bool Source::is<GeoJSONSource>() const {
50     return getType() == SourceType::GeoJSON;
51 }
52 
53 } // namespace style
54 } // namespace mbgl
55