#pragma once #include #include #include #include #include #include #include namespace mln { class AnnotationTileData; class CanonicalTileID; class ShapeAnnotationImpl { public: ShapeAnnotationImpl(AnnotationID); virtual ~ShapeAnnotationImpl() = default; virtual void updateStyle(style::Style::Impl &) const = 0; virtual const ShapeAnnotationGeometry &geometry() const = 0; void updateTileData(const CanonicalTileID &, AnnotationTileData &); const AnnotationID id; const std::string layerID; std::unique_ptr shapeTiler; }; struct CloseShapeAnnotation { ShapeAnnotationGeometry operator()(const mln::LineString &geom) const { return geom; } ShapeAnnotationGeometry operator()(const mln::MultiLineString &geom) const { return geom; } ShapeAnnotationGeometry operator()(const mln::Polygon &geom) const { mln::Polygon closed = geom; for (auto &ring : closed) { if (!ring.empty() && ring.front() != ring.back()) { ring.emplace_back(ring.front()); } } return closed; } ShapeAnnotationGeometry operator()(const mln::MultiPolygon &geom) const { mln::MultiPolygon closed = geom; for (auto &polygon : closed) { for (auto &ring : polygon) { if (!ring.empty() && ring.front() != ring.back()) { ring.emplace_back(ring.front()); } } } return closed; } }; } // namespace mln