Remove VectorTileGlyph, VectorTileFace, IndexedFaces, Faces and glyph related parts of vector_tile.proto. Refs #274.
This commit is contained in:
@@ -70,9 +70,6 @@ VectorTile::VectorTile(pbf tile) {
|
||||
if (tile.tag == 3) { // layer
|
||||
VectorTileLayer layer(tile.message());
|
||||
layers.emplace(layer.name, std::forward<VectorTileLayer>(layer));
|
||||
} else if (tile.tag == 4) { // face
|
||||
VectorTileFace face(tile.message());
|
||||
faces.emplace(face.name, std::forward<VectorTileFace>(face));
|
||||
} else {
|
||||
tile.skip();
|
||||
}
|
||||
@@ -86,100 +83,8 @@ VectorTile& VectorTile::operator=(VectorTile && other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
VectorTileFace::VectorTileFace(pbf face) {
|
||||
while (face.next()) {
|
||||
if (face.tag == 1) { // family
|
||||
family = face.string();
|
||||
} else if (face.tag == 2) { // style
|
||||
style = face.string();
|
||||
} else if (face.tag == 5) { // glyphs
|
||||
glyphs.emplace_back(face.message());
|
||||
} else {
|
||||
face.skip();
|
||||
}
|
||||
}
|
||||
name = family + " " + style;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& llmr::operator<<(std::ostream& os, const VectorTileFace& face) {
|
||||
os << "Face: " << face.name << std::endl;
|
||||
for (const VectorTileGlyph& glyph : face.glyphs) {
|
||||
os << " - " << glyph;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// -1 overflows to maximum value
|
||||
VectorTileGlyph::VectorTileGlyph() {}
|
||||
|
||||
VectorTileGlyph::VectorTileGlyph(pbf glyph) {
|
||||
while (glyph.next()) {
|
||||
if (glyph.tag == 1) { // id
|
||||
id = glyph.varint();
|
||||
} else if (glyph.tag == 2) { // bitmap
|
||||
bitmap = glyph.string();
|
||||
} else if (glyph.tag == 3) { // width
|
||||
metrics.width = glyph.varint();
|
||||
} else if (glyph.tag == 4) { // height
|
||||
metrics.height = glyph.varint();
|
||||
} else if (glyph.tag == 5) { // left
|
||||
metrics.left = glyph.svarint();
|
||||
} else if (glyph.tag == 6) { // top
|
||||
metrics.top = glyph.svarint();
|
||||
} else if (glyph.tag == 7) { // advance
|
||||
metrics.advance = glyph.varint();
|
||||
} else {
|
||||
glyph.skip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& llmr::operator<<(std::ostream& os, const VectorTileGlyph& glyph) {
|
||||
os << "Glyph " << glyph.id << ": " << glyph.metrics.width << "x" << glyph.metrics.height <<
|
||||
" (" << glyph.metrics.left << "/" << glyph.metrics.top << ") +" << glyph.metrics.advance << std::endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
class VectorTileLabel {
|
||||
public:
|
||||
VectorTileLabel(pbf data);
|
||||
|
||||
uint32_t text = 0;
|
||||
uint32_t stack = 0;
|
||||
std::vector<GlyphPlacement> placements;
|
||||
};
|
||||
|
||||
VectorTileLabel::VectorTileLabel(pbf label) {
|
||||
pbf faces, glyphs, x, y;
|
||||
|
||||
while (label.next()) {
|
||||
if (label.tag == 1) { // text
|
||||
text = label.varint();
|
||||
} else if (label.tag == 2) { // stack
|
||||
stack = label.varint();
|
||||
} else if (label.tag == 3) { // faces
|
||||
faces = label.message();
|
||||
} else if (label.tag == 4) { // glyphs
|
||||
glyphs = label.message();
|
||||
} else if (label.tag == 5) { // x
|
||||
x = label.message();
|
||||
} else if (label.tag == 6) { // y
|
||||
y = label.message();
|
||||
} else {
|
||||
label.skip();
|
||||
}
|
||||
}
|
||||
|
||||
while (faces && glyphs && x && y) {
|
||||
placements.emplace_back(faces.varint(), glyphs.varint(), x.varint(), y.varint());
|
||||
}
|
||||
}
|
||||
|
||||
VectorTileLayer::VectorTileLayer(pbf layer) : data(layer) {
|
||||
std::vector<std::string> stacks;
|
||||
std::vector<VectorTileLabel> labels;
|
||||
|
||||
while (layer.next()) {
|
||||
if (layer.tag == 1) { // name
|
||||
@@ -190,34 +95,10 @@ VectorTileLayer::VectorTileLayer(pbf layer) : data(layer) {
|
||||
values.emplace_back(std::move(parseValue(layer.message())));
|
||||
} else if (layer.tag == 5) { // extent
|
||||
extent = layer.varint();
|
||||
} else if (layer.tag == 7) { // faces
|
||||
faces.emplace_back(layer.string());
|
||||
} else if (layer.tag == 8) { // labels
|
||||
labels.emplace_back(layer.message());
|
||||
} else if (layer.tag == 9) { // stacks
|
||||
stacks.emplace_back(layer.string());
|
||||
} else {
|
||||
layer.skip();
|
||||
}
|
||||
}
|
||||
|
||||
// Build index of [stack][text] => shaping information
|
||||
for (VectorTileLabel& label : labels) {
|
||||
if (values.size() <= label.text || stacks.size() <= label.stack) {
|
||||
// The indices are out of range. Skip this label.
|
||||
continue;
|
||||
}
|
||||
|
||||
const Value& text = values[label.text];
|
||||
const std::string& stack = stacks[label.stack];
|
||||
|
||||
shaping[stack][text].swap(label.placements);
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& llmr::operator<<(std::ostream& os, const GlyphPlacement& placement) {
|
||||
os << "Glyph " << placement.face << "/" << placement.glyph << ": " << placement.x << "/" << placement.y << std::endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer, const BucketDescription& bucket_desc)
|
||||
|
||||
Reference in New Issue
Block a user