summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-02-18 17:09:26 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-03-01 20:58:54 +0000
commitf3fc87261c2f2db71ac9d63b680417836885da13 (patch)
treeac96b0dda727b5a262b664c121ae5579f9c0d645 /src
parent411a562061f404fa7174222f38a1a9a13a396fd9 (diff)
downloadqtlocation-mapboxgl-f3fc87261c2f2db71ac9d63b680417836885da13.tar.gz
[core] Coordinate is now GeometryCoordinate
Also introduced GeometryCoordinates (vector of GeometryCoordinate items), to better cope with GeometryCollection.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/point_annotation_impl.cpp2
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp2
-rw-r--r--src/mbgl/renderer/line_bucket.cpp20
-rw-r--r--src/mbgl/renderer/line_bucket.hpp6
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp4
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp6
-rw-r--r--src/mbgl/text/check_max_angle.cpp9
-rw-r--r--src/mbgl/text/check_max_angle.hpp7
-rw-r--r--src/mbgl/text/collision_feature.cpp12
-rw-r--r--src/mbgl/text/collision_feature.hpp10
-rw-r--r--src/mbgl/text/get_anchors.cpp8
-rw-r--r--src/mbgl/text/get_anchors.hpp3
-rw-r--r--src/mbgl/text/quads.cpp11
-rw-r--r--src/mbgl/text/quads.hpp5
-rw-r--r--src/mbgl/tile/geojson_tile.cpp2
-rw-r--r--src/mbgl/tile/geometry_tile.hpp5
-rw-r--r--src/mbgl/tile/vector_tile.cpp2
-rw-r--r--src/mbgl/util/clip_lines.cpp8
-rw-r--r--src/mbgl/util/clip_lines.hpp2
-rw-r--r--src/mbgl/util/merge_lines.cpp10
-rw-r--r--src/mbgl/util/merge_lines.hpp4
21 files changed, 75 insertions, 63 deletions
diff --git a/src/mbgl/annotation/point_annotation_impl.cpp b/src/mbgl/annotation/point_annotation_impl.cpp
index 8e1aab2edf..2eef68a8eb 100644
--- a/src/mbgl/annotation/point_annotation_impl.cpp
+++ b/src/mbgl/annotation/point_annotation_impl.cpp
@@ -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,
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index 418d3adaed..c8b31ef11f 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -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);
diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp
index ba50e6b1f0..316085c0bb 100644
--- a/src/mbgl/renderer/line_bucket.cpp
+++ b/src/mbgl/renderer/line_bucket.cpp
@@ -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,
diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp
index dd0ce4ff29..f02293c873 100644
--- a/src/mbgl/renderer/line_bucket.hpp
+++ b/src/mbgl/renderer/line_bucket.hpp
@@ -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);
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index 67c1bf3150..252ebe4fd1 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -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;
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index cebb7e5dbe..0b1e4e5cf3 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -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);
diff --git a/src/mbgl/text/check_max_angle.cpp b/src/mbgl/text/check_max_angle.cpp
index bb32e4235e..4777f66a23 100644
--- a/src/mbgl/text/check_max_angle.cpp
+++ b/src/mbgl/text/check_max_angle.cpp
@@ -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;
diff --git a/src/mbgl/text/check_max_angle.hpp b/src/mbgl/text/check_max_angle.hpp
index 1354abe95e..0fb8a715a9 100644
--- a/src/mbgl/text/check_max_angle.hpp
+++ b/src/mbgl/text/check_max_angle.hpp
@@ -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
diff --git a/src/mbgl/text/collision_feature.cpp b/src/mbgl/text/collision_feature.cpp
index 186fb39b5d..42f1119b33 100644
--- a/src/mbgl/text/collision_feature.cpp
+++ b/src/mbgl/text/collision_feature.cpp
@@ -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;
diff --git a/src/mbgl/text/collision_feature.hpp b/src/mbgl/text/collision_feature.hpp
index a9d227de1b..fcfb8e9ae9 100644
--- a/src/mbgl/text/collision_feature.hpp
+++ b/src/mbgl/text/collision_feature.hpp
@@ -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
diff --git a/src/mbgl/text/get_anchors.cpp b/src/mbgl/text/get_anchors.cpp
index 7a129d692c..740ec288b3 100644
--- a/src/mbgl/text/get_anchors.cpp
+++ b/src/mbgl/text/get_anchors.cpp
@@ -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) {
diff --git a/src/mbgl/text/get_anchors.hpp b/src/mbgl/text/get_anchors.hpp
index fcb0578d5b..1f76685f9a 100644
--- a/src/mbgl/text/get_anchors.hpp
+++ b/src/mbgl/text/get_anchors.hpp
@@ -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);
diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp
index 1950f41fc7..2117538232 100644
--- a/src/mbgl/text/quads.cpp
+++ b/src/mbgl/text/quads.cpp
@@ -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;
diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp
index cdf7c23627..12b8893503 100644
--- a/src/mbgl/text/quads.hpp
+++ b/src/mbgl/text/quads.hpp
@@ -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
diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp
index d8eabf00a2..fceae19619 100644
--- a/src/mbgl/tile/geojson_tile.cpp
+++ b/src/mbgl/tile/geojson_tile.cpp
@@ -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 =
diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp
index 5cb2f96fdc..13333dab53 100644
--- a/src/mbgl/tile/geometry_tile.hpp
+++ b/src/mbgl/tile/geometry_tile.hpp
@@ -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:
diff --git a/src/mbgl/tile/vector_tile.cpp b/src/mbgl/tile/vector_tile.cpp
index 9e35debbff..8b58ade169 100644
--- a/src/mbgl/tile/vector_tile.cpp
+++ b/src/mbgl/tile/vector_tile.cpp
@@ -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) {
diff --git a/src/mbgl/util/clip_lines.cpp b/src/mbgl/util/clip_lines.cpp
index 071e9d09bd..41965876cb 100644
--- a/src/mbgl/util/clip_lines.cpp
+++ b/src/mbgl/util/clip_lines.cpp
@@ -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;
diff --git a/src/mbgl/util/clip_lines.hpp b/src/mbgl/util/clip_lines.hpp
index 6e49b48085..a4a5c5fb8a 100644
--- a/src/mbgl/util/clip_lines.hpp
+++ b/src/mbgl/util/clip_lines.hpp
@@ -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
diff --git a/src/mbgl/util/merge_lines.cpp b/src/mbgl/util/merge_lines.cpp
index 4ff1caaf76..ee930c113e 100644
--- a/src/mbgl/util/merge_lines.cpp
+++ b/src/mbgl/util/merge_lines.cpp
@@ -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;
diff --git a/src/mbgl/util/merge_lines.hpp b/src/mbgl/util/merge_lines.hpp
index 4460a0bcea..55ad79036e 100644
--- a/src/mbgl/util/merge_lines.hpp
+++ b/src/mbgl/util/merge_lines.hpp
@@ -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);