summaryrefslogtreecommitdiff
path: root/platform/android/src/style/conversion/geojson.hpp
blob: 32a473b09231a9faf278a7798afd9854542c833f (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
#pragma once

#include <mapbox/geojson.hpp>
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/conversion/geojson.hpp>
#include <jni/jni.hpp>

namespace mbgl {
namespace style {
namespace conversion {

template <>
optional<GeoJSON> convertGeoJSON(const mbgl::android::Value& value, Error& error) {

    if(value.isNull() || !value.isString()) {
        error = { "no json data found" };
        return {};
    }

    return convertGeoJSON(value.toString(), error);
}

template <>
struct Converter<GeoJSON> {

    optional<GeoJSON> operator()(const mbgl::android::Value& value, Error& error) const {
        return convertGeoJSON(value, error);
    }

};

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