22 #ifndef IntermodalNetwork_h
23 #define IntermodalNetwork_h
51 template<
class E,
class L,
class N,
class V>
56 typedef std::pair<_IntermodalEdge*, _IntermodalEdge*>
EdgePair;
63 #ifdef IntermodalRouter_DEBUG_NETWORK
64 std::cout <<
"initIntermodalNetwork\n";
67 bool haveSeenWalkingArea =
false;
68 for (
typename std::vector<E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
69 const E*
const edge = *i;
70 if (edge->isInternal()) {
73 const L* lane = getSidewalk<E, L>(edge);
75 if (edge->isWalkingArea()) {
81 haveSeenWalkingArea =
true;
89 if (!edge->isWalkingArea()) {
99 for (
typename std::vector<E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
101 const L* sidewalk = getSidewalk<E, L>(edge);
102 if (edge->isInternal() || sidewalk == 0) {
108 #ifdef IntermodalRouter_DEBUG_NETWORK
109 std::cout <<
" building connections from " << sidewalk->getID() <<
"\n";
111 if (haveSeenWalkingArea) {
112 std::vector<const L*> outgoing = sidewalk->getOutgoingLanes();
115 bool hasWalkingArea =
false;
116 for (
typename std::vector<const L*>::iterator it = outgoing.begin(); it != outgoing.end(); ++it) {
117 const L* target = *it;
118 const E* targetEdge = &(target->getEdge());
119 if (targetEdge->isWalkingArea()) {
120 hasWalkingArea =
true;
124 for (
typename std::vector<const L*>::iterator it = outgoing.begin(); it != outgoing.end(); ++it) {
125 const L* target = *it;
126 const E* targetEdge = &(target->getEdge());
127 const bool used = (target == getSidewalk<E, L>(targetEdge)
128 && (!hasWalkingArea || targetEdge->isWalkingArea()));
129 #ifdef IntermodalRouter_DEBUG_NETWORK
130 const L* potTarget = getSidewalk<E, L>(targetEdge);
131 std::cout <<
" lane=" << (potTarget == 0 ?
"NULL" : potTarget->getID()) << (used ?
"(used)" :
"") <<
"\n";
135 pair.first->addSuccessor(targetPair.first);
136 targetPair.second->addSuccessor(pair.second);
137 #ifdef IntermodalRouter_DEBUG_NETWORK
138 std::cout <<
" " << pair.first->getID() <<
" -> " << targetPair.first->getID() <<
"\n";
139 std::cout <<
" " << targetPair.second->getID() <<
" -> " << pair.second->getID() <<
"\n";
146 const N* toNode = edge->getToJunction();
147 std::vector<const E*> outgoing = toNode->getOutgoing();
148 for (
typename std::vector<const E*>::iterator it = outgoing.begin(); it != outgoing.end(); ++it) {
150 const E* targetEdge = *it;
151 const L* target = getSidewalk<E, L>(targetEdge);
152 if (targetEdge->isInternal() || target == 0) {
156 pair.first->addSuccessor(targetPair.first);
157 targetPair.second->addSuccessor(pair.second);
158 #ifdef IntermodalRouter_DEBUG_NETWORK
159 std::cout <<
" " << pair.first->getID() <<
" -> " << targetPair.first->getID() <<
"\n";
160 std::cout <<
" " << targetPair.second->getID() <<
" -> " << pair.second->getID() <<
"\n";
163 std::vector<const E*> incoming = toNode->getIncoming();
164 for (
typename std::vector<const E*>::iterator it = incoming.begin(); it != incoming.end(); ++it) {
166 const E* targetEdge = *it;
167 const L* target = getSidewalk<E, L>(targetEdge);
168 if (targetEdge->isInternal() || target == 0 || targetEdge == edge) {
172 pair.first->addSuccessor(targetPair.second);
173 #ifdef IntermodalRouter_DEBUG_NETWORK
174 std::cout <<
" " << pair.first->getID() <<
" -> " << targetPair.second->getID() <<
"\n";
177 const N* fromNode = edge->getFromJunction();
178 outgoing = fromNode->getOutgoing();
179 for (
typename std::vector<const E*>::iterator it = outgoing.begin(); it != outgoing.end(); ++it) {
181 const E* targetEdge = *it;
182 const L* target = getSidewalk<E, L>(targetEdge);
183 if (targetEdge->isInternal() || target == 0 || targetEdge == edge) {
187 pair.second->addSuccessor(targetPair.first);
188 #ifdef IntermodalRouter_DEBUG_NETWORK
189 std::cout <<
" " << pair.second->getID() <<
" -> " << targetPair.first->getID() <<
"\n";
193 if (edge->isWalkingArea()) {
202 pair.first->addSuccessor(endConnector);
203 pair.second->addSuccessor(endConnector);
204 #ifdef IntermodalRouter_DEBUG_NETWORK
205 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.first->getID() <<
"\n";
206 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.second->getID() <<
"\n";
207 std::cout <<
" " << pair.first->getID() <<
" -> " << endConnector->
getID() <<
"\n";
208 std::cout <<
" " << pair.second->getID() <<
" -> " << endConnector->
getID() <<
"\n";
214 for (
typename std::vector<_IntermodalEdge*>::iterator it =
myEdges.begin(); it !=
myEdges.end(); ++it) {
226 void addConnectors(_IntermodalEdge*
const depConn, _IntermodalEdge*
const arrConn,
const int splitIndex) {
239 typename std::map<const E*, EdgePair>::const_iterator it =
myBidiLookup.find(e);
242 throw ProcessError(
"Edge '" + e->getID() +
"' not found in pedestrian network '");
249 typename std::map<const E*, std::vector<_IntermodalEdge*> >::const_iterator it =
myDepartLookup.find(e);
251 throw ProcessError(
"Depart edge '" + e->getID() +
"' not found in pedestrian network.");
253 const std::vector<_IntermodalEdge*>& splitList = it->second;
254 typename std::vector<_IntermodalEdge*>::const_iterator splitIt = splitList.begin();
256 while (splitIt != splitList.end() && totalLength + (*splitIt)->getLength() +
POSITION_EPS < pos) {
257 totalLength += (*splitIt)->getLength();
265 typename std::map<const E*, std::vector<_IntermodalEdge*> >::const_iterator it =
myArrivalLookup.find(e);
267 throw ProcessError(
"Arrival edge '" + e->getID() +
"' not found in pedestrian network.");
269 const std::vector<_IntermodalEdge*>& splitList = it->second;
270 typename std::vector<_IntermodalEdge*>::const_iterator splitIt = splitList.begin();
272 while (splitIt != splitList.end() && totalLength + (*splitIt)->getLength() +
POSITION_EPS < pos) {
273 totalLength += (*splitIt)->getLength();
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)
_IntermodalEdge * getDepartEdge(const E *e, const SUMOReal pos=-1.)
Returns the departing Intermodal edge.
void addSuccessor(IntermodalEdge *s)
IntermodalEdge< E, L, N, V > _IntermodalEdge
_IntermodalEdge * getArrivalEdge(const E *e, const SUMOReal pos=-1.)
Returns the arriving Intermodal edge.
const std::string & getID() const
Returns the id.
std::vector< _IntermodalEdge * > myEdges
the edge dictionary
PedestrianEdge< E, L, N, V > _PedestrianEdge
int getNumericalID() const
std::pair< _IntermodalEdge *, _IntermodalEdge * > EdgePair
std::map< const E *, std::vector< _IntermodalEdge * > > myArrivalLookup
retrieve the arrival edges for the given input edge E
const E * getEdge() const
IntermodalNetwork(const std::vector< E * > &edges, int numericalID=0)
the pedestrian network storing edges, connections and the mappings to the "real" edges ...
the base edge type that is given to the internal router (SUMOAbstractRouter)
std::map< const E *, std::vector< _IntermodalEdge * > > myDepartLookup
retrieve the depart edges for the given input edge E
const EdgePair & getBothDirections(const E *e)
Returns the pair of forward and backward edge.
the pedestrian edge type that is given to the internal router (SUMOAbstractRouter) ...
void addConnectors(_IntermodalEdge *const depConn, _IntermodalEdge *const arrConn, const int splitIndex)