Commit 2e5a6e34 authored by Bernhard Beschow's avatar Bernhard Beschow
Browse files

Revert "set the bboxe's height to the building height and use that for building rendering"

This reverts commit e2e3e198.
parent 91d07d77
......@@ -14,7 +14,6 @@
#include "ViewportParams.h"
#include "GeoDataTypes.h"
#include "GeoDataPlacemark.h"
#include "GeoDataLatLonAltBox.h"
#include "GeoDataLinearRing.h"
#include "GeoDataPolygon.h"
#include "GeoDataIconStyle.h"
......@@ -28,7 +27,7 @@ namespace Marble
BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark,
const GeoDataPolygon *polygon)
: AbstractGeoPolygonGraphicsItem(placemark, polygon)
, m_buildingHeight(polygon->latLonAltBox().maxAltitude() - polygon->latLonAltBox().minAltitude())
, m_buildingHeight(extractBuildingHeight(*placemark))
, m_buildingLabel(extractBuildingLabel(*placemark))
, m_entries(extractNamedEntries(*placemark))
{
......@@ -44,7 +43,7 @@ BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const GeoDataPlac
BuildingGeoPolygonGraphicsItem::BuildingGeoPolygonGraphicsItem(const GeoDataPlacemark *placemark,
const GeoDataLinearRing* ring)
: AbstractGeoPolygonGraphicsItem(placemark, ring)
, m_buildingHeight(ring->latLonAltBox().maxAltitude() - ring->latLonAltBox().minAltitude())
, m_buildingHeight(extractBuildingHeight(*placemark))
, m_buildingLabel(extractBuildingLabel(*placemark))
, m_entries(extractNamedEntries(*placemark))
{
......@@ -135,6 +134,31 @@ 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()) {
......
......@@ -46,6 +46,7 @@ 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);
......
......@@ -25,8 +25,6 @@ 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;
......@@ -45,12 +43,7 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint6
usedNodes << nodeId;
}
linearRing = GeoDataLinearRing(linearRing.optimized());
if (!linearRing.isEmpty() && height != 0) {
linearRing.first().setAltitude(height);
}
geometry = new GeoDataLinearRing(linearRing);
geometry = new GeoDataLinearRing(linearRing.optimized());
} else {
GeoDataLineString lineString;
......@@ -66,18 +59,10 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint6
usedNodes << nodeId;
}
lineString = lineString.optimized();
if (!lineString.isEmpty() && height != 0) {
lineString.first().setAltitude(height);
}
geometry = new GeoDataLineString(lineString);
geometry = new GeoDataLineString(lineString.optimized());
}
Q_ASSERT(geometry != nullptr);
if (height != 0) {
geometry->setAltitudeMode(RelativeToGround);
}
OsmObjectManager::registerId(m_osmData.id());
......@@ -195,27 +180,4 @@ 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);
}
}
......@@ -39,8 +39,6 @@ private:
static bool isAreaTag(const StyleBuilder::OsmTag &keyValue);
static double extractBuildingHeight(const OsmPlacemarkData &osmData);
OsmPlacemarkData m_osmData;
QVector<qint64> m_references;
......
Supports Markdown
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