Routino SVN Repository Browser

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

ViewVC logotype

Contents of /trunk/src/profiles.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 320 - (show annotations) (download) (as text)
Fri Mar 5 19:34:44 2010 UTC (15 years ago) by amb
File MIME type: text/x-csrc
File size: 35875 byte(s)
Change the format of the output for the --help-profile-{pl|js} options.

1 /***************************************
2 $Header: /home/amb/CVS/routino/src/profiles.c,v 1.30 2010-03-05 19:34:44 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-2010 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_Cycleway ] = 95,
51 [Way_Path ] = 100,
52 [Way_Steps ] = 80,
53 },
54 .speed = {
55 [Way_Motorway ] = 0,
56 [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 [Way_Cycleway ] = kph_to_speed(4),
65 [Way_Path ] = kph_to_speed(4),
66 [Way_Steps ] = kph_to_speed(4),
67 },
68 .props_yes= {
69 [Property_Paved ] = 50,
70 [Property_Multilane] = 25,
71 [Property_Bridge ] = 50,
72 [Property_Tunnel ] = 50,
73 },
74 .oneway = 0,
75 .weight = 0,
76 .height = 0,
77 .width = 0,
78 .length = 0,
79 },
80
81 /* 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 [Way_Steps ] = 0,
99 },
100 .speed = {
101 [Way_Motorway ] = 0,
102 [Way_Trunk ] = kph_to_speed(8),
103 [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 [Way_Steps ] = 0,
113 },
114 .props_yes= {
115 [Property_Paved ] = 20,
116 [Property_Multilane] = 25,
117 [Property_Bridge ] = 50,
118 [Property_Tunnel ] = 50,
119 },
120 .oneway = 1,
121 .weight = 0,
122 .height = 0,
123 .width = 0,
124 .length = 0,
125 },
126
127 /* 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 /* The profile for travel by Bicycle */
174
175 [Transport_Bicycle] = {
176 .transport=Transport_Bicycle,
177 .allow =Allow_Bicycle,
178 .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 [Way_Cycleway ] = 100,
189 [Way_Path ] = 90,
190 [Way_Steps ] = 0,
191 },
192 .speed = {
193 [Way_Motorway ] = 0,
194 [Way_Trunk ] = kph_to_speed(20),
195 [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 [Way_Cycleway ] = kph_to_speed(20),
203 [Way_Path ] = kph_to_speed(20),
204 [Way_Steps ] = 0,
205 },
206 .props_yes= {
207 [Property_Paved ] = 50,
208 [Property_Multilane] = 25,
209 [Property_Bridge ] = 50,
210 [Property_Tunnel ] = 50,
211 },
212 .oneway = 1,
213 .weight = 0,
214 .height = 0,
215 .width = 0,
216 .length = 0,
217 },
218
219 /* 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 [Way_Steps ] = 0,
237 },
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 [Way_Steps ] = 0,
251 },
252 .props_yes= {
253 [Property_Paved ] = 100,
254 [Property_Multilane] = 25,
255 [Property_Bridge ] = 50,
256 [Property_Tunnel ] = 50,
257 },
258 .oneway = 1,
259 .weight = 0,
260 .height = 0,
261 .width = 0,
262 .length = 0,
263 },
264
265 /* The profile for travel by Motorbike */
266
267 [Transport_Motorbike] = {
268 .transport=Transport_Motorbike,
269 .allow =Allow_Motorbike,
270 .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 [Way_Cycleway ] = 0,
281 [Way_Path ] = 0,
282 [Way_Steps ] = 0,
283 },
284 .speed = {
285 [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 [Way_Track ] = kph_to_speed(10*1.6),
294 [Way_Cycleway ] = 0,
295 [Way_Path ] = 0,
296 [Way_Steps ] = 0,
297 },
298 .props_yes= {
299 [Property_Paved ] = 100,
300 [Property_Multilane] = 75,
301 [Property_Bridge ] = 50,
302 [Property_Tunnel ] = 50,
303 },
304 .oneway = 1,
305 .weight = 0,
306 .height = 0,
307 .width = 0,
308 .length = 0,
309 },
310
311 /* The profile for travel by Motorcar */
312
313 [Transport_Motorcar] = {
314 .transport=Transport_Motorcar,
315 .allow =Allow_Motorcar,
316 .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 [Way_Cycleway ] = 0,
327 [Way_Path ] = 0,
328 [Way_Steps ] = 0,
329 },
330 .speed = {
331 [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 [Way_Track ] = kph_to_speed(10*1.6),
340 [Way_Cycleway ] = 0,
341 [Way_Path ] = 0,
342 [Way_Steps ] = 0,
343 },
344 .props_yes= {
345 [Property_Paved ] = 100,
346 [Property_Multilane] = 75,
347 [Property_Bridge ] = 50,
348 [Property_Tunnel ] = 50,
349 },
350 .oneway = 1,
351 .weight = 0,
352 .height = 0,
353 .width = 0,
354 .length = 0,
355 },
356
357 /* The profile for travel by Goods */
358
359 [Transport_Goods] = {
360 .transport=Transport_Goods,
361 .allow =Allow_Goods,
362 .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 [Way_Cycleway ] = 0,
373 [Way_Path ] = 0,
374 [Way_Steps ] = 0,
375 },
376 .speed = {
377 [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 [Way_Track ] = kph_to_speed(10*1.6),
386 [Way_Cycleway ] = 0,
387 [Way_Path ] = 0,
388 [Way_Steps ] = 0,
389 },
390 .props_yes= {
391 [Property_Paved ] = 100,
392 [Property_Multilane] = 75,
393 [Property_Bridge ] = 50,
394 [Property_Tunnel ] = 50,
395 },
396 .oneway = 1,
397 .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 },
402
403 /* The profile for travel by HGV */
404
405 [Transport_HGV] = {
406 .transport=Transport_HGV,
407 .allow =Allow_HGV,
408 .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 [Way_Cycleway ] = 0,
419 [Way_Path ] = 0,
420 [Way_Steps ] = 0,
421 },
422 .speed = {
423 [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 [Way_Track ] = kph_to_speed(10*1.6),
432 [Way_Cycleway ] = 0,
433 [Way_Path ] = 0,
434 [Way_Steps ] = 0,
435 },
436 .props_yes= {
437 [Property_Paved ] = 100,
438 [Property_Multilane] = 75,
439 [Property_Bridge ] = 50,
440 [Property_Tunnel ] = 50,
441 },
442 .oneway = 1,
443 .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 },
448
449 /* The profile for travel by PSV */
450
451 [Transport_PSV] = {
452 .transport=Transport_PSV,
453 .allow =Allow_PSV,
454 .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 [Way_Cycleway ] = 0,
465 [Way_Path ] = 0,
466 [Way_Steps ] = 0,
467 },
468 .speed = {
469 [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 [Way_Track ] = kph_to_speed(10*1.6),
478 [Way_Cycleway ] = 0,
479 [Way_Path ] = 0,
480 [Way_Steps ] = 0,
481 },
482 .props_yes= {
483 [Property_Paved ] = 100,
484 [Property_Multilane] = 75,
485 [Property_Bridge ] = 50,
486 [Property_Tunnel ] = 50,
487 },
488 .oneway = 1,
489 .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 },
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 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 score_t hmax=0;
520 int i;
521
522 /* Normalise the highway preferences into the range 0 -> 1 */
523
524 for(i=1;i<Way_Count;i++)
525 {
526 if(profile->highway[i]<0)
527 profile->highway[i]=0;
528
529 if(profile->highway[i]>hmax)
530 hmax=profile->highway[i];
531 }
532
533 for(i=1;i<Way_Count;i++)
534 profile->highway[i]/=hmax;
535
536 /* 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 /* Find the fastest and most preferred highway type */
551
552 profile->max_speed=0;
553
554 for(i=1;i<Way_Count;i++)
555 if(profile->speed[i]>profile->max_speed)
556 profile->max_speed=profile->speed[i];
557
558 profile->max_pref=1; /* since highway prefs were normalised to 1 */
559
560 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 }
566
567
568 /*++++++++++++++++++++++++++++++++++++++
569 Print out a profile.
570
571 const Profile *profile The profile to print.
572 ++++++++++++++++++++++++++++++++++++++*/
573
574 void PrintProfile(const Profile *profile)
575 {
576 unsigned int i;
577
578 printf("Profile\n=======\n");
579
580 printf("\n");
581
582 printf("Transport: %s\n",TransportName(profile->transport));
583
584 printf("\n");
585
586 for(i=1;i<Way_Count;i++)
587 printf("Highway %-12s: %3d%%\n",HighwayName(i),(int)profile->highway[i]);
588
589 printf("\n");
590
591 for(i=1;i<Way_Count;i++)
592 if(profile->highway[i])
593 printf("Speed on %-12s: %3d km/h / %2.0f mph\n",HighwayName(i),profile->speed[i],(double)profile->speed[i]/1.6);
594
595 printf("\n");
596
597 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 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 }
608
609
610 /*++++++++++++++++++++++++++++++++++++++
611 Print out the profiles as Javascript for use in a web form.
612 ++++++++++++++++++++++++++++++++++++++*/
613
614 void PrintProfilesJS(void)
615 {
616 unsigned int i,j;
617
618 printf("var routino={ // contains all default Routino options (generated using \"--help-profile-js\").\n\n");
619
620 printf(" // Default transport type\n");
621 printf(" transport: 'motorcar',\n");
622 printf("\n");
623
624 printf(" // Transport types\n");
625 printf(" transports: {");
626 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
627 printf("%s%s: %d",j==1?"":", ",TransportName(j),j);
628 printf("},\n");
629 printf("\n");
630
631 printf(" // Highway types\n");
632 printf(" highways: {");
633 for(i=1;i<Way_Count;i++)
634 printf("%s%s: %d",i==1?"":", ",HighwayName(i),i);
635 printf("},\n");
636 printf("\n");
637
638 printf(" // Property types\n");
639 printf(" properties: {");
640 for(i=1;i<Property_Count;i++)
641 printf("%s%s: %d",i==1?"":", ",PropertyName(i),i);
642 printf("},\n");
643 printf("\n");
644
645 printf(" // Restriction types\n");
646 printf(" restrictions: {oneway: 1, weight: 2, height: 3, width: 4, length: 5},\n");
647 printf("\n");
648
649 printf(" // Allowed highways\n");
650 printf(" profile_highway: {\n");
651 for(i=1;i<Way_Count;i++)
652 {
653 printf(" %12s: {",HighwayName(i));
654 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
655 printf("%s%s: %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].highway[i]);
656 printf("}%s\n",i==(Way_Count-1)?"":",");
657 }
658 printf(" },\n");
659 printf("\n");
660
661 printf(" // Speed limits\n");
662 printf(" profile_speed: {\n");
663 for(i=1;i<Way_Count;i++)
664 {
665 printf(" %12s: {",HighwayName(i));
666 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
667 printf("%s%s: %3d",j==1?"":", ",TransportName(j),builtin_profiles[j].speed[i]);
668 printf("}%s\n",i==(Way_Count-1)?"":",");
669 }
670 printf(" },\n");
671 printf("\n");
672
673 printf(" // Highway properties\n");
674 printf(" profile_property: {\n");
675 for(i=1;i<Property_Count;i++)
676 {
677 printf(" %12s: {",PropertyName(i));
678 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
679 printf("%s%s: %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].props_yes[i]);
680 printf("}%s\n",i==(Property_Count-1)?"":",");
681 }
682 printf(" },\n");
683 printf("\n");
684
685 printf(" // Restrictions\n");
686 printf(" profile_restrictions: {\n");
687 printf(" %12s: {","oneway");
688 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
689 printf("%s%s: %4d",j==1?"":", ",TransportName(j),builtin_profiles[j].oneway);
690 printf("},\n");
691 printf(" %12s: {","weight");
692 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
693 printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),weight_to_tonnes(builtin_profiles[j].weight));
694 printf("},\n");
695 printf(" %12s: {","height");
696 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
697 printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),height_to_metres(builtin_profiles[j].height));
698 printf("},\n");
699 printf(" %12s: {","width");
700 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
701 printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),width_to_metres(builtin_profiles[j].width));
702 printf("},\n");
703 printf(" %12s: {","length");
704 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
705 printf("%s%s: %4.1f",j==1?"":", ",TransportName(j),length_to_metres(builtin_profiles[j].length));
706 printf("}\n");
707 printf(" }\n");
708 printf("\n");
709
710 printf("}; // end of routino variable\n");
711 }
712
713
714 /*++++++++++++++++++++++++++++++++++++++
715 Print out the profiles as Perl for use in a web CGI.
716 ++++++++++++++++++++++++++++++++++++++*/
717
718 void PrintProfilesPerl(void)
719 {
720 unsigned int i,j;
721
722 printf("$routino={ # contains all default Routino options (generated using \"--help-profile-pl\").\n\n");
723
724 printf(" # Default transport type\n");
725 printf(" transport => 'motorcar',\n");
726 printf("\n");
727
728 printf(" # Transport types\n");
729 printf(" transports => {");
730 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
731 printf("%s%s => %d",j==1?"":", ",TransportName(j),j);
732 printf("},\n");
733 printf("\n");
734
735 printf(" # Highway types\n");
736 printf(" highways => {");
737 for(i=1;i<Way_Count;i++)
738 printf("%s%s => %d",i==1?"":", ",HighwayName(i),i);
739 printf("},\n");
740 printf("\n");
741
742 printf(" # Property types\n");
743 printf(" properties => {");
744 for(i=1;i<Property_Count;i++)
745 printf("%s%s => %d",i==1?"":", ",PropertyName(i),i);
746 printf("},\n");
747 printf("\n");
748
749 printf(" # Restriction types\n");
750 printf(" restrictions => {oneway => 1, weight => 2, height => 3, width => 4, length => 5},\n");
751 printf("\n");
752
753 printf(" # Allowed highways\n");
754 printf(" profile_highway => {\n");
755 for(i=1;i<Way_Count;i++)
756 {
757 printf(" %12s => {",HighwayName(i));
758 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
759 printf("%s %s => %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].highway[i]);
760 printf("}%s\n",i==(Way_Count-1)?"":",");
761 }
762 printf(" },\n");
763 printf("\n");
764
765 printf(" # Speed limits\n");
766 printf(" profile_speed => {\n");
767 for(i=1;i<Way_Count;i++)
768 {
769 printf(" %12s => {",HighwayName(i));
770 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
771 printf("%s %s => %3d",j==1?"":", ",TransportName(j),builtin_profiles[j].speed[i]);
772 printf("}%s\n",i==(Way_Count-1)?"":",");
773 }
774 printf(" },\n");
775 printf("\n");
776
777 printf(" # Highway properties\n");
778 printf(" profile_property => {\n");
779 for(i=1;i<Property_Count;i++)
780 {
781 printf(" %12s => {",PropertyName(i));
782 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
783 printf("%s %s => %3d",j==1?"":", ",TransportName(j),(int)builtin_profiles[j].props_yes[i]);
784 printf("}%s\n",i==(Property_Count-1)?"":",");
785 }
786 printf(" },\n");
787 printf("\n");
788
789 printf(" # Restrictions\n");
790 printf(" profile_restrictions => {\n");
791 printf(" %12s => {","oneway");
792 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
793 printf("%s %s => %4d",j==1?"":", ",TransportName(j),builtin_profiles[j].oneway);
794 printf("},\n");
795 printf(" %12s => {","weight");
796 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
797 printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),weight_to_tonnes(builtin_profiles[j].weight));
798 printf("},\n");
799 printf(" %12s => {","height");
800 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
801 printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),height_to_metres(builtin_profiles[j].height));
802 printf("},\n");
803 printf(" %12s => {","width");
804 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
805 printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),width_to_metres(builtin_profiles[j].width));
806 printf("},\n");
807 printf(" %12s => {","length");
808 for(j=1;j<sizeof(builtin_profiles)/sizeof(builtin_profiles[0]);j++)
809 printf("%s %s => %4.1f",j==1?"":", ",TransportName(j),length_to_metres(builtin_profiles[j].length));
810 printf("}\n");
811 printf(" },\n");
812 printf("\n");
813
814 printf("}; # end of routino variable\n");
815 }

Properties

Name Value
cvs:description Definition of built-in profiles and other functions.