allow crosstile labels and add symbol-avoid-edges

This commit is contained in:
Ansis Brammanis
2014-08-13 15:43:25 -07:00
committed by Konstantin Käfer
parent 69f71e9431
commit 6c45972502
6 changed files with 105 additions and 66 deletions

View File

@@ -40,6 +40,7 @@ public:
PlacementType placement = PlacementType::Point;
float min_distance = 250.0f;
bool avoid_edges = false;
struct {
bool allow_overlap = false;

View File

@@ -3,15 +3,35 @@
#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,
@@ -20,6 +40,10 @@ public:
private:
void *hTree;
void *cTree;
PlacementValue leftEdge;
PlacementValue topEdge;
PlacementValue rightEdge;
PlacementValue bottomEdge;
public:
const float tilePixelRatio;