summaryrefslogtreecommitdiff
path: root/src/mbgl/style/conversion/geojson.cpp
blob: 8103e9014a5a16dab5eb56b5e78d699413b4813b (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
#include <mbgl/style/conversion/geojson.hpp>
#include <mbgl/style/conversion/json.hpp>
#include <mbgl/util/rapidjson.hpp>

#include <mapbox/geojson.hpp>
#include <mapbox/geojson/rapidjson.hpp>

namespace mbgl {
namespace style {
namespace conversion {

optional<GeoJSON> Converter<GeoJSON>::operator()(const std::string& value, Error& error) const {
    return convertJSON<GeoJSON>(value, error);
}

template <>
optional<GeoJSON> Converter<GeoJSON>::operator()(const JSValue& value, Error& error) const {
    try {
        return mapbox::geojson::convert(value);
    } catch (const std::exception& ex) {
        error = { ex.what() };
        return {};
    }
}

} // namespace conversion
} // namespace style
} // namespace mbgl