57 #ifdef CHECK_MEMORY_LEAKS
59 #endif // CHECK_MEMORY_LEAKS
108 std::vector<std::string> ids;
111 if ((*i).second->isOnRoad()) {
112 ids.push_back((*i).first);
124 if (sumoVehicle == 0) {
168 tempMsg.
writeInt((
int)std::distance(lanes.begin(), std::find(lanes.begin(), lanes.end(), v->
getLane())));
229 std::pair<const MSVehicle* const, SUMOReal> leaderInfo = v->
getLeader(dist);
233 tempMsg.
writeString(leaderInfo.first != 0 ? leaderInfo.first->getID() :
"");
246 if (inputStorage.
readInt() != 2) {
278 if (inputStorage.
readInt() != 2) {
328 unsigned int cnt = 0;
330 const std::vector<MSVehicle::LaneQ>& bestLanes = onRoad ? v->
getBestLanes() : std::vector<MSVehicle::LaneQ>();
331 tempContent.
writeInt((
int) bestLanes.size());
333 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
350 std::vector<std::string> bestContIDs;
352 bestContIDs.push_back((*j)->getID());
407 std::string warning =
"";
429 const bool shouldExist = variable !=
ADD && variable !=
ADD_FULL;
431 if (sumoVehicle == 0) {
437 if (v == 0 && shouldExist) {
445 int compoundSize = inputStorage.
readInt();
446 if (compoundSize != 4 && compoundSize != 5) {
468 bool parking =
false;
469 bool triggered =
false;
470 if (compoundSize == 5) {
475 parking = ((stopFlags & 1) != 0);
476 triggered = ((stopFlags & 2) != 0);
487 const std::vector<MSLane*>& allLanes = road->
getLanes();
488 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
492 if (!v->
addTraciStop(allLanes[laneIndex], pos, 0, waitTime, parking, triggered)) {
502 if (inputStorage.
readInt() != 0) {
506 if (!static_cast<MSVehicle*>(v)->hasStops()) {
510 if (!static_cast<MSVehicle*>(v)->resumeFromStopping()) {
512 std::ostringstream strs;
513 strs <<
"reached: " << sto.
reached;
514 strs <<
", duration:" << sto.
duration;
515 strs <<
", edge:" << (*sto.
edge)->getID();
516 strs <<
", startPos: " << sto.
startPos;
517 std::string posStr = strs.str();
527 if (inputStorage.
readInt() != 2) {
540 if ((laneIndex < 0) || (laneIndex >= (
int)(v->
getEdge()->
getLanes().size()))) {
544 std::vector<std::pair<SUMOTime, unsigned int> > laneTimeLine;
545 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
546 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + stickyTime, laneIndex));
554 if (inputStorage.
readInt() != 2) {
571 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
573 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + duration, newSpeed));
603 if (vehicleType == 0) {
624 std::vector<std::string> edgeIDs;
628 std::vector<const MSEdge*> edges;
639 int parameterCount = inputStorage.
readInt();
640 if (parameterCount == 4) {
666 }
else if (parameterCount == 2) {
686 }
else if (parameterCount == 1) {
709 int parameterCount = inputStorage.
readInt();
710 if (parameterCount == 4) {
736 }
else if (parameterCount == 2) {
756 }
else if (parameterCount == 1) {
779 if (inputStorage.
readInt() != 0) {
789 if (inputStorage.
readInt() != 0) {
808 if (inputStorage.
readInt() != 2) {
827 if (!v->
willPass(&destinationEdge)) {
832 while (v->
getEdge() != &destinationEdge) {
848 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
850 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), speed));
869 int laneChangeMode = 0;
892 if (inputStorage.
readInt() != 6) {
896 vehicleParams.
id = id;
919 if (vehicleParams.
depart < 0) {
920 const int proc =
static_cast<int>(-vehicleParams.
depart);
935 const int proc =
static_cast<int>(-vehicleParams.
departPos);
950 const int proc =
static_cast<int>(-vehicleParams.
departSpeed);
964 const int proc =
static_cast<int>(-vehicleParams.
departLane);
990 if (inputStorage.
readInt() != 14) {
994 vehicleParams.
id = id;
1005 std::string vTypeID;
1136 if (inputStorage.
readInt() != 4) {
1150 double x = 0, y = 0;
1162 std::string origID = edgeID +
" " +
toString(laneNum);
1164 edgeID =
'-' + edgeID;
1173 std::cout << std::endl <<
"begin vehicle " << v->
getID() <<
" vehPos:" << vehPos <<
" lane:" << v->
getLane()->
getID() << std::endl;
1176 std::cout <<
" want pos:" << pos <<
" edge:" << edgeID <<
" laneNum:" << laneNum << std::endl;
1180 MSLane* laneA, *laneB, *laneC;
1181 laneA = laneB = laneC = 0;
1182 SUMOReal lanePosA, lanePosB, lanePosC;
1183 SUMOReal bestDistanceA, bestDistanceB, bestDistanceC;
1184 bestDistanceA = bestDistanceB = bestDistanceC = 1000.;
1185 int routeOffsetA, routeOffsetB, routeOffsetC;
1186 routeOffsetA = routeOffsetB = routeOffsetC = 0;
1195 if (cFound && (bestDistanceA > maxRouteDistance && bestDistanceC > maxRouteDistance)) {
1202 }
else if (aFound) {
1204 }
else if (cFound) {
1239 const std::map<std::string, std::vector<MSLane*> >& vtdMap =
getOrBuildVTDMap();
1240 if (vtdMap.find(origID) == vtdMap.end()) {
1242 std::cout <<
" a failed - lane not in map" << std::endl;
1246 const std::vector<MSLane*>& lanes = vtdMap.find(origID)->second;
1247 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end() && bestDistance >
POSITION_EPS; ++i) {
1251 std::cout <<
" a at lane " << l->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1253 if (dist < bestDistance) {
1254 bestDistance = dist;
1265 std::cout <<
" a failed - no incoming lane" << std::endl;
1270 MSEdgeVector::const_iterator p = std::find(tedges.begin() + v.
getRoutePosition(), tedges.end(), &pni->
getEdge());
1271 if (p != tedges.end()) {
1275 std::cout <<
" a ok lane:" << (*lane)->getID() <<
" lanePos:" << lanePos <<
" routeOffset:" << routeOffset << std::endl;
1280 std::cout <<
" a failed - route position beyond route length" << std::endl;
1291 int lastBestRouteEdge = 0;
1292 int lastRouteEdge = 0;
1293 MSLane* bestRouteLane = 0;
1295 for (std::vector<MSLane*>::const_iterator i = bestLaneConts.begin(); i != bestLaneConts.end() && bestDistance >
POSITION_EPS; ++i) {
1296 MSEdge& e = (*i)->getEdge();
1300 const std::vector<MSLane*>& lanes = e.
getLanes();
1301 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance >
POSITION_EPS; ++k) {
1305 std::cout <<
" b at lane " << cl->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1307 if (dist < bestDistance) {
1308 bestDistance = dist;
1310 lastBestRouteEdge = lastRouteEdge;
1314 bestRouteLane = *lane;
1319 if (bestRouteLane == 0) {
1321 std::cout <<
" b failed - no best route lane" << std::endl;
1326 routeOffset = lastBestRouteEdge;
1328 std::cout <<
" b ok lane " << bestRouteLane->
getID() <<
" lanePos:" << lanePos <<
" best:" << lastBestRouteEdge << std::endl;
1341 MSLane* nameMatchingLane = 0;
1342 SUMOReal minDistNameMatchingLane = 1 << (11);
1343 for (; minDistLane == 0 && r < 10 && nameMatchingLane == 0; ++r) {
1344 std::set<std::string> into;
1348 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
1350 const std::vector<MSLane*>& lanes = e->
getLanes();
1351 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
1356 if (dist < minDistNameMatchingLane) {
1357 minDistNameMatchingLane = dist;
1358 nameMatchingLane = lane;
1362 if (dist < minDist) {
1369 *lane = nameMatchingLane != 0 ? nameMatchingLane : minDistLane;
1372 std::cout <<
" c failed - no matching lane" << std::endl;
1380 std::cout <<
" c ok, on same lane" << std::endl;
1384 MSEdge& destinationEdge = (*lane)->getEdge();
1385 MSEdge* routePos = &destinationEdge;
1387 routePos = &routePos->
getLanes()[0]->getLogicalPredecessorLane()->getEdge();
1393 unsigned int rindex = 0;
1395 while (!found && ((
int)(c - r) >= 0 || c + r < l)) {
1396 if ((
int)(c - r) >= 0 && route[c - r] == routePos) {
1400 if (c + r < l && route[c + r] == routePos) {
1410 std::cout <<
" c ok, on a different edge of same route" << std::endl;
1415 MSLane* firstLane = *lane;
1417 edges.push_back(&destinationEdge);
1420 edges.push_back(&firstLane->
getEdge());
1423 if (lc.size() != 0 && lc[0]->getLane() != 0) {
1424 edges.push_back(&lc[0]->getLane()->getEdge());
1427 std::cout <<
" c ok, on a different route" << std::endl;
1439 if (inputStorage.
readInt() != 2) {
1444 std::pair<const MSLane*, SUMOReal> roadPos;
1451 std::string roadID = inputStorage.
readString();
1454 pos = roadPos.first->getShape().positionAtOffset(roadPos.second);
1461 const double p1x = inputStorage.
readDouble();
1462 const double p1y = inputStorage.
readDouble();
1481 v->
getEdge(), &roadPos.first->getEdge());
1512 std::string newID = oType.
getID().find(
'@') == std::string::npos ? oType.
getID() +
"@" + veh->
getID() : oType.
getID();
1514 static_cast<MSVehicle*
>(veh)->replaceVehicleType(type);
1521 const std::map<std::string, std::vector<MSLane*> >&
1525 for (std::vector<MSEdge*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
1526 const std::vector<MSLane*>& lanes = (*i)->getLanes();
1527 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
1528 if ((*j)->knowsParameter(
"origId")) {
1529 std::string origID = (*j)->getParameter(
"origId",
"");
1531 gVTDMap[origID] = std::vector<MSLane*>();
1533 gVTDMap[origID].push_back(*j);
1538 gVTDMap[
"unknown"] = std::vector<MSLane*>();