Revision 1903
Added a "feature id" field in bits 13,14,15,16 of the database ints, documented accordingly
trunk/code/projects/traffic_navigation/intersectData.h | ||
---|---|---|
1 | 1 |
#ifndef _INTERSECTION_DATABASE_ |
2 | 2 |
#define _INTERSECTION_DATABASE_ |
3 |
#define NUM_INTERSECTIONS 1 |
|
3 | 4 |
|
4 |
|
|
5 | 5 |
/**************************** |
6 | 6 |
* Intersection Information: 5-bit Integer |
7 | 7 |
* 3 bits of intersection type |
8 | 8 |
* 2 bits of entry information |
9 |
* |
|
10 |
* Also contains a "feature id": 4 bits in positions 13,14,15,16 |
|
9 | 11 |
* |
10 | 12 |
****************************/ |
11 | 13 |
|
... | ... | |
80 | 82 |
#define R_RAMP 2 |
81 | 83 |
|
82 | 84 |
// Global variable for the intersection database. You can change the size here. Size == number of intersections. |
83 |
int IntersectData[1];
|
|
85 |
int IntersectData[NUM_INTERSECTIONS];
|
|
84 | 86 |
|
85 | 87 |
void initializeData(); |
86 |
void insertIntersection(int barcode, int intersect_type, int intersect_position);
|
|
88 |
void insertIntersection(int key, int featureid, int intersect_type, int intersect_position);
|
|
87 | 89 |
|
88 | 90 |
// Functions to get data from the Database: |
89 |
int getIntersectType(int barcode); |
|
90 |
int getIntersectPos(int barcode); |
|
91 |
int getIntersectType(int entry); |
|
92 |
int getIntersectPos(int entry); |
|
93 |
int getFeatureId(int entry); |
|
91 | 94 |
|
92 | 95 |
#endif |
trunk/code/projects/traffic_navigation/intersectData.c | ||
---|---|---|
9 | 9 |
|
10 | 10 |
void initializeData(){ |
11 | 11 |
//insert all intersections that are in the map. |
12 |
insertIntersection(0, INTERSECTION_DOUBLE_C, TMIDDLE); |
|
12 |
insertIntersection(0, 0, INTERSECTION_DOUBLE_C, TMIDDLE);
|
|
13 | 13 |
return; |
14 | 14 |
} |
15 | 15 |
|
... | ... | |
22 | 22 |
|
23 | 23 |
|
24 | 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; |
|
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; |
|
28 | 29 |
return; |
29 | 30 |
} |
30 | 31 |
|
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. |
|
32 | 35 |
|
33 |
int getIntersectType(int barcode){
|
|
34 |
return (IntersectData[barcode])&28; // 28 == 11100;
|
|
36 |
int getIntersectType(int key){
|
|
37 |
return (IntersectData[key])&28; // 28 == 11100;
|
|
35 | 38 |
} |
36 | 39 |
|
37 |
int getIntersectPos(int barcode){
|
|
38 |
return (IntersectData[barcode])&3;
|
|
40 |
int getIntersectPos(int key){
|
|
41 |
return (IntersectData[key])&3;
|
|
39 | 42 |
} |
43 |
int getFeatureId(int key) |
|
44 |
{ |
|
45 |
return (IntersectData[key] >> 12)&0xF; |
|
46 |
} |
Also available in: Unified diff