Improved performance

This commit is contained in:
Martin Tůma 2019-01-01 21:27:07 +01:00
parent 2a89ef8dfd
commit a7294b30f8
5 changed files with 267 additions and 218 deletions

View File

@ -1,22 +1,24 @@
#include <QByteArray>
#include <QImage>
#include <QPainter>
#include <QDebug>
#include <QVariantHash>
#include "vector_tile.pb.h"
#include "style.h"
#include "tile.h"
#include "pbf.h" #include "pbf.h"
#define MOVE_TO 1
#define LINE_TO 2
#define CLOSE_PATH 7
#define POLYGON vector_tile::Tile_GeomType_POLYGON #define POLYGON vector_tile::Tile_GeomType_POLYGON
#define LINESTRING vector_tile::Tile_GeomType_LINESTRING #define LINESTRING vector_tile::Tile_GeomType_LINESTRING
#define POINT vector_tile::Tile_GeomType_POINT #define POINT vector_tile::Tile_GeomType_POINT
#define MOVE_TO 1
#define LINE_TO 2
#define CLOSE_PATH 7
static inline qint32 zigzag32decode(quint32 value)
{
return static_cast<qint32>((value >> 1u) ^ static_cast<quint32>(
-static_cast<qint32>(value & 1u)));
}
static inline QPoint parameters(quint32 v1, quint32 v2)
{
return QPoint(zigzag32decode(v1), zigzag32decode(v2));
}
static QVariant value(const vector_tile::Tile_Value &val) static QVariant value(const vector_tile::Tile_Value &val)
{ {
@ -38,100 +40,37 @@ static QVariant value(const vector_tile::Tile_Value &val)
return QVariant(); return QVariant();
} }
class Feature const QVariant *PBF::Feature::value(const QString &key) const
{ {
public: const KeyHash &keys(_layer->keys());
Feature() : _data(0) {} KeyHash::const_iterator it(keys.find(key));
Feature(const vector_tile::Tile_Feature *data, const QVector<QString> *keys, if (it == keys.constEnd())
const QVector<QVariant> *values) : _data(data) return 0;
{
for (int i = 0; i < data->tags_size(); i = i + 2)
_tags.insert(keys->at(data->tags(i)), values->at(data->tags(i+1)));
switch (data->type()) { const google::protobuf::RepeatedField<google::protobuf::uint32>
case POLYGON: &tags(_data->tags());
_tags.insert("$type", QVariant("Polygon")); google::protobuf::uint32 index = *it;
break; for (int i = 0; i < _data->tags_size(); i = i + 2)
case LINESTRING: if (tags[i] == index)
_tags.insert("$type", QVariant("LineString")); return &(_layer->values().at(tags[i+1]));
break;
case POINT:
_tags.insert("$type", QVariant("Point"));
break;
default:
break;
}
}
const QVariantHash &tags() const {return _tags;} return 0;
const vector_tile::Tile_Feature *data() const {return _data;}
private:
QVariantHash _tags;
const vector_tile::Tile_Feature *_data;
};
static bool cmp(const Feature &f1, const Feature &f2)
{
return f1.data()->id() < f2.data()->id();
} }
class Layer QPainterPath PBF::Feature::path(const QSizeF &factor) const
{ {
public:
Layer(const vector_tile::Tile_Layer *data) : _data(data)
{
QVector<QString> keys;
QVector<QVariant> values;
for (int i = 0; i < data->keys_size(); i++)
keys.append(QString::fromStdString(data->keys(i)));
for (int i = 0; i < data->values_size(); i++)
values.append(value(data->values(i)));
_features.reserve(data->features_size());
for (int i = 0; i < data->features_size(); i++)
_features.append(Feature(&(data->features(i)), &keys, &values));
qSort(_features.begin(), _features.end(), cmp);
}
const QVector<Feature> &features() const {return _features;}
const vector_tile::Tile_Layer *data() const {return _data;}
private:
const vector_tile::Tile_Layer *_data;
QVector<Feature> _features;
};
static inline qint32 zigzag32decode(quint32 value)
{
return static_cast<qint32>((value >> 1u) ^ static_cast<quint32>(
-static_cast<qint32>(value & 1u)));
}
static inline QPoint parameters(quint32 v1, quint32 v2)
{
return QPoint(zigzag32decode(v1), zigzag32decode(v2));
}
static void drawFeature(const Feature &feature, const Style *style,
int styleLayer, const QSizeF &factor, Tile &tile)
{
if (!style->match(tile.zoom(), styleLayer, feature.tags()))
return;
QPoint cursor; QPoint cursor;
QPainterPath path; QPainterPath path;
for (int i = 0; i < feature.data()->geometry_size(); i++) { for (int i = 0; i < _data->geometry_size(); i++) {
quint32 g = feature.data()->geometry(i); quint32 g = _data->geometry(i);
unsigned cmdId = g & 0x7; unsigned cmdId = g & 0x7;
unsigned cmdCount = g >> 3; unsigned cmdCount = g >> 3;
if (cmdId == MOVE_TO) { if (cmdId == MOVE_TO) {
for (unsigned j = 0; j < cmdCount; j++) { for (unsigned j = 0; j < cmdCount; j++) {
QPoint offset = parameters(feature.data()->geometry(i+1), QPoint offset = parameters(_data->geometry(i+1),
feature.data()->geometry(i+2)); _data->geometry(i+2));
i += 2; i += 2;
cursor += offset; cursor += offset;
path.moveTo(QPointF(cursor.x() * factor.width(), path.moveTo(QPointF(cursor.x() * factor.width(),
@ -139,8 +78,8 @@ static void drawFeature(const Feature &feature, const Style *style,
} }
} else if (cmdId == LINE_TO) { } else if (cmdId == LINE_TO) {
for (unsigned j = 0; j < cmdCount; j++) { for (unsigned j = 0; j < cmdCount; j++) {
QPoint offset = parameters(feature.data()->geometry(i+1), QPoint offset = parameters(_data->geometry(i+1),
feature.data()->geometry(i+2)); _data->geometry(i+2));
i += 2; i += 2;
cursor += offset; cursor += offset;
path.lineTo(QPointF(cursor.x() * factor.width(), path.lineTo(QPointF(cursor.x() * factor.width(),
@ -152,60 +91,35 @@ static void drawFeature(const Feature &feature, const Style *style,
} }
} }
if (path.elementCount()) return path;
style->drawFeature(tile, styleLayer, path, feature.tags());
} }
static void drawLayer(const Layer &layer, const Style *style, int styleLayer, PBF::Layer::Layer(const vector_tile::Tile_Layer *data) : _data(data)
Tile &tile)
{ {
if (layer.data()->version() > 2) _keys.reserve(data->keys_size());
return; for (int i = 0; i < data->keys_size(); i++)
_keys.insert(QString::fromStdString(data->keys(i)), i);
_values.reserve(data->values_size());
for (int i = 0; i < data->values_size(); i++)
_values.append(value(data->values(i)));
QSizeF factor(tile.size().width() / tile.scale().x() / _features.reserve(data->features_size());
(qreal)layer.data()->extent(), tile.size().height() / tile.scale().y() for (int i = 0; i < data->features_size(); i++)
/ (qreal)layer.data()->extent()); _features.append(Feature(&(data->features(i)), this));
qSort(_features.begin(), _features.end());
tile.painter().save();
style->setupLayer(tile, styleLayer);
for (int i = 0; i < layer.features().size(); i++)
drawFeature(layer.features().at(i), style, styleLayer, factor, tile);
tile.painter().restore();
} }
bool PBF::render(const QByteArray &data, int zoom, const Style *style, PBF::PBF(const vector_tile::Tile &tile)
const QPointF &scale, QImage *image)
{ {
vector_tile::Tile tile;
if (!tile.ParseFromArray(data.constData(), data.size())) {
qCritical() << "Invalid tile protocol buffer data";
return false;
}
Tile t(image, zoom, scale);
style->drawBackground(t);
// Prepare source layers
QMap<QString, Layer> layers;
for (int i = 0; i < tile.layers_size(); i++) { for (int i = 0; i < tile.layers_size(); i++) {
const vector_tile::Tile_Layer &layer = tile.layers(i); const vector_tile::Tile_Layer &layer = tile.layers(i);
QString name(QString::fromStdString(layer.name())); _layers.insert(QString::fromStdString(layer.name()), new Layer(&layer));
if (style->sourceLayers().contains(name))
layers.insert(name, Layer(&layer));
} }
}
// Process source layers in order of style layers
for (int i = 0; i < style->sourceLayers().size(); i++) { PBF::~PBF()
QMap<QString, Layer>::const_iterator it = layers.find( {
style->sourceLayers().at(i)); for (QHash<QString, Layer*>::iterator it = _layers.begin();
if (it == layers.constEnd()) it != _layers.end(); it++)
continue; delete *it;
drawLayer(*it, style, i, t);
}
t.text().render(&t.painter());
return true;
} }

View File

@ -1,15 +1,67 @@
#ifndef PBF_H #ifndef PBF_H
#define PBF_H #define PBF_H
class QByteArray; #include <QVariant>
class QImage; #include <QVector>
class Style; #include <QHash>
class QPointF; #include <QPainterPath>
#include "vector_tile.pb.h"
namespace PBF
typedef QHash<QString, google::protobuf::uint32> KeyHash;
class PBF
{ {
bool render(const QByteArray &data, int zoom, const Style *style, public:
const QPointF &scale, QImage *render); class Layer;
}
class Feature
{
public:
Feature() : _data(0), _layer(0) {}
Feature(const vector_tile::Tile_Feature *data, const Layer *layer)
: _data(data), _layer(layer) {}
const QVariant *value(const QString &key) const;
vector_tile::Tile_GeomType type() const {return _data->type();}
QPainterPath path(const QSizeF &factor) const;
friend bool operator<(const Feature &f1, const Feature &f2);
private:
const vector_tile::Tile_Feature *_data;
const Layer *_layer;
};
class Layer
{
public:
Layer(const vector_tile::Tile_Layer *data);
const QVector<Feature> &features() const {return _features;}
const QVector<QVariant> &values() const {return _values;}
const KeyHash &keys() const {return _keys;}
const vector_tile::Tile_Layer *data() const {return _data;}
private:
const vector_tile::Tile_Layer *_data;
QVector<Feature> _features;
QVector<QVariant> _values;
KeyHash _keys;
};
PBF(const vector_tile::Tile &tile);
~PBF();
const QHash<QString, Layer*> &layers() const {return _layers;}
private:
QHash<QString, Layer*> _layers;
};
inline bool operator<(const PBF::Feature &f1, const PBF::Feature &f2)
{return f1._data->id() < f2._data->id();}
#endif // PBF_H #endif // PBF_H

View File

@ -1,8 +1,10 @@
#include <QImage> #include <QImage>
#include <QIODevice> #include <QIODevice>
#include <QtEndian> #include <QtEndian>
#include <QDebug>
#include "gzip.h" #include "gzip.h"
#include "pbf.h" #include "tile.h"
#include "style.h"
#include "pbfhandler.h" #include "pbfhandler.h"
@ -61,6 +63,11 @@ bool PBFHandler::read(QImage *image)
ba = device()->readAll(); ba = device()->readAll();
if (ba.isNull()) if (ba.isNull())
return false; return false;
vector_tile::Tile data;
if (!data.ParseFromArray(ba.constData(), ba.size())) {
qCritical() << "Invalid PBF data";
return false;
}
bool ok; bool ok;
int zoom = format().toInt(&ok); int zoom = format().toInt(&ok);
@ -71,8 +78,11 @@ bool PBFHandler::read(QImage *image)
? QPointF(_scaledSize.width() / TILE_SIZE, _scaledSize.height() / TILE_SIZE) ? QPointF(_scaledSize.width() / TILE_SIZE, _scaledSize.height() / TILE_SIZE)
: QPointF(1.0, 1.0); : QPointF(1.0, 1.0);
*image = QImage(size, QImage::Format_ARGB32_Premultiplied); *image = QImage(size, QImage::Format_ARGB32_Premultiplied);
Tile tile(image, ok ? zoom : -1, scale);
return PBF::render(ba, ok ? zoom : -1, _style, scale, image); _style->render(data, tile);
return true;
} }
bool PBFHandler::supportsOption(ImageOption option) const bool PBFHandler::supportsOption(ImageOption option) const

View File

@ -10,9 +10,22 @@
#include "color.h" #include "color.h"
#include "font.h" #include "font.h"
#include "tile.h" #include "tile.h"
#include "pbf.h"
#include "style.h" #include "style.h"
static vector_tile::Tile_GeomType geometryType(const QString &str)
{
if (str == "Point")
return vector_tile::Tile_GeomType_POINT;
else if (str == "LineString")
return vector_tile::Tile_GeomType_LINESTRING;
else if (str == "Polygon")
return vector_tile::Tile_GeomType_POLYGON;
else
return vector_tile::Tile_GeomType_UNKNOWN;
}
Style::Layer::Filter::Filter(const QJsonArray &json) Style::Layer::Filter::Filter(const QJsonArray &json)
: _type(Unknown), _not(false) : _type(Unknown), _not(false)
{ {
@ -27,9 +40,15 @@ Style::Layer::Filter::Filter(const QJsonArray &json)
if (type == "==") { if (type == "==") {
if (json.size() != 3) if (json.size() != 3)
INVALID_FILTER(json); INVALID_FILTER(json);
if (json.at(1).toString() == "$type") {
_type = GeometryType;
_kv = QPair<QString, QVariant>(QString(),
QVariant(geometryType(json.at(2).toString())));
} else {
_type = EQ; _type = EQ;
_kv = QPair<QString, QVariant>(json.at(1).toString(), _kv = QPair<QString, QVariant>(json.at(1).toString(),
json.at(2).toVariant()); json.at(2).toVariant());
}
} else if (type == "!=") { } else if (type == "!=") {
if (json.size() != 3) if (json.size() != 3)
INVALID_FILTER(json); INVALID_FILTER(json);
@ -98,45 +117,68 @@ Style::Layer::Filter::Filter(const QJsonArray &json)
INVALID_FILTER(json); INVALID_FILTER(json);
} }
bool Style::Layer::Filter::match(const QVariantHash &tags) const bool Style::Layer::Filter::match(const PBF::Feature &feature) const
{ {
const QVariant *v;
switch (_type) { switch (_type) {
case None: case None:
return true; return true;
case EQ: case EQ:
return tags.value(_kv.first) == _kv.second; if (!(v = feature.value(_kv.first)))
case NE: return false;
return tags.value(_kv.first) != _kv.second; else
case GT: return *v == _kv.second;
return tags.value(_kv.first) > _kv.second; case NE:
case GE: if (!(v = feature.value(_kv.first)))
return tags.value(_kv.first) >= _kv.second; return true;
case LT: else
return tags.value(_kv.first) < _kv.second; return *v != _kv.second;
case LE: case GT:
return tags.value(_kv.first) <= _kv.second; if (!(v = feature.value(_kv.first)))
case In: return false;
return _set.contains(tags.value(_kv.first).toString()) ^ _not; else
case Has: return *v > _kv.second;
return tags.contains(_kv.first) ^ _not; case GE:
case All: if (!(v = feature.value(_kv.first)))
for (int i = 0; i < _filters.size(); i++) { return false;
if (!_filters.at(i).match(tags)) else
return *v >= _kv.second;
case LT:
if (!(v = feature.value(_kv.first)))
return false;
else
return *v < _kv.second;
case LE:
if (!(v = feature.value(_kv.first)))
return false;
else
return *v <= _kv.second;
case In:
if (!(v = feature.value(_kv.first)))
return _not;
else
return _set.contains((*v).toString()) ^ _not;
case Has:
return (feature.value(_kv.first) ? true : false) ^ _not;
case All:
for (int i = 0; i < _filters.size(); i++)
if (!_filters.at(i).match(feature))
return false; return false;
}
return true; return true;
case Any: case Any:
for (int i = 0; i < _filters.size(); i++) { for (int i = 0; i < _filters.size(); i++)
if (_filters.at(i).match(tags)) if (_filters.at(i).match(feature))
return true; return true;
}
return false; return false;
case GeometryType:
return feature.type() == _kv.second.toUInt();
default: default:
return false; return false;
} }
} }
QString Style::Layer::Template::value(int zoom, const QVariantHash &tags) const QString Style::Layer::Template::value(int zoom, const PBF::Feature &feature) const
{ {
QRegExp rx = QRegExp("\\{[^\\}]*\\}"); QRegExp rx = QRegExp("\\{[^\\}]*\\}");
QString text(_field.value(zoom)); QString text(_field.value(zoom));
@ -150,8 +192,8 @@ QString Style::Layer::Template::value(int zoom, const QVariantHash &tags) const
} }
for (int i = 0; i < keys.size(); i++) { for (int i = 0; i < keys.size(); i++) {
const QString &key = keys.at(i); const QString &key = keys.at(i);
const QVariant val = tags.value(key); const QVariant *val = feature.value(key);
text.replace(QString("{%1}").arg(key), val.toString()); text.replace(QString("{%1}").arg(key), val ? val->toString() : "");
} }
return text; return text;
@ -428,7 +470,7 @@ Style::Layer::Layer(const QJsonObject &json)
_paint = Paint(json["paint"].toObject()); _paint = Paint(json["paint"].toObject());
} }
bool Style::Layer::match(int zoom, const QVariantHash &tags) const bool Style::Layer::match(int zoom, const PBF::Feature &feature) const
{ {
if (zoom >= 0) { if (zoom >= 0) {
if (_minZoom > 0 && zoom < _minZoom) if (_minZoom > 0 && zoom < _minZoom)
@ -437,7 +479,7 @@ bool Style::Layer::match(int zoom, const QVariantHash &tags) const
return false; return false;
} }
return _filter.match(tags); return _filter.match(feature);
} }
void Style::Layer::setPathPainter(Tile &tile, const Sprites &sprites) const void Style::Layer::setPathPainter(Tile &tile, const Sprites &sprites) const
@ -472,13 +514,13 @@ void Style::Layer::setTextProperties(Tile &tile) const
} }
void Style::Layer::addSymbol(Tile &tile, const QPainterPath &path, void Style::Layer::addSymbol(Tile &tile, const QPainterPath &path,
const QVariantHash &tags, const Sprites &sprites) const const PBF::Feature &feature, const Sprites &sprites) const
{ {
QString text = _layout.text(tile.zoom(), tags); QString text = _layout.text(tile.zoom(), feature);
if (text.isEmpty()) if (text.isEmpty())
return; return;
QString icon = _layout.icon(tile.zoom(), tags); QString icon = _layout.icon(tile.zoom(), feature);
tile.text().addLabel(text, sprites.icon(icon), path); tile.text().addLabel(text, sprites.icon(icon), path);
} }
@ -525,9 +567,6 @@ bool Style::load(const QString &fileName)
_layers.append(Layer(layers[i].toObject())); _layers.append(Layer(layers[i].toObject()));
} }
for (int i = 0; i < _layers.size(); i++)
_sourceLayers.append(_layers.at(i).sourceLayer());
QDir styleDir = QFileInfo(fileName).absoluteDir(); QDir styleDir = QFileInfo(fileName).absoluteDir();
loadSprites(styleDir, "sprite.json", "sprite.png", _sprites); loadSprites(styleDir, "sprite.json", "sprite.png", _sprites);
#ifdef ENABLE_HIDPI #ifdef ENABLE_HIDPI
@ -548,25 +587,12 @@ const Sprites &Style::sprites(const QPointF &scale) const
#endif // ENABLE_HIDPI #endif // ENABLE_HIDPI
} }
void Style::setupLayer(Tile &tile, int layer) const void Style::setupLayer(Tile &tile, const Layer &layer) const
{ {
const Layer &sl = _layers.at(layer); if (layer.isSymbol())
layer.setTextProperties(tile);
if (sl.isSymbol()) else if (layer.isPath())
sl.setTextProperties(tile); layer.setPathPainter(tile, sprites(tile.scale()));
else if (sl.isPath())
sl.setPathPainter(tile, sprites(tile.scale()));
}
void Style::drawFeature(Tile &tile, int layer, const QPainterPath &path,
const QVariantHash &tags) const
{
const Layer &sl = _layers.at(layer);
if (sl.isPath())
tile.painter().drawPath(path);
else if (sl.isSymbol())
sl.addSymbol(tile, path, tags, sprites(tile.scale()));
} }
void Style::drawBackground(Tile &tile) const void Style::drawBackground(Tile &tile) const
@ -587,3 +613,52 @@ void Style::drawBackground(Tile &tile) const
//tile.painter().setPen(Qt::red); //tile.painter().setPen(Qt::red);
//tile.painter().drawRect(rect); //tile.painter().drawRect(rect);
} }
void Style::drawFeature(const PBF::Feature &feature, const Layer &layer,
Tile &tile, const QSizeF &factor) const
{
if (!layer.match(tile.zoom(), feature))
return;
QPainterPath path(feature.path(factor));
if (!path.elementCount())
return;
if (layer.isPath())
tile.painter().drawPath(path);
else if (layer.isSymbol())
layer.addSymbol(tile, path, feature, sprites(tile.scale()));
}
void Style::drawLayer(const PBF::Layer &pbfLayer, const Layer &styleLayer,
Tile &tile) const
{
if (pbfLayer.data()->version() > 2)
return;
QSizeF factor(tile.size().width() / tile.scale().x() /
(qreal)pbfLayer.data()->extent(), tile.size().height() / tile.scale().y()
/ (qreal)pbfLayer.data()->extent());
tile.painter().save();
setupLayer(tile, styleLayer);
for (int i = 0; i < pbfLayer.features().size(); i++)
drawFeature(pbfLayer.features().at(i), styleLayer, tile, factor);
tile.painter().restore();
}
void Style::render(const PBF &data, Tile &tile) const
{
drawBackground(tile);
for (int i = 0; i < _layers.size(); i++) {
QHash<QString, PBF::Layer*>::const_iterator it = data.layers().find(
_layers.at(i).sourceLayer());
if (it == data.layers().constEnd())
continue;
drawLayer(**it, _layers.at(i), tile);
}
tile.text().render(&tile.painter());
}

View File

@ -11,6 +11,7 @@
#include <QPen> #include <QPen>
#include <QBrush> #include <QBrush>
#include <QFont> #include <QFont>
#include "pbf.h"
#include "config.h" #include "config.h"
#include "text.h" #include "text.h"
#include "function.h" #include "function.h"
@ -29,16 +30,7 @@ public:
Style(QObject *parent = 0) : QObject(parent) {} Style(QObject *parent = 0) : QObject(parent) {}
bool load(const QString &fileName); bool load(const QString &fileName);
void render(const PBF &data, Tile &tile) const;
const QStringList &sourceLayers() const
{return _sourceLayers;}
bool match(int zoom, int layer, const QVariantHash &tags) const
{return _layers.at(layer).match(zoom, tags);}
void drawBackground(Tile &tile) const;
void setupLayer(Tile &tile, int layer) const;
void drawFeature(Tile &tile, int layer, const QPainterPath &path,
const QVariantHash &tags) const;
private: private:
class Layer { class Layer {
@ -51,11 +43,11 @@ private:
bool isBackground() const {return (_type == Background);} bool isBackground() const {return (_type == Background);}
bool isSymbol() const {return (_type == Symbol);} bool isSymbol() const {return (_type == Symbol);}
bool match(int zoom, const QVariantHash &tags) const; bool match(int zoom, const PBF::Feature &feature) const;
void setPathPainter(Tile &tile, const Sprites &sprites) const; void setPathPainter(Tile &tile, const Sprites &sprites) const;
void setTextProperties(Tile &tile) const; void setTextProperties(Tile &tile) const;
void addSymbol(Tile &tile, const QPainterPath &path, void addSymbol(Tile &tile, const QPainterPath &path,
const QVariantHash &tags, const Sprites &sprites) const; const PBF::Feature &feature, const Sprites &sprites) const;
private: private:
enum Type { enum Type {
@ -71,13 +63,13 @@ private:
Filter() : _type(None) {} Filter() : _type(None) {}
Filter(const QJsonArray &json); Filter(const QJsonArray &json);
bool match(const QVariantHash &tags) const; bool match(const PBF::Feature &feature) const;
private: private:
enum Type { enum Type {
None, Unknown, None, Unknown,
EQ, NE, GE, GT, LE, LT, EQ, NE, GE, GT, LE, LT,
All, Any, All, Any,
In, Has In, Has, GeometryType
}; };
Type _type; Type _type;
@ -91,7 +83,7 @@ private:
public: public:
Template() {} Template() {}
Template(const FunctionS &str) : _field(str) {} Template(const FunctionS &str) : _field(str) {}
QString value(int zoom, const QVariantHash &tags) const; QString value(int zoom, const PBF::Feature &feature) const;
private: private:
FunctionS _field; FunctionS _field;
@ -107,10 +99,10 @@ private:
{return _textMaxWidth.value(zoom);} {return _textMaxWidth.value(zoom);}
qreal maxTextAngle(int zoom) const qreal maxTextAngle(int zoom) const
{return _textMaxAngle.value(zoom);} {return _textMaxAngle.value(zoom);}
QString text(int zoom, const QVariantHash &tags) const QString text(int zoom, const PBF::Feature &feature) const
{return _text.value(zoom, tags).trimmed();} {return _text.value(zoom, feature).trimmed();}
QString icon(int zoom, const QVariantHash &tags) const QString icon(int zoom, const PBF::Feature &feature) const
{return _icon.value(zoom, tags);} {return _icon.value(zoom, feature);}
QFont font(int zoom) const; QFont font(int zoom) const;
Qt::PenCapStyle lineCap(int zoom) const; Qt::PenCapStyle lineCap(int zoom) const;
Qt::PenJoinStyle lineJoin(int zoom) const; Qt::PenJoinStyle lineJoin(int zoom) const;
@ -170,8 +162,14 @@ private:
const Sprites &sprites(const QPointF &scale) const; const Sprites &sprites(const QPointF &scale) const;
void drawBackground(Tile &tile) const;
void setupLayer(Tile &tile, const Layer &layer) const;
void drawFeature(const PBF::Feature &feature, const Layer &layer,
Tile &tile, const QSizeF &factor) const;
void drawLayer(const PBF::Layer &pbfLayer, const Layer &styleLayer,
Tile &tile) const;
QVector<Layer> _layers; QVector<Layer> _layers;
QStringList _sourceLayers;
Sprites _sprites; Sprites _sprites;
#ifdef ENABLE_HIDPI #ifdef ENABLE_HIDPI
Sprites _sprites2x; Sprites _sprites2x;