47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
55 using namespace traci;
175 if (inputStorage.
readInt() != 2) {
186 if (inputStorage.
readInt() != 3) {
215 std::pair<MSLane*, SUMOReal>
217 std::pair<MSLane*, SUMOReal> result;
218 std::vector<std::string> allEdgeIds;
222 for (std::vector<std::string>::iterator itId = allEdgeIds.begin(); itId != allEdgeIds.end(); itId++) {
224 for (std::vector<MSLane*>::const_iterator itLane = allLanes.begin(); itLane != allLanes.end(); itLane++) {
225 const SUMOReal newDistance = (*itLane)->getShape().distance(pos);
226 if (newDistance < minDistance) {
227 minDistance = newDistance;
228 result.first = (*itLane);
233 result.second = result.first->getShape().nearest_offset_to_point2D(pos,
false);
244 if (laneIndex < 0 || laneIndex >= (
int)edge->
getLanes().size()) {
248 if (pos < 0 || pos > lane->
getLength()) {
258 std::pair<MSLane*, SUMOReal> roadPos;
266 switch (srcPosType) {
277 cartesianPos.
set(x, y);
286 std::string roadID = inputStorage.
readString();
290 cartesianPos = geoPos = getLaneChecking(roadID, laneIdx, pos)->getShape().positionAtOffset(pos);
309 switch (destPosType) {
312 roadPos = convertCartesianToRoadMap(cartesianPos);
315 outputStorage.
writeString(roadPos.first->getEdge().getID());
317 const std::vector<MSLane*> lanes = roadPos.first->getEdge().getLanes();
318 outputStorage.
writeUnsignedByte((
int)distance(lanes.begin(), find(lanes.begin(), lanes.end(), roadPos.first)));
351 std::pair<const MSLane*, SUMOReal> roadPos1;
352 std::pair<const MSLane*, SUMOReal> roadPos2;
359 std::string roadID = inputStorage.
readString();
361 roadPos1.first = getLaneChecking(roadID, inputStorage.
readUnsignedByte(), roadPos1.second);
362 pos1 = roadPos1.first->getShape().positionAtOffset(roadPos1.second);
377 roadPos1 = convertCartesianToRoadMap(pos1);
389 std::string roadID = inputStorage.
readString();
391 roadPos2.first = getLaneChecking(roadID, inputStorage.
readUnsignedByte(), roadPos2.second);
392 pos2 = roadPos2.first->getShape().positionAtOffset(roadPos2.second);
407 roadPos2 = convertCartesianToRoadMap(pos2);
420 if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
422 distance = roadPos2.second - roadPos1.second;
427 MSRoute route(
"", newRoute,
false, 0, std::vector<SUMOVehicleParameter::Stop>());
428 distance = route.
getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
The vehicle has departed (was inserted into the network)
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
#define REQUEST_DRIVINGDIST
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
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.
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.
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
#define VAR_LOADED_VEHICLES_IDS
static bool processGet(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xaa: Get Edge Variable)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
#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 (in s)
#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.
virtual void writeInt(int)
virtual int readUnsignedByte()
TraCI server used to control sumo by a remote TraCI client.
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
#define POSITION_CONVERSION
A road/street connecting two junctions.
#define VAR_DEPARTED_VEHICLES_NUMBER
#define VAR_MIN_EXPECTED_VEHICLES
The vehicle arrived at his destination (is deleted)
std::vector< const MSEdge * > MSEdgeVector
#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
virtual void writeStringList(const std::vector< std::string > &s)
#define VAR_TELEPORT_ENDING_VEHICLES_IDS
The vehicle started to teleport.
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
#define VAR_DEPARTED_VEHICLES_IDS
MSBusStop * getBusStop(const std::string &id) const
Returns the named bus stop.
const Boundary & getConvBoundary() const
Returns the converted boundary.
The vehicle was built, but has not yet departed.
#define VAR_ARRIVED_VEHICLES_NUMBER
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
virtual void writeString(const std::string &s)
SUMOReal y() const
Returns the y-position.
void set(SUMOReal x, SUMOReal y)
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
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...
static bool commandPositionConversion(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
SUMOReal ymax() const
Returns maximum y-coordinate.
MSEdgeControl & getEdgeControl()
Returns the edge control.
static bool commandDistanceRequest(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
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.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
#define VAR_BUS_STOP_WAITING