[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [marble] src: Revert "have polygon and linear ring icons rendered by PlacemarkLayer"
From: Bernhard Beschow <bbeschow () cs ! tu-berlin ! de>
Date: 2016-10-23 12:21:29
Message-ID: E1byHmL-0004Hu-Od () code ! kde ! org
[Download RAW message or body]
Git commit 91d07d77a3726c7ece10c9d7770fdd7ed0f01797 by Bernhard Beschow.
Committed on 23/10/2016 at 12:08.
Pushed by beschow into branch 'master'.
Revert "have polygon and linear ring icons rendered by PlacemarkLayer"
This reverts commit b1a507ba5d9e2386bc2dd4b2432569910a5e030e.
M +3 -7 src/lib/marble/geodata/data/GeoDataPlacemark.cpp
M +44 -1 src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
M +2 -0 src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h
M +0 -6 src/plugins/runner/osm/OsmWay.cpp
http://commits.kde.org/marble/91d07d77a3726c7ece10c9d7770fdd7ed0f01797
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp \
b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp index ad7cbe4..5ccca5e 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
@@ -275,20 +275,16 @@ GeoDataCoordinates GeoDataPlacemark::coordinate( const QDateTime \
&dateTime, bool
if (d->m_geometry) {
// Beware: comparison between pointers, not strings.
- if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType
- || d->m_geometry->nodeType() == GeoDataTypes::GeoDataPolygonType
- || d->m_geometry->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
+ if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType) {
hasIcon = true;
- coord = d->m_geometry->latLonAltBox().center();
+ coord = static_cast<const GeoDataPoint *>(d->m_geometry)->coordinates();
} else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiGeometryType) {
const GeoDataMultiGeometry *multiGeometry = static_cast<const GeoDataMultiGeometry \
*>(d->m_geometry);
QVector<GeoDataGeometry*>::ConstIterator it = multiGeometry->constBegin();
QVector<GeoDataGeometry*>::ConstIterator end = multiGeometry->constEnd();
for ( ; it != end; ++it ) {
- if ((*it)->nodeType() == GeoDataTypes::GeoDataPointType
- || (*it)->nodeType() == GeoDataTypes::GeoDataPolygonType
- || (*it)->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
+ if ( (*it)->nodeType() == GeoDataTypes::GeoDataPointType ) {
hasIcon = true;
break;
}
diff --git a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp \
b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp index a44fa2a..e9f73d3 \
100644
--- a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
+++ b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
@@ -29,6 +29,7 @@ BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const \
GeoDataPlac
const GeoDataPolygon *polygon)
: AbstractGeoPolygonGraphicsItem(placemark, polygon)
, m_buildingHeight(polygon->latLonAltBox().maxAltitude() - \
polygon->latLonAltBox().minAltitude()) + , m_buildingLabel(extractBuildingLabel(*placemark))
, m_entries(extractNamedEntries(*placemark))
{
setZValue(this->zValue() + m_buildingHeight);
@@ -44,6 +45,7 @@ BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const \
GeoDataPlac
const GeoDataLinearRing* ring)
: AbstractGeoPolygonGraphicsItem(placemark, ring)
, m_buildingHeight(ring->latLonAltBox().maxAltitude() - \
ring->latLonAltBox().minAltitude()) + , m_buildingLabel(extractBuildingLabel(*placemark))
, m_entries(extractNamedEntries(*placemark))
{
setZValue(this->zValue() + m_buildingHeight);
@@ -133,6 +135,27 @@ QPointF BuildingGeoPolygonGraphicsItem::buildingOffset(const QPointF \
&point, con return QPointF(shiftX, shiftY);
}
+QString BuildingGeoPolygonGraphicsItem::extractBuildingLabel(const GeoDataPlacemark \
&placemark) +{
+ if (!placemark.name().isEmpty()) {
+ return placemark.name();
+ }
+
+ const OsmPlacemarkData &osmData = placemark.osmData();
+
+ auto tagIter = osmData.findTag(QStringLiteral("addr:housename"));
+ if (tagIter != osmData.tagsEnd()) {
+ return tagIter.value();
+ }
+
+ tagIter = osmData.findTag(QStringLiteral("addr:housenumber"));
+ if (tagIter != osmData.tagsEnd()) {
+ return tagIter.value();
+ }
+
+ return QString();
+}
+
QVector<BuildingGeoPolygonGraphicsItem::NamedEntry> \
BuildingGeoPolygonGraphicsItem::extractNamedEntries(const GeoDataPlacemark &placemark) {
QVector<NamedEntry> entries;
@@ -177,6 +200,7 @@ void BuildingGeoPolygonGraphicsItem::paintRoof(GeoPainter* painter, const \
Viewpo painter->save();
QPen const currentPen = configurePainter(painter, viewport);
+ bool const hasIcon = !style()->iconStyle().iconPath().isEmpty();
qreal maxSize(0.0);
QPointF roofCenter;
@@ -190,7 +214,7 @@ void BuildingGeoPolygonGraphicsItem::paintRoof(GeoPainter* painter, const \
Viewpo foreach(QPolygonF* outlinePolygon, outlinePolygons) {
QRectF const boundingRect = outlinePolygon->boundingRect();
QPolygonF buildingRoof;
- if (!m_entries.isEmpty()) {
+ if (hasIcon || !m_buildingLabel.isEmpty() || !m_entries.isEmpty()) {
QSizeF const polygonSize = boundingRect.size();
qreal size = polygonSize.width() * polygonSize.height();
if (size > maxSize) {
@@ -234,6 +258,25 @@ void BuildingGeoPolygonGraphicsItem::paintRoof(GeoPainter* painter, const \
Viewpo painter->drawPolygon(*outlinePolygon);
painter->translate(-offset);
}
+
+ if (hasIcon && !roofCenter.isNull()) {
+ QImage const icon = style()->iconStyle().scaledIcon();
+ QPointF const iconCenter(icon.size().width()/2.0, icon.size().height()/2.0);
+ painter->drawImage(roofCenter-iconCenter, icon);
+ } else if (drawAccurate3D && !m_buildingLabel.isEmpty() && !roofCenter.isNull()) {
+ double const w2 = 0.5 * painter->fontMetrics().width(m_buildingLabel);
+ double const ascent = painter->fontMetrics().ascent();
+ double const descent = painter->fontMetrics().descent();
+ double const a2 = 0.5 * painter->fontMetrics().ascent();
+ QPointF const textPosition = roofCenter - QPointF(w2, -a2);
+ if (buildingRoof.containsPoint(textPosition + QPointF(-2, -ascent), \
Qt::OddEvenFill) + && buildingRoof.containsPoint(textPosition + QPointF(-2, \
descent), Qt::OddEvenFill) + && buildingRoof.containsPoint(textPosition + \
QPointF(2+2*w2, descent), Qt::OddEvenFill) + && \
buildingRoof.containsPoint(textPosition + QPointF(2+2*w2, -ascent), Qt::OddEvenFill) + \
) { + painter->drawText(textPosition, m_buildingLabel);
+ }
+ }
}
// Render additional housenumbers at building entries
diff --git a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h \
b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h index 64f7d6e..bb7a662 \
100644
--- a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h
+++ b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h
@@ -46,10 +46,12 @@ private:
static QPointF centroid(const QPolygonF &polygon, double &area);
static void screenPolygons(const ViewportParams *viewport, const GeoDataPolygon* polygon,
QVector<QPolygonF*> &polygons, QVector<QPolygonF*> &outlines);
+ static QString extractBuildingLabel(const GeoDataPlacemark &placemark);
static QVector<NamedEntry> extractNamedEntries(const GeoDataPlacemark &placemark);
private:
const double m_buildingHeight;
+ const QString m_buildingLabel;
const QVector<NamedEntry> m_entries;
};
diff --git a/src/plugins/runner/osm/OsmWay.cpp b/src/plugins/runner/osm/OsmWay.cpp
index f369790..1b2a02b 100644
--- a/src/plugins/runner/osm/OsmWay.cpp
+++ b/src/plugins/runner/osm/OsmWay.cpp
@@ -88,12 +88,6 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, \
QSet<qint6 if (placemark->name().isEmpty()) {
placemark->setName(m_osmData.tagValue(QStringLiteral("ref")));
}
- if (placemark->name().isEmpty()) {
- placemark->setName(m_osmData.tagValue(QStringLiteral("addr:housename")));
- }
- if (placemark->name().isEmpty()) {
- placemark->setName(m_osmData.tagValue(QStringLiteral("addr:housenumber")));
- }
placemark->setOsmData(osmData);
placemark->setVisible(placemark->visualCategory() != GeoDataPlacemark::None);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic