Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/types.h
Parent Directory
|
Revision Log
Revision 118 -
(show annotations)
(download)
(as text)
Sun Feb 15 13:45:54 2009 UTC (16 years, 1 month ago) by amb
File MIME type: text/x-chdr
File size: 4802 byte(s)
Sun Feb 15 13:45:54 2009 UTC (16 years, 1 month ago) by amb
File MIME type: text/x-chdr
File size: 4802 byte(s)
Add macros for handling lat/long to bin conversions.
1 | /*************************************** |
2 | $Header: /home/amb/CVS/routino/src/types.h,v 1.14 2009-02-15 13:45:54 amb Exp $ |
3 | |
4 | Type definitions |
5 | ******************/ /****************** |
6 | Written by Andrew M. Bishop |
7 | |
8 | This file Copyright 2008,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 TYPES_H |
16 | #define TYPES_H /*+ To stop multiple inclusions. +*/ |
17 | |
18 | #include <stdint.h> |
19 | #include <math.h> |
20 | |
21 | |
22 | /* Constants and macros for handling them */ |
23 | |
24 | |
25 | /*+ The latitude and longitude conversion factor from float to integer. +*/ |
26 | #define LAT_LONG_SCALE (1024*1024) |
27 | |
28 | /*+ The latitude and longitude integer range within each bin. +*/ |
29 | #define LAT_LONG_BIN 65536 |
30 | |
31 | /*+ Convert a latitude or longitude to a bin number (taking care of rounding). +*/ |
32 | #define lat_long_to_bin(xxx) ((int32_t)floorf((xxx)*(LAT_LONG_SCALE/LAT_LONG_BIN))) |
33 | |
34 | /*+ Convert a bin number to a latitude or longitude. +*/ |
35 | #define bin_to_lat_long(xxx) ((float)(xxx)/(LAT_LONG_SCALE/LAT_LONG_BIN)) |
36 | |
37 | |
38 | /*+ A flag to mark super-nodes and super-segments. +*/ |
39 | #define SUPER_FLAG 0x80000000 |
40 | |
41 | /*+ A node index excluding the super-node flag +*/ |
42 | #define NODE(xxx) (index_t)((xxx)&(~SUPER_FLAG)) |
43 | |
44 | /*+ A segment index excluding the super-segment flag +*/ |
45 | #define SEGMENT(xxx) (index_t)((xxx)&(~SUPER_FLAG)) |
46 | |
47 | |
48 | /*+ A flag to mark a distance as only applying from node1 to node2. +*/ |
49 | #define ONEWAY_1TO2 0x80000000 |
50 | |
51 | /*+ A flag to mark a distance as only applying from node2 to node1. +*/ |
52 | #define ONEWAY_2TO1 0x40000000 |
53 | |
54 | /*+ The real distance ignoring the ONEWAY_* flags. +*/ |
55 | #define DISTANCE(xx) (distance_t)((xx)&(~(ONEWAY_1TO2|ONEWAY_2TO1))) |
56 | |
57 | |
58 | /* Simple Types */ |
59 | |
60 | |
61 | /*+ A node identifier. +*/ |
62 | typedef uint32_t node_t; |
63 | |
64 | |
65 | /*+ A node, segment or way index. +*/ |
66 | typedef uint32_t index_t; |
67 | |
68 | |
69 | /*+ A node latitude or longitude offset. +*/ |
70 | typedef uint16_t ll_off_t; |
71 | |
72 | |
73 | /*+ A distance, measured in metres. +*/ |
74 | typedef uint32_t distance_t; |
75 | |
76 | /*+ A duration, measured in 1/10th seconds. +*/ |
77 | typedef uint32_t duration_t; |
78 | |
79 | |
80 | /*+ Conversion from distance_t to kilometres. +*/ |
81 | #define distance_to_km(xx) ((double)(xx)/1000.0) |
82 | |
83 | /*+ Conversion from metres to distance_t. +*/ |
84 | #define km_to_distance(xx) ((distance_t)((double)(xx)*1000.0)) |
85 | |
86 | /*+ Conversion from duration_t to minutes. +*/ |
87 | #define duration_to_minutes(xx) ((double)(xx)/600.0) |
88 | |
89 | /*+ Conversion from duration_t to hours. +*/ |
90 | #define duration_to_hours(xx) ((double)(xx)/36000.0) |
91 | |
92 | /*+ Conversion from hours to duration_t. +*/ |
93 | #define hours_to_duration(xx) ((duration_t)((double)(xx)*36000.0)) |
94 | |
95 | /*+ Conversion from distance_t and speed_t to duration_t. +*/ |
96 | #define distance_speed_to_duration(xx,yy) ((duration_t)(((double)(xx)/(double)(yy))*(36000.0/1000.0))) |
97 | |
98 | |
99 | /*+ The speed limit of a way. +*/ |
100 | typedef uint8_t speed_t; |
101 | |
102 | /*+ The type of a way. +*/ |
103 | typedef uint8_t waytype_t; |
104 | |
105 | /*+ The different types of a way. +*/ |
106 | typedef enum _Highway |
107 | { |
108 | Way_Motorway = 1, |
109 | Way_Trunk = 2, |
110 | Way_Primary = 3, |
111 | Way_Secondary = 4, |
112 | Way_Tertiary = 5, |
113 | Way_Unclassified= 6, |
114 | Way_Residential = 7, |
115 | Way_Service = 8, |
116 | Way_Track = 9, |
117 | Way_Bridleway =10, |
118 | Way_Cycleway =11, |
119 | Way_Footway =12, |
120 | |
121 | Way_Unknown =13, |
122 | |
123 | Way_OneWay =16, |
124 | Way_Roundabout =32 |
125 | } |
126 | Highway; |
127 | |
128 | #define HIGHWAY(xx) ((xx)&0x0f) |
129 | |
130 | |
131 | /*+ The method of transport. +*/ |
132 | typedef uint8_t transport_t; |
133 | |
134 | /*+ The different methods of transport. +*/ |
135 | typedef enum _Transport |
136 | { |
137 | Transport_None = 0, |
138 | |
139 | Transport_Foot = 1, |
140 | Transport_Bicycle = 2, |
141 | Transport_Horse = 3, |
142 | Transport_Motorbike = 4, |
143 | Transport_Motorcar = 5, |
144 | Transport_Goods = 6, |
145 | Transport_HGV = 7, |
146 | Transport_PSV = 8 |
147 | } |
148 | Transport; |
149 | |
150 | |
151 | /*+ The allowed traffic on a way. +*/ |
152 | typedef uint8_t wayallow_t; |
153 | |
154 | /*+ The different allowed traffic on a way. +*/ |
155 | typedef enum _Allowed |
156 | { |
157 | Allow_Foot =1<<(Transport_Foot -1), |
158 | Allow_Bicycle =1<<(Transport_Bicycle -1), |
159 | Allow_Horse =1<<(Transport_Horse -1), |
160 | Allow_Motorbike =1<<(Transport_Motorbike-1), |
161 | Allow_Motorcar =1<<(Transport_Motorcar -1), |
162 | Allow_Goods =1<<(Transport_Goods -1), |
163 | Allow_HGV =1<<(Transport_HGV -1), |
164 | Allow_PSV =1<<(Transport_PSV -1), |
165 | |
166 | Allow_ALL =255 |
167 | } |
168 | Allowed; |
169 | |
170 | |
171 | /* Data structures */ |
172 | |
173 | typedef struct _Node Node; |
174 | |
175 | typedef struct _Nodes Nodes; |
176 | |
177 | typedef struct _Segment Segment; |
178 | |
179 | typedef struct _Segments Segments; |
180 | |
181 | typedef struct _Way Way; |
182 | |
183 | typedef struct _Ways Ways; |
184 | |
185 | typedef struct _NodeX NodeX; |
186 | |
187 | typedef struct _NodesX NodesX; |
188 | |
189 | typedef struct _SegmentX SegmentX; |
190 | |
191 | typedef struct _SegmentsX SegmentsX; |
192 | |
193 | typedef struct _WayX WayX; |
194 | |
195 | typedef struct _WaysX WaysX; |
196 | |
197 | |
198 | #endif /* TYPES_H */ |
Properties
Name | Value |
---|---|
cvs:description | Data type definitions. |