26 #define INVALID_POSITION std::numeric_limits<double>::max()
47 MSLane* currentLane =
nullptr;
50 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
51 controlledLanes.begin(); laneVector != controlledLanes.end();
53 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
54 laneVector->begin(); lane != laneVector->end(); lane++) {
55 currentLane = (*lane);
68 MSLane* currentLane =
nullptr;
70 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
71 controlledLanes.begin(); laneVector != controlledLanes.end();
73 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
74 laneVector->begin(); lane != laneVector->end(); lane++) {
75 currentLane = (*lane);
85 MSLane* currentLane =
nullptr;
88 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
89 controlledLanes.begin(); laneVector != controlledLanes.end();
91 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
92 laneVector->begin(); lane != laneVector->end(); lane++) {
93 currentLane = (*lane);
108 MSLane* currentLane =
nullptr;
111 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
112 controlledLanes.begin(); laneVector != controlledLanes.end();
114 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
115 laneVector->begin(); lane != laneVector->end(); lane++) {
116 currentLane = (*lane);
136 lensorLength = sensorLength <= (lane->
getLength() - sensorPos) ? sensorLength : (lane->
getLength() - sensorPos);
153 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
174 sensorPos = (lane->
getLength() - sensorLength)
175 - (SENSOR_START <= lane->getLength() ?
SENSOR_START : 0);
179 sensorLength <= (lane->
getLength() - sensorPos) ?
180 sensorLength : (lane->
getLength() - sensorPos);
197 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
209 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator;
223 return sensorsIterator->second->getPassedVeh() + additional;
230 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator;
234 sensorsIterator->second->subtractPassedVeh(passed);
260 lensorLength = sensorLength <= (lane->
getLength() - sensorPos) ? sensorLength : (lane->
getLength() - sensorPos);
276 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
284 if (lensorLength < sensorLength * 0.9) {
285 std::ostringstream oss;
286 oss <<
"Sensor on lane " << lane->getID() <<
" is long " << lensorLength <<
", while it should be " << sensorLength <<
". Continuing it on the other lanes if possible";
288 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = lane->getIncomingLanes().begin(); it != lane->getIncomingLanes().end(); ++it) {
289 const MSEdge* edge = &it->lane->getEdge();
299 double availableLength = sensorLength - usedLength;
301 double length = availableLength <= continueOnLane->
getLength() ? availableLength : continueOnLane->
getLength();
310 std::ostringstream oss;
311 oss <<
"Continue sensor on lane " << continueOnLane->getID() <<
". Current length " << (length + usedLength);
314 if (length + usedLength < sensorLength * 0.9) {
315 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = continueOnLane->getIncomingLanes().begin(); it != continueOnLane->getIncomingLanes().end(); ++it) {
316 const MSEdge* edge = &it->lane->getEdge();
341 sensorPos = (lane->
getLength() - sensorLength)
342 - (SENSOR_START <= lane->getLength() ?
SENSOR_START : 0);
346 sensorLength <= (lane->
getLength() - sensorPos) ?
347 sensorLength : (lane->
getLength() - sensorPos);
364 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
384 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator =
m_sensorMap.find(laneId);
389 double estQL = sensorsIterator->second->getEstimateQueueLength();
410 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator =
m_sensorMap.find(laneId);
422 return sensorsIterator->second->getEstimatedCurrentVehicleNumber(
speedThresholdParam) + additional;
426 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator =
m_sensorMap.find(laneId);
439 return count(sensorsIterator->second) + additional;
443 MSLaneID_MaxSpeedMap::const_iterator sensorsIteratorIn =
m_maxSpeedMap.find(laneId);
446 WRITE_ERROR(
"MSSOTLE2Sensors::meanVehiclesSpeed:: No lane found " + laneId);
449 return sensorsIteratorIn->second;
457 MSLaneID_MSE2CollectorMap::const_iterator sensorsIteratorOut =
m_sensorMap.find(laneId);
460 WRITE_ERROR(
"MSSOTLE2Sensors::meanVehiclesSpeed:: No lane found " + laneId);
463 double meanSpeedAcc = 0;
464 int totalCarNumer = 0;
472 totalCarNumer += number;
474 meanSpeedAcc += mean * (double) number;
476 int number = sensorsIteratorOut->second->getCurrentVehicleNumber();
477 totalCarNumer += number;
478 double mean = sensorsIteratorOut->second->getCurrentMeanSpeed();
479 meanSpeedAcc += mean * (double) number;
480 return totalCarNumer == 0 ? -1 : meanSpeedAcc / (double) totalCarNumer;
483 std::string
trim(std::string& str) {
484 int first = (int)str.find_first_not_of(
' ');
485 int last = (int)str.find_last_not_of(
' ');
486 return str.substr(first, (last - first + 1));
489 std::vector<std::string>&
split(
const std::string& s,
char delim, std::vector<std::string>& elems) {
490 std::stringstream ss(s);
492 while (std::getline(ss, item, delim)) {
494 elems.push_back(item);
501 std::vector<std::string> types;
502 split(weightString,
';', types);
503 std::ostringstream logstr;
504 logstr <<
"[MSSOTLE2Sensors::setVehicleWeigths] ";
505 for (std::vector<std::string>::iterator typesIt = types.begin(); typesIt != types.end(); ++typesIt) {
506 std::vector<std::string> typeWeight;
507 split(*typesIt,
'=', typeWeight);
508 if (typeWeight.size() == 2) {
509 std::string type =
trim(typeWeight[0]);
511 logstr << type <<
"=" << value <<
" ";
524 const std::vector<MSE2Collector::VehicleInfo*> vehicles = sensor->
getCurrentVehicles();
525 std::ostringstream logstr;
526 logstr <<
"[MSSOTLE2Sensors::count]";
527 for (std::vector<MSE2Collector::VehicleInfo*>::const_iterator vit = vehicles.begin(); vit != vehicles.end(); ++vit) {
528 if ((*vit)->onDetector) {
529 const std::string vtype = (*vit)->type;