void NLDetectorBuilder::buildInductLoop(const std::string &id, const std::string &lane, SUMOReal pos, int splInterval, OutputDevice& device, bool friendlyPos) throw(InvalidArgument) { if (splInterval<0) { throw InvalidArgument("Negative sampling frequency (in e1-detector '" + id + "')."); } if (splInterval==0) { throw InvalidArgument("Sampling frequency must not be zero (in e1-detector '" + id + "')."); } // get and check the lane MSLane *clane = getLaneChecking(lane, id); if (pos<0) { pos = clane->getLength() + pos; } #ifdef HAVE_MESOSIM if (!MSGlobals::gUseMesoSim) { #endif // get and check the position pos = getPositionChecking(pos, clane, friendlyPos, id); // build the loop MSInductLoop *loop = createInductLoop(id, clane, pos); // add the file output myNet.getDetectorControl().add(loop, device, splInterval); #ifdef HAVE_MESOSIM } else { if (pos<0) { pos = clane->getLength() + pos; } MESegment *s = MSGlobals::gMesoNet->getSegmentForEdge(clane->getEdge()); MESegment *prev = s; SUMOReal cpos = 0; while (cpos+prev->getLength()<pos&&s!=0) { prev = s; cpos += s->getLength(); s = s->getNextSegment(); } SUMOReal rpos = pos-cpos;//-prev->getLength(); if (rpos>prev->getLength()||rpos<0) { if (friendlyPos) { rpos = prev->getLength() - (SUMOReal) 0.1; } else { throw InvalidArgument("The position of detector '" + id + "' lies beyond the lane's '" + lane + "' length."); } } MEInductLoop *loop = createMEInductLoop(id, prev, rpos); myNet.getDetectorControl().add(loop, device, splInterval); } #endif }
void NLDetectorBuilder::buildInductLoop(const std::string& id, const std::string& lane, double pos, SUMOTime splInterval, const std::string& device, bool friendlyPos, const std::string& vTypes) { checkSampleInterval(splInterval, SUMO_TAG_E1DETECTOR, id); // get and check the lane MSLane* clane = getLaneChecking(lane, SUMO_TAG_E1DETECTOR, id); // get and check the position pos = getPositionChecking(pos, clane, friendlyPos, id); // build the loop MSDetectorFileOutput* loop = createInductLoop(id, clane, pos, vTypes); // add the file output myNet.getDetectorControl().add(SUMO_TAG_INDUCTION_LOOP, loop, device, splInterval); }
void NLDetectorBuilder::buildInductLoop(const std::string& id, const std::string& lane, SUMOReal pos, int splInterval, const std::string& device, bool friendlyPos, bool splitByType) { checkSampleInterval(splInterval, SUMO_TAG_E1DETECTOR, id); // get and check the lane MSLane* clane = getLaneChecking(lane, SUMO_TAG_E1DETECTOR, id); if (!MSGlobals::gUseMesoSim) { // get and check the position pos = getPositionChecking(pos, clane, friendlyPos, id); // build the loop MSDetectorFileOutput* loop = createInductLoop(id, clane, pos, splitByType); // add the file output myNet.getDetectorControl().add(SUMO_TAG_INDUCTION_LOOP, loop, device, splInterval); } else { #ifdef HAVE_INTERNAL if (pos < 0) { pos = clane->getLength() + pos; } MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(clane->getEdge()); MESegment* prev = s; SUMOReal cpos = 0; while (cpos + prev->getLength() < pos && s != 0) { prev = s; cpos += s->getLength(); s = s->getNextSegment(); } SUMOReal rpos = pos - cpos; //-prev->getLength(); if (rpos > prev->getLength() || rpos < 0) { if (friendlyPos) { rpos = prev->getLength() - (SUMOReal) 0.1; } else { throw InvalidArgument("The position of detector '" + id + "' lies beyond the lane's '" + lane + "' length."); } } MEInductLoop* loop = createMEInductLoop(id, prev, rpos); myNet.getDetectorControl().add(SUMO_TAG_INDUCTION_LOOP, loop, device, splInterval); #endif } }