21 #ifndef IntermodalNetwork_h 22 #define IntermodalNetwork_h 50 template<
class E,
class L,
class N,
class V>
55 typedef std::pair<_IntermodalEdge*, _IntermodalEdge*>
EdgePair;
63 #ifdef IntermodalRouter_DEBUG_NETWORK 64 std::cout <<
"initIntermodalNetwork\n";
66 const bool pedestrianOnly = numericalID == 0;
68 bool haveSeenWalkingArea =
false;
69 for (
const E*
const edge : edges) {
70 if (edge->isInternal() || edge->isTazConnector()) {
73 const L* lane = getSidewalk<E, L>(edge);
75 if (edge->isWalkingArea()) {
81 haveSeenWalkingArea =
true;
89 if (!edge->isWalkingArea()) {
91 _IntermodalEdge*
const departConn =
new _IntermodalEdge(edge->getID() +
"_depart_connector", numericalID++, edge,
"!connector");
92 _IntermodalEdge*
const arrivalConn =
new _IntermodalEdge(edge->getID() +
"_arrival_connector", numericalID++, edge,
"!connector");
98 for (
const E*
const edge : edges) {
99 if (edge->isInternal() || edge->isTazConnector()) {
102 if (haveSeenWalkingArea) {
103 if (!pedestrianOnly && getSidewalk<E, L>(edge) ==
nullptr) {
104 const N*
const node = edge->getToJunction();
111 for (
const N*
const node : {
112 edge->getFromJunction(), edge->getToJunction()
122 for (
const E*
const edge : edges) {
123 const L*
const sidewalk = getSidewalk<E, L>(edge);
124 if (edge->isInternal() || sidewalk == 0) {
130 #ifdef IntermodalRouter_DEBUG_NETWORK 131 std::cout <<
" building connections from " << sidewalk->getID() <<
"\n";
133 if (haveSeenWalkingArea) {
134 const std::vector<const L*> outgoing = sidewalk->getOutgoingLanes();
138 bool hasWalkingArea =
false;
139 for (
const L* target : outgoing) {
140 if (target->getEdge().isWalkingArea()) {
141 hasWalkingArea =
true;
145 for (
const L* target : outgoing) {
146 const E*
const targetEdge = &(target->getEdge());
147 const bool used = (target == getSidewalk<E, L>(targetEdge)
148 && (!hasWalkingArea || targetEdge->isWalkingArea()));
149 #ifdef IntermodalRouter_DEBUG_NETWORK 150 const L* potTarget = getSidewalk<E, L>(targetEdge);
151 std::cout <<
" lane=" << (potTarget == 0 ?
"NULL" : potTarget->getID()) << (used ?
"(used)" :
"") <<
"\n";
155 pair.first->addSuccessor(targetPair.first);
156 targetPair.second->addSuccessor(pair.second);
157 #ifdef IntermodalRouter_DEBUG_NETWORK 158 std::cout <<
" " << pair.first->getID() <<
" -> " << targetPair.first->getID() <<
"\n";
159 std::cout <<
" " << targetPair.second->getID() <<
" -> " << pair.second->getID() <<
"\n";
167 if (toNodeConn !=
nullptr) {
168 pair.first->addSuccessor(toNodeConn);
172 if (fromNodeConn !=
nullptr) {
173 pair.second->addSuccessor(fromNodeConn);
176 if (edge->isWalkingArea()) {
185 pair.first->addSuccessor(endConnector);
186 pair.second->addSuccessor(endConnector);
187 #ifdef IntermodalRouter_DEBUG_NETWORK 188 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.first->getID() <<
"\n";
189 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.second->getID() <<
"\n";
190 std::cout <<
" " << pair.first->getID() <<
" -> " << endConnector->
getID() <<
"\n";
191 std::cout <<
" " << pair.second->getID() <<
" -> " << endConnector->
getID() <<
"\n";
197 for (
typename std::vector<_IntermodalEdge*>::iterator it =
myEdges.begin(); it !=
myEdges.end(); ++it) {
209 void addConnectors(_IntermodalEdge*
const depConn, _IntermodalEdge*
const arrConn,
const int splitIndex) {
222 typename std::map<const E*, EdgePair>::const_iterator it =
myBidiLookup.find(e);
225 throw ProcessError(
"Edge '" + e->getID() +
"' not found in intermodal network '");
232 typename std::map<const E*, std::vector<_IntermodalEdge*> >::const_iterator it =
myDepartLookup.find(e);
234 throw ProcessError(
"Depart edge '" + e->getID() +
"' not found in intermodal network.");
236 const std::vector<_IntermodalEdge*>& splitList = it->second;
237 typename std::vector<_IntermodalEdge*>::const_iterator splitIt = splitList.begin();
238 double totalLength = 0.;
239 while (splitIt != splitList.end() && totalLength + (*splitIt)->getLength() < pos) {
240 totalLength += (*splitIt)->getLength();
253 typename std::map<const E*, std::vector<_IntermodalEdge*> >::const_iterator it =
myArrivalLookup.find(e);
255 throw ProcessError(
"Arrival edge '" + e->getID() +
"' not found in intermodal network.");
257 const std::vector<_IntermodalEdge*>& splitList = it->second;
258 typename std::vector<_IntermodalEdge*>::const_iterator splitIt = splitList.begin();
259 double totalLength = 0.;
260 while (splitIt != splitList.end() && totalLength + (*splitIt)->getLength() < pos) {
261 totalLength += (*splitIt)->getLength();
274 typename std::map<const N*, _IntermodalEdge*>::const_iterator it =
myWalkingConnectorLookup.find(e->getToJunction());
276 const L*
const sidewalk = getSidewalk<E, L>(e);
277 if (e->isInternal() || sidewalk == 0) {
280 for (
const L* target : sidewalk->getOutgoingLanes()) {
281 if (target->getEdge().isWalkingArea()) {
const EdgePair & getBothDirections(const E *e) const
Returns the pair of forward and backward edge.
_IntermodalEdge * getArrivalEdge(const E *e, const double pos) const
Returns the arriving intermodal edge.
_IntermodalEdge * getDepartConnector(const E *e, const int splitIndex=0) const
Returns the departing intermodal connector at the given split offset.
const std::vector< _IntermodalEdge * > & getAllEdges()
std::map< const E *, EdgePair > myBidiLookup
retrieve the forward and backward edge for the given input edge E
void addEdge(_IntermodalEdge *edge)
void addSuccessor(IntermodalEdge *s)
int getNumericalID() const
IntermodalEdge< E, L, N, V > _IntermodalEdge
const std::string & getID() const
Returns the id.
const E * getEdge() const
_IntermodalEdge * getWalkingConnector(const E *e) const
Returns the outgoing pedestrian edge, which is either a walking area or a walking connector...
std::vector< _IntermodalEdge * > myEdges
the edge dictionary
PedestrianEdge< E, L, N, V > _PedestrianEdge
_IntermodalEdge * getArrivalConnector(const E *e, const int splitIndex=0) const
Returns the arriving intermodal connector at the given split offset.
std::pair< _IntermodalEdge *, _IntermodalEdge * > EdgePair
std::map< const E *, std::vector< _IntermodalEdge * > > myArrivalLookup
retrieve the arrival edges for the given input edge E
the intermodal network storing edges, connections and the mappings to the "real" edges ...
the base edge type that is given to the internal router (SUMOAbstractRouter)
_IntermodalEdge * getDepartEdge(const E *e, const double pos) const
Returns the departing intermodal edge.
std::map< const N *, _IntermodalEdge * > myWalkingConnectorLookup
the walking connector edge (fake walking area)
std::map< const E *, std::vector< _IntermodalEdge * > > myDepartLookup
retrieve the depart edges for the given input edge E
IntermodalNetwork(const std::vector< E *> &edges, int numericalID=0)
the pedestrian edge type that is given to the internal router (SUMOAbstractRouter) ...
void addConnectors(_IntermodalEdge *const depConn, _IntermodalEdge *const arrConn, const int splitIndex)