root / trunk / code / projects / traffic_navigation / intersectData.c @ 1903
History | View | Annotate | Download (1.26 KB)
1 |
#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, 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 key, int featureid, int intersect_type, int intersect_position){ |
26 |
// if (key < sizeof(IntersectData)/sizeof(int))
|
27 |
if(key < NUM_INTERSECTIONS)
|
28 |
IntersectData[key] = (featureid << 12) + intersect_type + intersect_position;
|
29 |
return;
|
30 |
} |
31 |
|
32 |
// Functions to get data from the Database:
|
33 |
//@TODO:Add some checks to make sure the key is less than NUM_INTERSECTIONS
|
34 |
// also: figure out what to do when this happens.
|
35 |
|
36 |
int getIntersectType(int key){ |
37 |
return (IntersectData[key])&28; // 28 == 11100; |
38 |
} |
39 |
|
40 |
int getIntersectPos(int key){ |
41 |
return (IntersectData[key])&3; |
42 |
} |
43 |
int getFeatureId(int key) |
44 |
{ |
45 |
return (IntersectData[key] >> 12)&0xF; |
46 |
} |