Optimization

This commit is contained in:
Martin Tůma 2018-11-03 21:05:28 +01:00
parent a4089f9a29
commit d9d2042b03

View File

@ -401,6 +401,9 @@ void Style::Layer::drawPath(int zoom, const QPainterPath &path,
void Style::Layer::drawSymbol(int zoom, const QPainterPath &path, void Style::Layer::drawSymbol(int zoom, const QPainterPath &path,
const QVariantMap &tags, Tile &tile) const const QVariantMap &tags, Tile &tile) const
{ {
if (_layout.keys().isEmpty())
return;
QString text(_layout.field()); QString text(_layout.field());
for (int i = 0; i < _layout.keys().size(); i++) { for (int i = 0; i < _layout.keys().size(); i++) {
const QString &key = _layout.keys().at(i); const QString &key = _layout.keys().at(i);
@ -409,14 +412,18 @@ void Style::Layer::drawSymbol(int zoom, const QPainterPath &path,
? val.toString().toUpper() : val.toString()); ? val.toString().toUpper() : val.toString());
} }
QString tt(text.trimmed());
if (tt.isEmpty())
return;
QPen pen(_paint.pen(_type, zoom)); QPen pen(_paint.pen(_type, zoom));
QFont font(_layout.font(zoom)); QFont font(_layout.font(zoom));
if (path.elementCount() == 1 && path.elementAt(0).isMoveTo()) if (path.elementCount() == 1 && path.elementAt(0).isMoveTo())
tile.text().addLabel(text.trimmed(), path.elementAt(0), font, pen, tile.text().addLabel(tt, path.elementAt(0), font, pen,
_layout.maxTextWidth(zoom)); _layout.maxTextWidth(zoom));
else else
tile.text().addLabel(text.trimmed(), path, font, pen, tile.text().addLabel(tt, path, font, pen,
_layout.maxTextAngle(zoom), _layout.symbolSpacing(zoom)); _layout.maxTextAngle(zoom), _layout.symbolSpacing(zoom));
} }