55 #ifdef CHECK_MEMORY_LEAKS
57 #endif // CHECK_MEMORY_LEAKS
106 std::vector<std::string> ids;
109 if ((*i).second->isOnRoad()) {
110 ids.push_back((*i).first);
122 if (sumoVehicle == 0) {
160 tempMsg.
writeInt((
int)std::distance(lanes.begin(), std::find(lanes.begin(), lanes.end(), v->
getLane())));
224 if (inputStorage.
readInt() != 2) {
256 if (inputStorage.
readInt() != 2) {
306 unsigned int cnt = 0;
308 const std::vector<MSVehicle::LaneQ>& bestLanes = onRoad ? v->
getBestLanes() : std::vector<MSVehicle::LaneQ>();
309 tempContent.
writeInt((
int) bestLanes.size());
311 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
328 std::vector<std::string> bestContIDs;
330 bestContIDs.push_back((*j)->getID());
385 std::string warning =
"";
407 const bool shouldExist = variable !=
ADD;
409 if (sumoVehicle == 0) {
415 if (v == 0 && shouldExist) {
423 int compoundSize = inputStorage.
readInt();
424 if (compoundSize != 4 && compoundSize != 5) {
446 bool parking =
false;
447 bool triggered =
false;
448 if (compoundSize == 5) {
453 parking = ((stopFlags & 1) != 0);
454 triggered = ((stopFlags & 2) != 0);
465 const std::vector<MSLane*>& allLanes = road->
getLanes();
466 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
470 if (!v->
addTraciStop(allLanes[laneIndex], pos, 0, waitTime, parking, triggered)) {
480 if (inputStorage.
readInt() != 0) {
484 if (!static_cast<MSVehicle*>(v)->resumeFromStopping()) {
486 std::ostringstream strs;
487 strs <<
"reached: " << sto.
reached;
488 strs <<
", duration:" << sto.
duration;
489 strs <<
", edge:" << (*sto.
edge)->getID();
490 strs <<
", startPos: " << sto.
startPos;
491 std::string posStr = strs.str();
501 if (inputStorage.
readInt() != 2) {
514 if ((laneIndex < 0) || (laneIndex >= (
int)(v->
getEdge()->
getLanes().size()))) {
518 std::vector<std::pair<SUMOTime, unsigned int> > laneTimeLine;
519 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
520 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + stickyTime, laneIndex));
528 if (inputStorage.
readInt() != 2) {
545 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
547 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep() + duration, newSpeed));
577 if (vehicleType == 0) {
598 std::vector<std::string> edgeIDs;
602 std::vector<const MSEdge*> edges;
613 int parameterCount = inputStorage.
readInt();
614 if (parameterCount == 4) {
640 }
else if (parameterCount == 2) {
660 }
else if (parameterCount == 1) {
683 int parameterCount = inputStorage.
readInt();
684 if (parameterCount == 4) {
710 }
else if (parameterCount == 2) {
730 }
else if (parameterCount == 1) {
753 if (inputStorage.
readInt() != 0) {
763 if (inputStorage.
readInt() != 0) {
782 if (inputStorage.
readInt() != 2) {
801 if (!v->
willPass(&destinationEdge)) {
806 while (v->
getEdge() != &destinationEdge) {
822 std::vector<std::pair<SUMOTime, SUMOReal> > speedTimeLine;
824 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), speed));
825 speedTimeLine.push_back(std::make_pair(
SUMOTime_MAX, speed));
841 int laneChangeMode = 0;
864 if (inputStorage.
readInt() != 6) {
868 vehicleParams.
id = id;
891 if (vehicleParams.
depart < 0) {
892 const int proc =
static_cast<int>(-vehicleParams.
depart);
905 const int proc =
static_cast<int>(-vehicleParams.
departPos);
920 const int proc =
static_cast<int>(-vehicleParams.
departSpeed);
934 const int proc =
static_cast<int>(-vehicleParams.
departLane);
944 *params = vehicleParams;
996 if (inputStorage.
readInt() != 4) {
1010 double x = 0, y = 0;
1022 std::string origID = edgeID +
" " +
toString(laneNum);
1024 edgeID =
'-' + edgeID;
1033 std::cout << std::endl <<
"begin vehicle " << v->
getID() <<
" vehPos:" << vehPos <<
" lane:" << v->
getLane()->
getID() << std::endl;
1036 std::cout <<
" want pos:" << pos <<
" edge:" << edgeID <<
" laneNum:" << laneNum << std::endl;
1040 MSLane* laneA, *laneB, *laneC;
1041 laneA = laneB = laneC = 0;
1042 SUMOReal lanePosA, lanePosB, lanePosC;
1043 SUMOReal bestDistanceA, bestDistanceB, bestDistanceC;
1044 bestDistanceA = bestDistanceB = bestDistanceC = 1000.;
1045 int routeOffsetA, routeOffsetB, routeOffsetC;
1046 routeOffsetA = routeOffsetB = routeOffsetC = 0;
1055 if (cFound && (bestDistanceA > maxRouteDistance && bestDistanceC > maxRouteDistance)) {
1062 }
else if (aFound) {
1064 }
else if (cFound) {
1099 const std::map<std::string, std::vector<MSLane*> >& vtdMap =
getOrBuildVTDMap();
1100 if (vtdMap.find(origID) == vtdMap.end()) {
1102 std::cout <<
" a failed - lane not in map" << std::endl;
1106 const std::vector<MSLane*>& lanes = vtdMap.find(origID)->second;
1107 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end() && bestDistance >
POSITION_EPS; ++i) {
1111 std::cout <<
" a at lane " << l->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1113 if (dist < bestDistance) {
1114 bestDistance = dist;
1125 std::cout <<
" a failed - no incoming lane" << std::endl;
1130 MSEdgeVector::const_iterator p = std::find(tedges.begin() + v.
getRoutePosition(), tedges.end(), &pni->
getEdge());
1131 if (p != tedges.end()) {
1135 std::cout <<
" a ok lane:" << (*lane)->getID() <<
" lanePos:" << lanePos <<
" routeOffset:" << routeOffset << std::endl;
1140 std::cout <<
" a failed - route position beyond route length" << std::endl;
1151 int lastBestRouteEdge = 0;
1152 int lastRouteEdge = 0;
1153 MSLane* bestRouteLane = 0;
1155 for (std::vector<MSLane*>::const_iterator i = bestLaneConts.begin(); i != bestLaneConts.end() && bestDistance >
POSITION_EPS; ++i) {
1156 MSEdge& e = (*i)->getEdge();
1160 const std::vector<MSLane*>& lanes = e.
getLanes();
1161 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end() && bestDistance >
POSITION_EPS; ++k) {
1165 std::cout <<
" b at lane " << cl->
getID() <<
" dist:" << dist <<
" best:" << bestDistance << std::endl;
1167 if (dist < bestDistance) {
1168 bestDistance = dist;
1170 lastBestRouteEdge = lastRouteEdge;
1174 bestRouteLane = *lane;
1179 if (bestRouteLane == 0) {
1181 std::cout <<
" b failed - no best route lane" << std::endl;
1186 routeOffset = lastBestRouteEdge;
1188 std::cout <<
" b ok lane " << bestRouteLane->
getID() <<
" lanePos:" << lanePos <<
" best:" << lastBestRouteEdge << std::endl;
1201 MSLane* nameMatchingLane = 0;
1202 SUMOReal minDistNameMatchingLane = 1 << (11);
1203 for (; minDistLane == 0 && r < 10 && nameMatchingLane == 0; ++r) {
1204 std::set<std::string> into;
1208 for (std::set<std::string>::const_iterator j = into.begin(); j != into.end(); ++j) {
1210 const std::vector<MSLane*>& lanes = e->
getLanes();
1211 for (std::vector<MSLane*>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
1216 if (dist < minDistNameMatchingLane) {
1217 minDistNameMatchingLane = dist;
1218 nameMatchingLane = lane;
1222 if (dist < minDist) {
1229 *lane = nameMatchingLane != 0 ? nameMatchingLane : minDistLane;
1232 std::cout <<
" c failed - no matching lane" << std::endl;
1240 std::cout <<
" c ok, on same lane" << std::endl;
1244 MSEdge& destinationEdge = (*lane)->getEdge();
1245 MSEdge* routePos = &destinationEdge;
1247 routePos = &routePos->
getLanes()[0]->getLogicalPredecessorLane()->getEdge();
1253 unsigned int rindex = 0;
1255 while (!found && ((
int)(c - r) >= 0 || c + r < l)) {
1256 if ((
int)(c - r) >= 0 && route[c - r] == routePos) {
1260 if (c + r < l && route[c + r] == routePos) {
1270 std::cout <<
" c ok, on a different edge of same route" << std::endl;
1275 MSLane* firstLane = *lane;
1277 edges.push_back(&destinationEdge);
1280 edges.push_back(&firstLane->
getEdge());
1283 if (lc.size() != 0 && lc[0]->getLane() != 0) {
1284 edges.push_back(&lc[0]->getLane()->getEdge());
1287 std::cout <<
" c ok, on a different route" << std::endl;
1299 if (inputStorage.
readInt() != 2) {
1304 std::pair<const MSLane*, SUMOReal> roadPos;
1311 std::string roadID = inputStorage.
readString();
1314 pos = roadPos.first->getShape().positionAtOffset(roadPos.second);
1321 const double p1x = inputStorage.
readDouble();
1322 const double p1y = inputStorage.
readDouble();
1341 v->
getEdge(), &roadPos.first->getEdge());
1372 std::string newID = oType.
getID().find(
'@') == std::string::npos ? oType.
getID() +
"@" + veh->
getID() : oType.
getID();
1374 static_cast<MSVehicle*
>(veh)->replaceVehicleType(type);
1381 const std::map<std::string, std::vector<MSLane*> >&
1385 for (std::vector<MSEdge*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
1386 const std::vector<MSLane*>& lanes = (*i)->getLanes();
1387 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
1388 if ((*j)->knowsParameter(
"origId")) {
1389 std::string origID = (*j)->getParameter(
"origId",
"");
1391 gVTDMap[origID] = std::vector<MSLane*>();
1393 gVTDMap[origID].push_back(*j);
1398 gVTDMap[
"unknown"] = std::vector<MSLane*>();