Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/profiles.c
Parent Directory
|
Revision Log
Revision 292 -
(show annotations)
(download)
(as text)
Mon Oct 26 18:37:39 2009 UTC (15 years, 5 months ago) by amb
File MIME type: text/x-csrc
File size: 27090 byte(s)
Mon Oct 26 18:37:39 2009 UTC (15 years, 5 months ago) by amb
File MIME type: text/x-csrc
File size: 27090 byte(s)
Remove unneeded spaces at the end of the output.
1 | /*************************************** |
2 | $Header: /home/amb/CVS/routino/src/profiles.c,v 1.19 2009-10-26 18:37:39 amb Exp $ |
3 | |
4 | The pre-defined profiles and the functions for handling them. |
5 | |
6 | Part of the Routino routing software. |
7 | ******************/ /****************** |
8 | This file Copyright 2008,2009 Andrew M. Bishop |
9 | |
10 | 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 | ***************************************/ |
23 | |
24 | |
25 | #include <stdio.h> |
26 | |
27 | #include "profiles.h" |
28 | #include "types.h" |
29 | #include "ways.h" |
30 | |
31 | |
32 | /*+ The set of built-in profiles for different transport types. +*/ |
33 | 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 | .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 | [Way_Path ] = 100, |
51 | [Way_Bridleway ] = 100, |
52 | [Way_Cycleway ] = 95, |
53 | [Way_Footway ] = 100, |
54 | }, |
55 | .speed = { |
56 | [Way_Motorway ] = 0, |
57 | [Way_Trunk ] = kph_to_speed(4), |
58 | [Way_Primary ] = kph_to_speed(4), |
59 | [Way_Secondary ] = kph_to_speed(4), |
60 | [Way_Tertiary ] = kph_to_speed(4), |
61 | [Way_Unclassified] = kph_to_speed(4), |
62 | [Way_Residential ] = kph_to_speed(4), |
63 | [Way_Service ] = kph_to_speed(4), |
64 | [Way_Track ] = kph_to_speed(4), |
65 | [Way_Path ] = kph_to_speed(4), |
66 | [Way_Bridleway ] = kph_to_speed(4), |
67 | [Way_Cycleway ] = kph_to_speed(4), |
68 | [Way_Footway ] = kph_to_speed(4), |
69 | }, |
70 | .oneway = 0, |
71 | .weight = 0, |
72 | .height = 0, |
73 | .width = 0, |
74 | .length = 0, |
75 | }, |
76 | |
77 | /* The profile for travel by Bicycle */ |
78 | |
79 | [Transport_Bicycle] = { |
80 | .transport=Transport_Bicycle, |
81 | .allow =Allow_Bicycle, |
82 | .highway = { |
83 | [Way_Motorway ] = 0, |
84 | [Way_Trunk ] = 30, |
85 | [Way_Primary ] = 70, |
86 | [Way_Secondary ] = 80, |
87 | [Way_Tertiary ] = 90, |
88 | [Way_Unclassified] = 90, |
89 | [Way_Residential ] = 90, |
90 | [Way_Service ] = 90, |
91 | [Way_Track ] = 90, |
92 | [Way_Path ] = 90, |
93 | [Way_Bridleway ] = 90, |
94 | [Way_Cycleway ] = 100, |
95 | [Way_Footway ] = 90, |
96 | }, |
97 | .speed = { |
98 | [Way_Motorway ] = 0, |
99 | [Way_Trunk ] = 0, |
100 | [Way_Primary ] = kph_to_speed(20), |
101 | [Way_Secondary ] = kph_to_speed(20), |
102 | [Way_Tertiary ] = kph_to_speed(20), |
103 | [Way_Unclassified] = kph_to_speed(20), |
104 | [Way_Residential ] = kph_to_speed(20), |
105 | [Way_Service ] = kph_to_speed(20), |
106 | [Way_Track ] = kph_to_speed(20), |
107 | [Way_Path ] = kph_to_speed(20), |
108 | [Way_Bridleway ] = kph_to_speed(20), |
109 | [Way_Cycleway ] = kph_to_speed(20), |
110 | [Way_Footway ] = kph_to_speed(20), |
111 | }, |
112 | .oneway = 1, |
113 | .weight = 0, |
114 | .height = 0, |
115 | .width = 0, |
116 | .length = 0, |
117 | }, |
118 | |
119 | /* The profile for travel by Horse */ |
120 | |
121 | [Transport_Horse] = { |
122 | .transport=Transport_Horse, |
123 | .allow =Allow_Horse, |
124 | .highway = { |
125 | [Way_Motorway ] = 0, |
126 | [Way_Trunk ] = 25, |
127 | [Way_Primary ] = 50, |
128 | [Way_Secondary ] = 50, |
129 | [Way_Tertiary ] = 75, |
130 | [Way_Unclassified] = 75, |
131 | [Way_Residential ] = 75, |
132 | [Way_Service ] = 75, |
133 | [Way_Track ] = 100, |
134 | [Way_Path ] = 100, |
135 | [Way_Bridleway ] = 100, |
136 | [Way_Cycleway ] = 90, |
137 | [Way_Footway ] = 90, |
138 | }, |
139 | .speed = { |
140 | [Way_Motorway ] = 0, |
141 | [Way_Trunk ] = 0, |
142 | [Way_Primary ] = kph_to_speed(8), |
143 | [Way_Secondary ] = kph_to_speed(8), |
144 | [Way_Tertiary ] = kph_to_speed(8), |
145 | [Way_Unclassified] = kph_to_speed(8), |
146 | [Way_Residential ] = kph_to_speed(8), |
147 | [Way_Service ] = kph_to_speed(8), |
148 | [Way_Track ] = kph_to_speed(8), |
149 | [Way_Path ] = kph_to_speed(8), |
150 | [Way_Bridleway ] = kph_to_speed(8), |
151 | [Way_Cycleway ] = kph_to_speed(8), |
152 | [Way_Footway ] = kph_to_speed(8), |
153 | }, |
154 | .oneway = 1, |
155 | .weight = 0, |
156 | .height = 0, |
157 | .width = 0, |
158 | .length = 0, |
159 | }, |
160 | |
161 | /* The profile for travel by Motorbike */ |
162 | |
163 | [Transport_Motorbike] = { |
164 | .transport=Transport_Motorbike, |
165 | .allow =Allow_Motorbike, |
166 | .highway = { |
167 | [Way_Motorway ] = 100, |
168 | [Way_Trunk ] = 100, |
169 | [Way_Primary ] = 90, |
170 | [Way_Secondary ] = 80, |
171 | [Way_Tertiary ] = 70, |
172 | [Way_Unclassified] = 60, |
173 | [Way_Residential ] = 50, |
174 | [Way_Service ] = 80, |
175 | [Way_Track ] = 0, |
176 | [Way_Path ] = 0, |
177 | [Way_Bridleway ] = 0, |
178 | [Way_Cycleway ] = 0, |
179 | [Way_Footway ] = 0, |
180 | }, |
181 | .speed = { |
182 | [Way_Motorway ] = kph_to_speed(70*1.6), |
183 | [Way_Trunk ] = kph_to_speed(60*1.6), |
184 | [Way_Primary ] = kph_to_speed(60*1.6), |
185 | [Way_Secondary ] = kph_to_speed(55*1.6), |
186 | [Way_Tertiary ] = kph_to_speed(50*1.6), |
187 | [Way_Unclassified] = kph_to_speed(40*1.6), |
188 | [Way_Residential ] = kph_to_speed(30*1.6), |
189 | [Way_Service ] = kph_to_speed(20*1.6), |
190 | [Way_Track ] = kph_to_speed(10*1.6), |
191 | [Way_Path ] = 0, |
192 | [Way_Bridleway ] = 0, |
193 | [Way_Cycleway ] = 0, |
194 | [Way_Footway ] = 0, |
195 | }, |
196 | .oneway = 1, |
197 | .weight = 0, |
198 | .height = 0, |
199 | .width = 0, |
200 | .length = 0, |
201 | }, |
202 | |
203 | /* The profile for travel by Motorcar */ |
204 | |
205 | [Transport_Motorcar] = { |
206 | .transport=Transport_Motorcar, |
207 | .allow =Allow_Motorcar, |
208 | .highway = { |
209 | [Way_Motorway ] = 100, |
210 | [Way_Trunk ] = 100, |
211 | [Way_Primary ] = 90, |
212 | [Way_Secondary ] = 80, |
213 | [Way_Tertiary ] = 70, |
214 | [Way_Unclassified] = 60, |
215 | [Way_Residential ] = 50, |
216 | [Way_Service ] = 80, |
217 | [Way_Track ] = 0, |
218 | [Way_Path ] = 0, |
219 | [Way_Bridleway ] = 0, |
220 | [Way_Cycleway ] = 0, |
221 | [Way_Footway ] = 0, |
222 | }, |
223 | .speed = { |
224 | [Way_Motorway ] = kph_to_speed(70*1.6), |
225 | [Way_Trunk ] = kph_to_speed(60*1.6), |
226 | [Way_Primary ] = kph_to_speed(60*1.6), |
227 | [Way_Secondary ] = kph_to_speed(55*1.6), |
228 | [Way_Tertiary ] = kph_to_speed(50*1.6), |
229 | [Way_Unclassified] = kph_to_speed(40*1.6), |
230 | [Way_Residential ] = kph_to_speed(30*1.6), |
231 | [Way_Service ] = kph_to_speed(20*1.6), |
232 | [Way_Track ] = kph_to_speed(10*1.6), |
233 | [Way_Path ] = 0, |
234 | [Way_Bridleway ] = 0, |
235 | [Way_Cycleway ] = 0, |
236 | [Way_Footway ] = 0, |
237 | }, |
238 | .oneway = 1, |
239 | .weight = 0, |
240 | .height = 0, |
241 | .width = 0, |
242 | .length = 0, |
243 | }, |
244 | |
245 | /* The profile for travel by Goods */ |
246 | |
247 | [Transport_Goods] = { |
248 | .transport=Transport_Goods, |
249 | .allow =Allow_Goods, |
250 | .highway = { |
251 | [Way_Motorway ] = 100, |
252 | [Way_Trunk ] = 100, |
253 | [Way_Primary ] = 90, |
254 | [Way_Secondary ] = 80, |
255 | [Way_Tertiary ] = 70, |
256 | [Way_Unclassified] = 60, |
257 | [Way_Residential ] = 50, |
258 | [Way_Service ] = 80, |
259 | [Way_Track ] = 0, |
260 | [Way_Path ] = 0, |
261 | [Way_Bridleway ] = 0, |
262 | [Way_Cycleway ] = 0, |
263 | [Way_Footway ] = 0, |
264 | }, |
265 | .speed = { |
266 | [Way_Motorway ] = kph_to_speed(60*1.6), |
267 | [Way_Trunk ] = kph_to_speed(60*1.6), |
268 | [Way_Primary ] = kph_to_speed(60*1.6), |
269 | [Way_Secondary ] = kph_to_speed(55*1.6), |
270 | [Way_Tertiary ] = kph_to_speed(50*1.6), |
271 | [Way_Unclassified] = kph_to_speed(40*1.6), |
272 | [Way_Residential ] = kph_to_speed(30*1.6), |
273 | [Way_Service ] = kph_to_speed(20*1.6), |
274 | [Way_Track ] = kph_to_speed(10*1.6), |
275 | [Way_Path ] = 0, |
276 | [Way_Bridleway ] = 0, |
277 | [Way_Cycleway ] = 0, |
278 | [Way_Footway ] = 0, |
279 | }, |
280 | .oneway = 1, |
281 | .weight = tonnes_to_weight(5), |
282 | .height = metres_to_height(2.5), |
283 | .width = metres_to_width (2), |
284 | .length = metres_to_length(5), |
285 | }, |
286 | |
287 | /* The profile for travel by HGV */ |
288 | |
289 | [Transport_HGV] = { |
290 | .transport=Transport_HGV, |
291 | .allow =Allow_HGV, |
292 | .highway = { |
293 | [Way_Motorway ] = 100, |
294 | [Way_Trunk ] = 100, |
295 | [Way_Primary ] = 90, |
296 | [Way_Secondary ] = 80, |
297 | [Way_Tertiary ] = 70, |
298 | [Way_Unclassified] = 60, |
299 | [Way_Residential ] = 50, |
300 | [Way_Service ] = 80, |
301 | [Way_Track ] = 0, |
302 | [Way_Path ] = 0, |
303 | [Way_Bridleway ] = 0, |
304 | [Way_Cycleway ] = 0, |
305 | [Way_Footway ] = 0, |
306 | }, |
307 | .speed = { |
308 | [Way_Motorway ] = kph_to_speed(56*1.6), |
309 | [Way_Trunk ] = kph_to_speed(50*1.6), |
310 | [Way_Primary ] = kph_to_speed(50*1.6), |
311 | [Way_Secondary ] = kph_to_speed(50*1.6), |
312 | [Way_Tertiary ] = kph_to_speed(50*1.6), |
313 | [Way_Unclassified] = kph_to_speed(40*1.6), |
314 | [Way_Residential ] = kph_to_speed(30*1.6), |
315 | [Way_Service ] = kph_to_speed(20*1.6), |
316 | [Way_Track ] = kph_to_speed(10*1.6), |
317 | [Way_Path ] = 0, |
318 | [Way_Bridleway ] = 0, |
319 | [Way_Cycleway ] = 0, |
320 | [Way_Footway ] = 0, |
321 | }, |
322 | .oneway = 1, |
323 | .weight = tonnes_to_weight(10), |
324 | .height = metres_to_height(3), |
325 | .width = metres_to_width (2.5), |
326 | .length = metres_to_length(6), |
327 | }, |
328 | |
329 | /* The profile for travel by PSV */ |
330 | |
331 | [Transport_PSV] = { |
332 | .transport=Transport_PSV, |
333 | .allow =Allow_PSV, |
334 | .highway = { |
335 | [Way_Motorway ] = 100, |
336 | [Way_Trunk ] = 100, |
337 | [Way_Primary ] = 90, |
338 | [Way_Secondary ] = 80, |
339 | [Way_Tertiary ] = 70, |
340 | [Way_Unclassified] = 60, |
341 | [Way_Residential ] = 50, |
342 | [Way_Service ] = 80, |
343 | [Way_Track ] = 0, |
344 | [Way_Path ] = 0, |
345 | [Way_Bridleway ] = 0, |
346 | [Way_Cycleway ] = 0, |
347 | [Way_Footway ] = 0, |
348 | }, |
349 | .speed = { |
350 | [Way_Motorway ] = kph_to_speed(56*1.6), |
351 | [Way_Trunk ] = kph_to_speed(50*1.6), |
352 | [Way_Primary ] = kph_to_speed(50*1.6), |
353 | [Way_Secondary ] = kph_to_speed(50*1.6), |
354 | [Way_Tertiary ] = kph_to_speed(50*1.6), |
355 | [Way_Unclassified] = kph_to_speed(40*1.6), |
356 | [Way_Residential ] = kph_to_speed(30*1.6), |
357 | [Way_Service ] = kph_to_speed(20*1.6), |
358 | [Way_Track ] = kph_to_speed(10*1.6), |
359 | [Way_Path ] = 0, |
360 | [Way_Bridleway ] = 0, |
361 | [Way_Cycleway ] = 0, |
362 | [Way_Footway ] = 0, |
363 | }, |
364 | .oneway = 1, |
365 | .weight = tonnes_to_weight(15), |
366 | .height = metres_to_height(3), |
367 | .width = metres_to_width (2.5), |
368 | .length = metres_to_length(6), |
369 | }, |
370 | }; |
371 | |
372 | |
373 | /*++++++++++++++++++++++++++++++++++++++ |
374 | Get the profile for a type of transport. |
375 | |
376 | Profile *GetProfile Returns a pointer to the profile. |
377 | |
378 | Transport transport The type of transport. |
379 | ++++++++++++++++++++++++++++++++++++++*/ |
380 | |
381 | Profile *GetProfile(Transport transport) |
382 | { |
383 | return(&builtin_profiles[transport]); |
384 | } |
385 | |
386 | |
387 | /*++++++++++++++++++++++++++++++++++++++ |
388 | Update a profile with highway preference scaling factor. |
389 | |
390 | Profile *profile The profile to be updated. |
391 | ++++++++++++++++++++++++++++++++++++++*/ |
392 | |
393 | void UpdateProfile(Profile *profile) |
394 | { |
395 | score_t hmax=0; |
396 | int i; |
397 | |
398 | /* Normalise the highway preferences into the range 0 -> 1 */ |
399 | |
400 | for(i=1;i<Way_Unknown;i++) |
401 | if(profile->highway[i]>hmax) |
402 | hmax=profile->highway[i]; |
403 | |
404 | for(i=1;i<Way_Unknown;i++) |
405 | if(profile->highway[i]>0) |
406 | profile->highway[i]/=hmax; |
407 | else |
408 | profile->highway[i]=0; |
409 | |
410 | /* Find the fastest and most preferred highway type */ |
411 | |
412 | profile->max_speed=0; |
413 | |
414 | for(i=0;i<Way_Unknown;i++) |
415 | if(profile->speed[i]>profile->max_speed) |
416 | profile->max_speed=profile->speed[i]; |
417 | |
418 | profile->max_pref=0; |
419 | |
420 | for(i=0;i<Way_Unknown;i++) |
421 | if(profile->highway[i]>profile->max_pref) |
422 | profile->max_pref=profile->highway[i]; |
423 | } |
424 | |
425 | |
426 | /*++++++++++++++++++++++++++++++++++++++ |
427 | Print out a profile. |
428 | |
429 | const Profile *profile The profile to print. |
430 | ++++++++++++++++++++++++++++++++++++++*/ |
431 | |
432 | void PrintProfile(const Profile *profile) |
433 | { |
434 | unsigned int i; |
435 | |
436 | printf("Profile\n=======\n"); |
437 | |
438 | printf("\n"); |
439 | |
440 | printf("Transport: %s\n",TransportName(profile->transport)); |
441 | |
442 | printf("\n"); |
443 | |
444 | for(i=1;i<Way_Unknown;i++) |
445 | printf("Highway %-12s: %3d%%\n",HighwayName(i),(int)profile->highway[i]); |
446 | |
447 | printf("\n"); |
448 | |
449 | for(i=1;i<Way_Unknown;i++) |
450 | if(profile->highway[i]) |
451 | printf("Speed on %-12s: %3d km/h / %2.0f mph\n",HighwayName(i),profile->speed[i],(double)profile->speed[i]/1.6); |
452 | |
453 | printf("\n"); |
454 | |
455 | printf("Obey one-way : %s\n",profile->oneway?"yes":"no"); |
456 | printf("Minimum weight: %.1f tonnes\n",weight_to_tonnes(profile->weight)); |
457 | printf("Minimum height: %.1f metres\n",height_to_metres(profile->height)); |
458 | printf("Minimum width : %.1f metres\n",width_to_metres(profile->width)); |
459 | printf("Minimum length: %.1f metres\n",length_to_metres(profile->length)); |
460 | } |
461 | |
462 | |
463 | /*++++++++++++++++++++++++++++++++++++++ |
464 | Print out the profiles as Javascript for use in a web form. |
465 | ++++++++++++++++++++++++++++++++++++++*/ |
466 | |
467 | void PrintProfilesJS(void) |
468 | { |
469 | unsigned int i,j; |
470 | |
471 | printf("// Transport types\n"); |
472 | printf("var router_transports={"); |
473 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
474 | printf("%s%s: %d",j==1?"":", ",TransportName(j),j); |
475 | printf("};\n"); |
476 | printf("\n"); |
477 | |
478 | printf("// Highway types\n"); |
479 | printf("var router_highways={"); |
480 | for(i=1;i<Way_Unknown;i++) |
481 | printf("%s%s: %d",i==1?"":", ",HighwayName(i),i); |
482 | printf("};\n"); |
483 | printf("\n"); |
484 | |
485 | printf("// Restriction types\n"); |
486 | printf("var router_restrictions={oneway: 1, weight: 2, height: 3, width: 4, length: 5};\n"); |
487 | printf("\n"); |
488 | |
489 | printf("// Allowed highways\n"); |
490 | printf("var router_profile_highway={\n"); |
491 | for(i=1;i<Way_Unknown;i++) |
492 | { |
493 | printf(" %12s: {",HighwayName(i)); |
494 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
495 | printf("%s%s: %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].highway[i]); |
496 | printf("}%s\n",i==(Way_Unknown-1)?"":","); |
497 | } |
498 | printf(" };\n"); |
499 | printf("\n"); |
500 | |
501 | printf("// Speed limits\n"); |
502 | printf("var router_profile_speed={\n"); |
503 | for(i=1;i<Way_Unknown;i++) |
504 | { |
505 | printf(" %12s: {",HighwayName(i)); |
506 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
507 | printf("%s%s: %3d",j==1?"":", ",TransportName(j),builtin_profiles[j].speed[i]); |
508 | printf("}%s\n",i==(Way_Unknown-1)?"":","); |
509 | } |
510 | printf(" };\n"); |
511 | printf("\n"); |
512 | |
513 | printf("// Restrictions\n"); |
514 | printf("var router_profile_restrictions={\n"); |
515 | printf(" %12s: {","oneway"); |
516 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
517 | printf("%s%s: %4d",j==1?"":", ",TransportName(j),builtin_profiles[j].oneway); |
518 | printf("},\n"); |
519 | printf(" %12s: {","weight"); |
520 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
521 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),weight_to_tonnes(builtin_profiles[j].weight)); |
522 | printf("},\n"); |
523 | printf(" %12s: {","height"); |
524 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
525 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),height_to_metres(builtin_profiles[j].height)); |
526 | printf("},\n"); |
527 | printf(" %12s: {","width"); |
528 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
529 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),width_to_metres(builtin_profiles[j].width)); |
530 | printf("},\n"); |
531 | printf(" %12s: {","length"); |
532 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
533 | printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),length_to_metres(builtin_profiles[j].length)); |
534 | printf("}\n"); |
535 | printf(" };\n"); |
536 | printf("\n"); |
537 | } |
538 | |
539 | |
540 | /*++++++++++++++++++++++++++++++++++++++ |
541 | Print out the profiles as Perl for use in a web CGI. |
542 | ++++++++++++++++++++++++++++++++++++++*/ |
543 | |
544 | void PrintProfilesPerl(void) |
545 | { |
546 | unsigned int i,j; |
547 | |
548 | printf("# Transport types\n"); |
549 | printf("@router_transports=("); |
550 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
551 | printf("%s'%s'",j==1?"":", ",TransportName(j)); |
552 | printf(");\n"); |
553 | printf("\n"); |
554 | |
555 | printf("# Highway types\n"); |
556 | printf("@router_highways=("); |
557 | for(i=1;i<Way_Unknown;i++) |
558 | printf("%s'%s'",i==1?"":", ",HighwayName(i)); |
559 | printf(");\n"); |
560 | printf("\n"); |
561 | |
562 | printf("# Restriction types\n"); |
563 | printf("@router_restrictions=('oneway', 'weight', 'height', 'width', 'length');\n"); |
564 | printf("\n"); |
565 | |
566 | printf("# Allowed highways\n"); |
567 | printf("%%router_profile_highway=(\n"); |
568 | for(i=1;i<Way_Unknown;i++) |
569 | { |
570 | printf(" %12s => {",HighwayName(i)); |
571 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
572 | printf("%s %s => %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].highway[i]); |
573 | printf("}%s\n",i==(Way_Unknown-1)?"":","); |
574 | } |
575 | printf(" );\n"); |
576 | printf("\n"); |
577 | |
578 | printf("# Speed limits\n"); |
579 | printf("%%router_profile_speed=(\n"); |
580 | for(i=1;i<Way_Unknown;i++) |
581 | { |
582 | printf(" %12s => {",HighwayName(i)); |
583 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
584 | printf("%s %s => %3d",j==1?"":", ",TransportName(j),builtin_profiles[j].speed[i]); |
585 | printf("}%s\n",i==(Way_Unknown-1)?"":","); |
586 | } |
587 | printf(" );\n"); |
588 | printf("\n"); |
589 | |
590 | printf("# Restrictions\n"); |
591 | printf("%%router_profile_restrictions=(\n"); |
592 | printf(" %12s => {","oneway"); |
593 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
594 | printf("%s %s => %4d",j==1?"":", ",TransportName(j),builtin_profiles[j].oneway); |
595 | printf("},\n"); |
596 | printf(" %12s => {","weight"); |
597 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
598 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),weight_to_tonnes(builtin_profiles[j].weight)); |
599 | printf("},\n"); |
600 | printf(" %12s => {","height"); |
601 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
602 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),height_to_metres(builtin_profiles[j].height)); |
603 | printf("},\n"); |
604 | printf(" %12s => {","width"); |
605 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
606 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),width_to_metres(builtin_profiles[j].width)); |
607 | printf("},\n"); |
608 | printf(" %12s => {","length"); |
609 | for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++) |
610 | printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),length_to_metres(builtin_profiles[j].length)); |
611 | printf("}\n"); |
612 | printf(" );\n"); |
613 | printf("\n"); |
614 | } |
Properties
Name | Value |
---|---|
cvs:description | Definition of built-in profiles and other functions. |