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

Commit

Permalink
[android] - add expression filter integration
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Mar 13, 2018
1 parent 961aba1 commit 04cc3ee
Show file tree
Hide file tree
Showing 36 changed files with 434 additions and 425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.style.layers.Filter;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.sources.Source;
Expand Down Expand Up @@ -2079,13 +2079,13 @@ public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates, @Nullabl
* Queries the map for rendered features
*
* @param coordinates the point to query
* @param filter filters the returned features
* @param filter filters the returned features with an expression
* @param layerIds optionally - only query these layers
* @return the list of feature
*/
@NonNull
public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
@Nullable Filter.Statement filter,
@Nullable Expression filter,
@Nullable String... layerIds) {
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
}
Expand All @@ -2107,13 +2107,13 @@ public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
* Queries the map for rendered features
*
* @param coordinates the box to query
* @param filter filters the returned features
* @param filter filters the returned features with an expression
* @param layerIds optionally - only query these layers
* @return the list of feature
*/
@NonNull
public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
@Nullable Filter.Statement filter,
@Nullable Expression filter,
@Nullable String... layerIds) {
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
import com.mapbox.mapboxsdk.style.layers.Filter;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
Expand Down Expand Up @@ -799,7 +799,7 @@ public Bitmap getImage(String name) {
@NonNull
public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
@Nullable String[] layerIds,
@Nullable Filter.Statement filter) {
@Nullable Expression filter) {
if (isDestroyedOn("queryRenderedFeatures")) {
return new ArrayList<>();
}
Expand All @@ -811,7 +811,7 @@ public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
@NonNull
public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
@Nullable String[] layerIds,
@Nullable Filter.Statement filter) {
@Nullable Expression filter) {
if (isDestroyedOn("queryRenderedFeatures")) {
return new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

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

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

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

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

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

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

/**
Expand Down Expand Up @@ -69,25 +72,40 @@ public String getSourceLayer() {
}

/**
* Set a single filter.
* Set a single expression filter.
*
* @param filter the filter to set
* @param filter the expression filter to set
*/
public void setFilter(Filter.Statement filter) {
public void setFilter(Expression filter) {
nativeSetFilter(filter.toArray());
}

/**
* Set a single filter.
* Set a single expression filter.
*
* @param filter the filter to set
* @param filter the expression filter to set
* @return This
*/
public CircleLayer withFilter(Filter.Statement filter) {
public CircleLayer withFilter(Expression filter) {
setFilter(filter);
return this;
}

/**
* Get a single expression filter.
*
* @return the expression filter to get
*/
@Nullable
public Expression getFilter() {
Expression expression = null;
Object object = nativeGetFilter();
if (object != null && object instanceof JsonArray) {
expression = Expression.Converter.convert((JsonArray) object);
}
return expression;
}

/**
* Set a property or properties.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

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

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

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

/**
Expand Down Expand Up @@ -69,25 +72,40 @@ public String getSourceLayer() {
}

/**
* Set a single filter.
* Set a single expression filter.
*
* @param filter the filter to set
* @param filter the expression filter to set
*/
public void setFilter(Filter.Statement filter) {
public void setFilter(Expression filter) {
nativeSetFilter(filter.toArray());
}

/**
* Set a single filter.
* Set a single expression filter.
*
* @param filter the filter to set
* @param filter the expression filter to set
* @return This
*/
public FillExtrusionLayer withFilter(Filter.Statement filter) {
public FillExtrusionLayer withFilter(Expression filter) {
setFilter(filter);
return this;
}

/**
* Get a single expression filter.
*
* @return the expression filter to get
*/
@Nullable
public Expression getFilter() {
Expression expression = null;
Object object = nativeGetFilter();
if (object != null && object instanceof JsonArray) {
expression = Expression.Converter.convert((JsonArray) object);
}
return expression;
}

/**
* Set a property or properties.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

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

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

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

/**
Expand Down Expand Up @@ -69,25 +72,40 @@ public String getSourceLayer() {
}

/**
* Set a single filter.
* Set a single expression filter.
*
* @param filter the filter to set
* @param filter the expression filter to set
*/
public void setFilter(Filter.Statement filter) {
public void setFilter(Expression filter) {
nativeSetFilter(filter.toArray());
}

/**
* Set a single filter.
* Set a single expression filter.
*
* @param filter the filter to set
* @param filter the expression filter to set
* @return This
*/
public FillLayer withFilter(Filter.Statement filter) {
public FillLayer withFilter(Expression filter) {
setFilter(filter);
return this;
}

/**
* Get a single expression filter.
*
* @return the expression filter to get
*/
@Nullable
public Expression getFilter() {
Expression expression = null;
Object object = nativeGetFilter();
if (object != null && object instanceof JsonArray) {
expression = Expression.Converter.convert((JsonArray) object);
}
return expression;
}

/**
* Set a property or properties.
*
Expand Down
Loading

0 comments on commit 04cc3ee

Please sign in to comment.