47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
170 if (inputStorage.
readInt() != 2) {
181 if (inputStorage.
readInt() != 3) {
213 std::string warning =
"";
244 outputStorage.
writeInt((
int) ids.size());
256 std::pair<MSLane*, SUMOReal>
258 std::pair<MSLane*, SUMOReal> result;
259 std::vector<std::string> allEdgeIds;
263 for (std::vector<std::string>::iterator itId = allEdgeIds.begin(); itId != allEdgeIds.end(); itId++) {
265 for (std::vector<MSLane*>::const_iterator itLane = allLanes.begin(); itLane != allLanes.end(); itLane++) {
266 const SUMOReal newDistance = (*itLane)->getShape().distance(pos);
267 if (newDistance < minDistance) {
268 minDistance = newDistance;
269 result.first = (*itLane);
274 result.second = result.first->getShape().nearest_offset_to_point2D(pos,
false);
285 if (laneIndex < 0 || laneIndex >= (
int)edge->
getLanes().size()) {
289 if (pos < 0 || pos > lane->
getLength()) {
299 std::pair<MSLane*, SUMOReal> roadPos;
307 switch (srcPosType) {
318 cartesianPos.
set(x, y);
327 std::string roadID = inputStorage.
readString();
333 z = cartesianPos.
z();
352 switch (destPosType) {
358 outputStorage.
writeString(roadPos.first->getEdge().getID());
360 const std::vector<MSLane*> lanes = roadPos.first->getEdge().getLanes();
361 outputStorage.
writeUnsignedByte((
int)distance(lanes.begin(), find(lanes.begin(), lanes.end(), roadPos.first)));
394 std::pair<const MSLane*, SUMOReal> roadPos1;
395 std::pair<const MSLane*, SUMOReal> roadPos2;
402 std::string roadID = inputStorage.
readString();
405 pos1 = roadPos1.first->getShape().positionAtOffset(roadPos1.second);
432 std::string roadID = inputStorage.
readString();
435 pos2 = roadPos2.first->getShape().positionAtOffset(roadPos2.second);
463 if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
465 distance = roadPos2.second - roadPos1.second;
470 MSRoute route(
"", newRoute,
false, 0, std::vector<SUMOVehicleParameter::Stop>());
471 distance = route.
getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
The vehicle has departed (was inserted into the network)
#define CMD_CLEAR_PENDING_VEHICLES
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
#define REQUEST_DRIVINGDIST
static void writeVehicleStateIDs(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
#define VAR_PARKING_STARTING_VEHICLES_IDS
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static const MSLane * getLaneChecking(std::string roadID, int laneIndex, SUMOReal pos)
std::vector< std::string > getEdgeNames() const
Returns the list of names of all known edges.
#define VAR_STOP_ENDING_VEHICLES_IDS
#define VAR_PARKING_ENDING_VEHICLES_NUMBER
SUMOReal ymin() const
Returns minimum y-coordinate.
SUMOReal getLength() const
Returns the lane's length.
#define POSITION_LON_LAT_ALT
virtual double readDouble()
SUMOReal xmin() const
Returns minimum x-coordinate.
#define VAR_LOADED_VEHICLES_IDS
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xab: Get Simulation Variable)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
#define RESPONSE_GET_SIM_VARIABLE
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
#define VAR_TELEPORT_STARTING_VEHICLES_IDS
static std::pair< MSLane *, SUMOReal > convertCartesianToRoadMap(Position pos)
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
virtual void writeUnsignedByte(int)
SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge *fromEdge, const MSEdge *toEdge) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
#define VAR_LOADED_VEHICLES_NUMBER
SUMOReal x() const
Returns the x-position.
SUMOReal xmax() const
Returns maximum x-coordinate.
A class that stores a 2D geometrical boundary.
#define VAR_STOP_STARTING_VEHICLES_NUMBER
static void writeVehicleStateNumber(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
virtual void writeInt(int)
virtual int readUnsignedByte()
The vehicles starts to stop.
#define POSITION_CONVERSION
A road/street connecting two junctions.
#define VAR_DEPARTED_VEHICLES_NUMBER
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcb: Set Simulation Variable)
#define VAR_MIN_EXPECTED_VEHICLES
The vehicle arrived at his destination (is deleted)
The vehicles starts to park.
std::vector< const MSEdge * > MSEdgeVector
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
#define VAR_STOP_STARTING_VEHICLES_IDS
#define VAR_NET_BOUNDING_BOX
A point in 2D or 3D with translation and scaling methods.
A lane area vehicles can halt at.
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
SUMOReal z() const
Returns the z-position.
virtual void writeStringList(const std::vector< std::string > &s)
static bool commandPositionConversion(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
#define VAR_TELEPORT_ENDING_VEHICLES_IDS
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
The vehicle started to teleport.
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
#define VAR_DEPARTED_VEHICLES_IDS
void clearPendingVehicles(std::string &route)
clears out all pending vehicles from a route, "" for all routes
MSBusStop * getBusStop(const std::string &id) const
Returns the named bus stop.
The vehicle ends to park.
const Boundary & getConvBoundary() const
Returns the converted boundary.
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
TraCI server used to control sumo by a remote TraCI client.
#define CMD_SET_SIM_VARIABLE
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
VehicleState
Definition of a vehicle state.
static bool commandDistanceRequest(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
The vehicle was built, but has not yet departed.
#define VAR_ARRIVED_VEHICLES_NUMBER
virtual void writeString(const std::string &s)
#define VAR_STOP_ENDING_VEHICLES_NUMBER
MSInsertionControl & getInsertionControl()
Returns the insertion control.
SUMOReal y() const
Returns the y-position.
void set(SUMOReal x, SUMOReal y)
#define VAR_PARKING_ENDING_VEHICLES_IDS
The vehicle ends to stop.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const std::vector< MSEdge * > &prohibited=std::vector< MSEdge * >()) const
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
const PositionVector & getShape() const
Returns this lane's shape.
virtual void compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
SUMOReal ymax() const
Returns maximum y-coordinate.
MSEdgeControl & getEdgeControl()
Returns the edge control.
#define VAR_PARKING_STARTING_VEHICLES_NUMBER
unsigned int getPersonNumber() const
Returns the number of persons waiting on this stop.
Representation of a lane in the micro simulation.
#define VAR_ARRIVED_VEHICLES_IDS
The vehicle ended being teleported.
#define VAR_BUS_STOP_WAITING