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

Read extra GBFS feeds from a file

This replace the hardcoded special case in code, and it checks wheather
those feeds have meanwhile been added to the NABSA database so we don't
need to maintain duplicates.
parent 7e64c539
Pipeline #77736 passed with stage
in 22 seconds
https://api.openbike.ulm.dev/gbfs/gbfs.json
https://mds.bird.co/gbfs/v2/public/ulm/gbfs.json
https://mds.bird.co/gbfs/chicago/gbfs.json
https://www.bolt.miami/bolt2/chi/gbfs/gbfs.json
https://portal.clevrmobility.com/api/gbfs/chicago/en/discovery/?format=json
https://gbfs.uber.com/v1/chicago/gbfs.json
https://web.spin.pm/api/gbfs/v1/chicago/gbfs.json
https://chicago-gbfs.getwheelsapp.com/gbfs.json
https://share.veoride.com/api/share/gbfs.json
https://cykel.jenarad.de/gbfs/gbfs.json
https://ixsi.swu.de/gbfs.json
https://gbfs.conficars.de/gbfs.json
SPDX-License-Identifier: CC0-1.0
SPDX-FileCopyrightText: Volker Krause <vkrause@kde.org>
......@@ -36,10 +36,7 @@ public:
void writeFeeds();
QNetworkAccessManager m_nam;
// extra feeds not in systems.csv
QStringList m_gbfsFeeds = {
QStringLiteral("https://api.openbike.ulm.dev/gbfs/gbfs.json"),
};
QStringList m_gbfsFeeds;
int m_currentFeedIdx = -1;
std::vector<GBFSService> m_services;
......@@ -81,6 +78,28 @@ void GBFSProbe::getFeedList()
std::sort(m_gbfsFeeds.begin(), m_gbfsFeeds.end());
m_gbfsFeeds.erase(std::unique(m_gbfsFeeds.begin(), m_gbfsFeeds.end()), m_gbfsFeeds.end());
QFile extraFeeds(QStringLiteral("gbfs-feeds.txt"));
if (!extraFeeds.open(QFile::ReadOnly)) {
qCritical() << extraFeeds.errorString();
QCoreApplication::exit(1);
return;
}
const auto lines = QString::fromUtf8(extraFeeds.readAll()).split(QLatin1Char('\n'));
for (const auto &line : lines) {
const auto extraFeed = line.trimmed();
if (extraFeed.isEmpty()) {
continue;
}
const auto it = std::lower_bound(m_gbfsFeeds.begin(), m_gbfsFeeds.end(), extraFeed);
if (it != m_gbfsFeeds.end() && (*it) == extraFeed) {
qDebug() << "Extra feed already in NABSA systems.csv:" << extraFeed;
continue;
}
m_gbfsFeeds.insert(it, extraFeed);
}
qDebug() << "Found" << m_gbfsFeeds.size() << "possible feeds - running discovery on them...";
discoverNextFeed();
});
......
Supports Markdown
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