generate-shapes/src/pfaedle/netgraph/EdgePL.h

54 lines
1.5 KiB
C
Raw Normal View History

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_NETGRAPH_EDGEPL_H_
#define PFAEDLE_NETGRAPH_EDGEPL_H_
2018-07-25 20:14:46 +02:00
#include <map>
2018-06-09 17:14:08 +02:00
#include <set>
#include <string>
#include "ad/cppgtfs/gtfs/Feed.h"
2018-07-25 20:14:46 +02:00
#include "util/String.h"
2018-06-09 17:14:08 +02:00
#include "util/geo/GeoGraph.h"
using util::geograph::GeoEdgePL;
using ad::cppgtfs::gtfs::Trip;
namespace pfaedle {
namespace netgraph {
/*
* A payload class for edges on a network graph - that is a graph
* that exactly represents a physical public transit network
*/
class EdgePL : public GeoEdgePL<float> {
public:
EdgePL() {}
EdgePL(const util::geo::FLine& l, const std::set<const Trip*>& trips)
2018-07-25 20:14:46 +02:00
: _l(l), _trips(trips) {
for (const auto t : _trips) {
_routeShortNames.insert(t->getRoute()->getShortName());
_tripShortNames.insert(t->getShortname());
}
}
2018-06-09 17:14:08 +02:00
const util::geo::FLine* getGeom() const { return &_l; }
void getAttrs(std::map<std::string, std::string>* obj) const {
2018-07-25 20:14:46 +02:00
(*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(), ", ");
2018-06-09 17:14:08 +02:00
}
private:
util::geo::FLine _l;
std::set<const Trip*> _trips;
2018-07-25 20:14:46 +02:00
std::set<std::string> _routeShortNames;
std::set<std::string> _tripShortNames;
2018-06-09 17:14:08 +02:00
};
} // namespace netgraph
} // namespace pfaedle
#endif // PFAEDLE_NETGRAPH_EDGEPL_H_