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 88 -
(hide annotations)
(download)
(as text)
Tue Jan 27 18:22:37 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 4541 byte(s)
Tue Jan 27 18:22:37 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 4541 byte(s)
Intermediate version while transitioning data format for nodes and segments.
1 | amb | 21 | /*************************************** |
2 | amb | 88 | $Header: /home/amb/CVS/routino/src/ways.h,v 1.18 2009-01-27 18:22:37 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 | amb | 65 | /*+ The array size increment for ways - expect ~1,000,000 ways. +*/ |
25 | amb | 27 | #define INCREMENT_WAYS 256*1024 |
26 | amb | 21 | |
27 | amb | 27 | |
28 | amb | 21 | /* Simple Types */ |
29 | |||
30 | |||
31 | /*+ The speed limit of the way. +*/ | ||
32 | typedef uint8_t speed_t; | ||
33 | |||
34 | amb | 74 | /*+ The type of a way. +*/ |
35 | amb | 50 | typedef uint8_t waytype_t; |
36 | amb | 21 | |
37 | amb | 50 | /*+ The different types of a way. +*/ |
38 | amb | 74 | typedef enum _Highway |
39 | amb | 30 | { |
40 | amb | 85 | Way_Motorway = 1, |
41 | Way_Trunk = 2, | ||
42 | Way_Primary = 3, | ||
43 | Way_Secondary = 4, | ||
44 | Way_Tertiary = 5, | ||
45 | Way_Unclassified= 6, | ||
46 | Way_Residential = 7, | ||
47 | Way_Service = 8, | ||
48 | Way_Track = 9, | ||
49 | Way_Bridleway =10, | ||
50 | Way_Cycleway =11, | ||
51 | Way_Footway =12, | ||
52 | amb | 68 | |
53 | amb | 85 | Way_Unknown =13, |
54 | amb | 50 | |
55 | amb | 85 | Way_OneWay =16, |
56 | Way_Roundabout =32 | ||
57 | amb | 30 | } |
58 | amb | 74 | Highway; |
59 | amb | 30 | |
60 | amb | 75 | #define HIGHWAY(xx) ((xx)&0x0f) |
61 | amb | 30 | |
62 | amb | 75 | |
63 | amb | 74 | /*+ The type of a method of transport. +*/ |
64 | typedef uint8_t transport_t; | ||
65 | |||
66 | /*+ The different methods of transport. +*/ | ||
67 | typedef enum _Transport | ||
68 | { | ||
69 | Transport_None = 0, | ||
70 | |||
71 | Transport_Foot = 1, | ||
72 | Transport_Bicycle = 2, | ||
73 | Transport_Horse = 3, | ||
74 | Transport_Motorbike = 4, | ||
75 | Transport_Motorcar = 5, | ||
76 | amb | 82 | Transport_Goods = 6, |
77 | Transport_HGV = 7, | ||
78 | Transport_PSV = 8 | ||
79 | amb | 74 | } |
80 | Transport; | ||
81 | |||
82 | |||
83 | /*+ The allowed traffic on a way. +*/ | ||
84 | amb | 50 | typedef uint8_t wayallow_t; |
85 | amb | 30 | |
86 | amb | 50 | /*+ The different allowed traffic on a way. +*/ |
87 | amb | 74 | typedef enum _Allowed |
88 | amb | 50 | { |
89 | amb | 74 | Allow_Foot =1<<(Transport_Foot -1), |
90 | Allow_Bicycle =1<<(Transport_Bicycle -1), | ||
91 | Allow_Horse =1<<(Transport_Horse -1), | ||
92 | Allow_Motorbike =1<<(Transport_Motorbike-1), | ||
93 | Allow_Motorcar =1<<(Transport_Motorcar -1), | ||
94 | Allow_Goods =1<<(Transport_Goods -1), | ||
95 | Allow_HGV =1<<(Transport_HGV -1), | ||
96 | amb | 82 | Allow_PSV =1<<(Transport_PSV -1), |
97 | amb | 74 | |
98 | amb | 54 | Allow_ALL =255 |
99 | amb | 50 | } |
100 | amb | 74 | Allowed; |
101 | amb | 50 | |
102 | |||
103 | amb | 21 | /* Data structures */ |
104 | |||
105 | |||
106 | /*+ A structure containing a single way. +*/ | ||
107 | typedef struct _Way | ||
108 | { | ||
109 | amb | 87 | uint32_t name; /*+ The offset of the name of the way in the names array. +*/ |
110 | amb | 50 | speed_t limit; /*+ The defined speed limit on the way. +*/ |
111 | waytype_t type; /*+ The type of the way. +*/ | ||
112 | wayallow_t allow; /*+ The type of traffic allowed on the way. +*/ | ||
113 | amb | 21 | } |
114 | Way; | ||
115 | |||
116 | amb | 87 | /*+ An extended structure containing a single way. +*/ |
117 | typedef struct _WayEx | ||
118 | { | ||
119 | amb | 88 | uint32_t index; /*+ The index of the way. +*/ |
120 | amb | 87 | char *name; /*+ The name of the way. +*/ |
121 | |||
122 | Way way; /*+ The real Way data. +*/ | ||
123 | } | ||
124 | WayEx; | ||
125 | |||
126 | amb | 21 | /*+ A structure containing a set of ways (mmap format). +*/ |
127 | typedef struct _Ways | ||
128 | { | ||
129 | amb | 87 | uint32_t number; /*+ How many entries are used? +*/ |
130 | |||
131 | Way *ways; /*+ An array of ways. */ | ||
132 | char *names; /*+ An array of characters containing the names. +*/ | ||
133 | |||
134 | void *data; /*+ The memory mapped data. +*/ | ||
135 | amb | 21 | } |
136 | Ways; | ||
137 | |||
138 | /*+ A structure containing a set of ways (memory format). +*/ | ||
139 | typedef struct _WaysMem | ||
140 | { | ||
141 | amb | 87 | uint32_t sorted; /*+ Is the data sorted? +*/ |
142 | amb | 21 | uint32_t alloced; /*+ How many entries are allocated? +*/ |
143 | uint32_t number; /*+ How many entries are used? +*/ | ||
144 | amb | 87 | uint32_t length; /*+ How long is the string of name entries? +*/ |
145 | amb | 21 | |
146 | amb | 87 | WayEx *xdata; /*+ The extended data for the Ways. +*/ |
147 | char *names; /*+ The array containing all the names. +*/ | ||
148 | amb | 21 | } |
149 | WaysMem; | ||
150 | |||
151 | |||
152 | /* Functions */ | ||
153 | |||
154 | |||
155 | WaysMem *NewWayList(void); | ||
156 | |||
157 | Ways *LoadWayList(const char *filename); | ||
158 | amb | 87 | Ways *SaveWayList(WaysMem *waysmem,const char *filename); |
159 | amb | 21 | |
160 | amb | 87 | void DropWayList(Ways *ways); |
161 | amb | 21 | |
162 | amb | 87 | Way *AppendWay(WaysMem *waysmem,const char *name); |
163 | amb | 21 | |
164 | amb | 87 | void SortWayList(WaysMem *waysmem); |
165 | amb | 21 | |
166 | amb | 74 | Highway HighwayType(const char *highway); |
167 | Transport TransportType(const char *transport); | ||
168 | amb | 21 | |
169 | amb | 82 | const char *HighwayName(Highway highway); |
170 | const char *TransportName(Transport transport); | ||
171 | |||
172 | amb | 75 | const char *HighwayList(void); |
173 | const char *TransportList(void); | ||
174 | |||
175 | amb | 84 | #define LookupWay(xxx,yyy) (&(xxx)->ways[yyy]) |
176 | amb | 21 | |
177 | amb | 84 | #define IndexWay(xxx,yyy) ((yyy)-&(xxx)->ways[0]) |
178 | amb | 32 | |
179 | amb | 87 | #define WayName(xxx,yyy) (&(xxx)->names[(yyy)->name]) |
180 | amb | 32 | |
181 | amb | 84 | |
182 | amb | 21 | #endif /* WAYS_H */ |
Properties
Name | Value |
---|---|
cvs:description | Header file for ways. |