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/profiles.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 341 - (hide annotations) (download) (as text)
Mon Mar 29 18:20:06 2010 UTC (15 years ago) by amb
File MIME type: text/x-csrc
File size: 21224 byte(s)
Added command line option to specify a file containing profiles.
Added command line option to select profile by name from loaded set.
Use XML parser to read in the profiles.

1 amb 83 /***************************************
2 amb 341 $Header: /home/amb/CVS/routino/src/profiles.c,v 1.32 2010-03-29 18:20:06 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 320 This file Copyright 2008-2010 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 amb 336 #include <string.h>
27 amb 341 #include <stdlib.h>
28 amb 83
29     #include "profiles.h"
30 amb 97 #include "types.h"
31 amb 83 #include "ways.h"
32 amb 341 #include "xmlparse.h"
33 amb 83
34    
35 amb 341 /*+ The profiles that have been loaded from file. +*/
36     static Profile **loaded_profiles=NULL;
37 amb 83
38 amb 341 /*+ The number of profiles that have been loaded from file. +*/
39     static int nloaded_profiles=0;
40 amb 83
41 amb 294
42 amb 341 /* The XML tag processing function prototypes */
43 amb 294
44 amb 341 static void profile_function(char *name,char *transport);
45     static void length_function(char *limit);
46     static void width_function(char *limit);
47     static void height_function(char *limit);
48     static void weight_function(char *limit);
49     static void oneway_function(char *obey);
50     static void property_function(char *type,char *percent);
51     static void preference_function(char *highway,char *percent);
52     static void speed_function(char *highway,char *kph);
53 amb 314
54    
55 amb 341 /* The XML tag definitions */
56 amb 83
57 amb 341 /*+ The speedType type tag. +*/
58     static xmltag speed_tag=
59     {"speed",
60     {"highway","kph",NULL},
61     speed_function,
62     {NULL}};
63 amb 83
64 amb 341 /*+ The speedsType type tag. +*/
65     static xmltag speeds_tag=
66     {"speeds",
67     {NULL},
68     NULL,
69     {&speed_tag,NULL}};
70 amb 296
71 amb 341 /*+ The preferenceType type tag. +*/
72     static xmltag preference_tag=
73     {"preference",
74     {"highway","percent",NULL},
75     preference_function,
76     {NULL}};
77 amb 296
78 amb 341 /*+ The preferencesType type tag. +*/
79     static xmltag preferences_tag=
80     {"preferences",
81     {NULL},
82     NULL,
83     {&preference_tag,NULL}};
84 amb 83
85 amb 341 /*+ The propertyType type tag. +*/
86     static xmltag property_tag=
87     {"property",
88     {"type","percent",NULL},
89     property_function,
90     {NULL}};
91 amb 83
92 amb 341 /*+ The onewayType type tag. +*/
93     static xmltag oneway_tag=
94     {"oneway",
95     {"obey",NULL},
96     oneway_function,
97     {NULL}};
98 amb 83
99 amb 341 /*+ The propertiesType type tag. +*/
100     static xmltag properties_tag=
101     {"properties",
102     {NULL},
103     NULL,
104     {&property_tag,NULL}};
105 amb 83
106 amb 341 /*+ The weightType type tag. +*/
107     static xmltag weight_tag=
108     {"weight",
109     {"limit",NULL},
110     weight_function,
111     {NULL}};
112 amb 83
113 amb 341 /*+ The heightType type tag. +*/
114     static xmltag height_tag=
115     {"height",
116     {"limit",NULL},
117     height_function,
118     {NULL}};
119 amb 83
120 amb 341 /*+ The widthType type tag. +*/
121     static xmltag width_tag=
122     {"width",
123     {"limit",NULL},
124     width_function,
125     {NULL}};
126 amb 83
127 amb 341 /*+ The lengthType type tag. +*/
128     static xmltag length_tag=
129     {"length",
130     {"limit",NULL},
131     length_function,
132     {NULL}};
133 amb 83
134 amb 341 /*+ The restrictionsType type tag. +*/
135     static xmltag restrictions_tag=
136     {"restrictions",
137     {NULL},
138     NULL,
139     {&oneway_tag,&weight_tag,&height_tag,&width_tag,&length_tag,NULL}};
140 amb 83
141 amb 341 /*+ The profileType type tag. +*/
142     static xmltag profile_tag=
143     {"profile",
144     {"name","transport",NULL},
145     profile_function,
146     {&speeds_tag,&preferences_tag,&properties_tag,&restrictions_tag,NULL}};
147 amb 83
148 amb 341 /*+ The RoutinoProfilesType type tag. +*/
149     static xmltag routino_profiles_tag=
150     {"routino-profiles",
151     {NULL},
152     NULL,
153     {&profile_tag,NULL}};
154 amb 83
155 amb 341 /*+ The ?xmlType type tag. +*/
156     static xmltag _xml_tag=
157     {"?xml",
158     {"version","encoding",NULL},
159     NULL,
160     {NULL}};
161    
162    
163     /*+ The complete set of tags at the top level. +*/
164     static xmltag *xml_toplevel_tags[]={&_xml_tag,&routino_profiles_tag,NULL};
165    
166    
167     /* The XML tag processing functions */
168    
169    
170 amb 83 /*++++++++++++++++++++++++++++++++++++++
171 amb 341 The function that is called when the speedType type is seen
172    
173     char *highway The contents of the 'highway' attribute (or NULL if not defined).
174    
175     char *kph The contents of the 'kph' attribute (or NULL if not defined).
176     ++++++++++++++++++++++++++++++++++++++*/
177    
178     static void speed_function(char *highway,char *kph)
179     {
180     Highway highwaytype=HighwayType(highway);
181    
182     loaded_profiles[nloaded_profiles-1]->speed[highwaytype]=kph_to_speed(atoi(kph));
183     }
184    
185    
186     /*++++++++++++++++++++++++++++++++++++++
187     The function that is called when the preferenceType type is seen
188    
189     char *highway The contents of the 'highway' attribute (or NULL if not defined).
190    
191     char *percent The contents of the 'percent' attribute (or NULL if not defined).
192     ++++++++++++++++++++++++++++++++++++++*/
193    
194     static void preference_function(char *highway,char *percent)
195     {
196     Highway highwaytype=HighwayType(highway);
197    
198     loaded_profiles[nloaded_profiles-1]->highway[highwaytype]=atoi(percent);
199     }
200    
201    
202     /*++++++++++++++++++++++++++++++++++++++
203     The function that is called when the propertyType type is seen
204    
205     char *type The contents of the 'type' attribute (or NULL if not defined).
206    
207     char *percent The contents of the 'percent' attribute (or NULL if not defined).
208     ++++++++++++++++++++++++++++++++++++++*/
209    
210     static void property_function(char *type,char *percent)
211     {
212     Property property=PropertyType(type);
213    
214     loaded_profiles[nloaded_profiles-1]->props_yes[property]=atoi(percent);
215     }
216    
217    
218     /*++++++++++++++++++++++++++++++++++++++
219     The function that is called when the onewayType type is seen
220    
221     char *obey The contents of the 'obey' attribute (or NULL if not defined).
222     ++++++++++++++++++++++++++++++++++++++*/
223    
224     static void oneway_function(char *obey)
225     {
226     loaded_profiles[nloaded_profiles-1]->oneway=!!atoi(obey);
227     }
228    
229    
230     /*++++++++++++++++++++++++++++++++++++++
231     The function that is called when the weightType type is seen
232    
233     char *limit The contents of the 'limit' attribute (or NULL if not defined).
234     ++++++++++++++++++++++++++++++++++++++*/
235    
236     static void weight_function(char *limit)
237     {
238     loaded_profiles[nloaded_profiles-1]->weight=tonnes_to_weight(atof(limit));
239     }
240    
241    
242     /*++++++++++++++++++++++++++++++++++++++
243     The function that is called when the heightType type is seen
244    
245     char *limit The contents of the 'limit' attribute (or NULL if not defined).
246     ++++++++++++++++++++++++++++++++++++++*/
247    
248     static void height_function(char *limit)
249     {
250     loaded_profiles[nloaded_profiles-1]->height=metres_to_height(atof(limit));
251     }
252    
253    
254     /*++++++++++++++++++++++++++++++++++++++
255     The function that is called when the widthType type is seen
256    
257     char *limit The contents of the 'limit' attribute (or NULL if not defined).
258     ++++++++++++++++++++++++++++++++++++++*/
259    
260     static void width_function(char *limit)
261     {
262     loaded_profiles[nloaded_profiles-1]->width=metres_to_width(atof(limit));
263     }
264    
265    
266     /*++++++++++++++++++++++++++++++++++++++
267     The function that is called when the lengthType type is seen
268    
269     char *limit The contents of the 'limit' attribute (or NULL if not defined).
270     ++++++++++++++++++++++++++++++++++++++*/
271    
272     static void length_function(char *limit)
273     {
274     loaded_profiles[nloaded_profiles-1]->length=metres_to_length(atof(limit));
275     }
276    
277    
278     /*++++++++++++++++++++++++++++++++++++++
279     The function that is called when the profileType type is seen
280    
281     char *name The contents of the 'name' attribute (or NULL if not defined).
282    
283     char *transport The contents of the 'transport' attribute (or NULL if not defined).
284     ++++++++++++++++++++++++++++++++++++++*/
285    
286     static void profile_function(char *name,char *transport)
287     {
288     if((nloaded_profiles%16)==0)
289     loaded_profiles=(Profile**)realloc((void*)loaded_profiles,(nloaded_profiles+16)*sizeof(Profile*));
290    
291     nloaded_profiles++;
292    
293     loaded_profiles[nloaded_profiles-1]=(Profile*)calloc(1,sizeof(Profile));
294    
295     loaded_profiles[nloaded_profiles-1]->name=strcpy(malloc(strlen(name)+1),name);
296     loaded_profiles[nloaded_profiles-1]->transport=TransportType(transport);
297     }
298    
299    
300     /*++++++++++++++++++++++++++++++++++++++
301     The XML profile parser.
302    
303     int ParseXMLProfiles Returns 0 if OK or something else in case of an error.
304    
305     const char *filename The name of the file to read.
306     ++++++++++++++++++++++++++++++++++++++*/
307    
308     int ParseXMLProfiles(const char *filename)
309     {
310     FILE *file=fopen(filename,"r");
311    
312     if(!file)
313     return(1);
314    
315     ParseXML(file,xml_toplevel_tags,2);
316    
317     fclose(file);
318    
319     return(0);
320     }
321    
322    
323     /*++++++++++++++++++++++++++++++++++++++
324 amb 83 Get the profile for a type of transport.
325    
326     Profile *GetProfile Returns a pointer to the profile.
327    
328 amb 341 const char *name The name of the profile.
329 amb 83 ++++++++++++++++++++++++++++++++++++++*/
330    
331 amb 341 Profile *GetProfile(const char *name)
332 amb 83 {
333 amb 341 int i;
334    
335     for(i=0;i<nloaded_profiles;i++)
336     if(!strcmp(loaded_profiles[i]->name,name))
337     return(loaded_profiles[i]);
338    
339     return(NULL);
340 amb 83 }
341    
342    
343     /*++++++++++++++++++++++++++++++++++++++
344 amb 166 Update a profile with highway preference scaling factor.
345    
346     Profile *profile The profile to be updated.
347     ++++++++++++++++++++++++++++++++++++++*/
348    
349     void UpdateProfile(Profile *profile)
350     {
351 amb 168 score_t hmax=0;
352 amb 166 int i;
353    
354 amb 341 profile->allow=ALLOWED(profile->transport);
355    
356 amb 173 /* Normalise the highway preferences into the range 0 -> 1 */
357    
358 amb 300 for(i=1;i<Way_Count;i++)
359 amb 298 {
360     if(profile->highway[i]<0)
361     profile->highway[i]=0;
362    
363 amb 166 if(profile->highway[i]>hmax)
364     hmax=profile->highway[i];
365 amb 298 }
366 amb 166
367 amb 300 for(i=1;i<Way_Count;i++)
368 amb 298 profile->highway[i]/=hmax;
369 amb 173
370 amb 298 /* Normalise the attribute preferences into the range 0 -> 1 */
371    
372     for(i=1;i<Property_Count;i++)
373     {
374     if(profile->props_yes[i]<0)
375     profile->props_yes[i]=0;
376    
377     if(profile->props_yes[i]>100)
378     profile->props_yes[i]=100;
379    
380     profile->props_yes[i]/=100;
381     profile->props_no [i] =1-profile->props_yes[i];
382     }
383    
384 amb 173 /* Find the fastest and most preferred highway type */
385    
386     profile->max_speed=0;
387    
388 amb 300 for(i=1;i<Way_Count;i++)
389 amb 173 if(profile->speed[i]>profile->max_speed)
390     profile->max_speed=profile->speed[i];
391    
392 amb 298 profile->max_pref=1; /* since highway prefs were normalised to 1 */
393 amb 173
394 amb 298 for(i=1;i<Property_Count;i++)
395     if(profile->props_yes[i]>profile->props_no[i])
396     profile->max_pref*=profile->props_yes[i];
397     else if(profile->props_no[i]>profile->props_yes[i])
398     profile->max_pref*=profile->props_no[i];
399 amb 166 }
400    
401    
402     /*++++++++++++++++++++++++++++++++++++++
403 amb 83 Print out a profile.
404    
405     const Profile *profile The profile to print.
406     ++++++++++++++++++++++++++++++++++++++*/
407    
408     void PrintProfile(const Profile *profile)
409     {
410 amb 214 unsigned int i;
411 amb 83
412     printf("Profile\n=======\n");
413    
414     printf("\n");
415    
416     printf("Transport: %s\n",TransportName(profile->transport));
417    
418     printf("\n");
419    
420 amb 300 for(i=1;i<Way_Count;i++)
421 amb 166 printf("Highway %-12s: %3d%%\n",HighwayName(i),(int)profile->highway[i]);
422 amb 83
423     printf("\n");
424    
425 amb 300 for(i=1;i<Way_Count;i++)
426 amb 166 if(profile->highway[i])
427 amb 85 printf("Speed on %-12s: %3d km/h / %2.0f mph\n",HighwayName(i),profile->speed[i],(double)profile->speed[i]/1.6);
428 amb 83
429     printf("\n");
430    
431 amb 298 for(i=1;i<Property_Count;i++)
432     printf("Highway property %-12s: %3d%%\n",PropertyName(i),(int)profile->props_yes[i]);
433    
434     printf("\n");
435    
436 amb 138 printf("Obey one-way : %s\n",profile->oneway?"yes":"no");
437     printf("Minimum weight: %.1f tonnes\n",weight_to_tonnes(profile->weight));
438     printf("Minimum height: %.1f metres\n",height_to_metres(profile->height));
439     printf("Minimum width : %.1f metres\n",width_to_metres(profile->width));
440     printf("Minimum length: %.1f metres\n",length_to_metres(profile->length));
441 amb 83 }
442 amb 129
443    
444     /*++++++++++++++++++++++++++++++++++++++
445 amb 336 Print out the profiles as XML for use as program input.
446     ++++++++++++++++++++++++++++++++++++++*/
447    
448     void PrintProfilesXML(void)
449     {
450     unsigned int i,j;
451     char *padding=" ";
452    
453     printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
454     printf("\n");
455    
456     printf("<routino-profiles xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"routino-profiles.xsd\">\n");
457     printf("\n");
458    
459 amb 341 for(j=0;j<nloaded_profiles;j++)
460 amb 336 {
461 amb 341 printf(" <profile name=\"%s\" transport=\"%s\">\n",loaded_profiles[j]->name,TransportName(loaded_profiles[j]->transport));
462 amb 336
463     printf(" <speeds>\n");
464     for(i=1;i<Way_Count;i++)
465 amb 341 printf(" <speed highway=\"%s\"%s kph=\"%d\" />\n",HighwayName(i),padding+3+strlen(HighwayName(i)),loaded_profiles[j]->speed[i]);
466 amb 336 printf(" </speeds>\n");
467    
468     printf(" <preferences>\n");
469     for(i=1;i<Way_Count;i++)
470 amb 341 printf(" <preference highway=\"%s\"%s percent=\"%.0f\" />\n",HighwayName(i),padding+3+strlen(HighwayName(i)),loaded_profiles[j]->highway[i]);
471 amb 336 printf(" </preferences>\n");
472    
473     printf(" <properties>\n");
474     for(i=1;i<Property_Count;i++)
475 amb 341 printf(" <property type=\"%s\"%s percent=\"%.0f\" />\n",PropertyName(i),padding+6+strlen(PropertyName(i)),loaded_profiles[j]->props_yes[i]);
476 amb 336 printf(" </properties>\n");
477    
478     printf(" <restrictions>\n");
479 amb 341 printf(" <oneway obey=\"%d\" /> \n",loaded_profiles[j]->oneway);
480     printf(" <weight limit=\"%.1f\" />\n",weight_to_tonnes(loaded_profiles[j]->weight));
481     printf(" <height limit=\"%.1f\" />\n",height_to_metres(loaded_profiles[j]->height));
482     printf(" <width limit=\"%.1f\" />\n",width_to_metres(loaded_profiles[j]->width));
483     printf(" <length limit=\"%.1f\" />\n",length_to_metres(loaded_profiles[j]->length));
484 amb 336 printf(" </restrictions>\n");
485    
486     printf(" </profile>\n");
487     printf("\n");
488     }
489    
490     printf("</routino-profiles>\n");
491     }
492    
493    
494     /*++++++++++++++++++++++++++++++++++++++
495 amb 129 Print out the profiles as Javascript for use in a web form.
496     ++++++++++++++++++++++++++++++++++++++*/
497    
498     void PrintProfilesJS(void)
499     {
500 amb 214 unsigned int i,j;
501 amb 129
502 amb 336 printf("var routino={ // contains all default Routino options (generated using \"--help-profile-js\").\n");
503     printf("\n");
504 amb 320
505     printf(" // Default transport type\n");
506     printf(" transport: 'motorcar',\n");
507     printf("\n");
508    
509     printf(" // Transport types\n");
510     printf(" transports: {");
511 amb 341 for(j=0;j<nloaded_profiles;j++)
512     printf("%s%s: %d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),j);
513 amb 320 printf("},\n");
514 amb 129 printf("\n");
515    
516 amb 320 printf(" // Highway types\n");
517     printf(" highways: {");
518 amb 300 for(i=1;i<Way_Count;i++)
519 amb 292 printf("%s%s: %d",i==1?"":", ",HighwayName(i),i);
520 amb 320 printf("},\n");
521 amb 129 printf("\n");
522    
523 amb 320 printf(" // Property types\n");
524     printf(" properties: {");
525 amb 298 for(i=1;i<Property_Count;i++)
526     printf("%s%s: %d",i==1?"":", ",PropertyName(i),i);
527 amb 320 printf("},\n");
528 amb 298 printf("\n");
529    
530 amb 320 printf(" // Restriction types\n");
531     printf(" restrictions: {oneway: 1, weight: 2, height: 3, width: 4, length: 5},\n");
532 amb 138 printf("\n");
533    
534 amb 320 printf(" // Allowed highways\n");
535     printf(" profile_highway: {\n");
536 amb 300 for(i=1;i<Way_Count;i++)
537 amb 129 {
538 amb 320 printf(" %12s: {",HighwayName(i));
539 amb 341 for(j=0;j<nloaded_profiles;j++)
540     printf("%s%s: %3d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),(int)loaded_profiles[j]->highway[i]);
541 amb 300 printf("}%s\n",i==(Way_Count-1)?"":",");
542 amb 129 }
543 amb 320 printf(" },\n");
544 amb 129 printf("\n");
545    
546 amb 320 printf(" // Speed limits\n");
547     printf(" profile_speed: {\n");
548 amb 300 for(i=1;i<Way_Count;i++)
549 amb 129 {
550 amb 320 printf(" %12s: {",HighwayName(i));
551 amb 341 for(j=0;j<nloaded_profiles;j++)
552     printf("%s%s: %3d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),loaded_profiles[j]->speed[i]);
553 amb 300 printf("}%s\n",i==(Way_Count-1)?"":",");
554 amb 129 }
555 amb 320 printf(" },\n");
556 amb 129 printf("\n");
557    
558 amb 320 printf(" // Highway properties\n");
559     printf(" profile_property: {\n");
560 amb 298 for(i=1;i<Property_Count;i++)
561     {
562 amb 320 printf(" %12s: {",PropertyName(i));
563 amb 341 for(j=0;j<nloaded_profiles;j++)
564     printf("%s%s: %3d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),(int)loaded_profiles[j]->props_yes[i]);
565 amb 298 printf("}%s\n",i==(Property_Count-1)?"":",");
566     }
567 amb 320 printf(" },\n");
568 amb 298 printf("\n");
569    
570 amb 320 printf(" // Restrictions\n");
571     printf(" profile_restrictions: {\n");
572     printf(" %12s: {","oneway");
573 amb 341 for(j=0;j<nloaded_profiles;j++)
574     printf("%s%s: %4d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),loaded_profiles[j]->oneway);
575 amb 138 printf("},\n");
576 amb 320 printf(" %12s: {","weight");
577 amb 341 for(j=0;j<nloaded_profiles;j++)
578     printf("%s%s: %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),weight_to_tonnes(loaded_profiles[j]->weight));
579 amb 138 printf("},\n");
580 amb 320 printf(" %12s: {","height");
581 amb 341 for(j=0;j<nloaded_profiles;j++)
582     printf("%s%s: %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),height_to_metres(loaded_profiles[j]->height));
583 amb 138 printf("},\n");
584 amb 320 printf(" %12s: {","width");
585 amb 341 for(j=0;j<nloaded_profiles;j++)
586     printf("%s%s: %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),width_to_metres(loaded_profiles[j]->width));
587 amb 138 printf("},\n");
588 amb 320 printf(" %12s: {","length");
589 amb 341 for(j=0;j<nloaded_profiles;j++)
590     printf("%s%s: %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),length_to_metres(loaded_profiles[j]->length));
591 amb 138 printf("}\n");
592 amb 320 printf(" }\n");
593 amb 129 printf("\n");
594 amb 320
595     printf("}; // end of routino variable\n");
596 amb 129 }
597 amb 145
598    
599     /*++++++++++++++++++++++++++++++++++++++
600     Print out the profiles as Perl for use in a web CGI.
601     ++++++++++++++++++++++++++++++++++++++*/
602    
603     void PrintProfilesPerl(void)
604     {
605 amb 214 unsigned int i,j;
606 amb 145
607 amb 336 printf("$routino={ # contains all default Routino options (generated using \"--help-profile-pl\").\n");
608     printf("\n");
609 amb 320
610     printf(" # Default transport type\n");
611     printf(" transport => 'motorcar',\n");
612     printf("\n");
613    
614     printf(" # Transport types\n");
615     printf(" transports => {");
616 amb 341 for(j=0;j<nloaded_profiles;j++)
617     printf("%s%s => %d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),j);
618 amb 320 printf("},\n");
619 amb 145 printf("\n");
620    
621 amb 320 printf(" # Highway types\n");
622     printf(" highways => {");
623 amb 300 for(i=1;i<Way_Count;i++)
624 amb 320 printf("%s%s => %d",i==1?"":", ",HighwayName(i),i);
625     printf("},\n");
626 amb 145 printf("\n");
627    
628 amb 320 printf(" # Property types\n");
629     printf(" properties => {");
630 amb 298 for(i=1;i<Property_Count;i++)
631 amb 320 printf("%s%s => %d",i==1?"":", ",PropertyName(i),i);
632     printf("},\n");
633 amb 298 printf("\n");
634    
635 amb 320 printf(" # Restriction types\n");
636     printf(" restrictions => {oneway => 1, weight => 2, height => 3, width => 4, length => 5},\n");
637 amb 145 printf("\n");
638    
639 amb 320 printf(" # Allowed highways\n");
640     printf(" profile_highway => {\n");
641 amb 300 for(i=1;i<Way_Count;i++)
642 amb 145 {
643 amb 148 printf(" %12s => {",HighwayName(i));
644 amb 341 for(j=0;j<nloaded_profiles;j++)
645     printf("%s %s => %3d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),(int)loaded_profiles[j]->highway[i]);
646 amb 300 printf("}%s\n",i==(Way_Count-1)?"":",");
647 amb 145 }
648 amb 320 printf(" },\n");
649 amb 145 printf("\n");
650    
651 amb 320 printf(" # Speed limits\n");
652     printf(" profile_speed => {\n");
653 amb 300 for(i=1;i<Way_Count;i++)
654 amb 145 {
655 amb 148 printf(" %12s => {",HighwayName(i));
656 amb 341 for(j=0;j<nloaded_profiles;j++)
657     printf("%s %s => %3d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),loaded_profiles[j]->speed[i]);
658 amb 300 printf("}%s\n",i==(Way_Count-1)?"":",");
659 amb 145 }
660 amb 320 printf(" },\n");
661 amb 145 printf("\n");
662    
663 amb 320 printf(" # Highway properties\n");
664     printf(" profile_property => {\n");
665 amb 298 for(i=1;i<Property_Count;i++)
666     {
667     printf(" %12s => {",PropertyName(i));
668 amb 341 for(j=0;j<nloaded_profiles;j++)
669     printf("%s %s => %3d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),(int)loaded_profiles[j]->props_yes[i]);
670 amb 298 printf("}%s\n",i==(Property_Count-1)?"":",");
671     }
672 amb 320 printf(" },\n");
673 amb 298 printf("\n");
674    
675 amb 320 printf(" # Restrictions\n");
676     printf(" profile_restrictions => {\n");
677     printf(" %12s => {","oneway");
678 amb 341 for(j=0;j<nloaded_profiles;j++)
679     printf("%s %s => %4d",j==1?"":", ",TransportName(loaded_profiles[j]->transport),loaded_profiles[j]->oneway);
680 amb 145 printf("},\n");
681 amb 320 printf(" %12s => {","weight");
682 amb 341 for(j=0;j<nloaded_profiles;j++)
683     printf("%s %s => %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),weight_to_tonnes(loaded_profiles[j]->weight));
684 amb 145 printf("},\n");
685 amb 320 printf(" %12s => {","height");
686 amb 341 for(j=0;j<nloaded_profiles;j++)
687     printf("%s %s => %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),height_to_metres(loaded_profiles[j]->height));
688 amb 145 printf("},\n");
689 amb 320 printf(" %12s => {","width");
690 amb 341 for(j=0;j<nloaded_profiles;j++)
691     printf("%s %s => %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),width_to_metres(loaded_profiles[j]->width));
692 amb 145 printf("},\n");
693 amb 320 printf(" %12s => {","length");
694 amb 341 for(j=0;j<nloaded_profiles;j++)
695     printf("%s %s => %4.1f",j==1?"":", ",TransportName(loaded_profiles[j]->transport),length_to_metres(loaded_profiles[j]->length));
696 amb 145 printf("}\n");
697 amb 320 printf(" },\n");
698 amb 145 printf("\n");
699 amb 320
700     printf("}; # end of routino variable\n");
701 amb 145 }

Properties

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