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

Commit 131ce55

Browse files
committed
Restore point order in polygons that don't require fixup
wagyu algorithm setup and checking if polygon fixup is required is expensive as much as fixing it - so we continue running wagyu for all geojson and, if attempt to restore original point order after wagyu. Even with no polygon fixup, starting point in rings is changed. This causes a disparity between GL-JS and GL-native, visible in implementation of fill-extrusion pattern. Fixes: #15268
1 parent acfcd5c commit 131ce55

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

platform/node/test/ignores.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@
4747
"render-tests/debug/tile": "https://github.com/mapbox/mapbox-gl-native/issues/3841",
4848
"render-tests/debug/tile-overscaled": "https://github.com/mapbox/mapbox-gl-native/issues/3841",
4949
"render-tests/extent/1024-circle": "needs investigation",
50-
"render-tests/fill-extrusion-pattern/@2x": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
51-
"render-tests/fill-extrusion-pattern/function": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
52-
"render-tests/fill-extrusion-pattern/function-2": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
53-
"render-tests/fill-extrusion-pattern/literal": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
54-
"render-tests/fill-extrusion-pattern/opacity": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
55-
"render-tests/fill-extrusion-pattern/feature-expression": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
56-
"render-tests/fill-extrusion-pattern/tile-buffer": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
50+
"render-tests/fill-extrusion-pattern/tile-buffer": "https://github.com/mapbox/mapbox-gl-js/issues/4403",
5751
"render-tests/fill-pattern/literal": "FLAKY: do not re-enable without extensive testing - https://github.com/mapbox/mapbox-gl-native/issues/14423",
5852
"render-tests/fill-pattern/opacity": "FLAKY: do not re-enable without extensive testing - https://github.com/mapbox/mapbox-gl-native/issues/14870",
5953
"render-tests/fill-pattern/update-feature-state": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue",

src/mbgl/tile/geometry_tile_data.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ static GeometryCollection toGeometryCollection(MultiPolygon<int16_t>&& multipoly
3636
return result;
3737
}
3838

39+
// Attempts to restore original point order in rings:
40+
// see https://github.com/mapbox/mapbox-gl-native/issues/15268.
41+
static GeometryCollection restorePointOrder(GeometryCollection&& rings, const GeometryCollection& originalRings) {
42+
if (rings.size() != originalRings.size()) {
43+
// No sense restoring starting point if polygons are changed.
44+
return std::move(rings);
45+
}
46+
47+
int i = 0;
48+
for (auto& ring : rings) {
49+
const auto originalRing = originalRings[i++];
50+
auto item = find(ring.begin(), ring.end() - 1, originalRing[0]);
51+
if (item != ring.end()) {
52+
rotate(ring.begin(), item, ring.end() - 1);
53+
// Close the ring.
54+
ring.back() = ring.front();
55+
}
56+
}
57+
return std::move(rings);
58+
}
59+
3960
GeometryCollection fixupPolygons(const GeometryCollection& rings) {
4061
using namespace mapbox::geometry::wagyu;
4162

@@ -48,7 +69,7 @@ GeometryCollection fixupPolygons(const GeometryCollection& rings) {
4869
MultiPolygon<int16_t> multipolygon;
4970
clipper.execute(clip_type_union, multipolygon, fill_type_even_odd, fill_type_even_odd);
5071

51-
return toGeometryCollection(std::move(multipolygon));
72+
return restorePointOrder(toGeometryCollection(std::move(multipolygon)), rings);
5273
}
5374

5475
std::vector<GeometryCollection> classifyRings(const GeometryCollection& rings) {

0 commit comments

Comments
 (0)