Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file AccessEdge.h
15 : /// @author Michael Behrisch
16 : /// @date Mon, 03 March 2014
17 : ///
18 : // The AccessEdge is a special intermodal edge connecting different modes
19 : /****************************************************************************/
20 : #pragma once
21 : #include <config.h>
22 :
23 : #include "IntermodalEdge.h"
24 :
25 :
26 : // ===========================================================================
27 : // class definitions
28 : // ===========================================================================
29 : /// @brief the access edge connecting different modes that is given to the internal router (SUMOAbstractRouter)
30 : template<class E, class L, class N, class V>
31 : class AccessEdge : public IntermodalEdge<E, L, N, V> {
32 : private:
33 : typedef IntermodalEdge<E, L, N, V> _IntermodalEdge;
34 :
35 : public:
36 323615 : AccessEdge(int numericalID, const _IntermodalEdge* inEdge, const _IntermodalEdge* outEdge, const double length,
37 : SVCPermissions modeRestriction = SVC_IGNORING,
38 : SVCPermissions vehicleRestriction = SVC_IGNORING,
39 : double traveltime = -1) :
40 : _IntermodalEdge(inEdge->getID() + ":" + outEdge->getID() + (modeRestriction == SVC_TAXI ? ":taxi" : ""),
41 : numericalID, outEdge->getEdge(), "!access", length > 0. ? length : NUMERICAL_EPS),
42 323615 : myTraveltime(traveltime),
43 323615 : myModeRestrictions(modeRestriction),
44 1513424 : myVehicleRestriction(vehicleRestriction)
45 323615 : { }
46 :
47 106046 : AccessEdge(int numericalID, const std::string& id, const E* edge, const double length = 0,
48 : SVCPermissions modeRestriction = SVC_IGNORING,
49 : SVCPermissions vehicleRestriction = SVC_IGNORING) :
50 : _IntermodalEdge(id, numericalID, edge, "!access", length > 0. ? length : NUMERICAL_EPS),
51 106046 : myTraveltime(-1),
52 106046 : myModeRestrictions(modeRestriction),
53 424184 : myVehicleRestriction(vehicleRestriction)
54 106046 : { }
55 :
56 3979428 : double getTravelTime(const IntermodalTrip<E, N, V>* const trip, double /* time */) const {
57 3979428 : return myTraveltime > 0 ? myTraveltime : this->getLength() / trip->speed;
58 : }
59 :
60 5830683 : bool prohibits(const IntermodalTrip<E, N, V>* const trip) const {
61 350774 : return ((myModeRestrictions != SVC_IGNORING && (trip->modeSet & myModeRestrictions) == 0)
62 5857620 : || (myVehicleRestriction != SVC_IGNORING &&
63 31712 : ((trip->vehicle == nullptr ? SVC_PEDESTRIAN : trip->vehicle->getVClass()) & myVehicleRestriction) == 0));
64 : }
65 :
66 : private:
67 : /// @brief travel time (alternative to length)
68 : const double myTraveltime;
69 : /// @brief only allow using this edge if the modeSet matches (i.e. entering a taxi)
70 : const SVCPermissions myModeRestrictions;
71 : /// @brief only allow using this edge if the vehicle class matches (i.e. exiting a taxi)
72 : const SVCPermissions myVehicleRestriction;
73 :
74 : };
|