20 #ifndef PedestrianRouter_h
21 #define PedestrianRouter_h
46 #define TL_RED_PENALTY 20
52 template <
class E,
class L>
57 const std::vector<L*>& lanes = edge->getLanes();
58 for (
typename std::vector<L*>::const_iterator it = lanes.begin(); it != lanes.end(); ++it) {
71 template<
class E,
class N>
78 departPos(_departPos < 0 ? _from->getLength() + _departPos : _departPos),
79 arrivalPos(_arrivalPos < 0 ? _to->getLength() + _arrivalPos : _arrivalPos),
98 template<
class E,
class L,
class N>
100 typedef std::pair<PedestrianEdge*, PedestrianEdge*>
EdgePair;
120 #ifdef PedestrianRouter_DEBUG_NETWORK
121 std::cout <<
"initPedestrianNetwork\n";
124 unsigned int numericalID = 0;
125 for (
size_t i = 0; i < noE; i++) {
126 E* edge = E::dictionary(i);
127 const L* lane = getSidewalk<E, L>(edge);
128 if (edge->isInternal() || lane == 0) {
130 }
else if (edge->isWalkingArea()) {
145 for (
size_t i = 0; i < noE; i++) {
146 E* edge = E::dictionary(i);
147 const L* lane = getSidewalk<E, L>(edge);
148 if (edge->isInternal() || lane == 0) {
150 }
else if (edge->isWalkingArea()) {
163 for (
size_t i = 0; i < noE; i++) {
164 E* edge = E::dictionary(i);
165 const L* lane = getSidewalk<E, L>(edge);
166 if (edge->isInternal() || lane == 0) {
171 const L* sidewalk = getSidewalk<E, L>(edge);
174 #ifdef PedestrianRouter_DEBUG_NETWORK
175 std::cout <<
" building connections from " << sidewalk->getID() <<
"\n";
177 std::vector<const L*> outgoing = sidewalk->getOutgoingLanes();
178 for (
typename std::vector<const L*>::iterator it = outgoing.begin(); it != outgoing.end(); ++it) {
179 const L* target = *it;
180 const E* targetEdge = &(target->getEdge());
181 #ifdef PedestrianRouter_DEBUG_NETWORK
182 std::cout <<
" lane=" << getSidewalk<E, L>(targetEdge)->
getID() << (target == getSidewalk<E, L>(targetEdge) ?
"(used)" :
"") <<
"\n";
184 if (target == getSidewalk<E, L>(targetEdge)) {
186 pair.first->myFollowingEdges.push_back(targetPair.first);
187 targetPair.second->myFollowingEdges.push_back(pair.second);
188 #ifdef PedestrianRouter_DEBUG_NETWORK
189 std::cout <<
" " << pair.first->getID() <<
" -> " << targetPair.first->getID() <<
"\n";
190 std::cout <<
" " << targetPair.second->getID() <<
" -> " << pair.second->getID() <<
"\n";
194 if (edge->isWalkingArea()) {
203 pair.first->myFollowingEdges.push_back(endConnector);
204 pair.second->myFollowingEdges.push_back(endConnector);
205 #ifdef PedestrianRouter_DEBUG_NETWORK
206 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.first->getID() <<
"\n";
207 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.second->getID() <<
"\n";
208 std::cout <<
" " << pair.first->getID() <<
" -> " << endConnector->
getID() <<
"\n";
209 std::cout <<
" " << pair.second->getID() <<
" -> " << endConnector->
getID() <<
"\n";
224 typename std::map<const E*, EdgePair>::const_iterator it =
myBidiLookup.find(e);
227 throw ProcessError(
"Edge '" + e->getID() +
"' not found in pedestrian network '");
234 typename std::map<const E*, EdgePair>::const_iterator it =
myFromToLookup.find(e);
237 throw ProcessError(
"Edge '" + e->getID() +
"' not found in pedestrian network '");
239 return (*it).second.first;
244 typename std::map<const E*, EdgePair>::const_iterator it =
myFromToLookup.find(e);
247 throw ProcessError(
"Edge '" + e->getID() +
"' not found in pedestrian network '");
249 return (*it).second.second;
274 if (trip->
node == 0) {
279 return (
myEdge->getFromJunction() != trip->
node
316 #ifdef PedestrianRouter_DEBUG_EFFORTS
317 std::cout <<
" effort for " <<
getID() <<
" at " << time <<
": " << length / trip->
speed + tlsDelay <<
" l=" << length <<
" s=" << trip->
speed <<
" tlsDelay=" << tlsDelay <<
"\n";
319 return length / trip->
speed + tlsDelay;
323 PedestrianEdge(
unsigned int numericalID,
const E* edge,
const L* lane,
bool forward,
bool connector =
false) :
324 Named(edge->
getID() + (edge->isWalkingArea() ?
"" :
325 ((forward ?
"_fwd" :
"_bwd") + std::string(connector ?
"_connector" :
"")))),
366 template<
class E,
class L,
class N,
class INTERNALROUTER>
388 SUMOTime msTime,
const N* onlyNode, std::vector<const E*>& into,
bool allEdges =
false) {
390 _PedestrianTrip trip(from, to, departPos, arrivalPos, speed, msTime, onlyNode);
391 std::vector<const _PedestrianEdge*> intoPed;
394 for (
size_t i = 0; i < intoPed.size(); ++i) {
395 if (intoPed[i]->includeInRoute(allEdges)) {
396 into.push_back(intoPed[i]->getEdge());
399 #ifdef PedestrianRouter_DEBUG_ROUTES
400 std::cout <<
TIME2STEPS(msTime) <<
" trip from " << from->getID() <<
" to " << to->getID()
401 <<
" departPos=" << departPos
402 <<
" arrivalPos=" << arrivalPos
403 <<
" onlyNode=" << (onlyNode == 0 ?
"NULL" : onlyNode->getID())
405 <<
" resultEdges=" <<
toString(into)
423 std::vector<_PedestrianEdge*> toProhibitPE;
424 for (
typename std::vector<E*>::const_iterator it = toProhibit.begin(); it != toProhibit.end(); ++it) {
444 template<
class E,
class L,
class N>
446 DijkstraRouterTT_Direct<PedestrianEdge<E, L, N>, PedestrianTrip<E, N>, prohibited_withRestrictions<PedestrianEdge<E, L, N>, PedestrianTrip<E, N> > > > { };
453 template<
class E,
class L,
class N>
456 template<
class E,
class L,
class N>
459 template<
class E,
class L,
class N>
PedestrianRouter()
Constructor.
unsigned int getNoFollowing() const
const L * getSidewalk(const E *edge)
INTERNALROUTER * myInternalRouter
static const EdgePair & getBothDirections(const E *e)
Returns the pair of forward and backward edge.
PedestrianTrip(const E *_from, const E *_to, SUMOReal _departPos, SUMOReal _arrivalPos, SUMOReal _speed, SUMOReal _departTime, const N *_node)
void compute(const E *, const E *, const _PedestrianTrip *const, SUMOTime, std::vector< const E * > &)
Builds the route between the given edges using the minimum effort at the given time The definition of...
static PedestrianEdge * getDepartEdge(const E *e)
Returns the departing Pedestrian edge.
bool includeInRoute(bool allEdges) const
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
std::pair< PedestrianEdge *, PedestrianEdge * > EdgePair
std::vector< PedestrianEdge * > myFollowingEdges
List of edges that may be approached from this edge.
static std::vector< PedestrianEdge > myEdgeDict
the edge dictionary
bool myForward
the direction of this edge
static PedestrianEdge * getArrivalEdge(const E *e)
Returns the arriving Pedestrian edge.
PedestrianTrip & operator=(const PedestrianTrip &)
Invalidated assignment operator.
const E * myEdge
the original edge
const std::string & getID() const
Returns the id.
void compute(const E *from, const E *to, SUMOReal departPos, SUMOReal arrivalPos, SUMOReal speed, SUMOTime msTime, const N *onlyNode, std::vector< const E * > &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
const E * getEdge() const
bool myAmConnector
the direction of this edge
const SUMOReal departTime
bool prohibits(const PedestrianTrip< E, N > *const trip) const
PedestrianTrip< E, N > _PedestrianTrip
const SUMOReal arrivalPos
const L * myLane
the original edge
PedestrianEdge< E, L, N > _PedestrianEdge
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Base class for objects which have an id.
unsigned int getNumericalID() const
void prohibit(const std::vector< E * > &toProhibit)
static const PedestrianEdge * dictionary(size_t index)
Returns the PedstrianEdge with the given numericalID.
PedestrianEdge(unsigned int numericalID, const E *edge, const L *lane, bool forward, bool connector=false)
The link has red light (must brake)
static std::map< const E *, EdgePair > myBidiLookup
retrieve the forward and backward edge for the given input edge E
SUMOReal getEffort(const PedestrianTrip< E, N > *const trip, SUMOReal time) const
the edge type that is given to the internal router (SUMOAbstractRouter)
PedestrianRouter & operator=(const PedestrianRouter &s)
Invalidated assignment operator.
unsigned int myNumericalID
the index in myEdgeDict
SUMOReal recomputeCosts(const std::vector< const E * > &, const _PedestrianTrip *const, SUMOTime) const
PedestrianEdge * getFollower(unsigned int i) const
virtual ~PedestrianRouter()
Destructor.
static void initPedestrianNetwork(size_t noE)
static std::map< const E *, EdgePair > myFromToLookup
retrieve the depart and arrival edge for the given input edge E