summaryrefslogtreecommitdiff
path: root/src/mbgl/layout/symbol_layout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/layout/symbol_layout.cpp')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 7be2c13ada..387bb7fb00 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -20,6 +20,8 @@
#include <mbgl/util/platform.hpp>
#include <mbgl/util/logging.hpp>
+#include <mapbox/polylabel.hpp>
+
namespace mbgl {
using namespace style;
@@ -301,12 +303,20 @@ void SymbolLayout::addFeature(const SymbolFeature& feature,
}
}
} else if (feature.type == FeatureType::Polygon) {
- // TODO: pole of inaccessibility
- for (const auto& ring : feature.geometry) {
- for (const auto& point : ring) {
- Anchor anchor(point.x, point.y, 0, minScale);
- addSymbolInstance(ring, anchor);
+ for (const auto& polygon : classifyRings(feature.geometry)) {
+ Polygon<double> poly;
+ for (const auto& ring : polygon) {
+ LinearRing<double> r;
+ for (const auto& p : ring) {
+ r.push_back(convertPoint<double>(p));
+ }
+ poly.push_back(r);
}
+
+ // 16 here represents 2 pixels
+ auto poi = mapbox::polylabel(poly, 16.0);
+ Anchor anchor(poi.x, poi.y, 0, minScale);
+ addSymbolInstance(polygon[0], anchor);
}
} else if (feature.type == FeatureType::LineString) {
for (const auto& line : feature.geometry) {