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

[core] Support line within polygon in within expression #16220

Merged
merged 8 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

The `in expression` enables checking whether a Number/String/Boolean type item is in a String/Array and returns a boolean value.

- [core] Add support for using `within expression` with features having `'LineString'` geometry type. ([#16220](https://github.com/mapbox/mapbox-gl-native/pull/16220))

`within expression` now supports features with geometry types: `'Point'` or `'LineString'`.

### 🐞 Bug fixes

- [core] Don't provide multiple responses with the same data for 304 replies ([#16200](https://github.com/mapbox/mapbox-gl-native/pull/16200))
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ add_library(
${PROJECT_SOURCE_DIR}/src/mbgl/util/font_stack.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/geo.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/geojson_impl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/geometry_within.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/geometry_within.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/grid_index.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/grid_index.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/hash.hpp
Expand Down
22 changes: 8 additions & 14 deletions include/mbgl/style/expression/within.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#pragma once

#include <mbgl/style/conversion.hpp>
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/parsing_context.hpp>
#include <mbgl/util/geojson.hpp>

#include <memory>
#include <mbgl/util/geometry_within.hpp>
#include <mbgl/util/optional.hpp>

namespace mbgl {
namespace style {
namespace expression {

class Within final : public Expression {
public:
explicit Within(GeoJSON geojson);
explicit Within(GeoJSON geojson, Feature::geometry_type geometries_, WithinBBox polygonBBox_);

~Within() override;

Expand All @@ -23,21 +21,17 @@ class Within final : public Expression {

void eachChild(const std::function<void(const Expression&)>&) const override {}

bool operator==(const Expression& e) const override {
if (e.getKind() == Kind::Within) {
auto rhs = static_cast<const Within*>(&e);
return geoJSONSource == rhs->geoJSONSource;
}
return false;
}
bool operator==(const Expression& e) const override;

std::vector<optional<Value>> possibleOutputs() const override { return {{true}, {false}}; }
std::vector<optional<Value>> possibleOutputs() const override;

mbgl::Value serialize() const override;
std::string getOperator() const override { return "within"; }
std::string getOperator() const override;

private:
GeoJSON geoJSONSource;
Feature::geometry_type geometries;
WithinBBox polygonBBox;
};

} // namespace expression
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
0,
0
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
5,
4,
13,
1,
[
49152,
49152
],
[
286,
286
],
[
528,
528
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
0,
0
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
5,
4,
13,
1,
[
49152,
49152
],
[
286,
286
],
[
528,
528
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
0,
0
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
5,
4,
13,
1,
[
49152,
49152
],
[
286,
286
],
[
528,
528
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
0,
0
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
5,
4,
13,
1,
[
49152,
49152
],
[
286,
286
],
[
528,
528
]
]
]
}
Loading