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

Commit

Permalink
Update generate-style-code and add sort key api for LineLayer and Fil…
Browse files Browse the repository at this point in the history
…lLayer.
  • Loading branch information
kevin committed Mar 3, 2020
1 parent c217a61 commit 68fc21f
Show file tree
Hide file tree
Showing 26 changed files with 186 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* The background color or pattern of the map.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* A filled circle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* An extruded (3D) polygon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* A filled polygon with an optional stroked border.
Expand Down Expand Up @@ -141,6 +143,18 @@ public FillLayer withProperties(@NonNull PropertyValue<?>... properties) {

// Property getters

/**
* Get the FillSortKey property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getFillSortKey() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("fill-sort-key", nativeGetFillSortKey());
}

/**
* Get the FillAntialias property
*
Expand Down Expand Up @@ -364,6 +378,10 @@ public void setFillPatternTransition(@NonNull TransitionOptions options) {
nativeSetFillPatternTransition(options.getDuration(), options.getDelay());
}

@NonNull
@Keep
private native Object nativeGetFillSortKey();

@NonNull
@Keep
private native Object nativeGetFillAntialias();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* A heatmap.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* Client-side hillshading visualization based on DEM data. Currently, the implementation only supports Mapbox Terrain RGB and Mapzen Terrarium tiles.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* A stroked line.
Expand Down Expand Up @@ -189,6 +191,18 @@ public PropertyValue<Float> getLineRoundLimit() {
return (PropertyValue<Float>) new PropertyValue("line-round-limit", nativeGetLineRoundLimit());
}

/**
* Get the LineSortKey property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getLineSortKey() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("line-sort-key", nativeGetLineSortKey());
}

/**
* Get the LineOpacity property
*
Expand Down Expand Up @@ -560,6 +574,10 @@ public int getLineGradientAsInt() {
@Keep
private native Object nativeGetLineRoundLimit();

@NonNull
@Keep
private native Object nativeGetLineSortKey();

@NonNull
@Keep
private native Object nativeGetLineOpacity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,26 @@ public static PropertyValue<Expression> backgroundOpacity(Expression expression)
return new PaintPropertyValue<>("background-opacity", expression);
}

/**
* 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> fillSortKey(Float value) {
return new LayoutPropertyValue<>("fill-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> fillSortKey(Expression value) {
return new LayoutPropertyValue<>("fill-sort-key", value);
}

/**
* The display of line endings.
*
Expand Down Expand Up @@ -1725,6 +1745,26 @@ public static PropertyValue<Expression> lineRoundLimit(Expression value) {
return new LayoutPropertyValue<>("line-round-limit", 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> lineSortKey(Float value) {
return new LayoutPropertyValue<>("line-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> lineSortKey(Expression value) {
return new LayoutPropertyValue<>("line-sort-key", value);
}

/**
* Label placement relative to its geometry.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
* Raster map textures such as satellite imagery.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;

/**
* An icon or a text label.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

package com.mapbox.mapboxsdk.style.layers;

import android.support.annotation.ColorInt;
import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import androidx.annotation.ColorInt;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package com.mapbox.mapboxsdk.style.layers;

import android.support.annotation.StringDef;
import androidx.annotation.StringDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package com.mapbox.mapboxsdk.style.layers;

import android.support.annotation.ColorInt;
import androidx.annotation.ColorInt;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.types.Formatted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

package com.mapbox.mapboxsdk.style.light;

import android.support.annotation.ColorInt;
import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import android.support.annotation.UiThread;
import androidx.annotation.ColorInt;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.UiThread;

import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import org.junit.Before;
import timber.log.Timber;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;

import org.junit.Test;
import org.junit.runner.RunWith;

import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,32 @@ public void testFilter() {



@Test
@UiThreadTest
public void testFillSortKeyAsConstant() {
Timber.i("fill-sort-key");
assertNotNull(layer);
assertNull(layer.getFillSortKey().getValue());

// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillSortKey(propertyValue));
assertEquals(layer.getFillSortKey().getValue(), propertyValue);
}

@Test
@UiThreadTest
public void testFillSortKeyAsExpression() {
Timber.i("fill-sort-key-expression");
assertNotNull(layer);
assertNull(layer.getFillSortKey().getExpression());

// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(fillSortKey(expression));
assertEquals(layer.getFillSortKey().getExpression(), expression);
}

@Test
@UiThreadTest
public void testFillAntialiasAsConstant() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.mapbox.mapboxsdk.testapp.style;

import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import org.junit.Before;
import timber.log.Timber;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.HillshadeLayer;

import org.junit.Test;
import org.junit.runner.RunWith;

import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,32 @@ public void testLineRoundLimitAsConstant() {
assertEquals(layer.getLineRoundLimit().getValue(), propertyValue);
}

@Test
@UiThreadTest
public void testLineSortKeyAsConstant() {
Timber.i("line-sort-key");
assertNotNull(layer);
assertNull(layer.getLineSortKey().getValue());

// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineSortKey(propertyValue));
assertEquals(layer.getLineSortKey().getValue(), propertyValue);
}

@Test
@UiThreadTest
public void testLineSortKeyAsExpression() {
Timber.i("line-sort-key-expression");
assertNotNull(layer);
assertNull(layer.getLineSortKey().getExpression());

// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineSortKey(expression));
assertEquals(layer.getLineSortKey().getExpression(), expression);
}

@Test
@UiThreadTest
public void testLineOpacityTransition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

package com.mapbox.mapboxsdk.testapp.style;

import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;

import org.junit.Test;
import org.junit.runner.RunWith;

import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
Expand Down
Loading

0 comments on commit 68fc21f

Please sign in to comment.