Esempio n. 1
0
mbgl::Point<double> Point::convert(jni::JNIEnv &env, const jni::Object<Point>& jPoint) {
    static auto& javaClass = jni::Class<Point>::Singleton(env);
    static auto longitude = javaClass.GetMethod<jni::jdouble ()>(env, "longitude");
    static auto latitude = javaClass.GetMethod<jni::jdouble ()>(env, "latitude");

    if (!jPoint) {
        return {};
    }

    return {
        jPoint.Call(env, longitude),
        jPoint.Call(env, latitude)
    };
}
Esempio n. 2
0
mbgl::Feature Feature::convert(jni::JNIEnv& env, const jni::Object<Feature>& jFeature) {
    static auto& javaClass = jni::Class<Feature>::Singleton(env);
    static auto id = javaClass.GetMethod<jni::String ()>(env, "id");
    static auto geometry = javaClass.GetMethod<jni::Object<Geometry> ()>(env, "geometry");
    static auto properties = javaClass.GetMethod<jni::Object<gson::JsonObject> ()>(env, "properties");

    auto jId = jFeature.Call(env, id);

    return mbgl::Feature {
        Geometry::convert(env, jFeature.Call(env, geometry)),
        JsonObject::convert(env, jFeature.Call(env, properties)),
        jId ? std::experimental::optional<mapbox::geometry::identifier>(jni::Make<std::string>(env, jId))
            : std::experimental::nullopt
    };
}
Esempio n. 3
0
std::string Geometry::getType(jni::JNIEnv &env, jni::Object<Geometry> jGeometry) {
    static auto method = Geometry::javaClass.GetMethod<jni::String ()>(env, "getType");
    auto jType = jGeometry.Call(env, method);
    auto type = jni::Make<std::string>(env, jType);
    jni::DeleteLocalRef(env, jType);
    return type;
}
Esempio n. 4
0
std::vector<mapbox::geometry::value> JsonArray::convert(jni::JNIEnv &env, jni::Object<JsonArray> jsonArray) {
    std::vector<mapbox::geometry::value> values;

    if (jsonArray) {
        static auto getMethod = JsonArray::javaClass.GetMethod<jni::Object<JsonElement> (jni::jint)>(env, "get");
        static auto sizeMethod = JsonArray::javaClass.GetMethod<jni::jint ()>(env, "size");

        int size = jsonArray.Call(env, sizeMethod);
        values.reserve(uint(size));

        for (int i = 0; i < size; i++) {
            auto entry = jsonArray.Call(env, getMethod, i);
            if (entry) {
                values.push_back(JsonElement::convert(env, entry));
            }
            jni::DeleteLocalRef(env, entry);
        }
    }

    return values;
}
Esempio n. 5
0
std::string Geometry::getType(jni::JNIEnv &env, const jni::Object<Geometry>& jGeometry) {
    static auto& javaClass = jni::Class<Geometry>::Singleton(env);
    static auto method = javaClass.GetMethod<jni::String ()>(env, "type");
    return jni::Make<std::string>(env, jGeometry.Call(env, method));
}
jni::Object<java::util::List> Point::coordinates(jni::JNIEnv &env, jni::Object<Point> jPoint) {
     static auto method = Point::javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "coordinates");
     return jPoint.Call(env, method);
}
Esempio n. 7
0
std::string FileSource::ResourceTransformCallback::onURL(jni::JNIEnv& env, jni::Object<FileSource::ResourceTransformCallback> callback, int kind, std::string url_) {
    static auto method = FileSource::ResourceTransformCallback::javaClass.GetMethod<jni::String (jni::jint, jni::String)>(env, "onURL");
    auto url = jni::Make<jni::String>(env, url_);
    url = callback.Call(env, method, kind, url);
    return jni::Make<std::string>(env, url);
}