168 if (inputStorage.
readInt() != 2) {
179 if (inputStorage.
readInt() != 3) {
211 std::string warning =
"";
252 outputStorage.
writeInt((
int) ids.size());
264 std::pair<MSLane*, double>
266 std::pair<MSLane*, double> result;
267 std::vector<std::string> allEdgeIds;
271 for (std::vector<std::string>::iterator itId = allEdgeIds.begin(); itId != allEdgeIds.end(); itId++) {
273 for (std::vector<MSLane*>::const_iterator itLane = allLanes.begin(); itLane != allLanes.end(); itLane++) {
274 const double newDistance = (*itLane)->getShape().distance2D(pos);
275 if (newDistance < minDistance) {
276 minDistance = newDistance;
277 result.first = (*itLane);
282 result.second = result.first->getShape().nearest_offset_to_point2D(pos,
false);
290 std::pair<MSLane*, double> roadPos;
298 switch (srcPosType) {
309 cartesianPos.
set(x, y);
318 std::string roadID = inputStorage.
readString();
324 z = cartesianPos.
z();
343 switch (destPosType) {
349 outputStorage.
writeString(roadPos.first->getEdge().getID());
351 const std::vector<MSLane*> lanes = roadPos.first->getEdge().getLanes();
352 outputStorage.
writeUnsignedByte((
int)distance(lanes.begin(), find(lanes.begin(), lanes.end(), roadPos.first)));
385 std::pair<const MSLane*, double> roadPos1;
386 std::pair<const MSLane*, double> roadPos2;
393 std::string roadID = inputStorage.
readString();
396 pos1 = roadPos1.first->getShape().positionAtOffset(roadPos1.second);
423 std::string roadID = inputStorage.
readString();
426 pos2 = roadPos2.first->getShape().positionAtOffset(roadPos2.second);
451 double distance = 0.0;
454 if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
456 distance = roadPos2.second - roadPos1.second;
461 MSRoute route(
"", newRoute,
false, 0, std::vector<SUMOVehicleParameter::Stop>());
462 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
double ymin() const
Returns minimum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
#define REQUEST_DRIVINGDIST
static void writeVehicleStateIDs(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
double z() const
Returns the z-position.
const Boundary & getConvBoundary() const
Returns the converted boundary.
A lane area vehicles can halt at.
#define VAR_PARKING_STARTING_VEHICLES_IDS
#define VAR_STOP_ENDING_VEHICLES_IDS
#define VAR_PARKING_ENDING_VEHICLES_NUMBER
#define POSITION_LON_LAT_ALT
double y() const
Returns the y-position.
virtual double readDouble()
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
double x() const
Returns the x-position.
virtual bool 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...
#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.
const PositionVector & getShape() const
Returns this lane's shape.
#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
std::vector< const MSEdge * > ConstMSEdgeVector
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
virtual void writeUnsignedByte(int)
void set(double x, double y)
set positions x and y
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
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()
std::vector< std::string > getEdgeNames() const
Returns the list of names of all known edges.
The vehicles starts to stop.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
#define POSITION_CONVERSION
#define CMD_SAVE_SIMSTATE
#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.
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
#define VAR_STOP_STARTING_VEHICLES_IDS
#define VAR_NET_BOUNDING_BOX
A point in 2D or 3D with translation and scaling methods.
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
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
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
double xmin() const
Returns minimum x-coordinate.
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
The vehicle ends to park.
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)
std::string toHex(const T i, std::streamsize numDigits=0)
#define VAR_STOP_ENDING_VEHICLES_NUMBER
MSInsertionControl & getInsertionControl()
Returns the insertion control.
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
#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...
static std::pair< MSLane *, double > convertCartesianToRoadMap(Position pos)
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
MSEdgeControl & getEdgeControl()
Returns the edge control.
#define VAR_PARKING_STARTING_VEHICLES_NUMBER
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
double ymax() const
Returns maximum y-coordinate.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
#define VAR_ARRIVED_VEHICLES_IDS
MSStoppingPlace * getBusStop(const std::string &id) const
Returns the named bus stop.
The vehicle ended being teleported.
#define VAR_BUS_STOP_WAITING
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.