update cppgtfs, add (hidden as of now, as the mode is not complete) option -F to keep additional non-standard GTFS fields

This commit is contained in:
Patrick Brosi 2023-11-06 17:59:29 +01:00
parent dfb62babd9
commit dd05506c42
5 changed files with 25 additions and 11 deletions

@ -1 +1 @@
Subproject commit 8e1dd71097cbc2fa1136522a2e2ba3cb574efe96
Subproject commit dce9b94bd1e57bce1ba6242708234addc0db1d3c

View file

@ -135,7 +135,8 @@ int main(int argc, char** argv) {
if (!cfg.writeOverpass && !cfg.writeOsmfilter)
LOG(INFO) << "Reading GTFS feed " << cfg.feedPaths[0] << " ...";
try {
ad::cppgtfs::Parser p(cfg.feedPaths[0]);
ad::cppgtfs::Parser p(cfg.feedPaths[0], false,
cfg.parseAdditionalGTFSFields);
p.parse(&gtfs[0]);
} catch (const ad::cppgtfs::ParserException& ex) {
LOG(ERROR) << "Could not parse input GTFS feed, reason was:";

View file

@ -144,10 +144,11 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
{"stats", no_argument, 0, 14},
{"no-hop-cache", no_argument, 0, 15},
{"gaussian-noise", required_argument, 0, 16},
{"keep-additional-gtfs-fields", no_argument, 0, 'F'},
{0, 0, 0, 0}};
char c;
while ((c = getopt_long(argc, argv, ":o:hvi:c:x:Dm:g:X:T:d:pP:", ops, 0)) !=
while ((c = getopt_long(argc, argv, ":o:hvi:c:x:Dm:g:X:T:d:pP:F", ops, 0)) !=
-1) {
switch (c) {
case 1:
@ -219,6 +220,9 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
case 16:
cfg->gaussianNoise = atof(optarg);
break;
case 'F':
cfg->parseAdditionalGTFSFields = true;
break;
case 'v':
std::cout << "pfaedle " << VERSION_FULL << std::endl;
exit(0);

View file

@ -9,6 +9,7 @@
#include <sstream>
#include <string>
#include <vector>
#include "ad/cppgtfs/gtfs/Route.h"
#include "util/geo/Geo.h"
@ -36,6 +37,7 @@ struct Config {
noTrie(false),
noHopCache(false),
writeStats(false),
parseAdditionalGTFSFields(false),
gridSize(2000 / util::geo::M_PER_DEG),
gaussianNoise(0) {}
std::string dbgOutputPath;
@ -62,6 +64,7 @@ struct Config {
bool noTrie;
bool noHopCache;
bool writeStats;
bool parseAdditionalGTFSFields;
double gridSize;
double gaussianNoise;
@ -85,6 +88,7 @@ struct Config {
<< "no-a-star: " << noAStar << "\n"
<< "no-trie: " << noTrie << "\n"
<< "no-hop-cache: " << noHopCache << "\n"
<< "parse-additional-gtfs-fields: " << parseAdditionalGTFSFields << "\n"
<< "write-stats: " << writeStats << "\n"
<< "feed-paths: ";

View file

@ -426,14 +426,15 @@ void Writer::writeAgency(gtfs::Feed* sourceFeed, std::ostream* os) const {
ad::cppgtfs::Writer w;
auto csvw = ad::cppgtfs::Writer::getAgencyCsvw(os);
auto csvw =
ad::cppgtfs::Writer::getAgencyCsvw(os, sourceFeed->getAgencyAddFlds());
csvw->flushLine();
ad::cppgtfs::gtfs::flat::Agency fa;
auto flds = Parser::getAgencyFlds(csvp.get());
while (p.nextAgency(csvp.get(), &fa, flds)) {
w.writeAgency(fa, csvw.get());
w.writeAgency(fa, csvw.get(), sourceFeed->getAgencyAddFlds());
}
}
@ -443,14 +444,15 @@ void Writer::writeStops(gtfs::Feed* sourceFeed, std::ostream* os) const {
auto csvp = p.getCsvParser("stops.txt");
ad::cppgtfs::Writer w;
auto csvw = ad::cppgtfs::Writer::getStopsCsvw(os);
auto csvw =
ad::cppgtfs::Writer::getStopsCsvw(os, sourceFeed->getStopAddFlds());
csvw->flushLine();
ad::cppgtfs::gtfs::flat::Stop s;
auto flds = Parser::getStopFlds(csvp.get());
while (p.nextStop(csvp.get(), &s, flds)) {
w.writeStop(s, csvw.get());
w.writeStop(s, csvw.get(), sourceFeed->getStopAddFlds());
}
}
@ -458,11 +460,13 @@ void Writer::writeStops(gtfs::Feed* sourceFeed, std::ostream* os) const {
void Writer::writeRoutes(gtfs::Feed* sourceFeed, std::ostream* os) const {
ad::cppgtfs::Writer w;
auto csvw = ad::cppgtfs::Writer::getRoutesCsvw(os);
auto csvw =
ad::cppgtfs::Writer::getRoutesCsvw(os, sourceFeed->getRouteAddFlds());
csvw->flushLine();
for (auto r : sourceFeed->getRoutes()) {
w.writeRoute(r.second->getFlat(), csvw.get());
w.writeRoute(r.second->getFlat(), csvw.get(),
sourceFeed->getRouteAddFlds());
}
}
@ -611,12 +615,13 @@ bool Writer::writeTrips(gtfs::Feed* sourceFeed, std::ostream* os) const {
ad::cppgtfs::Writer w;
bool hasFreqs = false;
auto csvw = ad::cppgtfs::Writer::getTripsCsvw(os);
auto csvw =
ad::cppgtfs::Writer::getTripsCsvw(os, sourceFeed->getTripAddFlds());
csvw->flushLine();
for (auto t : sourceFeed->getTrips()) {
if (t.getFrequencies().size()) hasFreqs = true;
w.writeTrip(t.getFlat(), csvw.get());
w.writeTrip(t.getFlat(), csvw.get(), sourceFeed->getTripAddFlds());
}
return hasFreqs;