diff options
Diffstat (limited to 'include/mbgl')
-rw-r--r-- | include/mbgl/map/tile_parser.hpp | 5 | ||||
-rw-r--r-- | include/mbgl/style/style_bucket.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/text/collision.hpp | 31 |
3 files changed, 31 insertions, 6 deletions
diff --git a/include/mbgl/map/tile_parser.hpp b/include/mbgl/map/tile_parser.hpp index f011d47a38..fa64dad6d5 100644 --- a/include/mbgl/map/tile_parser.hpp +++ b/include/mbgl/map/tile_parser.hpp @@ -4,7 +4,6 @@ #include <mbgl/map/vector_tile.hpp> #include <mbgl/style/filter_expression.hpp> #include <mbgl/text/glyph.hpp> -#include <mbgl/text/collision.hpp> #include <cstdint> #include <iosfwd> @@ -28,6 +27,7 @@ class StyleBucketLine; class StyleBucketSymbol; class StyleLayerGroup; class VectorTileData; +class Collision; class TileParser { public: @@ -37,6 +37,7 @@ public: const std::shared_ptr<GlyphStore> &glyphStore, const std::shared_ptr<SpriteAtlas> &spriteAtlas, const std::shared_ptr<Sprite> &sprite); + ~TileParser(); public: void parse(); @@ -65,7 +66,7 @@ private: std::shared_ptr<Sprite> sprite; std::shared_ptr<Texturepool> texturePool; - Collision collision; + std::unique_ptr<Collision> collision; }; } diff --git a/include/mbgl/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp index 11b87d849d..58d4d705db 100644 --- a/include/mbgl/style/style_bucket.hpp +++ b/include/mbgl/style/style_bucket.hpp @@ -40,6 +40,7 @@ public: PlacementType placement = PlacementType::Point; float min_distance = 250.0f; + bool avoid_edges = false; struct { bool allow_overlap = false; diff --git a/include/mbgl/text/collision.hpp b/include/mbgl/text/collision.hpp index 87ebdb279e..e2e2414ba7 100644 --- a/include/mbgl/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -3,23 +3,46 @@ #include <mbgl/text/types.hpp> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#ifndef __clang__ +#pragma GCC diagnostic ignored "-Wunused-local-typedefs" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif +#include <boost/geometry.hpp> +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/box.hpp> +#include <boost/geometry/index/rtree.hpp> +#pragma GCC diagnostic pop + namespace mbgl { +namespace bg = boost::geometry; +namespace bgm = bg::model; +namespace bgi = bg::index; +typedef bgm::point<float, 2, bg::cs::cartesian> Point; +typedef bgm::box<Point> Box; +typedef std::pair<Box, PlacementBox> PlacementValue; +typedef bgi::rtree<PlacementValue, bgi::rstar<16>> Tree; + class Collision { public: Collision(float zoom, float tileExtent, float tileSize, float placementDepth = 1); - ~Collision(); - float getPlacementScale(const GlyphBoxes &glyphs, float minPlacementScale); + float getPlacementScale(const GlyphBoxes &glyphs, float minPlacementScale, bool avoidEdges); PlacementRange getPlacementRange(const GlyphBoxes &glyphs, float placementScale, bool horizontal); void insert(const GlyphBoxes &glyphs, const CollisionAnchor &anchor, float placementScale, const PlacementRange &placementRange, bool horizontal); private: - void *hTree; - void *cTree; + Tree hTree; + Tree cTree; + PlacementValue leftEdge; + PlacementValue topEdge; + PlacementValue rightEdge; + PlacementValue bottomEdge; public: const float tilePixelRatio; |