Merge pull request #419 from mapbox/crosstile

allow crosstile labels and add `symbol-avoid-edges`
This commit is contained in:
Konstantin Käfer
2014-08-15 15:50:36 +02:00
8 changed files with 127 additions and 88 deletions

View File

@@ -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;
};
}

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,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;