1#include <mbgl/style/conversion/geojson_options.hpp>
2
3namespace mbgl {
4namespace style {
5namespace conversion {
6
7optional<GeoJSONOptions> Converter<GeoJSONOptions>::operator()(const Convertible& value, Error& error) const {
8 GeoJSONOptions options;
9
10 const auto minzoomValue = objectMember(v: value, name: "minzoom");
11 if (minzoomValue) {
12 if (toNumber(v: *minzoomValue)) {
13 options.minzoom = static_cast<uint8_t>(*toNumber(v: *minzoomValue));
14 } else {
15 error = { .message: "GeoJSON source minzoom value must be a number" };
16 return {};
17 }
18 }
19
20 const auto maxzoomValue = objectMember(v: value, name: "maxzoom");
21 if (maxzoomValue) {
22 if (toNumber(v: *maxzoomValue)) {
23 options.maxzoom = static_cast<uint8_t>(*toNumber(v: *maxzoomValue));
24 } else {
25 error = { .message: "GeoJSON source maxzoom value must be a number" };
26 return {};
27 }
28 }
29
30 const auto bufferValue = objectMember(v: value, name: "buffer");
31 if (bufferValue) {
32 if (toNumber(v: *bufferValue)) {
33 options.buffer = static_cast<uint16_t>(*toNumber(v: *bufferValue));
34 } else {
35 error = { .message: "GeoJSON source buffer value must be a number" };
36 return {};
37 }
38 }
39
40 const auto toleranceValue = objectMember(v: value, name: "tolerance");
41 if (toleranceValue) {
42 if (toNumber(v: *toleranceValue)) {
43 options.tolerance = static_cast<double>(*toNumber(v: *toleranceValue));
44 } else {
45 error = { .message: "GeoJSON source tolerance value must be a number" };
46 return {};
47 }
48 }
49
50 const auto clusterValue = objectMember(v: value, name: "cluster");
51 if (clusterValue) {
52 if (toBool(v: *clusterValue)) {
53 options.cluster = *toBool(v: *clusterValue);
54 } else {
55 error = { .message: "GeoJSON source cluster value must be a boolean" };
56 return {};
57 }
58 }
59
60 const auto clusterMaxZoomValue = objectMember(v: value, name: "clusterMaxZoom");
61 if (clusterMaxZoomValue) {
62 if (toNumber(v: *clusterMaxZoomValue)) {
63 options.clusterMaxZoom = static_cast<uint8_t>(*toNumber(v: *clusterMaxZoomValue));
64 } else {
65 error = { .message: "GeoJSON source clusterMaxZoom value must be a number" };
66 return {};
67 }
68 }
69
70 const auto clusterRadiusValue = objectMember(v: value, name: "clusterRadius");
71 if (clusterRadiusValue) {
72 if (toNumber(v: *clusterRadiusValue)) {
73 options.clusterRadius = static_cast<double>(*toNumber(v: *clusterRadiusValue));
74 } else {
75 error = { .message: "GeoJSON source clusterRadius value must be a number" };
76 return {};
77 }
78 }
79
80 return { options };
81}
82
83} // namespace conversion
84} // namespace style
85} // namespace mbgl
86

source code of qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/style/conversion/geojson_options.cpp