Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #5896 - use mas geojson classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivovandongen committed Aug 9, 2016
1 parent 6b2fe1c commit 211133c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 16 deletions.
3 changes: 3 additions & 0 deletions platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dependencies {
compile "com.android.support:design:${supportLibVersion}"
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'com.mapzen.android:lost:1.1.0'
compile ('com.mapbox.mapboxsdk:mapbox-java-services:1.1.0@jar') {
transitive=true
}
}

android {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
import com.mapbox.mapboxsdk.geojson.Feature;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.InfoWindow;
Expand All @@ -44,6 +43,7 @@
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.services.commons.geojson.Feature;

import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.support.annotation.Nullable;
import android.view.Surface;

import com.mapbox.mapboxsdk.geojson.Feature;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.Polygon;
Expand All @@ -21,6 +20,7 @@
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.services.commons.geojson.Feature;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import android.util.Log;
import android.view.MenuItem;

import com.mapbox.mapboxsdk.geojson.Feature;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.services.commons.geojson.Feature;

import java.util.List;

Expand Down
26 changes: 22 additions & 4 deletions platform/android/src/geometry/conversion/feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../../conversion/conversion.hpp"

#include <mbgl/util/optional.hpp>
#include <mapbox/geometry.hpp>
#include <jni/jni.hpp>

#include <string>
Expand All @@ -14,11 +15,28 @@ namespace mbgl {
namespace android {
namespace conversion {

template <>
struct Converter<jni::jarray<jni::jobject>*, std::vector<Feature>> {
Result<jni::jarray<jni::jobject>*> operator()(jni::JNIEnv& env, const std::vector<Feature>& value) const {
static jni::jclass* featureClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/geojson/Feature")).release();

template <class T>
struct Converter<jni::jobject*, mapbox::geometry::feature<T>> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mapbox::geometry::feature<T>& value) const {
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/services/commons/geojson/Feature")).release();
static jni::jmethodID* fromGeometry = &jni::GetStaticMethodID(env, *javaClass, "fromGeometry", "(Lcom/mapbox/services/commons/geojson/Geometry;)Lcom/mapbox/services/commons/geojson/Feature;");
/**, TODO: converted geometry**/
return {reinterpret_cast<jni::jobject*>(jni::CallStaticMethod<jni::jobject*>(env, *javaClass, *fromGeometry, (jni::jobject*) nullptr))};
}
};

template <class T>
struct Converter<jni::jarray<jni::jobject>*, std::vector<mapbox::geometry::feature<T>>> {
Result<jni::jarray<jni::jobject>*> operator()(jni::JNIEnv& env, const std::vector<mapbox::geometry::feature<T>>& value) const {
static jni::jclass* featureClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/services/commons/geojson/Feature")).release();
jni::jarray<jni::jobject>& jarray = jni::NewObjectArray(env, value.size(), *featureClass);

for(size_t i = 0; i < value.size(); i = i + 1) {
Result<jni::jobject*> converted = convert<jni::jobject*, mapbox::geometry::feature<T>>(env, value.at(i));
jni::SetObjectArrayElement(env, jarray, i, *converted);
}

return {&jarray};
}
};
Expand Down
2 changes: 1 addition & 1 deletion platform/android/src/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
MAKE_NATIVE_METHOD(nativeRemoveSource, "(JLjava/lang/String;)V"),
MAKE_NATIVE_METHOD(nativeSetContentPadding, "(JDDDD)V"),
MAKE_NATIVE_METHOD(nativeScheduleTakeSnapshot, "(J)V"),
MAKE_NATIVE_METHOD(nativeQueryRenderedFeatures, "(JFF[Ljava/lang/String;)[Lcom/mapbox/mapboxsdk/geojson/Feature;")
MAKE_NATIVE_METHOD(nativeQueryRenderedFeatures, "(JFF[Ljava/lang/String;)[Lcom/mapbox/services/commons/geojson/Feature;")
);

// Offline begin
Expand Down

0 comments on commit 211133c

Please sign in to comment.