[android] Refactor composite stop types and conversions
This commit is contained in:
committed by
John Firebaugh
parent
f35ca0d9df
commit
c65e8bfa62
@@ -3,7 +3,10 @@ package com.mapbox.mapboxsdk.style.functions;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -21,13 +24,23 @@ import java.util.Map;
|
||||
* @param <O> the output type (the property type)
|
||||
* @see Function#composite
|
||||
*/
|
||||
public class CompositeFunction<Z extends Number, I, O> extends Function<I, O> {
|
||||
public class CompositeFunction<Z extends Number, I, O> extends Function<Stop.CompositeValue<Z, I>, O> {
|
||||
|
||||
private final String property;
|
||||
private O defaultValue;
|
||||
|
||||
CompositeFunction(@NonNull String property,
|
||||
@NonNull CompositeStops<Z, I, O, ? extends Stops<I, O>> stops) {
|
||||
@NonNull CategoricalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
this(null, property, stops);
|
||||
}
|
||||
|
||||
CompositeFunction(@NonNull String property,
|
||||
@NonNull ExponentialStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
this(null, property, stops);
|
||||
}
|
||||
|
||||
CompositeFunction(@NonNull String property,
|
||||
@NonNull IntervalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
this(null, property, stops);
|
||||
}
|
||||
|
||||
@@ -36,7 +49,7 @@ public class CompositeFunction<Z extends Number, I, O> extends Function<I, O> {
|
||||
* JNI Constructor
|
||||
*/
|
||||
private CompositeFunction(@Nullable O defaultValue, @NonNull String property,
|
||||
@NonNull CompositeStops<Z, I, O, ? extends Stops<I, O>> stops) {
|
||||
@NonNull Stops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
super(stops);
|
||||
this.defaultValue = defaultValue;
|
||||
this.property = property;
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
@@ -193,7 +192,7 @@ public class Function<I, O> {
|
||||
@NonNull String property,
|
||||
@NonNull CategoricalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
|
||||
return new CompositeFunction<>(property, new CompositeStops<>(stops));
|
||||
return new CompositeFunction<>(property, stops);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +218,7 @@ public class Function<I, O> {
|
||||
@NonNull String property,
|
||||
@NonNull ExponentialStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
|
||||
return new CompositeFunction<>(property, new CompositeStops<>(stops));
|
||||
return new CompositeFunction<>(property, stops);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +244,7 @@ public class Function<I, O> {
|
||||
@NonNull String property,
|
||||
@NonNull IntervalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
|
||||
return new CompositeFunction<>(property, new CompositeStops<>(stops));
|
||||
return new CompositeFunction<>(property, stops);
|
||||
}
|
||||
|
||||
// Class definition //
|
||||
@@ -257,7 +256,7 @@ public class Function<I, O> {
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
Function(@NonNull Stops stops) {
|
||||
Function(@NonNull Stops<I, O> stops) {
|
||||
this.stops = stops;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
|
||||
import android.support.annotation.Keep;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop.CompositeValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The {@link Stops} implementation for composite functions
|
||||
*
|
||||
* @param <Z> the zoom type (usually Float)
|
||||
* @param <I> the input type (the feature property type)
|
||||
* @param <O> the output type (the property type)
|
||||
* @param <S> the {@link Stops} implementation (eg CategoricalStops, {@link ExponentialStops} or {@link IntervalStops})
|
||||
*/
|
||||
public class CompositeStops<Z extends Number, I, O, S extends IterableStops<I, O, Stop<I, O>>>
|
||||
extends IterableStops<CompositeValue<Z, I>, O, Map.Entry<Z, S>> {
|
||||
|
||||
private final Map<Z, S> stops;
|
||||
|
||||
/**
|
||||
* JNI Constructor
|
||||
*
|
||||
* @param stops the stops {@link Map}
|
||||
*/
|
||||
@Keep
|
||||
private CompositeStops(@NonNull @Size(min = 1) Map<Z, S> stops) {
|
||||
this.stops = stops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create composite stops for {@link ExponentialStops}. Use
|
||||
* {@link com.mapbox.mapboxsdk.style.functions.Function#composite(String, ExponentialStops)}
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
public CompositeStops(@NonNull ExponentialStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
this.stops = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Z, List<Stop<I, O>>> entry : collect(stops).entrySet()) {
|
||||
// noinspection unchecked
|
||||
this.stops.put(entry.getKey(),
|
||||
(S) new ExponentialStops<>(stops.getBase(), entry.getValue().toArray(new Stop[0])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create composite stops for {@link IntervalStops}.
|
||||
* Use {@link com.mapbox.mapboxsdk.style.functions.Function#composite(String, IntervalStops)}
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
public CompositeStops(@NonNull IntervalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
this.stops = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Z, List<Stop<I, O>>> entry : collect(stops).entrySet()) {
|
||||
// noinspection unchecked
|
||||
this.stops.put(entry.getKey(), (S) new IntervalStops<>(entry.getValue().toArray(new Stop[0])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create composite stops for {@link CategoricalStops}.
|
||||
* Use {@link com.mapbox.mapboxsdk.style.functions.Function#composite(String, CategoricalStops)}
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
public CompositeStops(@NonNull CategoricalStops<CompositeValue<Z, I>, O> stops) {
|
||||
this.stops = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Z, List<Stop<I, O>>> entry : collect(stops).entrySet()) {
|
||||
// noinspection unchecked
|
||||
this.stops.put(entry.getKey(), (S) new CategoricalStops<>(entry.getValue().toArray(new Stop[0])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return stops.values().iterator().next().getTypeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> toValueObject() {
|
||||
Map<String, Object> map = super.toValueObject();
|
||||
|
||||
// Flatten and toValueObjects stops
|
||||
// noinspection unchecked
|
||||
map.put("stops", toValueObjects(flatten(this.stops).toArray(new Stop[0])));
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private List<Stop<CompositeValue<Z, I>, O>> flatten(Map<Z, S> stops) {
|
||||
List<Stop<CompositeValue<Z, I>, O>> flattenedStops = new ArrayList<>();
|
||||
for (Map.Entry<Z, S> entry : stops.entrySet()) {
|
||||
for (Stop<I, O> stop : entry.getValue()) {
|
||||
flattenedStops.add(new Stop<>(new CompositeValue<>(entry.getKey(), stop.in), stop.out));
|
||||
}
|
||||
}
|
||||
return flattenedStops;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Map<Z, List<Stop<I, O>>> collect(
|
||||
@NonNull IterableStops<CompositeValue<Z, I>, O, Stop<CompositeValue<Z, I>, O>> stops) {
|
||||
Map<Z, List<Stop<I, O>>> converted = new HashMap<>();
|
||||
|
||||
for (Stop<CompositeValue<Z, I>, O> stop : stops) {
|
||||
List<Stop<I, O>> stopsForZ = converted.get(stop.in.zoom);
|
||||
if (stopsForZ == null) {
|
||||
stopsForZ = new ArrayList<>();
|
||||
converted.put(stop.in.zoom, stopsForZ);
|
||||
}
|
||||
|
||||
stopsForZ.add(new Stop<>(stop.in.value, stop.out));
|
||||
}
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Map.Entry<Z, S>> iterator() {
|
||||
return stops.entrySet().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return stops.size();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,8 +52,8 @@ public class Stop<I, O> {
|
||||
* @param <V> the feature property input type
|
||||
*/
|
||||
public static class CompositeValue<Z extends Number, V> {
|
||||
Z zoom;
|
||||
V value;
|
||||
public final Z zoom;
|
||||
public final V value;
|
||||
|
||||
CompositeValue(Z zoom, V value) {
|
||||
this.zoom = zoom;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
@@ -77,6 +78,7 @@ public abstract class Stops<I, O> {
|
||||
*
|
||||
* @return the value object representation for conversion to core
|
||||
*/
|
||||
@CallSuper
|
||||
public Map<String, Object> toValueObject() {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("type", getTypeName());
|
||||
|
||||
@@ -13,10 +13,10 @@ import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -29,8 +29,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
|
||||
@@ -13,10 +13,10 @@ import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -29,8 +29,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
@@ -215,17 +213,15 @@ public class CircleLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getCircleRadius().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getCircleRadius().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleRadius().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getCircleRadius().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getCircleRadius().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getCircleRadius().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleRadius().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -479,17 +475,15 @@ public class CircleLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getCircleBlur().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getCircleBlur().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleBlur().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getCircleBlur().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getCircleBlur().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getCircleBlur().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleBlur().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -624,17 +618,15 @@ public class CircleLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getCircleOpacity().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getCircleOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleOpacity().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getCircleOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getCircleOpacity().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getCircleOpacity().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleOpacity().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -878,17 +870,15 @@ public class CircleLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getCircleStrokeWidth().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getCircleStrokeWidth().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeWidth().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getCircleStrokeWidth().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getCircleStrokeWidth().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeWidth().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1142,17 +1132,15 @@ public class CircleLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getCircleStrokeOpacity().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getCircleStrokeOpacity().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeOpacity().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -29,8 +29,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
@@ -251,17 +249,15 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getFillOpacity().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillOpacity().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -13,10 +13,10 @@ import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -29,8 +29,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
@@ -361,17 +359,15 @@ public class LineLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getLineOpacity().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getLineOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOpacity().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getLineOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getLineOpacity().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getLineOpacity().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOpacity().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -735,17 +731,15 @@ public class LineLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getLineGapWidth().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getLineGapWidth().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineGapWidth().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getLineGapWidth().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getLineGapWidth().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getLineGapWidth().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineGapWidth().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -880,17 +874,15 @@ public class LineLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getLineOffset().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getLineOffset().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOffset().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getLineOffset().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getLineOffset().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getLineOffset().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOffset().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1025,17 +1017,15 @@ public class LineLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getLineBlur().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getLineBlur().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineBlur().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getLineBlur().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getLineBlur().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getLineBlur().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineBlur().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -13,10 +13,10 @@ import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -29,8 +29,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
|
||||
@@ -13,10 +13,10 @@ import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -29,8 +29,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
@@ -614,17 +612,15 @@ public class SymbolLayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.getIconRotate().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getIconRotate().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconRotate().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getIconRotate().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getIconRotate().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getIconRotate().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconRotate().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,10 +17,10 @@ import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
@@ -33,8 +33,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
@@ -319,17 +317,15 @@ public class <%- camelize(type) %>LayerTest extends BaseStyleTest {
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, <%- propertyType(property) %>, <%- propertyType(property) %>, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>> stops =
|
||||
(CompositeStops<Float, <%- propertyType(property) %>, <%- propertyType(property) %>, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>>) layer.get<%- camelize(property.name) %>().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>>) layer.get<%- camelize(property.name) %>().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
|
||||
@@ -118,6 +118,16 @@ macro(mbgl_platform_core)
|
||||
platform/android/src/style/sources/raster_source.hpp
|
||||
platform/android/src/style/sources/vector_source.cpp
|
||||
platform/android/src/style/sources/vector_source.hpp
|
||||
platform/android/src/style/functions/stop.cpp
|
||||
platform/android/src/style/functions/stop.hpp
|
||||
platform/android/src/style/functions/categorical_stops.cpp
|
||||
platform/android/src/style/functions/categorical_stops.hpp
|
||||
platform/android/src/style/functions/exponential_stops.cpp
|
||||
platform/android/src/style/functions/exponential_stops.hpp
|
||||
platform/android/src/style/functions/identity_stops.cpp
|
||||
platform/android/src/style/functions/identity_stops.hpp
|
||||
platform/android/src/style/functions/interval_stops.cpp
|
||||
platform/android/src/style/functions/interval_stops.hpp
|
||||
|
||||
# Connectivity
|
||||
platform/android/src/connectivity_listener.cpp
|
||||
|
||||
21
platform/android/src/java/lang.hpp
Normal file
21
platform/android/src/java/lang.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace java {
|
||||
namespace lang {
|
||||
|
||||
class Float {
|
||||
public:
|
||||
static constexpr auto Name() { return "java/lang/Float"; };
|
||||
};
|
||||
|
||||
class Number {
|
||||
public:
|
||||
static constexpr auto Name() { return "java/lang/Number"; };
|
||||
};
|
||||
|
||||
} // namespace lang
|
||||
} // namespace java
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -14,6 +14,11 @@
|
||||
#include "bitmap.hpp"
|
||||
#include "bitmap_factory.hpp"
|
||||
#include "connectivity_listener.hpp"
|
||||
#include "style/functions/categorical_stops.hpp"
|
||||
#include "style/functions/exponential_stops.hpp"
|
||||
#include "style/functions/identity_stops.hpp"
|
||||
#include "style/functions/interval_stops.hpp"
|
||||
#include "style/functions/stop.hpp"
|
||||
#include "style/layers/layers.hpp"
|
||||
#include "style/sources/sources.hpp"
|
||||
|
||||
@@ -1780,6 +1785,11 @@ void registerNatives(JavaVM *vm) {
|
||||
BitmapFactory::registerNative(env);
|
||||
registerNativeLayers(env);
|
||||
registerNativeSources(env);
|
||||
Stop::registerNative(env);
|
||||
CategoricalStops::registerNative(env);
|
||||
ExponentialStops::registerNative(env);
|
||||
IdentityStops::registerNative(env);
|
||||
IntervalStops::registerNative(env);
|
||||
ConnectivityListener::registerNative(env);
|
||||
|
||||
latLngClass = &jni::FindClass(env, "com/mapbox/mapboxsdk/geometry/LatLng");
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
#include "../../conversion/conversion.hpp"
|
||||
#include "../../conversion/constant.hpp"
|
||||
#include "types.hpp"
|
||||
#include "../../java/lang.hpp"
|
||||
#include "../functions/stop.hpp"
|
||||
#include "../functions/categorical_stops.hpp"
|
||||
#include "../functions/exponential_stops.hpp"
|
||||
#include "../functions/identity_stops.hpp"
|
||||
#include "../functions/interval_stops.hpp"
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
@@ -44,7 +50,59 @@ struct Converter<jni::jobject*, mbgl::style::CategoricalValue> {
|
||||
};
|
||||
|
||||
template <class I, class O>
|
||||
inline jni::jobject* toFunctionStopJavaArray(jni::JNIEnv& env, std::map<I, O> value) {
|
||||
jni::Array<jni::Object<Stop>> toFunctionStopJavaArray(jni::JNIEnv& env, std::map<I, O> value) {
|
||||
|
||||
auto jarray = jni::Array<jni::Object<Stop>>::New(env, value.size(), Stop::javaClass);
|
||||
|
||||
size_t i = 0;
|
||||
for (auto const& stop : value) {
|
||||
jni::jobject* in = *convert<jni::jobject*, I>(env, stop.first);
|
||||
jni::jobject* out = *convert<jni::jobject*, O>(env, stop.second);
|
||||
|
||||
auto jstop = Stop::New(env, jni::Object<>(in), jni::Object<>(out));
|
||||
jarray.Set(env, i, jstop);
|
||||
|
||||
jni::DeleteLocalRef(env, in);
|
||||
jni::DeleteLocalRef(env, out);
|
||||
jni::DeleteLocalRef(env, jstop);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return jarray;
|
||||
}
|
||||
|
||||
template <class I, class O>
|
||||
jni::Array<jni::Object<Stop>> toFunctionStopJavaArray(jni::JNIEnv& env, std::map<float, std::map<I, O>> value) {
|
||||
|
||||
auto jarray = jni::Array<jni::Object<Stop>>::New(env, value.size(), Stop::javaClass);
|
||||
|
||||
for (auto const& zoomLevelMap : value) {
|
||||
size_t i = 0;
|
||||
for (auto const& stop: zoomLevelMap.second) {
|
||||
auto zoom = jni::Object<java::lang::Number>(*convert<jni::jobject*>(env, zoomLevelMap.first));
|
||||
auto in = jni::Object<>(*convert<jni::jobject*, I>(env, stop.first));
|
||||
auto out = jni::Object<>(*convert<jni::jobject*, O>(env, stop.second));
|
||||
auto compositeValue = Stop::CompositeValue::New(env, zoom, in);
|
||||
|
||||
auto jstop = Stop::New(env, compositeValue, out);
|
||||
jarray.Set(env, i, jstop);
|
||||
|
||||
jni::DeleteLocalRef(env, zoom);
|
||||
jni::DeleteLocalRef(env, in);
|
||||
jni::DeleteLocalRef(env, out);
|
||||
jni::DeleteLocalRef(env, compositeValue);
|
||||
jni::DeleteLocalRef(env, jstop);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return jarray;
|
||||
}
|
||||
|
||||
template <class I, typename O>
|
||||
inline jni::jobject* convertCompositeStopsArray(jni::JNIEnv& env, std::map<float, std::map<I, O>> value) {
|
||||
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/Stop")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
|
||||
@@ -73,85 +131,31 @@ public:
|
||||
StopsEvaluator(jni::JNIEnv& _env) : env(_env) {}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::CategoricalStops<T> &value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/CategoricalStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "([Lcom/mapbox/mapboxsdk/style/functions/stops/Stop;)V");
|
||||
return CategoricalStops::New(env, toFunctionStopJavaArray(env, value.stops)).Get();
|
||||
}
|
||||
|
||||
return &jni::NewObject(env, *clazz, *constructor, toFunctionStopJavaArray(env, value.stops));
|
||||
jni::jobject* operator()(const mbgl::style::CompositeCategoricalStops<T> &value) const {
|
||||
return CategoricalStops::New(env, toFunctionStopJavaArray(env, value.stops)).Get();
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::ExponentialStops<T> &value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "(Ljava/lang/Float;[Lcom/mapbox/mapboxsdk/style/functions/stops/Stop;)V");
|
||||
return ExponentialStops::New(env, jni::Object<java::lang::Float>(*convert<jni::jobject*>(env, value.base)), toFunctionStopJavaArray(env, value.stops)).Get();
|
||||
}
|
||||
|
||||
return &jni::NewObject(env, *clazz, *constructor,
|
||||
*convert<jni::jobject*>(env, value.base),
|
||||
toFunctionStopJavaArray(env, value.stops));
|
||||
jni::jobject* operator()(const mbgl::style::CompositeExponentialStops<T> &value) const {
|
||||
return ExponentialStops::New(env, jni::Object<java::lang::Float>(*convert<jni::jobject*>(env, value.base)), toFunctionStopJavaArray(env, value.stops)).Get();
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::IdentityStops<T> &) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/IdentityStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "()V");
|
||||
|
||||
return &jni::NewObject(env, *clazz, *constructor);
|
||||
return IdentityStops::New(env).Get();
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::IntervalStops<T> &value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/IntervalStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "([Lcom/mapbox/mapboxsdk/style/functions/stops/Stop;)V");
|
||||
|
||||
return &jni::NewObject(env, *clazz, *constructor, toFunctionStopJavaArray(env, value.stops));
|
||||
return IntervalStops::New(env, toFunctionStopJavaArray(env, value.stops)).Get();
|
||||
}
|
||||
|
||||
private:
|
||||
jni::JNIEnv& env;
|
||||
};
|
||||
|
||||
template <class T, typename X>
|
||||
inline jni::jobject* convertCompositeStopsArray(jni::JNIEnv& env, std::map<float, T> value) {
|
||||
// Create Java Map
|
||||
static jni::jclass* mapClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/util/HashMap")).release();
|
||||
static jni::jmethodID* mapConstructor = &jni::GetMethodID(env, *mapClass, "<init>", "()V");
|
||||
static jni::jmethodID* mapPutMethod = &jni::GetMethodID(env, *mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
jni::jobject& map = jni::NewObject(env, *mapClass, *mapConstructor);
|
||||
|
||||
// Add converted Stops for each zoom value
|
||||
StopsEvaluator<X> evaluator(env);
|
||||
for (auto const& entry : value) {
|
||||
jni::jobject* zoom = *convert<jni::jobject*, float>(env, entry.first);
|
||||
jni::jobject* stops = evaluator(entry.second);
|
||||
jni::CallMethod<jni::jobject*>(env, &map, *mapPutMethod, zoom, stops);
|
||||
jni::DeleteLocalRef(env, zoom);
|
||||
jni::DeleteLocalRef(env, stops);
|
||||
}
|
||||
|
||||
// Create CompositeStops from Java Map
|
||||
static jni::jclass* compositeStopsClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/CompositeStops")).release();
|
||||
static jni::jmethodID* compositeStopsConstructor = &jni::GetMethodID(env, *compositeStopsClass, "<init>", "(Ljava/util/Map;)V");
|
||||
jni::jobject& compositeStops = jni::NewObject(env, *compositeStopsClass, *compositeStopsConstructor, &map);
|
||||
jni::DeleteLocalRef(env, &map);
|
||||
|
||||
return &compositeStops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion from core composite function stops to CompositeFunctionStops java type
|
||||
*/
|
||||
template <class T>
|
||||
class CompositeStopsEvaluator {
|
||||
public:
|
||||
|
||||
CompositeStopsEvaluator(jni::JNIEnv& _env) : env(_env) {}
|
||||
|
||||
jni::jobject* operator()(const std::map<float, mbgl::style::CategoricalStops<T>> &value) const {
|
||||
return convertCompositeStopsArray<mbgl::style::CategoricalStops<T>, T>(env, value);
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const std::map<float, mbgl::style::ExponentialStops<T>> &value) const {
|
||||
return convertCompositeStopsArray<mbgl::style::ExponentialStops<T>, T>(env, value);
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const std::map<float, mbgl::style::IntervalStops<T>> &value) const {
|
||||
return convertCompositeStopsArray<mbgl::style::IntervalStops<T>, T>(env, value);
|
||||
jni::jobject* operator()(const mbgl::style::CompositeIntervalStops<T> &value) const {
|
||||
return IntervalStops::New(env, toFunctionStopJavaArray(env, value.stops)).Get();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -201,10 +205,10 @@ struct Converter<jni::jobject*, mbgl::style::CompositeFunction<T>> {
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::CompositeFunction<T>& value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/CompositeFunction")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>",
|
||||
"(Ljava/lang/Object;Ljava/lang/String;Lcom/mapbox/mapboxsdk/style/functions/stops/CompositeStops;)V");
|
||||
"(Ljava/lang/Object;Ljava/lang/String;Lcom/mapbox/mapboxsdk/style/functions/stops/Stops;)V");
|
||||
|
||||
// Convert stops
|
||||
CompositeStopsEvaluator<T> evaluator(env);
|
||||
StopsEvaluator<T> evaluator(env);
|
||||
jni::jobject* stops = apply_visitor(evaluator, value.stops);
|
||||
|
||||
|
||||
|
||||
18
platform/android/src/style/functions/categorical_stops.cpp
Normal file
18
platform/android/src/style/functions/categorical_stops.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "categorical_stops.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
jni::Object<CategoricalStops> CategoricalStops::New(jni::JNIEnv& env, jni::Array<jni::Object<Stop>> stops) {
|
||||
static auto constructor = CategoricalStops::javaClass.GetConstructor<jni::Array<jni::Object<Stop>>>(env);
|
||||
return CategoricalStops::javaClass.New(env, constructor, stops);
|
||||
}
|
||||
|
||||
jni::Class<CategoricalStops> CategoricalStops::javaClass;
|
||||
|
||||
void CategoricalStops::registerNative(jni::JNIEnv& env) {
|
||||
CategoricalStops::javaClass = *jni::Class<CategoricalStops>::Find(env).NewGlobalRef(env).release();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
23
platform/android/src/style/functions/categorical_stops.hpp
Normal file
23
platform/android/src/style/functions/categorical_stops.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
#include "stop.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class CategoricalStops : private mbgl::util::noncopyable {
|
||||
public:
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/functions/stops/CategoricalStops"; };
|
||||
|
||||
static jni::Object<CategoricalStops> New(jni::JNIEnv&, jni::Array<jni::Object<Stop>>);
|
||||
|
||||
static jni::Class<CategoricalStops> javaClass;
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
18
platform/android/src/style/functions/exponential_stops.cpp
Normal file
18
platform/android/src/style/functions/exponential_stops.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "exponential_stops.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
jni::Object<ExponentialStops> ExponentialStops::New(jni::JNIEnv& env, jni::Object<java::lang::Float> base, jni::Array<jni::Object<Stop>> stops) {
|
||||
static auto constructor = ExponentialStops::javaClass.GetConstructor<jni::Object<java::lang::Float>, jni::Array<jni::Object<Stop>>>(env);
|
||||
return ExponentialStops::javaClass.New(env, constructor, base, stops);
|
||||
}
|
||||
|
||||
jni::Class<ExponentialStops> ExponentialStops::javaClass;
|
||||
|
||||
void ExponentialStops::registerNative(jni::JNIEnv& env) {
|
||||
ExponentialStops::javaClass = *jni::Class<ExponentialStops>::Find(env).NewGlobalRef(env).release();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
24
platform/android/src/style/functions/exponential_stops.hpp
Normal file
24
platform/android/src/style/functions/exponential_stops.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
#include "../../java/lang.hpp"
|
||||
#include "stop.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class ExponentialStops : private mbgl::util::noncopyable {
|
||||
public:
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops"; };
|
||||
|
||||
static jni::Object<ExponentialStops> New(jni::JNIEnv&, jni::Object<java::lang::Float>, jni::Array<jni::Object<Stop>>);
|
||||
|
||||
static jni::Class<ExponentialStops> javaClass;
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
18
platform/android/src/style/functions/identity_stops.cpp
Normal file
18
platform/android/src/style/functions/identity_stops.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "identity_stops.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
jni::Object<IdentityStops> IdentityStops::New(jni::JNIEnv& env) {
|
||||
static auto constructor = IdentityStops::javaClass.GetConstructor<>(env);
|
||||
return IdentityStops::javaClass.New(env, constructor);
|
||||
}
|
||||
|
||||
jni::Class<IdentityStops> IdentityStops::javaClass;
|
||||
|
||||
void IdentityStops::registerNative(jni::JNIEnv& env) {
|
||||
IdentityStops::javaClass = *jni::Class<IdentityStops>::Find(env).NewGlobalRef(env).release();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
21
platform/android/src/style/functions/identity_stops.hpp
Normal file
21
platform/android/src/style/functions/identity_stops.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class IdentityStops : private mbgl::util::noncopyable {
|
||||
public:
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/functions/stops/IdentityStops"; };
|
||||
|
||||
static jni::Object<IdentityStops> New(jni::JNIEnv&);
|
||||
|
||||
static jni::Class<IdentityStops> javaClass;
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
18
platform/android/src/style/functions/interval_stops.cpp
Normal file
18
platform/android/src/style/functions/interval_stops.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "interval_stops.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
jni::Object<IntervalStops> IntervalStops::New(jni::JNIEnv& env, jni::Array<jni::Object<Stop>> stops) {
|
||||
static auto constructor = IntervalStops::javaClass.GetConstructor<jni::Array<jni::Object<Stop>>>(env);
|
||||
return IntervalStops::javaClass.New(env, constructor, stops);
|
||||
}
|
||||
|
||||
jni::Class<IntervalStops> IntervalStops::javaClass;
|
||||
|
||||
void IntervalStops::registerNative(jni::JNIEnv& env) {
|
||||
IntervalStops::javaClass = *jni::Class<IntervalStops>::Find(env).NewGlobalRef(env).release();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
23
platform/android/src/style/functions/interval_stops.hpp
Normal file
23
platform/android/src/style/functions/interval_stops.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
#include "stop.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class IntervalStops : private mbgl::util::noncopyable {
|
||||
public:
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/functions/stops/IntervalStops"; };
|
||||
|
||||
static jni::Object<IntervalStops> New(jni::JNIEnv&, jni::Array<jni::Object<Stop>>);
|
||||
|
||||
static jni::Class<IntervalStops> javaClass;
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
21
platform/android/src/style/functions/stop.cpp
Normal file
21
platform/android/src/style/functions/stop.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "interval_stops.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
jni::Object<Stop::CompositeValue> Stop::CompositeValue::New(jni::JNIEnv& env, jni::Object<java::lang::Number> zoom, jni::Object<> value) {
|
||||
static auto constructor = Stop::CompositeValue::javaClass.GetConstructor<jni::Object<java::lang::Number>, jni::Object<>>(env);
|
||||
return Stop::CompositeValue::javaClass.New(env, constructor, zoom, value);
|
||||
}
|
||||
|
||||
jni::Class<Stop> Stop::javaClass;
|
||||
|
||||
jni::Class<Stop::CompositeValue> Stop::CompositeValue::javaClass;
|
||||
|
||||
void Stop::registerNative(jni::JNIEnv& env) {
|
||||
Stop::javaClass = *jni::Class<Stop>::Find(env).NewGlobalRef(env).release();
|
||||
Stop::CompositeValue::javaClass = *jni::Class<Stop::CompositeValue>::Find(env).NewGlobalRef(env).release();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
36
platform/android/src/style/functions/stop.hpp
Normal file
36
platform/android/src/style/functions/stop.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
#include "../../java/lang.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class Stop : private mbgl::util::noncopyable {
|
||||
public:
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/functions/stops/Stop"; };
|
||||
|
||||
template<class I, class O>
|
||||
static jni::Object<Stop> New(jni::JNIEnv& env, jni::Object<I> in, jni::Object<O> out) {
|
||||
static auto constructor = Stop::javaClass.GetConstructor<jni::Object<>, jni::Object<>>(env);
|
||||
return Stop::javaClass.New(env, constructor, (jni::Object<>) in, (jni::Object<>) out);
|
||||
}
|
||||
|
||||
static jni::Class<Stop> javaClass;
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
|
||||
class CompositeValue : private mbgl::util::noncopyable {
|
||||
public:
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/functions/stops/Stop$CompositeValue"; };
|
||||
|
||||
static jni::Object<Stop::CompositeValue> New(jni::JNIEnv&, jni::Object<java::lang::Number>, jni::Object<>);
|
||||
|
||||
static jni::Class<Stop::CompositeValue> javaClass;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user