summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kolozsvari <[email protected]>2015-08-26 18:47:22 +0200
committerDavid Kolozsvari <[email protected]>2015-08-26 18:47:22 +0200
commitb1b0d5a000603b1ffca84ea746ea7497b2a7377a (patch)
tree989c4dc514e1590443814e0a058e00dfcb28ea1e
parent92d9e282763763eab18d852002a078c8863883ef (diff)
GSoC: Implemented decorations and street label placement for OSM Vector rendering.
REVIEW: 124511
-rw-r--r--src/lib/marble/GeoPainter.cpp105
-rw-r--r--src/lib/marble/GeoPainter.h3
-rw-r--r--src/lib/marble/GeoPainter_p.h11
-rw-r--r--src/lib/marble/MarbleGlobal.h3
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature.cpp64
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature.h4
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature_p.h23
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp41
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.h3
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp179
-rw-r--r--src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h6
-rw-r--r--src/lib/marble/graphicsview/GeoGraphicsItem.cpp53
-rw-r--r--src/lib/marble/graphicsview/GeoGraphicsItem.h17
-rw-r--r--src/lib/marble/graphicsview/GeoGraphicsItem_p.h6
-rw-r--r--src/lib/marble/layers/GeometryLayer.cpp45
-rw-r--r--src/lib/marble/osm/OsmPresetLibrary.cpp9
16 files changed, 491 insertions, 81 deletions
diff --git a/src/lib/marble/GeoPainter.cpp b/src/lib/marble/GeoPainter.cpp
index d04138c..f901b86 100644
--- a/src/lib/marble/GeoPainter.cpp
+++ b/src/lib/marble/GeoPainter.cpp
@@ -14,6 +14,7 @@
#include <QList>
#include <QPainterPath>
#include <QRegion>
+#include <qmath.h>
#include "MarbleDebug.h"
@@ -31,10 +32,11 @@
using namespace Marble;
-GeoPainterPrivate::GeoPainterPrivate( const ViewportParams *viewport, MapQuality mapQuality )
+GeoPainterPrivate::GeoPainterPrivate( GeoPainter* q, const ViewportParams *viewport, MapQuality mapQuality )
: m_viewport( viewport ),
m_mapQuality( mapQuality ),
- m_x( new qreal[100] )
+ m_x( new qreal[100] ),
+ m_parent(q)
{
}
@@ -174,11 +176,36 @@ bool GeoPainterPrivate::doClip( const ViewportParams *viewport )
return ( radius > viewport->width() / 2 || radius > viewport->height() / 2 );
}
+qreal GeoPainterPrivate::normalizeAngle(qreal angle)
+{
+// if (angle < 0.0) {
+// angle += 360.0*(static_cast<int>(-angle/360.0) + 1);
+// }
+// angle /= 360.0;
+// angle = (angle - qFloor(angle)) * 360.0;
+//
+// return angle;
+ angle = fmodf(angle, 360);
+ return angle < 0 ? angle + 360 : angle;
+}
+
+void GeoPainterPrivate::drawTextRotated( const QPointF &startPoint, qreal angle, const QString &text )
+{
+ QRectF textRect(startPoint, m_parent->fontMetrics().size( 0, text));
+ m_parent->save();
+ m_parent->translate(startPoint);
+ m_parent->rotate(angle);
+ m_parent->translate( -startPoint - QPointF(0.0, m_parent->fontMetrics().height()/2.0) );
+
+ m_parent->drawText( textRect, text);
+ m_parent->restore();
+}
+
// -------------------------------------------------------------------------------------------------
GeoPainter::GeoPainter( QPaintDevice* pd, const ViewportParams *viewport, MapQuality mapQuality )
: ClipPainter( pd, GeoPainterPrivate::doClip( viewport ) ),
- d( new GeoPainterPrivate( viewport, mapQuality ) )
+ d( new GeoPainterPrivate( this, viewport, mapQuality ) )
{
const bool antialiased = mapQuality == HighQuality || mapQuality == PrintQuality;
setRenderHint( QPainter::Antialiasing, antialiased );
@@ -485,7 +512,8 @@ void GeoPainter::drawPixmap ( const GeoDataCoordinates & centerPosition,
void GeoPainter::drawPolyline ( const GeoDataLineString & lineString,
const QString& labelText,
- LabelPositionFlags labelPositionFlags )
+ LabelPositionFlags labelPositionFlags,
+ const QColor& labelColor,const QFont& labelFont)
{
// Immediately leave this method now if:
// - the object is not visible in the viewport or if
@@ -506,7 +534,74 @@ void GeoPainter::drawPolyline ( const GeoDataLineString & lineString,
ClipPainter::drawPolyline( *itPolygon );
}
}
- else {
+ else if ( labelPositionFlags.testFlag( FollowLine ) ) {
+ const qreal maximumLabelFontSize = 20;
+ qreal fontSize = pen().widthF() * 0.45;
+ fontSize = qMin( fontSize, maximumLabelFontSize );
+ QFont font = labelFont;
+ font.setPointSizeF(fontSize);
+
+ QVector<QPointF> labelNodes;
+ foreach( QPolygonF* itPolygon, polygons ) {
+ QPainterPath path;
+ path.addPolygon(*itPolygon);
+
+ labelNodes.clear();
+ ClipPainter::drawPolyline( *itPolygon, labelNodes, labelPositionFlags );
+
+ save();
+ setPen(labelColor);
+ setFont(font);
+
+ int labelWidth = fontMetrics().width( labelText );
+ int maxNumLabels = static_cast<int>(path.length() / labelWidth);
+
+ if (fontSize >= 6.0 && maxNumLabels > 0) {
+ qreal textRelativeLength = labelWidth / path.length();
+ int numLabels = 1;
+ if (maxNumLabels > 1) {
+ numLabels = maxNumLabels/2;
+ }
+ qreal offset = (1.0 - numLabels*textRelativeLength)/numLabels;
+ qreal startPercent = offset/2.0;
+
+ for (int k = 0; k < numLabels; ++k, startPercent += textRelativeLength + offset) {
+ QPointF point = path.pointAtPercent(startPercent);
+
+ if ( viewport().contains(point.toPoint()) ) {
+ qreal angle = -path.angleAtPercent(startPercent);
+ qreal angle2 = -path.angleAtPercent(startPercent + textRelativeLength);
+ angle = GeoPainterPrivate::normalizeAngle(angle);
+ bool flipped = angle > 90.0 && angle < 270.0;
+
+ if ( qAbs(angle - angle2) < 3.0 ) {
+ if ( flipped ) {
+ angle += 180.0;
+ point = path.pointAtPercent(startPercent + textRelativeLength);
+ }
+
+ d->drawTextRotated(point, angle, labelText);
+ } else {
+ for (int i = 0; i < labelText.length(); ++i) {
+ qreal currentGlyphTextLength = fontMetrics().width(labelText.left(i)) / path.length();
+
+ angle = -path.angleAtPercent(startPercent + currentGlyphTextLength);
+ point = path.pointAtPercent(startPercent + currentGlyphTextLength);
+
+ if ( flipped ) {
+ angle += 180.0;
+ point = path.pointAtPercent(startPercent + textRelativeLength - currentGlyphTextLength);
+ }
+
+ d->drawTextRotated(point, angle, labelText[i]);
+ }
+ }
+ }
+ }
+ }
+ restore();
+ }
+ } else {
int labelWidth = fontMetrics().width( labelText );
int labelAscent = fontMetrics().ascent();
diff --git a/src/lib/marble/GeoPainter.h b/src/lib/marble/GeoPainter.h
index 7a757b9..0c9303e 100644
--- a/src/lib/marble/GeoPainter.h
+++ b/src/lib/marble/GeoPainter.h
@@ -308,7 +308,8 @@ class MARBLE_EXPORT GeoPainter : public ClipPainter
*/
void drawPolyline ( const GeoDataLineString & lineString,
const QString& labelText = QString(),
- LabelPositionFlags labelPositionFlags = LineCenter );
+ LabelPositionFlags labelPositionFlags = LineCenter,
+ const QColor& labelcolor = Qt::black, const QFont& labelFont = QFont("Arial"));
/*!
diff --git a/src/lib/marble/GeoPainter_p.h b/src/lib/marble/GeoPainter_p.h
index f0c4f9b..412abe2 100644
--- a/src/lib/marble/GeoPainter_p.h
+++ b/src/lib/marble/GeoPainter_p.h
@@ -14,6 +14,7 @@
#include <QVector>
#include "MarbleGlobal.h"
+//#include "GeoPainter.h"
class QPolygonF;
class QSizeF;
@@ -25,11 +26,12 @@ namespace Marble
class ViewportParams;
class GeoDataCoordinates;
+class GeoPainter;
class GeoPainterPrivate
{
public:
- GeoPainterPrivate( const ViewportParams *viewport, MapQuality mapQuality );
+ GeoPainterPrivate( GeoPainter* q, const ViewportParams *viewport, MapQuality mapQuality );
~GeoPainterPrivate();
@@ -45,9 +47,16 @@ class GeoPainterPrivate
static bool doClip( const ViewportParams *viewport );
+ static qreal normalizeAngle(qreal angle);
+
+ void drawTextRotated( const QPointF &startPoint, qreal angle, const QString &text );
+
const ViewportParams *const m_viewport;
const MapQuality m_mapQuality;
qreal *const m_x;
+
+private:
+ GeoPainter* m_parent;
};
} // namespace Marble
diff --git a/src/lib/marble/MarbleGlobal.h b/src/lib/marble/MarbleGlobal.h
index 8ba5b2d..bf676f8 100644
--- a/src/lib/marble/MarbleGlobal.h
+++ b/src/lib/marble/MarbleGlobal.h
@@ -118,7 +118,8 @@ enum LabelPositionFlag {
LineCenter = 0x2,
LineEnd = 0x4,
IgnoreXMargin = 0x8,
- IgnoreYMargin = 0x10
+ IgnoreYMargin = 0x10,
+ FollowLine = 0x20
};
Q_DECLARE_FLAGS(LabelPositionFlags, LabelPositionFlag)
diff --git a/src/lib/marble/geodata/data/GeoDataFeature.cpp b/src/lib/marble/geodata/data/GeoDataFeature.cpp
index 227f756..68aec91 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature.cpp
+++ b/src/lib/marble/geodata/data/GeoDataFeature.cpp
@@ -418,33 +418,38 @@ void GeoDataFeaturePrivate::initializeDefaultStyles()
s_defaultStyle[GeoDataFeature::ReligionSikh] = GeoDataFeaturePrivate::createOsmPOIStyle( osmFont, "place_of_worship_sikh3.p.16" );
s_defaultStyle[GeoDataFeature::HighwaySteps] = GeoDataFeaturePrivate::createStyle( 1, 5, "#F98072", "#F98072", true, true,
- Qt::SolidPattern, Qt::CustomDashLine, Qt::FlatCap,
+ Qt::SolidPattern, Qt::CustomDashLine, Qt::FlatCap,
false, QVector< qreal >() << 0.2 << 0.2 );
- s_defaultStyle[GeoDataFeature::HighwayUnknown] = GeoDataFeaturePrivate::createHighwayStyle( "highway_unclassified", "#808080" );
- s_defaultStyle[GeoDataFeature::HighwayPath] = GeoDataFeaturePrivate::createHighwayStyle( "highway_path", "#F98072", 1.0, 2, Qt::DashLine );
- s_defaultStyle[GeoDataFeature::HighwayTrack] = GeoDataFeaturePrivate::createHighwayStyle( "highway_track", "#986600", 1.0, 3, Qt::DashLine );
- s_defaultStyle[GeoDataFeature::HighwayPedestrian] = GeoDataFeaturePrivate::createHighwayStyle( "highway_footway", "#F98072", 1.0, 2, Qt::DashLine );
- s_defaultStyle[GeoDataFeature::HighwayService] = GeoDataFeaturePrivate::createHighwayStyle( "highway_unclassified", "#FEFEFE", 1.0, 6 );
- s_defaultStyle[GeoDataFeature::HighwayRoad] = GeoDataFeaturePrivate::createHighwayStyle( "highway_unclassified", "#FEFEFE", 1.5, 9 );
- s_defaultStyle[GeoDataFeature::HighwayTertiary] = GeoDataFeaturePrivate::createHighwayStyle( "highway_tertiary", "#FEFEB3", 2.0, 11 );
- s_defaultStyle[GeoDataFeature::HighwaySecondary] = GeoDataFeaturePrivate::createHighwayStyle( "highway_secondary", "#FDD6A4", 2.0, 13 );
- s_defaultStyle[GeoDataFeature::HighwayPrimary] = GeoDataFeaturePrivate::createHighwayStyle( "highway_primary", "#EB989A", 3.0, 15 );
- s_defaultStyle[GeoDataFeature::HighwayTrunk] = GeoDataFeaturePrivate::createHighwayStyle( "highway_trunk", "#A9DAA9", 3.0, 18 );
- s_defaultStyle[GeoDataFeature::HighwayMotorway] = GeoDataFeaturePrivate::createHighwayStyle( "highway_motorway", "#809BC0", 3.0, 20 );
-
- s_defaultStyle[GeoDataFeature::HighwayTertiaryLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_tertiary", "#FEFEB3", 2.0, 9 );
- s_defaultStyle[GeoDataFeature::HighwaySecondaryLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_secondary", "#FDD6A4", 2.0, 11 );
- s_defaultStyle[GeoDataFeature::HighwayPrimaryLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_primary", "#EB989A", 2.0, 13 );
- s_defaultStyle[GeoDataFeature::HighwayTrunkLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_trunk", "#A9DAA9", 3.0, 15 );
- s_defaultStyle[GeoDataFeature::HighwayMotorwayLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_motorway", "#809BC0", 3.0, 18 );
-
- s_defaultStyle[GeoDataFeature::NaturalWater] = GeoDataFeaturePrivate::createStyle( 2, 10, "#B5D0D0", "#B5D0D0",
- true, true, Qt::SolidPattern, Qt::SolidLine, Qt::RoundCap, false );
+ s_defaultStyle[GeoDataFeature::HighwayUnknown] = GeoDataFeaturePrivate::createHighwayStyle( "highway_unknown", "#808080", QColor("#808080").darker(150));
+ s_defaultStyle[GeoDataFeature::HighwayPath] = GeoDataFeaturePrivate::createHighwayStyle( "highway_path", "#ECECEC", "#F49B8C", QFont("Arial"), "000000", 1.0, 2, Qt::DotLine, Qt::RoundCap, true);
+ s_defaultStyle[GeoDataFeature::HighwayTrack] = GeoDataFeaturePrivate::createHighwayStyle( "highway_track", "#ECECEC", "#A27F38", QFont("Arial"), "000000", 1.0, 2, Qt::DashDotLine, Qt::RoundCap, true );
+ s_defaultStyle[GeoDataFeature::HighwayPedestrian] = GeoDataFeaturePrivate::createHighwayStyle( "highway_pedestrian", "#EBEBEB", QColor("#EBEBEB").darker(150), QFont("Arial"), "000000", 1.5, 9);
+ s_defaultStyle[GeoDataFeature::HighwayFootway] = GeoDataFeaturePrivate::createHighwayStyle( "highway_footway", "#ECECEC", "#F49B8C", QFont("Arial"), "000000", 1.0, 2, Qt::DotLine, Qt::RoundCap, true);
+ s_defaultStyle[GeoDataFeature::HighwayCycleway] = GeoDataFeaturePrivate::createHighwayStyle( "highway_cycleway", "#ECECEC", "#4B5CAD", QFont("Arial"), "000000", 1.0, 2, Qt::DotLine, Qt::RoundCap, true);
+ s_defaultStyle[GeoDataFeature::HighwayService] = GeoDataFeaturePrivate::createHighwayStyle( "highway_service", "#FEFEFE", QColor("#FEFEFE").darker(150), QFont("Arial"), "000000", 1.0, 6 );
+ s_defaultStyle[GeoDataFeature::HighwayLivingStreet] = GeoDataFeaturePrivate::createHighwayStyle( "highway_living_street", "#CCCCCC", QColor("#CCCCCC").darker(150), QFont("Arial"), "000000", 1.5, 9 );
+ s_defaultStyle[GeoDataFeature::HighwayRoad] = GeoDataFeaturePrivate::createHighwayStyle( "highway_road", "#DCDCDC", QColor("#DCDCDC").darker(150), QFont("Arial"), "000000", 1.5, 9 );
+ s_defaultStyle[GeoDataFeature::HighwayUnclassified] = GeoDataFeaturePrivate::createHighwayStyle( "highway_unclassified", "#FEFEFE", QColor("#FEFEFE").darker(150), QFont("Arial"), "000000", 1.5, 9 );
+ s_defaultStyle[GeoDataFeature::HighwayTertiary] = GeoDataFeaturePrivate::createHighwayStyle( "highway_tertiary", "#F8F8BA", QColor("#F8F8BA").darker(150), QFont("Arial"), "000000", 2.0, 11 );
+ s_defaultStyle[GeoDataFeature::HighwaySecondary] = GeoDataFeaturePrivate::createHighwayStyle( "highway_secondary", "#F8D6AA", QColor("#F8D6AA").darker(150), QFont("Arial"), "000000", 2.0, 13 );
+ s_defaultStyle[GeoDataFeature::HighwayPrimary] = GeoDataFeaturePrivate::createHighwayStyle( "highway_primary", "#EB989A", QColor("#EB989A").darker(150), QFont("Arial"), "000000", 3.0, 15 );
+ s_defaultStyle[GeoDataFeature::HighwayTrunk] = GeoDataFeaturePrivate::createHighwayStyle( "highway_trunk", "#94D494", QColor("#94D494").darker(150), QFont("Arial"), "000000", 3.0, 18 );
+ s_defaultStyle[GeoDataFeature::HighwayMotorway] = GeoDataFeaturePrivate::createHighwayStyle( "highway_motorway", "#809BC0", QColor("#809BC0").darker(150), QFont("Arial"), "000000", 3.0, 20 );
+
+ s_defaultStyle[GeoDataFeature::HighwayTertiaryLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_tertiary", "#F8F8BA", QColor("#F8F8BA").darker(150), QFont("Arial"), "000000", 2.0, 9 );
+ s_defaultStyle[GeoDataFeature::HighwaySecondaryLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_secondary", "#F8D6AA", QColor("#F8D6AA").darker(150), QFont("Arial"), "000000", 2.0, 11 );
+ s_defaultStyle[GeoDataFeature::HighwayPrimaryLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_primary", "#EB989A", QColor("#EB989A").darker(150), QFont("Arial"), "000000", 2.0, 13 );
+ s_defaultStyle[GeoDataFeature::HighwayTrunkLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_trunk", "#94D494", QColor("#94D494").darker(150), QFont("Arial"), "000000", 3.0, 15 );
+ s_defaultStyle[GeoDataFeature::HighwayMotorwayLink] = GeoDataFeaturePrivate::createHighwayStyle( "highway_motorway", "#809BC0", QColor("#809BC0").darker(150), QFont("Arial"), "000000", 3.0, 18 );
+
+ s_defaultStyle[GeoDataFeature::NaturalWater] = GeoDataFeaturePrivate::createStyle( 2, 10, "#B5D0D0", "#B5D0D0", true, true,
+ Qt::SolidPattern, Qt::SolidLine, Qt::RoundCap, false, QVector< qreal >(),
+ QFont("Arial"), QColor("#B5D0D0").darker(150));
s_defaultStyle[GeoDataFeature::NaturalWood] = GeoDataFeaturePrivate::createWayStyle( "#8DC46C", "#8DC46C" );
-
+
s_defaultStyle[GeoDataFeature::LeisurePark] = GeoDataFeaturePrivate::createWayStyle( "#CDF6CA", "#CDF6CA" );
-
+
s_defaultStyle[GeoDataFeature::LanduseAllotments] = GeoDataFeaturePrivate::createWayStyle( "#E4C6AA", "#E4C6AA" );
s_defaultStyle[GeoDataFeature::LanduseBasin] = GeoDataFeaturePrivate::createWayStyle( QColor(0xB5, 0xD0, 0xD0, 0x80 ), QColor( 0xB5, 0xD0, 0xD0 ) );
s_defaultStyle[GeoDataFeature::LanduseCemetery] = GeoDataFeaturePrivate::createWayStyle( "#A9C9AE", "#A9C9AE" );
@@ -463,15 +468,16 @@ void GeoDataFeaturePrivate::initializeDefaultStyles()
s_defaultStyle[GeoDataFeature::LanduseReservoir] = GeoDataFeaturePrivate::createWayStyle( "#B5D0D0", "#B5D0D0" );
s_defaultStyle[GeoDataFeature::LanduseResidential] = GeoDataFeaturePrivate::createWayStyle( "#DCDCDC", "#DCDCDC" );
s_defaultStyle[GeoDataFeature::LanduseRetail] = GeoDataFeaturePrivate::createWayStyle( Qt::transparent, Qt::transparent, false, false );
-
- s_defaultStyle[GeoDataFeature::RailwayRail] = GeoDataFeaturePrivate::createStyle( 2, 5, "#989898", "#E1E1E1", true, true, Qt::SolidPattern, Qt::DashLine, Qt::FlatCap, true );
- s_defaultStyle[GeoDataFeature::RailwayTram] = GeoDataFeaturePrivate::createStyle( 1, 4, "#989898", "#989898", true, true, Qt::SolidPattern, Qt::SolidLine, Qt::RoundCap, false );
+
+ s_defaultStyle[GeoDataFeature::RailwayRail] = GeoDataFeaturePrivate::createStyle( 2, 5, "#706E70", "#EEEEEE", true, true, Qt::SolidPattern, Qt::CustomDashLine, Qt::FlatCap, true,
+ QVector< qreal >() << 2 << 3 );
+ s_defaultStyle[GeoDataFeature::RailwayTram] = GeoDataFeaturePrivate::createStyle( 1, 4, "#706E70", "#706E70", true, true, Qt::SolidPattern, Qt::SolidLine, Qt::RoundCap, false );
s_defaultStyle[GeoDataFeature::RailwayLightRail] = GeoDataFeaturePrivate::createWayStyle( Qt::transparent, Qt::transparent, false, false );
- s_defaultStyle[GeoDataFeature::RailwayAbandoned] = GeoDataFeaturePrivate::createStyle( 2, 5, Qt::transparent, "#989898", false, false, Qt::SolidPattern, Qt::DotLine, Qt::FlatCap, false );
+ s_defaultStyle[GeoDataFeature::RailwayAbandoned] = GeoDataFeaturePrivate::createStyle( 2, 5, Qt::transparent, "#706E70", false, false, Qt::SolidPattern, Qt::DotLine, Qt::FlatCap, false );
s_defaultStyle[GeoDataFeature::RailwaySubway] = GeoDataFeaturePrivate::createWayStyle( Qt::transparent, Qt::transparent, false, false );
- s_defaultStyle[GeoDataFeature::RailwayPreserved] = GeoDataFeaturePrivate::createStyle( 2, 5, "#E1E1E1", "#989898", true, true, Qt::SolidPattern, Qt::DotLine, Qt::FlatCap, true );
+ s_defaultStyle[GeoDataFeature::RailwayPreserved] = GeoDataFeaturePrivate::createStyle( 2, 5, "#EEEEEE", "#706E70", true, true, Qt::SolidPattern, Qt::DotLine, Qt::FlatCap, true );
s_defaultStyle[GeoDataFeature::RailwayMiniature] = GeoDataFeaturePrivate::createWayStyle( Qt::transparent, Qt::transparent, false, false );
- s_defaultStyle[GeoDataFeature::RailwayConstruction] = GeoDataFeaturePrivate::createStyle( 2, 5, "#E1E1E1", "#989898", true, true, Qt::SolidPattern, Qt::DotLine, Qt::FlatCap, true );
+ s_defaultStyle[GeoDataFeature::RailwayConstruction] = GeoDataFeaturePrivate::createStyle( 2, 5, "#EEEEEE", "#706E70", true, true, Qt::SolidPattern, Qt::DotLine, Qt::FlatCap, true );
s_defaultStyle[GeoDataFeature::RailwayMonorail] = GeoDataFeaturePrivate::createWayStyle( Qt::transparent, Qt::transparent, false, false );
s_defaultStyle[GeoDataFeature::RailwayFunicular] = GeoDataFeaturePrivate::createWayStyle( Qt::transparent, Qt::transparent, false, false );
diff --git a/src/lib/marble/geodata/data/GeoDataFeature.h b/src/lib/marble/geodata/data/GeoDataFeature.h
index 06d4dcb..9cc0e70 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature.h
+++ b/src/lib/marble/geodata/data/GeoDataFeature.h
@@ -142,10 +142,14 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
HighwaySteps,
HighwayUnknown,
HighwayPath,
+ HighwayFootway,
HighwayTrack,
HighwayPedestrian,
+ HighwayCycleway,
HighwayService,
HighwayRoad,
+ HighwayLivingStreet,
+ HighwayUnclassified,
HighwayTertiaryLink,
HighwayTertiary,
HighwaySecondaryLink,
diff --git a/src/lib/marble/geodata/data/GeoDataFeature_p.h b/src/lib/marble/geodata/data/GeoDataFeature_p.h
index db1ee90..998557c 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature_p.h
+++ b/src/lib/marble/geodata/data/GeoDataFeature_p.h
@@ -137,11 +137,16 @@ class GeoDataFeaturePrivate
return style;
}
- static GeoDataStyle* createHighwayStyle( const QString &bitmap, const QColor& color, qreal width = 1, qreal realWidth = 0.0,
- Qt::PenStyle penStyle = Qt::SolidLine,
- Qt::PenCapStyle capStyle = Qt::RoundCap )
+ static GeoDataStyle* createHighwayStyle( const QString &bitmap, const QColor& color, const QColor& outlineColor,
+ const QFont& font = QFont("Arial"), const QColor& fontColor = Qt::black,
+ qreal width = 1, qreal realWidth = 0.0,
+ Qt::PenStyle penStyle = Qt::SolidLine,
+ Qt::PenCapStyle capStyle = Qt::RoundCap,
+ bool lineBackground = false)
{
- GeoDataStyle *style = createStyle( width, realWidth, color, color, true, true, Qt::SolidPattern, penStyle, capStyle, false );
+ GeoDataStyle *style = createStyle( width, realWidth, color, outlineColor, true, true,
+ Qt::SolidPattern, penStyle, capStyle, lineBackground, QVector< qreal >(),
+ font, fontColor );
if( !bitmap.isEmpty() ) {
style->setIconStyle( GeoDataIconStyle( MarbleDirs::path( "bitmaps/" + bitmap + ".png" ) ) );
}
@@ -155,12 +160,12 @@ class GeoDataFeaturePrivate
return createStyle( 1, 0, color, outlineColor, fill, outline, brushStyle, Qt::SolidLine, Qt::RoundCap, false );
}
- static GeoDataStyle* createStyle( qreal width, qreal realWidth, const QColor& color,
+ static GeoDataStyle* createStyle( qreal width, qreal realWidth, const QColor& color,
const QColor& outlineColor, bool fill, bool outline,
- Qt::BrushStyle brushStyle, Qt::PenStyle penStyle,
+ Qt::BrushStyle brushStyle, Qt::PenStyle penStyle,
Qt::PenCapStyle capStyle, bool lineBackground,
- const QVector< qreal >& dashPattern = QVector< qreal >()
- )
+ const QVector< qreal >& dashPattern = QVector< qreal >(),
+ const QFont& font = QFont("Arial"), const QColor& fontColor = Qt::black)
{
GeoDataStyle *style = new GeoDataStyle;
GeoDataLineStyle lineStyle( outlineColor );
@@ -174,8 +179,10 @@ class GeoDataFeaturePrivate
polyStyle.setOutline( outline );
polyStyle.setFill( fill );
polyStyle.setBrushStyle( brushStyle );
+ GeoDataLabelStyle labelStyle(font, fontColor);
style->setLineStyle( lineStyle );
style->setPolyStyle( polyStyle );
+ style->setLabelStyle( labelStyle );
return style;
}
diff --git a/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp b/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp
index 4320c07..8db0f9f 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp
+++ b/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.cpp
@@ -19,12 +19,28 @@
namespace Marble
{
-GeoLineStringGraphicsItem::GeoLineStringGraphicsItem( const GeoDataFeature *feature, const GeoDataLineString* lineString )
+GeoLineStringGraphicsItem::GeoLineStringGraphicsItem( const GeoDataFeature *feature,
+ const GeoDataLineString* lineString )
: GeoGraphicsItem( feature ),
m_lineString( lineString )
{
}
+
+const float GeoLineStringGraphicsItem::s_outlineZValue = -0.001;
+
+void GeoLineStringGraphicsItem::createDecorations()
+{
+ if ( style() != nullptr ) {
+ if ( style()->polyStyle().outline() ) {
+ GeoLineStringGraphicsItem* outline = new GeoLineStringGraphicsItem(this->feature(), this->m_lineString);
+ outline->setZValue(this->zValue() + s_outlineZValue);
+
+ this->addDecoration(outline);
+ }
+ }
+}
+
void GeoLineStringGraphicsItem::setLineString( const GeoDataLineString* lineString )
{
m_lineString = lineString;
@@ -41,11 +57,11 @@ void GeoLineStringGraphicsItem::paint( GeoPainter* painter, const ViewportParams
painter->save();
+ QPen currentPen = painter->pen();
if ( !style() ) {
painter->setPen( QPen() );
}
else {
- QPen currentPen = painter->pen();
if ( currentPen.color() != style()->lineStyle().paintedColor() )
currentPen.setColor( style()->lineStyle().paintedColor() );
@@ -101,7 +117,26 @@ void GeoLineStringGraphicsItem::paint( GeoPainter* painter, const ViewportParams
}
}
- painter->drawPolyline( *m_lineString, feature()->name(), labelPositionFlags );
+ if ( ! ( isDecoration() && currentPen.widthF() < 2.5f ) )
+ {
+ if( style()->polyStyle().outline() &&
+ style()->lineStyle().penStyle() == Qt::SolidLine ) {
+ if ( isDecoration() ) {
+ painter->drawPolyline( *m_lineString, "", NoLabel );
+ } else {
+ if ( currentPen.widthF() > 2.5f ) {
+ currentPen.setWidthF( currentPen.widthF() - 2.0f );
+ }
+ currentPen.setColor( style()->polyStyle().paintedColor() );
+ painter->setPen( currentPen );
+ painter->drawPolyline( *m_lineString, feature()->name(), FollowLine,
+ style()->labelStyle().paintedColor(),
+ style()->labelStyle().font());
+ }
+ } else {
+ painter->drawPolyline( *m_lineString, feature()->name(), labelPositionFlags );
+ }
+ }
painter->restore();
}
diff --git a/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.h b/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.h
index 4842809..e49f302 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.h
+++ b/src/lib/marble/geodata/graphicsitem/GeoLineStringGraphicsItem.h
@@ -33,6 +33,9 @@ public:
protected:
const GeoDataLineString *m_lineString;
+ static const float s_outlineZValue;
+
+ virtual void createDecorations();
};
}
diff --git a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
index 81cfe9a..d41f052 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
+++ b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.cpp
@@ -16,6 +16,9 @@
#include "ViewportParams.h"
#include "GeoDataStyle.h"
+#include <QVector2D>
+#include <QtCore/qmath.h>
+
namespace Marble
{
@@ -33,6 +36,94 @@ GeoPolygonGraphicsItem::GeoPolygonGraphicsItem( const GeoDataFeature *feature, c
{
}
+const float GeoPolygonGraphicsItem::s_decorationZValue = -0.001;
+
+void GeoPolygonGraphicsItem::createDecorations()
+{
+ if (isDecoration()) {
+ return;
+ }
+
+ GeoPolygonGraphicsItem *fake3D;
+
+ switch ( feature()->visualCategory() ) {
+ case GeoDataFeature::Building:
+ //case GeoDataFeature::AccomodationCamping:
+ case GeoDataFeature::AccomodationHostel:
+ case GeoDataFeature::AccomodationHotel:
+ case GeoDataFeature::AccomodationMotel:
+ case GeoDataFeature::AccomodationYouthHostel:
+ case GeoDataFeature::AmenityLibrary:
+ case GeoDataFeature::EducationCollege:
+ case GeoDataFeature::EducationSchool:
+ case GeoDataFeature::EducationUniversity:
+ case GeoDataFeature::FoodBar:
+ case GeoDataFeature::FoodBiergarten:
+ case GeoDataFeature::FoodCafe:
+ case GeoDataFeature::FoodFastFood:
+ case GeoDataFeature::FoodPub:
+ case GeoDataFeature::FoodRestaurant:
+ case GeoDataFeature::HealthDoctors:
+ case GeoDataFeature::HealthHospital:
+ case GeoDataFeature::HealthPharmacy:
+ case GeoDataFeature::MoneyAtm:
+ case GeoDataFeature::MoneyBank:
+ case GeoDataFeature::ShoppingBeverages:
+ case GeoDataFeature::ShoppingHifi:
+ case GeoDataFeature::ShoppingSupermarket:
+ //case GeoDataFeature::TouristAttraction:
+ //case GeoDataFeature::TouristCastle:
+ case GeoDataFeature::TouristCinema:
+ //case GeoDataFeature::TouristMonument:
+ case GeoDataFeature::TouristMuseum:
+ //case GeoDataFeature::TouristRuin:
+ case GeoDataFeature::TouristTheatre:
+ //case GeoDataFeature::TouristThemePark:
+ //case GeoDataFeature::TouristViewPoint:
+ //case GeoDataFeature::TouristZoo:
+ case GeoDataFeature::ReligionPlaceOfWorship:
+ case GeoDataFeature::ReligionBahai:
+ case GeoDataFeature::ReligionBuddhist:
+ case GeoDataFeature::ReligionChristian:
+ case GeoDataFeature::ReligionHindu:
+ case GeoDataFeature::ReligionJain:
+ case GeoDataFeature::ReligionJewish:
+ case GeoDataFeature::ReligionShinto:
+ case GeoDataFeature::ReligionSikh:
+ fake3D = new GeoPolygonGraphicsItem( feature(), m_polygon );
+ fake3D->setZValue(this->zValue() + s_decorationZValue);
+ break;
+
+ default:
+ fake3D = nullptr;
+ break;
+ }
+
+ this->addDecoration(fake3D);
+}
+
+QPointF GeoPolygonGraphicsItem::buildingOffset(const QPointF &point, const ViewportParams *viewport) const
+{
+ qreal const cameraFactor = 0.5 * tan(0.5 * 110 * DEG2RAD);
+ qreal const buildingHeightMeter = 8.0;
+ qreal const buildingFactor = buildingHeightMeter / EARTH_RADIUS;
+
+ qreal const cameraHeightPixel = viewport->width() * cameraFactor;
+ qreal const buildingHeightPixel = viewport->radius() * buildingFactor;
+
+ qreal const offsetX = point.x() - viewport->width() / 2.0;
+ qreal const alpha1 = atan2(offsetX, cameraHeightPixel);
+ qreal const alpha2 = atan2(offsetX, cameraHeightPixel-buildingHeightPixel);
+ qreal const shiftX = 2 * (cameraHeightPixel-buildingHeightPixel) * sin(0.5*(alpha2-alpha1));
+
+ qreal const offsetY = point.y() - viewport->height() / 2.0;
+ qreal const beta1 = atan2(offsetY, cameraHeightPixel);
+ qreal const beta2 = atan2(offsetY, cameraHeightPixel-buildingHeightPixel);
+ qreal const shiftY = 2 * (cameraHeightPixel-buildingHeightPixel) * sin(0.5*(beta2-beta1));
+
+ return QPointF(shiftX, shiftY);
+}
+
const GeoDataLatLonAltBox& GeoPolygonGraphicsItem::latLonAltBox() const
{
if( m_polygon ) {
@@ -46,22 +137,23 @@ const GeoDataLatLonAltBox& GeoPolygonGraphicsItem::latLonAltBox() const
void GeoPolygonGraphicsItem::paint( GeoPainter* painter, const ViewportParams* viewport )
{
- Q_UNUSED( viewport );
-
painter->save();
+ bool const isBuildingFrame = isDecoration();
+ bool const isBuildingRoof = !isDecoration();
+
+ QPen currentPen = painter->pen();
+
if ( !style() ) {
painter->setPen( QPen() );
}
else {
- QPen currentPen = painter->pen();
-
- if ( !style()->polyStyle().outline() ) {
+ if ( !style()->polyStyle().outline() || isBuildingFrame ) {
currentPen.setColor( Qt::transparent );
}
else {
if ( currentPen.color() != style()->lineStyle().paintedColor() ||
- currentPen.widthF() != style()->lineStyle().width() ) {
+ currentPen.widthF() != style()->lineStyle().width() ) {
currentPen.setColor( style()->lineStyle().paintedColor() );
currentPen.setWidthF( style()->lineStyle().width() );
}
@@ -71,13 +163,6 @@ void GeoPolygonGraphicsItem::paint( GeoPainter* painter, const ViewportParams* v
if ( currentPen.style() != style()->lineStyle().penStyle() )
currentPen.setStyle( style()->lineStyle().penStyle() );
-
- if ( painter->mapQuality() != Marble::HighQuality
- && painter->mapQuality() != Marble::PrintQuality ) {
- QColor penColor = currentPen.color();
- penColor.setAlpha( 255 );
- currentPen.setColor( penColor );
- }
}
if ( painter->pen() != currentPen )
@@ -88,16 +173,74 @@ void GeoPolygonGraphicsItem::paint( GeoPainter* painter, const ViewportParams* v
painter->setBrush( QColor( Qt::transparent ) );
}
else {
- if ( painter->brush().color() != style()->polyStyle().paintedColor() ) {
+ if ( isBuildingFrame ) {
+ painter->setBrush( style()->polyStyle().paintedColor().darker(150) );
+ } else if ( painter->brush().color() != style()->polyStyle().paintedColor() ) {
painter->setBrush( style()->polyStyle().paintedColor() );
}
}
}
- if ( m_polygon ) {
- painter->drawPolygon( *m_polygon );
- } else if ( m_ring ) {
- painter->drawPolygon( *m_ring );
+ QPointF offsetAtCorner = buildingOffset(QPointF(0, 0), viewport);
+ qreal maxOffset = qMax( qAbs( offsetAtCorner.x() ), qAbs( offsetAtCorner.y() ) );
+ bool drawAccurate3D = maxOffset > 5.0;
+
+ if ( isBuildingFrame ) {
+ QVector<QPolygonF*> polygons;
+ if (m_polygon) {
+ viewport->screenCoordinates(m_polygon->outerBoundary(), polygons);
+ } else if (m_ring) {
+ viewport->screenCoordinates(*m_ring, polygons);
+ }
+ foreach(QPolygonF* polygon, polygons) {
+ if (polygon->isEmpty()) {
+ continue;
+ }
+ if ( drawAccurate3D ) {
+ int const size = polygon->size();
+ QPointF & a = (*polygon)[0];
+ QPointF shiftA = a + buildingOffset(a, viewport);
+ for (int i=1; i<size; ++i) {
+ QPointF const & b = (*polygon)[i];
+ QPointF const shiftB = b + buildingOffset(b, viewport);
+ QPolygonF buildingSide = QPolygonF() << a << shiftA << shiftB << b;
+ painter->drawPolygon(buildingSide);
+ a = b;
+ shiftA = shiftB;
+ }
+ } else {
+ painter->drawPolygon(*polygon);
+ }
+ }
+ qDeleteAll(polygons);
+ } else if (isBuildingRoof) {
+ QVector<QPolygonF*> polygons;
+ if (m_polygon) {
+ viewport->screenCoordinates(m_polygon->outerBoundary(), polygons);
+ } else if (m_ring) {
+ viewport->screenCoordinates(*m_ring, polygons);
+ }
+ foreach(QPolygonF* polygon, polygons) {
+ if ( drawAccurate3D) {
+ QPolygonF buildingRoof;
+ foreach(const QPointF &point, *polygon) {
+ buildingRoof << point + buildingOffset(point, viewport);
+ }
+ painter->drawPolygon(buildingRoof);
+ } else {
+ QPointF const offset = buildingOffset(polygon->boundingRect().center(), viewport);
+ painter->translate(offset);
+ painter->drawPolygon(*polygon);
+ }
+ }
+ qDeleteAll(polygons);
+ }
+ else {
+ if ( m_polygon ) {
+ painter->drawPolygon( *m_polygon );
+ } else if ( m_ring ) {
+ painter->drawPolygon( *m_ring );
+ }
}
painter->restore();
diff --git a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
index f469dfb..f71aad3 100644
--- a/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
+++ b/src/lib/marble/geodata/graphicsitem/GeoPolygonGraphicsItem.h
@@ -14,6 +14,8 @@
#include "GeoGraphicsItem.h"
#include "marble_export.h"
+class QPointF;
+
namespace Marble
{
@@ -31,8 +33,12 @@ public:
virtual void paint( GeoPainter* painter, const ViewportParams *viewport );
protected:
+ virtual void createDecorations();
+ QPointF buildingOffset(const QPointF &point, const ViewportParams *viewport) const;
+
const GeoDataPolygon *const m_polygon;
const GeoDataLinearRing *const m_ring;
+ static const float s_decorationZValue;
};
}
diff --git a/src/lib/marble/graphicsview/GeoGraphicsItem.cpp b/src/lib/marble/graphicsview/GeoGraphicsItem.cpp
index b8fa693..916c0a6 100644
--- a/src/lib/marble/graphicsview/GeoGraphicsItem.cpp
+++ b/src/lib/marble/graphicsview/GeoGraphicsItem.cpp
@@ -29,6 +29,7 @@ GeoGraphicsItem::GeoGraphicsItem( const GeoDataFeature *feature )
GeoGraphicsItem::~GeoGraphicsItem()
{
+ qDeleteAll< QList<GeoGraphicsItem*> >(p()->m_decorations);
delete p()->m_highlightStyle;
delete d;
}
@@ -41,6 +42,9 @@ bool GeoGraphicsItem::visible() const
void GeoGraphicsItem::setVisible( bool visible )
{
setFlag( ItemIsVisible, visible );
+ foreach( GeoGraphicsItem* decoration, p()->m_decorations ) {
+ decoration->setVisible( visible );
+ }
}
GeoGraphicsItem::GeoGraphicsItemFlags GeoGraphicsItem::flags() const
@@ -75,11 +79,17 @@ const GeoDataLatLonAltBox& GeoGraphicsItem::latLonAltBox() const
void GeoGraphicsItem::setLatLonAltBox( const GeoDataLatLonAltBox& latLonAltBox )
{
p()->m_latLonAltBox = latLonAltBox;
+ foreach( GeoGraphicsItem* decoration, p()->m_decorations ) {
+ decoration->setLatLonAltBox( latLonAltBox );
+ }
}
void GeoGraphicsItem::setStyle( const GeoDataStyle* style )
{
p()->m_style = style;
+ foreach( GeoGraphicsItem* decoration, p()->m_decorations ) {
+ decoration->setStyle( style );
+ }
}
void GeoGraphicsItem::setHighlightStyle( GeoDataStyle* highlightStyle)
@@ -90,6 +100,9 @@ void GeoGraphicsItem::setHighlightStyle( GeoDataStyle* highlightStyle)
*/
delete p()->m_highlightStyle;
p()->m_highlightStyle = highlightStyle;
+ foreach( GeoGraphicsItem* decoration, p()->m_decorations ) {
+ decoration->setHighlightStyle( highlightStyle );
+ }
}
const GeoDataStyle* GeoGraphicsItem::style() const
@@ -117,6 +130,9 @@ void GeoGraphicsItem::setZValue( qreal z )
void GeoGraphicsItem::setHighlighted( bool highlight )
{
p()->m_highlighted = highlight;
+ foreach( GeoGraphicsItem* decoration, p()->m_decorations ) {
+ decoration->setHighlighted( highlight );
+ }
}
bool GeoGraphicsItem::isHighlighted() const
@@ -142,5 +158,42 @@ int GeoGraphicsItem::minZoomLevel() const
void GeoGraphicsItem::setMinZoomLevel(int zoomLevel)
{
p()->m_minZoomLevel = zoomLevel;
+ foreach( GeoGraphicsItem* decoration, p()->m_decorations ) {
+ decoration->setMinZoomLevel( zoomLevel );
+ }
+}
+
+const QList<GeoGraphicsItem*>& GeoGraphicsItem::decorations()
+{
+ if ( p()->m_decorations.isEmpty() ) {
+ createDecorations();
+ }
+
+ return p()->m_decorations;
}
+void GeoGraphicsItem::addDecoration(GeoGraphicsItem* decoration)
+{
+ if (decoration != nullptr) {
+ decoration->p()->m_isDecoration = true;
+
+ decoration->setLatLonAltBox(this->latLonAltBox());
+ decoration->setFlags(this->flags());
+ decoration->setHighlighted(this->isHighlighted());
+ decoration->setStyle(this->style());
+ decoration->setMinZoomLevel(this->minZoomLevel());
+ decoration->setVisible(this->visible());
+
+ p()->m_decorations.append(decoration);
+ }
+}
+
+bool GeoGraphicsItem::isDecoration() const
+{
+ return p()->m_isDecoration;
+}
+
+void GeoGraphicsItem::createDecorations()
+{
+ return;
+}
diff --git a/src/lib/marble/graphicsview/GeoGraphicsItem.h b/src/lib/marble/graphicsview/GeoGraphicsItem.h
index 4ca4727..1f6f5d1 100644
--- a/src/lib/marble/graphicsview/GeoGraphicsItem.h
+++ b/src/lib/marble/graphicsview/GeoGraphicsItem.h
@@ -130,9 +130,26 @@ class MARBLE_EXPORT GeoGraphicsItem
bool isHighlighted() const;
+ const QList<GeoGraphicsItem*>& decorations();
+
+ bool isDecoration() const;
+
protected:
GeoGraphicsItemPrivate *const d;
+ /**
+ * Creates a new decoration for this item.
+ *
+ * Override this function to create a new type of decoration,
+ * e.g. outlines for lines or "fake 3D effect" for polygons.
+ * After a decoration was created add it to the item with
+ * addDecoration(). You can create multiple decoration for a
+ * single GeoGraphicsItem.
+ */
+ virtual void createDecorations();
+
+ void addDecoration(GeoGraphicsItem* decoration);
+
private:
GeoGraphicsItemPrivate *p();
const GeoGraphicsItemPrivate *p() const;
diff --git a/src/lib/marble/graphicsview/GeoGraphicsItem_p.h b/src/lib/marble/graphicsview/GeoGraphicsItem_p.h
index 01becfc..f6fa3f4 100644
--- a/src/lib/marble/graphicsview/GeoGraphicsItem_p.h
+++ b/src/lib/marble/graphicsview/GeoGraphicsItem_p.h
@@ -23,12 +23,13 @@ namespace Marble
class GeoGraphicsItemPrivate
{
public:
- explicit GeoGraphicsItemPrivate( const GeoDataFeature *feature )
+ explicit GeoGraphicsItemPrivate( const GeoDataFeature *feature)
: m_zValue( 0 ),
m_minZoomLevel( 0 ),
m_feature( feature ),
m_latLonAltBox(),
m_style( 0 ),
+ m_isDecoration( false ),
m_highlighted( false ),
m_highlightStyle( 0 )
{
@@ -46,6 +47,9 @@ class GeoGraphicsItemPrivate
GeoDataLatLonAltBox m_latLonAltBox;
const GeoDataStyle *m_style;
+ bool m_isDecoration;
+ QList<GeoGraphicsItem*> m_decorations;
+
// To highlight a placemark
bool m_highlighted;
GeoDataStyle *m_highlightStyle;
diff --git a/src/lib/marble/layers/GeometryLayer.cpp b/src/lib/marble/layers/GeometryLayer.cpp
index 11eca7d..23f2dd7 100644
--- a/src/lib/marble/layers/GeometryLayer.cpp
+++ b/src/lib/marble/layers/GeometryLayer.cpp
@@ -141,7 +141,7 @@ void GeometryLayerPrivate::initializeDefaultValues()
s_defaultZValues[GeoDataFeature::None] = 0;
for ( int i = GeoDataFeature::LanduseAllotments; i <= GeoDataFeature::LanduseRetail; i++ )
- s_defaultZValues[(GeoDataFeature::GeoDataVisualCategory)i] = s_defaultZValue - 16;
+ s_defaultZValues[(GeoDataFeature::GeoDataVisualCategory)i] = s_defaultZValue - 17;
s_defaultZValues[GeoDataFeature::NaturalWater] = s_defaultZValue - 16;
s_defaultZValues[GeoDataFeature::NaturalWood] = s_defaultZValue - 15;
@@ -152,19 +152,17 @@ void GeometryLayerPrivate::initializeDefaultValues()
s_defaultZValues[GeoDataFeature::TransportParking] = s_defaultZValue - 13;
- s_defaultZValues[GeoDataFeature::HighwayTertiaryLink] = s_defaultZValue - 12;
- s_defaultZValues[GeoDataFeature::HighwaySecondaryLink]= s_defaultZValue - 12;
- s_defaultZValues[GeoDataFeature::HighwayPrimaryLink] = s_defaultZValue - 12;
- s_defaultZValues[GeoDataFeature::HighwayTrunkLink] = s_defaultZValue - 12;
- s_defaultZValues[GeoDataFeature::HighwayMotorwayLink] = s_defaultZValue - 12;
-
s_defaultZValues[GeoDataFeature::HighwayUnknown] = s_defaultZValue - 11;
s_defaultZValues[GeoDataFeature::HighwayPath] = s_defaultZValue - 10;
s_defaultZValues[GeoDataFeature::HighwayTrack] = s_defaultZValue - 9;
s_defaultZValues[GeoDataFeature::HighwaySteps] = s_defaultZValue - 8;
- s_defaultZValues[GeoDataFeature::HighwayPedestrian] = s_defaultZValue - 8;
+ s_defaultZValues[GeoDataFeature::HighwayFootway] = s_defaultZValue - 8;
+ s_defaultZValues[GeoDataFeature::HighwayCycleway] = s_defaultZValue - 8;
s_defaultZValues[GeoDataFeature::HighwayService] = s_defaultZValue - 7;
+ s_defaultZValues[GeoDataFeature::HighwayLivingStreet] = s_defaultZValue - 7;
+ s_defaultZValues[GeoDataFeature::HighwayPedestrian] = s_defaultZValue - 6;
s_defaultZValues[GeoDataFeature::HighwayRoad] = s_defaultZValue - 6;
+ s_defaultZValues[GeoDataFeature::HighwayUnclassified] = s_defaultZValue - 6;
s_defaultZValues[GeoDataFeature::HighwayTertiary] = s_defaultZValue - 5;
s_defaultZValues[GeoDataFeature::HighwaySecondary] = s_defaultZValue - 4;
s_defaultZValues[GeoDataFeature::HighwayPrimary] = s_defaultZValue - 3;
@@ -172,6 +170,12 @@ void GeometryLayerPrivate::initializeDefaultValues()
s_defaultZValues[GeoDataFeature::HighwayMotorway] = s_defaultZValue - 1;
s_defaultZValues[GeoDataFeature::RailwayRail] = s_defaultZValue - 1;
+ s_defaultZValues[GeoDataFeature::HighwayTertiaryLink] = s_defaultZValues[GeoDataFeature::HighwayTertiary];
+ s_defaultZValues[GeoDataFeature::HighwaySecondaryLink]= s_defaultZValues[GeoDataFeature::HighwaySecondary];
+ s_defaultZValues[GeoDataFeature::HighwayPrimaryLink] = s_defaultZValues[GeoDataFeature::HighwayPrimary];
+ s_defaultZValues[GeoDataFeature::HighwayTrunkLink] = s_defaultZValues[GeoDataFeature::HighwayTrunk];
+ s_defaultZValues[GeoDataFeature::HighwayMotorwayLink] = s_defaultZValues[GeoDataFeature::HighwayMotorway];
+
s_defaultMinZoomLevels[GeoDataFeature::Default] = 1;
s_defaultMinZoomLevels[GeoDataFeature::NaturalWater] = 8;
s_defaultMinZoomLevels[GeoDataFeature::NaturalWood] = 8;
@@ -182,8 +186,10 @@ void GeometryLayerPrivate::initializeDefaultValues()
s_defaultMinZoomLevels[GeoDataFeature::HighwayUnknown] = 13;
s_defaultMinZoomLevels[GeoDataFeature::HighwayPath] = 13;
s_defaultMinZoomLevels[GeoDataFeature::HighwayTrack] = 13;
- s_defaultMinZoomLevels[GeoDataFeature::HighwayPedestrian] = 14;
- s_defaultMinZoomLevels[GeoDataFeature::HighwayService] = 14;
+ s_defaultMinZoomLevels[GeoDataFeature::HighwayPedestrian] = 13;
+ s_defaultMinZoomLevels[GeoDataFeature::HighwayFootway] = 13;
+ s_defaultMinZoomLevels[GeoDataFeature::HighwayCycleway] = 13;
+ s_defaultMinZoomLevels[GeoDataFeature::HighwayService] = 13;
s_defaultMinZoomLevels[GeoDataFeature::HighwayRoad] = 13;
s_defaultMinZoomLevels[GeoDataFeature::HighwayTertiaryLink] = 10;
s_defaultMinZoomLevels[GeoDataFeature::HighwayTertiary] = 10;
@@ -252,6 +258,25 @@ bool GeometryLayer::render( GeoPainter *painter, ViewportParams *viewport,
int maxZoomLevel = qMin<int>( qMax<int>( qLn( viewport->radius() *4 / 256 ) / qLn( 2.0 ), 1), GeometryLayerPrivate::maximumZoomLevel() );
QList<GeoGraphicsItem*> items = d->m_scene.items( viewport->viewLatLonAltBox(), maxZoomLevel );
+ switch ( painter->mapQuality() ) {
+ case Marble::MapQuality::LowQuality :
+ case Marble::MapQuality::NormalQuality :
+ case Marble::MapQuality::HighQuality :
+ case Marble::MapQuality::PrintQuality :
+ for ( int i = 0, n = items.size(); i < n; ++i ) {
+ items << items[i]->decorations();
+ }
+
+ // Needs sorting by z-value
+ qStableSort(items.begin(), items.end(), [](const GeoGraphicsItem* a, const GeoGraphicsItem* b) {
+ return a->zValue() < b->zValue();
+ });
+
+ break;
+ default:
+ break;
+ }
+
int painted = 0;
foreach( GeoGraphicsItem* item, items )
{
diff --git a/src/lib/marble/osm/OsmPresetLibrary.cpp b/src/lib/marble/osm/OsmPresetLibrary.cpp
index eb48f7c..e0b1d23 100644
--- a/src/lib/marble/osm/OsmPresetLibrary.cpp
+++ b/src/lib/marble/osm/OsmPresetLibrary.cpp
@@ -96,14 +96,15 @@ void OsmPresetLibrary::initializeOsmVisualCategories()
s_visualCategories[ OsmTag( "highway", "unknown" ) ] = GeoDataFeature::HighwayUnknown;
s_visualCategories[ OsmTag( "highway", "steps" ) ] = GeoDataFeature::HighwaySteps;
- s_visualCategories[ OsmTag( "highway", "footway" ) ] = GeoDataFeature::HighwayPedestrian;
+ s_visualCategories[ OsmTag( "highway", "footway" ) ] = GeoDataFeature::HighwayFootway;
s_visualCategories[ OsmTag( "highway", "path" ) ] = GeoDataFeature::HighwayPath;
s_visualCategories[ OsmTag( "highway", "track" ) ] = GeoDataFeature::HighwayTrack;
s_visualCategories[ OsmTag( "highway", "pedestrian" ) ] = GeoDataFeature::HighwayPedestrian;
s_visualCategories[ OsmTag( "highway", "service" ) ] = GeoDataFeature::HighwayService;
- s_visualCategories[ OsmTag( "highway", "living_street" ) ] = GeoDataFeature::HighwayRoad;
- s_visualCategories[ OsmTag( "highway", "unclassified" ) ] = GeoDataFeature::HighwayRoad;
- s_visualCategories[ OsmTag( "highway", "residential" ) ] = GeoDataFeature::HighwayRoad;
+ s_visualCategories[ OsmTag( "highway", "living_street" ) ] = GeoDataFeature::HighwayLivingStreet;
+ s_visualCategories[ OsmTag( "highway", "unclassified" ) ] = GeoDataFeature::HighwayUnclassified;
+ s_visualCategories[ OsmTag( "highway", "residential" ) ] = GeoDataFeature::HighwayUnclassified;
+ s_visualCategories[ OsmTag( "highway", "road" ) ] = GeoDataFeature::HighwayRoad;
s_visualCategories[ OsmTag( "highway", "tertiary_link" ) ] = GeoDataFeature::HighwayTertiaryLink;
s_visualCategories[ OsmTag( "highway", "tertiary" ) ] = GeoDataFeature::HighwayTertiary;
s_visualCategories[ OsmTag( "highway", "secondary_link" ) ] = GeoDataFeature::HighwaySecondaryLink;