refactoring
This commit is contained in:
parent
7f0443243c
commit
5703eb47bd
5 changed files with 58 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -26,20 +26,19 @@ static const char* AUTHORS = "Patrick Brosi <brosi@informatik.uni-freiburg.de>";
|
|||
// _____________________________________________________________________________
|
||||
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 <OSM FILE> -c <CFG FILE> <GTFS FEED>\n\n"
|
||||
<< "Usage: " << bin << " -x <OSM FILE> -c <CFG FILE> <GTFS FEED>\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 <dbg-path>/graph.json\n"
|
||||
<< std::setw(35) << " --write-cgraph"
|
||||
<< "write combination graph as GeoJSON to <dbg-path>/combraph.json\n"
|
||||
<< "if -T is set, write combination graph as GeoJSON to "
|
||||
"<dbg-path>/combgraph.json\n"
|
||||
<< std::setw(35) << " --method arg (=global)"
|
||||
<< "matching method to use, either 'global' (based on HMM), 'greedy' or "
|
||||
"'greedy2'\n"
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
#ifndef PFAEDLE_NETGRAPH_EDGEPL_H_
|
||||
#define PFAEDLE_NETGRAPH_EDGEPL_H_
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#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<float> {
|
|||
public:
|
||||
EdgePL() {}
|
||||
EdgePL(const util::geo::FLine& l, const std::set<const Trip*>& 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<std::string, std::string>* 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<const Trip*> _trips;
|
||||
std::set<std::string> _routeShortNames;
|
||||
std::set<std::string> _tripShortNames;
|
||||
};
|
||||
} // namespace netgraph
|
||||
} // namespace pfaedle
|
||||
|
|
|
@ -143,16 +143,25 @@ inline size_t editDist(const std::string& s1, const std::string& s2) {
|
|||
}
|
||||
|
||||
// _____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline std::string implode(const std::vector<T>& vec, const char* del) {
|
||||
template <class Iter>
|
||||
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 <typename T>
|
||||
inline std::string implode(const std::vector<T>& vec, const char* del) {
|
||||
return implode(vec.begin(), vec.end(), del);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // UTIL_STRING_H_
|
||||
|
|
Loading…
Reference in a new issue