25 #define INVALID_POSITION std::numeric_limits<double>::max()
46 MSLane* currentLane =
nullptr;
49 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
50 controlledLanes.begin(); laneVector != controlledLanes.end();
52 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
53 laneVector->begin(); lane != laneVector->end(); lane++) {
54 currentLane = (*lane);
67 MSLane* currentLane =
nullptr;
69 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
70 controlledLanes.begin(); laneVector != controlledLanes.end();
72 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
73 laneVector->begin(); lane != laneVector->end(); lane++) {
74 currentLane = (*lane);
84 MSLane* currentLane =
nullptr;
87 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
88 controlledLanes.begin(); laneVector != controlledLanes.end();
90 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
91 laneVector->begin(); lane != laneVector->end(); lane++) {
92 currentLane = (*lane);
107 MSLane* currentLane =
nullptr;
110 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
111 controlledLanes.begin(); laneVector != controlledLanes.end();
113 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
114 laneVector->begin(); lane != laneVector->end(); lane++) {
115 currentLane = (*lane);
135 lensorLength = sensorLength <= (lane->
getLength() - sensorPos) ? sensorLength : (lane->
getLength() - sensorPos);
152 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
173 sensorPos = (lane->
getLength() - sensorLength)
174 - (SENSOR_START <= lane->getLength() ?
SENSOR_START : 0);
178 sensorLength <= (lane->
getLength() - sensorPos) ?
179 sensorLength : (lane->
getLength() - sensorPos);
196 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
208 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator;
222 return sensorsIterator->second->getPassedVeh() + additional;
229 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator;
233 sensorsIterator->second->subtractPassedVeh(passed);
259 lensorLength = sensorLength <= (lane->
getLength() - sensorPos) ? sensorLength : (lane->
getLength() - sensorPos);
275 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
283 if (lensorLength < sensorLength * 0.9) {
284 std::ostringstream oss;
285 oss <<
"Sensor on lane " << lane->getID() <<
" is long " << lensorLength <<
", while it should be " << sensorLength <<
". Continuing it on the other lanes if possible";
287 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = lane->getIncomingLanes().begin(); it != lane->getIncomingLanes().end(); ++it) {
288 const MSEdge* edge = &it->lane->getEdge();
298 double availableLength = sensorLength - usedLength;
300 double length = availableLength <= continueOnLane->
getLength() ? availableLength : continueOnLane->
getLength();
309 std::ostringstream oss;
310 oss <<
"Continue sensor on lane " << continueOnLane->getID() <<
". Current length " << (length + usedLength);
313 if (length + usedLength < sensorLength * 0.9) {
314 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator it = continueOnLane->getIncomingLanes().begin(); it != continueOnLane->getIncomingLanes().end(); ++it) {
315 const MSEdge* edge = &it->lane->getEdge();
340 sensorPos = (lane->
getLength() - sensorLength)
341 - (SENSOR_START <= lane->getLength() ?
SENSOR_START : 0);
345 sensorLength <= (lane->
getLength() - sensorPos) ?
346 sensorLength : (lane->
getLength() - sensorPos);
363 (lane->getLength() - sensorPos - lensorLength),
INVALID_POSITION, lensorLength,
383 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator =
m_sensorMap.find(laneId);
388 double estQL = sensorsIterator->second->getEstimateQueueLength();
409 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator =
m_sensorMap.find(laneId);
421 return sensorsIterator->second->getEstimatedCurrentVehicleNumber(
speedThresholdParam) + additional;
425 MSLaneID_MSE2CollectorMap::const_iterator sensorsIterator =
m_sensorMap.find(laneId);
438 return count(sensorsIterator->second) + additional;
442 MSLaneID_MaxSpeedMap::const_iterator sensorsIteratorIn =
m_maxSpeedMap.find(laneId);
445 WRITE_ERROR(
"MSSOTLE2Sensors::meanVehiclesSpeed:: No lane found " + laneId);
448 return sensorsIteratorIn->second;
456 MSLaneID_MSE2CollectorMap::const_iterator sensorsIteratorOut =
m_sensorMap.find(laneId);
459 WRITE_ERROR(
"MSSOTLE2Sensors::meanVehiclesSpeed:: No lane found " + laneId);
462 double meanSpeedAcc = 0;
463 int totalCarNumer = 0;
471 totalCarNumer += number;
473 meanSpeedAcc += mean * (double) number;
475 int number = sensorsIteratorOut->second->getCurrentVehicleNumber();
476 totalCarNumer += number;
477 double mean = sensorsIteratorOut->second->getCurrentMeanSpeed();
478 meanSpeedAcc += mean * (double) number;
479 return totalCarNumer == 0 ? -1 : meanSpeedAcc / (double) totalCarNumer;
482 std::string
trim(std::string& str) {
483 int first = (int)str.find_first_not_of(
' ');
484 int last = (int)str.find_last_not_of(
' ');
485 return str.substr(first, (last - first + 1));
488 std::vector<std::string>&
split(
const std::string& s,
char delim, std::vector<std::string>& elems) {
489 std::stringstream ss(s);
491 while (std::getline(ss, item, delim)) {
493 elems.push_back(item);
500 std::vector<std::string> types;
501 split(weightString,
';', types);
502 std::ostringstream logstr;
503 logstr <<
"[MSSOTLE2Sensors::setVehicleWeigths] ";
504 for (std::vector<std::string>::iterator typesIt = types.begin(); typesIt != types.end(); ++typesIt) {
505 std::vector<std::string> typeWeight;
506 split(*typesIt,
'=', typeWeight);
507 if (typeWeight.size() == 2) {
508 std::string type =
trim(typeWeight[0]);
510 logstr << type <<
"=" << value <<
" ";
523 const std::vector<MSE2Collector::VehicleInfo*> vehicles = sensor->
getCurrentVehicles();
524 std::ostringstream logstr;
525 logstr <<
"[MSSOTLE2Sensors::count]";
526 for (std::vector<MSE2Collector::VehicleInfo*>::const_iterator vit = vehicles.begin(); vit != vehicles.end(); ++vit) {
527 if ((*vit)->onDetector) {
528 const std::string vtype = (*vit)->type;