// Copyright 2018, University of Freiburg, // Chair of Algorithms and Data Structures. // Authors: Patrick Brosi #ifndef PFAEDLE_EVAL_COLLECTOR_H_ #define PFAEDLE_EVAL_COLLECTOR_H_ #include #include #include #include #include #include #include "ad/cppgtfs/gtfs/Feed.h" #include "pfaedle/gtfs/Feed.h" #include "pfaedle/Def.h" #include "pfaedle/eval/Result.h" #include "util/geo/Geo.h" using pfaedle::gtfs::Trip; using ad::cppgtfs::gtfs::Shape; namespace pfaedle { namespace eval { /* * Collects routing results for evaluation */ class Collector { public: Collector(const std::string& evalOutPath, const std::vector& dfBins) : _noOrigShp(0), _fdSum(0), _unmatchedSegSum(0), _unmatchedSegLengthSum(0), _evalOutPath(evalOutPath), _dfBins(dfBins) {} // Add a shape found by our tool newS for a trip t with newly calculated // station dist values with the old shape oldS double add(const Trip* t, const Shape* oldS, const Shape& newS, const std::vector& newDists); // Return the set of all Result objects const std::set& getResults() const; // Print general stats to os void printStats(std::ostream* os) const; // Print histogramgs for the results to os void printHisto(std::ostream* os, const std::set& result, const std::vector& bins) const; // Print a CSV for the results to os void printCsv(std::ostream* os, const std::set& result, const std::vector& bins) const; // Return the averaged average frechet distance double getAvgDist() const; static LINE getWebMercLine(const Shape* s, double from, double to); static LINE getWebMercLine(const Shape* s, double from, double to, std::vector* dists); private: std::set _results; std::set _resultsAN; std::set _resultsAL; std::map > _dCache; std::map > > _dACache; size_t _noOrigShp; double _fdSum; size_t _unmatchedSegSum; double _unmatchedSegLengthSum; std::string _evalOutPath; std::vector _dfBins; static std::pair getDa(const std::vector& a, const std::vector& b); static std::vector segmentize(const Trip* t, const LINE& shape, const std::vector& dists, const std::vector* newTripDists); static std::vector getBins(double mind, double maxd, size_t steps); }; } // namespace eval } // namespace pfaedle #endif // PFAEDLE_EVAL_COLLECTOR_H_