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),
103 template<
class E,
class L,
class N>
105 typedef std::pair<PedestrianEdge*, PedestrianEdge*>
EdgePair;
125 #ifdef PedestrianRouter_DEBUG_NETWORK
126 std::cout <<
"initPedestrianNetwork\n";
129 unsigned int numericalID = 0;
130 for (
size_t i = 0; i < noE; i++) {
131 E* edge = E::dictionary(i);
132 const L* lane = getSidewalk<E, L>(edge);
133 if (edge->isInternal() || lane == 0) {
135 }
else if (edge->isWalkingArea()) {
150 for (
size_t i = 0; i < noE; i++) {
151 E* edge = E::dictionary(i);
152 const L* lane = getSidewalk<E, L>(edge);
153 if (edge->isInternal() || lane == 0) {
155 }
else if (edge->isWalkingArea()) {
168 for (
size_t i = 0; i < noE; i++) {
169 E* edge = E::dictionary(i);
170 const L* lane = getSidewalk<E, L>(edge);
171 if (edge->isInternal() || lane == 0) {
176 const L* sidewalk = getSidewalk<E, L>(edge);
179 #ifdef PedestrianRouter_DEBUG_NETWORK
180 std::cout <<
" building connections from " << sidewalk->getID() <<
"\n";
182 std::vector<const L*> outgoing = sidewalk->getOutgoingLanes();
183 for (
typename std::vector<const L*>::iterator it = outgoing.begin(); it != outgoing.end(); ++it) {
184 const L* target = *it;
185 const E* targetEdge = &(target->getEdge());
186 #ifdef PedestrianRouter_DEBUG_NETWORK
187 std::cout <<
" lane=" << getSidewalk<E, L>(targetEdge)->
getID() << (target == getSidewalk<E, L>(targetEdge) ?
"(used)" :
"") <<
"\n";
189 if (target == getSidewalk<E, L>(targetEdge)) {
191 pair.first->myFollowingEdges.push_back(targetPair.first);
192 targetPair.second->myFollowingEdges.push_back(pair.second);
193 #ifdef PedestrianRouter_DEBUG_NETWORK
194 std::cout <<
" " << pair.first->getID() <<
" -> " << targetPair.first->getID() <<
"\n";
195 std::cout <<
" " << targetPair.second->getID() <<
" -> " << pair.second->getID() <<
"\n";
199 if (edge->isWalkingArea()) {
208 pair.first->myFollowingEdges.push_back(endConnector);
209 pair.second->myFollowingEdges.push_back(endConnector);
210 #ifdef PedestrianRouter_DEBUG_NETWORK
211 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.first->getID() <<
"\n";
212 std::cout <<
" " << startConnector->
getID() <<
" -> " << pair.second->getID() <<
"\n";
213 std::cout <<
" " << pair.first->getID() <<
" -> " << endConnector->
getID() <<
"\n";
214 std::cout <<
" " << pair.second->getID() <<
" -> " << endConnector->
getID() <<
"\n";
229 typename std::map<const E*, EdgePair>::const_iterator it =
myBidiLookup.find(e);
232 throw ProcessError(
"Edge '" + e->getID() +
"' not found in pedestrian network '");
239 typename std::map<const E*, EdgePair>::const_iterator it =
myFromToLookup.find(e);
242 throw ProcessError(
"Edge '" + e->getID() +
"' not found in pedestrian network '");
244 return (*it).second.first;
249 typename std::map<const E*, EdgePair>::const_iterator it =
myFromToLookup.find(e);
252 throw ProcessError(
"Edge '" + e->getID() +
"' not found in pedestrian network '");
254 return (*it).second.second;
279 if (trip->
node == 0) {
284 return (
myEdge->getFromJunction() != trip->
node
322 #ifdef PedestrianRouter_DEBUG_EFFORTS
323 std::cout <<
" effort for " <<
getID() <<
" at " << time <<
": " << length / trip->
speed + tlsDelay <<
" l=" << length <<
" s=" << trip->
speed <<
" tlsDelay=" << tlsDelay <<
"\n";
325 return length / trip->
speed + tlsDelay;
329 PedestrianEdge(
unsigned int numericalID,
const E* edge,
const L* lane,
bool forward,
bool connector =
false) :
330 Named(edge->
getID() + (edge->isWalkingArea() ?
"" :
331 ((forward ?
"_fwd" :
"_bwd") + std::string(connector ?
"_connector" :
"")))),
372 template<
class E,
class L,
class N,
class INTERNALROUTER>
398 SUMOTime msTime,
const N* onlyNode, std::vector<const E*>& into,
bool allEdges =
false) {
400 _PedestrianTrip trip(from, to, departPos, arrivalPos, speed, msTime, onlyNode);
401 std::vector<const _PedestrianEdge*> intoPed;
404 for (
size_t i = 0; i < intoPed.size(); ++i) {
405 if (intoPed[i]->includeInRoute(allEdges)) {
406 into.push_back(intoPed[i]->getEdge());
409 #ifdef PedestrianRouter_DEBUG_ROUTES
410 std::cout <<
TIME2STEPS(msTime) <<
" trip from " << from->getID() <<
" to " << to->getID()
411 <<
" departPos=" << departPos
412 <<
" arrivalPos=" << arrivalPos
413 <<
" onlyNode=" << (onlyNode == 0 ?
"NULL" : onlyNode->getID())
415 <<
" resultEdges=" <<
toString(into)
433 std::vector<_PedestrianEdge*> toProhibitPE;
434 for (
typename std::vector<E*>::const_iterator it = toProhibit.begin(); it != toProhibit.end(); ++it) {
454 template<
class E,
class L,
class N>
456 DijkstraRouterTT<PedestrianEdge<E, L, N>, PedestrianTrip<E, N>, prohibited_withRestrictions<PedestrianEdge<E, L, N>, PedestrianTrip<E, N> > > > { };
463 template<
class E,
class L,
class N>
466 template<
class E,
class L,
class N>
469 template<
class E,
class L,
class N>
PedestrianRouter()
Constructor.
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
std::string getID() 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...
unsigned int getNumSuccessors() const
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 * getSuccessor(unsigned int i) const
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
the edge type that is given to the internal router (SUMOAbstractRouter)
PedestrianRouter & operator=(const PedestrianRouter &s)
Invalidated assignment operator.
virtual SUMOAbstractRouter< E, PedestrianTrip< E, N > > * clone() const
static SUMOReal getEffort(const PedestrianEdge *const edge, const PedestrianTrip< E, N > *const trip, SUMOReal time)
unsigned int myNumericalID
the index in myEdgeDict
SUMOReal recomputeCosts(const std::vector< const E * > &, const _PedestrianTrip *const, SUMOTime) 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