diff options
Diffstat (limited to 'include/mbgl/style/conversion/source.hpp')
-rw-r--r-- | include/mbgl/style/conversion/source.hpp | 60 |
1 files changed, 5 insertions, 55 deletions
diff --git a/include/mbgl/style/conversion/source.hpp b/include/mbgl/style/conversion/source.hpp index c4b2fe303f..6e1b4347c3 100644 --- a/include/mbgl/style/conversion/source.hpp +++ b/include/mbgl/style/conversion/source.hpp @@ -2,6 +2,7 @@ #include <mbgl/style/conversion.hpp> #include <mbgl/style/conversion/geojson.hpp> +#include <mbgl/style/conversion/geojson_options.hpp> #include <mbgl/style/conversion/tileset.hpp> #include <mbgl/style/source.hpp> #include <mbgl/style/sources/geojson_source.hpp> @@ -103,63 +104,12 @@ private: return Error{ "GeoJSON source must have a data value" }; } - GeoJSONOptions options; - - const auto maxzoomValue = objectMember(value, "maxzoom"); - if (maxzoomValue) { - if (toNumber(*maxzoomValue)) { - options.maxzoom = static_cast<uint8_t>(*toNumber(*maxzoomValue)); - } else { - return Error{ "GeoJSON source maxzoom value must be a number" }; - } - } - - const auto bufferValue = objectMember(value, "buffer"); - if (bufferValue) { - if (toNumber(*bufferValue)) { - options.buffer = static_cast<uint16_t>(*toNumber(*bufferValue)); - } else { - return Error{ "GeoJSON source buffer value must be a number" }; - } - } - - const auto toleranceValue = objectMember(value, "tolerance"); - if (toleranceValue) { - if (toNumber(*toleranceValue)) { - options.tolerance = static_cast<double>(*toNumber(*toleranceValue)); - } else { - return Error{ "GeoJSON source tolerance value must be a number" }; - } - } - - const auto clusterValue = objectMember(value, "cluster"); - if (clusterValue) { - if (toBool(*clusterValue)) { - options.cluster = *toBool(*clusterValue); - } else { - return Error{ "GeoJSON source cluster value must be a boolean" }; - } - } - - const auto clusterMaxZoomValue = objectMember(value, "clusterMaxZoom"); - if (clusterMaxZoomValue) { - if (toNumber(*clusterMaxZoomValue)) { - options.clusterMaxZoom = static_cast<uint8_t>(*toNumber(*clusterMaxZoomValue)); - } else { - return Error{ "GeoJSON source clusterMaxZoom value must be a number" }; - } - } - - const auto clusterRadiusValue = objectMember(value, "clusterRadius"); - if (clusterRadiusValue) { - if (toNumber(*clusterRadiusValue)) { - options.clusterRadius = static_cast<double>(*toNumber(*clusterRadiusValue)); - } else { - return Error{ "GeoJSON source clusterRadius value must be a number" }; - } + Result<GeoJSONOptions> options = convert<GeoJSONOptions>(value); + if (!options) { + return options.error(); } - auto result = std::make_unique<GeoJSONSource>(id, options); + auto result = std::make_unique<GeoJSONSource>(id, *options); if (isObject(*dataValue)) { Result<GeoJSON> geoJSON = convertGeoJSON(*dataValue); |