summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-31 13:13:18 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-08-31 13:13:18 (GMT)
commit468adca632813265130a7e37399ff20a7b6b0a41 (patch)
treee5845c8ea8c4217aef4f4d1a1dc84afcfb775f80
parentdd5e1550ee69708a89c3601ab1577a7aa43fe729 (diff)
osm reader: Use QStringLiteral for creating QString objects from raw strings
-rw-r--r--src/plugins/runner/osm/OsmNode.cpp10
-rw-r--r--src/plugins/runner/osm/OsmParser.cpp14
-rw-r--r--src/plugins/runner/osm/OsmRelation.cpp14
-rw-r--r--src/plugins/runner/osm/OsmWay.cpp84
4 files changed, 61 insertions, 61 deletions
diff --git a/src/plugins/runner/osm/OsmNode.cpp b/src/plugins/runner/osm/OsmNode.cpp
index b9ca66a..f0e18e0 100644
--- a/src/plugins/runner/osm/OsmNode.cpp
+++ b/src/plugins/runner/osm/OsmNode.cpp
@@ -46,20 +46,20 @@ void OsmNode::create(GeoDataDocument *document) const
placemark->setCoordinate(m_coordinates);
if ((category == GeoDataFeature::TransportCarShare || category == GeoDataFeature::MoneyAtm)
- && m_osmData.containsTagKey("operator")) {
- placemark->setName(m_osmData.tagValue("operator"));
+ && m_osmData.containsTagKey(QStringLiteral("operator"))) {
+ placemark->setName(m_osmData.tagValue(QStringLiteral("operator")));
} else {
- placemark->setName(m_osmData.tagValue("name"));
+ placemark->setName(m_osmData.tagValue(QStringLiteral("name")));
}
if (placemark->name().isEmpty()) {
- placemark->setName(m_osmData.tagValue("ref"));
+ placemark->setName(m_osmData.tagValue(QStringLiteral("ref")));
}
placemark->setVisualCategory(category);
placemark->setStyle( GeoDataStyle::Ptr() );
placemark->setZoomLevel( 18 );
if (category >= GeoDataFeature::PlaceCity && category <= GeoDataFeature::PlaceVillage) {
- int const population = m_osmData.tagValue("population").toInt();
+ int const population = m_osmData.tagValue(QStringLiteral("population")).toInt();
placemark->setPopulation(qMax(0, population));
if (population > 0) {
placemark->setZoomLevel(populationIndex(population));
diff --git a/src/plugins/runner/osm/OsmParser.cpp b/src/plugins/runner/osm/OsmParser.cpp
index 99f062b..01a8ec8 100644
--- a/src/plugins/runner/osm/OsmParser.cpp
+++ b/src/plugins/runner/osm/OsmParser.cpp
@@ -49,9 +49,9 @@ GeoDataDocument* OsmParser::parseO5m(const QString &filename, QString &error)
OsmWays ways;
OsmRelations relations;
QHash<uint8_t, QString> relationTypes;
- relationTypes[O5MREADER_DS_NODE] = "node";
- relationTypes[O5MREADER_DS_WAY] = "way";
- relationTypes[O5MREADER_DS_REL] = "relation";
+ relationTypes[O5MREADER_DS_NODE] = QStringLiteral("node");
+ relationTypes[O5MREADER_DS_WAY] = QStringLiteral("way");
+ relationTypes[O5MREADER_DS_REL] = QStringLiteral("relation");
auto file = fopen(filename.toStdString().c_str(), "rb");
o5mreader_open(&reader, file);
@@ -116,7 +116,7 @@ GeoDataDocument* OsmParser::parseXml(const QString &filename, QString &error)
MarbleZipReader zipReader(filename);
if (zipReader.fileInfoList().size() != 1) {
int const fileNumber = zipReader.fileInfoList().size();
- error = QString("Unexpected number of files (%1) in %2").arg(fileNumber).arg(filename);
+ error = QStringLiteral("Unexpected number of files (%1) in %2").arg(fileNumber).arg(filename);
return nullptr;
}
QByteArray const data = zipReader.fileData(zipReader.fileInfoList().first().filePath);
@@ -126,7 +126,7 @@ GeoDataDocument* OsmParser::parseXml(const QString &filename, QString &error)
} else {
file.setFileName(filename);
if (!file.open(QFile::ReadOnly)) {
- error = QString("Cannot open file %1").arg(filename);
+ error = QStringLiteral("Cannot open file %1").arg(filename);
return nullptr;
}
parser.setDevice(&file);
@@ -186,10 +186,10 @@ GeoDataDocument *OsmParser::createDocument(OsmNodes &nodes, OsmWays &ways, OsmRe
GeoDataPolyStyle backgroundPolyStyle;
backgroundPolyStyle.setFill( true );
backgroundPolyStyle.setOutline( false );
- backgroundPolyStyle.setColor("#f1eee8");
+ backgroundPolyStyle.setColor(QStringLiteral("#f1eee8"));
GeoDataStyle::Ptr backgroundStyle(new GeoDataStyle);
backgroundStyle->setPolyStyle( backgroundPolyStyle );
- backgroundStyle->setId( "background" );
+ backgroundStyle->setId(QStringLiteral("background"));
document->addStyle( backgroundStyle );
QSet<qint64> usedNodes, usedWays;
diff --git a/src/plugins/runner/osm/OsmRelation.cpp b/src/plugins/runner/osm/OsmRelation.cpp
index f786946..d9a83ec 100644
--- a/src/plugins/runner/osm/OsmRelation.cpp
+++ b/src/plugins/runner/osm/OsmRelation.cpp
@@ -50,11 +50,11 @@ void OsmRelation::addMember(qint64 reference, const QString &role, const QString
void OsmRelation::create(GeoDataDocument *document, OsmWays &ways, const OsmNodes &nodes, QSet<qint64> &usedNodes, QSet<qint64> &usedWays) const
{
- if (!m_osmData.containsTag("type", "multipolygon")) {
+ if (!m_osmData.containsTag(QStringLiteral("type"), QStringLiteral("multipolygon"))) {
return;
}
- QStringList const outerRoles = QStringList() << "outer" << "";
+ QStringList const outerRoles = QStringList() << QStringLiteral("outer") << QString();
QSet<qint64> outerWays;
QSet<qint64> outerNodes;
const QList<GeoDataLinearRing> outer = rings(outerRoles, ways, nodes, outerNodes, outerWays);
@@ -104,7 +104,7 @@ void OsmRelation::create(GeoDataDocument *document, OsmWays &ways, const OsmNode
}
}
- QStringList const innerRoles = QStringList() << "inner";
+ QStringList const innerRoles = QStringList() << QStringLiteral("inner");
QSet<qint64> innerWays;
const QList<GeoDataLinearRing> inner = rings(innerRoles, ways, nodes, usedNodes, innerWays);
@@ -128,9 +128,9 @@ void OsmRelation::create(GeoDataDocument *document, OsmWays &ways, const OsmNode
// In case of a bathymetry store elevation info since it is required during styling
// The ele=* tag is present in the outermost way
const OsmPlacemarkData outerWayData = ways[*outerWays.begin()].osmData();
- if (outerWayData.containsTagKey("ele")) {
- const QString value = outerWayData.tagValue("ele");
- osmData.addTag("ele", value);
+ if (outerWayData.containsTagKey(QStringLiteral("ele"))) {
+ const QString value = outerWayData.tagValue(QStringLiteral("ele"));
+ osmData.addTag(QStringLiteral("ele"), value);
}
}
@@ -141,7 +141,7 @@ void OsmRelation::create(GeoDataDocument *document, OsmWays &ways, const OsmNode
}
GeoDataPlacemark *placemark = new GeoDataPlacemark;
- placemark->setName(m_osmData.tagValue("name"));
+ placemark->setName(m_osmData.tagValue(QStringLiteral("name")));
placemark->setVisualCategory(outerCategory);
placemark->setStyle( GeoDataStyle::Ptr() );
placemark->setVisible(outerCategory != GeoDataFeature::None);
diff --git a/src/plugins/runner/osm/OsmWay.cpp b/src/plugins/runner/osm/OsmWay.cpp
index 30a97d4..ac39143 100644
--- a/src/plugins/runner/osm/OsmWay.cpp
+++ b/src/plugins/runner/osm/OsmWay.cpp
@@ -27,9 +27,9 @@ void OsmWay::create(GeoDataDocument *document, const OsmNodes &nodes, QSet<qint6
GeoDataPlacemark* placemark = new GeoDataPlacemark;
placemark->setOsmData(m_osmData);
placemark->setVisualCategory(StyleBuilder::determineVisualCategory(m_osmData));
- placemark->setName(m_osmData.tagValue("name"));
+ placemark->setName(m_osmData.tagValue(QStringLiteral("name")));
if (placemark->name().isEmpty() && placemark->visualCategory() >= GeoDataFeature::HighwaySteps && placemark->visualCategory() <= GeoDataFeature::HighwayMotorway) {
- placemark->setName(m_osmData.tagValue("ref"));
+ placemark->setName(m_osmData.tagValue(QStringLiteral("ref")));
}
placemark->setVisible(placemark->visualCategory() != GeoDataFeature::None);
@@ -102,14 +102,14 @@ bool OsmWay::isArea() const
// See also https://wiki.openstreetmap.org/wiki/Key:area
bool const isLinearFeature =
- m_osmData.containsTag("area", "no") ||
- m_osmData.containsTagKey("highway") ||
- m_osmData.containsTagKey("barrier");
+ m_osmData.containsTag(QStringLiteral("area"), QStringLiteral("no")) ||
+ m_osmData.containsTagKey(QStringLiteral("highway")) ||
+ m_osmData.containsTagKey(QStringLiteral("barrier"));
if (isLinearFeature) {
return false;
}
- bool const isAreaFeature = m_osmData.containsTagKey("landuse");
+ bool const isAreaFeature = m_osmData.containsTagKey(QStringLiteral("landuse"));
if (isAreaFeature) {
return true;
}
@@ -131,46 +131,46 @@ bool OsmWay::isAreaTag(const QString &keyValue)
// All these tags can be found updated at
// http://wiki.openstreetmap.org/wiki/Map_Features#Landuse
- s_areaTags.insert( "natural=water" );
- s_areaTags.insert( "natural=wood" );
- s_areaTags.insert( "natural=beach" );
- s_areaTags.insert( "natural=wetland" );
- s_areaTags.insert( "natural=glacier" );
- s_areaTags.insert( "natural=scrub" );
- s_areaTags.insert( "natural=cliff" );
- s_areaTags.insert( "area=yes" );
- s_areaTags.insert( "waterway=riverbank" );
+ s_areaTags.insert(QStringLiteral("natural=water"));
+ s_areaTags.insert(QStringLiteral("natural=wood"));
+ s_areaTags.insert(QStringLiteral("natural=beach"));
+ s_areaTags.insert(QStringLiteral("natural=wetland"));
+ s_areaTags.insert(QStringLiteral("natural=glacier"));
+ s_areaTags.insert(QStringLiteral("natural=scrub"));
+ s_areaTags.insert(QStringLiteral("natural=cliff"));
+ s_areaTags.insert(QStringLiteral("area=yes"));
+ s_areaTags.insert(QStringLiteral("waterway=riverbank"));
foreach(const QString &value, StyleBuilder::buildingValues() ) {
s_areaTags.insert(QLatin1String("building=") + value);
}
- s_areaTags.insert( "man_made=bridge" );
-
- s_areaTags.insert( "amenity=graveyard" );
- s_areaTags.insert( "amenity=parking" );
- s_areaTags.insert( "amenity=parking_space" );
- s_areaTags.insert( "amenity=bicycle_parking" );
- s_areaTags.insert( "amenity=college" );
- s_areaTags.insert( "amenity=hospital" );
- s_areaTags.insert( "amenity=kindergarten" );
- s_areaTags.insert( "amenity=school" );
- s_areaTags.insert( "amenity=university" );
- s_areaTags.insert( "leisure=common" );
- s_areaTags.insert( "leisure=garden" );
- s_areaTags.insert( "leisure=golf_course" );
- s_areaTags.insert( "leisure=marina" );
- s_areaTags.insert( "leisure=playground" );
- s_areaTags.insert( "leisure=pitch" );
- s_areaTags.insert( "leisure=park" );
- s_areaTags.insert( "leisure=sports_centre" );
- s_areaTags.insert( "leisure=stadium" );
- s_areaTags.insert( "leisure=swimming_pool" );
- s_areaTags.insert( "leisure=track" );
-
- s_areaTags.insert( "military=danger_area" );
-
- s_areaTags.insert( "marble_land=landmass" );
- s_areaTags.insert( "settlement=yes" );
+ s_areaTags.insert(QStringLiteral("man_made=bridge"));
+
+ s_areaTags.insert(QStringLiteral("amenity=graveyard"));
+ s_areaTags.insert(QStringLiteral("amenity=parking"));
+ s_areaTags.insert(QStringLiteral("amenity=parking_space"));
+ s_areaTags.insert(QStringLiteral("amenity=bicycle_parking"));
+ s_areaTags.insert(QStringLiteral("amenity=college"));
+ s_areaTags.insert(QStringLiteral("amenity=hospital"));
+ s_areaTags.insert(QStringLiteral("amenity=kindergarten"));
+ s_areaTags.insert(QStringLiteral("amenity=school"));
+ s_areaTags.insert(QStringLiteral("amenity=university"));
+ s_areaTags.insert(QStringLiteral("leisure=common"));
+ s_areaTags.insert(QStringLiteral("leisure=garden"));
+ s_areaTags.insert(QStringLiteral("leisure=golf_course"));
+ s_areaTags.insert(QStringLiteral("leisure=marina"));
+ s_areaTags.insert(QStringLiteral("leisure=playground"));
+ s_areaTags.insert(QStringLiteral("leisure=pitch"));
+ s_areaTags.insert(QStringLiteral("leisure=park"));
+ s_areaTags.insert(QStringLiteral("leisure=sports_centre"));
+ s_areaTags.insert(QStringLiteral("leisure=stadium"));
+ s_areaTags.insert(QStringLiteral("leisure=swimming_pool"));
+ s_areaTags.insert(QStringLiteral("leisure=track"));
+
+ s_areaTags.insert(QStringLiteral("military=danger_area"));
+
+ s_areaTags.insert(QStringLiteral("marble_land=landmass"));
+ s_areaTags.insert(QStringLiteral("settlement=yes"));
}
return s_areaTags.contains(keyValue);