Routino SVN Repository Browser

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

ViewVC logotype

Annotation of /branches/destination-access/src/router.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1292 - (hide annotations) (download) (as text)
Fri May 3 15:25:56 2013 UTC (11 years, 10 months ago) by amb
Original Path: trunk/src/router.c
File MIME type: text/x-csrc
File size: 24259 byte(s)
Add node, segment, way and turn relation cache for slim mode.  Approx 40%
speed-up for router.

1 amb 2 /***************************************
2     OSM router.
3 amb 151
4     Part of the Routino routing software.
5 amb 2 ******************/ /******************
6 amb 1281 This file Copyright 2008-2013 Andrew M. Bishop
7 amb 2
8 amb 151 This program is free software: you can redistribute it and/or modify
9     it under the terms of the GNU Affero General Public License as published by
10     the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12    
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     GNU Affero General Public License for more details.
17    
18     You should have received a copy of the GNU Affero General Public License
19     along with this program. If not, see <http://www.gnu.org/licenses/>.
20 amb 2 ***************************************/
21    
22    
23     #include <stdio.h>
24 amb 31 #include <string.h>
25 amb 2 #include <stdlib.h>
26 amb 130 #include <ctype.h>
27 amb 2
28 amb 96 #include "types.h"
29 amb 115 #include "nodes.h"
30     #include "segments.h"
31 amb 109 #include "ways.h"
32 amb 542 #include "relations.h"
33 amb 2
34 amb 449 #include "files.h"
35 amb 519 #include "logging.h"
36 amb 449 #include "functions.h"
37 amb 532 #include "fakes.h"
38 amb 449 #include "translations.h"
39     #include "profiles.h"
40 amb 2
41 amb 449
42 amb 1278 /*+ To help when debugging +*/
43     #define DEBUG 0
44    
45 amb 303 /*+ The maximum distance from the specified point to search for a node or segment (in km). +*/
46 amb 321 #define MAXSEARCH 1
47 amb 242
48 amb 303
49 amb 680 /* Global variables */
50    
51 amb 113 /*+ The option not to print any progress information. +*/
52 amb 107 int option_quiet=0;
53    
54 amb 324 /*+ The options to select the format of the output. +*/
55 amb 380 int option_html=0,option_gpx_track=0,option_gpx_route=0,option_text=0,option_text_all=0,option_none=0;
56 amb 324
57 amb 113 /*+ The option to calculate the quickest route insted of the shortest. +*/
58     int option_quickest=0;
59 amb 107
60 amb 113
61 amb 342 /* Local functions */
62    
63 amb 490 static void print_usage(int detail,const char *argerr,const char *err);
64 amb 342
65    
66     /*++++++++++++++++++++++++++++++++++++++
67     The main program for the router.
68     ++++++++++++++++++++++++++++++++++++++*/
69    
70 amb 2 int main(int argc,char** argv)
71     {
72 amb 95 Nodes *OSMNodes;
73     Segments *OSMSegments;
74     Ways *OSMWays;
75 amb 542 Relations*OSMRelations;
76 amb 242 Results *results[NWAYPOINTS+1]={NULL};
77     int point_used[NWAYPOINTS+1]={0};
78 amb 675 double point_lon[NWAYPOINTS+1],point_lat[NWAYPOINTS+1];
79     double heading=-999;
80 amb 342 int help_profile=0,help_profile_xml=0,help_profile_json=0,help_profile_pl=0;
81 amb 359 char *dirname=NULL,*prefix=NULL;
82     char *profiles=NULL,*profilename=NULL;
83     char *translations=NULL,*language=NULL;
84 amb 315 int exactnodes=0;
85 amb 82 Transport transport=Transport_None;
86 amb 342 Profile *profile=NULL;
87 amb 605 index_t start_node=NO_NODE,finish_node=NO_NODE;
88     index_t join_segment=NO_SEGMENT;
89 amb 303 int arg,point;
90 amb 2
91 amb 44 /* Parse the command line arguments */
92 amb 2
93 amb 145 if(argc<2)
94 amb 490 print_usage(0,NULL,NULL);
95 amb 75
96 amb 341 /* Get the non-routing, general program options */
97 amb 75
98 amb 165 for(arg=1;arg<argc;arg++)
99 amb 44 {
100 amb 324 if(!strcmp(argv[arg],"--help"))
101 amb 490 print_usage(1,NULL,NULL);
102 amb 324 else if(!strcmp(argv[arg],"--help-profile"))
103     help_profile=1;
104 amb 336 else if(!strcmp(argv[arg],"--help-profile-xml"))
105     help_profile_xml=1;
106 amb 342 else if(!strcmp(argv[arg],"--help-profile-json"))
107     help_profile_json=1;
108     else if(!strcmp(argv[arg],"--help-profile-perl"))
109 amb 324 help_profile_pl=1;
110     else if(!strncmp(argv[arg],"--dir=",6))
111     dirname=&argv[arg][6];
112     else if(!strncmp(argv[arg],"--prefix=",9))
113     prefix=&argv[arg][9];
114 amb 341 else if(!strncmp(argv[arg],"--profiles=",11))
115     profiles=&argv[arg][11];
116 amb 359 else if(!strncmp(argv[arg],"--translations=",15))
117     translations=&argv[arg][15];
118 amb 324 else if(!strcmp(argv[arg],"--exact-nodes-only"))
119     exactnodes=1;
120     else if(!strcmp(argv[arg],"--quiet"))
121     option_quiet=1;
122 amb 519 else if(!strcmp(argv[arg],"--loggable"))
123     option_loggable=1;
124 amb 324 else if(!strcmp(argv[arg],"--output-html"))
125     option_html=1;
126     else if(!strcmp(argv[arg],"--output-gpx-track"))
127     option_gpx_track=1;
128     else if(!strcmp(argv[arg],"--output-gpx-route"))
129     option_gpx_route=1;
130     else if(!strcmp(argv[arg],"--output-text"))
131     option_text=1;
132     else if(!strcmp(argv[arg],"--output-text-all"))
133     option_text_all=1;
134 amb 380 else if(!strcmp(argv[arg],"--output-none"))
135     option_none=1;
136 amb 341 else if(!strncmp(argv[arg],"--profile=",10))
137     profilename=&argv[arg][10];
138 amb 359 else if(!strncmp(argv[arg],"--language=",11))
139     language=&argv[arg][11];
140 amb 341 else if(!strncmp(argv[arg],"--transport=",12))
141     {
142     transport=TransportType(&argv[arg][12]);
143    
144     if(transport==Transport_None)
145 amb 490 print_usage(0,argv[arg],NULL);
146 amb 341 }
147     else
148     continue;
149    
150     argv[arg]=NULL;
151     }
152    
153     /* Load in the profiles */
154    
155     if(transport==Transport_None)
156     transport=Transport_Motorcar;
157    
158 amb 407 if(profiles)
159     {
160     if(!ExistsFile(profiles))
161     {
162     fprintf(stderr,"Error: The '--profiles' option specifies a file that does not exist.\n");
163     return(1);
164     }
165     }
166     else
167     {
168     if(ExistsFile(FileName(dirname,prefix,"profiles.xml")))
169     profiles=FileName(dirname,prefix,"profiles.xml");
170 amb 1191 else if(ExistsFile(FileName(DATADIR,NULL,"profiles.xml")))
171 amb 481 profiles=FileName(DATADIR,NULL,"profiles.xml");
172 amb 407 else
173     {
174     fprintf(stderr,"Error: The '--profiles' option was not used and the default 'profiles.xml' does not exist.\n");
175     return(1);
176     }
177     }
178 amb 341
179 amb 481 if(ParseXMLProfiles(profiles))
180 amb 341 {
181     fprintf(stderr,"Error: Cannot read the profiles in the file '%s'.\n",profiles);
182     return(1);
183     }
184    
185 amb 680 /* Choose the selected profile. */
186    
187 amb 341 if(profilename)
188 amb 342 {
189 amb 341 profile=GetProfile(profilename);
190    
191 amb 342 if(!profile)
192     {
193     fprintf(stderr,"Error: Cannot find a profile called '%s' in '%s'.\n",profilename,profiles);
194     return(1);
195     }
196     }
197     else
198 amb 341 profile=GetProfile(TransportName(transport));
199    
200     if(!profile)
201     {
202     profile=(Profile*)calloc(1,sizeof(Profile));
203     profile->transport=transport;
204     }
205    
206     /* Parse the other command line arguments */
207    
208     for(arg=1;arg<argc;arg++)
209     {
210     if(!argv[arg])
211     continue;
212 amb 325 else if(!strcmp(argv[arg],"--shortest"))
213     option_quickest=0;
214     else if(!strcmp(argv[arg],"--quickest"))
215     option_quickest=1;
216 amb 324 else if(isdigit(argv[arg][0]) ||
217 amb 165 ((argv[arg][0]=='-' || argv[arg][0]=='+') && isdigit(argv[arg][1])))
218 amb 130 {
219 amb 303 for(point=1;point<=NWAYPOINTS;point++)
220     if(point_used[point]!=3)
221 amb 165 {
222 amb 303 if(point_used[point]==0)
223 amb 165 {
224 amb 303 point_lon[point]=degrees_to_radians(atof(argv[arg]));
225     point_used[point]=1;
226 amb 165 }
227 amb 303 else /* if(point_used[point]==1) */
228 amb 165 {
229 amb 303 point_lat[point]=degrees_to_radians(atof(argv[arg]));
230     point_used[point]=3;
231 amb 165 }
232     break;
233     }
234     }
235 amb 242 else if(!strncmp(argv[arg],"--lon",5) && isdigit(argv[arg][5]))
236     {
237     char *p=&argv[arg][6];
238     while(isdigit(*p)) p++;
239     if(*p++!='=')
240 amb 490 print_usage(0,argv[arg],NULL);
241 amb 242
242 amb 303 point=atoi(&argv[arg][5]);
243     if(point>NWAYPOINTS || point_used[point]&1)
244 amb 490 print_usage(0,argv[arg],NULL);
245 amb 242
246 amb 303 point_lon[point]=degrees_to_radians(atof(p));
247     point_used[point]+=1;
248 amb 130 }
249 amb 242 else if(!strncmp(argv[arg],"--lat",5) && isdigit(argv[arg][5]))
250     {
251     char *p=&argv[arg][6];
252     while(isdigit(*p)) p++;
253     if(*p++!='=')
254 amb 490 print_usage(0,argv[arg],NULL);
255 amb 242
256 amb 303 point=atoi(&argv[arg][5]);
257     if(point>NWAYPOINTS || point_used[point]&2)
258 amb 490 print_usage(0,argv[arg],NULL);
259 amb 242
260 amb 303 point_lat[point]=degrees_to_radians(atof(p));
261     point_used[point]+=2;
262 amb 165 }
263 amb 675 else if(!strncmp(argv[arg],"--heading=",10))
264     {
265     double h=atof(&argv[arg][10]);
266    
267     if(h>=-360 && h<=360)
268     {
269     heading=h;
270    
271     if(heading<0) heading+=360;
272     }
273     }
274 amb 165 else if(!strncmp(argv[arg],"--transport=",12))
275 amb 324 ; /* Done this already */
276 amb 165 else if(!strncmp(argv[arg],"--highway-",10))
277 amb 75 {
278 amb 130 Highway highway;
279 amb 165 char *equal=strchr(argv[arg],'=');
280 amb 130 char *string;
281 amb 82
282 amb 130 if(!equal)
283 amb 490 print_usage(0,argv[arg],NULL);
284 amb 130
285 amb 165 string=strcpy((char*)malloc(strlen(argv[arg])),argv[arg]+10);
286     string[equal-argv[arg]-10]=0;
287 amb 130
288     highway=HighwayType(string);
289    
290 amb 1174 if(highway==Highway_None)
291 amb 490 print_usage(0,argv[arg],NULL);
292 amb 82
293 amb 341 profile->highway[highway]=atof(equal+1);
294 amb 298
295     free(string);
296 amb 75 }
297 amb 165 else if(!strncmp(argv[arg],"--speed-",8))
298 amb 82 {
299     Highway highway;
300 amb 165 char *equal=strchr(argv[arg],'=');
301 amb 82 char *string;
302    
303     if(!equal)
304 amb 490 print_usage(0,argv[arg],NULL);
305 amb 82
306 amb 165 string=strcpy((char*)malloc(strlen(argv[arg])),argv[arg]+8);
307     string[equal-argv[arg]-8]=0;
308 amb 82
309     highway=HighwayType(string);
310    
311 amb 1174 if(highway==Highway_None)
312 amb 490 print_usage(0,argv[arg],NULL);
313 amb 82
314 amb 341 profile->speed[highway]=kph_to_speed(atof(equal+1));
315 amb 298
316     free(string);
317 amb 82 }
318 amb 298 else if(!strncmp(argv[arg],"--property-",11))
319     {
320     Property property;
321     char *equal=strchr(argv[arg],'=');
322     char *string;
323    
324     if(!equal)
325 amb 490 print_usage(0,argv[arg],NULL);
326 amb 298
327     string=strcpy((char*)malloc(strlen(argv[arg])),argv[arg]+11);
328     string[equal-argv[arg]-11]=0;
329    
330     property=PropertyType(string);
331    
332 amb 1174 if(property==Property_None)
333 amb 490 print_usage(0,argv[arg],NULL);
334 amb 298
335 amb 341 profile->props_yes[property]=atof(equal+1);
336 amb 298
337     free(string);
338     }
339 amb 165 else if(!strncmp(argv[arg],"--oneway=",9))
340 amb 341 profile->oneway=!!atoi(&argv[arg][9]);
341 amb 622 else if(!strncmp(argv[arg],"--turns=",8))
342     profile->turns=!!atoi(&argv[arg][8]);
343 amb 165 else if(!strncmp(argv[arg],"--weight=",9))
344 amb 341 profile->weight=tonnes_to_weight(atof(&argv[arg][9]));
345 amb 165 else if(!strncmp(argv[arg],"--height=",9))
346 amb 341 profile->height=metres_to_height(atof(&argv[arg][9]));
347 amb 165 else if(!strncmp(argv[arg],"--width=",8))
348 amb 341 profile->width=metres_to_width(atof(&argv[arg][8]));
349 amb 165 else if(!strncmp(argv[arg],"--length=",9))
350 amb 341 profile->length=metres_to_length(atof(&argv[arg][9]));
351 amb 44 else
352 amb 490 print_usage(0,argv[arg],NULL);
353 amb 44 }
354    
355 amb 303 for(point=1;point<=NWAYPOINTS;point++)
356     if(point_used[point]==1 || point_used[point]==2)
357 amb 490 print_usage(0,NULL,"All waypoints must have latitude and longitude.");
358 amb 165
359 amb 680 /* Print one of the profiles if requested */
360    
361 amb 82 if(help_profile)
362     {
363 amb 341 PrintProfile(profile);
364 amb 82
365     return(0);
366     }
367 amb 336 else if(help_profile_xml)
368     {
369     PrintProfilesXML();
370    
371     return(0);
372     }
373 amb 342 else if(help_profile_json)
374 amb 129 {
375 amb 342 PrintProfilesJSON();
376 amb 82
377 amb 129 return(0);
378     }
379 amb 145 else if(help_profile_pl)
380     {
381     PrintProfilesPerl();
382 amb 129
383 amb 145 return(0);
384     }
385    
386 amb 359 /* Load in the translations */
387    
388 amb 380 if(option_html==0 && option_gpx_track==0 && option_gpx_route==0 && option_text==0 && option_text_all==0 && option_none==0)
389     option_html=option_gpx_track=option_gpx_route=option_text=option_text_all=1;
390 amb 359
391 amb 380 if(option_html || option_gpx_route || option_gpx_track)
392 amb 359 {
393 amb 481 if(translations)
394 amb 380 {
395 amb 481 if(!ExistsFile(translations))
396     {
397     fprintf(stderr,"Error: The '--translations' option specifies a file that does not exist.\n");
398     return(1);
399     }
400 amb 380 }
401 amb 481 else
402     {
403     if(ExistsFile(FileName(dirname,prefix,"translations.xml")))
404     translations=FileName(dirname,prefix,"translations.xml");
405     else if(ExistsFile(FileName(DATADIR,NULL,"translations.xml")))
406     translations=FileName(DATADIR,NULL,"translations.xml");
407     else
408     {
409     fprintf(stderr,"Error: The '--translations' option was not used and the default 'translations.xml' does not exist.\n");
410     return(1);
411     }
412     }
413 amb 380
414 amb 481 if(ParseXMLTranslations(translations,language))
415 amb 380 {
416     fprintf(stderr,"Error: Cannot read the translations in the file '%s'.\n",translations);
417     return(1);
418     }
419 amb 359 }
420    
421 amb 329 /* Load in the data - Note: No error checking because Load*List() will call exit() in case of an error. */
422 amb 2
423 amb 329 OSMNodes=LoadNodeList(FileName(dirname,prefix,"nodes.mem"));
424 amb 95
425 amb 329 OSMSegments=LoadSegmentList(FileName(dirname,prefix,"segments.mem"));
426 amb 100
427 amb 329 OSMWays=LoadWayList(FileName(dirname,prefix,"ways.mem"));
428 amb 66
429 amb 542 OSMRelations=LoadRelationList(FileName(dirname,prefix,"relations.mem"));
430    
431 amb 410 if(UpdateProfile(profile,OSMWays))
432 amb 307 {
433 amb 410 fprintf(stderr,"Error: Profile is invalid or not compatible with database.\n");
434 amb 307 return(1);
435     }
436    
437 amb 303 /* Loop through all pairs of points */
438 amb 99
439 amb 303 for(point=1;point<=NWAYPOINTS;point++)
440 amb 107 {
441 amb 239 Results *begin,*end;
442 amb 315 distance_t distmax=km_to_distance(MAXSEARCH);
443     distance_t distmin;
444 amb 456 index_t segment=NO_SEGMENT;
445 amb 303 index_t node1,node2;
446 amb 99
447 amb 303 if(point_used[point]!=3)
448 amb 165 continue;
449 amb 107
450 amb 303 /* Find the closest point */
451 amb 107
452 amb 605 start_node=finish_node;
453 amb 165
454 amb 315 if(exactnodes)
455     {
456 amb 605 finish_node=FindClosestNode(OSMNodes,OSMSegments,OSMWays,point_lat[point],point_lon[point],distmax,profile,&distmin);
457 amb 315 }
458     else
459     {
460     distance_t dist1,dist2;
461 amb 165
462 amb 456 segment=FindClosestSegment(OSMNodes,OSMSegments,OSMWays,point_lat[point],point_lon[point],distmax,profile,&distmin,&node1,&node2,&dist1,&dist2);
463    
464     if(segment!=NO_SEGMENT)
465 amb 608 finish_node=CreateFakes(OSMNodes,OSMSegments,point,LookupSegment(OSMSegments,segment,1),node1,node2,dist1,dist2);
466 amb 421 else
467 amb 605 finish_node=NO_NODE;
468 amb 315 }
469 amb 303
470 amb 605 if(finish_node==NO_NODE)
471 amb 107 {
472 amb 303 fprintf(stderr,"Error: Cannot find node close to specified point %d.\n",point);
473 amb 107 return(1);
474     }
475    
476     if(!option_quiet)
477     {
478 amb 219 double lat,lon;
479 amb 107
480 amb 605 if(IsFakeNode(finish_node))
481     GetFakeLatLong(finish_node,&lat,&lon);
482 amb 303 else
483 amb 1291 GetLatLong(OSMNodes,finish_node,NULL,&lat,&lon);
484 amb 107
485 amb 605 if(IsFakeNode(finish_node))
486 amb 790 printf("Point %d is segment %"Pindex_t" (node %"Pindex_t" -> %"Pindex_t"): %3.6f %4.6f = %2.3f km\n",point,segment,node1,node2,
487 amb 315 radians_to_degrees(lon),radians_to_degrees(lat),distance_to_km(distmin));
488 amb 303 else
489 amb 790 printf("Point %d is node %"Pindex_t": %3.6f %4.6f = %2.3f km\n",point,finish_node,
490 amb 315 radians_to_degrees(lon),radians_to_degrees(lat),distance_to_km(distmin));
491 amb 107 }
492    
493 amb 605 if(start_node==NO_NODE)
494 amb 165 continue;
495    
496 amb 605 if(start_node==finish_node)
497 amb 431 continue;
498    
499 amb 675 if(heading!=-999 && join_segment==NO_SEGMENT)
500     join_segment=FindClosestSegmentHeading(OSMNodes,OSMSegments,OSMWays,start_node,heading,profile);
501    
502 amb 239 /* Calculate the beginning of the route */
503 amb 165
504 amb 1278 begin=FindStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,start_node,join_segment,finish_node);
505 amb 107
506 amb 1278 if(begin)
507 amb 77 {
508 amb 1278 /* Check if the end of the route was reached */
509 amb 696
510 amb 1281 if(begin->finish_node!=NO_NODE)
511 amb 1278 results[point]=ExtendStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,finish_node);
512 amb 696 }
513 amb 1278 else
514     {
515     if(join_segment!=NO_SEGMENT)
516     {
517     /* Try again but allow a U-turn at the start waypoint -
518     this solves the problem of facing a dead-end that contains no super-nodes. */
519 amb 696
520 amb 1278 join_segment=NO_SEGMENT;
521    
522     begin=FindStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,start_node,join_segment,finish_node);
523     }
524    
525     if(begin)
526     {
527     /* Check if the end of the route was reached */
528    
529 amb 1281 if(begin->finish_node!=NO_NODE)
530 amb 1278 results[point]=ExtendStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,finish_node);
531     }
532     else
533     {
534     fprintf(stderr,"Error: Cannot find initial section of route compatible with profile.\n");
535     return(1);
536     }
537 amb 112 }
538 amb 239
539 amb 1278 /* Calculate the rest of the route */
540 amb 828
541 amb 1278 if(!results[point])
542 amb 239 {
543 amb 686 Results *middle;
544 amb 48
545 amb 239 /* Calculate the end of the route */
546 amb 34
547 amb 721 end=FindFinishRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,finish_node);
548 amb 34
549 amb 531 if(!end)
550 amb 112 {
551 amb 531 fprintf(stderr,"Error: Cannot find final section of route compatible with profile.\n");
552     return(1);
553 amb 112 }
554    
555 amb 239 /* Calculate the middle of the route */
556    
557 amb 721 middle=FindMiddleRoute(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,end);
558 amb 734
559 amb 1278 if(!middle && join_segment!=NO_SEGMENT)
560 amb 678 {
561 amb 734 /* Try again but allow a U-turn at the start waypoint -
562 amb 696 this solves the problem of facing a dead-end that contains some super-nodes. */
563 amb 239
564 amb 678 FreeResultsList(begin);
565    
566 amb 1278 begin=FindStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,start_node,NO_SEGMENT,finish_node);
567 amb 678
568 amb 1278 if(begin)
569     middle=FindMiddleRoute(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,end);
570 amb 678 }
571    
572 amb 317 FreeResultsList(end);
573    
574 amb 686 if(!middle)
575 amb 165 {
576 amb 1278 fprintf(stderr,"Error: Cannot find super-route compatible with profile.\n");
577     return(1);
578 amb 165 }
579 amb 1278
580     results[point]=CombineRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,middle);
581    
582     if(!results[point])
583 amb 828 {
584 amb 1278 fprintf(stderr,"Error: Cannot create combined route following super-route.\n");
585     return(1);
586     }
587 amb 34
588 amb 1278 FreeResultsList(begin);
589 amb 317
590 amb 1278 FreeResultsList(middle);
591     }
592 amb 722
593 amb 1278 #if DEBUG
594     Result *r=FindResult(results[point],results[point]->start_node,results[point]->prev_segment);
595 amb 828
596 amb 1278 printf("The final route is:\n");
597 amb 828
598 amb 1278 while(r)
599 amb 828 {
600 amb 1278 printf(" node=%"Pindex_t" segment=%"Pindex_t" score=%f\n",r->node,r->segment,r->score);
601 amb 828
602 amb 1278 r=r->next;
603 amb 34 }
604 amb 1278 #endif
605 amb 605
606     join_segment=results[point]->last_segment;
607 amb 31 }
608    
609 amb 629 if(!option_quiet)
610     {
611     printf("Routed OK\n");
612     fflush(stdout);
613     }
614    
615 amb 239 /* Print out the combined route */
616 amb 164
617 amb 380 if(!option_none)
618     PrintRoute(results,NWAYPOINTS,OSMNodes,OSMSegments,OSMWays,profile);
619 amb 164
620 amb 1283 /* Destroy the remaining results lists */
621    
622     for(point=1;point<=NWAYPOINTS;point++)
623     if(results[point])
624     FreeResultsList(results[point]);
625    
626 amb 1292 #if SLIM
627     DeleteNodeCache(OSMNodes->cache);
628     DeleteSegmentCache(OSMSegments->cache);
629     DeleteWayCache(OSMWays->cache);
630     DeleteTurnRelationCache(OSMRelations->cache);
631     #endif
632    
633 amb 2 return(0);
634     }
635 amb 303
636    
637     /*++++++++++++++++++++++++++++++++++++++
638 amb 342 Print out the usage information.
639    
640     int detail The level of detail to use - 0 = low, 1 = high.
641 amb 490
642     const char *argerr The argument that gave the error (if there is one).
643    
644     const char *err Other error message (if there is one).
645 amb 342 ++++++++++++++++++++++++++++++++++++++*/
646    
647 amb 490 static void print_usage(int detail,const char *argerr,const char *err)
648 amb 342 {
649     fprintf(stderr,
650     "Usage: router [--help | --help-profile | --help-profile-xml |\n"
651     " --help-profile-json | --help-profile-perl ]\n"
652 amb 359 " [--dir=<dirname>] [--prefix=<name>]\n"
653     " [--profiles=<filename>] [--translations=<filename>]\n"
654 amb 342 " [--exact-nodes-only]\n"
655 amb 519 " [--loggable | --quiet]\n"
656 amb 362 " [--language=<lang>]\n"
657 amb 342 " [--output-html]\n"
658     " [--output-gpx-track] [--output-gpx-route]\n"
659     " [--output-text] [--output-text-all]\n"
660 amb 380 " [--output-none]\n"
661 amb 342 " [--profile=<name>]\n"
662     " [--transport=<transport>]\n"
663     " [--shortest | --quickest]\n"
664     " --lon1=<longitude> --lat1=<latitude>\n"
665     " --lon2=<longitude> --lon2=<latitude>\n"
666     " [ ... --lon99=<longitude> --lon99=<latitude>]\n"
667     " [--highway-<highway>=<preference> ...]\n"
668     " [--speed-<highway>=<speed> ...]\n"
669     " [--property-<property>=<preference> ...]\n"
670 amb 622 " [--oneway=(0|1)] [--turns=(0|1)]\n"
671 amb 342 " [--weight=<weight>]\n"
672     " [--height=<height>] [--width=<width>] [--length=<length>]\n");
673    
674 amb 490 if(argerr)
675     fprintf(stderr,
676     "\n"
677     "Error with command line parameter: %s\n",argerr);
678    
679 amb 491 if(err)
680 amb 490 fprintf(stderr,
681     "\n"
682     "Error: %s\n",err);
683    
684 amb 342 if(detail)
685     fprintf(stderr,
686     "\n"
687     "--help Prints this information.\n"
688     "--help-profile Prints the information about the selected profile.\n"
689     "--help-profile-xml Prints all loaded profiles in XML format.\n"
690     "--help-profile-json Prints all loaded profiles in JSON format.\n"
691     "--help-profile-perl Prints all loaded profiles in Perl format.\n"
692     "\n"
693     "--dir=<dirname> The directory containing the routing database.\n"
694     "--prefix=<name> The filename prefix for the routing database.\n"
695 amb 481 "--profiles=<filename> The name of the XML file containing the profiles\n"
696 amb 488 " (defaults to 'profiles.xml' with '--dir' and\n"
697 amb 481 " '--prefix' options or the file installed in\n"
698     " '" DATADIR "').\n"
699     "--translations=<fname> The name of the XML file containing the translations\n"
700 amb 488 " (defaults to 'translations.xml' with '--dir' and\n"
701 amb 481 " '--prefix' options or the file installed in\n"
702     " '" DATADIR "').\n"
703 amb 342 "\n"
704     "--exact-nodes-only Only route between nodes (don't find closest segment).\n"
705     "\n"
706 amb 519 "--loggable Print progress messages suitable for logging to file.\n"
707 amb 380 "--quiet Don't print any screen output when running.\n"
708 amb 519 "\n"
709 amb 362 "--language=<lang> Use the translations for specified language.\n"
710 amb 342 "--output-html Write an HTML description of the route.\n"
711     "--output-gpx-track Write a GPX track file with all route points.\n"
712     "--output-gpx-route Write a GPX route file with interesting junctions.\n"
713     "--output-text Write a plain text file with interesting junctions.\n"
714     "--output-text-all Write a plain test file with all route points.\n"
715 amb 380 "--output-none Don't write any output files or read any translations.\n"
716 amb 342 " (If no output option is given then all are written.)\n"
717     "\n"
718     "--profile=<name> Select the loaded profile with this name.\n"
719     "--transport=<transport> Select the transport to use (selects the profile\n"
720     " named after the transport if '--profile' is not used.)\n"
721     "\n"
722     "--shortest Find the shortest route between the waypoints.\n"
723     "--quickest Find the quickest route between the waypoints.\n"
724     "\n"
725     "--lon<n>=<longitude> Specify the longitude of the n'th waypoint.\n"
726     "--lat<n>=<latitude> Specify the latitude of the n'th waypoint.\n"
727     "\n"
728 amb 675 "--heading=<bearing> Initial compass bearing at lowest numbered waypoint.\n"
729     "\n"
730 amb 342 " Routing preference options\n"
731     "--highway-<highway>=<preference> * preference for highway type (%%).\n"
732     "--speed-<highway>=<speed> * speed for highway type (km/h).\n"
733     "--property-<property>=<preference> * preference for proprty type (%%).\n"
734 amb 622 "--oneway=(0|1) * oneway restrictions are to be obeyed.\n"
735     "--turns=(0|1) * turn restrictions are to be obeyed.\n"
736 amb 342 "--weight=<weight> * maximum weight limit (tonnes).\n"
737     "--height=<height> * maximum height limit (metres).\n"
738     "--width=<width> * maximum width limit (metres).\n"
739     "--length=<length> * maximum length limit (metres).\n"
740     "\n"
741     "<transport> defaults to motorcar but can be set to:\n"
742     "%s"
743     "\n"
744     "<highway> can be selected from:\n"
745     "%s"
746     "\n"
747     "<property> can be selected from:\n"
748     "%s",
749     TransportList(),HighwayList(),PropertyList());
750    
751     exit(!detail);
752     }

Properties

Name Value
cvs:description Router.