diff --git a/src/map/mapsforge/rastertile.cpp b/src/map/mapsforge/rastertile.cpp index 14d79a43..8883ace1 100644 --- a/src/map/mapsforge/rastertile.cpp +++ b/src/map/mapsforge/rastertile.cpp @@ -107,20 +107,20 @@ void RasterTile::processPointLabels(const QList &points, for (int j = 0; j < symbols.size(); j++) { const Style::Symbol *ri = symbols.at(j); - - if (ri->rule().match(point.tags)) - if (!si || si->priority() < ri->priority()) - si = ri; + if (ri->rule().match(point.tags)) { + si = ri; + break; + } } for (int j = 0; j < labels.size(); j++) { const Style::TextRender *ri = labels.at(j); if (ri->rule().match(point.tags)) { if ((lbl = label(ri->key(), point.tags))) { - if (si && si->id() != ri->symbolId()) - continue; - if (!ti || ti->priority() < ri->priority()) + if (!si || si->id() == ri->symbolId()) { ti = ri; + break; + } } } } @@ -166,21 +166,20 @@ void RasterTile::processAreaLabels(const QVector &paths, for (int j = 0; j < symbols.size(); j++) { const Style::Symbol *ri = symbols.at(j); - - if (ri->rule().match(path.path->closed, path.path->tags)) - if (!si || si->priority() < ri->priority()) - si = ri; + if (ri->rule().match(path.path->closed, path.path->tags)) { + si = ri; + break; + } } for (int j = 0; j < labels.size(); j++) { const Style::TextRender *ri = labels.at(j); if (ri->rule().match(path.path->closed, path.path->tags)) { if ((lbl = label(ri->key(), path.path->tags))) { - if (si && si->id() != ri->symbolId()) - continue; - - ti = ri; - break; + if (!si || si->id() == ri->symbolId()) { + ti = ri; + break; + } } } } @@ -232,15 +231,6 @@ void RasterTile::processLineLabels(const QVector &paths, if (path.path->closed) continue; - for (int j = 0; j < labels.size(); j++) { - const Style::TextRender *ri = labels.at(j); - if (ri->rule().match(path.path->closed, path.path->tags)) { - if ((lbl = label(ri->key(), path.path->tags))) - ti = ri; - break; - } - } - for (int j = 0; j < symbols.size(); j++) { const Style::Symbol *ri = symbols.at(j); if (ri->rule().match(path.path->closed, path.path->tags)) { @@ -249,6 +239,18 @@ void RasterTile::processLineLabels(const QVector &paths, } } + for (int j = 0; j < labels.size(); j++) { + const Style::TextRender *ri = labels.at(j); + if (ri->rule().match(path.path->closed, path.path->tags)) { + if ((lbl = label(ri->key(), path.path->tags))) { + if (!si || si->id() == ri->symbolId()) { + ti = ri; + break; + } + } + } + } + if (ti || si) items.append(PathText(&path, lbl, si, ti)); } diff --git a/src/map/mapsforge/style.cpp b/src/map/mapsforge/style.cpp index 90ba2dd2..f0c62b67 100644 --- a/src/map/mapsforge/style.cpp +++ b/src/map/mapsforge/style.cpp @@ -77,6 +77,16 @@ static QList valList(const QList &in) return out; } +static bool symbolCmp(const Style::Symbol &a, const Style::Symbol &b) +{ + return a.priority() > b.priority(); +} + +static bool labelCmp(const Style::TextRender &a, const Style::TextRender &b) +{ + return a.priority() > b.priority(); +} + const Style::Menu::Layer *Style::Menu::findLayer(const QString &id) const { for (int i = 0; i < _layers.size(); i++) @@ -759,6 +769,12 @@ void Style::load(const MapData &data, qreal ratio) if (!QFileInfo::exists(path) || !loadXml(path, data, ratio)) loadXml(":/mapsforge/default.xml", data, ratio); + + std::sort(_symbols.begin(), _symbols.end(), symbolCmp); + std::sort(_lineSymbols.begin(), _lineSymbols.end(), symbolCmp); + std::stable_sort(_pointLabels.begin(), _pointLabels.end(), labelCmp); + std::stable_sort(_areaLabels.begin(), _areaLabels.end(), labelCmp); + std::stable_sort(_pathLabels.begin(), _pathLabels.end(), labelCmp); } void Style::clear()