Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/profiles.c
Parent Directory
|
Revision Log
Revision 314 -
(hide annotations)
(download)
(as text)
Tue Dec 15 18:44:28 2009 UTC (15 years, 3 months ago) by amb
File MIME type: text/x-csrc
File size: 35357 byte(s)
Tue Dec 15 18:44:28 2009 UTC (15 years, 3 months ago) by amb
File MIME type: text/x-csrc
File size: 35357 byte(s)
Added wheelchair as type of transport.
1 | amb | 83 | /*************************************** |
2 | amb | 314 | $Header: /home/amb/CVS/routino/src/profiles.c,v 1.29 2009-12-15 18:44:28 amb Exp $ |
3 | amb | 83 | |
4 | The pre-defined profiles and the functions for handling them. | ||
5 | amb | 151 | |
6 | Part of the Routino routing software. | ||
7 | amb | 83 | ******************/ /****************** |
8 | amb | 151 | This file Copyright 2008,2009 Andrew M. Bishop |
9 | amb | 83 | |
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 | 83 | ***************************************/ |
23 | |||
24 | |||
25 | #include <stdio.h> | ||
26 | |||
27 | #include "profiles.h" | ||
28 | amb | 97 | #include "types.h" |
29 | amb | 83 | #include "ways.h" |
30 | |||
31 | |||
32 | amb | 228 | /*+ The set of built-in profiles for different transport types. +*/ |
33 | amb | 83 | static Profile builtin_profiles[]= |
34 | { | ||
35 | /* The profile for travel by Foot */ | ||
36 | |||
37 | [Transport_Foot] = { | ||
38 | .transport=Transport_Foot, | ||
39 | .allow =Allow_Foot, | ||
40 | amb | 166 | .highway = { |
41 | [Way_Motorway ] = 0, | ||
42 | [Way_Trunk ] = 40, | ||
43 | [Way_Primary ] = 50, | ||
44 | [Way_Secondary ] = 60, | ||
45 | [Way_Tertiary ] = 70, | ||
46 | [Way_Unclassified] = 80, | ||
47 | [Way_Residential ] = 90, | ||
48 | [Way_Service ] = 90, | ||
49 | [Way_Track ] = 95, | ||
50 | amb | 293 | [Way_Cycleway ] = 95, |
51 | amb | 166 | [Way_Path ] = 100, |
52 | amb | 306 | [Way_Steps ] = 80, |
53 | amb | 83 | }, |
54 | .speed = { | ||
55 | amb | 112 | [Way_Motorway ] = 0, |
56 | amb | 138 | [Way_Trunk ] = kph_to_speed(4), |
57 | [Way_Primary ] = kph_to_speed(4), | ||
58 | [Way_Secondary ] = kph_to_speed(4), | ||
59 | [Way_Tertiary ] = kph_to_speed(4), | ||
60 | [Way_Unclassified] = kph_to_speed(4), | ||
61 | [Way_Residential ] = kph_to_speed(4), | ||
62 | [Way_Service ] = kph_to_speed(4), | ||
63 | [Way_Track ] = kph_to_speed(4), | ||
64 | amb | 293 | [Way_Cycleway ] = kph_to_speed(4), |
65 | amb | 148 | [Way_Path ] = kph_to_speed(4), |
66 | amb | 306 | [Way_Steps ] = kph_to_speed(4), |
67 | amb | 83 | }, |
68 | amb | 298 | .props_yes= { |
69 | amb | 313 | [Property_Paved ] = 50, |
70 | amb | 308 | [Property_Multilane] = 25, |
71 | amb | 313 | [Property_Bridge ] = 50, |
72 | [Property_Tunnel ] = 50, | ||
73 | amb | 298 | }, |
74 | amb | 83 | .oneway = 0, |
75 | amb | 138 | .weight = 0, |
76 | .height = 0, | ||
77 | .width = 0, | ||
78 | .length = 0, | ||
79 | amb | 83 | }, |
80 | |||
81 | amb | 294 | /* The profile for travel by Horse */ |
82 | |||
83 | [Transport_Horse] = { | ||
84 | .transport=Transport_Horse, | ||
85 | .allow =Allow_Horse, | ||
86 | .highway = { | ||
87 | [Way_Motorway ] = 0, | ||
88 | [Way_Trunk ] = 25, | ||
89 | [Way_Primary ] = 50, | ||
90 | [Way_Secondary ] = 50, | ||
91 | [Way_Tertiary ] = 75, | ||
92 | [Way_Unclassified] = 75, | ||
93 | [Way_Residential ] = 75, | ||
94 | [Way_Service ] = 75, | ||
95 | [Way_Track ] = 100, | ||
96 | [Way_Cycleway ] = 90, | ||
97 | [Way_Path ] = 100, | ||
98 | amb | 306 | [Way_Steps ] = 0, |
99 | amb | 294 | }, |
100 | .speed = { | ||
101 | [Way_Motorway ] = 0, | ||
102 | amb | 295 | [Way_Trunk ] = kph_to_speed(8), |
103 | amb | 294 | [Way_Primary ] = kph_to_speed(8), |
104 | [Way_Secondary ] = kph_to_speed(8), | ||
105 | [Way_Tertiary ] = kph_to_speed(8), | ||
106 | [Way_Unclassified] = kph_to_speed(8), | ||
107 | [Way_Residential ] = kph_to_speed(8), | ||
108 | [Way_Service ] = kph_to_speed(8), | ||
109 | [Way_Track ] = kph_to_speed(8), | ||
110 | [Way_Cycleway ] = kph_to_speed(8), | ||
111 | [Way_Path ] = kph_to_speed(8), | ||
112 | amb | 306 | [Way_Steps ] = 0, |
113 | amb | 294 | }, |
114 | amb | 298 | .props_yes= { |
115 | amb | 313 | [Property_Paved ] = 20, |
116 | amb | 308 | [Property_Multilane] = 25, |
117 | amb | 313 | [Property_Bridge ] = 50, |
118 | [Property_Tunnel ] = 50, | ||
119 | amb | 298 | }, |
120 | amb | 294 | .oneway = 1, |
121 | .weight = 0, | ||
122 | .height = 0, | ||
123 | .width = 0, | ||
124 | .length = 0, | ||
125 | }, | ||
126 | |||
127 | amb | 314 | /* The profile for travel by Wheelchair */ |
128 | |||
129 | [Transport_Wheelchair] = { | ||
130 | .transport=Transport_Wheelchair, | ||
131 | .allow =Allow_Wheelchair, | ||
132 | .highway = { | ||
133 | [Way_Motorway ] = 0, | ||
134 | [Way_Trunk ] = 40, | ||
135 | [Way_Primary ] = 50, | ||
136 | [Way_Secondary ] = 60, | ||
137 | [Way_Tertiary ] = 70, | ||
138 | [Way_Unclassified] = 80, | ||
139 | [Way_Residential ] = 90, | ||
140 | [Way_Service ] = 90, | ||
141 | [Way_Track ] = 95, | ||
142 | [Way_Cycleway ] = 95, | ||
143 | [Way_Path ] = 100, | ||
144 | [Way_Steps ] = 0, | ||
145 | }, | ||
146 | .speed = { | ||
147 | [Way_Motorway ] = 0, | ||
148 | [Way_Trunk ] = kph_to_speed(4), | ||
149 | [Way_Primary ] = kph_to_speed(4), | ||
150 | [Way_Secondary ] = kph_to_speed(4), | ||
151 | [Way_Tertiary ] = kph_to_speed(4), | ||
152 | [Way_Unclassified] = kph_to_speed(4), | ||
153 | [Way_Residential ] = kph_to_speed(4), | ||
154 | [Way_Service ] = kph_to_speed(4), | ||
155 | [Way_Track ] = kph_to_speed(4), | ||
156 | [Way_Cycleway ] = kph_to_speed(4), | ||
157 | [Way_Path ] = kph_to_speed(4), | ||
158 | [Way_Steps ] = kph_to_speed(4), | ||
159 | }, | ||
160 | .props_yes= { | ||
161 | [Property_Paved ] = 90, | ||
162 | [Property_Multilane] = 25, | ||
163 | [Property_Bridge ] = 50, | ||
164 | [Property_Tunnel ] = 50, | ||
165 | }, | ||
166 | .oneway = 0, | ||
167 | .weight = 0, | ||
168 | .height = 0, | ||
169 | .width = 0, | ||
170 | .length = 0, | ||
171 | }, | ||
172 | |||
173 | amb | 83 | /* The profile for travel by Bicycle */ |
174 | |||
175 | [Transport_Bicycle] = { | ||
176 | .transport=Transport_Bicycle, | ||
177 | .allow =Allow_Bicycle, | ||
178 | amb | 166 | .highway = { |
179 | [Way_Motorway ] = 0, | ||
180 | [Way_Trunk ] = 30, | ||
181 | [Way_Primary ] = 70, | ||
182 | [Way_Secondary ] = 80, | ||
183 | [Way_Tertiary ] = 90, | ||
184 | [Way_Unclassified] = 90, | ||
185 | [Way_Residential ] = 90, | ||
186 | [Way_Service ] = 90, | ||
187 | [Way_Track ] = 90, | ||
188 | amb | 293 | [Way_Cycleway ] = 100, |
189 | amb | 166 | [Way_Path ] = 90, |
190 | amb | 306 | [Way_Steps ] = 0, |
191 | amb | 83 | }, |
192 | .speed = { | ||
193 | amb | 112 | [Way_Motorway ] = 0, |
194 | amb | 295 | [Way_Trunk ] = kph_to_speed(20), |
195 | amb | 138 | [Way_Primary ] = kph_to_speed(20), |
196 | [Way_Secondary ] = kph_to_speed(20), | ||
197 | [Way_Tertiary ] = kph_to_speed(20), | ||
198 | [Way_Unclassified] = kph_to_speed(20), | ||
199 | [Way_Residential ] = kph_to_speed(20), | ||
200 | [Way_Service ] = kph_to_speed(20), | ||
201 | [Way_Track ] = kph_to_speed(20), | ||
202 | amb | 293 | [Way_Cycleway ] = kph_to_speed(20), |
203 | amb | 148 | [Way_Path ] = kph_to_speed(20), |
204 | amb | 306 | [Way_Steps ] = 0, |
205 | amb | 83 | }, |
206 | amb | 298 | .props_yes= { |
207 | amb | 313 | [Property_Paved ] = 50, |
208 | amb | 308 | [Property_Multilane] = 25, |
209 | amb | 313 | [Property_Bridge ] = 50, |
210 | [Property_Tunnel ] = 50, | ||
211 | amb | 298 | }, |
212 | amb | 83 | .oneway = 1, |
213 | amb | 138 | .weight = 0, |
214 | .height = 0, | ||
215 | .width = 0, | ||
216 | .length = 0, | ||
217 | amb | 83 | }, |
218 | |||
219 | amb | 296 | /* The profile for travel by Moped */ |
220 | |||
221 | [Transport_Moped] = { | ||
222 | .transport=Transport_Moped, | ||
223 | .allow =Allow_Moped, | ||
224 | .highway = { | ||
225 | [Way_Motorway ] = 0, | ||
226 | [Way_Trunk ] = 90, | ||
227 | [Way_Primary ] = 100, | ||
228 | [Way_Secondary ] = 90, | ||
229 | [Way_Tertiary ] = 80, | ||
230 | [Way_Unclassified] = 70, | ||
231 | [Way_Residential ] = 60, | ||
232 | [Way_Service ] = 80, | ||
233 | [Way_Track ] = 0, | ||
234 | [Way_Cycleway ] = 0, | ||
235 | [Way_Path ] = 0, | ||
236 | amb | 306 | [Way_Steps ] = 0, |
237 | amb | 296 | }, |
238 | .speed = { | ||
239 | [Way_Motorway ] = kph_to_speed(30*1.6), | ||
240 | [Way_Trunk ] = kph_to_speed(30*1.6), | ||
241 | [Way_Primary ] = kph_to_speed(30*1.6), | ||
242 | [Way_Secondary ] = kph_to_speed(30*1.6), | ||
243 | [Way_Tertiary ] = kph_to_speed(30*1.6), | ||
244 | [Way_Unclassified] = kph_to_speed(30*1.6), | ||
245 | [Way_Residential ] = kph_to_speed(30*1.6), | ||
246 | [Way_Service ] = kph_to_speed(20*1.6), | ||
247 | [Way_Track ] = kph_to_speed(10*1.6), | ||
248 | [Way_Cycleway ] = 0, | ||
249 | [Way_Path ] = 0, | ||
250 | amb | 306 | [Way_Steps ] = 0, |
251 | amb | 296 | }, |
252 | amb | 298 | .props_yes= { |
253 | amb | 313 | [Property_Paved ] = 100, |
254 | amb | 308 | [Property_Multilane] = 25, |
255 | amb | 313 | [Property_Bridge ] = 50, |
256 | [Property_Tunnel ] = 50, | ||
257 | amb | 298 | }, |
258 | amb | 296 | .oneway = 1, |
259 | .weight = 0, | ||
260 | .height = 0, | ||
261 | .width = 0, | ||
262 | .length = 0, | ||
263 | }, | ||
264 | |||
265 | amb | 83 | /* The profile for travel by Motorbike */ |
266 | |||
267 | [Transport_Motorbike] = { | ||
268 | .transport=Transport_Motorbike, | ||
269 | .allow =Allow_Motorbike, | ||
270 | amb | 166 | .highway = { |
271 | [Way_Motorway ] = 100, | ||
272 | [Way_Trunk ] = 100, | ||
273 | [Way_Primary ] = 90, | ||
274 | [Way_Secondary ] = 80, | ||
275 | [Way_Tertiary ] = 70, | ||
276 | [Way_Unclassified] = 60, | ||
277 | [Way_Residential ] = 50, | ||
278 | [Way_Service ] = 80, | ||
279 | [Way_Track ] = 0, | ||
280 | amb | 293 | [Way_Cycleway ] = 0, |
281 | amb | 166 | [Way_Path ] = 0, |
282 | amb | 306 | [Way_Steps ] = 0, |
283 | amb | 83 | }, |
284 | .speed = { | ||
285 | amb | 138 | [Way_Motorway ] = kph_to_speed(70*1.6), |
286 | [Way_Trunk ] = kph_to_speed(60*1.6), | ||
287 | [Way_Primary ] = kph_to_speed(60*1.6), | ||
288 | [Way_Secondary ] = kph_to_speed(55*1.6), | ||
289 | [Way_Tertiary ] = kph_to_speed(50*1.6), | ||
290 | [Way_Unclassified] = kph_to_speed(40*1.6), | ||
291 | [Way_Residential ] = kph_to_speed(30*1.6), | ||
292 | [Way_Service ] = kph_to_speed(20*1.6), | ||
293 | amb | 178 | [Way_Track ] = kph_to_speed(10*1.6), |
294 | amb | 293 | [Way_Cycleway ] = 0, |
295 | amb | 148 | [Way_Path ] = 0, |
296 | amb | 306 | [Way_Steps ] = 0, |
297 | amb | 83 | }, |
298 | amb | 298 | .props_yes= { |
299 | amb | 313 | [Property_Paved ] = 100, |
300 | amb | 308 | [Property_Multilane] = 75, |
301 | amb | 313 | [Property_Bridge ] = 50, |
302 | [Property_Tunnel ] = 50, | ||
303 | amb | 298 | }, |
304 | amb | 83 | .oneway = 1, |
305 | amb | 138 | .weight = 0, |
306 | .height = 0, | ||
307 | .width = 0, | ||
308 | .length = 0, | ||
309 | amb | 83 | }, |
310 | |||
311 | /* The profile for travel by Motorcar */ | ||
312 | |||
313 | [Transport_Motorcar] = { | ||
314 | .transport=Transport_Motorcar, | ||
315 | .allow =Allow_Motorcar, | ||
316 | amb | 166 | .highway = { |
317 | [Way_Motorway ] = 100, | ||
318 | [Way_Trunk ] = 100, | ||
319 | [Way_Primary ] = 90, | ||
320 | [Way_Secondary ] = 80, | ||
321 | [Way_Tertiary ] = 70, | ||
322 | [Way_Unclassified] = 60, | ||
323 | [Way_Residential ] = 50, | ||
324 | [Way_Service ] = 80, | ||
325 | [Way_Track ] = 0, | ||
326 | amb | 293 | [Way_Cycleway ] = 0, |
327 | amb | 166 | [Way_Path ] = 0, |
328 | amb | 306 | [Way_Steps ] = 0, |
329 | amb | 83 | }, |
330 | .speed = { | ||
331 | amb | 138 | [Way_Motorway ] = kph_to_speed(70*1.6), |
332 | [Way_Trunk ] = kph_to_speed(60*1.6), | ||
333 | [Way_Primary ] = kph_to_speed(60*1.6), | ||
334 | [Way_Secondary ] = kph_to_speed(55*1.6), | ||
335 | [Way_Tertiary ] = kph_to_speed(50*1.6), | ||
336 | [Way_Unclassified] = kph_to_speed(40*1.6), | ||
337 | [Way_Residential ] = kph_to_speed(30*1.6), | ||
338 | [Way_Service ] = kph_to_speed(20*1.6), | ||
339 | amb | 178 | [Way_Track ] = kph_to_speed(10*1.6), |
340 | amb | 293 | [Way_Cycleway ] = 0, |
341 | amb | 148 | [Way_Path ] = 0, |
342 | amb | 306 | [Way_Steps ] = 0, |
343 | amb | 83 | }, |
344 | amb | 298 | .props_yes= { |
345 | amb | 313 | [Property_Paved ] = 100, |
346 | amb | 308 | [Property_Multilane] = 75, |
347 | amb | 313 | [Property_Bridge ] = 50, |
348 | [Property_Tunnel ] = 50, | ||
349 | amb | 298 | }, |
350 | amb | 83 | .oneway = 1, |
351 | amb | 138 | .weight = 0, |
352 | .height = 0, | ||
353 | .width = 0, | ||
354 | .length = 0, | ||
355 | amb | 83 | }, |
356 | |||
357 | /* The profile for travel by Goods */ | ||
358 | |||
359 | [Transport_Goods] = { | ||
360 | .transport=Transport_Goods, | ||
361 | .allow =Allow_Goods, | ||
362 | amb | 166 | .highway = { |
363 | [Way_Motorway ] = 100, | ||
364 | [Way_Trunk ] = 100, | ||
365 | [Way_Primary ] = 90, | ||
366 | [Way_Secondary ] = 80, | ||
367 | [Way_Tertiary ] = 70, | ||
368 | [Way_Unclassified] = 60, | ||
369 | [Way_Residential ] = 50, | ||
370 | [Way_Service ] = 80, | ||
371 | [Way_Track ] = 0, | ||
372 | amb | 293 | [Way_Cycleway ] = 0, |
373 | amb | 166 | [Way_Path ] = 0, |
374 | amb | 306 | [Way_Steps ] = 0, |
375 | amb | 83 | }, |
376 | .speed = { | ||
377 | amb | 138 | [Way_Motorway ] = kph_to_speed(60*1.6), |
378 | [Way_Trunk ] = kph_to_speed(60*1.6), | ||
379 | [Way_Primary ] = kph_to_speed(60*1.6), | ||
380 | [Way_Secondary ] = kph_to_speed(55*1.6), | ||
381 | [Way_Tertiary ] = kph_to_speed(50*1.6), | ||
382 | [Way_Unclassified] = kph_to_speed(40*1.6), | ||
383 | [Way_Residential ] = kph_to_speed(30*1.6), | ||
384 | [Way_Service ] = kph_to_speed(20*1.6), | ||
385 | amb | 178 | [Way_Track ] = kph_to_speed(10*1.6), |
386 | amb | 293 | [Way_Cycleway ] = 0, |
387 | amb | 148 | [Way_Path ] = 0, |
388 | amb | 306 | [Way_Steps ] = 0, |
389 | amb | 83 | }, |
390 | amb | 298 | .props_yes= { |
391 | amb | 313 | [Property_Paved ] = 100, |
392 | amb | 308 | [Property_Multilane] = 75, |
393 | amb | 313 | [Property_Bridge ] = 50, |
394 | [Property_Tunnel ] = 50, | ||
395 | amb | 298 | }, |
396 | amb | 83 | .oneway = 1, |
397 | amb | 138 | .weight = tonnes_to_weight(5), |
398 | .height = metres_to_height(2.5), | ||
399 | .width = metres_to_width (2), | ||
400 | .length = metres_to_length(5), | ||
401 | amb | 83 | }, |
402 | |||
403 | /* The profile for travel by HGV */ | ||
404 | |||
405 | [Transport_HGV] = { | ||
406 | .transport=Transport_HGV, | ||
407 | .allow =Allow_HGV, | ||
408 | amb | 166 | .highway = { |
409 | [Way_Motorway ] = 100, | ||
410 | [Way_Trunk ] = 100, | ||
411 | [Way_Primary ] = 90, | ||
412 | [Way_Secondary ] = 80, | ||
413 | [Way_Tertiary ] = 70, | ||
414 | [Way_Unclassified] = 60, | ||
415 | [Way_Residential ] = 50, | ||
416 | [Way_Service ] = 80, | ||
417 | [Way_Track ] = 0, | ||
418 | amb | 293 | [Way_Cycleway ] = 0, |
419 | amb | 166 | [Way_Path ] = 0, |
420 | amb | 306 | [Way_Steps ] = 0, |
421 | amb | 83 | }, |
422 | .speed = { | ||
423 | amb | 138 | [Way_Motorway ] = kph_to_speed(56*1.6), |
424 | [Way_Trunk ] = kph_to_speed(50*1.6), | ||
425 | [Way_Primary ] = kph_to_speed(50*1.6), | ||
426 | [Way_Secondary ] = kph_to_speed(50*1.6), | ||
427 | [Way_Tertiary ] = kph_to_speed(50*1.6), | ||
428 | [Way_Unclassified] = kph_to_speed(40*1.6), | ||
429 | [Way_Residential ] = kph_to_speed(30*1.6), | ||
430 | [Way_Service ] = kph_to_speed(20*1.6), | ||
431 | amb | 178 | [Way_Track ] = kph_to_speed(10*1.6), |
432 | amb | 293 | [Way_Cycleway ] = 0, |
433 | amb | 148 | [Way_Path ] = 0, |
434 | amb | 306 | [Way_Steps ] = 0, |
435 | amb | 83 | }, |
436 | amb | 298 | .props_yes= { |
437 | amb | 313 | [Property_Paved ] = 100, |
438 | amb | 308 | [Property_Multilane] = 75, |
439 | amb | 313 | [Property_Bridge ] = 50, |
440 | [Property_Tunnel ] = 50, | ||
441 | amb | 298 | }, |
442 | amb | 83 | .oneway = 1, |
443 | amb | 138 | .weight = tonnes_to_weight(10), |
444 | .height = metres_to_height(3), | ||
445 | .width = metres_to_width (2.5), | ||
446 | .length = metres_to_length(6), | ||
447 | amb | 83 | }, |
448 | |||
449 | /* The profile for travel by PSV */ | ||
450 | |||
451 | [Transport_PSV] = { | ||
452 | .transport=Transport_PSV, | ||
453 | .allow =Allow_PSV, | ||
454 | amb | 166 | .highway = { |
455 | [Way_Motorway ] = 100, | ||
456 | [Way_Trunk ] = 100, | ||
457 | [Way_Primary ] = 90, | ||
458 | [Way_Secondary ] = 80, | ||
459 | [Way_Tertiary ] = 70, | ||
460 | [Way_Unclassified] = 60, | ||
461 | [Way_Residential ] = 50, | ||
462 | [Way_Service ] = 80, | ||
463 | [Way_Track ] = 0, | ||
464 | amb | 293 | [Way_Cycleway ] = 0, |
465 | amb | 166 | [Way_Path ] = 0, |
466 | amb | 306 | [Way_Steps ] = 0, |
467 | amb | 83 | }, |
468 | .speed = { | ||
469 | amb | 138 | [Way_Motorway ] = kph_to_speed(56*1.6), |
470 | [Way_Trunk ] = kph_to_speed(50*1.6), | ||
471 | [Way_Primary ] = kph_to_speed(50*1.6), | ||
472 | [Way_Secondary ] = kph_to_speed(50*1.6), | ||
473 | [Way_Tertiary ] = kph_to_speed(50*1.6), | ||
474 | [Way_Unclassified] = kph_to_speed(40*1.6), | ||
475 | [Way_Residential ] = kph_to_speed(30*1.6), | ||
476 | [Way_Service ] = kph_to_speed(20*1.6), | ||
477 | amb | 178 | [Way_Track ] = kph_to_speed(10*1.6), |
478 | amb | 293 | [Way_Cycleway ] = 0, |
479 | amb | 148 | [Way_Path ] = 0, |
480 | amb | 306 | [Way_Steps ] = 0, |
481 | amb | 83 | }, |
482 | amb | 298 | .props_yes= { |
483 | amb | 313 | [Property_Paved ] = 100, |
484 | amb | 308 | [Property_Multilane] = 75, |
485 | amb | 313 | [Property_Bridge ] = 50, |
486 | [Property_Tunnel ] = 50, | ||
487 | amb | 298 | }, |
488 | amb | 83 | .oneway = 1, |
489 | amb | 138 | .weight = tonnes_to_weight(15), |
490 | .height = metres_to_height(3), | ||
491 | .width = metres_to_width (2.5), | ||
492 | .length = metres_to_length(6), | ||
493 | amb | 83 | }, |
494 | }; | ||
495 | |||
496 | |||
497 | /*++++++++++++++++++++++++++++++++++++++ | ||
498 | Get the profile for a type of transport. | ||
499 | |||
500 | Profile *GetProfile Returns a pointer to the profile. | ||
501 | |||
502 | Transport transport The type of transport. | ||
503 | ++++++++++++++++++++++++++++++++++++++*/ | ||
504 | |||
505 | Profile *GetProfile(Transport transport) | ||
506 | { | ||
507 | return(&builtin_profiles[transport]); | ||
508 | } | ||
509 | |||
510 | |||
511 | /*++++++++++++++++++++++++++++++++++++++ | ||
512 | amb | 166 | Update a profile with highway preference scaling factor. |
513 | |||
514 | Profile *profile The profile to be updated. | ||
515 | ++++++++++++++++++++++++++++++++++++++*/ | ||
516 | |||
517 | void UpdateProfile(Profile *profile) | ||
518 | { | ||
519 | amb | 168 | score_t hmax=0; |
520 | amb | 166 | int i; |
521 | |||
522 | amb | 173 | /* Normalise the highway preferences into the range 0 -> 1 */ |
523 | |||
524 | amb | 300 | for(i=1;i<Way_Count;i++) |
525 | amb | 298 | { |
526 | if(profile->highway[i]<0) | ||
527 | profile->highway[i]=0; | ||
528 | |||
529 | amb | 166 | if(profile->highway[i]>hmax) |
530 | hmax=profile->highway[i]; | ||
531 | amb | 298 | } |
532 | amb | 166 | |
533 | amb | 300 | for(i=1;i<Way_Count;i++) |
534 | amb | 298 | profile->highway[i]/=hmax; |
535 | amb | 173 | |
536 | amb | 298 | /* Normalise the attribute preferences into the range 0 -> 1 */ |
537 | |||
538 | for(i=1;i<Property_Count;i++) | ||
539 | { | ||
540 | if(profile->props_yes[i]<0) | ||
541 | profile->props_yes[i]=0; | ||
542 | |||
543 | if(profile->props_yes[i]>100) | ||
544 | profile->props_yes[i]=100; | ||
545 | |||
546 | profile->props_yes[i]/=100; | ||
547 | profile->props_no [i] =1-profile->props_yes[i]; | ||
548 | } | ||
549 | |||
550 | amb | 173 | /* Find the fastest and most preferred highway type */ |
551 | |||
552 | profile->max_speed=0; | ||
553 | |||
554 | amb | 300 | for(i=1;i<Way_Count;i++) |
555 | amb | 173 | if(profile->speed[i]>profile->max_speed) |
556 | profile->max_speed=profile->speed[i]; | ||
557 | |||
558 | amb | 298 | profile->max_pref=1; /* since highway prefs were normalised to 1 */ |
559 | amb | 173 | |
560 | amb | 298 | for(i=1;i<Property_Count;i++) |
561 | if(profile->props_yes[i]>profile->props_no[i]) | ||
562 | profile->max_pref*=profile->props_yes[i]; | ||
563 | else if(profile->props_no[i]>profile->props_yes[i]) | ||
564 | profile->max_pref*=profile->props_no[i]; | ||
565 | amb | 166 | } |
566 | |||
567 | |||
568 | /*++++++++++++++++++++++++++++++++++++++ | ||
569 | amb | 83 | Print out a profile. |
570 | |||
571 | const Profile *profile The profile to print. | ||
572 | ++++++++++++++++++++++++++++++++++++++*/ | ||
573 | |||
574 | void PrintProfile(const Profile *profile) | ||
575 | { | ||
576 | amb | 214 | unsigned int i; |
577 | amb | 83 | |
578 | printf("Profile\n=======\n"); | ||
579 | |||
580 | printf("\n"); | ||
581 | |||
582 | printf("Transport: %s\n",TransportName(profile->transport)); | ||
583 | |||
584 | printf("\n"); | ||
585 | |||
586 | amb | 300 | for(i=1;i<Way_Count;i++) |
587 | amb | 166 | printf("Highway %-12s: %3d%%\n",HighwayName(i),(int)profile->highway[i]); |
588 | amb | 83 | |
589 | printf("\n"); | ||
590 | |||
591 | amb | 300 | for(i=1;i<Way_Count;i++) |
592 | amb | 166 | if(profile->highway[i]) |
593 | amb | 85 | printf("Speed on %-12s: %3d km/h / %2.0f mph\n",HighwayName(i),profile->speed[i],(double)profile->speed[i]/1.6); |
594 | amb | 83 | |
595 | printf("\n"); | ||
596 | |||
597 | amb | 298 | for(i=1;i<Property_Count;i++) |
598 | printf("Highway property %-12s: %3d%%\n",PropertyName(i),(int)profile->props_yes[i]); | ||
599 | |||
600 | printf("\n"); | ||
601 | |||
602 | amb | 138 | printf("Obey one-way : %s\n",profile->oneway?"yes":"no"); |
603 | printf("Minimum weight: %.1f tonnes\n",weight_to_tonnes(profile->weight)); | ||
604 | printf("Minimum height: %.1f metres\n",height_to_metres(profile->height)); | ||
605 | printf("Minimum width : %.1f metres\n",width_to_metres(profile->width)); | ||
606 | printf("Minimum length: %.1f metres\n",length_to_metres(profile->length)); | ||
607 | amb | 83 | } |
608 | amb | 129 | |
609 | |||
610 | /*++++++++++++++++++++++++++++++++++++++ | ||
611 | Print out the profiles as Javascript for use in a web form. | ||
612 | ++++++++++++++++++++++++++++++++++++++*/ | ||
613 | |||
614 | void PrintProfilesJS(void) | ||
615 | { | ||
616 | amb | 214 | unsigned int i,j; |
617 | amb | 129 | |
618 | printf("// Transport types\n"); | ||
619 | amb | 163 | printf("var router_transports={"); |
620 | amb | 129 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
621 | amb | 292 | printf("%s%s: %d",j==1?"":", ",TransportName(j),j); |
622 | amb | 129 | printf("};\n"); |
623 | printf("\n"); | ||
624 | |||
625 | printf("// Highway types\n"); | ||
626 | amb | 163 | printf("var router_highways={"); |
627 | amb | 300 | for(i=1;i<Way_Count;i++) |
628 | amb | 292 | printf("%s%s: %d",i==1?"":", ",HighwayName(i),i); |
629 | amb | 129 | printf("};\n"); |
630 | printf("\n"); | ||
631 | |||
632 | amb | 298 | printf("// Property types\n"); |
633 | printf("var router_properties={"); | ||
634 | for(i=1;i<Property_Count;i++) | ||
635 | printf("%s%s: %d",i==1?"":", ",PropertyName(i),i); | ||
636 | printf("};\n"); | ||
637 | printf("\n"); | ||
638 | |||
639 | amb | 138 | printf("// Restriction types\n"); |
640 | amb | 163 | printf("var router_restrictions={oneway: 1, weight: 2, height: 3, width: 4, length: 5};\n"); |
641 | amb | 138 | printf("\n"); |
642 | |||
643 | amb | 129 | printf("// Allowed highways\n"); |
644 | amb | 163 | printf("var router_profile_highway={\n"); |
645 | amb | 300 | for(i=1;i<Way_Count;i++) |
646 | amb | 129 | { |
647 | amb | 148 | printf(" %12s: {",HighwayName(i)); |
648 | amb | 129 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
649 | amb | 166 | printf("%s%s: %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].highway[i]); |
650 | amb | 300 | printf("}%s\n",i==(Way_Count-1)?"":","); |
651 | amb | 129 | } |
652 | printf(" };\n"); | ||
653 | printf("\n"); | ||
654 | |||
655 | printf("// Speed limits\n"); | ||
656 | amb | 163 | printf("var router_profile_speed={\n"); |
657 | amb | 300 | for(i=1;i<Way_Count;i++) |
658 | amb | 129 | { |
659 | amb | 148 | printf(" %12s: {",HighwayName(i)); |
660 | amb | 129 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
661 | amb | 163 | printf("%s%s: %3d",j==1?"":", ",TransportName(j),builtin_profiles[j].speed[i]); |
662 | amb | 300 | printf("}%s\n",i==(Way_Count-1)?"":","); |
663 | amb | 129 | } |
664 | printf(" };\n"); | ||
665 | printf("\n"); | ||
666 | |||
667 | amb | 298 | printf("// Highway properties\n"); |
668 | printf("var router_profile_property={\n"); | ||
669 | for(i=1;i<Property_Count;i++) | ||
670 | { | ||
671 | printf(" %12s: {",PropertyName(i)); | ||
672 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) | ||
673 | printf("%s%s: %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].props_yes[i]); | ||
674 | printf("}%s\n",i==(Property_Count-1)?"":","); | ||
675 | } | ||
676 | printf(" };\n"); | ||
677 | printf("\n"); | ||
678 | |||
679 | amb | 138 | printf("// Restrictions\n"); |
680 | amb | 163 | printf("var router_profile_restrictions={\n"); |
681 | printf(" %12s: {","oneway"); | ||
682 | amb | 129 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
683 | amb | 163 | printf("%s%s: %4d",j==1?"":", ",TransportName(j),builtin_profiles[j].oneway); |
684 | amb | 138 | printf("},\n"); |
685 | amb | 148 | printf(" %12s: {","weight"); |
686 | amb | 138 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
687 | amb | 163 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),weight_to_tonnes(builtin_profiles[j].weight)); |
688 | amb | 138 | printf("},\n"); |
689 | amb | 148 | printf(" %12s: {","height"); |
690 | amb | 138 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
691 | amb | 163 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),height_to_metres(builtin_profiles[j].height)); |
692 | amb | 138 | printf("},\n"); |
693 | amb | 148 | printf(" %12s: {","width"); |
694 | amb | 138 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
695 | amb | 163 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),width_to_metres(builtin_profiles[j].width)); |
696 | amb | 138 | printf("},\n"); |
697 | amb | 148 | printf(" %12s: {","length"); |
698 | amb | 138 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
699 | amb | 163 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),length_to_metres(builtin_profiles[j].length)); |
700 | amb | 138 | printf("}\n"); |
701 | amb | 163 | printf(" };\n"); |
702 | amb | 129 | printf("\n"); |
703 | } | ||
704 | amb | 145 | |
705 | |||
706 | /*++++++++++++++++++++++++++++++++++++++ | ||
707 | Print out the profiles as Perl for use in a web CGI. | ||
708 | ++++++++++++++++++++++++++++++++++++++*/ | ||
709 | |||
710 | void PrintProfilesPerl(void) | ||
711 | { | ||
712 | amb | 214 | unsigned int i,j; |
713 | amb | 145 | |
714 | printf("# Transport types\n"); | ||
715 | printf("@router_transports=("); | ||
716 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) | ||
717 | printf("%s'%s'",j==1?"":", ",TransportName(j)); | ||
718 | printf(");\n"); | ||
719 | printf("\n"); | ||
720 | |||
721 | printf("# Highway types\n"); | ||
722 | printf("@router_highways=("); | ||
723 | amb | 300 | for(i=1;i<Way_Count;i++) |
724 | amb | 145 | printf("%s'%s'",i==1?"":", ",HighwayName(i)); |
725 | printf(");\n"); | ||
726 | printf("\n"); | ||
727 | |||
728 | amb | 298 | printf("# Property types\n"); |
729 | printf("@router_properties=("); | ||
730 | for(i=1;i<Property_Count;i++) | ||
731 | printf("%s'%s'",i==1?"":", ",PropertyName(i)); | ||
732 | printf(");\n"); | ||
733 | printf("\n"); | ||
734 | |||
735 | amb | 145 | printf("# Restriction types\n"); |
736 | printf("@router_restrictions=('oneway', 'weight', 'height', 'width', 'length');\n"); | ||
737 | printf("\n"); | ||
738 | |||
739 | printf("# Allowed highways\n"); | ||
740 | printf("%%router_profile_highway=(\n"); | ||
741 | amb | 300 | for(i=1;i<Way_Count;i++) |
742 | amb | 145 | { |
743 | amb | 148 | printf(" %12s => {",HighwayName(i)); |
744 | amb | 145 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
745 | amb | 166 | printf("%s %s => %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].highway[i]); |
746 | amb | 300 | printf("}%s\n",i==(Way_Count-1)?"":","); |
747 | amb | 145 | } |
748 | printf(" );\n"); | ||
749 | printf("\n"); | ||
750 | |||
751 | printf("# Speed limits\n"); | ||
752 | printf("%%router_profile_speed=(\n"); | ||
753 | amb | 300 | for(i=1;i<Way_Count;i++) |
754 | amb | 145 | { |
755 | amb | 148 | printf(" %12s => {",HighwayName(i)); |
756 | amb | 145 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
757 | amb | 163 | printf("%s %s => %3d",j==1?"":", ",TransportName(j),builtin_profiles[j].speed[i]); |
758 | amb | 300 | printf("}%s\n",i==(Way_Count-1)?"":","); |
759 | amb | 145 | } |
760 | printf(" );\n"); | ||
761 | printf("\n"); | ||
762 | |||
763 | amb | 298 | printf("# Highway properties\n"); |
764 | printf("%%router_profile_property=(\n"); | ||
765 | for(i=1;i<Property_Count;i++) | ||
766 | { | ||
767 | printf(" %12s => {",PropertyName(i)); | ||
768 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) | ||
769 | printf("%s %s => %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].props_yes[i]); | ||
770 | printf("}%s\n",i==(Property_Count-1)?"":","); | ||
771 | } | ||
772 | printf(" );\n"); | ||
773 | printf("\n"); | ||
774 | |||
775 | amb | 145 | printf("# Restrictions\n"); |
776 | printf("%%router_profile_restrictions=(\n"); | ||
777 | amb | 163 | printf(" %12s => {","oneway"); |
778 | amb | 145 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
779 | amb | 163 | printf("%s %s => %4d",j==1?"":", ",TransportName(j),builtin_profiles[j].oneway); |
780 | amb | 145 | printf("},\n"); |
781 | amb | 148 | printf(" %12s => {","weight"); |
782 | amb | 145 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
783 | amb | 163 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),weight_to_tonnes(builtin_profiles[j].weight)); |
784 | amb | 145 | printf("},\n"); |
785 | amb | 148 | printf(" %12s => {","height"); |
786 | amb | 145 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
787 | amb | 163 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),height_to_metres(builtin_profiles[j].height)); |
788 | amb | 145 | printf("},\n"); |
789 | amb | 148 | printf(" %12s => {","width"); |
790 | amb | 145 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
791 | amb | 163 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),width_to_metres(builtin_profiles[j].width)); |
792 | amb | 145 | printf("},\n"); |
793 | amb | 148 | printf(" %12s => {","length"); |
794 | amb | 145 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
795 | amb | 163 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),length_to_metres(builtin_profiles[j].length)); |
796 | amb | 145 | printf("}\n"); |
797 | amb | 163 | printf(" );\n"); |
798 | amb | 145 | printf("\n"); |
799 | } |
Properties
Name | Value |
---|---|
cvs:description | Definition of built-in profiles and other functions. |