Commit c646253c authored by Volker Krause's avatar Volker Krause
Browse files

Only do Austrian coach layout queries in Austria

The new API gives us 404 for non-Austrian stations.
parent 98efafd5
......@@ -34,7 +34,7 @@ static QString trainNumber(Line line)
bool OebbBackend::queryVehicleLayout(const VehicleLayoutRequest &request, VehicleLayoutReply *reply, QNetworkAccessManager *nam) const
{
const auto ibnr = request.stopover().stopPoint().identifier(QStringLiteral("ibnr"));
if (!UicStationCode::isValid(ibnr)) {
if (!UicStationCode::isValid(ibnr) || UicStationCode::country(ibnr) != QLatin1String("81")) {
return false;
}
const auto trainNum = trainNumber(request.stopover().route().line());
......
......@@ -32,3 +32,8 @@ bool UicStationCode::isValid(QStringView id, const std::vector<uint8_t> &allowed
// if no UIC country codes are explicitly allowed, insist on the right length
return id.size() == 7 && id.at(0) != QLatin1Char('0');
}
QStringView UicStationCode::country(QStringView id)
{
return id.mid(0, 2);
}
......@@ -27,6 +27,9 @@ namespace UicStationCode
*/
bool isValid(QStringView id, const std::vector<uint8_t> &allowedCountryCodes = {});
/** Returns the country code of a given valid UIC station code. */
QStringView country(QStringView id);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment