Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/ways.h
Parent Directory
|
Revision Log
Revision 54 -
(hide annotations)
(download)
(as text)
Sun Jan 18 16:04:09 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3813 byte(s)
Sun Jan 18 16:04:09 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3813 byte(s)
Added Super-Ways and allow user to select method of transport.
1 | amb | 21 | /*************************************** |
2 | amb | 54 | $Header: /home/amb/CVS/routino/src/ways.h,v 1.7 2009-01-18 16:03:45 amb Exp $ |
3 | amb | 21 | |
4 | A header file for the ways. | ||
5 | ******************/ /****************** | ||
6 | Written by Andrew M. Bishop | ||
7 | |||
8 | This file Copyright 2009 Andrew M. Bishop | ||
9 | It may be distributed under the GNU Public License, version 2, or | ||
10 | any higher version. See section COPYING of the GNU Public license | ||
11 | for conditions under which this file may be redistributed. | ||
12 | ***************************************/ | ||
13 | |||
14 | |||
15 | #ifndef WAYS_H | ||
16 | #define WAYS_H /*+ To stop multiple inclusions. +*/ | ||
17 | |||
18 | #include <stdint.h> | ||
19 | |||
20 | |||
21 | /* Constants */ | ||
22 | |||
23 | |||
24 | #if 1 /* set to 0 to use a flat array, 1 for indexed. */ | ||
25 | |||
26 | /*+ The number of bins for ways. +*/ | ||
27 | #define NBINS_WAYS 1024 | ||
28 | |||
29 | #else | ||
30 | |||
31 | #undef NBINS_WAYS | ||
32 | |||
33 | #endif | ||
34 | |||
35 | amb | 27 | /*+ The array size increment for ways. +*/ |
36 | #define INCREMENT_WAYS 256*1024 | ||
37 | amb | 21 | |
38 | amb | 27 | |
39 | amb | 21 | /* Simple Types */ |
40 | |||
41 | |||
42 | /*+ A way identifier. +*/ | ||
43 | typedef uint32_t way_t; | ||
44 | |||
45 | /*+ The speed limit of the way. +*/ | ||
46 | typedef uint8_t speed_t; | ||
47 | |||
48 | amb | 30 | /*+ A way type identifier. +*/ |
49 | amb | 50 | typedef uint8_t waytype_t; |
50 | amb | 21 | |
51 | amb | 50 | /*+ The different types of a way. +*/ |
52 | amb | 30 | typedef enum _WayType |
53 | { | ||
54 | Way_Motorway =1, | ||
55 | Way_Trunk =2, | ||
56 | Way_Primary =3, | ||
57 | Way_Tertiary =4, | ||
58 | Way_Secondary =5, | ||
59 | Way_Unclassfied=6, | ||
60 | Way_Residential=7, | ||
61 | Way_Service =8, | ||
62 | Way_Track =9, | ||
63 | Way_Bridleway =10, | ||
64 | Way_Cycleway =11, | ||
65 | Way_Footway =12, | ||
66 | Way_Unknown =15, | ||
67 | amb | 50 | |
68 | Way_OneWay =16, | ||
69 | Way_Roundabout =32 | ||
70 | amb | 30 | } |
71 | WayType; | ||
72 | |||
73 | #define Way_TYPE(xx) ((xx)&0x0f) | ||
74 | |||
75 | |||
76 | amb | 50 | /*+ A way type identifier. +*/ |
77 | typedef uint8_t wayallow_t; | ||
78 | amb | 30 | |
79 | amb | 50 | /*+ The different allowed traffic on a way. +*/ |
80 | typedef enum _AllowType | ||
81 | { | ||
82 | Allow_Foot = 1, | ||
83 | Allow_Bicycle = 2, | ||
84 | Allow_Horse = 4, | ||
85 | Allow_Motorbike = 8, | ||
86 | Allow_Motorcar = 16, | ||
87 | Allow_PSV = 32, | ||
88 | Allow_Goods = 64, | ||
89 | amb | 54 | Allow_HGV =128, |
90 | Allow_ALL =255 | ||
91 | amb | 50 | } |
92 | AllowType; | ||
93 | |||
94 | |||
95 | amb | 21 | /* Data structures */ |
96 | |||
97 | |||
98 | /*+ A structure containing a single way. +*/ | ||
99 | typedef struct _Way | ||
100 | { | ||
101 | amb | 50 | way_t id; /*+ The way identifier. +*/ |
102 | uint32_t name; /*+ An offset of the name of the way in the ways array. +*/ | ||
103 | speed_t limit; /*+ The defined speed limit on the way. +*/ | ||
104 | speed_t speed; /*+ The assumed speed limit on the way. +*/ | ||
105 | waytype_t type; /*+ The type of the way. +*/ | ||
106 | wayallow_t allow; /*+ The type of traffic allowed on the way. +*/ | ||
107 | amb | 21 | } |
108 | Way; | ||
109 | |||
110 | /*+ A structure containing a set of ways (mmap format). +*/ | ||
111 | typedef struct _Ways | ||
112 | { | ||
113 | amb | 26 | uint32_t number; /*+ How many entries are used? +*/ |
114 | amb | 21 | #ifdef NBINS_WAYS |
115 | amb | 26 | uint32_t offset[NBINS_WAYS+1]; /*+ An offset to the first entry in each bin. +*/ |
116 | amb | 21 | #endif |
117 | amb | 26 | Way ways[1]; /*+ An array of ways whose size is not limited to 1 |
118 | amb | 21 | (i.e. may overflow the end of this structure). +*/ |
119 | } | ||
120 | Ways; | ||
121 | |||
122 | /*+ A structure containing a set of ways (memory format). +*/ | ||
123 | typedef struct _WaysMem | ||
124 | { | ||
125 | uint32_t alloced; /*+ How many entries are allocated? +*/ | ||
126 | uint32_t number; /*+ How many entries are used? +*/ | ||
127 | uint32_t number_str; /*+ How many name entries are used? +*/ | ||
128 | uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/ | ||
129 | |||
130 | Ways *ways; /*+ The real data +*/ | ||
131 | char **names; /*+ An array of names. +*/ | ||
132 | } | ||
133 | WaysMem; | ||
134 | |||
135 | |||
136 | /* Functions */ | ||
137 | |||
138 | |||
139 | WaysMem *NewWayList(void); | ||
140 | |||
141 | Ways *LoadWayList(const char *filename); | ||
142 | Ways *SaveWayList(WaysMem *ways,const char *filename); | ||
143 | |||
144 | Way *FindWay(Ways *ways,way_t id); | ||
145 | |||
146 | amb | 30 | Way *AppendWay(WaysMem *ways,way_t id,const char *name); |
147 | amb | 21 | |
148 | void SortWayList(WaysMem *ways); | ||
149 | |||
150 | amb | 30 | WayType TypeOfWay(const char *type); |
151 | amb | 21 | |
152 | amb | 54 | AllowType AllowedType(const char *transport); |
153 | |||
154 | amb | 32 | #define LookupWay(xxx,yyy) (&xxx->ways[yyy]) |
155 | amb | 21 | |
156 | amb | 32 | #define WayName(xxx,yyy) ((char*)&xxx->ways[yyy->name]) |
157 | |||
158 | |||
159 | amb | 21 | #endif /* WAYS_H */ |
Properties
Name | Value |
---|---|
cvs:description | Header file for ways. |