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

Do not duplicate the label rules

This commit is contained in:
Martin Tůma 2024-11-19 01:45:34 +01:00
parent d577eab66e
commit 7c59998f96
2 changed files with 32 additions and 30 deletions

View File

@ -471,12 +471,8 @@ void Style::text(QXmlStreamReader &reader, const MapData &data,
if (fontSize) { if (fontSize) {
if (line) if (line)
_pathLabels.append(ri); _pathLabels.append(ri);
else { else
if (rule._type == Rule::WayType || rule._type == Rule::AnyType) _labels.append(ri);
_areaLabels.append(ri);
if (rule._type == Rule::NodeType || rule._type == Rule::AnyType)
_pointLabels.append(ri);
}
} }
reader.skipCurrentElement(); reader.skipCurrentElement();
@ -806,8 +802,7 @@ void Style::load(const MapData &data, qreal ratio)
std::sort(_symbols.begin(), _symbols.end()); std::sort(_symbols.begin(), _symbols.end());
std::sort(_lineSymbols.begin(), _lineSymbols.end()); std::sort(_lineSymbols.begin(), _lineSymbols.end());
std::stable_sort(_pointLabels.begin(), _pointLabels.end()); std::stable_sort(_labels.begin(), _labels.end());
std::stable_sort(_areaLabels.begin(), _areaLabels.end());
std::stable_sort(_pathLabels.begin(), _pathLabels.end()); std::stable_sort(_pathLabels.begin(), _pathLabels.end());
} }
@ -816,8 +811,7 @@ void Style::clear()
_paths = QList<PathRender>(); _paths = QList<PathRender>();
_circles = QList<CircleRender>(); _circles = QList<CircleRender>();
_pathLabels = QList<TextRender>(); _pathLabels = QList<TextRender>();
_pointLabels = QList<TextRender>(); _labels = QList<TextRender>();
_areaLabels = QList<TextRender>();
_symbols = QList<Symbol>(); _symbols = QList<Symbol>();
_lineSymbols = QList<Symbol>(); _lineSymbols = QList<Symbol>();
_hillShading = HillShadingRender(); _hillShading = HillShadingRender();
@ -868,9 +862,13 @@ QList<const Style::TextRender*> Style::pointLabels(int zoom) const
{ {
QList<const TextRender*> list; QList<const TextRender*> list;
for (int i = 0; i < _pointLabels.size(); i++) for (int i = 0; i < _labels.size(); i++) {
if (_pointLabels.at(i).rule()._zooms.contains(zoom)) const TextRender &label= _labels.at(i);
list.append(&_pointLabels.at(i)); const Rule &rule = label.rule();
if (rule._zooms.contains(zoom) && (rule._type == Rule::AnyType
|| rule._type == Rule::NodeType))
list.append(&label);
}
return list; return list;
} }
@ -879,9 +877,26 @@ QList<const Style::TextRender*> Style::areaLabels(int zoom) const
{ {
QList<const TextRender*> list; QList<const TextRender*> list;
for (int i = 0; i < _areaLabels.size(); i++) for (int i = 0; i < _labels.size(); i++) {
if (_areaLabels.at(i).rule()._zooms.contains(zoom)) const TextRender &label= _labels.at(i);
list.append(&_areaLabels.at(i)); const Rule &rule = label.rule();
if (rule._zooms.contains(zoom) && (rule._type == Rule::AnyType
|| rule._type == Rule::WayType))
list.append(&label);
}
return list;
}
QList<const Style::Symbol*> Style::lineSymbols(int zoom) const
{
QList<const Symbol*> list;
for (int i = 0; i < _lineSymbols.size(); i++) {
const Symbol &symbol = _lineSymbols.at(i);
if (symbol.rule()._zooms.contains(zoom))
list.append(&symbol);
}
return list; return list;
} }
@ -901,19 +916,6 @@ QList<const Style::Symbol*> Style::pointSymbols(int zoom) const
return list; return list;
} }
QList<const Style::Symbol*> Style::lineSymbols(int zoom) const
{
QList<const Symbol*> list;
for (int i = 0; i < _lineSymbols.size(); i++) {
const Symbol &symbol = _lineSymbols.at(i);
if (symbol.rule()._zooms.contains(zoom))
list.append(&symbol);
}
return list;
}
QList<const Style::Symbol*> Style::areaSymbols(int zoom) const QList<const Style::Symbol*> Style::areaSymbols(int zoom) const
{ {
QList<const Symbol*> list; QList<const Symbol*> list;

View File

@ -317,7 +317,7 @@ private:
HillShadingRender _hillShading; HillShadingRender _hillShading;
QList<PathRender> _paths; QList<PathRender> _paths;
QList<CircleRender> _circles; QList<CircleRender> _circles;
QList<TextRender> _pathLabels, _pointLabels, _areaLabels; QList<TextRender> _labels, _pathLabels;
QList<Symbol> _symbols, _lineSymbols; QList<Symbol> _symbols, _lineSymbols;
bool loadXml(const QString &path, const MapData &data, qreal ratio); bool loadXml(const QString &path, const MapData &data, qreal ratio);