Commit 8f3b1df6 authored by Dennis Nienhüser's avatar Dennis Nienhüser

Render building entries with house numbers

When nodes of a building are tagged with house numbers, render them.
parent 57b4f749
...@@ -219,6 +219,16 @@ void GeoPolygonGraphicsItem::extractBuildingHeight() ...@@ -219,6 +219,16 @@ void GeoPolygonGraphicsItem::extractBuildingHeight()
} else if (placemark->osmData().containsTagKey("addr:housenumber")) { } else if (placemark->osmData().containsTagKey("addr:housenumber")) {
m_buildingLabel = placemark->osmData().tagValue("addr:housenumber"); m_buildingLabel = placemark->osmData().tagValue("addr:housenumber");
} }
auto const end = placemark->osmData().nodeReferencesEnd();
for (auto iter = placemark->osmData().nodeReferencesBegin(); iter != end; ++iter) {
if (iter.value().containsTagKey("addr:housenumber")) {
NamedEntry entry;
entry.point = iter.key();
entry.label = iter.value().tagValue("addr:housenumber");
m_entries.push_back(entry);
}
}
} }
m_buildingHeight = qBound(1.0, height, 1000.0); m_buildingHeight = qBound(1.0, height, 1000.0);
...@@ -349,6 +359,17 @@ void GeoPolygonGraphicsItem::paintRoof( GeoPainter* painter, const ViewportParam ...@@ -349,6 +359,17 @@ void GeoPolygonGraphicsItem::paintRoof( GeoPainter* painter, const ViewportParam
} }
} }
// Render additional housenumbers at building entries
foreach(const auto &entry, m_entries) {
qreal x, y;
viewport->screenCoordinates(entry.point, x, y);
QPointF point(x, y);
point += buildingOffset(point, viewport);
point.rx() -= 0.5 * painter->fontMetrics().width(entry.label);
point.ry() += 0.5 * painter->fontMetrics().ascent();
painter->drawText(point, entry.label);
}
// then paint the outlines if there are inner boundaries // then paint the outlines if there are inner boundaries
if (hasInnerBoundaries) { if (hasInnerBoundaries) {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define MARBLE_GEOPOLYGONGRAPHICSITEM_H #define MARBLE_GEOPOLYGONGRAPHICSITEM_H
#include "GeoGraphicsItem.h" #include "GeoGraphicsItem.h"
#include "GeoDataCoordinates.h"
#include "marble_export.h" #include "marble_export.h"
#include <QImage> #include <QImage>
#include <QColor> #include <QColor>
...@@ -56,6 +57,12 @@ private: ...@@ -56,6 +57,12 @@ private:
QString m_cachedTexturePath; QString m_cachedTexturePath;
QColor m_cachedTextureColor; QColor m_cachedTextureColor;
QImage m_cachedTexture; QImage m_cachedTexture;
struct NamedEntry {
GeoDataCoordinates point;
QString label;
};
QList<NamedEntry> m_entries;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment