Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/router.c
Parent Directory
|
Revision Log
Revision 1312 -
(show annotations)
(download)
(as text)
Sat May 11 11:12:56 2013 UTC (11 years, 10 months ago) by amb
File MIME type: text/x-csrc
File size: 24246 byte(s)
Sat May 11 11:12:56 2013 UTC (11 years, 10 months ago) by amb
File MIME type: text/x-csrc
File size: 24246 byte(s)
Add functions to destroy the node/segment/way/relation lists and don't call them from the end of the router by default.
1 | /*************************************** |
2 | OSM router. |
3 | |
4 | Part of the Routino routing software. |
5 | ******************/ /****************** |
6 | This file Copyright 2008-2013 Andrew M. Bishop |
7 | |
8 | 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 | ***************************************/ |
21 | |
22 | |
23 | #include <stdio.h> |
24 | #include <string.h> |
25 | #include <stdlib.h> |
26 | #include <ctype.h> |
27 | |
28 | #include "types.h" |
29 | #include "nodes.h" |
30 | #include "segments.h" |
31 | #include "ways.h" |
32 | #include "relations.h" |
33 | |
34 | #include "files.h" |
35 | #include "logging.h" |
36 | #include "functions.h" |
37 | #include "fakes.h" |
38 | #include "translations.h" |
39 | #include "profiles.h" |
40 | |
41 | |
42 | /*+ To help when debugging +*/ |
43 | #define DEBUG 0 |
44 | |
45 | /*+ The maximum distance from the specified point to search for a node or segment (in km). +*/ |
46 | #define MAXSEARCH 1 |
47 | |
48 | |
49 | /* Global variables */ |
50 | |
51 | /*+ The option not to print any progress information. +*/ |
52 | int option_quiet=0; |
53 | |
54 | /*+ The options to select the format of the output. +*/ |
55 | int option_html=0,option_gpx_track=0,option_gpx_route=0,option_text=0,option_text_all=0,option_none=0; |
56 | |
57 | /*+ The option to calculate the quickest route insted of the shortest. +*/ |
58 | int option_quickest=0; |
59 | |
60 | |
61 | /* Local functions */ |
62 | |
63 | static void print_usage(int detail,const char *argerr,const char *err); |
64 | |
65 | |
66 | /*++++++++++++++++++++++++++++++++++++++ |
67 | The main program for the router. |
68 | ++++++++++++++++++++++++++++++++++++++*/ |
69 | |
70 | int main(int argc,char** argv) |
71 | { |
72 | Nodes *OSMNodes; |
73 | Segments *OSMSegments; |
74 | Ways *OSMWays; |
75 | Relations*OSMRelations; |
76 | Results *results[NWAYPOINTS+1]={NULL}; |
77 | int point_used[NWAYPOINTS+1]={0}; |
78 | double point_lon[NWAYPOINTS+1],point_lat[NWAYPOINTS+1]; |
79 | double heading=-999; |
80 | int help_profile=0,help_profile_xml=0,help_profile_json=0,help_profile_pl=0; |
81 | char *dirname=NULL,*prefix=NULL; |
82 | char *profiles=NULL,*profilename=NULL; |
83 | char *translations=NULL,*language=NULL; |
84 | int exactnodes=0; |
85 | Transport transport=Transport_None; |
86 | Profile *profile=NULL; |
87 | index_t start_node=NO_NODE,finish_node=NO_NODE; |
88 | index_t join_segment=NO_SEGMENT; |
89 | int arg,point; |
90 | |
91 | /* Parse the command line arguments */ |
92 | |
93 | if(argc<2) |
94 | print_usage(0,NULL,NULL); |
95 | |
96 | /* Get the non-routing, general program options */ |
97 | |
98 | for(arg=1;arg<argc;arg++) |
99 | { |
100 | if(!strcmp(argv[arg],"--help")) |
101 | print_usage(1,NULL,NULL); |
102 | else if(!strcmp(argv[arg],"--help-profile")) |
103 | help_profile=1; |
104 | else if(!strcmp(argv[arg],"--help-profile-xml")) |
105 | help_profile_xml=1; |
106 | else if(!strcmp(argv[arg],"--help-profile-json")) |
107 | help_profile_json=1; |
108 | else if(!strcmp(argv[arg],"--help-profile-perl")) |
109 | 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 | else if(!strncmp(argv[arg],"--profiles=",11)) |
115 | profiles=&argv[arg][11]; |
116 | else if(!strncmp(argv[arg],"--translations=",15)) |
117 | translations=&argv[arg][15]; |
118 | else if(!strcmp(argv[arg],"--exact-nodes-only")) |
119 | exactnodes=1; |
120 | else if(!strcmp(argv[arg],"--quiet")) |
121 | option_quiet=1; |
122 | else if(!strcmp(argv[arg],"--loggable")) |
123 | option_loggable=1; |
124 | 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 | else if(!strcmp(argv[arg],"--output-none")) |
135 | option_none=1; |
136 | else if(!strncmp(argv[arg],"--profile=",10)) |
137 | profilename=&argv[arg][10]; |
138 | else if(!strncmp(argv[arg],"--language=",11)) |
139 | language=&argv[arg][11]; |
140 | else if(!strncmp(argv[arg],"--transport=",12)) |
141 | { |
142 | transport=TransportType(&argv[arg][12]); |
143 | |
144 | if(transport==Transport_None) |
145 | print_usage(0,argv[arg],NULL); |
146 | } |
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 | 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 | else if(ExistsFile(FileName(DATADIR,NULL,"profiles.xml"))) |
171 | profiles=FileName(DATADIR,NULL,"profiles.xml"); |
172 | 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 | |
179 | if(ParseXMLProfiles(profiles)) |
180 | { |
181 | fprintf(stderr,"Error: Cannot read the profiles in the file '%s'.\n",profiles); |
182 | return(1); |
183 | } |
184 | |
185 | /* Choose the selected profile. */ |
186 | |
187 | if(profilename) |
188 | { |
189 | profile=GetProfile(profilename); |
190 | |
191 | 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 | 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 | else if(!strcmp(argv[arg],"--shortest")) |
213 | option_quickest=0; |
214 | else if(!strcmp(argv[arg],"--quickest")) |
215 | option_quickest=1; |
216 | else if(isdigit(argv[arg][0]) || |
217 | ((argv[arg][0]=='-' || argv[arg][0]=='+') && isdigit(argv[arg][1]))) |
218 | { |
219 | for(point=1;point<=NWAYPOINTS;point++) |
220 | if(point_used[point]!=3) |
221 | { |
222 | if(point_used[point]==0) |
223 | { |
224 | point_lon[point]=degrees_to_radians(atof(argv[arg])); |
225 | point_used[point]=1; |
226 | } |
227 | else /* if(point_used[point]==1) */ |
228 | { |
229 | point_lat[point]=degrees_to_radians(atof(argv[arg])); |
230 | point_used[point]=3; |
231 | } |
232 | break; |
233 | } |
234 | } |
235 | 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 | print_usage(0,argv[arg],NULL); |
241 | |
242 | point=atoi(&argv[arg][5]); |
243 | if(point>NWAYPOINTS || point_used[point]&1) |
244 | print_usage(0,argv[arg],NULL); |
245 | |
246 | point_lon[point]=degrees_to_radians(atof(p)); |
247 | point_used[point]+=1; |
248 | } |
249 | 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 | print_usage(0,argv[arg],NULL); |
255 | |
256 | point=atoi(&argv[arg][5]); |
257 | if(point>NWAYPOINTS || point_used[point]&2) |
258 | print_usage(0,argv[arg],NULL); |
259 | |
260 | point_lat[point]=degrees_to_radians(atof(p)); |
261 | point_used[point]+=2; |
262 | } |
263 | 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 | else if(!strncmp(argv[arg],"--transport=",12)) |
275 | ; /* Done this already */ |
276 | else if(!strncmp(argv[arg],"--highway-",10)) |
277 | { |
278 | Highway highway; |
279 | char *equal=strchr(argv[arg],'='); |
280 | char *string; |
281 | |
282 | if(!equal) |
283 | print_usage(0,argv[arg],NULL); |
284 | |
285 | string=strcpy((char*)malloc(strlen(argv[arg])),argv[arg]+10); |
286 | string[equal-argv[arg]-10]=0; |
287 | |
288 | highway=HighwayType(string); |
289 | |
290 | if(highway==Highway_None) |
291 | print_usage(0,argv[arg],NULL); |
292 | |
293 | profile->highway[highway]=atof(equal+1); |
294 | |
295 | free(string); |
296 | } |
297 | else if(!strncmp(argv[arg],"--speed-",8)) |
298 | { |
299 | Highway highway; |
300 | char *equal=strchr(argv[arg],'='); |
301 | char *string; |
302 | |
303 | if(!equal) |
304 | print_usage(0,argv[arg],NULL); |
305 | |
306 | string=strcpy((char*)malloc(strlen(argv[arg])),argv[arg]+8); |
307 | string[equal-argv[arg]-8]=0; |
308 | |
309 | highway=HighwayType(string); |
310 | |
311 | if(highway==Highway_None) |
312 | print_usage(0,argv[arg],NULL); |
313 | |
314 | profile->speed[highway]=kph_to_speed(atof(equal+1)); |
315 | |
316 | free(string); |
317 | } |
318 | 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 | print_usage(0,argv[arg],NULL); |
326 | |
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 | if(property==Property_None) |
333 | print_usage(0,argv[arg],NULL); |
334 | |
335 | profile->props_yes[property]=atof(equal+1); |
336 | |
337 | free(string); |
338 | } |
339 | else if(!strncmp(argv[arg],"--oneway=",9)) |
340 | profile->oneway=!!atoi(&argv[arg][9]); |
341 | else if(!strncmp(argv[arg],"--turns=",8)) |
342 | profile->turns=!!atoi(&argv[arg][8]); |
343 | else if(!strncmp(argv[arg],"--weight=",9)) |
344 | profile->weight=tonnes_to_weight(atof(&argv[arg][9])); |
345 | else if(!strncmp(argv[arg],"--height=",9)) |
346 | profile->height=metres_to_height(atof(&argv[arg][9])); |
347 | else if(!strncmp(argv[arg],"--width=",8)) |
348 | profile->width=metres_to_width(atof(&argv[arg][8])); |
349 | else if(!strncmp(argv[arg],"--length=",9)) |
350 | profile->length=metres_to_length(atof(&argv[arg][9])); |
351 | else |
352 | print_usage(0,argv[arg],NULL); |
353 | } |
354 | |
355 | for(point=1;point<=NWAYPOINTS;point++) |
356 | if(point_used[point]==1 || point_used[point]==2) |
357 | print_usage(0,NULL,"All waypoints must have latitude and longitude."); |
358 | |
359 | /* Print one of the profiles if requested */ |
360 | |
361 | if(help_profile) |
362 | { |
363 | PrintProfile(profile); |
364 | |
365 | return(0); |
366 | } |
367 | else if(help_profile_xml) |
368 | { |
369 | PrintProfilesXML(); |
370 | |
371 | return(0); |
372 | } |
373 | else if(help_profile_json) |
374 | { |
375 | PrintProfilesJSON(); |
376 | |
377 | return(0); |
378 | } |
379 | else if(help_profile_pl) |
380 | { |
381 | PrintProfilesPerl(); |
382 | |
383 | return(0); |
384 | } |
385 | |
386 | /* Load in the translations */ |
387 | |
388 | 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 | |
391 | if(option_html || option_gpx_route || option_gpx_track) |
392 | { |
393 | if(translations) |
394 | { |
395 | if(!ExistsFile(translations)) |
396 | { |
397 | fprintf(stderr,"Error: The '--translations' option specifies a file that does not exist.\n"); |
398 | return(1); |
399 | } |
400 | } |
401 | 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 | |
414 | if(ParseXMLTranslations(translations,language)) |
415 | { |
416 | fprintf(stderr,"Error: Cannot read the translations in the file '%s'.\n",translations); |
417 | return(1); |
418 | } |
419 | } |
420 | |
421 | /* Load in the data - Note: No error checking because Load*List() will call exit() in case of an error. */ |
422 | |
423 | OSMNodes=LoadNodeList(FileName(dirname,prefix,"nodes.mem")); |
424 | |
425 | OSMSegments=LoadSegmentList(FileName(dirname,prefix,"segments.mem")); |
426 | |
427 | OSMWays=LoadWayList(FileName(dirname,prefix,"ways.mem")); |
428 | |
429 | OSMRelations=LoadRelationList(FileName(dirname,prefix,"relations.mem")); |
430 | |
431 | if(UpdateProfile(profile,OSMWays)) |
432 | { |
433 | fprintf(stderr,"Error: Profile is invalid or not compatible with database.\n"); |
434 | return(1); |
435 | } |
436 | |
437 | /* Loop through all pairs of points */ |
438 | |
439 | for(point=1;point<=NWAYPOINTS;point++) |
440 | { |
441 | Results *begin,*end; |
442 | distance_t distmax=km_to_distance(MAXSEARCH); |
443 | distance_t distmin; |
444 | index_t segment=NO_SEGMENT; |
445 | index_t node1,node2; |
446 | |
447 | if(point_used[point]!=3) |
448 | continue; |
449 | |
450 | /* Find the closest point */ |
451 | |
452 | start_node=finish_node; |
453 | |
454 | if(exactnodes) |
455 | { |
456 | finish_node=FindClosestNode(OSMNodes,OSMSegments,OSMWays,point_lat[point],point_lon[point],distmax,profile,&distmin); |
457 | } |
458 | else |
459 | { |
460 | distance_t dist1,dist2; |
461 | |
462 | 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 | finish_node=CreateFakes(OSMNodes,OSMSegments,point,LookupSegment(OSMSegments,segment,1),node1,node2,dist1,dist2); |
466 | else |
467 | finish_node=NO_NODE; |
468 | } |
469 | |
470 | if(finish_node==NO_NODE) |
471 | { |
472 | fprintf(stderr,"Error: Cannot find node close to specified point %d.\n",point); |
473 | return(1); |
474 | } |
475 | |
476 | if(!option_quiet) |
477 | { |
478 | double lat,lon; |
479 | |
480 | if(IsFakeNode(finish_node)) |
481 | GetFakeLatLong(finish_node,&lat,&lon); |
482 | else |
483 | GetLatLong(OSMNodes,finish_node,NULL,&lat,&lon); |
484 | |
485 | if(IsFakeNode(finish_node)) |
486 | 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 | radians_to_degrees(lon),radians_to_degrees(lat),distance_to_km(distmin)); |
488 | else |
489 | printf("Point %d is node %"Pindex_t": %3.6f %4.6f = %2.3f km\n",point,finish_node, |
490 | radians_to_degrees(lon),radians_to_degrees(lat),distance_to_km(distmin)); |
491 | } |
492 | |
493 | if(start_node==NO_NODE) |
494 | continue; |
495 | |
496 | if(start_node==finish_node) |
497 | continue; |
498 | |
499 | if(heading!=-999 && join_segment==NO_SEGMENT) |
500 | join_segment=FindClosestSegmentHeading(OSMNodes,OSMSegments,OSMWays,start_node,heading,profile); |
501 | |
502 | /* Calculate the beginning of the route */ |
503 | |
504 | begin=FindStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,start_node,join_segment,finish_node); |
505 | |
506 | if(begin) |
507 | { |
508 | /* Check if the end of the route was reached */ |
509 | |
510 | if(begin->finish_node!=NO_NODE) |
511 | results[point]=ExtendStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,finish_node); |
512 | } |
513 | 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 | |
520 | 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 | if(begin->finish_node!=NO_NODE) |
530 | 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 | } |
538 | |
539 | /* Calculate the rest of the route */ |
540 | |
541 | if(!results[point]) |
542 | { |
543 | Results *middle; |
544 | |
545 | /* Calculate the end of the route */ |
546 | |
547 | end=FindFinishRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,finish_node); |
548 | |
549 | if(!end) |
550 | { |
551 | fprintf(stderr,"Error: Cannot find final section of route compatible with profile.\n"); |
552 | return(1); |
553 | } |
554 | |
555 | /* Calculate the middle of the route */ |
556 | |
557 | middle=FindMiddleRoute(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,end); |
558 | |
559 | if(!middle && join_segment!=NO_SEGMENT) |
560 | { |
561 | /* Try again but allow a U-turn at the start waypoint - |
562 | this solves the problem of facing a dead-end that contains some super-nodes. */ |
563 | |
564 | FreeResultsList(begin); |
565 | |
566 | begin=FindStartRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,start_node,NO_SEGMENT,finish_node); |
567 | |
568 | if(begin) |
569 | middle=FindMiddleRoute(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,end); |
570 | } |
571 | |
572 | FreeResultsList(end); |
573 | |
574 | if(!middle) |
575 | { |
576 | fprintf(stderr,"Error: Cannot find super-route compatible with profile.\n"); |
577 | return(1); |
578 | } |
579 | |
580 | results[point]=CombineRoutes(OSMNodes,OSMSegments,OSMWays,OSMRelations,profile,begin,middle); |
581 | |
582 | if(!results[point]) |
583 | { |
584 | fprintf(stderr,"Error: Cannot create combined route following super-route.\n"); |
585 | return(1); |
586 | } |
587 | |
588 | FreeResultsList(begin); |
589 | |
590 | FreeResultsList(middle); |
591 | } |
592 | |
593 | #if DEBUG |
594 | Result *r=FindResult(results[point],results[point]->start_node,results[point]->prev_segment); |
595 | |
596 | printf("The final route is:\n"); |
597 | |
598 | while(r) |
599 | { |
600 | printf(" node=%"Pindex_t" segment=%"Pindex_t" score=%f\n",r->node,r->segment,r->score); |
601 | |
602 | r=r->next; |
603 | } |
604 | #endif |
605 | |
606 | join_segment=results[point]->last_segment; |
607 | } |
608 | |
609 | if(!option_quiet) |
610 | { |
611 | printf("Routed OK\n"); |
612 | fflush(stdout); |
613 | } |
614 | |
615 | /* Print out the combined route */ |
616 | |
617 | if(!option_none) |
618 | PrintRoute(results,NWAYPOINTS,OSMNodes,OSMSegments,OSMWays,profile); |
619 | |
620 | /* Destroy the remaining results lists and data structures */ |
621 | |
622 | #if 0 |
623 | |
624 | for(point=1;point<=NWAYPOINTS;point++) |
625 | if(results[point]) |
626 | FreeResultsList(results[point]); |
627 | |
628 | DestroyNodeList(OSMNodes); |
629 | DestroySegmentList(OSMSegments); |
630 | DestroyWayList(OSMWays); |
631 | DestroyRelationList(OSMRelations); |
632 | |
633 | #endif |
634 | |
635 | return(0); |
636 | } |
637 | |
638 | |
639 | /*++++++++++++++++++++++++++++++++++++++ |
640 | Print out the usage information. |
641 | |
642 | int detail The level of detail to use - 0 = low, 1 = high. |
643 | |
644 | const char *argerr The argument that gave the error (if there is one). |
645 | |
646 | const char *err Other error message (if there is one). |
647 | ++++++++++++++++++++++++++++++++++++++*/ |
648 | |
649 | static void print_usage(int detail,const char *argerr,const char *err) |
650 | { |
651 | fprintf(stderr, |
652 | "Usage: router [--help | --help-profile | --help-profile-xml |\n" |
653 | " --help-profile-json | --help-profile-perl ]\n" |
654 | " [--dir=<dirname>] [--prefix=<name>]\n" |
655 | " [--profiles=<filename>] [--translations=<filename>]\n" |
656 | " [--exact-nodes-only]\n" |
657 | " [--loggable | --quiet]\n" |
658 | " [--language=<lang>]\n" |
659 | " [--output-html]\n" |
660 | " [--output-gpx-track] [--output-gpx-route]\n" |
661 | " [--output-text] [--output-text-all]\n" |
662 | " [--output-none]\n" |
663 | " [--profile=<name>]\n" |
664 | " [--transport=<transport>]\n" |
665 | " [--shortest | --quickest]\n" |
666 | " --lon1=<longitude> --lat1=<latitude>\n" |
667 | " --lon2=<longitude> --lon2=<latitude>\n" |
668 | " [ ... --lon99=<longitude> --lon99=<latitude>]\n" |
669 | " [--highway-<highway>=<preference> ...]\n" |
670 | " [--speed-<highway>=<speed> ...]\n" |
671 | " [--property-<property>=<preference> ...]\n" |
672 | " [--oneway=(0|1)] [--turns=(0|1)]\n" |
673 | " [--weight=<weight>]\n" |
674 | " [--height=<height>] [--width=<width>] [--length=<length>]\n"); |
675 | |
676 | if(argerr) |
677 | fprintf(stderr, |
678 | "\n" |
679 | "Error with command line parameter: %s\n",argerr); |
680 | |
681 | if(err) |
682 | fprintf(stderr, |
683 | "\n" |
684 | "Error: %s\n",err); |
685 | |
686 | if(detail) |
687 | fprintf(stderr, |
688 | "\n" |
689 | "--help Prints this information.\n" |
690 | "--help-profile Prints the information about the selected profile.\n" |
691 | "--help-profile-xml Prints all loaded profiles in XML format.\n" |
692 | "--help-profile-json Prints all loaded profiles in JSON format.\n" |
693 | "--help-profile-perl Prints all loaded profiles in Perl format.\n" |
694 | "\n" |
695 | "--dir=<dirname> The directory containing the routing database.\n" |
696 | "--prefix=<name> The filename prefix for the routing database.\n" |
697 | "--profiles=<filename> The name of the XML file containing the profiles\n" |
698 | " (defaults to 'profiles.xml' with '--dir' and\n" |
699 | " '--prefix' options or the file installed in\n" |
700 | " '" DATADIR "').\n" |
701 | "--translations=<fname> The name of the XML file containing the translations\n" |
702 | " (defaults to 'translations.xml' with '--dir' and\n" |
703 | " '--prefix' options or the file installed in\n" |
704 | " '" DATADIR "').\n" |
705 | "\n" |
706 | "--exact-nodes-only Only route between nodes (don't find closest segment).\n" |
707 | "\n" |
708 | "--loggable Print progress messages suitable for logging to file.\n" |
709 | "--quiet Don't print any screen output when running.\n" |
710 | "\n" |
711 | "--language=<lang> Use the translations for specified language.\n" |
712 | "--output-html Write an HTML description of the route.\n" |
713 | "--output-gpx-track Write a GPX track file with all route points.\n" |
714 | "--output-gpx-route Write a GPX route file with interesting junctions.\n" |
715 | "--output-text Write a plain text file with interesting junctions.\n" |
716 | "--output-text-all Write a plain test file with all route points.\n" |
717 | "--output-none Don't write any output files or read any translations.\n" |
718 | " (If no output option is given then all are written.)\n" |
719 | "\n" |
720 | "--profile=<name> Select the loaded profile with this name.\n" |
721 | "--transport=<transport> Select the transport to use (selects the profile\n" |
722 | " named after the transport if '--profile' is not used.)\n" |
723 | "\n" |
724 | "--shortest Find the shortest route between the waypoints.\n" |
725 | "--quickest Find the quickest route between the waypoints.\n" |
726 | "\n" |
727 | "--lon<n>=<longitude> Specify the longitude of the n'th waypoint.\n" |
728 | "--lat<n>=<latitude> Specify the latitude of the n'th waypoint.\n" |
729 | "\n" |
730 | "--heading=<bearing> Initial compass bearing at lowest numbered waypoint.\n" |
731 | "\n" |
732 | " Routing preference options\n" |
733 | "--highway-<highway>=<preference> * preference for highway type (%%).\n" |
734 | "--speed-<highway>=<speed> * speed for highway type (km/h).\n" |
735 | "--property-<property>=<preference> * preference for proprty type (%%).\n" |
736 | "--oneway=(0|1) * oneway restrictions are to be obeyed.\n" |
737 | "--turns=(0|1) * turn restrictions are to be obeyed.\n" |
738 | "--weight=<weight> * maximum weight limit (tonnes).\n" |
739 | "--height=<height> * maximum height limit (metres).\n" |
740 | "--width=<width> * maximum width limit (metres).\n" |
741 | "--length=<length> * maximum length limit (metres).\n" |
742 | "\n" |
743 | "<transport> defaults to motorcar but can be set to:\n" |
744 | "%s" |
745 | "\n" |
746 | "<highway> can be selected from:\n" |
747 | "%s" |
748 | "\n" |
749 | "<property> can be selected from:\n" |
750 | "%s", |
751 | TransportList(),HighwayList(),PropertyList()); |
752 | |
753 | exit(!detail); |
754 | } |
Properties
Name | Value |
---|---|
cvs:description | Router. |