From 919698f9b3c86532b66448a3a98860600b28e167 Mon Sep 17 00:00:00 2001 From: Thomas Fischer Date: Sat, 30 Jul 2016 00:27:16 +0200 Subject: [PATCH] Adding RMV.de for southern/central Hesse, Germany Adding support for Rhein-Main-Verkehrsverbund (RMV), the transport network serving the Frankfurt metropolitan area in southern and central Hesse, Germany. The implementation is actually quite simple, as RMV uses HAFAS, inheriting and specializing the existing ParserHafasXml class. --- fahrplan2.pro | 2 ++ src/fahrplan_backend_manager.cpp | 1 + src/fahrplan_parser_thread.cpp | 3 +++ src/fahrplan_parser_thread.h | 1 + src/parser/parser_xmlrmvde.cpp | 31 ++++++++++++++++++++++++ src/parser/parser_xmlrmvde.h | 41 ++++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 src/parser/parser_xmlrmvde.cpp create mode 100644 src/parser/parser_xmlrmvde.h diff --git a/fahrplan2.pro b/fahrplan2.pro index a584e2ee..4da3d020 100644 --- a/fahrplan2.pro +++ b/fahrplan2.pro @@ -123,6 +123,7 @@ HEADERS += \ src/parser/parser_munich_efa.h \ src/parser/parser_salzburg_efa.h \ src/parser/parser_resrobot.h \ + src/parser/parser_xmlrmvde.h \ src/parser/parser_finland_matka.h \ src/models/backends.h SOURCES += src/main.cpp \ @@ -156,6 +157,7 @@ SOURCES += src/main.cpp \ src/parser/parser_munich_efa.cpp \ src/parser/parser_salzburg_efa.cpp \ src/parser/parser_resrobot.cpp \ + src/parser/parser_xmlrmvde.cpp \ src/parser/parser_finland_matka.cpp \ src/models/backends.cpp diff --git a/src/fahrplan_backend_manager.cpp b/src/fahrplan_backend_manager.cpp index f2dd6941..1ef7d6a7 100644 --- a/src/fahrplan_backend_manager.cpp +++ b/src/fahrplan_backend_manager.cpp @@ -35,6 +35,7 @@ QStringList FahrplanBackendManager::getParserList() result.append(ParserXmlSbbCh::getName()); result.append(ParserXmlNri::getName()); result.append(ParserXmlVasttrafikSe::getName()); + result.append(ParserXmlRMVde::getName()); result.append(ParserPTVVicGovAu::getName()); result.append(ParserSydneyEFA::getName()); result.append(ParserSFBayEFA::getName()); diff --git a/src/fahrplan_parser_thread.cpp b/src/fahrplan_parser_thread.cpp index 1dde8780..815a6fb7 100644 --- a/src/fahrplan_parser_thread.cpp +++ b/src/fahrplan_parser_thread.cpp @@ -164,6 +164,9 @@ void FahrplanParserThread::run() case 15: m_parser = new ParserFinlandMatka(); break; + case 16: + m_parser = new ParserXmlRMVde(); + break; } m_name = m_parser->name(); diff --git a/src/fahrplan_parser_thread.h b/src/fahrplan_parser_thread.h index 837212ec..383b9cfa 100644 --- a/src/fahrplan_parser_thread.h +++ b/src/fahrplan_parser_thread.h @@ -40,6 +40,7 @@ #include "parser/parser_salzburg_efa.h" #include "parser/parser_resrobot.h" #include "parser/parser_finland_matka.h" +#include "parser/parser_xmlrmvde.h" class FahrplanParserThread : public QThread { diff --git a/src/parser/parser_xmlrmvde.cpp b/src/parser/parser_xmlrmvde.cpp new file mode 100644 index 00000000..d3996e1b --- /dev/null +++ b/src/parser/parser_xmlrmvde.cpp @@ -0,0 +1,31 @@ +#include "parser_xmlrmvde.h" + +#include + +ParserXmlRMVde::ParserXmlRMVde(QObject *parent) : + ParserHafasXml(parent) +{ + baseXmlUrl = QLatin1String("http://www.rmv.de/auskunft/bin/jp/query.exe"); + baseUrl = QLatin1String("http://www.rmv.de/auskunft/bin/jp/query.exe"); +} + +void ParserXmlRMVde::parseStationsByName(QNetworkReply *networkReply) +{ + const QString data = QString::fromUtf8(networkReply->readAll()); + const StationsList result = internalParseStationsByName(data); + emit stationsResult(result); +} + +QString ParserXmlRMVde::getTrainRestrictionsCodes(int trainrestrictions) +{ + Q_UNUSED(trainrestrictions) + // TODO should something else get returned? + return QLatin1String("1111111111111111"); +} + +QStringList ParserXmlRMVde::getTrainRestrictions() +{ + QStringList result; + result.append(tr("All")); + return result; +} diff --git a/src/parser/parser_xmlrmvde.h b/src/parser/parser_xmlrmvde.h new file mode 100644 index 00000000..38bd663a --- /dev/null +++ b/src/parser/parser_xmlrmvde.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** This file is a part of Fahrplan. +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License along +** with this program. If not, see . +** +****************************************************************************/ + +#ifndef PARSER_XMLRMVDE_H +#define PARSER_XMLRMVDE_H + +#include "parser_hafasxml.h" + +class ParserXmlRMVde : public ParserHafasXml +{ + Q_OBJECT + +public: + explicit ParserXmlRMVde(QObject *parent = 0); + static QString getName() { return QString(QLatin1String("%1 (rmv.de)")).arg(tr("Germany, Hesse")); } + virtual QString name() { return getName(); } + virtual QString shortName() { return QLatin1String("rmv.de"); } + +protected: + void parseStationsByName(QNetworkReply *networkReply); + QStringList getTrainRestrictions(); + QString getTrainRestrictionsCodes(int trainrestrictions); +}; + +#endif // PARSER_XMLRMVDE_H