summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-08-06 13:32:16 +0300
committerAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-08-06 13:32:16 +0300
commit131ce55ade6765e883d45a5ee2ba7d65d9aaeee0 (patch)
treeb8010d1bad5e4b9a089a9b8d4a8d9ab3160f3b51
parentacfcd5c29c15e91e3bf80b1503d63caef1487149 (diff)
downloadqtlocation-mapboxgl-131ce55ade6765e883d45a5ee2ba7d65d9aaeee0.tar.gz
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: https://github.com/mapbox/mapbox-gl-native/issues/15268
-rw-r--r--platform/node/test/ignores.json8
-rw-r--r--src/mbgl/tile/geometry_tile_data.cpp23
2 files changed, 23 insertions, 8 deletions
diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json
index 5814114a15..b23978cac4 100644
--- a/platform/node/test/ignores.json
+++ b/platform/node/test/ignores.json
@@ -47,13 +47,7 @@
"render-tests/debug/tile": "https://github.com/mapbox/mapbox-gl-native/issues/3841",
"render-tests/debug/tile-overscaled": "https://github.com/mapbox/mapbox-gl-native/issues/3841",
"render-tests/extent/1024-circle": "needs investigation",
- "render-tests/fill-extrusion-pattern/@2x": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
- "render-tests/fill-extrusion-pattern/function": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
- "render-tests/fill-extrusion-pattern/function-2": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
- "render-tests/fill-extrusion-pattern/literal": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
- "render-tests/fill-extrusion-pattern/opacity": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
- "render-tests/fill-extrusion-pattern/feature-expression": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
- "render-tests/fill-extrusion-pattern/tile-buffer": "https://github.com/mapbox/mapbox-gl-js/issues/3327",
+ "render-tests/fill-extrusion-pattern/tile-buffer": "https://github.com/mapbox/mapbox-gl-js/issues/4403",
"render-tests/fill-pattern/literal": "FLAKY: do not re-enable without extensive testing - https://github.com/mapbox/mapbox-gl-native/issues/14423",
"render-tests/fill-pattern/opacity": "FLAKY: do not re-enable without extensive testing - https://github.com/mapbox/mapbox-gl-native/issues/14870",
"render-tests/fill-pattern/update-feature-state": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue",
diff --git a/src/mbgl/tile/geometry_tile_data.cpp b/src/mbgl/tile/geometry_tile_data.cpp
index 5320df6893..7f4c3dbeb0 100644
--- a/src/mbgl/tile/geometry_tile_data.cpp
+++ b/src/mbgl/tile/geometry_tile_data.cpp
@@ -36,6 +36,27 @@ static GeometryCollection toGeometryCollection(MultiPolygon<int16_t>&& multipoly
return result;
}
+// Attempts to restore original point order in rings:
+// see https://github.com/mapbox/mapbox-gl-native/issues/15268.
+static GeometryCollection restorePointOrder(GeometryCollection&& rings, const GeometryCollection& originalRings) {
+ if (rings.size() != originalRings.size()) {
+ // No sense restoring starting point if polygons are changed.
+ return std::move(rings);
+ }
+
+ int i = 0;
+ for (auto& ring : rings) {
+ const auto originalRing = originalRings[i++];
+ auto item = find(ring.begin(), ring.end() - 1, originalRing[0]);
+ if (item != ring.end()) {
+ rotate(ring.begin(), item, ring.end() - 1);
+ // Close the ring.
+ ring.back() = ring.front();
+ }
+ }
+ return std::move(rings);
+}
+
GeometryCollection fixupPolygons(const GeometryCollection& rings) {
using namespace mapbox::geometry::wagyu;
@@ -48,7 +69,7 @@ GeometryCollection fixupPolygons(const GeometryCollection& rings) {
MultiPolygon<int16_t> multipolygon;
clipper.execute(clip_type_union, multipolygon, fill_type_even_odd, fill_type_even_odd);
- return toGeometryCollection(std::move(multipolygon));
+ return restorePointOrder(toGeometryCollection(std::move(multipolygon)), rings);
}
std::vector<GeometryCollection> classifyRings(const GeometryCollection& rings) {