* speed up hop-to-hop calculations

* better and faster trip clustering: trip tries
* add --write-colors to extract line colors from OSM data
* refactor config parameter names, update default pfaedle.cfg
* add --stats for writing a stats.json file
* add --no-fast-hops, --no-a-star, --no-trie for debugging
* general refactoring
This commit is contained in:
Patrick Brosi 2022-01-03 22:27:59 +01:00
parent f1822868c5
commit 4c29892658
126 changed files with 14576 additions and 12196 deletions

View file

@ -3,22 +3,19 @@
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#include <string>
#include <vector>
#include <limits>
#include <unordered_map>
#include "pfaedle/trgraph/NodePL.h"
#include "pfaedle/trgraph/StatGroup.h"
#include "pfaedle/trgraph/StatInfo.h"
#include "util/String.h"
using pfaedle::trgraph::StatInfo;
using pfaedle::trgraph::NodePL;
using pfaedle::trgraph::Component;
using pfaedle::trgraph::NodePL;
using pfaedle::trgraph::StatInfo;
// we use the adress of this dummy station info as a special value
// of this node, meaning "is a station block". Re-using the _si field here
// saves some memory
StatInfo NodePL::_blockerSI = StatInfo();
std::unordered_map<const Component*, size_t> NodePL::_comps;
std::vector<Component> NodePL::comps;
std::vector<StatInfo> NodePL::_statInfos;
// _____________________________________________________________________________
NodePL::NodePL()
@ -32,19 +29,6 @@ NodePL::NodePL()
{
}
// _____________________________________________________________________________
NodePL::NodePL(const NodePL& pl)
: _geom(pl._geom),
_si(0),
_component(pl._component)
#ifdef PFAEDLE_DBG
,
_vis(pl._vis)
#endif
{
if (pl._si) setSI(*(pl._si));
}
// _____________________________________________________________________________
NodePL::NodePL(const POINT& geom)
: _geom(geom),
@ -70,18 +54,6 @@ NodePL::NodePL(const POINT& geom, const StatInfo& si)
setSI(si);
}
// _____________________________________________________________________________
NodePL::~NodePL() {
if (getSI()) delete _si;
if (_component) {
_comps[_component]--;
if (_comps[_component] == 0) {
delete _component;
_comps.erase(_comps.find(_component));
}
}
}
// _____________________________________________________________________________
void NodePL::setVisited() const {
#ifdef PFAEDLE_DBG
@ -93,18 +65,14 @@ void NodePL::setVisited() const {
void NodePL::setNoStat() { _si = 0; }
// _____________________________________________________________________________
const Component* NodePL::getComp() const { return _component; }
const Component& NodePL::getComp() const { return comps[_component - 1]; }
// _____________________________________________________________________________
void NodePL::setComp(const Component* c) {
if (_component == c) return;
_component = c;
uint32_t NodePL::getCompId() const { return _component; }
// NOT thread safe!
if (!_comps.count(c))
_comps[c] = 1;
else
_comps[c]++;
// _____________________________________________________________________________
void NodePL::setComp(uint32_t id) {
_component = id;
}
// _____________________________________________________________________________
@ -116,54 +84,59 @@ void NodePL::setGeom(const POINT& geom) { _geom = geom; }
// _____________________________________________________________________________
util::json::Dict NodePL::getAttrs() const {
util::json::Dict obj;
obj["component"] = std::to_string(reinterpret_cast<size_t>(_component));
obj["component"] = std::to_string(_component);
#ifdef PFAEDLE_DBG
obj["dijkstra_vis"] = _vis ? "yes" : "no";
#endif
if (getSI()) {
obj["station_info_ptr"] = util::toString(_si);
obj["station_name"] = _si->getName();
obj["station_alt_names"] = util::implode(_si->getAltNames(), ",");
obj["from_osm"] = _si->isFromOsm() ? "yes" : "no";
obj["station_platform"] = _si->getTrack();
obj["station_group"] =
std::to_string(reinterpret_cast<size_t>(_si->getGroup()));
obj["station_name"] = getSI()->getName();
obj["station_alt_names"] =
util::implode(getSI()->getAltNames(), ",");
obj["station_platform"] = getSI()->getTrack();
#ifdef PFAEDLE_STATION_IDS
// only print this in debug mode
obj["station_id"] = _si->getId();
obj["station_id"] = getSI()->getId();
#endif
std::stringstream gtfsIds;
if (_si->getGroup()) {
for (auto* s : _si->getGroup()->getStops()) {
gtfsIds << s->getId() << " (" << s->getName() << "),";
}
}
obj["station_group_stops"] = gtfsIds.str();
}
return obj;
}
// _____________________________________________________________________________
void NodePL::setSI(const StatInfo& si) { _si = new StatInfo(si); }
void NodePL::setSI(const StatInfo& si) {
_statInfos.emplace_back(si);
_si = _statInfos.size();
}
// _____________________________________________________________________________
const StatInfo* NodePL::getSI() const {
if (isBlocker()) return 0;
return _si;
if (isTurnCycle()) return 0;
if (_si == 0) return 0;
return &_statInfos[_si - 1];
}
// _____________________________________________________________________________
StatInfo* NodePL::getSI() {
if (isBlocker()) return 0;
return _si;
if (isTurnCycle()) return 0;
if (_si == 0) return 0;
return &_statInfos[_si - 1];
}
// _____________________________________________________________________________
void NodePL::setBlocker() { _si = &_blockerSI; }
void NodePL::setTurnCycle() { _si = std::numeric_limits<uint32_t>::max() - 1; }
// _____________________________________________________________________________
bool NodePL::isBlocker() const { return _si == &_blockerSI; }
bool NodePL::isTurnCycle() const {
return _si == (std::numeric_limits<uint32_t>::max() - 1);
}
// _____________________________________________________________________________
void NodePL::setBlocker() { _si = std::numeric_limits<uint32_t>::max(); }
// _____________________________________________________________________________
bool NodePL::isBlocker() const {
return _si == std::numeric_limits<uint32_t>::max();
}