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 7 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
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