summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-09-18 12:29:11 (GMT)
committerBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-10-03 14:30:57 (GMT)
commite2e3e1989783c8b5640ad703e2d7001d87f05dcc (patch)
treea8e86b0d092d2e40f0e6510898eb09fd129ae292
parent620949187746a4a2368e81e77fb8d6360e996b7c (diff)
set the bboxe's height to the building height and use that for building rendering
-rw-r--r--src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp30
-rw-r--r--src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h1
-rw-r--r--src/plugins/runner/osm/OsmWay.cpp42
-rw-r--r--src/plugins/runner/osm/OsmWay.h2
4 files changed, 45 insertions, 30 deletions
diff --git a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
index cf86ea7..e9f73d3 100644
--- a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
+++ b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.cpp
@@ -14,6 +14,7 @@
#include "ViewportParams.h"
#include "GeoDataTypes.h"
#include "GeoDataPlacemark.h"
+#include "GeoDataLatLonAltBox.h"
#include "GeoDataLinearRing.h"
#include "GeoDataPolygon.h"
#include "GeoDataIconStyle.h"
@@ -27,7 +28,7 @@ namespace Marble
BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark,
const GeoDataPolygon *polygon)
: AbstractGeoPolygonGraphicsItem(placemark, polygon)
- , m_buildingHeight(extractBuildingHeight(*placemark))
+ , m_buildingHeight(polygon->latLonAltBox().maxAltitude() - polygon->latLonAltBox().minAltitude())
, m_buildingLabel(extractBuildingLabel(*placemark))
, m_entries(extractNamedEntries(*placemark))
{
@@ -43,7 +44,7 @@ BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const GeoDataPlac
BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark,
const GeoDataLinearRing* ring)
: AbstractGeoPolygonGraphicsItem(placemark, ring)
- , m_buildingHeight(extractBuildingHeight(*placemark))
+ , m_buildingHeight(ring->latLonAltBox().maxAltitude() - ring->latLonAltBox().minAltitude())
, m_buildingLabel(extractBuildingLabel(*placemark))
, m_entries(extractNamedEntries(*placemark))
{
@@ -134,31 +135,6 @@ QPointF BuildingGeoPolygonGraphicsItem::buildingOffset(const QPointF &point, con
return QPointF(shiftX, shiftY);
}
-double BuildingGeoPolygonGraphicsItem::extractBuildingHeight(const GeoDataPlacemark &placemark)
-{
- double height = 8.0;
-
- const OsmPlacemarkData &osmData = placemark.osmData();
-
- QHash<QString, QString>::const_iterator tagIter;
- if ((tagIter = osmData.findTag(QStringLiteral("height"))) != osmData.tagsEnd()) {
- /** @todo Also parse non-SI units, see https://wiki.openstreetmap.org/wiki/Key:height#Height_of_buildings */
- QString const heightValue = QString(tagIter.value()).remove(QStringLiteral(" meters")).remove(QStringLiteral(" m"));
- bool extracted = false;
- double extractedHeight = heightValue.toDouble(&extracted);
- if (extracted) {
- height = extractedHeight;
- }
- } else if ((tagIter = osmData.findTag(QStringLiteral("building:levels"))) != osmData.tagsEnd()) {
- int const levels = tagIter.value().toInt();
- int const skipLevels = osmData.tagValue(QStringLiteral("building:min_level")).toInt();
- /** @todo Is 35 as an upper bound for the number of levels sane? */
- height = 3.0 * qBound(1, 1+levels-skipLevels, 35);
- }
-
- return qBound(1.0, height, 1000.0);
-}
-
QString BuildingGeoPolygonGraphicsItem::extractBuildingLabel(const GeoDataPlacemark &placemark)
{
if (!placemark.name().isEmpty()) {
diff --git a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h
index 8514cc5..bb7a662 100644
--- a/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h
+++ b/src/lib/marble/geodata/graphicsitem/BuildingGeoPolygonGraphicsItem.h
@@ -46,7 +46,6 @@ 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 double extractBuildingHeight(const GeoDataPlacemark &placemark);
static QString extractBuildingLabel(const GeoDataPlacemark &placemark);
static QVector<NamedEntry> extractNamedEntries(const GeoDataPlacemark &placemark);
diff --git a/src/plugins/runner/osm/OsmWay.cpp b/src/plugins/runner/osm/OsmWay.cpp
index 151f91d..1b2a02b 100644
--- a/src/plugins/runner/osm/OsmWay.cpp
+++ b/src/plugins/runner/osm/OsmWay.cpp
@@ -25,6 +25,8 @@ QSet<StyleBuilder::OsmTag> OsmWay::s_areaTags;
void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint64> &usedNodes) const
{
+ const double height = extractBuildingHeight(m_osmData);
+
OsmPlacemarkData osmData = m_osmData;
GeoDataGeometry *geometry = 0;
@@ -43,7 +45,12 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint6
usedNodes << nodeId;
}
- geometry = new GeoDataLinearRing(linearRing.optimized());
+ linearRing = GeoDataLinearRing(linearRing.optimized());
+ if (!linearRing.isEmpty() && height != 0) {
+ linearRing.first().setAltitude(height);
+ }
+
+ geometry = new GeoDataLinearRing(linearRing);
} else {
GeoDataLineString lineString;
@@ -59,10 +66,18 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint6
usedNodes << nodeId;
}
- geometry = new GeoDataLineString(lineString.optimized());
+ lineString = lineString.optimized();
+ if (!lineString.isEmpty() && height != 0) {
+ lineString.first().setAltitude(height);
+ }
+
+ geometry = new GeoDataLineString(lineString);
}
Q_ASSERT(geometry != nullptr);
+ if (height != 0) {
+ geometry->setAltitudeMode(RelativeToGround);
+ }
OsmObjectManager::registerId(m_osmData.id());
@@ -180,4 +195,27 @@ bool OsmWay::isAreaTag(const StyleBuilder::OsmTag &keyValue)
return s_areaTags.contains(keyValue);
}
+double OsmWay::extractBuildingHeight(const OsmPlacemarkData &osmData)
+{
+ double height = 8.0;
+
+ QHash<QString, QString>::const_iterator tagIter;
+ if ((tagIter = osmData.findTag(QStringLiteral("height"))) != osmData.tagsEnd()) {
+ /** @todo Also parse non-SI units, see https://wiki.openstreetmap.org/wiki/Key:height#Height_of_buildings */
+ QString const heightValue = QString(tagIter.value()).remove(QStringLiteral(" meters")).remove(QStringLiteral(" m"));
+ bool extracted = false;
+ double extractedHeight = heightValue.toDouble(&extracted);
+ if (extracted) {
+ height = extractedHeight;
+ }
+ } else if ((tagIter = osmData.findTag(QStringLiteral("building:levels"))) != osmData.tagsEnd()) {
+ int const levels = tagIter.value().toInt();
+ int const skipLevels = osmData.tagValue(QStringLiteral("building:min_level")).toInt();
+ /** @todo Is 35 as an upper bound for the number of levels sane? */
+ height = 3.0 * qBound(1, 1+levels-skipLevels, 35);
+ }
+
+ return qBound(1.0, height, 1000.0);
+}
+
}
diff --git a/src/plugins/runner/osm/OsmWay.h b/src/plugins/runner/osm/OsmWay.h
index 3a9efa0..7672ba6 100644
--- a/src/plugins/runner/osm/OsmWay.h
+++ b/src/plugins/runner/osm/OsmWay.h
@@ -38,6 +38,8 @@ private:
static bool isAreaTag(const StyleBuilder::OsmTag &keyValue);
+ static double extractBuildingHeight(const OsmPlacemarkData &osmData);
+
OsmPlacemarkData m_osmData;
QVector<qint64> m_references;