Add bindings for circle-sort-key (#322)
* Update generate-style-code.js * add jni bindings for circle-sort-key * update mapbox-gl-native to latest * Revert "add jni bindings for circle-sort-key" This reverts commit cdd6049d Co-authored-by: kevin <kevin.li@mapbox.com>
This commit is contained in:
@@ -37,6 +37,11 @@ namespace android {
|
||||
|
||||
// Property getters
|
||||
|
||||
jni::Local<jni::Object<>> CircleLayer::getCircleSortKey(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toCircleLayer(layer).getCircleSortKey()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> CircleLayer::getCircleRadius(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toCircleLayer(layer).getCircleRadius()));
|
||||
@@ -237,6 +242,7 @@ namespace android {
|
||||
jni::MakePeer<CircleLayer, jni::String&, jni::String&>,
|
||||
"initialize",
|
||||
"finalize",
|
||||
METHOD(&CircleLayer::getCircleSortKey, "nativeGetCircleSortKey"),
|
||||
METHOD(&CircleLayer::getCircleRadiusTransition, "nativeGetCircleRadiusTransition"),
|
||||
METHOD(&CircleLayer::setCircleRadiusTransition, "nativeSetCircleRadiusTransition"),
|
||||
METHOD(&CircleLayer::getCircleRadius, "nativeGetCircleRadius"),
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
|
||||
// Properties
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getCircleSortKey(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getCircleRadius(jni::JNIEnv&);
|
||||
void setCircleRadiusTransition(jni::JNIEnv&, jlong duration, jlong delay);
|
||||
jni::Local<jni::Object<TransitionOptions>> getCircleRadiusTransition(jni::JNIEnv&);
|
||||
|
||||
@@ -143,6 +143,18 @@ public class CircleLayer extends Layer {
|
||||
|
||||
// Property getters
|
||||
|
||||
/**
|
||||
* Get the CircleSortKey property
|
||||
*
|
||||
* @return property wrapper value around Float
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getCircleSortKey() {
|
||||
checkThread();
|
||||
return (PropertyValue<Float>) new PropertyValue("circle-sort-key", nativeGetCircleSortKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CircleRadius property
|
||||
*
|
||||
@@ -477,6 +489,10 @@ public class CircleLayer extends Layer {
|
||||
nativeSetCircleStrokeOpacityTransition(options.getDuration(), options.getDelay());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetCircleSortKey();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetCircleRadius();
|
||||
|
||||
@@ -1826,7 +1826,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key when they overlap. Features with a lower sort key will have priority over other features when doing placement.
|
||||
* Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When {@link PropertyFactory#iconAllowOverlap} or {@link PropertyFactory#textAllowOverlap} is `false`, features with a lower sort key will have priority during placement. When {@link PropertyFactory#iconAllowOverlap} or {@link PropertyFactory#textAllowOverlap} is set to `true`, features with a higher sort key will overlap over features with a lower sort key.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
@@ -1836,7 +1836,7 @@ public class PropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key when they overlap. Features with a lower sort key will have priority over other features when doing placement.
|
||||
* Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When {@link PropertyFactory#iconAllowOverlap} or {@link PropertyFactory#textAllowOverlap} is `false`, features with a lower sort key will have priority during placement. When {@link PropertyFactory#iconAllowOverlap} or {@link PropertyFactory#textAllowOverlap} is set to `true`, features with a higher sort key will overlap over features with a lower sort key.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
@@ -2595,4 +2595,24 @@ public class PropertyFactory {
|
||||
return new LayoutPropertyValue<>("text-optional", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
*/
|
||||
public static PropertyValue<Float> circleSortKey(Float value) {
|
||||
return new LayoutPropertyValue<>("circle-sort-key", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
*/
|
||||
public static PropertyValue<Expression> circleSortKey(Expression value) {
|
||||
return new LayoutPropertyValue<>("circle-sort-key", value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -99,6 +99,32 @@ public class CircleLayerTest extends BaseLayerTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testCircleSortKeyAsConstant() {
|
||||
Timber.i("circle-sort-key");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getCircleSortKey().getValue());
|
||||
|
||||
// Set and Get
|
||||
Float propertyValue = 0.3f;
|
||||
layer.setProperties(circleSortKey(propertyValue));
|
||||
assertEquals(layer.getCircleSortKey().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testCircleSortKeyAsExpression() {
|
||||
Timber.i("circle-sort-key-expression");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getCircleSortKey().getExpression());
|
||||
|
||||
// Set and Get
|
||||
Expression expression = number(Expression.get("undefined"));
|
||||
layer.setProperties(circleSortKey(expression));
|
||||
assertEquals(layer.getCircleSortKey().getExpression(), expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testCircleRadiusTransition() {
|
||||
|
||||
@@ -7,7 +7,7 @@ const spec = require('../vendor/mapbox-gl-native/scripts/style-spec');
|
||||
const _ = require('lodash');
|
||||
|
||||
// FIXME: https://github.com/mapbox/mapbox-gl-native/issues/15008
|
||||
delete spec.layout_circle["circle-sort-key"]
|
||||
//delete spec.layout_circle["circle-sort-key"]
|
||||
//delete spec.layout_line["line-sort-key"]
|
||||
//delete spec.layout_fill["fill-sort-key"]
|
||||
|
||||
@@ -384,14 +384,14 @@ for (const layer of layers) {
|
||||
}
|
||||
|
||||
// Jni
|
||||
const layerHpp = ejs.compile(fs.readFileSync('vendor/mapbox-gl-native/platform/android/src/style/layers/layer.hpp.ejs', 'utf8'), {strict: true});
|
||||
const layerCpp = ejs.compile(fs.readFileSync('vendor/mapbox-gl-native/platform/android/src/style/layers/layer.cpp.ejs', 'utf8'), {strict: true});
|
||||
const layerHpp = ejs.compile(fs.readFileSync('MapboxGLAndroidSDK/src/cpp/style/layers/layer.hpp.ejs', 'utf8'), {strict: true});
|
||||
const layerCpp = ejs.compile(fs.readFileSync('MapboxGLAndroidSDK/src/cpp/style/layers/layer.cpp.ejs', 'utf8'), {strict: true});
|
||||
|
||||
for (const layer of layers) {
|
||||
const layerFileName = layer.type.replace('-', '_');
|
||||
|
||||
writeIfModified(`vendor/mapbox-gl-native/platform/android/src/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer));
|
||||
writeIfModified(`vendor/mapbox-gl-native/platform/android/src/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer));
|
||||
writeIfModified(`MapboxGLAndroidSDK/src/cpp/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer));
|
||||
writeIfModified(`MapboxGLAndroidSDK/src/cpp/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer));
|
||||
}
|
||||
|
||||
// Java PropertyFactory
|
||||
|
||||
2
vendor/mapbox-gl-native
vendored
2
vendor/mapbox-gl-native
vendored
Submodule vendor/mapbox-gl-native updated: be9ca95e9a...66ac554459
Reference in New Issue
Block a user