Lane.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711
  1. #include "Lane.h"
  2. /**
  3. * Lane section class. Holds all the lane section information
  4. *
  5. *
  6. *
  7. *
  8. */
  9. /**
  10. * Constructor. Sets basic lane section parameters
  11. * @param s s-offset of the lane section
  12. */
  13. LaneSection::LaneSection (double s)
  14. { mS=s; }
  15. /**
  16. * Add a lane to the lane section
  17. * @param side the side of the road to which the lane will be added
  18. * @param id ID of the lane
  19. * @param type Type of the lane (Section 6.5 of the OpenDRIVE specification)
  20. * @param level Level parameter of the road
  21. * @param sort Defines if the lanes should be sorted when added. True by default
  22. */
  23. unsigned int LaneSection::AddLane(short int side, int id, string type, bool level, bool sort)
  24. {
  25. unsigned int index=0;
  26. //if lanes are sorted, add the lane to the correct side
  27. if(sort)
  28. {
  29. if(side<0)
  30. {
  31. index=GetLaneCount();
  32. mLaneVector.push_back(Lane(side,id,type,level));
  33. mLastAddedLane=index;
  34. }
  35. else if(side==0)
  36. {
  37. int sz=GetLaneCount();
  38. if(sz>0)
  39. {
  40. for(int i=0; i<sz; i++)
  41. {
  42. if(mLaneVector[i].GetId()<0)
  43. {
  44. index=i;
  45. mLaneVector.insert(mLaneVector.begin()+index, Lane(side,id,type,level));
  46. mLastAddedLane=index;
  47. break;
  48. }
  49. }
  50. }
  51. else
  52. {
  53. index=0;
  54. mLaneVector.push_back(Lane(side,id,type,level));
  55. mLastAddedLane=index;
  56. }
  57. }
  58. else
  59. {
  60. index=0;
  61. mLaneVector.insert(mLaneVector.begin(), Lane(side,id,type,level));
  62. mLastAddedLane=index;
  63. }
  64. return index;
  65. }
  66. else
  67. {
  68. index=GetLaneCount();
  69. mLaneVector.push_back(Lane(side,id,type,level));
  70. mLastAddedLane=index;
  71. return index;
  72. }
  73. }
  74. /**
  75. * Delete the lane at the provided index
  76. */
  77. void LaneSection::DeleteLane(unsigned int index)
  78. {
  79. mLaneVector.erase(mLaneVector.begin()+index);
  80. }
  81. /**
  82. * Delete the outside left or right lane
  83. */
  84. void LaneSection::DeleteLeftLane()
  85. {
  86. mLaneVector.erase(mLaneVector.begin());
  87. }
  88. void LaneSection::DeleteRigthLane()
  89. {
  90. mLaneVector.pop_back();
  91. }
  92. /**
  93. * Get the last lane
  94. * @return A pointer to Lane object
  95. */
  96. Lane* LaneSection::GetLastLane()
  97. {
  98. if (mLaneVector.size()>0)
  99. return &mLaneVector.at(mLaneVector.size()-1);
  100. else
  101. return NULL;
  102. }
  103. /**
  104. * Get the last added lane (which might not be the one from the end of the vector)
  105. * @return A pointer to Lane object
  106. */
  107. Lane* LaneSection::GetLastAddedLane()
  108. {
  109. if(mLastAddedLane<mLaneVector.size())
  110. return &mLaneVector.at(mLastAddedLane);
  111. else
  112. return NULL;
  113. }
  114. /**
  115. * Get the last left lane
  116. * @return A pointer to Lane object
  117. */
  118. Lane* LaneSection::GetLastLeftLane()
  119. {
  120. if(mLaneVector.size()>0)
  121. {
  122. if(mLaneVector.at(0).GetSide()>0)
  123. return &mLaneVector.at(0);
  124. else
  125. return NULL;
  126. }
  127. else
  128. return NULL;
  129. }
  130. /**
  131. * Get the last center lane
  132. * @return A pointer to Lane object
  133. */
  134. Lane* LaneSection::GetLastCenterLane()
  135. {
  136. int sz=GetLaneCount();
  137. for(int i=0; i<sz; i++)
  138. {
  139. if(mLaneVector[i].GetSide()==0)
  140. {
  141. return &mLaneVector.at(i);
  142. }
  143. }
  144. return NULL;
  145. }
  146. /**
  147. * Get the last right lane
  148. * @return A pointer to Lane object
  149. */
  150. Lane* LaneSection::GetLastRightLane()
  151. {
  152. if(mLaneVector.size()>0)
  153. {
  154. int indexLast=mLaneVector.size()-1;
  155. if(mLaneVector.at(indexLast).GetSide()<0)
  156. return &mLaneVector.at(indexLast);
  157. else
  158. return NULL;
  159. }
  160. else return NULL;
  161. }
  162. /**
  163. * Get the lane vector
  164. * @return A pointer to a vector of type Lane
  165. */
  166. vector<Lane>* LaneSection::GetLaneVector()
  167. {
  168. return &mLaneVector;
  169. }
  170. /**
  171. * Get the lane by providing its index
  172. * @param i Index of the lane to be returned
  173. * @return A pointer to Lane object
  174. */
  175. Lane* LaneSection::GetLane(unsigned int i)
  176. {
  177. if ((mLaneVector.size()>0)&&(i<mLaneVector.size()))
  178. return &mLaneVector.at(i);
  179. else
  180. return NULL;
  181. }
  182. /**
  183. * Get the lane number
  184. * @return Unsigned int with that stores the number of lanes
  185. */
  186. unsigned int LaneSection::GetLaneCount()
  187. {
  188. return mLaneVector.size();
  189. }
  190. /**
  191. * Get the lane section s-offset
  192. */
  193. double LaneSection::GetS()
  194. {
  195. return mS;
  196. }
  197. /**
  198. * Get the lane section final s-offset which is the s-offset of the last record of the lane section
  199. */
  200. double LaneSection::GetS2()
  201. {
  202. double lHighestS=0;
  203. int sz=GetLaneCount();
  204. for(int i=0; i<sz; i++)
  205. {
  206. Lane *lLane = GetLane(i);
  207. //width
  208. LaneWidth *lWidth = lLane->GetLaneWidth(lLane->GetLaneWidthCount()-1);
  209. if(lWidth!=NULL)
  210. {
  211. if(lWidth->GetS()>lHighestS) lHighestS=lWidth->GetS();
  212. }
  213. //road mark
  214. LaneRoadMark *lRoadMark = lLane->GetLaneRoadMark(lLane->GetLaneRoadMarkCount()-1);
  215. if(lRoadMark!=NULL)
  216. {
  217. if(lRoadMark->GetS()>lHighestS) lHighestS=lRoadMark->GetS();
  218. }
  219. //material
  220. LaneMaterial *lMaterial = lLane->GetLaneMaterial(lLane->GetLaneMaterialCount()-1);
  221. if(lMaterial!=NULL)
  222. {
  223. if(lMaterial->GetS()>lHighestS) lHighestS=lMaterial->GetS();
  224. }
  225. //visibility
  226. LaneVisibility *lVisibility = lLane->GetLaneVisibility(lLane->GetLaneVisibilityCount()-1);
  227. if(lVisibility!=NULL)
  228. {
  229. if(lVisibility->GetS()>lHighestS) lHighestS=lVisibility->GetS();
  230. }
  231. //speed
  232. LaneSpeed *lSpeed = lLane->GetLaneSpeed(lLane->GetLaneSpeedCount()-1);
  233. if(lSpeed!=NULL)
  234. {
  235. if(lSpeed->GetS()>lHighestS) lHighestS=lSpeed->GetS();
  236. }
  237. //access
  238. LaneAccess *lAccess = lLane->GetLaneAccess(lLane->GetLaneAccessCount()-1);
  239. if(lAccess!=NULL)
  240. {
  241. if(lAccess->GetS()>lHighestS) lHighestS=lAccess->GetS();
  242. }
  243. //height
  244. LaneHeight *lHeight = lLane->GetLaneHeight(lLane->GetLaneHeightCount()-1);
  245. if(lHeight!=NULL)
  246. {
  247. if(lHeight->GetS()>lHighestS) lHighestS=lHeight->GetS();
  248. }
  249. }
  250. return mS+lHighestS;
  251. }
  252. /**
  253. * Set the lane section s-offset
  254. */
  255. void LaneSection::SetS(double value)
  256. {
  257. mS=value;
  258. }
  259. /**
  260. * Check if the tested s-offset is inside the lane section interval
  261. * @param A double s-offset value that has to be checked
  262. * @return Return true if the s-offset value belongs to current lane section, false otherwise
  263. */
  264. bool LaneSection::CheckInterval(double s_check)
  265. {
  266. if (s_check>=mS)
  267. return true;
  268. else
  269. return false;
  270. }
  271. /**
  272. * Return the lane-0 index in the lanes vector
  273. * @return An unsigned int value with the index
  274. */
  275. unsigned int LaneSection::GetZeroLaneIndex()
  276. {
  277. for (unsigned int i=0; i<GetLaneCount(); i++)
  278. {
  279. if(mLaneVector.at(i).GetId()==0)
  280. return i;
  281. }
  282. return 0;
  283. }
  284. /**
  285. * Return the number of left lanes
  286. * @return An unsigned int value with the number of left lanes
  287. */
  288. unsigned int LaneSection::GetLeftLaneCount()
  289. {
  290. unsigned int count=0;
  291. for (unsigned int i=0;i<GetLaneCount();i++)
  292. {
  293. if(mLaneVector.at(i).GetSide()==1)
  294. count++;
  295. }
  296. return count;
  297. }
  298. /**
  299. * Return the number of central lanes
  300. * @return An unsigned int value with the number of central lanes
  301. */
  302. unsigned int LaneSection::GetCenterLaneCount()
  303. {
  304. unsigned int count=0;
  305. for(unsigned int i=0; i<GetLaneCount(); i++)
  306. {
  307. if(mLaneVector[i].GetSide()==0)
  308. {
  309. count++;
  310. }
  311. }
  312. return count;
  313. }
  314. /**
  315. * Return the number of right lanes
  316. * @return An unsigned int value with the number of right lanes
  317. */
  318. unsigned int LaneSection::GetRightLaneCount()
  319. {
  320. unsigned int count=0;
  321. for (unsigned int i=0;i<GetLaneCount();i++)
  322. {
  323. if(mLaneVector.at(i).GetSide()==-1)
  324. count++;
  325. }
  326. return count;
  327. }
  328. /**
  329. * Fill a special structure with all the lane / lane section data that is sampled at a provided s-offset position along the road
  330. * This data is used later to fill the geometry arrays
  331. * @param s_chek s-offset along the road at which to sample the lane section
  332. * @param laneSectionSample The structure that has to be filled with the sampled data
  333. * @return Returns true if the operation was successful.
  334. */
  335. bool LaneSection::FillLaneSectionSample(double s_check, LaneSectionSample& laneSectionSample)
  336. {
  337. //clear and initialize variables
  338. laneSectionSample.ClearVectors();
  339. double width=0;
  340. int leftMax=0;
  341. int rightMax=GetLaneCount()-1;
  342. s_check-=GetS();
  343. bool level;
  344. string type;
  345. LaneHeight height;
  346. LaneRoadMark roadMark;
  347. //Fill in left width vector
  348. //if there are left lanes
  349. if (GetLeftLaneCount()>0)
  350. {
  351. //go through all of them
  352. for (int i=GetZeroLaneIndex(); i>=leftMax;i--)
  353. {
  354. type=GetLane(i)->GetType();
  355. level=GetLane(i)->GetLevel();
  356. height=GetLane(i)->GetHeightValue(s_check);
  357. roadMark=GetLane(i)->GetRoadMarkValue(s_check);
  358. //and accumulate the width
  359. width=GetLane(i)->GetWidthValue(s_check);
  360. laneSectionSample.AddLeftRecord(type, width, height, roadMark, level);
  361. }
  362. }
  363. //same for the right side of the road
  364. if (GetRightLaneCount()>0)
  365. {
  366. //go through all of them
  367. for (int i=GetZeroLaneIndex(); i<=rightMax;i++)
  368. {
  369. type=GetLane(i)->GetType();
  370. level=GetLane(i)->GetLevel();
  371. height=GetLane(i)->GetHeightValue(s_check);
  372. roadMark=GetLane(i)->GetRoadMarkValue(s_check);
  373. //and accumulate the width
  374. width=GetLane(i)->GetWidthValue(s_check);
  375. laneSectionSample.AddRightRecord(type, width, height, roadMark, level);
  376. }
  377. }
  378. return true;
  379. }
  380. /**
  381. * Destructor. Delete all the members of the vectors: mLeft, mCenter, mRight
  382. */
  383. LaneSection::~LaneSection()
  384. {
  385. // DELETING LANES
  386. mLaneVector.clear();
  387. }
  388. /**
  389. * @brief LaneSection::SetSingleSide
  390. * @param singleSide
  391. */
  392. void LaneSection::SetSingleSide(std::string singleSide)
  393. {
  394. msingleSide = singleSide;
  395. }
  396. /**
  397. * @brief LaneSection::GetSingleSide
  398. * @return singleSide
  399. */
  400. string LaneSection::GetSingleSide()
  401. {
  402. return msingleSide;
  403. }
  404. /**
  405. * Lane Section Sample. Holds all the lane information at a certain S value including lane widths, levels,
  406. * heights, etc
  407. *
  408. *
  409. *
  410. *
  411. */
  412. LaneSectionSample::LaneSectionSample()
  413. {}
  414. /*
  415. * Add various elements to the structure. Depending on the the value to be added, various input parameters are used.
  416. * The methods are divided into left and right for left and right sides of the road.
  417. */
  418. void LaneSectionSample::AddLeftType(string type)
  419. { mLeftTypeVector.push_back(type); }
  420. void LaneSectionSample::AddLeftWidth(double width)
  421. { mLeftWidthVector.push_back(width); }
  422. void LaneSectionSample::AddLeftHeight(LaneHeight height)
  423. { mLeftHeightVector.push_back(height); }
  424. void LaneSectionSample::AddLeftRoadMark(LaneRoadMark roadMark)
  425. { mLeftRoadMarkVector.push_back(roadMark); }
  426. void LaneSectionSample::AddLeftLevel(bool level)
  427. { mLeftLevelVector.push_back(level); }
  428. void LaneSectionSample::AddRightType(string type)
  429. { mRightTypeVector.push_back(type); }
  430. void LaneSectionSample::AddRightWidth(double width)
  431. { mRightWidthVector.push_back(width); }
  432. void LaneSectionSample::AddRightHeight(LaneHeight height)
  433. { mRightHeightVector.push_back(height); }
  434. void LaneSectionSample::AddRightRoadMark(LaneRoadMark roadMark)
  435. { mRightRoadMarkVector.push_back(roadMark); }
  436. void LaneSectionSample::AddRightLevel(bool level)
  437. { mRightLevelVector.push_back(level); }
  438. void LaneSectionSample::AddLeftRecord(string type, double width, LaneHeight height, LaneRoadMark roadMark, bool level)
  439. {
  440. AddLeftType(type);
  441. AddLeftWidth(width);
  442. AddLeftHeight(height);
  443. AddLeftRoadMark(roadMark);
  444. AddLeftLevel(level);
  445. }
  446. void LaneSectionSample::AddRightRecord(string type, double width, LaneHeight height, LaneRoadMark roadMark, bool level)
  447. {
  448. AddRightType(type);
  449. AddRightWidth(width);
  450. AddRightHeight(height);
  451. AddRightRoadMark(roadMark);
  452. AddRightLevel(level);
  453. }
  454. /*
  455. * Get various elements of the structure. The methods return type depends on the elements that are returned.
  456. * The methods are divided into left and right for left and right sides of the road.
  457. */
  458. string LaneSectionSample::GetLeftType(unsigned int i)
  459. { return mLeftTypeVector.at(i); }
  460. double LaneSectionSample::GetLeftWidth(unsigned int i)
  461. { return mLeftWidthVector.at(i); }
  462. LaneHeight LaneSectionSample::GetLeftHeight(unsigned int i)
  463. { return mLeftHeightVector.at(i); }
  464. LaneRoadMark LaneSectionSample::GetLeftRoadMark(unsigned int i)
  465. { return mLeftRoadMarkVector.at(i); }
  466. bool LaneSectionSample::GetLeftLevel(unsigned int i)
  467. { return mLeftLevelVector.at(i); }
  468. string LaneSectionSample::GetRightType(unsigned int i)
  469. { return mRightTypeVector.at(i); }
  470. double LaneSectionSample::GetRightWidth(unsigned int i)
  471. { return mRightWidthVector.at(i); }
  472. LaneHeight LaneSectionSample::GetRightHeight(unsigned int i)
  473. { return mRightHeightVector.at(i); }
  474. LaneRoadMark LaneSectionSample::GetRightRoadMark(unsigned int i)
  475. { return mRightRoadMarkVector.at(i); }
  476. bool LaneSectionSample::GetRightLevel(unsigned int i)
  477. { return mRightLevelVector.at(i); }
  478. /*
  479. * Get the number of elements in the vectors
  480. */
  481. unsigned int LaneSectionSample::GetLeftVectorsSize()
  482. { return mLeftWidthVector.size(); }
  483. unsigned int LaneSectionSample::GetRightVectorsSize()
  484. { return mRightWidthVector.size(); }
  485. /*
  486. * Get the various record vectors. The vector type depends on the record
  487. * The methods are divided into left and right for left and right sides of the road.
  488. */
  489. vector<string>* LaneSectionSample::GetLeftTypeVector()
  490. { return &mLeftTypeVector; }
  491. vector<double>* LaneSectionSample::GetLeftWidthVector()
  492. { return &mLeftWidthVector; }
  493. vector<LaneHeight>* LaneSectionSample::GetLeftHeigthVector()
  494. { return &mLeftHeightVector; }
  495. vector<LaneRoadMark>* LaneSectionSample::GetLeftRoadMarkVector()
  496. { return &mLeftRoadMarkVector; }
  497. vector<bool>* LaneSectionSample::GetLeftLevelVector()
  498. { return &mLeftLevelVector; }
  499. vector<string>* LaneSectionSample::GetRightTypeVector()
  500. { return &mRightTypeVector; }
  501. vector<double>* LaneSectionSample::GetRightWidthVector()
  502. { return &mRightWidthVector; }
  503. vector<LaneHeight>* LaneSectionSample::GetRightHeigthVector()
  504. { return &mRightHeightVector; }
  505. vector<LaneRoadMark>* LaneSectionSample::GetRightRoadMarkVector()
  506. { return &mRightRoadMarkVector; }
  507. vector<bool>* LaneSectionSample::GetRightLevelVector()
  508. { return &mRightLevelVector; }
  509. /*
  510. * Clear the vectors
  511. */
  512. void LaneSectionSample::ClearVectors()
  513. {
  514. mLeftTypeVector.clear();
  515. mLeftWidthVector.clear();
  516. mLeftHeightVector.clear();
  517. mLeftRoadMarkVector.clear();
  518. mLeftLevelVector.clear();
  519. mRightTypeVector.clear();
  520. mRightWidthVector.clear();
  521. mRightHeightVector.clear();
  522. mRightRoadMarkVector.clear();
  523. mRightLevelVector.clear();
  524. }
  525. /**
  526. * Lane class. Holds all the record data that describes a lane
  527. *
  528. *
  529. *
  530. *
  531. *
  532. */
  533. /**
  534. * Constructor
  535. */
  536. Lane::Lane(short int side, int id, string type, bool level)
  537. { mSide=side; mId=id; mType=type; mLevel=level; mPredecessorExists=false; mSuccessorExists=false; }
  538. /**
  539. * Various set methods.
  540. */
  541. void Lane::SetSide(short int side)
  542. {
  543. mSide=side;
  544. }
  545. void Lane::SetId(int id)
  546. {
  547. mId=id;
  548. }
  549. void Lane::SetType(string type)
  550. {
  551. mType=type;
  552. }
  553. void Lane::SetLevel(bool level)
  554. {
  555. mLevel=level;
  556. }
  557. //-------------
  558. void Lane::SetPredecessor(int predecessor)
  559. { mPredecessor=predecessor; mPredecessorExists=true; }
  560. //-------------
  561. void Lane::SetSuccessor(int successor)
  562. { mSuccessor=successor; mSuccessorExists=true; }
  563. /**
  564. * Remove lane linkage
  565. */
  566. void Lane::RemovePredecessor()
  567. { mPredecessor=0; mPredecessorExists=false; }
  568. void Lane::RemoveSuccessor()
  569. { mSuccessor=0; mSuccessorExists=false; }
  570. /**
  571. * @brief Lane::AddBorderRecord Add Border Record
  572. * @param s
  573. * @param a
  574. * @param b
  575. * @param c
  576. * @param d
  577. * @return
  578. */
  579. unsigned int Lane::AddBorderRecord(double s, double a, double b, double c, double d)
  580. {
  581. // Gets the index where the record should be inserted in the vector
  582. unsigned int index = CheckBorderInterval(s)+1;
  583. // If larger than the record count - push to the back
  584. if(index>=GetLaneBorderCount()) mLaneBorder.push_back(LaneBorder(s,a,b,c,d));
  585. // else insert in the middle
  586. else mLaneBorder.insert(mLaneBorder.begin()+index, LaneBorder(s,a,b,c,d));
  587. // Save the last added record index
  588. mLastAddedLaneBorder=index;
  589. return index;
  590. }
  591. /**
  592. * Methods used to add child records to the respective vectors
  593. */
  594. unsigned int Lane::AddWidthRecord(double s, double a, double b, double c, double d)
  595. {
  596. // Gets the index where the record should be inserted in the vector
  597. unsigned int index = CheckWidthInterval(s)+1;
  598. // If larger than the record count - push to the back
  599. if(index>=GetLaneWidthCount()) mLaneWidth.push_back(LaneWidth(s,a,b,c,d));
  600. // else insert in the middle
  601. else mLaneWidth.insert(mLaneWidth.begin()+index, LaneWidth(s,a,b,c,d));
  602. // Save the last added record index
  603. mLastAddedLaneWidth=index;
  604. return index;
  605. }
  606. //-------------
  607. unsigned int Lane::AddRoadMarkRecord(double sOffset, string type, string weight, string color, double width, string laneChange)
  608. {
  609. // Check the first method in the group for details
  610. unsigned int index = CheckRoadMarkInterval(sOffset)+1;
  611. if(index>=GetLaneRoadMarkCount()) mLaneRoadMark.push_back(LaneRoadMark(sOffset, type, weight, color, width, laneChange));
  612. else mLaneRoadMark.insert(mLaneRoadMark.begin()+index, LaneRoadMark(sOffset, type, weight, color, width, laneChange));
  613. mLastAddedLaneRoadMark=index;
  614. return index;
  615. }
  616. //-------------
  617. unsigned int Lane::AddMaterialRecord(double sOffset, string surface, double friction, double roughness)
  618. {
  619. // Check the first method in the group for details
  620. unsigned int index = CheckMaterialInterval(sOffset)+1;
  621. if(index>=GetLaneMaterialCount()) mLaneMaterial.push_back(LaneMaterial(sOffset,surface,friction,roughness));
  622. else mLaneMaterial.insert(mLaneMaterial.begin()+index, LaneMaterial(sOffset,surface,friction,roughness));
  623. mLastAddedLaneMaterial=index;
  624. return index;
  625. }
  626. //-------------
  627. unsigned int Lane::AddVisibilityRecord(double sOffset, double forward, double back, double left, double right)
  628. {
  629. // Check the first method in the group for details
  630. unsigned int index = CheckVisibilityInterval(sOffset)+1;
  631. if(index>=GetLaneVisibilityCount()) mLaneVisibility.push_back(LaneVisibility(sOffset,forward,back,left,right));
  632. else mLaneVisibility.insert(mLaneVisibility.begin()+index, LaneVisibility(sOffset,forward,back,left,right));
  633. mLastAddedLaneVisibility=index;
  634. return index;
  635. }
  636. //-------------
  637. unsigned int Lane::AddSpeedRecord(double sOffset, double max)
  638. {
  639. // Check the first method in the group for details
  640. unsigned int index = CheckSpeedInterval(sOffset)+1;
  641. if(index>=GetLaneSpeedCount()) mLaneSpeed.push_back(LaneSpeed(sOffset,max));
  642. else mLaneSpeed.insert(mLaneSpeed.begin()+index, LaneSpeed(sOffset,max));
  643. mLastAddedLaneSpeed=index;
  644. return index;
  645. }
  646. //-------------
  647. unsigned int Lane::AddAccessRecord(double sOffset, string restriction)
  648. {
  649. // Check the first method in the group for details
  650. unsigned int index = CheckAccessInterval(sOffset)+1;
  651. if(index>=GetLaneAccessCount()) mLaneAccess.push_back(LaneAccess(sOffset,restriction));
  652. else mLaneAccess.insert(mLaneAccess.begin()+index, LaneAccess(sOffset,restriction));
  653. mLastAddedLaneAccess=index;
  654. return index;
  655. }
  656. //-------------
  657. unsigned int Lane::AddHeightRecord(double sOffset, double inner, double outer)
  658. {
  659. // Check the first method in the group for details
  660. unsigned int index = CheckHeightInterval(sOffset)+1;
  661. if(index>=GetLaneHeightCount()) mLaneHeight.push_back(LaneHeight(sOffset,inner,outer));
  662. else mLaneHeight.insert(mLaneHeight.begin()+index, LaneHeight(sOffset,inner,outer));
  663. mLastAddedLaneHeight=index;
  664. return index;
  665. }
  666. /**
  667. * @brief Lane::CloneLaneBorder
  668. * @param index
  669. * @return
  670. */
  671. unsigned int Lane::CloneLaneBorder(unsigned int index)
  672. {
  673. // Clone the object and insert it in the middle of the vector
  674. if(index<mLaneBorder.size()-1)
  675. mLaneBorder.insert(mLaneBorder.begin()+index+1, mLaneBorder[index]);
  676. // or just push it to the back
  677. else if(index==mLaneBorder.size()-1)
  678. mLaneBorder.push_back(mLaneBorder[index]);
  679. // Save the last added record index
  680. mLastAddedLaneBorder=index+1;
  681. return mLastAddedLaneBorder;
  682. }
  683. /**
  684. * Methods used to clone child records in the respective vectors
  685. */
  686. unsigned int Lane::CloneLaneWidth(unsigned int index)
  687. {
  688. // Clone the object and insert it in the middle of the vector
  689. if(index<mLaneWidth.size()-1)
  690. mLaneWidth.insert(mLaneWidth.begin()+index+1, mLaneWidth[index]);
  691. // or just push it to the back
  692. else if(index==mLaneWidth.size()-1)
  693. mLaneWidth.push_back(mLaneWidth[index]);
  694. // Save the last added record index
  695. mLastAddedLaneWidth=index+1;
  696. return mLastAddedLaneWidth;
  697. }
  698. unsigned int Lane::CloneLaneRoadMark(unsigned int index)
  699. {
  700. // Check the first method in the group for details
  701. if(index<mLaneRoadMark.size()-1)
  702. mLaneRoadMark.insert(mLaneRoadMark.begin()+index+1, mLaneRoadMark[index]);
  703. else if(index==mLaneRoadMark.size()-1)
  704. mLaneRoadMark.push_back(mLaneRoadMark[index]);
  705. mLastAddedLaneRoadMark=index+1;
  706. return mLastAddedLaneRoadMark;
  707. }
  708. unsigned int Lane::CloneLaneMaterial(unsigned int index)
  709. {
  710. // Check the first method in the group for details
  711. if(index<mLaneMaterial.size()-1)
  712. mLaneMaterial.insert(mLaneMaterial.begin()+index+1, mLaneMaterial[index]);
  713. else if(index==mLaneMaterial.size()-1)
  714. mLaneMaterial.push_back(mLaneMaterial[index]);
  715. mLastAddedLaneMaterial=index+1;
  716. return mLastAddedLaneMaterial;
  717. }
  718. unsigned int Lane::CloneLaneVisibility(unsigned int index)
  719. {
  720. // Check the first method in the group for details
  721. if(index<mLaneVisibility.size()-1)
  722. mLaneVisibility.insert(mLaneVisibility.begin()+index+1, mLaneVisibility[index]);
  723. else if(index==mLaneVisibility.size()-1)
  724. mLaneVisibility.push_back(mLaneVisibility[index]);
  725. mLastAddedLaneVisibility=index+1;
  726. return mLastAddedLaneVisibility;
  727. }
  728. unsigned int Lane::CloneLaneSpeed(unsigned int index)
  729. {
  730. // Check the first method in the group for details
  731. if(index<mLaneSpeed.size()-1)
  732. mLaneSpeed.insert(mLaneSpeed.begin()+index+1, mLaneSpeed[index]);
  733. else if(index==mLaneSpeed.size()-1)
  734. mLaneSpeed.push_back(mLaneSpeed[index]);
  735. mLastAddedLaneSpeed=index+1;
  736. return mLastAddedLaneSpeed;
  737. }
  738. unsigned int Lane::CloneLaneAccess(unsigned int index)
  739. {
  740. // Check the first method in the group for details
  741. if(index<mLaneAccess.size()-1)
  742. mLaneAccess.insert(mLaneAccess.begin()+index+1, mLaneAccess[index]);
  743. else if(index==mLaneAccess.size()-1)
  744. mLaneAccess.push_back(mLaneAccess[index]);
  745. mLastAddedLaneAccess=index+1;
  746. return mLastAddedLaneAccess;
  747. }
  748. unsigned int Lane::CloneLaneHeight(unsigned int index)
  749. {
  750. // Check the first method in the group for details
  751. if(index<mLaneHeight.size()-1)
  752. mLaneHeight.insert(mLaneHeight.begin()+index+1, mLaneHeight[index]);
  753. else if(index==mLaneHeight.size()-1)
  754. mLaneHeight.push_back(mLaneHeight[index]);
  755. mLastAddedLaneHeight=index+1;
  756. return mLastAddedLaneHeight;
  757. }
  758. /**
  759. * Methods used to delete child records from the respective vectors
  760. */
  761. void Lane::DeleteLaneBoder(unsigned int index)
  762. {
  763. mLaneBorder.erase(mLaneBorder.begin()+index);
  764. }
  765. void Lane::DeleteLaneWidth(unsigned int index)
  766. {
  767. mLaneWidth.erase(mLaneWidth.begin()+index);
  768. }
  769. void Lane::DeleteLaneRoadMark(unsigned int index)
  770. {
  771. mLaneRoadMark.erase(mLaneRoadMark.begin()+index);
  772. }
  773. void Lane::DeleteLaneMaterial(unsigned int index)
  774. {
  775. mLaneMaterial.erase(mLaneMaterial.begin()+index);
  776. }
  777. void Lane::DeleteLaneVisibility(unsigned int index)
  778. {
  779. mLaneVisibility.erase(mLaneVisibility.begin()+index);
  780. }
  781. void Lane::DeleteLaneSpeed(unsigned int index)
  782. {
  783. mLaneSpeed.erase(mLaneSpeed.begin()+index);
  784. }
  785. void Lane::DeleteLaneAccess(unsigned int index)
  786. {
  787. mLaneAccess.erase(mLaneAccess.begin()+index);
  788. }
  789. void Lane::DeleteLaneHeight(unsigned int index)
  790. {
  791. mLaneHeight.erase(mLaneHeight.begin()+index);
  792. }
  793. /**
  794. * Getters of the lane parameters
  795. */
  796. int Lane::GetSide()
  797. {
  798. return mSide;
  799. }
  800. int Lane::GetId()
  801. {
  802. return mId;
  803. }
  804. string Lane::GetType()
  805. {
  806. return mType;
  807. }
  808. bool Lane::GetLevel()
  809. {
  810. return mLevel;
  811. }
  812. /**
  813. * Check if linkage information is provided
  814. */
  815. bool Lane::IsPredecessorSet()
  816. {
  817. return mPredecessorExists;
  818. }
  819. int Lane::GetPredecessor()
  820. {
  821. return mPredecessor;
  822. }
  823. bool Lane::IsSuccessorSet()
  824. {
  825. return mSuccessorExists;
  826. }
  827. int Lane::GetSuccessor()
  828. {
  829. return mSuccessor;
  830. }
  831. /**
  832. * Get pointers to the records vectors
  833. */
  834. vector <LaneBorder> *Lane::GetLaneBorderVector()
  835. { return &mLaneBorder; }
  836. vector <LaneWidth> *Lane::GetLaneWidthVector()
  837. { return &mLaneWidth; }
  838. vector <LaneRoadMark> *Lane::GetLaneRoadMarkVector()
  839. { return &mLaneRoadMark; }
  840. vector <LaneMaterial> *Lane::GetLaneMaterialVector()
  841. { return &mLaneMaterial; }
  842. vector <LaneVisibility> *Lane::GetLaneVisibilityVector()
  843. { return &mLaneVisibility; }
  844. vector <LaneSpeed> *Lane::GetLaneSpeedVector()
  845. { return &mLaneSpeed; }
  846. vector <LaneAccess> *Lane::GetLaneAccessVector()
  847. { return &mLaneAccess; }
  848. vector <LaneHeight> *Lane::GetLaneHeightVector()
  849. { return &mLaneHeight; }
  850. /**
  851. * Get the number of elements in a certain vector
  852. */
  853. unsigned int Lane::GetLaneBorderCount()
  854. { return mLaneBorder.size(); }
  855. unsigned int Lane::GetLaneWidthCount()
  856. { return mLaneWidth.size(); }
  857. unsigned int Lane::GetLaneRoadMarkCount()
  858. { return mLaneRoadMark.size(); }
  859. unsigned int Lane::GetLaneMaterialCount()
  860. { return mLaneMaterial.size(); }
  861. unsigned int Lane::GetLaneVisibilityCount()
  862. { return mLaneVisibility.size(); }
  863. unsigned int Lane::GetLaneSpeedCount()
  864. { return mLaneSpeed.size(); }
  865. unsigned int Lane::GetLaneAccessCount()
  866. { return mLaneAccess.size(); }
  867. unsigned int Lane::GetLaneHeightCount()
  868. { return mLaneHeight.size(); }
  869. /**
  870. * Get the elements of a certain vectors at position i
  871. */
  872. LaneBorder* Lane::GetLaneBorder(unsigned int i)
  873. {
  874. if ((mLaneBorder.size()>0)&&(i<mLaneBorder.size()))
  875. return &mLaneBorder.at(i);
  876. else
  877. return NULL;
  878. }
  879. LaneWidth* Lane::GetLaneWidth(unsigned int i)
  880. {
  881. if ((mLaneWidth.size()>0)&&(i<mLaneWidth.size()))
  882. return &mLaneWidth.at(i);
  883. else
  884. return NULL;
  885. }
  886. LaneRoadMark* Lane::GetLaneRoadMark(unsigned int i)
  887. {
  888. if ((mLaneRoadMark.size()>0)&&(i<mLaneRoadMark.size()))
  889. return &mLaneRoadMark.at(i);
  890. else
  891. return NULL;
  892. }
  893. LaneMaterial* Lane::GetLaneMaterial(unsigned int i)
  894. {
  895. if ((mLaneMaterial.size()>0)&&(i<mLaneMaterial.size()))
  896. return &mLaneMaterial.at(i);
  897. else
  898. return NULL;
  899. }
  900. LaneVisibility* Lane::GetLaneVisibility(unsigned int i)
  901. {
  902. if ((mLaneVisibility.size()>0)&&(i<mLaneVisibility.size()))
  903. return &mLaneVisibility.at(i);
  904. else
  905. return NULL;
  906. }
  907. LaneSpeed* Lane::GetLaneSpeed(unsigned int i)
  908. {
  909. if ((mLaneSpeed.size()>0)&&(i<mLaneSpeed.size()))
  910. return &mLaneSpeed.at(i);
  911. else
  912. return NULL;
  913. }
  914. LaneAccess* Lane::GetLaneAccess(unsigned int i)
  915. {
  916. if ((mLaneAccess.size()>0)&&(i<mLaneAccess.size()))
  917. return &mLaneAccess.at(i);
  918. else
  919. return NULL;
  920. }
  921. LaneHeight* Lane::GetLaneHeight(unsigned int i)
  922. {
  923. if ((mLaneHeight.size()>0)&&(i<mLaneHeight.size()))
  924. return &mLaneHeight.at(i);
  925. else
  926. return NULL;
  927. }
  928. /**
  929. * Get the last elements of a certain vectors
  930. */
  931. LaneBorder* Lane::GetLastLaneBorder()
  932. {
  933. if (mLaneBorder.size()>0)
  934. return &mLaneBorder.at(mLaneBorder.size()-1);
  935. else
  936. return NULL;
  937. }
  938. LaneWidth* Lane::GetLastLaneWidth()
  939. {
  940. if (mLaneWidth.size()>0)
  941. return &mLaneWidth.at(mLaneWidth.size()-1);
  942. else
  943. return NULL;
  944. }
  945. LaneRoadMark* Lane::GetLastLaneRoadMark()
  946. {
  947. if (mLaneRoadMark.size()>0)
  948. return &mLaneRoadMark.at(mLaneRoadMark.size()-1);
  949. else
  950. return NULL;
  951. }
  952. LaneMaterial* Lane::GetLastLaneMaterial()
  953. {
  954. if (mLaneMaterial.size()>0)
  955. return &mLaneMaterial.at(mLaneMaterial.size()-1);
  956. else
  957. return NULL;
  958. }
  959. LaneVisibility* Lane::GetLastLaneVisibility()
  960. {
  961. if (mLaneVisibility.size()>0)
  962. return &mLaneVisibility.at(mLaneVisibility.size()-1);
  963. else
  964. return NULL;
  965. }
  966. LaneSpeed* Lane::GetLastLaneSpeed()
  967. {
  968. if (mLaneSpeed.size()>0)
  969. return &mLaneSpeed.at(mLaneSpeed.size()-1);
  970. else
  971. return NULL;
  972. }
  973. LaneAccess* Lane::GetLastLaneAccess()
  974. {
  975. if (mLaneAccess.size()>0)
  976. return &mLaneAccess.at(mLaneAccess.size()-1);
  977. else
  978. return NULL;
  979. }
  980. LaneHeight* Lane::GetLastLaneHeight()
  981. {
  982. if (mLaneHeight.size()>0)
  983. return &mLaneHeight.at(mLaneHeight.size()-1);
  984. else
  985. return NULL;
  986. }
  987. /**
  988. * Get the last added elements of a certain vectors (their position might not be at the end of the vector)
  989. */
  990. LaneBorder* Lane::GetLastAddedLaneBorder()
  991. {
  992. if(mLastAddedLaneBorder<mLaneBorder.size())
  993. return &mLaneBorder.at(mLastAddedLaneBorder);
  994. else
  995. return NULL;
  996. }
  997. LaneWidth* Lane::GetLastAddedLaneWidth()
  998. {
  999. if(mLastAddedLaneWidth<mLaneWidth.size())
  1000. return &mLaneWidth.at(mLastAddedLaneWidth);
  1001. else
  1002. return NULL;
  1003. }
  1004. LaneRoadMark* Lane::GetLastAddedLaneRoadMark()
  1005. {
  1006. if(mLastAddedLaneRoadMark<mLaneRoadMark.size())
  1007. return &mLaneRoadMark.at(mLastAddedLaneRoadMark);
  1008. else
  1009. return NULL;
  1010. }
  1011. LaneMaterial* Lane::GetLastAddedLaneMaterial()
  1012. {
  1013. if(mLastAddedLaneMaterial<mLaneMaterial.size())
  1014. return &mLaneMaterial.at(mLastAddedLaneMaterial);
  1015. else
  1016. return NULL;
  1017. }
  1018. LaneVisibility* Lane::GetLastAddedLaneVisibility()
  1019. {
  1020. if(mLastAddedLaneVisibility<mLaneVisibility.size())
  1021. return &mLaneVisibility.at(mLastAddedLaneVisibility);
  1022. else
  1023. return NULL;
  1024. }
  1025. LaneSpeed* Lane::GetLastAddedLaneSpeed()
  1026. {
  1027. if(mLastAddedLaneSpeed<mLaneSpeed.size())
  1028. return &mLaneSpeed.at(mLastAddedLaneSpeed);
  1029. else
  1030. return NULL;
  1031. }
  1032. LaneAccess* Lane::GetLastAddedLaneAccess()
  1033. {
  1034. if(mLastAddedLaneAccess<mLaneAccess.size())
  1035. return &mLaneAccess.at(mLastAddedLaneAccess);
  1036. else
  1037. return NULL;
  1038. }
  1039. LaneHeight* Lane::GetLastAddedLaneHeight()
  1040. {
  1041. if(mLastAddedLaneHeight<mLaneHeight.size())
  1042. return &mLaneHeight.at(mLastAddedLaneHeight);
  1043. else
  1044. return NULL;
  1045. }
  1046. /**
  1047. * Check the intervals and return the index of the records that applies to the provided s-offset
  1048. */
  1049. int Lane::CheckBorderInterval(double s_check)
  1050. {
  1051. int res=-1;
  1052. //Go through all the width records
  1053. for (unsigned int i=0;i<mLaneBorder.size();i++)
  1054. {
  1055. //check if the s_check belongs to the current record
  1056. if (s_check >= mLaneBorder.at(i).GetS())
  1057. res=i; //assign it to the result id
  1058. else
  1059. break; //if not, break;
  1060. }
  1061. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1062. }
  1063. int Lane::CheckWidthInterval(double s_check)
  1064. {
  1065. int res=-1;
  1066. //Go through all the width records
  1067. for (unsigned int i=0;i<mLaneWidth.size();i++)
  1068. {
  1069. //check if the s_check belongs to the current record
  1070. if (s_check >= mLaneWidth.at(i).GetS())
  1071. res=i; //assign it to the result id
  1072. else
  1073. break; //if not, break;
  1074. }
  1075. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1076. }
  1077. int Lane::CheckRoadMarkInterval(double s_check)
  1078. {
  1079. int res=-1;
  1080. //Go through all the road mark records
  1081. for (unsigned int i=0;i<mLaneRoadMark.size();i++)
  1082. {
  1083. //check if the s_check belongs to the current record
  1084. if (s_check >= mLaneRoadMark.at(i).GetS())
  1085. res=i; //assign it to the result id
  1086. else
  1087. break; //if not, break;
  1088. }
  1089. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1090. }
  1091. int Lane::CheckMaterialInterval(double s_check)
  1092. {
  1093. int res=-1;
  1094. //Go through all the material records
  1095. for (unsigned int i=0;i<mLaneMaterial.size();i++)
  1096. {
  1097. //check if the s_check belongs to the current record
  1098. if (s_check >= mLaneMaterial.at(i).GetS())
  1099. res=i; //assign it to the result id
  1100. else
  1101. break; //if not, break;
  1102. }
  1103. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1104. }
  1105. int Lane::CheckVisibilityInterval(double s_check)
  1106. {
  1107. int res=-1;
  1108. //Go through all the visibility records
  1109. for (unsigned int i=0;i<mLaneVisibility.size();i++)
  1110. {
  1111. //check if the s_check belongs to the current record
  1112. if (s_check >= mLaneVisibility.at(i).GetS())
  1113. res=i; //assign it to the result id
  1114. else
  1115. break; //if not, break;
  1116. }
  1117. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1118. }
  1119. int Lane::CheckSpeedInterval(double s_check)
  1120. {
  1121. int res=-1;
  1122. //Go through all the speed records
  1123. for (unsigned int i=0;i<mLaneSpeed.size();i++)
  1124. {
  1125. //check if the s_check belongs to the current record
  1126. if (s_check >= mLaneSpeed.at(i).GetS())
  1127. res=i; //assign it to the result id
  1128. else
  1129. break; //if not, break;
  1130. }
  1131. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1132. }
  1133. int Lane::CheckAccessInterval(double s_check)
  1134. {
  1135. int res=-1;
  1136. //Go through all the access records
  1137. for (unsigned int i=0;i<mLaneAccess.size();i++)
  1138. {
  1139. //check if the s_check belongs to the current record
  1140. if (s_check >= mLaneAccess.at(i).GetS())
  1141. res=i; //assign it to the result id
  1142. else
  1143. break; //if not, break;
  1144. }
  1145. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1146. }
  1147. int Lane::CheckHeightInterval(double s_check)
  1148. {
  1149. int res=-1;
  1150. //Go through all the height records
  1151. for (unsigned int i=0;i<mLaneHeight.size();i++)
  1152. {
  1153. //check if the s_check belongs to the current record
  1154. if (s_check >= mLaneHeight.at(i).GetS())
  1155. res=i; //assign it to the result id
  1156. else
  1157. break; //if not, break;
  1158. }
  1159. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1160. }
  1161. /**
  1162. * Evaluate the record and return the width value
  1163. */
  1164. double Lane::GetBorderValue(double s_check)
  1165. {
  1166. double retVal=0;
  1167. //find the record where s_check belongs
  1168. int index=CheckBorderInterval(s_check);
  1169. //If found, return the type
  1170. if (index>=0)
  1171. retVal= mLaneBorder.at(index).GetValue(s_check);
  1172. return retVal;
  1173. }
  1174. double Lane::GetWidthValue(double s_check)
  1175. {
  1176. double retVal=0;
  1177. //find the record where s_check belongs
  1178. int index=CheckWidthInterval(s_check);
  1179. //If found, return the type
  1180. if (index>=0)
  1181. retVal= mLaneWidth.at(index).GetValue(s_check);
  1182. return retVal;
  1183. }
  1184. /**
  1185. * Evaluate the record and return the height object
  1186. */
  1187. LaneHeight Lane::GetHeightValue(double s_check)
  1188. {
  1189. LaneHeight retVal(0,0,0);
  1190. //find the record where s_check belongs
  1191. int index=CheckHeightInterval(s_check);
  1192. //If found, return the type
  1193. if (index>=0)
  1194. {
  1195. retVal.SetInner(mLaneHeight.at(index).GetInner());
  1196. retVal.SetOuter(mLaneHeight.at(index).GetOuter());
  1197. }
  1198. return retVal;
  1199. }
  1200. void Lane::SetuserData(std::string struserData)
  1201. {
  1202. muserData = struserData;
  1203. }
  1204. void Lane::GetuserData(std::string &struserData)
  1205. {
  1206. struserData = muserData;
  1207. }
  1208. /**
  1209. * Evaluate the road marks records and return the road mark object corresponding to the provided s-offset
  1210. */
  1211. LaneRoadMark Lane::GetRoadMarkValue(double s_check)
  1212. {
  1213. LaneRoadMark returnRoadMark;
  1214. //find the record where s_check belongs
  1215. int index=CheckRoadMarkInterval(s_check);
  1216. //If found, return the params
  1217. if (index>=0)
  1218. {
  1219. returnRoadMark.SetColor(mLaneRoadMark.at(index).GetColor());
  1220. returnRoadMark.SetLaneChange(mLaneRoadMark.at(index).GetLaneChange());
  1221. returnRoadMark.SetType(mLaneRoadMark.at(index).GetType());
  1222. returnRoadMark.SetWeight(mLaneRoadMark.at(index).GetWeight());
  1223. returnRoadMark.SetWidth(mLaneRoadMark.at(index).GetWidth());
  1224. }
  1225. return returnRoadMark;
  1226. }
  1227. /**
  1228. * Destructor
  1229. * Delete all the members of the vectors:
  1230. * mLaneWidth, mRoadMark, mLaneMaterial, mLaneVisibility, mLaneSpeed, mLaneAccess, mLaneHeight
  1231. */
  1232. Lane::~Lane()
  1233. {
  1234. // DELETING LANE WIDTHS
  1235. mLaneWidth.clear();
  1236. // DELETING LANE ROAD MARKS
  1237. mLaneRoadMark.clear();
  1238. // DELETING LANE MATERIAL
  1239. mLaneMaterial.clear();
  1240. // DELETING LANE VISIBILITY
  1241. mLaneVisibility.clear();
  1242. // DELETING LANE SPEED
  1243. mLaneSpeed.clear();
  1244. // DELETING LANE ACCESS
  1245. mLaneAccess.clear();
  1246. // DELETING LANE HEIGHTS
  1247. mLaneHeight.clear();
  1248. //DELETE LANE BORDERS
  1249. mLaneBorder.clear();
  1250. }
  1251. /**
  1252. * @brief LaneWidth::LaneWidth
  1253. * @param s
  1254. * @param a
  1255. * @param b
  1256. * @param c
  1257. * @param d
  1258. */
  1259. LaneBorder::LaneBorder(double s, double a, double b, double c, double d):ThirdOrderPolynom(s,a,b,c,d)
  1260. {}
  1261. /**
  1262. * Lane width class. Holds all the data that describes a lane width
  1263. *
  1264. *
  1265. *
  1266. *
  1267. *
  1268. */
  1269. /**
  1270. * Constructor
  1271. * @param s s-offset of the record starting from the lane section s-offset
  1272. * @ param a,b,c,d The 4 parameters of the polynomial
  1273. */
  1274. LaneWidth::LaneWidth(double s, double a, double b, double c, double d):ThirdOrderPolynom (s,a,b,c,d)
  1275. {}
  1276. /**
  1277. * Road mark class. Holds all the data that describes a road mark
  1278. *
  1279. *
  1280. *
  1281. *
  1282. *
  1283. */
  1284. /*
  1285. * Constructors
  1286. */
  1287. LaneRoadMark::LaneRoadMark()
  1288. { mSOffset=0, mType="none"; mWeight="standard"; mColor="standard"; mWidth=0.75; mLaneChange="both"; }
  1289. //-------------
  1290. LaneRoadMark::LaneRoadMark(double sOffset, string type, string weight, string color, double width, string laneChange)
  1291. { mSOffset=sOffset; mType=type; mWeight=weight; mColor=color; mWidth=width; mLaneChange=laneChange;
  1292. }
  1293. //-------------
  1294. LaneRoadMark::LaneRoadMark(double sOffset, string type, string weight, string color, double width)
  1295. { mSOffset=sOffset; mType=type; mWeight=weight; mColor=color; mWidth=width; mLaneChange="both"; }
  1296. /*
  1297. * Methods that set the parameters of the road mark
  1298. */
  1299. void LaneRoadMark::SetS(double value)
  1300. { mSOffset = value; }
  1301. void LaneRoadMark::SetType(string type)
  1302. { mType=type; }
  1303. void LaneRoadMark::SetWeight(string weight)
  1304. { mWeight=weight; }
  1305. void LaneRoadMark::SetColor(string color)
  1306. { mColor=color; }
  1307. void LaneRoadMark::SetWidth(double value)
  1308. { mWidth=value; }
  1309. void LaneRoadMark::SetLaneChange(string laneChange)
  1310. { mLaneChange=laneChange; }
  1311. /*
  1312. * Methods that return the parameters of the road mark
  1313. */
  1314. double LaneRoadMark::GetS()
  1315. { return mSOffset; }
  1316. string LaneRoadMark::GetType()
  1317. { return mType; }
  1318. string LaneRoadMark::GetWeight()
  1319. { return mWeight; }
  1320. string LaneRoadMark::GetColor()
  1321. { return mColor; }
  1322. double LaneRoadMark::GetWidth()
  1323. { return mWidth; }
  1324. string LaneRoadMark::GetLaneChange()
  1325. { return mLaneChange; }
  1326. /**
  1327. * Lane material class. Contains all the data that describes a lane material
  1328. *
  1329. *
  1330. *
  1331. *
  1332. *
  1333. */
  1334. /*
  1335. * Constructor
  1336. */
  1337. LaneMaterial::LaneMaterial (double sOffset, string surface, double friction, double roughness)
  1338. { mSOffset=sOffset; mSurface=surface; mFriction=friction; mRoughness=roughness; }
  1339. /*
  1340. * Methods that return the parameters of the lane material
  1341. */
  1342. double LaneMaterial::GetS()
  1343. { return mSOffset; }
  1344. string LaneMaterial::GetSurface()
  1345. { return mSurface; }
  1346. double LaneMaterial::GetFriction()
  1347. { return mFriction; }
  1348. double LaneMaterial::GetRoughness()
  1349. { return mRoughness; }
  1350. /*
  1351. * Methods that set the parameters of the lane material
  1352. */
  1353. void LaneMaterial::SetS(double value)
  1354. { mSOffset=value; }
  1355. void LaneMaterial::SetSurface(string surface)
  1356. { mSurface=surface; }
  1357. void LaneMaterial::SetFriction(double value)
  1358. { mFriction=value; }
  1359. void LaneMaterial::SetRoughness(double value)
  1360. { mRoughness=value; }
  1361. /**
  1362. * Lane visibility class. Contains all the data that describes lane visibility record
  1363. *
  1364. *
  1365. *
  1366. *
  1367. *
  1368. */
  1369. /*
  1370. * Constructor
  1371. */
  1372. LaneVisibility::LaneVisibility(double sOffset, double forward, double back, double left, double right)
  1373. { mSOffset=sOffset; mForward=forward; mBack=back; mLeft=left; mRight=right; }
  1374. /*
  1375. * Methods that return the parameters of the lane visibility
  1376. */
  1377. double LaneVisibility::GetS()
  1378. { return mSOffset; }
  1379. double LaneVisibility::GetForward()
  1380. { return mForward; }
  1381. double LaneVisibility::GetBack()
  1382. { return mBack; }
  1383. double LaneVisibility::GetLeft()
  1384. { return mLeft; }
  1385. double LaneVisibility::GetRight()
  1386. { return mRight; }
  1387. /*
  1388. * Methods that set the parameters of the lane visibility
  1389. */
  1390. void LaneVisibility::SetS(double value)
  1391. { mSOffset=value; }
  1392. void LaneVisibility::SetForward(double value)
  1393. { mForward=value; }
  1394. void LaneVisibility::SetBack(double value)
  1395. { mBack=value; }
  1396. void LaneVisibility::SetLeft(double value)
  1397. { mLeft=value; }
  1398. void LaneVisibility::SetRight(double value)
  1399. { mRight=value; }
  1400. /**
  1401. * Lane speed class. Contains all the data that describes lane speed record
  1402. *
  1403. *
  1404. *
  1405. *
  1406. *
  1407. */
  1408. /*
  1409. * Constructor
  1410. */
  1411. LaneSpeed::LaneSpeed (double sOffset, double max)
  1412. { mSOffset=sOffset; mMax=max;}
  1413. /*
  1414. * Methods that return the parameters of the lane speed
  1415. */
  1416. double LaneSpeed::GetS()
  1417. { return mSOffset; }
  1418. double LaneSpeed::GetMax()
  1419. { return mMax; }
  1420. /*
  1421. * Methods that set the parameters of the lane speed
  1422. */
  1423. void LaneSpeed::SetS(double value)
  1424. { mSOffset=value; }
  1425. void LaneSpeed::SetMax(double value)
  1426. { mMax=value; }
  1427. /**
  1428. * Lane access class. Contains all the data that describes lane access record
  1429. *
  1430. *
  1431. *
  1432. *
  1433. *
  1434. */
  1435. /*
  1436. * Constructor
  1437. */
  1438. LaneAccess::LaneAccess (double sOffset, string restriction)
  1439. { mSOffset=sOffset; mRestriction = restriction; }
  1440. /*
  1441. * Methods that return the parameters of the lane access
  1442. */
  1443. double LaneAccess::GetS()
  1444. { return mSOffset; }
  1445. string LaneAccess::GetRestriction()
  1446. { return mRestriction; }
  1447. /*
  1448. * Methods that set the parameters of the lane access
  1449. */
  1450. void LaneAccess::SetS(double value)
  1451. { mSOffset=value; }
  1452. void LaneAccess::SetRestriction(string restriction)
  1453. { mRestriction=restriction; }
  1454. /**
  1455. * Lane height class. Contains all the data that describes lane access record
  1456. *
  1457. *
  1458. *
  1459. *
  1460. *
  1461. */
  1462. /*
  1463. * Constructors
  1464. */
  1465. LaneHeight::LaneHeight()
  1466. {mSOffset=0; mInner=0; mOuter=0;}
  1467. LaneHeight::LaneHeight (double sOffset, double inner, double outer)
  1468. { mSOffset=sOffset; mInner=inner; mOuter=outer; }
  1469. /*
  1470. * Methods that return the parameters of the lane height
  1471. */
  1472. double LaneHeight::GetS()
  1473. { return mSOffset; }
  1474. double LaneHeight::GetInner()
  1475. { return mInner; }
  1476. double LaneHeight::GetOuter()
  1477. { return mOuter; }
  1478. /*
  1479. * Methods that set the parameters of the lane height
  1480. */
  1481. void LaneHeight::SetS(double value)
  1482. { mSOffset=value; }
  1483. void LaneHeight::SetInner(double value)
  1484. { mInner=value; }
  1485. void LaneHeight::SetOuter(double value)
  1486. { mOuter=value; }
  1487. /**
  1488. * Lane offset class. Contains all the data that describes lane offset record
  1489. *
  1490. *
  1491. *
  1492. *
  1493. *
  1494. */
  1495. /*
  1496. * Constructors
  1497. */
  1498. LaneOffset::LaneOffset()
  1499. { ms = 0; ma=0; mb=0; mc=0; md=0;}
  1500. LaneOffset::LaneOffset(double sOffset, double a, double b, double c, double d)
  1501. { ms = sOffset; ma = a; mb = b; mc = c; md = d;}
  1502. /*
  1503. * Methods that return the parameters of the lane height
  1504. */
  1505. double LaneOffset::GetS()
  1506. { return ms;}
  1507. double LaneOffset::Geta()
  1508. { return ma;}
  1509. double LaneOffset::Getb()
  1510. { return mb;}
  1511. double LaneOffset::Getc()
  1512. { return mc;}
  1513. double LaneOffset::Getd()
  1514. { return md;}
  1515. /**
  1516. * Check if the tested s-offset is inside the lane offset interval
  1517. * @param A double s-offset value that has to be checked
  1518. * @return Return true if the s-offset value belongs to current lane section, false otherwise
  1519. */
  1520. bool LaneOffset::CheckInterval(double s_check)
  1521. {
  1522. if (s_check>=ms)
  1523. return true;
  1524. else
  1525. return false;
  1526. }
  1527. /*
  1528. * Methods that set the parameters of the lane offset
  1529. */
  1530. void LaneOffset::SetS(double value)
  1531. { ms = value;}
  1532. void LaneOffset::Seta(double value)
  1533. { ma = value;}
  1534. void LaneOffset::Setb(double value)
  1535. { mb = value;}
  1536. void LaneOffset::Setc(double value)
  1537. { mc = value;}
  1538. void LaneOffset::Setd(double value)
  1539. { md = value;}