Remove unit param for expression distance. (#352)

This commit is contained in:
Kevin Li
2020-04-29 15:57:25 +08:00
committed by GitHub
parent 4e878d614d
commit 859f64f97e
3 changed files with 1 additions and 23 deletions

View File

@@ -1575,24 +1575,6 @@ public class Expression {
return new Expression("in", literal(needle), haystack);
}
/**
* Retrieves the shortest distance between two geometries.
* The returned value can be consumed as an input into another expression for changing a paint or layout property
* or filtering features by distance.
*
* @param geoJson the target feature geoJso.
* Currently supports `Point`, `MultiPoint`, `LineString`, `MultiLineString` geometry types
* @param unit the unit for the returned value.
* Currently supports `metres`, `kilometers`, `miles`, `nauticalmiles`, "yards","feet","inches"。
* @return the distance in the unit that is provided.
* @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-distance">Style specification</a>
*/
public static Expression distance(@NonNull GeoJson geoJson, String unit) {
Map<String, Expression> map = new HashMap<>();
map.put("json", literal(geoJson.toJson()));
return new Expression("distance", new ExpressionMap(map), literal(unit));
}
/**
* Retrieves the shortest distance between two geometries.
* The returned value can be consumed as an input into another expression for changing a paint or layout property

View File

@@ -497,10 +497,6 @@ public class ExpressionTest {
Object[] expected = new Object[] {"distance", map};
Object[] actual = distance(point).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
Object[] expectedWithUnit = new Object[] {"distance", map, "meters"};
Object[] actualWithUnit = distance(point, "meters").toArray();
assertTrue("expression should match", Arrays.deepEquals(expectedWithUnit, actualWithUnit));
}

View File

@@ -74,7 +74,7 @@ class DistanceExpressionActivity : AppCompatActivity() {
val symbolLayer = style.getLayer("poi-label") as SymbolLayer
symbolLayer.setFilter(lt(
distance(
Point.fromLngLat(lon, lat), "meters"
Point.fromLngLat(lon, lat)
), 150)
)