root / trunk / code / projects / traffic_navigation / intersectData.c @ 1908
History | View | Annotate | Download (1.96 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 |
//THIS DATA FOR THE DEMO MAP
|
13 |
|
14 |
insertNode(0, INTERSECTION_NODE, INTERSECTION_DOUBLE_C, TMIDDLE);
|
15 |
insertNode(1, ROAD_NODE, ROAD, ROAD_DOUBLE);
|
16 |
insertNode(2, ROAD_NODE, ROAD, ROAD_DOUBLE);
|
17 |
insertNode(3, ROAD_NODE, ROAD, ROAD_DOUBLE);
|
18 |
insertNode(4, ROAD_NODE, ROAD, ROAD_DOUBLE);
|
19 |
return;
|
20 |
} |
21 |
|
22 |
/*
|
23 |
* This function serves to make the code for the intersection database
|
24 |
* as reuseable as possible. This part creates the implementation of the
|
25 |
* database that can be copied over for all projects.
|
26 |
*
|
27 |
*/
|
28 |
|
29 |
|
30 |
// Does nothing if your indmaex is out of bounds.
|
31 |
void insertNode(int key, int featureid, int node_type, int node_info){ |
32 |
// if (key < sizeof(IntersectData)/sizeof(int))
|
33 |
if(key < NUM_FEATURES)
|
34 |
IntersectData[key] = featureid + node_type + node_info; |
35 |
return;
|
36 |
} |
37 |
|
38 |
// Functions to get data from the Database:
|
39 |
//@TODO:Add some checks to make sure the key is less than NUM_FEATURES
|
40 |
// also: figure out what to do when this happens.
|
41 |
// Add checks to see if we call getIntersect...() on intersections
|
42 |
// and getRoad...() on roads.
|
43 |
|
44 |
int getIntersectType(int key){ |
45 |
return (IntersectData[key])&28; // 28 == 11100; |
46 |
} |
47 |
|
48 |
int getTurningIntersect(int key){ |
49 |
switch(getIntersectType(key))
|
50 |
{ |
51 |
case INTERSECTION_SINGLE:
|
52 |
return SINGLE;
|
53 |
case INTERSECTION_DOUBLE_C:
|
54 |
case INTERSECTION_DOUBLE_T:
|
55 |
return DOUBLE;
|
56 |
case INTERSECTION_ON_RAMP:
|
57 |
return ON_RAMP;
|
58 |
case INTERSECTION_OFF_RAMP:
|
59 |
return OFF_RAMP;
|
60 |
} |
61 |
} |
62 |
|
63 |
int getIntersectPos(int key){ |
64 |
return (IntersectData[key])&3; |
65 |
} |
66 |
int getFeatureId(int key) |
67 |
{ |
68 |
return (IntersectData[key])&61440; // 61220 == (15<<12); |
69 |
} |
70 |
int getRoadType(int key){ |
71 |
return (IntersectData[key])&28; // 28 == 11100; |
72 |
} |
73 |
int getRoadInfo(int key){ |
74 |
return (IntersectData[key])&3; |
75 |
} |
76 |
|