diff --git a/eval/Makefile b/eval/Makefile index b802467..19b290c 100644 --- a/eval/Makefile +++ b/eval/Makefile @@ -45,7 +45,7 @@ osm/spain-latest.osm.pbf: mkdir -p osm wget http://download.geofabrik.de/europe/spain-latest.osm.pbf -O $@ -osm/spain-latest.osm: osm/spain-latest.osm.pbf osmconvert +osm/spain-latest.osm: osm/spain-latest.osm.pbf osmconvert @# pre-filter to vitoria gasteiz osmconvert -b=-2.8661,42.7480,-2.4788,43.0237 $< > $@ @@ -53,14 +53,14 @@ osm/baden-wuerttemberg-latest.osm.pbf: mkdir -p osm wget http://download.geofabrik.de/europe/germany/baden-wuerttemberg-latest.osm.pbf -O $@ -osm/baden-wuerttemberg-latest.osm: osm/baden-wuerttemberg-latest.osm.pbf osmconvert +osm/baden-wuerttemberg-latest.osm: osm/baden-wuerttemberg-latest.osm.pbf osmconvert osmconvert $< > $@ osm/france-latest.osm.pbf: mkdir -p osm wget http://download.geofabrik.de/europe/france-latest.osm.pbf -O $@ -osm/paris-latest.osm: osm/france-latest.osm.pbf osmconvert +osm/paris-latest.osm: osm/france-latest.osm.pbf osmconvert @# pre-filter to greater ile de france osmconvert -b=0.374,47.651,4.241,50.261 $< > $@ @@ -68,7 +68,7 @@ osm/europe-latest.osm.pbf: mkdir -p osm wget http://download.geofabrik.de/europe-latest.osm.pbf -O $@ -osm/switzerland-latest.osm: osm/europe-latest.osm.pbf osmconvert +osm/switzerland-latest.osm: osm/europe-latest.osm.pbf osmconvert @# pre-filter to greater switzerland osmconvert -b=3.757,44.245,15.579,52.670 $< > $@ @@ -87,21 +87,21 @@ gtfs/stuttgart/%.txt: echo "* to brosi@cs.informatik.uni-freiburg.de to receive the password. " echo "******************************************************************" wget http://www.vvs.de/download/opendata/VVS_GTFS.zip --ask-password --user vvsopendata01 -O gtfs/stuttgart/gtfs.zip - cd gtfs/stuttgart && unzip gtfs.zip + cd gtfs/stuttgart && unzip -o gtfs.zip rm gtfs/stuttgart/gtfs.zip gtfs/paris/%.txt: mkdir -p gtfs mkdir -p gtfs/paris wget https://transitfeeds.com/p/stif/822/latest/download -O gtfs/paris/gtfs.zip - cd gtfs/paris && unzip gtfs.zip + cd gtfs/paris && unzip -o gtfs.zip rm gtfs/paris/gtfs.zip gtfs/switzerland/%.txt: mkdir -p gtfs mkdir -p gtfs/switzerland wget http://gtfs.geops.ch/dl/gtfs_complete.zip -O gtfs/switzerland/gtfs.zip - cd gtfs/switzerland && unzip gtfs.zip + cd gtfs/switzerland && unzip -o gtfs.zip rm gtfs/switzerland/gtfs.zip osm/vitoria.osm: osm/spain-latest.osm gtfs/vitoria/stops.txt eval.cfg diff --git a/src/pfaedle/PfaedleMain.cpp b/src/pfaedle/PfaedleMain.cpp index 93b0515..7c74e3f 100644 --- a/src/pfaedle/PfaedleMain.cpp +++ b/src/pfaedle/PfaedleMain.cpp @@ -36,6 +36,7 @@ using pfaedle::config::ConfigReader; using pfaedle::eval::Collector; std::string getMotStr(const MOTs& mots); +std::string getFileNameMotStr(const MOTs& mots); MOTs getContMots(const MotConfig& motCfg, const MOTs& mots); // _____________________________________________________________________________ @@ -116,8 +117,11 @@ int main(int argc, char** argv) { Collector ecoll(cfg.evalPath, dfBins); for (const auto& motCfg : motCfgReader.getConfigs()) { + std::string filePost; auto usedMots = getContMots(motCfg, cmdCfgMots); if (!usedMots.size()) continue; + if (motCfgReader.getConfigs().size() > 1) + filePost = getFileNameMotStr(usedMots); std::string motStr = getMotStr(usedMots); LOG(INFO) << "Calculating shapes for mots " << motStr; @@ -125,7 +129,7 @@ int main(int argc, char** argv) { ShapeBuilder shapeBuilder(>fs, cmdCfgMots, motCfg, &ecoll, cfg); if (cfg.writeGraph) { - LOG(INFO) << "Outputting graph.json..."; + LOG(INFO) << "Outputting graph" + filePost + ".json..."; util::geo::output::GeoGraphJsonOutput out; std::ofstream fstr(cfg.dbgOutputPath + "/graph.json"); out.print(*shapeBuilder.getGraph(), fstr); @@ -155,9 +159,9 @@ int main(int argc, char** argv) { shapeBuilder.shape(&ng); if (cfg.buildTransitGraph) { - LOG(INFO) << "Outputting trgraph.json..."; util::geo::output::GeoGraphJsonOutput out; - std::ofstream fstr(cfg.dbgOutputPath + "/trgraph.json"); + LOG(INFO) << "Outputting trgraph" + filePost + ".json..."; + std::ofstream fstr(cfg.dbgOutputPath + "/trgraph" + filePost + ".json"); out.print(ng, fstr); fstr.close(); } @@ -187,6 +191,16 @@ std::string getMotStr(const MOTs& mots) { return motStr; } +// _____________________________________________________________________________ +std::string getFileNameMotStr(const MOTs& mots) { + std::string motStr; + for (const auto& mot : mots) { + motStr += "-" + Route::getTypeString(mot); + } + + return motStr; +} + // _____________________________________________________________________________ MOTs getContMots(const MotConfig& motCfg, const MOTs& mots) { MOTs ret; diff --git a/src/pfaedle/config/ConfigReader.cpp b/src/pfaedle/config/ConfigReader.cpp index a211d59..02b9fd6 100644 --- a/src/pfaedle/config/ConfigReader.cpp +++ b/src/pfaedle/config/ConfigReader.cpp @@ -26,20 +26,19 @@ static const char* AUTHORS = "Patrick Brosi "; // _____________________________________________________________________________ void ConfigReader::help(const char* bin) { std::cout - << std::setfill(' ') << std::left - << "pfaedle GTFS map matcher\n" + << std::setfill(' ') << std::left << "pfaedle GTFS map matcher\n" << VERSION_FULL << " (built " << __DATE__ << " " << __TIME__ << ")\n\n" << "(C) " << YEAR << " " << COPY << "\n" << "Authors: " << AUTHORS << "\n\n" - << "Usage: " - << bin - << " -x -c \n\n" + << "Usage: " << bin << " -x -c \n\n" << "Allowed options:\n\n" << "General:\n" << std::setw(35) << " -v [ --version ]" << "print version\n" << std::setw(35) << " -h [ --help ]" << "show this help message\n" + << std::setw(35) << " -D [ --drop-shapes ]" + << "drop shapes already present in the feed and recalculate them\n" << "\nInput:\n" << std::setw(35) << " -c [ --config ] arg" << "pfaedle config file\n" @@ -68,7 +67,8 @@ void ConfigReader::help(const char* bin) { << std::setw(35) << " --write-graph" << "write routing graph as GeoJSON to /graph.json\n" << std::setw(35) << " --write-cgraph" - << "write combination graph as GeoJSON to /combraph.json\n" + << "if -T is set, write combination graph as GeoJSON to " + "/combgraph.json\n" << std::setw(35) << " --method arg (=global)" << "matching method to use, either 'global' (based on HMM), 'greedy' or " "'greedy2'\n" diff --git a/src/pfaedle/netgraph/EdgePL.h b/src/pfaedle/netgraph/EdgePL.h index 8950e7d..b568fed 100644 --- a/src/pfaedle/netgraph/EdgePL.h +++ b/src/pfaedle/netgraph/EdgePL.h @@ -5,10 +5,11 @@ #ifndef PFAEDLE_NETGRAPH_EDGEPL_H_ #define PFAEDLE_NETGRAPH_EDGEPL_H_ +#include #include #include -#include #include "ad/cppgtfs/gtfs/Feed.h" +#include "util/String.h" #include "util/geo/GeoGraph.h" using util::geograph::GeoEdgePL; @@ -25,15 +26,26 @@ class EdgePL : public GeoEdgePL { public: EdgePL() {} EdgePL(const util::geo::FLine& l, const std::set& trips) - : _l(l), _trips(trips) {} + : _l(l), _trips(trips) { + for (const auto t : _trips) { + _routeShortNames.insert(t->getRoute()->getShortName()); + _tripShortNames.insert(t->getShortname()); + } + } const util::geo::FLine* getGeom() const { return &_l; } void getAttrs(std::map* obj) const { - (*obj)["numtrips"] = std::to_string(_trips.size()); + (*obj)["num_trips"] = std::to_string(_trips.size()); + (*obj)["route_short_names"] = + util::implode(_routeShortNames.begin(), _routeShortNames.end(), ", "); + (*obj)["trip_short_names"] = + util::implode(_tripShortNames.begin(), _tripShortNames.end(), ", "); } private: util::geo::FLine _l; std::set _trips; + std::set _routeShortNames; + std::set _tripShortNames; }; } // namespace netgraph } // namespace pfaedle diff --git a/src/util/String.h b/src/util/String.h index 8f8071a..ed03c17 100644 --- a/src/util/String.h +++ b/src/util/String.h @@ -143,16 +143,25 @@ inline size_t editDist(const std::string& s1, const std::string& s2) { } // _____________________________________________________________________________ -template -inline std::string implode(const std::vector& vec, const char* del) { +template +inline std::string implode(Iter begin, const Iter& end, const char* del) { std::stringstream ss; - for (size_t i = 0; i < vec.size(); i++) { + size_t i = 0; + while (begin != end) { if (i != 0) ss << del; - ss << vec[i]; + ss << *begin; + begin++; + i++; } return ss.str(); } + +// _____________________________________________________________________________ +template +inline std::string implode(const std::vector& vec, const char* del) { + return implode(vec.begin(), vec.end(), del); +} } #endif // UTIL_STRING_H_