1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Fixed symbol/label display priority

This commit is contained in:
Martin Tůma 2024-11-07 18:31:39 +01:00
parent 62ef1f4243
commit 9b0fb8b77c
2 changed files with 43 additions and 25 deletions

View File

@ -107,20 +107,20 @@ void RasterTile::processPointLabels(const QList<MapData::Point> &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())
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,24 +166,23 @@ void RasterTile::processAreaLabels(const QVector<PainterPath> &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())
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;
if (!si || si->id() == ri->symbolId()) {
ti = ri;
break;
}
}
}
}
if (ti || si)
items.append(PathText(&path, lbl, si, ti));
@ -232,15 +231,6 @@ void RasterTile::processLineLabels(const QVector<PainterPath> &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<PainterPath> &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));
}

View File

@ -77,6 +77,16 @@ static QList<QByteArray> valList(const QList<QByteArray> &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()