return m_azimuth;
}
-QString RouteSegment::earthDirection() const
+const QString& RouteSegment::earthDirection() const
{
qDebug() << __PRETTY_FUNCTION__;
return m_earthDirection;
}
-QString RouteSegment::instruction() const
+const QString& RouteSegment::instruction() const
{
qDebug() << __PRETTY_FUNCTION__;
return m_length;
}
-QString RouteSegment::lengthCaption() const
+const QString& RouteSegment::lengthCaption() const
{
qDebug() << __PRETTY_FUNCTION__;
m_azimuth = azimuth;
}
-void RouteSegment::setEarthDirection(QString direction)
+void RouteSegment::setEarthDirection(const QString &direction)
{
qDebug() << __PRETTY_FUNCTION__;
m_earthDirection = direction;
}
-void RouteSegment::setInstruction(QString instruction)
+void RouteSegment::setInstruction(const QString &instruction)
{
qDebug() << __PRETTY_FUNCTION__;
m_length = meters;
}
-void RouteSegment::setLengthCaption(QString length)
+void RouteSegment::setLengthCaption(const QString &length)
{
qDebug() << __PRETTY_FUNCTION__;
m_turnAngle = degrees;
}
-void RouteSegment::setTurnType(QString type)
+void RouteSegment::setTurnType(const QString &type)
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
+ // turn type codes
+ const QString TURN_TYPE_CONTINUE = "C";
+ const QString TURN_TYPE_LEFT = "TL";
+ const QString TURN_TYPE_SLIGHT_LEFT = "TSLL";
+ const QString TURN_TYPE_SHARP_LEFT = "TSHL";
+ const QString TURN_TYPE_RIGHT = "TR";
+ const QString TURN_TYPE_SLIGHT_RIGHT = "TSLR";
+ const QString TURN_TYPE_SHARP_RIGHT = "TSHR";
+ const QString TURN_TYPE_U_TURN = "TU";
+ const QString TURN_TYPE_ROUNDABOUT = "EXIT";
+
// regular expressions for matching/replacing instructions
const QString REGEXP_1ST_SEGMENT
= "^Head (north|northeast|east|southeast|south|southwest|west|northwest)";
// cut beginning of the instruction
// (but only if it matches with the expected value)
- if (m_turnType == "") {
+ if (m_turnType.isEmpty()) {
// first segment (without turn type code)
QRegExp regexp(REGEXP_1ST_SEGMENT);
result.replace(regexp, "");
- } else if (m_turnType == "C") {
+ } else if (m_turnType == TURN_TYPE_CONTINUE) {
// continue straight
QRegExp regexp(REGEXP_CONTINUE);
result.replace(regexp, "");
- } else if ((m_turnType == "TL") || (m_turnType == "TSLL")
- || (m_turnType == "TSHL") || (m_turnType == "TR")
- || (m_turnType == "TSLR") || (m_turnType == "TSHR")) {
+ } else if ((m_turnType == TURN_TYPE_LEFT) || (m_turnType == TURN_TYPE_SLIGHT_LEFT)
+ || (m_turnType == TURN_TYPE_SHARP_LEFT) || (m_turnType == TURN_TYPE_RIGHT)
+ || (m_turnType == TURN_TYPE_SLIGHT_RIGHT) || (m_turnType == TURN_TYPE_SHARP_RIGHT)) {
// turns
QRegExp regexp(REGEXP_TURNS);
result.replace(regexp, "");
- } else if (m_turnType == "TU") {
+ } else if (m_turnType == TURN_TYPE_U_TURN) {
// u-turn
QRegExp regexp(REGEXP_U_TURN);
result.replace(regexp, "");
- } else if (m_turnType.startsWith("EXIT")) {
+ } else if (m_turnType.startsWith(TURN_TYPE_ROUNDABOUT)) {
// roundabout
QRegExp regexp(REGEXP_ROUNDABOUT);
result.replace(regexp, "");
- } else {
- // no match, parsing failed
- qCritical() << __PRETTY_FUNCTION__ << "PARSING FAILED! ( turn type:"
- << m_turnType << "instruction:" << m_instruction << ")";
}
+ // else: do nothing
// replace on/at/onto words at the beginning of the result
// with zero or one leading space and one following space
return m_turnAngle;
}
-QString RouteSegment::turnType() const
+const QString& RouteSegment::turnType() const
{
qDebug() << __PRETTY_FUNCTION__;