root / trunk / code / projects / traffic_navigation / intersectData.c @ 1900
History | View | Annotate | Download (1.03 KB)
1 | 1887 | pdeo | #include "intersectData.h" |
---|---|---|---|
2 | |||
3 | /*
|
||
4 | * This function serves to make the code for the intersection database
|
||
5 | * as reuseable as possible. This part initializes the data and is the
|
||
6 | * only one that needs to be rewritten for each map.
|
||
7 | *
|
||
8 | */
|
||
9 | |||
10 | void initializeData(){
|
||
11 | //insert all intersections that are in the map.
|
||
12 | insertIntersection(0, INTERSECTION_DOUBLE_C, TMIDDLE);
|
||
13 | return;
|
||
14 | } |
||
15 | |||
16 | /*
|
||
17 | * This function serves to make the code for the intersection database
|
||
18 | * as reuseable as possible. This part creates the implementation of the
|
||
19 | * database that can be copied over for all projects.
|
||
20 | *
|
||
21 | */
|
||
22 | |||
23 | |||
24 | // Does nothing if your indmaex is out of bounds.
|
||
25 | void insertIntersection(int barcode, int intersect_type, int intersect_position){ |
||
26 | if (barcode < sizeof(IntersectData)/sizeof(int)) |
||
27 | IntersectData[barcode] = intersect_type + intersect_position; |
||
28 | return;
|
||
29 | } |
||
30 | |||
31 | // Functions to get data from the Database:
|
||
32 | |||
33 | int getIntersectType(int barcode){ |
||
34 | return (IntersectData[barcode])&28; // 28 == 11100; |
||
35 | } |
||
36 | |||
37 | int getIntersectPos(int barcode){ |
||
38 | return (IntersectData[barcode])&3; |
||
39 | } |