Road.cpp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  1. #include "Road.h"
  2. #define _USE_MATH_DEFINES
  3. #include <math.h>
  4. //***********************************************************************************
  5. //Road segment
  6. //***********************************************************************************
  7. /**
  8. * Constructor
  9. */
  10. Road::Road()
  11. {
  12. mPredecessor=NULL; mSuccessor=NULL; mNeighbor1=NULL; mNeighbor2=NULL;
  13. }
  14. /**
  15. * Constructor that initializes the road with basic properties
  16. *
  17. * @param name Name of the road
  18. * @param length Length of the road
  19. * @param id Unique ID of the road
  20. * @param junction ID of the junction, this road might be a part of
  21. */
  22. Road::Road(string name, double length, string id, string junction)
  23. {
  24. mPredecessor=NULL; mSuccessor=NULL; mNeighbor1=NULL; mNeighbor2=NULL; mName=name; mLength=length; mId=id; mJunction=junction;
  25. }
  26. /**
  27. * Copy constructor
  28. */
  29. Road::Road (const Road& road)
  30. {
  31. mName=road.mName;
  32. mLength=road.mLength;
  33. mId=road.mId;
  34. mJunction=road.mJunction;
  35. mPredecessor=NULL;
  36. mSuccessor=NULL;
  37. mNeighbor1=NULL;
  38. mNeighbor2=NULL;
  39. if (road.mPredecessor!=NULL)
  40. mPredecessor = new RoadLink(road.mPredecessor->GetElementType(), road.mPredecessor->GetElementId(), road.mPredecessor->GetContactPoint());
  41. if (road.mSuccessor!=NULL)
  42. mSuccessor = new RoadLink(road.mSuccessor->GetElementType(), road.mSuccessor->GetElementId(), road.mSuccessor->GetContactPoint());
  43. if (road.mNeighbor1!=NULL)
  44. mNeighbor1 = new RoadNeighbor(road.mNeighbor1->GetSide(), road.mNeighbor1->GetElementId(), road.mNeighbor1->GetDirection());
  45. if (road.mNeighbor2!=NULL)
  46. mNeighbor2 = new RoadNeighbor(road.mNeighbor2->GetSide(), road.mNeighbor2->GetElementId(), road.mNeighbor2->GetDirection());
  47. mRoadTypeVector=road.mRoadTypeVector;
  48. mGeometryBlockVector=road.mGeometryBlockVector;
  49. mElevationVector=road.mElevationVector;
  50. mSuperElevationVector=road.mSuperElevationVector;
  51. mCrossfallVector=road.mCrossfallVector;
  52. mLaneSectionsVector=road.mLaneSectionsVector;
  53. mObjectsVector=road.mObjectsVector;
  54. mSignalsVector=road.mSignalsVector;
  55. mLaneOffsetVector=road.mLaneOffsetVector;
  56. }
  57. /**
  58. * Assignment operator overload
  59. */
  60. const Road& Road::operator=(const Road& otherRoad)
  61. {
  62. if (this!= &otherRoad)
  63. {
  64. mName=otherRoad.mName;
  65. mLength=otherRoad.mLength;
  66. mId=otherRoad.mId;
  67. mJunction=otherRoad.mJunction;
  68. delete mPredecessor;
  69. delete mSuccessor;
  70. delete mNeighbor1;
  71. delete mNeighbor2;
  72. mPredecessor=NULL;
  73. mSuccessor=NULL;
  74. mNeighbor1=NULL;
  75. mNeighbor2=NULL;
  76. if (otherRoad.mPredecessor!=NULL)
  77. mPredecessor = new RoadLink(otherRoad.mPredecessor->GetElementType(), otherRoad.mPredecessor->GetElementId(), otherRoad.mPredecessor->GetContactPoint());
  78. if (otherRoad.mSuccessor!=NULL)
  79. mSuccessor = new RoadLink(otherRoad.mSuccessor->GetElementType(), otherRoad.mSuccessor->GetElementId(), otherRoad.mSuccessor->GetContactPoint());
  80. if (otherRoad.mNeighbor1!=NULL)
  81. mNeighbor1 = new RoadNeighbor(otherRoad.mNeighbor1->GetSide(), otherRoad.mNeighbor1->GetElementId(), otherRoad.mNeighbor1->GetDirection());
  82. if (otherRoad.mNeighbor2!=NULL)
  83. mNeighbor2 = new RoadNeighbor(otherRoad.mNeighbor2->GetSide(), otherRoad.mNeighbor2->GetElementId(), otherRoad.mNeighbor2->GetDirection());
  84. mRoadTypeVector=otherRoad.mRoadTypeVector;
  85. mGeometryBlockVector=otherRoad.mGeometryBlockVector;
  86. mElevationVector=otherRoad.mElevationVector;
  87. mSuperElevationVector=otherRoad.mSuperElevationVector;
  88. mCrossfallVector=otherRoad.mCrossfallVector;
  89. mLaneSectionsVector=otherRoad.mLaneSectionsVector;
  90. mObjectsVector=otherRoad.mObjectsVector;
  91. mSignalsVector=otherRoad.mSignalsVector;
  92. mLaneOffsetVector=otherRoad.mLaneOffsetVector;
  93. }
  94. return *this;
  95. }
  96. //-------------------------------------------------
  97. /**
  98. * Recalculates the chordline geometry of the road
  99. */
  100. void Road::RecalculateGeometry()
  101. {
  102. // Goes through geometry blocks and recalculates their coordinates and headings starting with the second record
  103. // so the second geometry will start at the coordinates where the first one ended
  104. double length=0;
  105. unsigned int lGeometryVectorSize = mGeometryBlockVector.size();
  106. if(lGeometryVectorSize>0)
  107. {
  108. double lS=0;
  109. double lX=0;
  110. double lY=0;
  111. double lHdg=0;
  112. mGeometryBlockVector.at(0).GetLastCoords(lS,lX,lY,lHdg);
  113. length+=mGeometryBlockVector.at(0).GetBlockLength();
  114. GeometryBlock *lGeometry;
  115. for(unsigned int i=1; i<lGeometryVectorSize; i++)
  116. {
  117. lGeometry=&mGeometryBlockVector.at(i);
  118. lGeometry->Recalculate(lS,lX,lY,lHdg);
  119. lGeometry->GetLastCoords(lS,lX,lY,lHdg);
  120. length+=lGeometry->GetBlockLength();
  121. }
  122. }
  123. mLength=length;
  124. }
  125. /**
  126. * Getters for the basic properties of the road
  127. */
  128. string Road::GetRoadName() const
  129. {
  130. return mName;
  131. }
  132. double Road::GetRoadLength() const
  133. {
  134. return mLength;
  135. }
  136. string Road::GetRoadId() const
  137. {
  138. return mId;
  139. }
  140. string Road::GetRoadJunction() const
  141. {
  142. return mJunction;
  143. }
  144. string Road::GetRoadRule() const
  145. {
  146. return mRule;
  147. }
  148. /**
  149. * Getters for the linking properties of the road
  150. */
  151. RoadLink* Road::GetPredecessor()
  152. {
  153. return mPredecessor;
  154. }
  155. RoadLink* Road::GetSuccessor()
  156. {
  157. return mSuccessor;
  158. }
  159. RoadNeighbor* Road::GetNeighbor1()
  160. {
  161. return mNeighbor1;
  162. }
  163. RoadNeighbor* Road::GetNeighbor2()
  164. {
  165. return mNeighbor2;
  166. }
  167. /**
  168. * Getters for the child records and their vectors
  169. */
  170. // Road type records
  171. vector<RoadType> *Road::GetRoadTypeVector()
  172. {
  173. return &mRoadTypeVector;
  174. }
  175. RoadType* Road::GetRoadType(unsigned int i)
  176. {
  177. if ((mRoadTypeVector.size()>0)&&(i<mRoadTypeVector.size()))
  178. return &mRoadTypeVector.at(i);
  179. else
  180. return NULL;
  181. }
  182. unsigned int Road::GetRoadTypeCount()
  183. {
  184. return mRoadTypeVector.size();
  185. }
  186. // Road geometry records
  187. vector<GeometryBlock> *Road::GetGeometryBlockVector()
  188. {
  189. return &mGeometryBlockVector;
  190. }
  191. GeometryBlock* Road::GetGeometryBlock(unsigned int i)
  192. {
  193. if ((mGeometryBlockVector.size()>0)&&(i<mGeometryBlockVector.size()))
  194. return &mGeometryBlockVector.at(i);
  195. else
  196. return NULL;
  197. }
  198. unsigned int Road::GetGeometryBlockCount()
  199. {
  200. return mGeometryBlockVector.size();
  201. }
  202. // Road elevation records
  203. vector<Elevation> *Road::GetElevationVector()
  204. {
  205. return &mElevationVector;
  206. }
  207. Elevation* Road::GetElevation(unsigned int i)
  208. {
  209. if ((mElevationVector.size()>0)&&(i<mElevationVector.size()))
  210. return &mElevationVector.at(i);
  211. else
  212. return NULL;
  213. }
  214. unsigned int Road::GetElevationCount()
  215. {
  216. return mElevationVector.size();
  217. }
  218. // Road superelevation records
  219. vector<SuperElevation> *Road::GetSuperElevationVector()
  220. {
  221. return &mSuperElevationVector;
  222. }
  223. SuperElevation* Road::GetSuperElevation(unsigned int i)
  224. {
  225. if ((mSuperElevationVector.size()>0)&&(i<mSuperElevationVector.size()))
  226. return &mSuperElevationVector.at(i);
  227. else
  228. return NULL;
  229. }
  230. unsigned int Road::GetSuperElevationCount()
  231. {
  232. return mSuperElevationVector.size();
  233. }
  234. // Road crossfall records
  235. vector<Crossfall> *Road::GetCrossfallVector()
  236. {
  237. return &mCrossfallVector;
  238. }
  239. Crossfall* Road::GetCrossfall(unsigned int i)
  240. {
  241. if ((mCrossfallVector.size()>0)&&(i<mCrossfallVector.size()))
  242. return &mCrossfallVector.at(i);
  243. else
  244. return NULL;
  245. }
  246. unsigned int Road::GetCrossfallCount()
  247. {
  248. return mCrossfallVector.size();
  249. }
  250. // Road lane section records
  251. vector<LaneSection> *Road::GetLaneSectionVector()
  252. {
  253. return &mLaneSectionsVector;
  254. }
  255. LaneSection* Road::GetLaneSection(unsigned int i)
  256. {
  257. if ((mLaneSectionsVector.size()>0)&&(i<mLaneSectionsVector.size()))
  258. return &mLaneSectionsVector.at(i);
  259. else
  260. return NULL;
  261. }
  262. unsigned int Road::GetLaneSectionCount()
  263. {
  264. return mLaneSectionsVector.size();
  265. }
  266. // Road lane offset records
  267. vector<LaneOffset> * Road::GetLaneOffsetVector()
  268. {
  269. return &mLaneOffsetVector;
  270. }
  271. LaneOffset * Road::GetLaneOffset(unsigned int i)
  272. {
  273. if ((mLaneOffsetVector.size()>0)&&(i<mLaneOffsetVector.size()))
  274. return &mLaneOffsetVector.at(i);
  275. else
  276. return NULL;
  277. }
  278. unsigned int Road::GetLaneOffsetCount()
  279. {
  280. return mLaneOffsetVector.size();
  281. }
  282. // Road object records
  283. vector<Object> *Road::GetObjectVector()
  284. {
  285. return &mObjectsVector;
  286. }
  287. Object* Road::GetObject(unsigned int i)
  288. {
  289. if ((mObjectsVector.size()>0)&&(i<mObjectsVector.size()))
  290. return &mObjectsVector.at(i);
  291. else
  292. return NULL;
  293. }
  294. unsigned int Road::GetObjectCount()
  295. {
  296. return mObjectsVector.size();
  297. }
  298. // Road signal records
  299. vector<Signal> *Road::GetSignalVector()
  300. {
  301. return &mSignalsVector;
  302. }
  303. Signal* Road::GetSignal(unsigned int i)
  304. {
  305. if ((mSignalsVector.size()>0)&&(i<mSignalsVector.size()))
  306. return &mSignalsVector.at(i);
  307. else
  308. return NULL;
  309. }
  310. unsigned int Road::GetSignalCount()
  311. {
  312. return mSignalsVector.size();
  313. }
  314. //-------------------------------------------------
  315. /**
  316. * Getters for the last child records in their respective vectors
  317. */
  318. RoadType* Road::GetLastRoadType()
  319. {
  320. if (mRoadTypeVector.size()>0)
  321. return &mRoadTypeVector.at(mRoadTypeVector.size()-1);
  322. else
  323. return NULL;
  324. }
  325. GeometryBlock* Road::GetLastGeometryBlock()
  326. {
  327. if (mGeometryBlockVector.size()>0)
  328. return &mGeometryBlockVector.at(mGeometryBlockVector.size()-1);
  329. else
  330. return NULL;
  331. }
  332. Elevation* Road::GetLastElevation()
  333. {
  334. if (mElevationVector.size()>0)
  335. return &mElevationVector.at(mElevationVector.size()-1);
  336. else
  337. return NULL;
  338. }
  339. SuperElevation* Road::GetLastSuperElevation()
  340. {
  341. if (mSuperElevationVector.size()>0)
  342. return &mSuperElevationVector.at(mSuperElevationVector.size()-1);
  343. else
  344. return NULL;
  345. }
  346. Crossfall* Road::GetLastCrossfall()
  347. {
  348. if (mCrossfallVector.size()>0)
  349. return &mCrossfallVector.at(mCrossfallVector.size()-1);
  350. else
  351. return NULL;
  352. }
  353. LaneSection* Road::GetLastLaneSection()
  354. {
  355. if (mLaneSectionsVector.size()>0)
  356. return &mLaneSectionsVector.at(mLaneSectionsVector.size()-1);
  357. else
  358. return NULL;
  359. }
  360. Object* Road::GetLastObject()
  361. {
  362. if (mObjectsVector.size()>0)
  363. return &mObjectsVector.at(mObjectsVector.size()-1);
  364. else
  365. return NULL;
  366. }
  367. Signal* Road::GetLastSignal()
  368. {
  369. if (mSignalsVector.size()>0)
  370. return &mSignalsVector.at(mSignalsVector.size()-1);
  371. else
  372. return NULL;
  373. }
  374. /**
  375. * Getters for the last added child records in their respective vectors
  376. */
  377. RoadType* Road::GetLastAddedRoadType()
  378. {
  379. if(mLastAddedRoadType<mRoadTypeVector.size())
  380. return &mRoadTypeVector.at(mLastAddedRoadType);
  381. else
  382. return NULL;
  383. }
  384. GeometryBlock* Road::GetLastAddedGeometryBlock()
  385. {
  386. if(mLastAddedGeometryBlock<mGeometryBlockVector.size())
  387. return &mGeometryBlockVector.at(mLastAddedGeometryBlock);
  388. else
  389. return NULL;
  390. }
  391. Elevation* Road::GetLastAddedElevation()
  392. {
  393. if(mLastAddedElevation<mElevationVector.size())
  394. return &mElevationVector.at(mLastAddedElevation);
  395. else
  396. return NULL;
  397. }
  398. SuperElevation* Road::GetLastAddedSuperElevation()
  399. {
  400. if(mLastAddedSuperElevation<mSuperElevationVector.size())
  401. return &mSuperElevationVector.at(mLastAddedSuperElevation);
  402. else
  403. return NULL;
  404. }
  405. Crossfall* Road::GetLastAddedCrossfall()
  406. {
  407. if(mLastAddedCrossfall<mCrossfallVector.size())
  408. return &mCrossfallVector.at(mLastAddedCrossfall);
  409. else
  410. return NULL;
  411. }
  412. LaneSection* Road::GetLastAddedLaneSection()
  413. {
  414. if(mLastAddedLaneSection<mLaneSectionsVector.size())
  415. return &mLaneSectionsVector.at(mLastAddedLaneSection);
  416. else
  417. return NULL;
  418. }
  419. Object* Road::GetLastAddedObject()
  420. {
  421. if(mLastAddedObject<mObjectsVector.size())
  422. return &mObjectsVector.at(mLastAddedObject);
  423. else
  424. return NULL;
  425. }
  426. Signal* Road::GetLastAddedSignal()
  427. {
  428. if(mLastAddedSignal<mSignalsVector.size())
  429. return &mSignalsVector.at(mLastAddedSignal);
  430. else
  431. return NULL;
  432. }
  433. //-------------------------------------------------
  434. /**
  435. * Setters for the basic road properties
  436. */
  437. void Road::SetRoadName(string name)
  438. {
  439. mName=name;
  440. }
  441. void Road::SetRoadLength(double length)
  442. {
  443. mLength=length;
  444. }
  445. void Road::SetRoadId(string id)
  446. {
  447. mId=id;
  448. }
  449. void Road::SetRoadJunction(string junction)
  450. {
  451. mJunction=junction;
  452. }
  453. void Road::SetRoadRule(std::string rule)
  454. {
  455. mRule=rule;
  456. }
  457. /**
  458. * Setters for the linking road properties
  459. */
  460. void Road::SetPredecessor(string elementType, string elementId, string contactPoint)
  461. {
  462. if(mPredecessor!=NULL)
  463. {
  464. mPredecessor->SetElementType(elementType);
  465. mPredecessor->SetElementId(elementId);
  466. mPredecessor->SetContactPoint(contactPoint);
  467. }
  468. else mPredecessor = new RoadLink(elementType, elementId,contactPoint);
  469. }
  470. void Road::SetSuccessor(string elementType, string elementId, string contactPoint)
  471. {
  472. if(mSuccessor!=NULL)
  473. {
  474. mSuccessor->SetElementType(elementType);
  475. mSuccessor->SetElementId(elementId);
  476. mSuccessor->SetContactPoint(contactPoint);
  477. }
  478. else mSuccessor=new RoadLink(elementType, elementId,contactPoint);
  479. }
  480. void Road::SetNeighbor(string side, string elementId, string direction)
  481. {
  482. if (mNeighbor1==NULL)
  483. mNeighbor1=new RoadNeighbor(side, elementId, direction);
  484. else
  485. mNeighbor2=new RoadNeighbor(side, elementId, direction);
  486. }
  487. void Road::SetNeighbor1(string side, string elementId, string direction)
  488. {
  489. if (mNeighbor1==NULL) mNeighbor1=new RoadNeighbor(side, elementId, direction);
  490. }
  491. void Road::SetNeighbor2(string side, string elementId, string direction)
  492. {
  493. if (mNeighbor2==NULL) mNeighbor2=new RoadNeighbor(side, elementId, direction);
  494. }
  495. /**
  496. * Removers for the linking road properties
  497. */
  498. void Road::RemovePredecessor()
  499. {
  500. if(mPredecessor!=NULL)
  501. {
  502. delete mPredecessor;
  503. mPredecessor = NULL;
  504. }
  505. }
  506. void Road::RemoveSuccessor()
  507. {
  508. if(mSuccessor!=NULL)
  509. {
  510. delete mSuccessor;
  511. mSuccessor = NULL;
  512. }
  513. }
  514. void Road::RemoveNeighbor1()
  515. {
  516. if(mNeighbor1!=NULL)
  517. {
  518. delete mNeighbor1;
  519. mNeighbor1 = NULL;
  520. }
  521. }
  522. void Road::RemoveNeighbor2()
  523. {
  524. if(mNeighbor2!=NULL)
  525. {
  526. delete mNeighbor2;
  527. mNeighbor2 = NULL;
  528. }
  529. }
  530. //-------------------------------------------------
  531. /**
  532. * Methods used to add child records to the respective vectors
  533. */
  534. unsigned int Road::AddRoadType(double s, string type,string country)
  535. {
  536. // Gets the index where the record should be inserted in the vector
  537. unsigned int index = CheckRoadTypeInterval(s)+1;
  538. // If larger than the record count - push to the back
  539. if(index>=GetRoadTypeCount()) mRoadTypeVector.push_back(RoadType(s, type,country));
  540. // else insert in the middle
  541. else mRoadTypeVector.insert(mRoadTypeVector.begin()+index, RoadType(s, type,country));
  542. // Save the last added record index
  543. mLastAddedRoadType=index;
  544. return index;
  545. }
  546. //-------------
  547. unsigned int Road::AddGeometryBlock()
  548. {
  549. // Check the first method in the group for details
  550. unsigned int index=GetGeometryBlockCount();
  551. mGeometryBlockVector.push_back(GeometryBlock());
  552. mLastAddedGeometryBlock=index;
  553. return index;
  554. }
  555. //-------------
  556. unsigned int Road::AddElevation(double s, double a, double b, double c, double d)
  557. {
  558. // Check the first method in the group for details
  559. unsigned int index = CheckElevationInterval(s)+1;
  560. if(index>=GetElevationCount()) mElevationVector.push_back(Elevation(s,a,b,c,d));
  561. else mElevationVector.insert(mElevationVector.begin()+index, Elevation(s,a,b,c,d));
  562. mLastAddedElevation=index;
  563. return index;
  564. }
  565. //-------------
  566. unsigned int Road::AddSuperElevation(double s, double a, double b, double c, double d)
  567. {
  568. // Check the first method in the group for details
  569. unsigned int index = CheckSuperElevationInterval(s)+1;
  570. if(index>=GetSuperElevationCount()) mSuperElevationVector.push_back(SuperElevation(s,a,b,c,d));
  571. else mSuperElevationVector.insert(mSuperElevationVector.begin()+index, SuperElevation(s,a,b,c,d));
  572. mLastAddedSuperElevation=index;
  573. return index;
  574. }
  575. //-------------
  576. unsigned int Road::AddCrossfall (string side, double s, double a, double b, double c, double d)
  577. {
  578. // Check the first method in the group for details
  579. unsigned int index = CheckCrossfallInterval(s)+1;
  580. if(index>=GetCrossfallCount()) mCrossfallVector.push_back(Crossfall(side,s,a,b,c,d));
  581. else mCrossfallVector.insert(mCrossfallVector.begin()+index, Crossfall(side,s,a,b,c,d));
  582. mLastAddedCrossfall=index;
  583. return index;
  584. }
  585. //-------------
  586. unsigned int Road::AddLaneSection(double s)
  587. {
  588. // Check the first method in the group for details
  589. unsigned int index = CheckLaneSectionInterval(s)+1;
  590. if(index>=GetLaneSectionCount()) mLaneSectionsVector.push_back(LaneSection(s));
  591. else mLaneSectionsVector.insert(mLaneSectionsVector.begin()+index, LaneSection(s));
  592. mLastAddedLaneSection=index;
  593. return index;
  594. }
  595. unsigned int Road::AddLaneOffset(double s, double a, double b, double c, double d)
  596. {
  597. unsigned int index = CheckLaneOffsetInterval(s)+1;
  598. if(index>=GetLaneOffsetCount()) mLaneOffsetVector.push_back(LaneOffset(s,a,b,c,d));
  599. else mLaneOffsetVector.insert(mLaneOffsetVector.begin()+index, LaneOffset(s,a,b,c,d));
  600. mLastAddedLaneOffset=index;
  601. return index;
  602. }
  603. //-------------
  604. unsigned int Road::AddObject(string id,double s,double t,double zOffset)
  605. {
  606. // Check the first method in the group for details
  607. unsigned int index=GetObjectCount();
  608. mObjectsVector.push_back(Object(id,s,t,zOffset));
  609. mLastAddedObject=index;
  610. return index;
  611. }
  612. //-------------
  613. unsigned int Road::AddSignal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,string type,string country,string countryRevision,
  614. string subtype,double hOffset,double pitch,double roll ,double height,double width)
  615. {
  616. // Check the first method in the group for details
  617. unsigned int index=GetSignalCount();
  618. Signal x(s,t,id,name,dynamic,orientation,zOffset,type,country,countryRevision,
  619. subtype,hOffset,pitch,roll,height,width);
  620. mSignalsVector.push_back(x);
  621. // mSignalsVector.push_back(Signal(s,t,id,name,dynamic,orientation,zOffset,type,country,countryRevision,
  622. // subtype,hOffset,pitch,roll,height,width));
  623. mLastAddedSignal=index;
  624. return index;
  625. }
  626. //-----------
  627. /**
  628. * Methods used to clone child records in the respective vectors
  629. */
  630. unsigned int Road::CloneRoadType(unsigned int index)
  631. {
  632. // Clone the object and insert it in the middle of the vector
  633. if(index<mRoadTypeVector.size()-1)
  634. mRoadTypeVector.insert(mRoadTypeVector.begin()+index+1, mRoadTypeVector[index]);
  635. // or just push it to the back
  636. else if(index==mRoadTypeVector.size()-1)
  637. mRoadTypeVector.push_back(mRoadTypeVector[index]);
  638. // Save the last added record index
  639. mLastAddedRoadType=index+1;
  640. return mLastAddedRoadType;
  641. }
  642. unsigned int Road::CloneElevation(unsigned int index)
  643. {
  644. // Check the first method in the group for details
  645. if(index<mElevationVector.size()-1)
  646. mElevationVector.insert(mElevationVector.begin()+index+1, mElevationVector[index]);
  647. else if(index==mElevationVector.size()-1)
  648. mElevationVector.push_back(mElevationVector[index]);
  649. mLastAddedElevation=index+1;
  650. return mLastAddedElevation;
  651. }
  652. unsigned int Road::CloneSuperElevation(unsigned int index)
  653. {
  654. // Check the first method in the group for details
  655. if(index<mSuperElevationVector.size()-1)
  656. mSuperElevationVector.insert(mSuperElevationVector.begin()+index+1, mSuperElevationVector[index]);
  657. else if(index==mSuperElevationVector.size()-1)
  658. mSuperElevationVector.push_back(mSuperElevationVector[index]);
  659. mLastAddedSuperElevation=index+1;
  660. return mLastAddedSuperElevation;
  661. }
  662. unsigned int Road::CloneCrossfall(unsigned int index)
  663. {
  664. // Check the first method in the group for details
  665. if(index<mCrossfallVector.size()-1)
  666. mCrossfallVector.insert(mCrossfallVector.begin()+index+1, mCrossfallVector[index]);
  667. else if(index==mCrossfallVector.size()-1)
  668. mCrossfallVector.push_back(mCrossfallVector[index]);
  669. mLastAddedCrossfall=index+1;
  670. return mLastAddedCrossfall;
  671. }
  672. unsigned int Road::CloneLaneSection(unsigned int index)
  673. {
  674. // Check the first method in the group for details
  675. if(index<mLaneSectionsVector.size()-1)
  676. mLaneSectionsVector.insert(mLaneSectionsVector.begin()+index+1, mLaneSectionsVector[index]);
  677. else if(index==mLaneSectionsVector.size()-1)
  678. mLaneSectionsVector.push_back(mLaneSectionsVector[index]);
  679. mLastAddedLaneSection=index+1;
  680. return mLastAddedLaneSection;
  681. }
  682. unsigned int Road::CloneLaneSectionEnd(unsigned int index)
  683. {
  684. // Check the first method in the group for details
  685. // Clones the lane section, duplicating only the last records in each child category
  686. LaneSection lNewLaneSection(mLaneSectionsVector[index].GetS());
  687. unsigned int iLaneCount=mLaneSectionsVector[index].GetLaneCount();
  688. double lHighestS = 0;
  689. for(unsigned int iLane=0; iLane<iLaneCount; iLane++)
  690. {
  691. Lane *lLane = mLaneSectionsVector[index].GetLane(iLane);
  692. lNewLaneSection.AddLane(lLane->GetSide(), lLane->GetId(), lLane->GetType(), lLane->GetLevel(),false);
  693. Lane *lNewLane = lNewLaneSection.GetLastAddedLane();
  694. //width
  695. LaneWidth *lWidth = lLane->GetLaneWidth(lLane->GetLaneWidthCount()-1);
  696. if(lWidth!=NULL)
  697. {
  698. lNewLane->AddWidthRecord(0.0, lWidth->GetA(), lWidth->GetB(), lWidth->GetC(), lWidth->GetD());
  699. if(lWidth->GetS()>lHighestS) lHighestS=lWidth->GetS();
  700. }
  701. //road mark
  702. LaneRoadMark *lRoadMark = lLane->GetLaneRoadMark(lLane->GetLaneRoadMarkCount()-1);
  703. if(lRoadMark!=NULL)
  704. {
  705. lNewLane->AddRoadMarkRecord(0.0, lRoadMark->GetType(), lRoadMark->GetWeight(), lRoadMark->GetColor(), lRoadMark->GetWidth(), lRoadMark->GetLaneChange());
  706. if(lRoadMark->GetS()>lHighestS) lHighestS=lRoadMark->GetS();
  707. }
  708. //material
  709. LaneMaterial *lMaterial = lLane->GetLaneMaterial(lLane->GetLaneMaterialCount()-1);
  710. if(lMaterial!=NULL)
  711. {
  712. lNewLane->AddMaterialRecord(0.0, lMaterial->GetSurface(), lMaterial->GetFriction(), lMaterial->GetRoughness());
  713. if(lMaterial->GetS()>lHighestS) lHighestS=lMaterial->GetS();
  714. }
  715. //visibility
  716. LaneVisibility *lVisibility = lLane->GetLaneVisibility(lLane->GetLaneVisibilityCount()-1);
  717. if(lVisibility!=NULL)
  718. {
  719. lNewLane->AddVisibilityRecord(0.0, lVisibility->GetForward(), lVisibility->GetBack(), lVisibility->GetLeft(), lVisibility->GetRight());
  720. if(lVisibility->GetS()>lHighestS) lHighestS=lVisibility->GetS();
  721. }
  722. //speed
  723. LaneSpeed *lSpeed = lLane->GetLaneSpeed(lLane->GetLaneSpeedCount()-1);
  724. if(lSpeed!=NULL)
  725. {
  726. lNewLane->AddSpeedRecord(0.0, lSpeed->GetMax());
  727. if(lSpeed->GetS()>lHighestS) lHighestS=lSpeed->GetS();
  728. }
  729. //access
  730. LaneAccess *lAccess = lLane->GetLaneAccess(lLane->GetLaneAccessCount()-1);
  731. if(lAccess!=NULL)
  732. {
  733. lNewLane->AddAccessRecord(0.0, lAccess->GetRestriction());
  734. if(lAccess->GetS()>lHighestS) lHighestS=lAccess->GetS();
  735. }
  736. //height
  737. LaneHeight *lHeight = lLane->GetLaneHeight(lLane->GetLaneHeightCount()-1);
  738. if(lHeight!=NULL)
  739. {
  740. lNewLane->AddHeightRecord(0.0, lHeight->GetInner(), lHeight->GetOuter());
  741. if(lHeight->GetS()>lHighestS) lHighestS=lHeight->GetS();
  742. }
  743. }
  744. lHighestS += mLaneSectionsVector[index].GetS();
  745. if(index+1 < mLaneSectionsVector.size())
  746. {
  747. if(lHighestS < mLaneSectionsVector[index+1].GetS())
  748. lNewLaneSection.SetS(lHighestS);
  749. }
  750. if(index<mLaneSectionsVector.size()-1)
  751. mLaneSectionsVector.insert(mLaneSectionsVector.begin()+index+1, lNewLaneSection);
  752. else if(index==mLaneSectionsVector.size()-1)
  753. mLaneSectionsVector.push_back(lNewLaneSection);
  754. mLastAddedLaneSection=index+1;
  755. return mLastAddedLaneSection;
  756. }
  757. unsigned int Road::CloneObject(unsigned int index)
  758. {
  759. // Check the first method in the group for details
  760. if(index<mSignalsVector.size()-1)
  761. mSignalsVector.insert(mSignalsVector.begin()+index+1, mSignalsVector[index]);
  762. else if(index==mSignalsVector.size()-1)
  763. mSignalsVector.push_back(mSignalsVector[index]);
  764. mLastAddedObject=index+1;
  765. return mLastAddedObject;
  766. }
  767. unsigned int Road::CloneSignal(unsigned int index)
  768. {
  769. // Check the first method in the group for details
  770. if(index<mSignalsVector.size()-1)
  771. mSignalsVector.insert(mSignalsVector.begin()+index+1, mSignalsVector[index]);
  772. else if(index==mSignalsVector.size()-1)
  773. mSignalsVector.push_back(mSignalsVector[index]);
  774. mLastAddedSignal=index+1;
  775. return mLastAddedSignal;
  776. }
  777. /**
  778. * Methods used to delete child records from the respective vectors
  779. */
  780. void Road::DeleteRoadType(unsigned int index)
  781. {
  782. mRoadTypeVector.erase(mRoadTypeVector.begin()+index);
  783. }
  784. void Road::DeleteGeometryBlock(unsigned int index)
  785. {
  786. mGeometryBlockVector.erase(mGeometryBlockVector.begin()+index);
  787. }
  788. void Road::DeleteElevation(unsigned int index)
  789. {
  790. mElevationVector.erase(mElevationVector.begin()+index);
  791. }
  792. void Road::DeleteSuperElevation(unsigned int index)
  793. {
  794. mSuperElevationVector.erase(mSuperElevationVector.begin()+index);
  795. }
  796. void Road::DeleteCrossfall(unsigned int index)
  797. {
  798. mCrossfallVector.erase(mCrossfallVector.begin()+index);
  799. }
  800. void Road::DeleteLaneSection(unsigned int index)
  801. {
  802. mLaneSectionsVector.erase(mLaneSectionsVector.begin()+index);
  803. }
  804. void Road::DeleteLaneOffset(unsigned int index)
  805. {
  806. mLaneOffsetVector.erase(mLaneOffsetVector.begin()+index);
  807. }
  808. void Road::DeleteObject(unsigned int index)
  809. {
  810. mObjectsVector.erase(mObjectsVector.begin()+index);
  811. }
  812. void Road::DeleteSignal(unsigned int index)
  813. {
  814. mSignalsVector.erase(mSignalsVector.begin()+index);
  815. }
  816. //-------------------------------------------------
  817. // EVALUATION METHODS
  818. /**
  819. * Geometry evaluation
  820. */
  821. bool Road::CheckGeometryInterval (double s_check)
  822. {
  823. string tmp;
  824. return CheckGeometryInterval(s_check,tmp);
  825. }
  826. //-----------
  827. bool Road::CheckGeometryInterval (double s_check, string &roadId)
  828. {
  829. for (unsigned int i=0;i<mGeometryBlockVector.size();i++)
  830. {
  831. if (mGeometryBlockVector.at(i).CheckInterval(s_check))
  832. {
  833. roadId=mId;
  834. return true;
  835. }
  836. }
  837. roadId="N/A";
  838. return false;
  839. }
  840. //-----------
  841. short int Road::GetGeometryCoords(double s_check, double &retX, double &retY)
  842. {
  843. double tmp;
  844. return GetGeometryCoords(s_check,retX,retY, tmp);
  845. }
  846. //-------------
  847. short int Road::GetGeometryCoords(double s_check, double &retX, double &retY, double &retHDG)
  848. {
  849. //go trough all of the blocks
  850. for (unsigned int i=0; i<mGeometryBlockVector.size();i++)
  851. {
  852. //Check the block and get coords.
  853. short int res=mGeometryBlockVector.at(i).GetCoords(s_check,retX,retY, retHDG);
  854. // If the returned value is one of the geometry types (for 0=line,1=arc and 2=spiral) then the result has been found and parameters filled, so, return the value
  855. if (res>=0 )
  856. return res;
  857. }
  858. //if s_check does not belong to the road, return -999
  859. return -999;
  860. }
  861. //-----------
  862. /**
  863. * Other evaluation
  864. */
  865. int Road::CheckRoadTypeInterval(double s_check)
  866. {
  867. int res=-1;
  868. //Go through all the road type records
  869. for (unsigned int i=0;i<mRoadTypeVector.size();i++)
  870. {
  871. //check if the s_check belongs to the current record
  872. if (s_check >= mRoadTypeVector.at(i).GetS())
  873. res=i; //assign it to the result id
  874. else
  875. break; //if not, break;
  876. }
  877. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  878. }
  879. //-----------
  880. string Road::GetRoadTypeValue(double s_check)
  881. {
  882. string retType="unknown";
  883. //find the record where s_check belongs
  884. int index= CheckRoadTypeInterval(s_check);
  885. //If found, return the type
  886. if (index>=0)
  887. retType= mRoadTypeVector.at(index).GetType();
  888. return retType;
  889. }
  890. //-----------
  891. int Road::CheckElevationInterval(double s_check)
  892. {
  893. int res=-1;
  894. //Go through all the road type records
  895. for (unsigned int i=0;i<mElevationVector.size();i++)
  896. {
  897. //check if the s_check belongs to the current record
  898. if (mElevationVector.at(i).CheckInterval(s_check))
  899. res=i; //assign it to the result id
  900. else
  901. break; //if not, break;
  902. }
  903. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  904. }
  905. //-----------
  906. double Road::GetElevationValue (double s_check)
  907. {
  908. double retVal=0;
  909. //find the record where s_check belongs
  910. int index=CheckElevationInterval(s_check);
  911. //If found, return the type
  912. if (index>=0)
  913. retVal= (mElevationVector.at(index).GetValue(s_check));
  914. return retVal;
  915. }
  916. //-----------
  917. int Road::CheckSuperElevationInterval(double s_check)
  918. {
  919. int res=-1;
  920. //Go through all the road type records
  921. for (unsigned int i=0;i<mSuperElevationVector.size();i++)
  922. {
  923. //check if the s_check belongs to the current record
  924. if (mSuperElevationVector.at(i).CheckInterval(s_check))
  925. res=i; //assign it to the result id
  926. else
  927. break; //if not, break;
  928. }
  929. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  930. }
  931. //-----------
  932. double Road::GetSuperElevationValue (double s_check)
  933. {
  934. double retVal=0;
  935. //find the record where s_check belongs
  936. int index=CheckSuperElevationInterval(s_check);
  937. //If found, return the type
  938. if (index>=0)
  939. retVal= (mSuperElevationVector.at(index).GetValue(s_check));
  940. return retVal;
  941. }
  942. //-----------
  943. int Road::CheckCrossfallInterval(double s_check)
  944. {
  945. int res=-1;
  946. //Go through all the road type records
  947. for (unsigned int i=0;i<mCrossfallVector.size();i++)
  948. {
  949. //check if the s_check belongs to the current record
  950. if (mCrossfallVector.at(i).CheckInterval(s_check))
  951. res=i; //assign it to the result id
  952. else
  953. break; //if not, break;
  954. }
  955. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  956. }
  957. //-----------
  958. void Road::GetCrossfallValue (double s_check, double &angleLeft, double &angleRight)
  959. {
  960. angleLeft=0.0;
  961. angleRight=0.0;
  962. //find the record where s_check belongs
  963. int index=CheckCrossfallInterval(s_check);
  964. //If found, return the type
  965. string side;
  966. double angle=0.0;
  967. if (index>=0)
  968. {
  969. angle =(mCrossfallVector.at(index).GetValue(s_check));
  970. side=(mCrossfallVector.at(index).GetSide());
  971. }
  972. if (side.compare("left")==0)
  973. {
  974. angleLeft=-angle;
  975. }
  976. else if (side.compare("right")==0)
  977. {
  978. angleRight=-angle;
  979. }
  980. else
  981. {
  982. angleLeft=-angle;
  983. angleRight=-angle;
  984. }
  985. }
  986. //-----------
  987. int Road::CheckLaneSectionInterval(double s_check)
  988. {
  989. int res=-1;
  990. //Go through all the lane section records
  991. for (unsigned int i=0;i<mLaneSectionsVector.size();i++)
  992. {
  993. //check if the s_check belongs to the current record
  994. if (mLaneSectionsVector.at(i).CheckInterval(s_check))
  995. res=i; //assign it to the result id
  996. else
  997. break; //if not, break;
  998. }
  999. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1000. }
  1001. //-----------
  1002. int Road::CheckLaneOffsetInterval(double s_check)
  1003. {
  1004. int res=-1;
  1005. //Go through all the lane section records
  1006. for (unsigned int i=0;i<mLaneOffsetVector.size();i++)
  1007. {
  1008. //check if the s_check belongs to the current record
  1009. if (mLaneOffsetVector.at(i).CheckInterval(s_check))
  1010. res=i; //assign it to the result id
  1011. else
  1012. break; //if not, break;
  1013. }
  1014. return res; //return the result: 0 to MaxInt as the index to the record containing s_check or -1 if nothing found
  1015. }
  1016. //-----------
  1017. void Road::FillLaneSectionSample(double s_check, LaneSectionSample& laneSectionSample)
  1018. {
  1019. int index=CheckLaneSectionInterval(s_check);
  1020. if (index>=0)
  1021. mLaneSectionsVector.at(index).FillLaneSectionSample(s_check,laneSectionSample);
  1022. }
  1023. //-------------------------------------------------
  1024. /**
  1025. * Destructor
  1026. */
  1027. Road::~Road()
  1028. {
  1029. delete mPredecessor;
  1030. delete mSuccessor;
  1031. delete mNeighbor1;
  1032. delete mNeighbor2;
  1033. // DELETING ROAD TYPES
  1034. mRoadTypeVector.clear();
  1035. // DELETING GEOMETRY BLOKS
  1036. mGeometryBlockVector.clear();
  1037. // DELETING ELEVATIONS
  1038. mElevationVector.clear();
  1039. // DELETING SUPERELEVATION
  1040. mSuperElevationVector.clear();
  1041. // DELETING CROSSFALL
  1042. mCrossfallVector.clear();
  1043. // DELETING LANE SECTIONS
  1044. mLaneSectionsVector.clear();
  1045. // DELETING OBJECTS
  1046. mObjectsVector.clear();
  1047. // DELETING SIGNALS
  1048. mSignalsVector.clear();
  1049. }
  1050. //***********************************************************************************
  1051. //Road Link Record
  1052. //***********************************************************************************
  1053. /**
  1054. * Constructor which intializes the basic properties
  1055. */
  1056. RoadLink::RoadLink(string elementType, string elementId, string contactPoint)
  1057. {
  1058. mElementType=elementType;
  1059. mElementId=elementId;
  1060. mContactPoint=contactPoint;
  1061. }
  1062. /**
  1063. * Getters for the basic properties
  1064. */
  1065. string RoadLink::GetElementType()
  1066. {
  1067. return mElementType;
  1068. }
  1069. string RoadLink::GetElementId()
  1070. {
  1071. return mElementId;
  1072. }
  1073. string RoadLink::GetContactPoint()
  1074. {
  1075. return mContactPoint;
  1076. }
  1077. double RoadLink::GetElementS()
  1078. {
  1079. return mElementS;
  1080. }
  1081. string RoadLink::GetElementDir()
  1082. {
  1083. return mElementDir;
  1084. }
  1085. /**
  1086. * Setters for the basic properties
  1087. */
  1088. void RoadLink::SetElementType(string elementType)
  1089. {
  1090. mElementType=elementType;
  1091. }
  1092. void RoadLink::SetElementId(string elementId)
  1093. {
  1094. mElementId=elementId;
  1095. }
  1096. void RoadLink::SetContactPoint(string contactPoint)
  1097. {
  1098. mContactPoint=contactPoint;
  1099. }
  1100. void RoadLink::SetElementS(double value)
  1101. {
  1102. mElementS = value;
  1103. }
  1104. void RoadLink::SetELementDir(std::string elementdir)
  1105. {
  1106. mElementDir = elementdir;
  1107. }
  1108. //***********************************************************************************
  1109. //Road Neighbor Record
  1110. //***********************************************************************************
  1111. /**
  1112. * Constructor which intializes the basic properties
  1113. */
  1114. RoadNeighbor::RoadNeighbor(string side, string elementId, string direction)
  1115. {
  1116. mSide=side;
  1117. mElementId=elementId;
  1118. mDirection=direction;
  1119. }
  1120. /**
  1121. * Getters for the basic properties
  1122. */
  1123. string RoadNeighbor::GetSide()
  1124. {
  1125. return mSide;
  1126. }
  1127. string RoadNeighbor::GetElementId()
  1128. {
  1129. return mElementId;
  1130. }
  1131. string RoadNeighbor::GetDirection()
  1132. {
  1133. return mDirection;
  1134. }
  1135. /**
  1136. * Setters for the basic properties
  1137. */
  1138. void RoadNeighbor::SetSide(string side)
  1139. {
  1140. mSide=side;
  1141. }
  1142. void RoadNeighbor::SetElementId(string elementId)
  1143. {
  1144. mElementId=elementId;
  1145. }
  1146. void RoadNeighbor::SetDirection(string direction)
  1147. {
  1148. mDirection=direction;
  1149. }
  1150. //***********************************************************************************
  1151. //Road Type
  1152. //***********************************************************************************
  1153. /**
  1154. * Constructor which intializes the basic properties
  1155. */
  1156. RoadType::RoadType (double s, string type,string country)
  1157. {
  1158. mS=s; mType=type;mCountry = country;
  1159. }
  1160. /**
  1161. * Setters for the basic properties
  1162. */
  1163. void RoadType::SetS(double value)
  1164. {
  1165. mS=value;
  1166. }
  1167. void RoadType::SetType(string type)
  1168. {
  1169. mType=type;
  1170. }
  1171. void RoadType::SetCountry(std::string country)
  1172. {
  1173. mCountry = country;
  1174. }
  1175. /**
  1176. * Getters for the basic properties
  1177. */
  1178. double RoadType::GetS()
  1179. {
  1180. return mS;
  1181. }
  1182. string RoadType::GetType()
  1183. {
  1184. return mType;
  1185. }
  1186. string RoadType::GetCountry()
  1187. {
  1188. return mCountry;
  1189. }
  1190. vector<RoadTypeSpeed> * RoadType::GetRoadTypeSpeedVector()
  1191. {
  1192. return &mRoadTypeSpeedVector;
  1193. }
  1194. unsigned int RoadType::GetRoadTypeSpeedCount()
  1195. {
  1196. return mRoadTypeSpeedVector.size();
  1197. }
  1198. RoadTypeSpeed * RoadType::GetRoadTypeSpeed(unsigned int i)
  1199. {
  1200. if ((mRoadTypeSpeedVector.size()>0)&&(i<mRoadTypeSpeedVector.size()))
  1201. return &mRoadTypeSpeedVector.at(i);
  1202. else
  1203. return NULL;
  1204. }
  1205. unsigned int RoadType::AddRoadTypeSpeed(double maxSpeed, std::string unit)
  1206. {
  1207. RoadTypeSpeed rts(maxSpeed,unit);
  1208. if(mRoadTypeSpeedVector.size()>0)mRoadTypeSpeedVector.clear();
  1209. mRoadTypeSpeedVector.push_back(rts);
  1210. return mRoadTypeSpeedVector.size()-1;
  1211. }
  1212. void RoadType::DeleteRoadTypeSpeed(unsigned int index)
  1213. {
  1214. if(index >= 1)
  1215. {
  1216. return;
  1217. }
  1218. mRoadTypeSpeedVector.clear();
  1219. }
  1220. //***********************************************************************************
  1221. //Road Type Speed
  1222. //***********************************************************************************
  1223. /**
  1224. * Constructor which intializes the basic properties
  1225. */
  1226. RoadTypeSpeed::RoadTypeSpeed(double maxSpeed, std::string unit)
  1227. {
  1228. mmaxSpeed = maxSpeed;
  1229. munit = unit;
  1230. }
  1231. /**
  1232. * Setters for the basic properties
  1233. */
  1234. void RoadTypeSpeed::SetmaxSpeed(double value)
  1235. {
  1236. mmaxSpeed = value;
  1237. }
  1238. void RoadTypeSpeed::Setunit(std::string unit)
  1239. {
  1240. munit = unit;
  1241. }
  1242. /**
  1243. * Getters for the basic properties
  1244. */
  1245. double RoadTypeSpeed::GetmaxSpeed()
  1246. {
  1247. return mmaxSpeed;
  1248. }
  1249. string RoadTypeSpeed::Getunit()
  1250. {
  1251. return munit;
  1252. }
  1253. //***********************************************************************************
  1254. //Elevation record
  1255. //***********************************************************************************
  1256. /**
  1257. * Constructor which intializes the basic properties
  1258. */
  1259. Elevation::Elevation(double s, double a, double b, double c, double d): ThirdOrderPolynom(s,a,b,c,d)
  1260. {}
  1261. //***********************************************************************************
  1262. //Elevation record
  1263. //***********************************************************************************
  1264. /**
  1265. * Constructor which intializes the basic properties
  1266. */
  1267. SuperElevation::SuperElevation(double s, double a, double b, double c, double d): ThirdOrderPolynom(s,a,b,c,d)
  1268. {}
  1269. //***********************************************************************************
  1270. //Crossfall Record
  1271. //***********************************************************************************
  1272. /**
  1273. * Constructor which intializes the basic properties
  1274. */
  1275. Crossfall::Crossfall (string side, double s, double a, double b, double c, double d):ThirdOrderPolynom(s,a,b,c,d)
  1276. {
  1277. mSide=side;
  1278. }
  1279. /**
  1280. * Getters for the crossfall side
  1281. */
  1282. string Crossfall::GetSide()
  1283. {
  1284. return mSide;
  1285. }
  1286. /**
  1287. * Setters for the crossfall side
  1288. */
  1289. void Crossfall::SetSide(string side)
  1290. {
  1291. mSide=side;
  1292. }