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

Support polygon geometry type in distance expression #16446

Merged
merged 5 commits into from
Apr 29, 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 @@ -2,6 +2,10 @@

## master

### ✨ New features

- [core] Add support for `Polygon`, `MultiPolygon` geometry types in `distance` expression. ([#16446](https://github.com/mapbox/mapbox-gl-native/pull/16446))

### 🐞 Bug fixes

- [core][tile mode] Labels priority fixes ([#16432](https://github.com/mapbox/mapbox-gl-native/pull/16432))
Expand Down
2 changes: 1 addition & 1 deletion metrics/binary-size/android-arm64-v8a/metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[
"android-arm64-v8a",
"/tmp/attach/install/android-arm64-v8a-release/lib/libmbgl-render-test-runner.so",
1856758
1878341
]
]
}
484 changes: 407 additions & 77 deletions src/mbgl/style/expression/distance.cpp

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/mbgl/util/geometry_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,13 @@ template bool lineStringWithinPolygon(const LineString<int64_t>& line, const Pol
template bool lineStringWithinPolygons(const LineString<int64_t>& line, const MultiPolygon<int64_t>& polygons);

template void updateBBox(GeometryBBox<double>& bbox, const Point<double>& p);
template bool boxWithinBox(const GeometryBBox<double>& bbox1, const GeometryBBox<double>& bbox2);
template bool segmentIntersectSegment(const Point<double>& a,
const Point<double>& b,
const Point<double>& c,
const Point<double>& d);
template bool pointWithinPolygon(const Point<double>& point,
const Polygon<double>& polygon,
bool trueOnBoundary = false);

} // namespace mbgl
75 changes: 75 additions & 0 deletions test/fixtures/geometry_data/multi_point_3.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"type": "Feature",
"properties": {
"marker-color": "#e0d96a"
},
"geometry": {
"type": "MultiPoint",
"coordinates": [
[
24.941325187683105,
60.169503396855
],
[
24.943127632141113,
60.16984495711831
],
[
24.94493007659912,
60.17101904344053
],
[
24.947762489318848,
60.16753935642882
],
[
24.9479341506958,
60.16907644153227
],
[
24.946002960205078,
60.16901239775532
],
[
24.944028854370117,
60.16824386269413
],
[
24.9459171295166,
60.16756070532545
],
[
24.940338134765625,
60.168286559558055
],
[
24.94248390197754,
60.1678168910033
],
[
24.944286346435547,
60.16696293097573
],
[
24.946260452270508,
60.16619434797435
],
[
24.941411018371582,
60.16619434797435
],
[
24.943749904632565,
60.16782756536319
],
[
24.942612648010254,
60.16908711548297
],
[
24.944608211517334,
60.16952474447549
]
]
}
}
132 changes: 132 additions & 0 deletions test/fixtures/geometry_data/multi_polygon_1.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"stroke": "#e0d96a",
"stroke-width": 2,
"stroke-opacity": 1,
"fill": "#c6ec00",
"fill-opacity": 0.5
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
24.93870735168457,
60.16429416283512
],
[
24.936389923095703,
60.16205223008669
],
[
24.940123558044434,
60.16250062887229
],
[
24.943857192993164,
60.16333335324268
],
[
24.943127632141113,
60.16465712803696
],
[
24.94123935699463,
60.16595949958244
],
[
24.936561584472656,
60.16561789892518
],
[
24.93450164794922,
60.16435821580911
],
[
24.935274124145508,
60.163568220403924
],
[
24.93870735168457,
60.16429416283512
]
]
],
[
[
[
24.95166778564453,
60.174306261926034
],
[
24.949607849121094,
60.172918839697616
],
[
24.952783584594727,
60.17144597351834
],
[
24.95595932006836,
60.17217174191747
],
[
24.956517219543457,
60.1742635728851
],
[
24.954586029052734,
60.175736312737385
],
[
24.950637817382812,
60.175245406790246
],
[
24.9514102935791,
60.174348950911465
],
[
24.95166778564453,
60.174306261926034
]
]
],
[
[
[
24.930424690246582,
60.17413550542946
],
[
24.92875099182129,
60.171830205844614
],
[
24.936904907226562,
60.1703145966823
],
[
24.937891960144043,
60.172150396016946
],
[
24.937891960144043,
60.173922058560485
],
[
24.930424690246582,
60.17413550542946
]
]
]
]
}
}
]
}
81 changes: 81 additions & 0 deletions test/fixtures/geometry_data/multi_polygon_2.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
24.94171142578125,
60.16777419352904
],
[
24.948577880859375,
60.16777419352904
],
[
24.948577880859375,
60.170122472217564
],
[
24.94171142578125,
60.170122472217564
],
[
24.94171142578125,
60.16777419352904
]
]
],
[
[
[
24.951581954956055,
60.169503396855
],
[
24.955186843872067,
60.169503396855
],
[
24.955186843872067,
60.17052806699205
],
[
24.951581954956055,
60.17052806699205
],
[
24.951581954956055,
60.169503396855
]
]
],
[
[
[
24.944243431091305,
60.16301307713581
],
[
24.94716167449951,
60.16301307713581
],
[
24.94716167449951,
60.16412335429406
],
[
24.944243431091305,
60.16412335429406
],
[
24.944243431091305,
60.16301307713581
]
]
]
]
}
}
Loading