diff --git a/src/libsumo/Simulation.cpp b/src/libsumo/Simulation.cpp index ad70188f29a..210aa94a256 100644 --- a/src/libsumo/Simulation.cpp +++ b/src/libsumo/Simulation.cpp @@ -262,6 +262,8 @@ Simulation::findIntermodalRoute(const std::string& from, const std::string& to, result.back().edges.push_back(e->getID()); } result.back().travelTime = result.back().cost = it->cost; + result.back().intended = it->intended; + result.back().depart = it->depart; } } } diff --git a/src/libsumo/TraCIDefs.h b/src/libsumo/TraCIDefs.h index 42ab9bd7807..79fb95d4cce 100644 --- a/src/libsumo/TraCIDefs.h +++ b/src/libsumo/TraCIDefs.h @@ -205,7 +205,7 @@ struct TraCIBestLanesData { class TraCIStage { public: TraCIStage() {} // only to make swig happy - TraCIStage(int _type) : type(_type) {} + TraCIStage(int _type) : type(_type), depart(-1) {} /// @brief The type of stage (walking, driving, ...) int type; /// @brief The line or the id of the vehicle type @@ -218,6 +218,10 @@ class TraCIStage { double travelTime; /// @brief effort needed double cost; + /// @brief id of the intended vehicle for public transport ride + std::string intended; + /// @brief intended depart time for public transport ride or -1 + double depart; }; } diff --git a/src/router/ROPerson.cpp b/src/router/ROPerson.cpp index 3298b74c732..1338c6db671 100644 --- a/src/router/ROPerson.cpp +++ b/src/router/ROPerson.cpp @@ -127,7 +127,7 @@ ROPerson::Ride::saveAsXML(OutputDevice& os, const bool extended) const { os.writeAttr(SUMO_ATTR_BUS_STOP, destStop); } os.writeAttr(SUMO_ATTR_LINES, lines); - if (intended != "") { + if (intended != "" && intended != lines) { os.writeAttr(SUMO_ATTR_INTENDED, intended); } if (depart >= 0) { diff --git a/src/traci-server/TraCIServerAPI_Simulation.cpp b/src/traci-server/TraCIServerAPI_Simulation.cpp index f93004dc1ae..6a15fe8b9a5 100644 --- a/src/traci-server/TraCIServerAPI_Simulation.cpp +++ b/src/traci-server/TraCIServerAPI_Simulation.cpp @@ -377,6 +377,10 @@ TraCIServerAPI_Simulation::writeStage(tcpip::Storage& outputStorage, const libsu outputStorage.writeDouble(stage.travelTime); outputStorage.writeUnsignedByte(TYPE_DOUBLE); outputStorage.writeDouble(stage.cost); + outputStorage.writeUnsignedByte(TYPE_STRING); + outputStorage.writeString(stage.intended); + outputStorage.writeUnsignedByte(TYPE_DOUBLE); + outputStorage.writeDouble(stage.depart); } diff --git a/src/utils/vehicle/IntermodalRouter.h b/src/utils/vehicle/IntermodalRouter.h index 5d13bacff70..e32e7075e9c 100644 --- a/src/utils/vehicle/IntermodalRouter.h +++ b/src/utils/vehicle/IntermodalRouter.h @@ -66,7 +66,8 @@ class IntermodalRouter : public SUMOAbstractRouter > public: struct TripItem { - TripItem(const std::string& _line = "") : line(_line), cost(0.) {} + TripItem(const std::string& _line = "") : + line(_line), intended(_line), depart(-1), cost(0.) {} std::string line; std::string destStop; std::string intended; // intended public transport vehicle id diff --git a/tests/complex/traci/pythonApi/simulation/output.complex b/tests/complex/traci/pythonApi/simulation/output.complex index d3eb85a9b16..61d9debb003 100644 --- a/tests/complex/traci/pythonApi/simulation/output.complex +++ b/tests/complex/traci/pythonApi/simulation/output.complex @@ -1,5 +1,5 @@ Loading configuration... done. -Could not connect to TraCI server at localhost:52945 [Errno 111] Connection refused +Could not connect to TraCI server at localhost:44067 [Errno 111] Connection refused Retrying in 1 seconds {114: ['horiz', 'horiz1'], 116: []} step 0 @@ -56,9 +56,9 @@ getParameter 0.00 getParameter parkingArea.capacity 6 getParameter parkingArea.occupancy 0 getBusStopWaiting 0 -findRoute Stage(stageType=3, line='', destStop='', edges=['o', '2o'], travelTime=738.4, cost=738.4) -findRoute with routing mode Stage(stageType=3, line='', destStop='', edges=['o', '2o'], travelTime=0.0, cost=0.0) -findIntermodalRoute [Stage(stageType=2, line='', destStop='', edges=['o', '2o'], travelTime=3694.9536, cost=3694.9536)] +findRoute Stage(stageType=3, line='', destStop='', edges=['o', '2o'], travelTime=738.4, cost=738.4, intended='', depart=-1.0) +findRoute with routing mode Stage(stageType=3, line='', destStop='', edges=['o', '2o'], travelTime=0.0, cost=0.0, intended='', depart=-1.0) +findIntermodalRoute [Stage(stageType=2, line='', destStop='', edges=['o', '2o'], travelTime=3694.9536, cost=3694.9536, intended='', depart=-1.0)] step 0 {114: [], 116: []} step 1 diff --git a/tools/traci/_simulation.py b/tools/traci/_simulation.py index 3cb7565632b..599abb84ba8 100644 --- a/tools/traci/_simulation.py +++ b/tools/traci/_simulation.py @@ -21,7 +21,7 @@ from .domain import Domain from .storage import Storage -Stage = collections.namedtuple('Stage', ['stageType', 'line', 'destStop', 'edges', 'travelTime', 'cost']) +Stage = collections.namedtuple('Stage', ['stageType', 'line', 'destStop', 'edges', 'travelTime', 'cost', 'intended', 'depart']) def _readStage(result): # compound size and type @@ -33,7 +33,11 @@ def _readStage(result): result.read("!B") # Type edges = result.readStringList() _, travelTime, _, cost = result.read("!BdBd") - return Stage(stageType, line, destStop, edges, travelTime, cost) + result.read("!B") # Type + intended = result.readString() + result.read("!B") # Type + depart = result.readDouble() + return Stage(stageType, line, destStop, edges, travelTime, cost, intended, depart) _RETURN_VALUE_FUNC = {tc.VAR_TIME_STEP: Storage.readInt, tc.VAR_LOADED_VEHICLES_NUMBER: Storage.readInt,