Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Annotation of /trunk/src/types.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 198 - (hide annotations) (download) (as text)
Mon Jun 15 18:52:54 2009 UTC (15 years, 9 months ago) by amb
File MIME type: text/x-chdr
File size: 7051 byte(s)
Add a macro for converting degrees to radians and radians to degrees.

1 amb 2 /***************************************
2 amb 198 $Header: /home/amb/CVS/routino/src/types.h,v 1.22 2009-06-15 18:52:54 amb Exp $
3 amb 2
4     Type definitions
5 amb 151
6     Part of the Routino routing software.
7 amb 2 ******************/ /******************
8 amb 151 This file Copyright 2008,2009 Andrew M. Bishop
9 amb 2
10 amb 151 This program is free software: you can redistribute it and/or modify
11     it under the terms of the GNU Affero General Public License as published by
12     the Free Software Foundation, either version 3 of the License, or
13     (at your option) any later version.
14    
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     GNU Affero General Public License for more details.
19    
20     You should have received a copy of the GNU Affero General Public License
21     along with this program. If not, see <http://www.gnu.org/licenses/>.
22 amb 2 ***************************************/
23    
24    
25     #ifndef TYPES_H
26     #define TYPES_H /*+ To stop multiple inclusions. +*/
27    
28     #include <stdint.h>
29 amb 118 #include <math.h>
30 amb 2
31    
32 amb 118 /* Constants and macros for handling them */
33 amb 2
34    
35 amb 121 /*+ The latitude and longitude conversion factor from float (radians) to integer. +*/
36     #define LAT_LONG_SCALE (1024*65536)
37 amb 109
38     /*+ The latitude and longitude integer range within each bin. +*/
39     #define LAT_LONG_BIN 65536
40    
41 amb 118 /*+ Convert a latitude or longitude to a bin number (taking care of rounding). +*/
42 amb 121 #define lat_long_to_bin(xxx) ((int32_t)floorf((xxx)*1024))
43 amb 109
44 amb 118 /*+ Convert a bin number to a latitude or longitude. +*/
45 amb 121 #define bin_to_lat_long(xxx) ((float)(xxx)/1024)
46 amb 109
47 amb 118
48 amb 198 /*+ Convert radians to degrees. +*/
49     #define radians_to_degrees(xxx) ((xxx)*(180.0/M_PI))
50    
51     /*+ Convert degrees to radians. +*/
52     #define degrees_to_radians(xxx) ((xxx)*(M_PI/180.0))
53    
54    
55 amb 96 /*+ A flag to mark super-nodes and super-segments. +*/
56 amb 176 #define SUPER_FLAG ((index_t)0x80000000)
57 amb 96
58 amb 176 /*+ A node index excluding the super-node flag. +*/
59 amb 109 #define NODE(xxx) (index_t)((xxx)&(~SUPER_FLAG))
60    
61 amb 176 /*+ An undefined node index. +*/
62     #define NO_NODE (~(index_t)0)
63    
64     /*+ A segment index excluding the super-segment flag. +*/
65 amb 109 #define SEGMENT(xxx) (index_t)((xxx)&(~SUPER_FLAG))
66    
67 amb 176 /*+ An undefined segment index. +*/
68     #define NO_SEGMENT (~(index_t)0)
69 amb 109
70 amb 176
71 amb 104 /*+ A flag to mark a distance as only applying from node1 to node2. +*/
72 amb 176 #define ONEWAY_1TO2 ((distance_t)0x80000000)
73 amb 96
74 amb 104 /*+ A flag to mark a distance as only applying from node2 to node1. +*/
75 amb 176 #define ONEWAY_2TO1 ((distance_t)0x40000000)
76 amb 96
77 amb 109 /*+ The real distance ignoring the ONEWAY_* flags. +*/
78 amb 176 #define DISTANCE(xx) (distance_t)((xx)&(~(ONEWAY_1TO2|ONEWAY_2TO1)))
79 amb 104
80 amb 109
81 amb 176 /*+ A very large almost infinite score. +*/
82     #define INF_SCORE (score_t)1E30
83    
84    
85 amb 96 /* Simple Types */
86    
87    
88 amb 109 /*+ A node identifier. +*/
89     typedef uint32_t node_t;
90    
91    
92 amb 96 /*+ A node, segment or way index. +*/
93     typedef uint32_t index_t;
94    
95    
96 amb 99 /*+ A node latitude or longitude offset. +*/
97     typedef uint16_t ll_off_t;
98    
99    
100 amb 96 /*+ A distance, measured in metres. +*/
101     typedef uint32_t distance_t;
102    
103     /*+ A duration, measured in 1/10th seconds. +*/
104     typedef uint32_t duration_t;
105    
106 amb 166 /*+ A routing optimisation score. +*/
107 amb 168 typedef float score_t;
108 amb 96
109 amb 166
110 amb 96 /*+ Conversion from distance_t to kilometres. +*/
111     #define distance_to_km(xx) ((double)(xx)/1000.0)
112    
113     /*+ Conversion from metres to distance_t. +*/
114     #define km_to_distance(xx) ((distance_t)((double)(xx)*1000.0))
115    
116     /*+ Conversion from duration_t to minutes. +*/
117     #define duration_to_minutes(xx) ((double)(xx)/600.0)
118    
119     /*+ Conversion from duration_t to hours. +*/
120 amb 176 #define duration_to_hours(xx) ((double)(xx)/36000.0)
121 amb 96
122     /*+ Conversion from hours to duration_t. +*/
123 amb 176 #define hours_to_duration(xx) ((duration_t)((double)(xx)*36000.0))
124 amb 96
125     /*+ Conversion from distance_t and speed_t to duration_t. +*/
126     #define distance_speed_to_duration(xx,yy) ((duration_t)(((double)(xx)/(double)(yy))*(36000.0/1000.0)))
127    
128    
129     /*+ The type of a way. +*/
130     typedef uint8_t waytype_t;
131    
132     /*+ The different types of a way. +*/
133     typedef enum _Highway
134     {
135     Way_Motorway = 1,
136     Way_Trunk = 2,
137     Way_Primary = 3,
138     Way_Secondary = 4,
139     Way_Tertiary = 5,
140     Way_Unclassified= 6,
141     Way_Residential = 7,
142     Way_Service = 8,
143     Way_Track = 9,
144 amb 148 Way_Path =10,
145     Way_Bridleway =11,
146     Way_Cycleway =12,
147     Way_Footway =13,
148 amb 96
149 amb 148 Way_Unknown =14,
150 amb 96
151 amb 148 Way_OneWay =32,
152     Way_Roundabout =64
153 amb 96 }
154     Highway;
155    
156     #define HIGHWAY(xx) ((xx)&0x0f)
157    
158    
159     /*+ The method of transport. +*/
160     typedef uint8_t transport_t;
161    
162     /*+ The different methods of transport. +*/
163     typedef enum _Transport
164     {
165     Transport_None = 0,
166    
167     Transport_Foot = 1,
168     Transport_Bicycle = 2,
169     Transport_Horse = 3,
170     Transport_Motorbike = 4,
171     Transport_Motorcar = 5,
172     Transport_Goods = 6,
173     Transport_HGV = 7,
174     Transport_PSV = 8
175     }
176     Transport;
177    
178    
179     /*+ The allowed traffic on a way. +*/
180     typedef uint8_t wayallow_t;
181    
182     /*+ The different allowed traffic on a way. +*/
183     typedef enum _Allowed
184     {
185     Allow_Foot =1<<(Transport_Foot -1),
186     Allow_Bicycle =1<<(Transport_Bicycle -1),
187     Allow_Horse =1<<(Transport_Horse -1),
188     Allow_Motorbike =1<<(Transport_Motorbike-1),
189     Allow_Motorcar =1<<(Transport_Motorcar -1),
190     Allow_Goods =1<<(Transport_Goods -1),
191     Allow_HGV =1<<(Transport_HGV -1),
192     Allow_PSV =1<<(Transport_PSV -1),
193    
194     Allow_ALL =255
195     }
196     Allowed;
197    
198 amb 166
199 amb 135 /*+ The speed limit of a way, measured in km/hour. +*/
200     typedef uint8_t speed_t;
201 amb 96
202 amb 135 /*+ The maximum weight of a way, measured in 0.2 tonnes. +*/
203     typedef uint8_t weight_t;
204    
205     /*+ The maximum height of a way, measured in 0.1 metres. +*/
206     typedef uint8_t height_t;
207    
208     /*+ The maximum width of a way, measured in 0.1 metres. +*/
209     typedef uint8_t width_t;
210    
211     /*+ The maximum length of a way, measured in 0.1 metres. +*/
212     typedef uint8_t length_t;
213    
214    
215     /*+ Conversion of km/hr to speed_t. +*/
216     #define kph_to_speed(xxx) (speed_t)(xxx)
217    
218     /*+ Conversion of speed_t to km/hr. +*/
219     #define speed_to_kph(xxx) (xxx)
220    
221     /*+ Conversion of tonnes to weight_t. +*/
222     #define tonnes_to_weight(xxx) (weight_t)((xxx)*5)
223    
224     /*+ Conversion of weight_t to tonnes. +*/
225     #define weight_to_tonnes(xxx) ((double)(xxx)/5.0)
226    
227     /*+ Conversion of metres to height_t. +*/
228     #define metres_to_height(xxx) (height_t)((xxx)*10)
229    
230     /*+ Conversion of height_t to metres. +*/
231     #define height_to_metres(xxx) ((double)(xxx)/10.0)
232    
233     /*+ Conversion of metres to width_t. +*/
234     #define metres_to_width(xxx) (width_t)((xxx)*10)
235    
236     /*+ Conversion of width_t to metres. +*/
237     #define width_to_metres(xxx) ((double)(xxx)/10.0)
238    
239     /*+ Conversion of metres to length_t. +*/
240     #define metres_to_length(xxx) (length_t)((xxx)*10)
241    
242     /*+ Conversion of length_t to metres. +*/
243     #define length_to_metres(xxx) ((double)(xxx)/10.0)
244    
245    
246 amb 96 /* Data structures */
247    
248 amb 109 typedef struct _Node Node;
249 amb 96
250 amb 109 typedef struct _Nodes Nodes;
251 amb 104
252 amb 109 typedef struct _Segment Segment;
253 amb 15
254 amb 109 typedef struct _Segments Segments;
255 amb 96
256 amb 109 typedef struct _Way Way;
257 amb 104
258 amb 109 typedef struct _Ways Ways;
259 amb 104
260 amb 109 typedef struct _NodeX NodeX;
261 amb 104
262 amb 109 typedef struct _NodesX NodesX;
263 amb 15
264 amb 109 typedef struct _SegmentX SegmentX;
265 amb 15
266 amb 109 typedef struct _SegmentsX SegmentsX;
267 amb 104
268 amb 109 typedef struct _WayX WayX;
269 amb 104
270 amb 109 typedef struct _WaysX WaysX;
271 amb 104
272 amb 96
273 amb 2 #endif /* TYPES_H */

Properties

Name Value
cvs:description Data type definitions.