[android] Generate style code for symbol-sort-key
This commit is contained in:
@@ -110,6 +110,10 @@ public final class Property {
|
||||
|
||||
// SYMBOL_Z_ORDER: Controls the order in which overlapping symbols in the same layer are rendered
|
||||
|
||||
/**
|
||||
* If {@link SYMBOL_SORT_KEY} is set, sort based on that. Otherwise sort symbols by their position relative to the viewport.
|
||||
*/
|
||||
public static final String SYMBOL_Z_ORDER_AUTO = "auto";
|
||||
/**
|
||||
* Symbols will be sorted by their y-position relative to the viewport.
|
||||
*/
|
||||
@@ -123,6 +127,7 @@ public final class Property {
|
||||
* Controls the order in which overlapping symbols in the same layer are rendered
|
||||
*/
|
||||
@StringDef({
|
||||
SYMBOL_Z_ORDER_AUTO,
|
||||
SYMBOL_Z_ORDER_VIEWPORT_Y,
|
||||
SYMBOL_Z_ORDER_SOURCE,
|
||||
})
|
||||
|
||||
@@ -1785,6 +1785,26 @@ public class PropertyFactory {
|
||||
return new LayoutPropertyValue<>("symbol-avoid-edges", 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 wehn they overlap. Features with a lower sort key will have priority over other features when doing placement.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
*/
|
||||
public static PropertyValue<Float> symbolSortKey(Float value) {
|
||||
return new LayoutPropertyValue<>("symbol-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 wehn they overlap. Features with a lower sort key will have priority over other features when doing placement.
|
||||
*
|
||||
* @param value a Float value
|
||||
* @return property wrapper around Float
|
||||
*/
|
||||
public static PropertyValue<Expression> symbolSortKey(Expression value) {
|
||||
return new LayoutPropertyValue<>("symbol-sort-key", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the order in which overlapping symbols in the same layer are rendered
|
||||
*
|
||||
|
||||
@@ -181,6 +181,18 @@ public class SymbolLayer extends Layer {
|
||||
return (PropertyValue<Boolean>) new PropertyValue("symbol-avoid-edges", nativeGetSymbolAvoidEdges());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SymbolSortKey property
|
||||
*
|
||||
* @return property wrapper value around Float
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getSymbolSortKey() {
|
||||
checkThread();
|
||||
return (PropertyValue<Float>) new PropertyValue("symbol-sort-key", nativeGetSymbolSortKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SymbolZOrder property
|
||||
*
|
||||
@@ -1113,6 +1125,10 @@ public class SymbolLayer extends Layer {
|
||||
@Keep
|
||||
private native Object nativeGetSymbolAvoidEdges();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetSymbolSortKey();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetSymbolZOrder();
|
||||
|
||||
@@ -140,6 +140,32 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
assertEquals(layer.getSymbolAvoidEdges().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSymbolSortKeyAsConstant() {
|
||||
Timber.i("symbol-sort-key");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getSymbolSortKey().getValue());
|
||||
|
||||
// Set and Get
|
||||
Float propertyValue = 0.3f;
|
||||
layer.setProperties(symbolSortKey(propertyValue));
|
||||
assertEquals(layer.getSymbolSortKey().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSymbolSortKeyAsExpression() {
|
||||
Timber.i("symbol-sort-key-expression");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getSymbolSortKey().getExpression());
|
||||
|
||||
// Set and Get
|
||||
Expression expression = number(Expression.get("undefined"));
|
||||
layer.setProperties(symbolSortKey(expression));
|
||||
assertEquals(layer.getSymbolSortKey().getExpression(), expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testSymbolZOrderAsConstant() {
|
||||
@@ -148,7 +174,7 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
assertNull(layer.getSymbolZOrder().getValue());
|
||||
|
||||
// Set and Get
|
||||
String propertyValue = SYMBOL_Z_ORDER_VIEWPORT_Y;
|
||||
String propertyValue = SYMBOL_Z_ORDER_AUTO;
|
||||
layer.setProperties(symbolZOrder(propertyValue));
|
||||
assertEquals(layer.getSymbolZOrder().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace android {
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getSymbolAvoidEdges()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> SymbolLayer::getSymbolSortKey(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getSymbolSortKey()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> SymbolLayer::getSymbolZOrder(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getSymbolZOrder()));
|
||||
@@ -500,6 +505,7 @@ namespace android {
|
||||
METHOD(&SymbolLayer::getSymbolPlacement, "nativeGetSymbolPlacement"),
|
||||
METHOD(&SymbolLayer::getSymbolSpacing, "nativeGetSymbolSpacing"),
|
||||
METHOD(&SymbolLayer::getSymbolAvoidEdges, "nativeGetSymbolAvoidEdges"),
|
||||
METHOD(&SymbolLayer::getSymbolSortKey, "nativeGetSymbolSortKey"),
|
||||
METHOD(&SymbolLayer::getSymbolZOrder, "nativeGetSymbolZOrder"),
|
||||
METHOD(&SymbolLayer::getIconAllowOverlap, "nativeGetIconAllowOverlap"),
|
||||
METHOD(&SymbolLayer::getIconIgnorePlacement, "nativeGetIconIgnorePlacement"),
|
||||
|
||||
@@ -32,6 +32,8 @@ public:
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getSymbolAvoidEdges(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getSymbolSortKey(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getSymbolZOrder(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getIconAllowOverlap(jni::JNIEnv&);
|
||||
|
||||
Reference in New Issue
Block a user