pass shaping directly instead of looking it up

This commit is contained in:
Konstantin Käfer
2014-05-30 14:01:53 +02:00
parent 461a19dfa2
commit 31d9dbefea
3 changed files with 8 additions and 34 deletions

View File

@@ -36,9 +36,9 @@ public:
void addGlyphs(const PlacedGlyphs &glyphs, float placementZoom,
PlacementRange placementRange, float zoom);
void addFeature(const VectorTileFeature &feature,
void addFeature(const pbf &geometry,
const GlyphPositions &face,
const std::map<Value, Shaping> &shapings);
const Shaping &shaping);
void drawGlyphs(TextShader &shader);

View File

@@ -199,7 +199,6 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
// Create a copy!
const FontStack &fontStack = glyphStore.getFontStack(bucket_desc.geometry.font);
std::map<Value, Shaping> shaping;
GlyphPositions face;
// Shape and place all labels.
@@ -222,18 +221,15 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
const std::u32string string = ucs4conv.convert(source_string);
// Shape labels.
const Shaping shaped = fontStack.getShaping(string);
shaping.emplace(source_string, shaped);
const Shaping shaping = fontStack.getShaping(string);
// Place labels.
addGlyph(tile.id.to_uint64(), bucket_desc.geometry.font, string, fontStack, glyphAtlas, face);
bucket->addFeature(feature.geometry, face, shaping);
}
}
// It looks like nearly the same interface through the rest
// of the stack.
addBucketFeatures(bucket, layer, bucket_desc, face, shaping);
return std::move(bucket);
}

View File

@@ -99,37 +99,15 @@ void TextBucket::addGlyphs(const PlacedGlyphs &glyphs, float placementZoom,
}
};
void TextBucket::addFeature(const VectorTileFeature &feature,
void TextBucket::addFeature(const pbf &geom_pbf,
const GlyphPositions &face,
const std::map<Value, Shaping> &shapings) {
auto it_prop = feature.properties.find(geom_desc.field);
if (it_prop == feature.properties.end()) {
// feature does not have the correct property
if (debug::labelTextMissingWarning) {
fprintf(stderr, "[WARNING] feature doesn't have property '%s' required for labelling\n", geom_desc.field.c_str());
}
return;
}
const Value &value = it_prop->second;
auto it_shaping = shapings.find(toString(value));
if (it_shaping == shapings.end()) {
if (debug::shapingWarning) {
fprintf(stderr, "[WARNING] missing shaping for '%s'\n", toString(value).c_str());
}
// we lack shaping information for this label
return;
}
const Shaping &shaping = it_shaping->second;
// std::cerr << "we have shaping for " << value << std::endl;
const Shaping &shaping) {
// Decode all lines.
std::vector<Coordinate> line;
Geometry::command cmd;
Coordinate coord;
pbf geom = feature.geometry;
pbf geom(geom_pbf);
Geometry geometry(geom);
int32_t x, y;
while ((cmd = geometry.next(x, y)) != Geometry::end) {