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