summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2020-04-28 20:33:37 +0300
committerzmiao <miao.zhao@mapbox.com>2020-04-28 20:39:14 +0300
commit4b0d42c2c13dada961e46c17f88829a14ae5bb5a (patch)
tree875af0adb3085ed449d17a65e1d925ae37c21b12
parent34e475c3ace28ff774d4669e1c3ecc0d6aea2ca3 (diff)
downloadqtlocation-mapboxgl-upstream/zmiao-distance-expression-clean-up.tar.gz
[core] Distance expression: Remove code and comments related to unit argumentupstream/zmiao-distance-expression-clean-up
-rw-r--r--src/mbgl/style/expression/distance.cpp16
-rw-r--r--test/fixtures/expression_equality/distance.a.json2
-rw-r--r--test/fixtures/expression_equality/distance.b.json2
3 files changed, 9 insertions, 11 deletions
diff --git a/src/mbgl/style/expression/distance.cpp b/src/mbgl/style/expression/distance.cpp
index 9992ef5394..5ab1206340 100644
--- a/src/mbgl/style/expression/distance.cpp
+++ b/src/mbgl/style/expression/distance.cpp
@@ -394,28 +394,26 @@ double calculateDistance(const GeometryTileFeature& feature,
optional<GeoJSON> parseValue(const style::conversion::Convertible& value, style::expression::ParsingContext& ctx) {
if (isArray(value)) {
- // object value, quoted with ["Distance", GeoJSONObj, "unit(optional)"]
+ // object value, quoted with ["Distance", GeoJSONObj]
auto length = arrayLength(value);
- if (length != 2 && length != 3) {
- ctx.error("'distance' expression requires either one argument or two arguments, but found " +
+ if (length != 2) {
+ ctx.error("'distance' expression requires one argument, but found " +
util::toString(arrayLength(value) - 1) + " instead.");
return nullopt;
}
// Parse geometry info
- const auto& argument1 = arrayMember(value, 1);
- if (isObject(argument1)) {
+ const auto& argument = arrayMember(value, 1);
+ if (isObject(argument)) {
style::conversion::Error error;
- auto geojson = toGeoJSON(argument1, error);
+ auto geojson = toGeoJSON(argument, error);
if (geojson && error.message.empty()) {
return *geojson;
}
ctx.error(error.message);
}
}
- ctx.error(
- "'distance' expression needs to be an array with format [\"Distance\", GeoJSONObj, \"units\"(\"units\" is an "
- "optional argument, 'meters' will be used by default)].");
+ ctx.error("'distance' expression needs to be an array with format [\"Distance\", GeoJSONObj].");
return nullopt;
}
diff --git a/test/fixtures/expression_equality/distance.a.json b/test/fixtures/expression_equality/distance.a.json
index 25079db719..5deaf2c8f2 100644
--- a/test/fixtures/expression_equality/distance.a.json
+++ b/test/fixtures/expression_equality/distance.a.json
@@ -1,5 +1,5 @@
["distance", {
"type": "LineString",
"coordinates": [[0, 0], [0, 5], [5, 5], [5, 0]]
- }, "meters"
+ }
] \ No newline at end of file
diff --git a/test/fixtures/expression_equality/distance.b.json b/test/fixtures/expression_equality/distance.b.json
index cac710cb92..4a4714354e 100644
--- a/test/fixtures/expression_equality/distance.b.json
+++ b/test/fixtures/expression_equality/distance.b.json
@@ -1,5 +1,5 @@
["distance", {
"type": "LineString",
"coordinates": [[0, 0], [0, 6], [5, 5], [5, 0]]
- }, "meters"
+ }
] \ No newline at end of file