summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-08-11 18:16:27 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-08-11 18:17:11 (GMT)
commitf3fce78606547afdb5dcd83edbc0305a2023c709 (patch)
tree7584dc009dd4d4960b7ea3a2699a037aa8f8de1b
parent8ec326688e2fd68b9179bb5da538560515dae340 (diff)
Extract explicit width values for highways
-rw-r--r--src/lib/marble/StyleBuilder.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/marble/StyleBuilder.cpp b/src/lib/marble/StyleBuilder.cpp
index f78d1c1..ae07fdf 100644
--- a/src/lib/marble/StyleBuilder.cpp
+++ b/src/lib/marble/StyleBuilder.cpp
@@ -981,12 +981,19 @@ GeoDataStyle::ConstPtr StyleBuilder::createStyle(const StyleParameters &paramete
lineStyle.setPhysicalWidth(0.0);
lineStyle.setWidth(4.0);
} else {
- bool const isOneWay = osmData.containsTag("oneway", "yes") || osmData.containsTag("oneway", "-1");
- int const lanes = isOneWay ? 1 : 2; // also for motorway which implicitly is one way, but has two lanes and each direction has its own highway
- double const laneWidth = 3.0;
- double const margins = visualCategory == GeoDataFeature::HighwayMotorway ? 2.0 : (isOneWay ? 1.0 : 0.0);
- double const physicalWidth = margins + lanes * laneWidth;
- lineStyle.setPhysicalWidth(physicalWidth);
+ if (osmData.containsTagKey("width")) {
+ QString const widthValue = osmData.tagValue("width").remove(QStringLiteral(" meters")).remove(QStringLiteral(" m"));
+ bool ok;
+ float const width = widthValue.toFloat(&ok);
+ lineStyle.setPhysicalWidth(ok ? qBound(0.1f, width, 200.0f) : 0.0f);
+ } else {
+ bool const isOneWay = osmData.containsTag("oneway", "yes") || osmData.containsTag("oneway", "-1");
+ int const lanes = isOneWay ? 1 : 2; // also for motorway which implicitly is one way, but has two lanes and each direction has its own highway
+ double const laneWidth = 3.0;
+ double const margins = visualCategory == GeoDataFeature::HighwayMotorway ? 2.0 : (isOneWay ? 1.0 : 0.0);
+ double const physicalWidth = margins + lanes * laneWidth;
+ lineStyle.setPhysicalWidth(physicalWidth);
+ }
}
QString const accessValue = osmData.tagValue("access");