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:
parent
dfb62babd9
commit
dd05506c42
5 changed files with 25 additions and 11 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 8e1dd71097cbc2fa1136522a2e2ba3cb574efe96
|
Subproject commit dce9b94bd1e57bce1ba6242708234addc0db1d3c
|
|
@ -135,7 +135,8 @@ int main(int argc, char** argv) {
|
||||||
if (!cfg.writeOverpass && !cfg.writeOsmfilter)
|
if (!cfg.writeOverpass && !cfg.writeOsmfilter)
|
||||||
LOG(INFO) << "Reading GTFS feed " << cfg.feedPaths[0] << " ...";
|
LOG(INFO) << "Reading GTFS feed " << cfg.feedPaths[0] << " ...";
|
||||||
try {
|
try {
|
||||||
ad::cppgtfs::Parser p(cfg.feedPaths[0]);
|
ad::cppgtfs::Parser p(cfg.feedPaths[0], false,
|
||||||
|
cfg.parseAdditionalGTFSFields);
|
||||||
p.parse(>fs[0]);
|
p.parse(>fs[0]);
|
||||||
} catch (const ad::cppgtfs::ParserException& ex) {
|
} catch (const ad::cppgtfs::ParserException& ex) {
|
||||||
LOG(ERROR) << "Could not parse input GTFS feed, reason was:";
|
LOG(ERROR) << "Could not parse input GTFS feed, reason was:";
|
||||||
|
|
|
@ -144,10 +144,11 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
|
||||||
{"stats", no_argument, 0, 14},
|
{"stats", no_argument, 0, 14},
|
||||||
{"no-hop-cache", no_argument, 0, 15},
|
{"no-hop-cache", no_argument, 0, 15},
|
||||||
{"gaussian-noise", required_argument, 0, 16},
|
{"gaussian-noise", required_argument, 0, 16},
|
||||||
|
{"keep-additional-gtfs-fields", no_argument, 0, 'F'},
|
||||||
{0, 0, 0, 0}};
|
{0, 0, 0, 0}};
|
||||||
|
|
||||||
char c;
|
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) {
|
-1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -219,6 +220,9 @@ void ConfigReader::read(Config* cfg, int argc, char** argv) {
|
||||||
case 16:
|
case 16:
|
||||||
cfg->gaussianNoise = atof(optarg);
|
cfg->gaussianNoise = atof(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
cfg->parseAdditionalGTFSFields = true;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
std::cout << "pfaedle " << VERSION_FULL << std::endl;
|
std::cout << "pfaedle " << VERSION_FULL << std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "ad/cppgtfs/gtfs/Route.h"
|
#include "ad/cppgtfs/gtfs/Route.h"
|
||||||
#include "util/geo/Geo.h"
|
#include "util/geo/Geo.h"
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ struct Config {
|
||||||
noTrie(false),
|
noTrie(false),
|
||||||
noHopCache(false),
|
noHopCache(false),
|
||||||
writeStats(false),
|
writeStats(false),
|
||||||
|
parseAdditionalGTFSFields(false),
|
||||||
gridSize(2000 / util::geo::M_PER_DEG),
|
gridSize(2000 / util::geo::M_PER_DEG),
|
||||||
gaussianNoise(0) {}
|
gaussianNoise(0) {}
|
||||||
std::string dbgOutputPath;
|
std::string dbgOutputPath;
|
||||||
|
@ -62,6 +64,7 @@ struct Config {
|
||||||
bool noTrie;
|
bool noTrie;
|
||||||
bool noHopCache;
|
bool noHopCache;
|
||||||
bool writeStats;
|
bool writeStats;
|
||||||
|
bool parseAdditionalGTFSFields;
|
||||||
double gridSize;
|
double gridSize;
|
||||||
double gaussianNoise;
|
double gaussianNoise;
|
||||||
|
|
||||||
|
@ -85,6 +88,7 @@ struct Config {
|
||||||
<< "no-a-star: " << noAStar << "\n"
|
<< "no-a-star: " << noAStar << "\n"
|
||||||
<< "no-trie: " << noTrie << "\n"
|
<< "no-trie: " << noTrie << "\n"
|
||||||
<< "no-hop-cache: " << noHopCache << "\n"
|
<< "no-hop-cache: " << noHopCache << "\n"
|
||||||
|
<< "parse-additional-gtfs-fields: " << parseAdditionalGTFSFields << "\n"
|
||||||
<< "write-stats: " << writeStats << "\n"
|
<< "write-stats: " << writeStats << "\n"
|
||||||
<< "feed-paths: ";
|
<< "feed-paths: ";
|
||||||
|
|
||||||
|
|
|
@ -426,14 +426,15 @@ void Writer::writeAgency(gtfs::Feed* sourceFeed, std::ostream* os) const {
|
||||||
|
|
||||||
ad::cppgtfs::Writer w;
|
ad::cppgtfs::Writer w;
|
||||||
|
|
||||||
auto csvw = ad::cppgtfs::Writer::getAgencyCsvw(os);
|
auto csvw =
|
||||||
|
ad::cppgtfs::Writer::getAgencyCsvw(os, sourceFeed->getAgencyAddFlds());
|
||||||
csvw->flushLine();
|
csvw->flushLine();
|
||||||
|
|
||||||
ad::cppgtfs::gtfs::flat::Agency fa;
|
ad::cppgtfs::gtfs::flat::Agency fa;
|
||||||
auto flds = Parser::getAgencyFlds(csvp.get());
|
auto flds = Parser::getAgencyFlds(csvp.get());
|
||||||
|
|
||||||
while (p.nextAgency(csvp.get(), &fa, flds)) {
|
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");
|
auto csvp = p.getCsvParser("stops.txt");
|
||||||
ad::cppgtfs::Writer w;
|
ad::cppgtfs::Writer w;
|
||||||
|
|
||||||
auto csvw = ad::cppgtfs::Writer::getStopsCsvw(os);
|
auto csvw =
|
||||||
|
ad::cppgtfs::Writer::getStopsCsvw(os, sourceFeed->getStopAddFlds());
|
||||||
csvw->flushLine();
|
csvw->flushLine();
|
||||||
|
|
||||||
ad::cppgtfs::gtfs::flat::Stop s;
|
ad::cppgtfs::gtfs::flat::Stop s;
|
||||||
auto flds = Parser::getStopFlds(csvp.get());
|
auto flds = Parser::getStopFlds(csvp.get());
|
||||||
|
|
||||||
while (p.nextStop(csvp.get(), &s, flds)) {
|
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 {
|
void Writer::writeRoutes(gtfs::Feed* sourceFeed, std::ostream* os) const {
|
||||||
ad::cppgtfs::Writer w;
|
ad::cppgtfs::Writer w;
|
||||||
|
|
||||||
auto csvw = ad::cppgtfs::Writer::getRoutesCsvw(os);
|
auto csvw =
|
||||||
|
ad::cppgtfs::Writer::getRoutesCsvw(os, sourceFeed->getRouteAddFlds());
|
||||||
csvw->flushLine();
|
csvw->flushLine();
|
||||||
|
|
||||||
for (auto r : sourceFeed->getRoutes()) {
|
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;
|
ad::cppgtfs::Writer w;
|
||||||
bool hasFreqs = false;
|
bool hasFreqs = false;
|
||||||
|
|
||||||
auto csvw = ad::cppgtfs::Writer::getTripsCsvw(os);
|
auto csvw =
|
||||||
|
ad::cppgtfs::Writer::getTripsCsvw(os, sourceFeed->getTripAddFlds());
|
||||||
csvw->flushLine();
|
csvw->flushLine();
|
||||||
|
|
||||||
for (auto t : sourceFeed->getTrips()) {
|
for (auto t : sourceFeed->getTrips()) {
|
||||||
if (t.getFrequencies().size()) hasFreqs = true;
|
if (t.getFrequencies().size()) hasFreqs = true;
|
||||||
w.writeTrip(t.getFlat(), csvw.get());
|
w.writeTrip(t.getFlat(), csvw.get(), sourceFeed->getTripAddFlds());
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasFreqs;
|
return hasFreqs;
|
||||||
|
|
Loading…
Reference in a new issue