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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1889 - (hide annotations) (download) (as text)
Tue Jul 12 18:46:17 2016 UTC (8 years, 9 months ago) by amb
File MIME type: text/x-csrc
File size: 22875 byte(s)
Improve the error message when the default profiles, translations or
tagging files cannot be found.

1 amb 2 /***************************************
2     OSM planet file splitter.
3 amb 151
4     Part of the Routino routing software.
5 amb 2 ******************/ /******************
6 amb 1889 This file Copyright 2008-2016 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     #include <stdlib.h>
25 amb 60 #include <string.h>
26 amb 330 #include <errno.h>
27 amb 2
28 amb 1797 #include "version.h"
29    
30 amb 449 #include "types.h"
31     #include "ways.h"
32    
33 amb 199 #include "typesx.h"
34 amb 109 #include "nodesx.h"
35     #include "segmentsx.h"
36     #include "waysx.h"
37 amb 498 #include "relationsx.h"
38 amb 109 #include "superx.h"
39 amb 949 #include "prunex.h"
40 amb 449
41     #include "files.h"
42 amb 519 #include "logging.h"
43 amb 1319 #include "errorlogx.h"
44 amb 449 #include "functions.h"
45 amb 940 #include "osmparser.h"
46 amb 395 #include "tagging.h"
47 amb 1194 #include "uncompress.h"
48 amb 2
49    
50 amb 395 /* Global variables */
51 amb 284
52 amb 256 /*+ The name of the temporary directory. +*/
53 amb 284 char *option_tmpdirname=NULL;
54 amb 249
55 amb 358 /*+ The amount of RAM to use for filesorting. +*/
56     size_t option_filesort_ramsize=0;
57 amb 284
58 amb 991 /*+ The number of threads to use for filesorting. +*/
59     int option_filesort_threads=1;
60 amb 358
61 amb 991
62 amb 342 /* Local functions */
63    
64 amb 490 static void print_usage(int detail,const char *argerr,const char *err);
65 amb 342
66    
67     /*++++++++++++++++++++++++++++++++++++++
68 amb 395 The main program for the planetsplitter.
69 amb 342 ++++++++++++++++++++++++++++++++++++++*/
70    
71 amb 2 int main(int argc,char** argv)
72     {
73 amb 1314 NodesX *OSMNodes;
74     SegmentsX *OSMSegments,*SuperSegments=NULL,*MergedSegments=NULL;
75     WaysX *OSMWays;
76     RelationsX *OSMRelations;
77 amb 498 int iteration=0,quit=0;
78 amb 861 int max_iterations=5;
79 amb 804 char *dirname=NULL,*prefix=NULL,*tagging=NULL,*errorlog=NULL;
80 amb 1140 int option_parse_only=0,option_process_only=0;
81 amb 1171 int option_append=0,option_keep=0,option_changes=0;
82 amb 498 int option_filenames=0;
83 amb 975 int option_prune_isolated=500,option_prune_short=5,option_prune_straight=3;
84 amb 498 int arg;
85 amb 26
86 amb 1398 printf_program_start();
87 amb 982
88 amb 82 /* Parse the command line arguments */
89    
90 amb 327 for(arg=1;arg<argc;arg++)
91 amb 60 {
92 amb 1797 if(!strcmp(argv[arg],"--version"))
93     print_usage(-1,NULL,NULL);
94     else if(!strcmp(argv[arg],"--help"))
95 amb 490 print_usage(1,NULL,NULL);
96 amb 1202 else if(!strncmp(argv[arg],"--dir=",6))
97     dirname=&argv[arg][6];
98     else if(!strncmp(argv[arg],"--prefix=",9))
99     prefix=&argv[arg][9];
100 amb 358 else if(!strncmp(argv[arg],"--sort-ram-size=",16))
101     option_filesort_ramsize=atoi(&argv[arg][16]);
102 amb 991 #if defined(USE_PTHREADS) && USE_PTHREADS
103     else if(!strncmp(argv[arg],"--sort-threads=",15))
104     option_filesort_threads=atoi(&argv[arg][15]);
105     #endif
106 amb 327 else if(!strncmp(argv[arg],"--tmpdir=",9))
107     option_tmpdirname=&argv[arg][9];
108 amb 1202 else if(!strncmp(argv[arg],"--tagging=",10))
109     tagging=&argv[arg][10];
110     else if(!strcmp(argv[arg],"--loggable"))
111     option_loggable=1;
112     else if(!strcmp(argv[arg],"--logtime"))
113     option_logtime=1;
114 amb 1598 else if(!strcmp(argv[arg],"--logmemory"))
115     option_logmemory=1;
116 amb 1202 else if(!strcmp(argv[arg],"--errorlog"))
117     errorlog="error.log";
118     else if(!strncmp(argv[arg],"--errorlog=",11))
119     errorlog=&argv[arg][11];
120 amb 327 else if(!strcmp(argv[arg],"--parse-only"))
121 amb 326 option_parse_only=1;
122 amb 327 else if(!strcmp(argv[arg],"--process-only"))
123 amb 326 option_process_only=1;
124 amb 1120 else if(!strcmp(argv[arg],"--append"))
125     option_append=1;
126 amb 1167 else if(!strcmp(argv[arg],"--keep"))
127     option_keep=1;
128 amb 1140 else if(!strcmp(argv[arg],"--changes"))
129     option_changes=1;
130 amb 327 else if(!strncmp(argv[arg],"--max-iterations=",17))
131     max_iterations=atoi(&argv[arg][17]);
132 amb 953 else if(!strncmp(argv[arg],"--prune",7))
133     {
134 amb 975 if(!strcmp(&argv[arg][7],"-none"))
135     option_prune_isolated=option_prune_short=option_prune_straight=0;
136 amb 953 else if(!strncmp(&argv[arg][7],"-isolated=",10))
137 amb 975 option_prune_isolated=atoi(&argv[arg][17]);
138 amb 964 else if(!strncmp(&argv[arg][7],"-short=",7))
139 amb 975 option_prune_short=atoi(&argv[arg][14]);
140 amb 966 else if(!strncmp(&argv[arg][7],"-straight=",10))
141 amb 975 option_prune_straight=atoi(&argv[arg][17]);
142 amb 953 else
143     print_usage(0,argv[arg],NULL);
144     }
145 amb 327 else if(argv[arg][0]=='-' && argv[arg][1]=='-')
146 amb 490 print_usage(0,argv[arg],NULL);
147 amb 327 else
148     option_filenames++;
149 amb 60 }
150 amb 26
151 amb 395 /* Check the specified command line options */
152    
153 amb 326 if(option_parse_only && option_process_only)
154 amb 490 print_usage(0,NULL,"Cannot use '--parse-only' and '--process-only' at the same time.");
155 amb 326
156 amb 1120 if(option_append && option_process_only)
157     print_usage(0,NULL,"Cannot use '--append' and '--process-only' at the same time.");
158    
159 amb 327 if(option_filenames && option_process_only)
160 amb 490 print_usage(0,NULL,"Cannot use '--process-only' and filenames at the same time.");
161 amb 327
162 amb 1224 if(!option_filenames && !option_process_only)
163     print_usage(0,NULL,"File names must be specified unless using '--process-only'");
164    
165 amb 358 if(!option_filesort_ramsize)
166     {
167 amb 452 #if SLIM
168 amb 940 option_filesort_ramsize=64*1024*1024;
169 amb 452 #else
170 amb 940 option_filesort_ramsize=256*1024*1024;
171 amb 452 #endif
172 amb 358 }
173     else
174     option_filesort_ramsize*=1024*1024;
175    
176 amb 284 if(!option_tmpdirname)
177 amb 252 {
178     if(!dirname)
179 amb 284 option_tmpdirname=".";
180 amb 252 else
181 amb 284 option_tmpdirname=dirname;
182 amb 252 }
183    
184 amb 989 if(!option_process_only)
185 amb 395 {
186 amb 989 if(tagging)
187 amb 481 {
188 amb 989 if(!ExistsFile(tagging))
189     {
190 amb 1889 fprintf(stderr,"Error: The '--tagging' option specifies a file '%s' that does not exist.\n",tagging);
191 amb 1359 exit(EXIT_FAILURE);
192 amb 989 }
193 amb 481 }
194     else
195     {
196 amb 1784 tagging=FileName(dirname,prefix,"tagging.xml");
197    
198     if(!ExistsFile(tagging))
199     {
200 amb 1889 char *defaulttagging=FileName(ROUTINO_DATADIR,NULL,"tagging.xml");
201 amb 1784
202 amb 1889 if(!ExistsFile(defaulttagging))
203 amb 1784 {
204 amb 1889 fprintf(stderr,"Error: The '--tagging' option was not used and the files '%s' and '%s' do not exist.\n",tagging,defaulttagging);
205 amb 1784 exit(EXIT_FAILURE);
206     }
207 amb 1889
208     free(tagging);
209     tagging=defaulttagging;
210 amb 989 }
211     }
212    
213     if(ParseXMLTaggingRules(tagging))
214     {
215     fprintf(stderr,"Error: Cannot read the tagging rules in the file '%s'.\n",tagging);
216 amb 1359 exit(EXIT_FAILURE);
217 amb 481 }
218     }
219 amb 395
220 amb 498 /* Create new node, segment, way and relation variables */
221 amb 82
222 amb 1314 OSMNodes=NewNodeList(option_append||option_changes,option_process_only);
223 amb 275
224 amb 1314 OSMWays=NewWayList(option_append||option_changes,option_process_only);
225 amb 26
226 amb 1314 OSMRelations=NewRelationList(option_append||option_changes,option_process_only);
227 amb 498
228 amb 804 /* Create the error log file */
229    
230 amb 809 if(errorlog)
231 amb 1313 open_errorlog(FileName(dirname,prefix,errorlog),option_append||option_changes||option_process_only,option_keep);
232 amb 804
233 amb 89 /* Parse the file */
234 amb 2
235 amb 989 if(!option_process_only)
236     {
237 amb 1224 for(arg=1;arg<argc;arg++)
238 amb 989 {
239 amb 1224 int fd;
240 amb 1227 char *filename,*p;
241 amb 327
242 amb 1224 if(argv[arg][0]=='-' && argv[arg][1]=='-')
243     continue;
244 amb 327
245 amb 1227 filename=strcpy(malloc(strlen(argv[arg])+1),argv[arg]);
246 amb 327
247 amb 1412 fd=OpenFile(filename);
248 amb 1227
249     if((p=strstr(filename,".bz2")) && !strcmp(p,".bz2"))
250     {
251 amb 1224 fd=Uncompress_Bzip2(fd);
252 amb 1227 *p=0;
253     }
254 amb 1194
255 amb 1227 if((p=strstr(filename,".gz")) && !strcmp(p,".gz"))
256     {
257 amb 1224 fd=Uncompress_Gzip(fd);
258 amb 1227 *p=0;
259     }
260 amb 1196
261 amb 1514 if((p=strstr(filename,".xz")) && !strcmp(p,".xz"))
262     {
263     fd=Uncompress_Xz(fd);
264     *p=0;
265     }
266    
267 amb 1224 if(option_changes)
268     {
269 amb 1227 printf("\nParse OSC Data [%s]\n==============\n\n",filename);
270 amb 1224 fflush(stdout);
271    
272 amb 1227 if((p=strstr(filename,".pbf")) && !strcmp(p,".pbf"))
273 amb 1140 {
274 amb 1226 logassert(0,"Unable to read a PBF file to apply changes (format does not permit this)");
275 amb 1140 }
276 amb 1227 else if((p=strstr(filename,".o5c")) && !strcmp(p,".o5c"))
277     {
278 amb 1339 if(ParseO5CFile(fd,OSMNodes,OSMWays,OSMRelations))
279 amb 1227 exit(EXIT_FAILURE);
280     }
281 amb 1140 else
282     {
283 amb 1339 if(ParseOSCFile(fd,OSMNodes,OSMWays,OSMRelations))
284 amb 1224 exit(EXIT_FAILURE);
285 amb 1140 }
286 amb 989 }
287 amb 1224 else
288 amb 1140 {
289 amb 1227 printf("\nParse OSM Data [%s]\n==============\n\n",filename);
290 amb 1140 fflush(stdout);
291 amb 2
292 amb 1227 if((p=strstr(filename,".pbf")) && !strcmp(p,".pbf"))
293 amb 1224 {
294 amb 1339 if(ParsePBFFile(fd,OSMNodes,OSMWays,OSMRelations))
295 amb 1224 exit(EXIT_FAILURE);
296     }
297 amb 1227 else if((p=strstr(filename,".o5m")) && !strcmp(p,".o5m"))
298     {
299 amb 1339 if(ParseO5MFile(fd,OSMNodes,OSMWays,OSMRelations))
300 amb 1227 exit(EXIT_FAILURE);
301     }
302 amb 1224 else
303     {
304 amb 1339 if(ParseOSMFile(fd,OSMNodes,OSMWays,OSMRelations))
305 amb 1224 exit(EXIT_FAILURE);
306     }
307 amb 1140 }
308    
309 amb 1412 CloseFile(fd);
310 amb 1227
311     free(filename);
312 amb 989 }
313 amb 80
314 amb 989 DeleteXMLTaggingRules();
315     }
316    
317 amb 1314 FinishNodeList(OSMNodes);
318     FinishWayList(OSMWays);
319     FinishRelationList(OSMRelations);
320 amb 1139
321 amb 1157 if(option_parse_only)
322 amb 326 {
323 amb 1314 FreeNodeList(OSMNodes,1);
324     FreeWayList(OSMWays,1);
325     FreeRelationList(OSMRelations,1);
326 amb 326
327 amb 1599 exit(EXIT_SUCCESS);
328 amb 326 }
329    
330 amb 1120
331 amb 1151 /* Sort the data */
332 amb 229
333 amb 1151 printf("\nSort OSM Data\n=============\n\n");
334 amb 227 fflush(stdout);
335 amb 8
336 amb 1355 /* Sort the nodes, ways and relations */
337 amb 263
338 amb 1314 SortNodeList(OSMNodes);
339 amb 263
340 amb 1314 SortWayList(OSMWays);
341 amb 87
342 amb 1314 SortRelationList(OSMRelations);
343 amb 559
344 amb 1151 /* Process the data */
345    
346     printf("\nProcess OSM Data\n================\n\n");
347     fflush(stdout);
348    
349 amb 1609 /* Remove non-highway nodes by looking through the ways (must be before splitting the ways) */
350 amb 1350
351     RemoveNonHighwayNodes(OSMNodes,OSMWays,option_keep||option_changes);
352    
353 amb 1609 /* Separate the segments and way names and sort them (must be before processing the segments) */
354 amb 1339
355 amb 1349 OSMSegments=SplitWays(OSMWays,OSMNodes,option_keep||option_changes);
356 amb 1339
357 amb 1348 SortWayNames(OSMWays);
358    
359 amb 1339 SortSegmentList(OSMSegments);
360    
361 amb 1609 /* Process the segments and index them (must be before processing relations) */
362 amb 549
363 amb 1351 ProcessSegments(OSMSegments,OSMNodes,OSMWays);
364 amb 549
365 amb 1352 IndexSegments(OSMSegments,OSMNodes,OSMWays);
366    
367 amb 1353 /* Process the route relations and turn relations (must be before compacting the ways) */
368 amb 498
369 amb 1314 ProcessRouteRelations(OSMRelations,OSMWays,option_keep||option_changes);
370 amb 498
371 amb 1353 ProcessTurnRelations(OSMRelations,OSMNodes,OSMSegments,OSMWays,option_keep||option_changes);
372 amb 498
373 amb 1609 /* Compact the ways */
374 amb 643
375 amb 1314 CompactWayList(OSMWays,OSMSegments);
376 amb 1100
377 amb 1614 /* Sort the nodes and segments geographically */
378 amb 1100
379 amb 1614 SortNodeListGeographically(OSMNodes);
380    
381     SortSegmentListGeographically(OSMSegments,OSMNodes);
382    
383     /* Re-index the segments */
384    
385 amb 1314 IndexSegments(OSMSegments,OSMNodes,OSMWays);
386 amb 1100
387 amb 1614 /* Sort the turn relations geographically */
388    
389 amb 1784 SortTurnRelationListGeographically(OSMRelations,OSMNodes,OSMSegments,0);
390 amb 1614
391 amb 1609 /* Prune unwanted nodes/segments */
392 amb 645
393 amb 975 if(option_prune_straight || option_prune_isolated || option_prune_short)
394 amb 949 {
395 amb 1098 printf("\nPrune Unneeded Data\n===================\n\n");
396     fflush(stdout);
397    
398 amb 1604 if(option_prune_straight)
399     {
400     StartPruning(OSMNodes,OSMSegments,OSMWays);
401 amb 1431
402 amb 1451 PruneStraightHighwayNodes(OSMNodes,OSMSegments,OSMWays,option_prune_straight);
403    
404 amb 1604 FinishPruning(OSMNodes,OSMSegments,OSMWays);
405    
406     RemovePrunedNodes(OSMNodes,OSMSegments);
407     RemovePrunedSegments(OSMSegments,OSMWays);
408     CompactWayList(OSMWays,OSMSegments);
409     RemovePrunedTurnRelations(OSMRelations,OSMNodes);
410    
411     IndexSegments(OSMSegments,OSMNodes,OSMWays);
412     }
413    
414 amb 975 if(option_prune_isolated)
415 amb 1604 {
416     StartPruning(OSMNodes,OSMSegments,OSMWays);
417    
418 amb 1314 PruneIsolatedRegions(OSMNodes,OSMSegments,OSMWays,option_prune_isolated);
419 amb 953
420 amb 1604 FinishPruning(OSMNodes,OSMSegments,OSMWays);
421    
422     RemovePrunedNodes(OSMNodes,OSMSegments);
423     RemovePrunedSegments(OSMSegments,OSMWays);
424     CompactWayList(OSMWays,OSMSegments);
425     RemovePrunedTurnRelations(OSMRelations,OSMNodes);
426    
427     IndexSegments(OSMSegments,OSMNodes,OSMWays);
428     }
429    
430 amb 975 if(option_prune_short)
431 amb 1604 {
432     StartPruning(OSMNodes,OSMSegments,OSMWays);
433    
434 amb 1314 PruneShortSegments(OSMNodes,OSMSegments,OSMWays,option_prune_short);
435 amb 964
436 amb 1604 FinishPruning(OSMNodes,OSMSegments,OSMWays);
437 amb 1431
438 amb 1604 RemovePrunedNodes(OSMNodes,OSMSegments);
439     RemovePrunedSegments(OSMSegments,OSMWays);
440     CompactWayList(OSMWays,OSMSegments);
441     RemovePrunedTurnRelations(OSMRelations,OSMNodes);
442 amb 1098
443 amb 1604 IndexSegments(OSMSegments,OSMNodes,OSMWays);
444     }
445 amb 949 }
446    
447 amb 258 /* Repeated iteration on Super-Nodes and Super-Segments */
448 amb 58
449     do
450     {
451 amb 1302 index_t nsuper;
452 amb 650
453 amb 229 printf("\nProcess Super-Data (iteration %d)\n================================%s\n\n",iteration,iteration>9?"=":"");
454 amb 227 fflush(stdout);
455 amb 80
456 amb 90 if(iteration==0)
457     {
458     /* Select the super-nodes */
459 amb 58
460 amb 1314 ChooseSuperNodes(OSMNodes,OSMSegments,OSMWays);
461 amb 58
462 amb 90 /* Select the super-segments */
463 amb 58
464 amb 1314 SuperSegments=CreateSuperSegments(OSMNodes,OSMSegments,OSMWays);
465 amb 650
466 amb 1314 nsuper=OSMSegments->number;
467 amb 90 }
468     else
469     {
470 amb 97 SegmentsX *SuperSegments2;
471 amb 58
472 amb 1605 /* Index the super-segments */
473    
474     IndexSegments(SuperSegments,OSMNodes,OSMWays);
475    
476 amb 90 /* Select the super-nodes */
477    
478 amb 1314 ChooseSuperNodes(OSMNodes,SuperSegments,OSMWays);
479 amb 90
480     /* Select the super-segments */
481    
482 amb 1314 SuperSegments2=CreateSuperSegments(OSMNodes,SuperSegments,OSMWays);
483 amb 90
484 amb 650 nsuper=SuperSegments->number;
485 amb 104
486 amb 1339 FreeSegmentList(SuperSegments);
487 amb 90
488 amb 97 SuperSegments=SuperSegments2;
489 amb 90 }
490    
491 amb 1132 /* Sort the super-segments and remove duplicates */
492 amb 58
493 amb 1314 DeduplicateSuperSegments(SuperSegments,OSMWays);
494 amb 58
495 amb 643 /* Check for end condition */
496    
497 amb 650 if(SuperSegments->number==nsuper)
498     quit=1;
499    
500 amb 89 iteration++;
501 amb 58
502 amb 89 if(iteration>max_iterations)
503     quit=1;
504     }
505     while(!quit);
506 amb 58
507 amb 229 /* Combine the super-segments */
508    
509 amb 1427 printf("\nCombine Segments and Super-Segments\n===================================\n\n");
510 amb 227 fflush(stdout);
511 amb 58
512 amb 104 /* Merge the super-segments */
513    
514 amb 1314 MergedSegments=MergeSuperSegments(OSMSegments,SuperSegments);
515 amb 104
516 amb 1339 FreeSegmentList(OSMSegments);
517 amb 256
518 amb 1339 FreeSegmentList(SuperSegments);
519 amb 58
520 amb 1314 OSMSegments=MergedSegments;
521 amb 90
522 amb 1427 /* Cross reference the nodes and segments */
523 amb 90
524 amb 1427 printf("\nCross-Reference Nodes and Segments\n==================================\n\n");
525     fflush(stdout);
526    
527     /* Sort the nodes and segments geographically */
528    
529     SortNodeListGeographically(OSMNodes);
530    
531     SortSegmentListGeographically(OSMSegments,OSMNodes);
532    
533     /* Re-index the segments */
534    
535 amb 1314 IndexSegments(OSMSegments,OSMNodes,OSMWays);
536 amb 665
537 amb 1108 /* Sort the turn relations geographically */
538 amb 212
539 amb 1784 SortTurnRelationListGeographically(OSMRelations,OSMNodes,OSMSegments,1);
540 amb 551
541 amb 229 /* Output the results */
542    
543     printf("\nWrite Out Database Files\n========================\n\n");
544     fflush(stdout);
545    
546 amb 89 /* Write out the nodes */
547 amb 58
548 amb 1314 SaveNodeList(OSMNodes,FileName(dirname,prefix,"nodes.mem"),OSMSegments);
549 amb 95
550 amb 89 /* Write out the segments */
551 amb 58
552 amb 1314 SaveSegmentList(OSMSegments,FileName(dirname,prefix,"segments.mem"));
553 amb 58
554 amb 89 /* Write out the ways */
555 amb 58
556 amb 1314 SaveWayList(OSMWays,FileName(dirname,prefix,"ways.mem"));
557 amb 58
558 amb 549 /* Write out the relations */
559    
560 amb 1314 SaveRelationList(OSMRelations,FileName(dirname,prefix,"relations.mem"));
561 amb 549
562 amb 1595 /* Free the memory (delete the temporary files) */
563    
564     FreeSegmentList(OSMSegments);
565    
566 amb 1317 /* Close the error log file and process the data */
567 amb 804
568 amb 809 if(errorlog)
569 amb 1317 {
570 amb 809 close_errorlog();
571 amb 804
572 amb 1317 if(option_keep)
573     {
574 amb 1362 ErrorLogsX *OSMErrorLogs;
575    
576 amb 1317 printf("\nCreate Error Log\n================\n\n");
577     fflush(stdout);
578    
579 amb 1362 OSMErrorLogs=NewErrorLogList();
580 amb 1317
581 amb 1362 ProcessErrorLogs(OSMErrorLogs,OSMNodes,OSMWays,OSMRelations);
582 amb 1317
583 amb 1362 SortErrorLogsGeographically(OSMErrorLogs);
584    
585     SaveErrorLogs(OSMErrorLogs,FileName(dirname,prefix,"errorlogs.mem"));
586    
587     FreeErrorLogList(OSMErrorLogs);
588 amb 1317 }
589     }
590    
591 amb 1314 /* Free the memory (delete the temporary files) */
592    
593     FreeNodeList(OSMNodes,0);
594     FreeWayList(OSMWays,0);
595     FreeRelationList(OSMRelations,0);
596    
597 amb 1601 printf("\n");
598     fflush(stdout);
599    
600 amb 1398 printf_program_end();
601 amb 982
602 amb 1599 exit(EXIT_SUCCESS);
603 amb 2 }
604 amb 342
605    
606     /*++++++++++++++++++++++++++++++++++++++
607     Print out the usage information.
608    
609 amb 1797 int detail The level of detail to use: -1 = just version number, 0 = low detail, 1 = full details.
610 amb 490
611     const char *argerr The argument that gave the error (if there is one).
612    
613     const char *err Other error message (if there is one).
614 amb 342 ++++++++++++++++++++++++++++++++++++++*/
615    
616 amb 490 static void print_usage(int detail,const char *argerr,const char *err)
617 amb 342 {
618 amb 1797 if(detail<0)
619     {
620     fprintf(stderr,
621     "Routino version " ROUTINO_VERSION " " ROUTINO_URL ".\n"
622     );
623     }
624    
625     if(detail>=0)
626     {
627     fprintf(stderr,
628     "Usage: planetsplitter [--version]\n"
629     " [--help]\n"
630     " [--dir=<dirname>] [--prefix=<name>]\n"
631 amb 991 #if defined(USE_PTHREADS) && USE_PTHREADS
632 amb 1797 " [--sort-ram-size=<size>] [--sort-threads=<number>]\n"
633 amb 991 #else
634 amb 1797 " [--sort-ram-size=<size>]\n"
635 amb 991 #endif
636 amb 1797 " [--tmpdir=<dirname>]\n"
637     " [--tagging=<filename>]\n"
638     " [--loggable] [--logtime] [--logmemory]\n"
639     " [--errorlog[=<name>]]\n"
640     " [--parse-only | --process-only]\n"
641     " [--append] [--keep] [--changes]\n"
642     " [--max-iterations=<number>]\n"
643     " [--prune-none]\n"
644     " [--prune-isolated=<len>]\n"
645     " [--prune-short=<len>]\n"
646     " [--prune-straight=<len>]\n"
647     " [<filename.osm> ... | <filename.osc> ...\n"
648     " | <filename.pbf> ...\n"
649     " | <filename.o5m> ... | <filename.o5c> ..."
650 amb 1197 #if defined(USE_BZIP2) && USE_BZIP2
651 amb 1797 "\n | <filename.(osm|osc|o5m|o5c).bz2> ..."
652 amb 1197 #endif
653     #if defined(USE_GZIP) && USE_GZIP
654 amb 1797 "\n | <filename.(osm|osc|o5m|o5c).gz> ..."
655 amb 1197 #endif
656 amb 1514 #if defined(USE_XZ) && USE_XZ
657 amb 1797 "\n | <filename.(osm|osc|o5m|o5c).xz> ..."
658 amb 1514 #endif
659 amb 1797 "]\n");
660 amb 342
661 amb 1797 if(argerr)
662     fprintf(stderr,
663     "\n"
664     "Error with command line parameter: %s\n",argerr);
665 amb 490
666 amb 1797 if(err)
667     fprintf(stderr,
668     "\n"
669     "Error: %s\n",err);
670     }
671 amb 490
672 amb 1797 if(detail==1)
673 amb 342 fprintf(stderr,
674     "\n"
675 amb 1797 "--version Print the version of Routino.\n"
676     "\n"
677 amb 342 "--help Prints this information.\n"
678     "\n"
679     "--dir=<dirname> The directory containing the routing database.\n"
680     "--prefix=<name> The filename prefix for the routing database.\n"
681     "\n"
682 amb 358 "--sort-ram-size=<size> The amount of RAM (in MB) to use for data sorting\n"
683 amb 452 #if SLIM
684     " (defaults to 64MB otherwise.)\n"
685     #else
686     " (defaults to 256MB otherwise.)\n"
687     #endif
688 amb 991 #if defined(USE_PTHREADS) && USE_PTHREADS
689     "--sort-threads=<number> The number of threads to use for data sorting.\n"
690     #endif
691     "\n"
692 amb 342 "--tmpdir=<dirname> The directory name for temporary files.\n"
693 amb 358 " (defaults to the '--dir' option directory.)\n"
694 amb 342 "\n"
695 amb 953 "--tagging=<filename> The name of the XML file containing the tagging rules\n"
696     " (defaults to 'tagging.xml' with '--dir' and\n"
697     " '--prefix' options or the file installed in\n"
698 amb 1680 " '" ROUTINO_DATADIR "').\n"
699 amb 342 "\n"
700 amb 519 "--loggable Print progress messages suitable for logging to file.\n"
701 amb 982 "--logtime Print the elapsed time for each processing step.\n"
702 amb 1598 "--logmemory Print the max allocated/mapped memory for each step.\n"
703 amb 810 "--errorlog[=<name>] Log parsing errors to 'error.log' or the given name\n"
704 amb 804 " (the '--dir' and '--prefix' options are applied).\n"
705 amb 519 "\n"
706 amb 1140 "--parse-only Parse the OSM/OSC file(s) and store the results.\n"
707 amb 953 "--process-only Process the stored results from previous option.\n"
708 amb 1120 "--append Parse the OSM file(s) and append to existing results.\n"
709 amb 1167 "--keep Keep the intermediate files after parsing & sorting.\n"
710 amb 1140 "--changes Parse the data as an OSC file and apply the changes.\n"
711 amb 953 "\n"
712 amb 861 "--max-iterations=<number> The number of iterations for finding super-nodes\n"
713     " (defaults to 5).\n"
714 amb 342 "\n"
715 amb 975 "--prune-none Disable the prune options below, they are re-enabled\n"
716     " by adding them to the command line after this option.\n"
717 amb 1117 "--prune-isolated=<len> Remove access from small disconnected segment groups\n"
718 amb 975 " (defaults to removing groups under 500m).\n"
719     "--prune-short=<len> Remove short segments (defaults to removing segments\n"
720     " up to a maximum length of 5m).\n"
721     "--prune-straight=<len> Remove nodes in almost straight highways (defaults to\n"
722     " removing nodes up to 3m offset from a straight line).\n"
723 amb 395 "\n"
724 amb 1227 "<filename.osm>, <filename.osc>, <filename.pbf>, <filename.o5m>, <filename.o5c>\n"
725 amb 1224 " The name(s) of the file(s) to read and parse.\n"
726 amb 1227 " Filenames ending '.pbf' read as PBF, filenames ending\n"
727     " '.o5m' or '.o5c' read as O5M/O5C, others as XML.\n"
728 amb 1197 #if defined(USE_BZIP2) && USE_BZIP2
729     " Filenames ending '.bz2' will be bzip2 uncompressed.\n"
730     #endif
731     #if defined(USE_GZIP) && USE_GZIP
732     " Filenames ending '.gz' will be gzip uncompressed.\n"
733     #endif
734 amb 1514 #if defined(USE_XZ) && USE_XZ
735     " Filenames ending '.xz' will be xz uncompressed.\n"
736     #endif
737 amb 342 "\n"
738     "<transport> defaults to all but can be set to:\n"
739     "%s"
740     "\n"
741     "<highway> can be selected from:\n"
742     "%s"
743     "\n"
744     "<property> can be selected from:\n"
745     "%s",
746     TransportList(),HighwayList(),PropertyList());
747    
748     exit(!detail);
749     }

Properties

Name Value
cvs:description Planet file splitter.