[core] Coordinate is now GeometryCoordinate
Also introduced GeometryCoordinates (vector of GeometryCoordinate items), to better cope with GeometryCollection.
This commit is contained in:
@@ -120,8 +120,6 @@ struct vec4 {
|
||||
};
|
||||
|
||||
|
||||
using Coordinate = vec2<int16_t>;
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,7 @@ void PointAnnotationImpl::updateLayer(const TileID& tileID, AnnotationTileLayer&
|
||||
const uint32_t z2 = 1 << tileID.z;
|
||||
const uint32_t x = pp.x * z2;
|
||||
const uint32_t y = pp.y * z2;
|
||||
const Coordinate coordinate(extent * (pp.x * z2 - x), extent * (pp.y * z2 - y));
|
||||
const GeometryCoordinate coordinate(extent * (pp.x * z2 - x), extent * (pp.y * z2 - y));
|
||||
|
||||
layer.features.emplace_back(
|
||||
std::make_shared<const AnnotationTileFeature>(FeatureType::Point,
|
||||
|
||||
@@ -133,7 +133,7 @@ void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile)
|
||||
|
||||
GeometryCollection renderGeometry;
|
||||
for (auto& shapeRing : shapeFeature.tileGeometry.get<geojsonvt::TileRings>()) {
|
||||
std::vector<Coordinate> renderLine;
|
||||
GeometryCoordinates renderLine;
|
||||
|
||||
for (auto& shapePoint : shapeRing) {
|
||||
renderLine.emplace_back(shapePoint.x, shapePoint.y);
|
||||
|
||||
@@ -41,7 +41,7 @@ void LineBucket::addGeometry(const GeometryCollection& geometryCollection) {
|
||||
const float COS_HALF_SHARP_CORNER = std::cos(75.0 / 2.0 * (M_PI / 180.0));
|
||||
const float SHARP_CORNER_OFFSET = 15.0f;
|
||||
|
||||
void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
void LineBucket::addGeometry(const GeometryCoordinates& vertices) {
|
||||
const GLsizei len = [&vertices] {
|
||||
GLsizei l = static_cast<GLsizei>(vertices.size());
|
||||
// If the line has duplicate vertices at the end, adjust length to remove them.
|
||||
@@ -60,8 +60,8 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
|
||||
const double sharpCornerOffset = SHARP_CORNER_OFFSET * (util::EXTENT / (512.0 * overscaling));
|
||||
|
||||
const Coordinate firstVertex = vertices.front();
|
||||
const Coordinate lastVertex = vertices[len - 1];
|
||||
const GeometryCoordinate firstVertex = vertices.front();
|
||||
const GeometryCoordinate lastVertex = vertices[len - 1];
|
||||
const bool closed = firstVertex == lastVertex;
|
||||
|
||||
if (len == 2 && closed) {
|
||||
@@ -75,8 +75,8 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
int8_t flip = 1;
|
||||
double distance = 0;
|
||||
bool startOfLine = true;
|
||||
Coordinate currentVertex = Coordinate::null(), prevVertex = Coordinate::null(),
|
||||
nextVertex = Coordinate::null();
|
||||
GeometryCoordinate currentVertex = GeometryCoordinate::null(), prevVertex = GeometryCoordinate::null(),
|
||||
nextVertex = GeometryCoordinate::null();
|
||||
vec2<double> prevNormal = vec2<double>::null(), nextNormal = vec2<double>::null();
|
||||
|
||||
// the last three vertices added
|
||||
@@ -99,7 +99,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
nextVertex = vertices[i + 1];
|
||||
} else {
|
||||
// there is no next vertex
|
||||
nextVertex = Coordinate::null();
|
||||
nextVertex = GeometryCoordinate::null();
|
||||
}
|
||||
|
||||
// if two consecutive vertices exist, skip the current one
|
||||
@@ -153,7 +153,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
if (isSharpCorner && i > 0) {
|
||||
const double prevSegmentLength = util::dist<double>(currentVertex, prevVertex);
|
||||
if (prevSegmentLength > 2.0 * sharpCornerOffset) {
|
||||
Coordinate newPrevVertex = currentVertex - (util::round(vec2<double>(currentVertex - prevVertex) * (sharpCornerOffset / prevSegmentLength)));
|
||||
GeometryCoordinate newPrevVertex = currentVertex - (util::round(vec2<double>(currentVertex - prevVertex) * (sharpCornerOffset / prevSegmentLength)));
|
||||
distance += util::dist<double>(newPrevVertex, prevVertex);
|
||||
addCurrentVertex(newPrevVertex, flip, distance, prevNormal, 0, 0, false, startVertex, triangleStore);
|
||||
prevVertex = newPrevVertex;
|
||||
@@ -328,7 +328,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
if (isSharpCorner && i < len - 1) {
|
||||
const double nextSegmentLength = util::dist<double>(currentVertex, nextVertex);
|
||||
if (nextSegmentLength > 2 * sharpCornerOffset) {
|
||||
Coordinate newCurrentVertex = currentVertex + util::round(vec2<double>(nextVertex - currentVertex) * (sharpCornerOffset / nextSegmentLength));
|
||||
GeometryCoordinate newCurrentVertex = currentVertex + util::round(vec2<double>(nextVertex - currentVertex) * (sharpCornerOffset / nextSegmentLength));
|
||||
distance += util::dist<double>(newCurrentVertex, currentVertex);
|
||||
addCurrentVertex(newCurrentVertex, flip, distance, nextNormal, 0, 0, false, startVertex, triangleStore);
|
||||
currentVertex = newCurrentVertex;
|
||||
@@ -361,7 +361,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
}
|
||||
}
|
||||
|
||||
void LineBucket::addCurrentVertex(const Coordinate& currentVertex,
|
||||
void LineBucket::addCurrentVertex(const GeometryCoordinate& currentVertex,
|
||||
float flip,
|
||||
double distance,
|
||||
const vec2<double>& normal,
|
||||
@@ -395,7 +395,7 @@ void LineBucket::addCurrentVertex(const Coordinate& currentVertex,
|
||||
e2 = e3;
|
||||
}
|
||||
|
||||
void LineBucket::addPieSliceVertex(const Coordinate& currentVertex,
|
||||
void LineBucket::addPieSliceVertex(const GeometryCoordinate& currentVertex,
|
||||
float flip,
|
||||
double distance,
|
||||
const vec2<double>& extrude,
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
bool hasData() const override;
|
||||
|
||||
void addGeometry(const GeometryCollection&);
|
||||
void addGeometry(const std::vector<Coordinate>& line);
|
||||
void addGeometry(const GeometryCoordinates& line);
|
||||
|
||||
void drawLines(LineShader&, gl::GLObjectStore&);
|
||||
void drawLineSDF(LineSDFShader&, gl::GLObjectStore&);
|
||||
@@ -43,10 +43,10 @@ private:
|
||||
TriangleElement(uint16_t a_, uint16_t b_, uint16_t c_) : a(a_), b(b_), c(c_) {}
|
||||
uint16_t a, b, c;
|
||||
};
|
||||
void addCurrentVertex(const Coordinate& currentVertex, float flip, double distance,
|
||||
void addCurrentVertex(const GeometryCoordinate& currentVertex, float flip, double distance,
|
||||
const vec2<double>& normal, float endLeft, float endRight, bool round,
|
||||
GLint startVertex, std::vector<LineBucket::TriangleElement>& triangleStore);
|
||||
void addPieSliceVertex(const Coordinate& currentVertex, float flip, double distance,
|
||||
void addPieSliceVertex(const GeometryCoordinate& currentVertex, float flip, double distance,
|
||||
const vec2<double>& extrude, bool lineTurnsLeft, GLint startVertex,
|
||||
std::vector<TriangleElement>& triangleStore);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
SymbolInstance::SymbolInstance(Anchor& anchor, const std::vector<Coordinate>& line,
|
||||
SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line,
|
||||
const Shaping& shapedText, const PositionedIcon& shapedIcon,
|
||||
const SymbolLayoutProperties& layout, const bool addToBuffers, const uint32_t index_,
|
||||
const float textBoxScale, const float textPadding, const float textAlongLine,
|
||||
@@ -271,7 +271,7 @@ void SymbolBucket::addFeatures(uintptr_t tileUID,
|
||||
}
|
||||
|
||||
|
||||
void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
|
||||
void SymbolBucket::addFeature(const GeometryCollection &lines,
|
||||
const Shaping &shapedText, const PositionedIcon &shapedIcon, const GlyphPositions &face) {
|
||||
|
||||
const float minScale = 0.5f;
|
||||
|
||||
@@ -35,7 +35,7 @@ class GlyphStore;
|
||||
|
||||
class SymbolFeature {
|
||||
public:
|
||||
std::vector<std::vector<Coordinate>> geometry;
|
||||
GeometryCollection geometry;
|
||||
std::u32string label;
|
||||
std::string sprite;
|
||||
};
|
||||
@@ -44,7 +44,7 @@ struct Anchor;
|
||||
|
||||
class SymbolInstance {
|
||||
public:
|
||||
explicit SymbolInstance(Anchor& anchor, const std::vector<Coordinate>& line,
|
||||
explicit SymbolInstance(Anchor& anchor, const GeometryCoordinates& line,
|
||||
const Shaping& shapedText, const PositionedIcon& shapedIcon,
|
||||
const SymbolLayoutProperties& layout, const bool inside, const uint32_t index,
|
||||
const float textBoxScale, const float textPadding, const float textAlongLine,
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
void placeFeatures(CollisionTile&) override;
|
||||
|
||||
private:
|
||||
void addFeature(const std::vector<std::vector<Coordinate>> &lines,
|
||||
void addFeature(const GeometryCollection &lines,
|
||||
const Shaping &shapedText, const PositionedIcon &shapedIcon,
|
||||
const GlyphPositions &face);
|
||||
bool anchorIsTooClose(const std::u32string &text, const float repeatDistance, Anchor &anchor);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <mbgl/text/check_max_angle.hpp>
|
||||
#include <mbgl/geometry/anchor.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
|
||||
#include <queue>
|
||||
|
||||
namespace mbgl{
|
||||
@@ -10,14 +13,14 @@ struct Corner {
|
||||
float angleDelta;
|
||||
};
|
||||
|
||||
bool checkMaxAngle(const std::vector<Coordinate> &line, Anchor &anchor, const float labelLength,
|
||||
bool checkMaxAngle(const GeometryCoordinates &line, Anchor &anchor, const float labelLength,
|
||||
const float windowSize, const float maxAngle) {
|
||||
|
||||
// horizontal labels always pass
|
||||
if (anchor.segment < 0) return true;
|
||||
|
||||
Coordinate anchorPoint = Coordinate{ (int16_t)anchor.x, (int16_t)anchor.y };
|
||||
Coordinate &p = anchorPoint;
|
||||
GeometryCoordinate anchorPoint = { (int16_t)anchor.x, (int16_t)anchor.y };
|
||||
GeometryCoordinate &p = anchorPoint;
|
||||
int index = anchor.segment + 1;
|
||||
float anchorDistance = 0;
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#ifndef MBGL_TEXT_CHECK_MAX_ANGLE
|
||||
#define MBGL_TEXT_CHECK_MAX_ANGLE
|
||||
|
||||
#include <mbgl/geometry/anchor.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
bool checkMaxAngle(const std::vector<Coordinate> &line, Anchor &anchor, const float labelLength,
|
||||
struct Anchor;
|
||||
|
||||
bool checkMaxAngle(const GeometryCoordinates &line, Anchor &anchor, const float labelLength,
|
||||
const float windowSize, const float maxAngle);
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
CollisionFeature::CollisionFeature(const std::vector<Coordinate> &line, const Anchor &anchor,
|
||||
CollisionFeature::CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor,
|
||||
const float top, const float bottom, const float left, const float right,
|
||||
const float boxScale, const float padding, const bool alongLine, const bool straight) {
|
||||
|
||||
@@ -22,12 +22,12 @@ CollisionFeature::CollisionFeature(const std::vector<Coordinate> &line, const An
|
||||
|
||||
height = std::max(10.0f * boxScale, height);
|
||||
|
||||
Coordinate anchorPoint(int16_t(anchor.x), int16_t(anchor.y));
|
||||
GeometryCoordinate anchorPoint(int16_t(anchor.x), int16_t(anchor.y));
|
||||
|
||||
if (straight) {
|
||||
// used for icon labels that are aligned with the line, but don't curve along it
|
||||
const vec2<double> vector = util::unit(vec2<double>(line[anchor.segment + 1] - line[anchor.segment])) * length;
|
||||
const std::vector<Coordinate> newLine({ anchorPoint - vector, anchorPoint + vector });
|
||||
const GeometryCoordinates newLine({ anchorPoint - vector, anchorPoint + vector });
|
||||
bboxifyLabel(newLine, anchorPoint, 0, length, height);
|
||||
} else {
|
||||
// used for text labels that curve along a line
|
||||
@@ -38,8 +38,8 @@ CollisionFeature::CollisionFeature(const std::vector<Coordinate> &line, const An
|
||||
}
|
||||
}
|
||||
|
||||
void CollisionFeature::bboxifyLabel(const std::vector<Coordinate> &line,
|
||||
Coordinate &anchorPoint, const int segment, const float labelLength, const float boxSize) {
|
||||
void CollisionFeature::bboxifyLabel(const GeometryCoordinates &line,
|
||||
GeometryCoordinate &anchorPoint, const int segment, const float labelLength, const float boxSize) {
|
||||
|
||||
const float step = boxSize / 2;
|
||||
const unsigned int nBoxes = std::floor(labelLength / step);
|
||||
@@ -48,7 +48,7 @@ void CollisionFeature::bboxifyLabel(const std::vector<Coordinate> &line,
|
||||
// box is at the edge of the label.
|
||||
const float firstBoxOffset = -boxSize / 2;
|
||||
|
||||
Coordinate &p = anchorPoint;
|
||||
GeometryCoordinate &p = anchorPoint;
|
||||
int index = segment + 1;
|
||||
float anchorDistance = firstBoxOffset;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <mbgl/util/vec.hpp>
|
||||
#include <mbgl/geometry/anchor.hpp>
|
||||
#include <mbgl/text/shaping.hpp>
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -32,7 +34,7 @@ namespace mbgl {
|
||||
class CollisionFeature {
|
||||
public:
|
||||
// for text
|
||||
inline explicit CollisionFeature(const std::vector<Coordinate> &line, const Anchor &anchor,
|
||||
inline explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor,
|
||||
const Shaping &shapedText,
|
||||
const float boxScale, const float padding, const bool alongLine)
|
||||
: CollisionFeature(line, anchor,
|
||||
@@ -40,14 +42,14 @@ namespace mbgl {
|
||||
boxScale, padding, alongLine, false) {}
|
||||
|
||||
// for icons
|
||||
inline explicit CollisionFeature(const std::vector<Coordinate> &line, const Anchor &anchor,
|
||||
inline explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor,
|
||||
const PositionedIcon &shapedIcon,
|
||||
const float boxScale, const float padding, const bool alongLine)
|
||||
: CollisionFeature(line, anchor,
|
||||
shapedIcon.top, shapedIcon.bottom, shapedIcon.left, shapedIcon.right,
|
||||
boxScale, padding, alongLine, true) {}
|
||||
|
||||
explicit CollisionFeature(const std::vector<Coordinate> &line, const Anchor &anchor,
|
||||
explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor,
|
||||
const float top, const float bottom, const float left, const float right,
|
||||
const float boxScale, const float padding, const bool alongLine, const bool straight);
|
||||
|
||||
@@ -55,7 +57,7 @@ namespace mbgl {
|
||||
std::vector<CollisionBox> boxes;
|
||||
|
||||
private:
|
||||
void bboxifyLabel(const std::vector<Coordinate> &line, Coordinate &anchorPoint, const int segment, const float length, const float height);
|
||||
void bboxifyLabel(const GeometryCoordinates &line, GeometryCoordinate &anchorPoint, const int segment, const float length, const float height);
|
||||
};
|
||||
} // namespace mbgl
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
Anchors resample(const std::vector<Coordinate> &line, const float offset, const float spacing,
|
||||
Anchors resample(const GeometryCoordinates &line, const float offset, const float spacing,
|
||||
const float angleWindowSize, const float maxAngle, const float labelLength, const bool continuedLine, const bool placeAtMiddle) {
|
||||
|
||||
const float halfLabelLength = labelLength / 2.0f;
|
||||
@@ -23,8 +23,8 @@ Anchors resample(const std::vector<Coordinate> &line, const float offset, const
|
||||
|
||||
int i = 0;
|
||||
for (auto it = line.begin(), end = line.end() - 1; it != end; it++, i++) {
|
||||
const Coordinate &a = *(it);
|
||||
const Coordinate &b = *(it + 1);
|
||||
const GeometryCoordinate &a = *(it);
|
||||
const GeometryCoordinate &b = *(it + 1);
|
||||
|
||||
const float segmentDist = util::dist<float>(a, b);
|
||||
const float angle = util::angle_to(b, a);
|
||||
@@ -65,7 +65,7 @@ Anchors resample(const std::vector<Coordinate> &line, const float offset, const
|
||||
return anchors;
|
||||
}
|
||||
|
||||
Anchors getAnchors(const std::vector<Coordinate> &line, float spacing,
|
||||
Anchors getAnchors(const GeometryCoordinates &line, float spacing,
|
||||
const float maxAngle, const float textLeft, const float textRight,
|
||||
const float iconLeft, const float iconRight,
|
||||
const float glyphSize, const float boxScale, const float overscaling) {
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
#define MBGL_TEXT_GETANCHORS
|
||||
|
||||
#include <mbgl/geometry/anchor.hpp>
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
Anchors getAnchors(const std::vector<Coordinate> &line, float spacing,
|
||||
Anchors getAnchors(const GeometryCoordinates &line, float spacing,
|
||||
const float maxAngle, const float textLeft, const float textRight,
|
||||
const float iconLeft, const float iconRight,
|
||||
const float glyphSize, const float boxScale, const float overscaling);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/text/quads.hpp>
|
||||
#include <mbgl/text/shaping.hpp>
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
#include <mbgl/geometry/anchor.hpp>
|
||||
#include <mbgl/layer/symbol_layer.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
@@ -11,7 +12,7 @@ namespace mbgl {
|
||||
const float globalMinScale = 0.5f; // underscale by 1 zoom level
|
||||
|
||||
SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon,
|
||||
const std::vector<Coordinate>& line, const SymbolLayoutProperties& layout,
|
||||
const GeometryCoordinates& line, const SymbolLayoutProperties& layout,
|
||||
const bool alongLine) {
|
||||
|
||||
auto image = *(shapedIcon.image);
|
||||
@@ -30,10 +31,10 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon,
|
||||
float angle = layout.icon.rotate * util::DEG2RAD;
|
||||
if (alongLine) {
|
||||
assert(static_cast<unsigned int>(anchor.segment) < line.size());
|
||||
const Coordinate &prev= line[anchor.segment];
|
||||
const GeometryCoordinate &prev= line[anchor.segment];
|
||||
if (anchor.y == prev.y && anchor.x == prev.x &&
|
||||
static_cast<unsigned int>(anchor.segment + 1) < line.size()) {
|
||||
const Coordinate &next= line[anchor.segment + 1];
|
||||
const GeometryCoordinate &next= line[anchor.segment + 1];
|
||||
angle += std::atan2(anchor.y - next.y, anchor.x - next.x) + M_PI;
|
||||
} else {
|
||||
angle += std::atan2(anchor.y - prev.y, anchor.x - prev.x);
|
||||
@@ -74,7 +75,7 @@ struct GlyphInstance {
|
||||
typedef std::vector<GlyphInstance> GlyphInstances;
|
||||
|
||||
void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> glyphs, Anchor &anchor,
|
||||
float offset, const std::vector<Coordinate> &line, int segment, bool forward) {
|
||||
float offset, const GeometryCoordinates &line, int segment, bool forward) {
|
||||
|
||||
const bool upsideDown = !forward;
|
||||
|
||||
@@ -132,7 +133,7 @@ void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> glyphs, Anchor &
|
||||
}
|
||||
|
||||
SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText,
|
||||
const float boxScale, const std::vector<Coordinate>& line, const SymbolLayoutProperties& layout,
|
||||
const float boxScale, const GeometryCoordinates& line, const SymbolLayoutProperties& layout,
|
||||
const bool alongLine, const GlyphPositions& face) {
|
||||
|
||||
const float textRotate = layout.text.rotate * util::DEG2RAD;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define MBGL_TEXT_QUADS
|
||||
|
||||
#include <mbgl/text/glyph.hpp>
|
||||
#include <mbgl/tile/geometry_tile.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
|
||||
#include <vector>
|
||||
@@ -37,11 +38,11 @@ namespace mbgl {
|
||||
class PositionedIcon;
|
||||
|
||||
SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon,
|
||||
const std::vector<Coordinate>& line, const SymbolLayoutProperties& layout,
|
||||
const GeometryCoordinates& line, const SymbolLayoutProperties& layout,
|
||||
const bool alongLine);
|
||||
|
||||
SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText,
|
||||
const float boxScale, const std::vector<Coordinate>& line, const SymbolLayoutProperties& layout,
|
||||
const float boxScale, const GeometryCoordinates& line, const SymbolLayoutProperties& layout,
|
||||
const bool alongLine, const GlyphPositions& face);
|
||||
} // namespace mbgl
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ std::unique_ptr<GeoJSONTile> convertTile(const mapbox::geojsonvt::Tile& tile) {
|
||||
|
||||
if (tile) {
|
||||
std::vector<std::shared_ptr<const GeoJSONTileFeature>> features;
|
||||
std::vector<Coordinate> line;
|
||||
GeometryCoordinates line;
|
||||
|
||||
for (auto& feature : tile.features) {
|
||||
const FeatureType featureType =
|
||||
|
||||
@@ -24,7 +24,10 @@ enum class FeatureType : uint8_t {
|
||||
Polygon = 3
|
||||
};
|
||||
|
||||
typedef std::vector<std::vector<Coordinate>> GeometryCollection;
|
||||
// Normalized vector tile coordinates.
|
||||
using GeometryCoordinate = vec2<int16_t>;
|
||||
using GeometryCoordinates = std::vector<GeometryCoordinate>;
|
||||
using GeometryCollection = std::vector<GeometryCoordinates>;
|
||||
|
||||
class GeometryTileFeature : private util::noncopyable {
|
||||
public:
|
||||
|
||||
@@ -94,7 +94,7 @@ GeometryCollection VectorTileFeature::getGeometries() const {
|
||||
GeometryCollection lines;
|
||||
|
||||
lines.emplace_back();
|
||||
std::vector<Coordinate>* line = &lines.back();
|
||||
GeometryCoordinates* line = &lines.back();
|
||||
|
||||
while (data.data < data.end) {
|
||||
if (length == 0) {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
std::vector<std::vector<Coordinate>> clipLines(const std::vector<std::vector<Coordinate>> &lines,
|
||||
GeometryCollection clipLines(const GeometryCollection &lines,
|
||||
const int16_t x1, const int16_t y1, const int16_t x2, const int16_t y2) {
|
||||
|
||||
std::vector<std::vector<Coordinate>> clippedLines;
|
||||
GeometryCollection clippedLines;
|
||||
|
||||
for (auto& line : lines) {
|
||||
|
||||
@@ -15,8 +15,8 @@ std::vector<std::vector<Coordinate>> clipLines(const std::vector<std::vector<Coo
|
||||
|
||||
auto end = line.end() - 1;
|
||||
for (auto it = line.begin(); it != end; it++) {
|
||||
Coordinate p0 = *(it);
|
||||
Coordinate p1 = *(it + 1);
|
||||
GeometryCoordinate p0 = *(it);
|
||||
GeometryCoordinate p1 = *(it + 1);
|
||||
|
||||
if (p0.x < x1 && p1.x < x1) {
|
||||
continue;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
|
||||
std::vector<std::vector<Coordinate>> clipLines(const std::vector<std::vector<Coordinate>> &lines,
|
||||
GeometryCollection clipLines(const GeometryCollection &lines,
|
||||
const int16_t x1, const int16_t y1, const int16_t x2, const int16_t y2);
|
||||
|
||||
} // end namespace util
|
||||
|
||||
@@ -11,7 +11,7 @@ unsigned int mergeFromRight(std::vector<SymbolFeature> &features,
|
||||
Index &rightIndex,
|
||||
Index::iterator left,
|
||||
size_t rightKey,
|
||||
std::vector<std::vector<Coordinate>> &geom) {
|
||||
GeometryCollection &geom) {
|
||||
|
||||
unsigned int index = left->second;
|
||||
rightIndex.erase(left);
|
||||
@@ -27,7 +27,7 @@ unsigned int mergeFromLeft(std::vector<SymbolFeature> &features,
|
||||
Index &leftIndex,
|
||||
size_t leftKey,
|
||||
Index::iterator right,
|
||||
std::vector<std::vector<Coordinate>> &geom) {
|
||||
GeometryCollection &geom) {
|
||||
|
||||
unsigned int index = right->second;
|
||||
leftIndex.erase(right);
|
||||
@@ -41,8 +41,8 @@ unsigned int mergeFromLeft(std::vector<SymbolFeature> &features,
|
||||
}
|
||||
|
||||
size_t
|
||||
getKey(const std::u32string& text, const std::vector<std::vector<Coordinate>>& geom, bool onRight) {
|
||||
const Coordinate& coord = onRight ? geom[0].back() : geom[0].front();
|
||||
getKey(const std::u32string& text, const GeometryCollection& geom, bool onRight) {
|
||||
const GeometryCoordinate& coord = onRight ? geom[0].back() : geom[0].front();
|
||||
|
||||
auto hash = std::hash<std::u32string>()(text);
|
||||
boost::hash_combine(hash, coord.x);
|
||||
@@ -57,7 +57,7 @@ void mergeLines(std::vector<SymbolFeature> &features) {
|
||||
|
||||
for (unsigned int k = 0; k < features.size(); k++) {
|
||||
SymbolFeature &feature = features[k];
|
||||
std::vector<std::vector<Coordinate>> &geometry = feature.geometry;
|
||||
GeometryCollection &geometry = feature.geometry;
|
||||
|
||||
if (!feature.label.length()) {
|
||||
continue;
|
||||
|
||||
@@ -13,13 +13,13 @@ unsigned int mergeFromRight(std::vector<SymbolFeature> &features,
|
||||
std::map<std::string, unsigned int> &rightIndex,
|
||||
std::map<std::string, unsigned int>::iterator left,
|
||||
std::string &rightKey,
|
||||
std::vector<std::vector<Coordinate>> &geom);
|
||||
GeometryCollection &geom);
|
||||
|
||||
unsigned int mergeFromLeft(std::vector<SymbolFeature> &features,
|
||||
std::map<std::string, unsigned int> &leftIndex,
|
||||
std::string &leftKey,
|
||||
std::map<std::string, unsigned int>::iterator right,
|
||||
std::vector<std::vector<Coordinate>> &geom);
|
||||
GeometryCollection &geom);
|
||||
|
||||
void mergeLines(std::vector<SymbolFeature> &features);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user