2018-06-09 17:14:08 +02:00
|
|
|
// Copyright 2018, University of Freiburg,
|
|
|
|
|
// Chair of Algorithms and Data Structures.
|
|
|
|
|
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
|
|
|
|
|
|
|
|
|
|
#ifndef PFAEDLE_EVAL_COLLECTOR_H_
|
|
|
|
|
#define PFAEDLE_EVAL_COLLECTOR_H_
|
|
|
|
|
|
2022-01-03 22:27:59 +01:00
|
|
|
#include <fstream>
|
2018-06-09 17:14:08 +02:00
|
|
|
#include <map>
|
|
|
|
|
#include <ostream>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "ad/cppgtfs/gtfs/Feed.h"
|
2018-08-10 16:42:38 +02:00
|
|
|
#include "pfaedle/Def.h"
|
2022-01-03 22:27:59 +01:00
|
|
|
#include "shapevl/Result.h"
|
2018-06-09 17:14:08 +02:00
|
|
|
#include "util/geo/Geo.h"
|
|
|
|
|
|
|
|
|
|
using ad::cppgtfs::gtfs::Shape;
|
2022-01-03 22:27:59 +01:00
|
|
|
using ad::cppgtfs::gtfs::Trip;
|
2018-06-09 17:14:08 +02:00
|
|
|
|
|
|
|
|
namespace pfaedle {
|
|
|
|
|
namespace eval {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Collects routing results for evaluation
|
|
|
|
|
*/
|
|
|
|
|
class Collector {
|
|
|
|
|
public:
|
2022-01-03 22:27:59 +01:00
|
|
|
Collector(std::ostream* reportOut)
|
|
|
|
|
: _trips(0),
|
|
|
|
|
_noOrigShp(0),
|
2018-06-09 17:14:08 +02:00
|
|
|
_fdSum(0),
|
|
|
|
|
_unmatchedSegSum(0),
|
|
|
|
|
_unmatchedSegLengthSum(0),
|
2022-01-03 22:27:59 +01:00
|
|
|
_acc0(0),
|
|
|
|
|
_acc10(0),
|
|
|
|
|
_acc20(0),
|
|
|
|
|
_acc40(0),
|
|
|
|
|
_acc80(0),
|
|
|
|
|
_reportOut(reportOut) {}
|
2018-06-09 17:14:08 +02:00
|
|
|
|
|
|
|
|
// Add a shape found by our tool newS for a trip t with newly calculated
|
|
|
|
|
// station dist values with the old shape oldS
|
2022-01-03 22:27:59 +01:00
|
|
|
double add(const Trip* oldT, const Shape* oldS, const Trip* newT,
|
|
|
|
|
const Shape* newS);
|
2018-06-09 17:14:08 +02:00
|
|
|
|
|
|
|
|
// Return the set of all Result objects
|
|
|
|
|
const std::set<Result>& getResults() const;
|
|
|
|
|
|
|
|
|
|
// Print general stats to os
|
|
|
|
|
void printStats(std::ostream* os) const;
|
|
|
|
|
|
2022-01-03 22:27:59 +01:00
|
|
|
// Print general stats to os
|
|
|
|
|
void printShortStats(std::ostream* os) const;
|
2018-06-09 17:14:08 +02:00
|
|
|
|
|
|
|
|
// Print a CSV for the results to os
|
2022-01-03 22:27:59 +01:00
|
|
|
void printCsv(std::ostream* os, const std::set<Result>& result) const;
|
2018-06-09 17:14:08 +02:00
|
|
|
|
|
|
|
|
// Return the averaged average frechet distance
|
|
|
|
|
double getAvgDist() const;
|
|
|
|
|
|
2022-01-03 22:27:59 +01:00
|
|
|
static LINE getWebMercLine(const Shape* s, std::vector<double>* dists);
|
|
|
|
|
|
|
|
|
|
double getAcc() const;
|
2018-06-09 17:14:08 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::set<Result> _results;
|
2019-01-10 16:52:59 +01:00
|
|
|
std::map<const Shape*, std::map<std::string, double> > _dCache;
|
|
|
|
|
std::map<const Shape*, std::map<std::string, std::pair<size_t, double> > >
|
2018-06-09 17:14:08 +02:00
|
|
|
_dACache;
|
2022-01-03 22:27:59 +01:00
|
|
|
size_t _trips;
|
2018-06-09 17:14:08 +02:00
|
|
|
size_t _noOrigShp;
|
|
|
|
|
|
|
|
|
|
double _fdSum;
|
|
|
|
|
size_t _unmatchedSegSum;
|
|
|
|
|
double _unmatchedSegLengthSum;
|
|
|
|
|
|
2022-01-07 17:35:30 +01:00
|
|
|
size_t _an0;
|
|
|
|
|
size_t _an5;
|
|
|
|
|
size_t _an10;
|
|
|
|
|
size_t _an30;
|
|
|
|
|
size_t _an50;
|
|
|
|
|
size_t _an70;
|
|
|
|
|
size_t _an90;
|
2018-06-09 17:14:08 +02:00
|
|
|
|
2022-01-03 22:27:59 +01:00
|
|
|
std::ostream* _reportOut;
|
2018-06-09 17:14:08 +02:00
|
|
|
|
2018-08-10 16:42:38 +02:00
|
|
|
static std::pair<size_t, double> getDa(const std::vector<LINE>& a,
|
|
|
|
|
const std::vector<LINE>& b);
|
2018-06-09 17:14:08 +02:00
|
|
|
|
2018-08-10 16:42:38 +02:00
|
|
|
static std::vector<LINE> segmentize(const Trip* t, const LINE& shape,
|
2022-01-03 22:27:59 +01:00
|
|
|
const std::vector<double>& dists);
|
2018-06-09 17:14:08 +02:00
|
|
|
|
|
|
|
|
static std::vector<double> getBins(double mind, double maxd, size_t steps);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace eval
|
|
|
|
|
} // namespace pfaedle
|
|
|
|
|
|
|
|
|
|
#endif // PFAEDLE_EVAL_COLLECTOR_H_
|