Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/planetsplitter.c
Parent Directory
|
Revision Log
Revision 1157 -
(hide annotations)
(download)
(as text)
Mon Nov 19 18:30:35 2012 UTC (12 years, 4 months ago) by amb
File MIME type: text/x-csrc
File size: 19115 byte(s)
Mon Nov 19 18:30:35 2012 UTC (12 years, 4 months ago) by amb
File MIME type: text/x-csrc
File size: 19115 byte(s)
Do not require that --preserve must be used with --parse-only before changes can be applied (reverses r1151 for the change to functionality but preserves the changes to the functions that enable it).
1 | amb | 2 | /*************************************** |
2 | OSM planet file splitter. | ||
3 | amb | 151 | |
4 | Part of the Routino routing software. | ||
5 | amb | 2 | ******************/ /****************** |
6 | amb | 949 | This file Copyright 2008-2012 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 | 982 | #include <sys/time.h> |
28 | amb | 2 | |
29 | amb | 449 | #include "types.h" |
30 | #include "ways.h" | ||
31 | |||
32 | amb | 199 | #include "typesx.h" |
33 | amb | 109 | #include "nodesx.h" |
34 | #include "segmentsx.h" | ||
35 | #include "waysx.h" | ||
36 | amb | 498 | #include "relationsx.h" |
37 | amb | 109 | #include "superx.h" |
38 | amb | 949 | #include "prunex.h" |
39 | amb | 449 | |
40 | #include "files.h" | ||
41 | amb | 519 | #include "logging.h" |
42 | amb | 449 | #include "functions.h" |
43 | amb | 940 | #include "osmparser.h" |
44 | amb | 395 | #include "tagging.h" |
45 | amb | 2 | |
46 | |||
47 | amb | 395 | /* Global variables */ |
48 | amb | 284 | |
49 | amb | 256 | /*+ The name of the temporary directory. +*/ |
50 | amb | 284 | char *option_tmpdirname=NULL; |
51 | amb | 249 | |
52 | amb | 358 | /*+ The amount of RAM to use for filesorting. +*/ |
53 | size_t option_filesort_ramsize=0; | ||
54 | amb | 284 | |
55 | amb | 991 | /*+ The number of threads to use for filesorting. +*/ |
56 | int option_filesort_threads=1; | ||
57 | amb | 358 | |
58 | amb | 1146 | /*+ The option to apply changes (needed to suppress some error log messages) +*/ |
59 | int option_changes=0; | ||
60 | amb | 991 | |
61 | amb | 1146 | |
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 | 982 | struct timeval start_time; |
74 | amb | 498 | NodesX *Nodes; |
75 | SegmentsX *Segments,*SuperSegments=NULL,*MergedSegments=NULL; | ||
76 | WaysX *Ways; | ||
77 | RelationsX *Relations; | ||
78 | int iteration=0,quit=0; | ||
79 | amb | 861 | int max_iterations=5; |
80 | amb | 804 | char *dirname=NULL,*prefix=NULL,*tagging=NULL,*errorlog=NULL; |
81 | amb | 1140 | int option_parse_only=0,option_process_only=0; |
82 | amb | 1146 | int option_append=0,option_preserve=0; |
83 | amb | 498 | int option_filenames=0; |
84 | amb | 975 | int option_prune_isolated=500,option_prune_short=5,option_prune_straight=3; |
85 | amb | 498 | int arg; |
86 | amb | 26 | |
87 | amb | 982 | gettimeofday(&start_time,NULL); |
88 | |||
89 | amb | 82 | /* Parse the command line arguments */ |
90 | |||
91 | amb | 327 | for(arg=1;arg<argc;arg++) |
92 | amb | 60 | { |
93 | amb | 327 | if(!strcmp(argv[arg],"--help")) |
94 | amb | 490 | print_usage(1,NULL,NULL); |
95 | amb | 358 | else if(!strncmp(argv[arg],"--sort-ram-size=",16)) |
96 | option_filesort_ramsize=atoi(&argv[arg][16]); | ||
97 | amb | 991 | #if defined(USE_PTHREADS) && USE_PTHREADS |
98 | else if(!strncmp(argv[arg],"--sort-threads=",15)) | ||
99 | option_filesort_threads=atoi(&argv[arg][15]); | ||
100 | #endif | ||
101 | amb | 327 | else if(!strncmp(argv[arg],"--dir=",6)) |
102 | dirname=&argv[arg][6]; | ||
103 | else if(!strncmp(argv[arg],"--tmpdir=",9)) | ||
104 | option_tmpdirname=&argv[arg][9]; | ||
105 | else if(!strncmp(argv[arg],"--prefix=",9)) | ||
106 | prefix=&argv[arg][9]; | ||
107 | else if(!strcmp(argv[arg],"--parse-only")) | ||
108 | amb | 326 | option_parse_only=1; |
109 | amb | 327 | else if(!strcmp(argv[arg],"--process-only")) |
110 | amb | 326 | option_process_only=1; |
111 | amb | 1120 | else if(!strcmp(argv[arg],"--append")) |
112 | option_append=1; | ||
113 | amb | 1136 | else if(!strcmp(argv[arg],"--preserve")) |
114 | option_preserve=1; | ||
115 | amb | 1140 | else if(!strcmp(argv[arg],"--changes")) |
116 | option_changes=1; | ||
117 | amb | 519 | else if(!strcmp(argv[arg],"--loggable")) |
118 | option_loggable=1; | ||
119 | amb | 982 | else if(!strcmp(argv[arg],"--logtime")) |
120 | option_logtime=1; | ||
121 | amb | 810 | else if(!strcmp(argv[arg],"--errorlog")) |
122 | errorlog="error.log"; | ||
123 | amb | 804 | else if(!strncmp(argv[arg],"--errorlog=",11)) |
124 | errorlog=&argv[arg][11]; | ||
125 | amb | 327 | else if(!strncmp(argv[arg],"--max-iterations=",17)) |
126 | max_iterations=atoi(&argv[arg][17]); | ||
127 | amb | 395 | else if(!strncmp(argv[arg],"--tagging=",10)) |
128 | tagging=&argv[arg][10]; | ||
129 | amb | 953 | else if(!strncmp(argv[arg],"--prune",7)) |
130 | { | ||
131 | amb | 975 | if(!strcmp(&argv[arg][7],"-none")) |
132 | option_prune_isolated=option_prune_short=option_prune_straight=0; | ||
133 | amb | 953 | else if(!strncmp(&argv[arg][7],"-isolated=",10)) |
134 | amb | 975 | option_prune_isolated=atoi(&argv[arg][17]); |
135 | amb | 964 | else if(!strncmp(&argv[arg][7],"-short=",7)) |
136 | amb | 975 | option_prune_short=atoi(&argv[arg][14]); |
137 | amb | 966 | else if(!strncmp(&argv[arg][7],"-straight=",10)) |
138 | amb | 975 | option_prune_straight=atoi(&argv[arg][17]); |
139 | amb | 953 | else |
140 | print_usage(0,argv[arg],NULL); | ||
141 | } | ||
142 | amb | 327 | else if(argv[arg][0]=='-' && argv[arg][1]=='-') |
143 | amb | 490 | print_usage(0,argv[arg],NULL); |
144 | amb | 327 | else |
145 | option_filenames++; | ||
146 | amb | 60 | } |
147 | amb | 26 | |
148 | amb | 395 | /* Check the specified command line options */ |
149 | |||
150 | amb | 326 | if(option_parse_only && option_process_only) |
151 | amb | 490 | print_usage(0,NULL,"Cannot use '--parse-only' and '--process-only' at the same time."); |
152 | amb | 326 | |
153 | amb | 1120 | if(option_append && option_process_only) |
154 | print_usage(0,NULL,"Cannot use '--append' and '--process-only' at the same time."); | ||
155 | |||
156 | amb | 327 | if(option_filenames && option_process_only) |
157 | amb | 490 | print_usage(0,NULL,"Cannot use '--process-only' and filenames at the same time."); |
158 | amb | 327 | |
159 | amb | 358 | if(!option_filesort_ramsize) |
160 | { | ||
161 | amb | 452 | #if SLIM |
162 | amb | 940 | option_filesort_ramsize=64*1024*1024; |
163 | amb | 452 | #else |
164 | amb | 940 | option_filesort_ramsize=256*1024*1024; |
165 | amb | 452 | #endif |
166 | amb | 358 | } |
167 | else | ||
168 | option_filesort_ramsize*=1024*1024; | ||
169 | |||
170 | amb | 284 | if(!option_tmpdirname) |
171 | amb | 252 | { |
172 | if(!dirname) | ||
173 | amb | 284 | option_tmpdirname="."; |
174 | amb | 252 | else |
175 | amb | 284 | option_tmpdirname=dirname; |
176 | amb | 252 | } |
177 | |||
178 | amb | 989 | if(!option_process_only) |
179 | amb | 395 | { |
180 | amb | 989 | if(tagging) |
181 | amb | 481 | { |
182 | amb | 989 | if(!ExistsFile(tagging)) |
183 | { | ||
184 | fprintf(stderr,"Error: The '--tagging' option specifies a file that does not exist.\n"); | ||
185 | return(1); | ||
186 | } | ||
187 | amb | 481 | } |
188 | else | ||
189 | { | ||
190 | amb | 989 | if(ExistsFile(FileName(dirname,prefix,"tagging.xml"))) |
191 | tagging=FileName(dirname,prefix,"tagging.xml"); | ||
192 | else if(ExistsFile(FileName(DATADIR,NULL,"tagging.xml"))) | ||
193 | tagging=FileName(DATADIR,NULL,"tagging.xml"); | ||
194 | else | ||
195 | { | ||
196 | fprintf(stderr,"Error: The '--tagging' option was not used and the default 'tagging.xml' does not exist.\n"); | ||
197 | return(1); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | if(ParseXMLTaggingRules(tagging)) | ||
202 | { | ||
203 | fprintf(stderr,"Error: Cannot read the tagging rules in the file '%s'.\n",tagging); | ||
204 | amb | 481 | return(1); |
205 | } | ||
206 | } | ||
207 | amb | 395 | |
208 | amb | 498 | /* Create new node, segment, way and relation variables */ |
209 | amb | 82 | |
210 | amb | 1140 | Nodes=NewNodeList(option_append||option_changes,option_process_only); |
211 | amb | 275 | |
212 | amb | 1140 | Segments=NewSegmentList(option_append||option_changes,option_process_only); |
213 | amb | 275 | |
214 | amb | 1145 | Ways=NewWayList(option_append||option_changes,option_process_only,option_changes); |
215 | amb | 26 | |
216 | amb | 1140 | Relations=NewRelationList(option_append||option_changes,option_process_only); |
217 | amb | 498 | |
218 | amb | 804 | /* Create the error log file */ |
219 | |||
220 | amb | 809 | if(errorlog) |
221 | amb | 1140 | open_errorlog(FileName(dirname,prefix,errorlog),option_append||option_changes||option_process_only); |
222 | amb | 804 | |
223 | amb | 89 | /* Parse the file */ |
224 | amb | 2 | |
225 | amb | 989 | if(!option_process_only) |
226 | { | ||
227 | if(option_filenames) | ||
228 | { | ||
229 | for(arg=1;arg<argc;arg++) | ||
230 | { | ||
231 | FILE *file; | ||
232 | amb | 327 | |
233 | amb | 989 | if(argv[arg][0]=='-' && argv[arg][1]=='-') |
234 | continue; | ||
235 | amb | 327 | |
236 | amb | 989 | file=fopen(argv[arg],"rb"); |
237 | amb | 327 | |
238 | amb | 989 | if(!file) |
239 | { | ||
240 | fprintf(stderr,"Cannot open file '%s' for reading [%s].\n",argv[arg],strerror(errno)); | ||
241 | exit(EXIT_FAILURE); | ||
242 | } | ||
243 | amb | 327 | |
244 | amb | 1140 | if(option_changes) |
245 | { | ||
246 | printf("\nParse OSC Data [%s]\n==============\n\n",argv[arg]); | ||
247 | fflush(stdout); | ||
248 | amb | 327 | |
249 | amb | 1140 | if(ParseOSC(file,Nodes,Segments,Ways,Relations)) |
250 | exit(EXIT_FAILURE); | ||
251 | } | ||
252 | else | ||
253 | { | ||
254 | printf("\nParse OSM Data [%s]\n==============\n\n",argv[arg]); | ||
255 | fflush(stdout); | ||
256 | amb | 327 | |
257 | amb | 1140 | if(ParseOSM(file,Nodes,Segments,Ways,Relations)) |
258 | exit(EXIT_FAILURE); | ||
259 | } | ||
260 | |||
261 | amb | 989 | fclose(file); |
262 | } | ||
263 | } | ||
264 | else | ||
265 | { | ||
266 | amb | 1140 | if(option_changes) |
267 | { | ||
268 | printf("\nParse OSC Data\n==============\n\n"); | ||
269 | fflush(stdout); | ||
270 | amb | 2 | |
271 | amb | 1140 | if(ParseOSC(stdin,Nodes,Segments,Ways,Relations)) |
272 | exit(EXIT_FAILURE); | ||
273 | } | ||
274 | else | ||
275 | { | ||
276 | printf("\nParse OSM Data\n==============\n\n"); | ||
277 | fflush(stdout); | ||
278 | |||
279 | if(ParseOSM(stdin,Nodes,Segments,Ways,Relations)) | ||
280 | exit(EXIT_FAILURE); | ||
281 | } | ||
282 | amb | 989 | } |
283 | amb | 80 | |
284 | amb | 989 | DeleteXMLTaggingRules(); |
285 | } | ||
286 | |||
287 | amb | 1151 | FinishNodeList(Nodes); |
288 | FinishSegmentList(Segments); | ||
289 | FinishWayList(Ways); | ||
290 | FinishRelationList(Relations); | ||
291 | amb | 1139 | |
292 | amb | 1157 | if(option_parse_only) |
293 | amb | 326 | { |
294 | amb | 1151 | FreeNodeList(Nodes,1); |
295 | FreeSegmentList(Segments,1); | ||
296 | FreeWayList(Ways,1); | ||
297 | FreeRelationList(Relations,1); | ||
298 | amb | 326 | |
299 | return(0); | ||
300 | } | ||
301 | |||
302 | amb | 1120 | |
303 | amb | 1151 | /* Sort the data */ |
304 | amb | 229 | |
305 | amb | 1151 | printf("\nSort OSM Data\n=============\n\n"); |
306 | amb | 227 | fflush(stdout); |
307 | amb | 8 | |
308 | amb | 498 | /* Sort the nodes, segments, ways and relations */ |
309 | amb | 263 | |
310 | SortNodeList(Nodes); | ||
311 | |||
312 | amb | 1140 | if(option_changes) |
313 | ApplySegmentChanges(Segments); | ||
314 | |||
315 | amb | 1100 | SortSegmentList(Segments); |
316 | amb | 80 | |
317 | amb | 256 | SortWayList(Ways); |
318 | amb | 87 | |
319 | amb | 559 | SortRelationList(Relations); |
320 | |||
321 | amb | 1151 | /* Process the data */ |
322 | |||
323 | printf("\nProcess OSM Data\n================\n\n"); | ||
324 | fflush(stdout); | ||
325 | |||
326 | amb | 1140 | /* Extract the way names (must be before using the ways) */ |
327 | amb | 498 | |
328 | amb | 1140 | ExtractWayNames(Ways,option_preserve||option_changes); |
329 | amb | 549 | |
330 | amb | 1140 | /* Remove bad segments (must be after sorting the nodes, segments and ways) */ |
331 | amb | 549 | |
332 | amb | 1140 | RemoveBadSegments(Segments,Nodes,Ways,option_preserve||option_changes); |
333 | amb | 549 | |
334 | amb | 1140 | /* Remove non-highway nodes (must be after removing the bad segments) */ |
335 | amb | 1130 | |
336 | amb | 1140 | RemoveNonHighwayNodes(Nodes,Segments,option_preserve||option_changes); |
337 | amb | 1130 | |
338 | amb | 680 | /* Process the route relations and first part of turn relations (must be before compacting the ways) */ |
339 | amb | 498 | |
340 | amb | 1140 | ProcessRouteRelations(Relations,Ways,option_preserve||option_changes); |
341 | amb | 498 | |
342 | amb | 1140 | ProcessTurnRelations1(Relations,Nodes,Ways,option_preserve||option_changes); |
343 | amb | 498 | |
344 | amb | 279 | /* Measure the segments and replace node/way id with index (must be after removing non-highway nodes) */ |
345 | amb | 247 | |
346 | amb | 644 | MeasureSegments(Segments,Nodes,Ways); |
347 | amb | 66 | |
348 | amb | 643 | /* Index the segments */ |
349 | amb | 66 | |
350 | amb | 1100 | IndexSegments(Segments,Nodes,Ways); |
351 | amb | 643 | |
352 | amb | 645 | /* Convert the turn relations from ways into nodes */ |
353 | amb | 643 | |
354 | amb | 645 | ProcessTurnRelations2(Relations,Nodes,Segments,Ways); |
355 | |||
356 | amb | 1100 | /* Compact the ways (must be after turn relations 2) */ |
357 | |||
358 | CompactWayList(Ways,Segments); | ||
359 | |||
360 | /* Index the segments */ | ||
361 | |||
362 | IndexSegments(Segments,Nodes,Ways); | ||
363 | |||
364 | amb | 949 | /* Prune unwanted nodes/segments. */ |
365 | amb | 645 | |
366 | amb | 975 | if(option_prune_straight || option_prune_isolated || option_prune_short) |
367 | amb | 949 | { |
368 | amb | 1098 | printf("\nPrune Unneeded Data\n===================\n\n"); |
369 | fflush(stdout); | ||
370 | |||
371 | amb | 949 | StartPruning(Nodes,Segments,Ways); |
372 | |||
373 | amb | 975 | if(option_prune_straight) |
374 | PruneStraightHighwayNodes(Nodes,Segments,Ways,option_prune_straight); | ||
375 | amb | 974 | |
376 | amb | 975 | if(option_prune_isolated) |
377 | PruneIsolatedRegions(Nodes,Segments,Ways,option_prune_isolated); | ||
378 | amb | 953 | |
379 | amb | 975 | if(option_prune_short) |
380 | PruneShortSegments(Nodes,Segments,Ways,option_prune_short); | ||
381 | amb | 964 | |
382 | amb | 949 | FinishPruning(Nodes,Segments,Ways); |
383 | amb | 1098 | |
384 | /* Remove the pruned nodes and segments and update the indexes */ | ||
385 | |||
386 | RemovePrunedNodes(Nodes,Segments); | ||
387 | amb | 1100 | RemovePrunedSegments(Segments,Ways); |
388 | CompactWayList(Ways,Segments); | ||
389 | amb | 1098 | RemovePrunedTurnRelations(Relations,Nodes); |
390 | amb | 1100 | IndexSegments(Segments,Nodes,Ways); |
391 | amb | 949 | } |
392 | |||
393 | amb | 258 | /* Repeated iteration on Super-Nodes and Super-Segments */ |
394 | amb | 58 | |
395 | do | ||
396 | { | ||
397 | amb | 650 | int nsuper; |
398 | |||
399 | amb | 229 | printf("\nProcess Super-Data (iteration %d)\n================================%s\n\n",iteration,iteration>9?"=":""); |
400 | amb | 227 | fflush(stdout); |
401 | amb | 80 | |
402 | amb | 90 | if(iteration==0) |
403 | { | ||
404 | /* Select the super-nodes */ | ||
405 | amb | 58 | |
406 | amb | 653 | ChooseSuperNodes(Nodes,Segments,Ways); |
407 | amb | 58 | |
408 | amb | 90 | /* Select the super-segments */ |
409 | amb | 58 | |
410 | amb | 653 | SuperSegments=CreateSuperSegments(Nodes,Segments,Ways); |
411 | amb | 650 | |
412 | nsuper=Segments->number; | ||
413 | amb | 90 | } |
414 | else | ||
415 | { | ||
416 | amb | 97 | SegmentsX *SuperSegments2; |
417 | amb | 58 | |
418 | amb | 90 | /* Select the super-nodes */ |
419 | |||
420 | amb | 653 | ChooseSuperNodes(Nodes,SuperSegments,Ways); |
421 | amb | 90 | |
422 | /* Select the super-segments */ | ||
423 | |||
424 | amb | 653 | SuperSegments2=CreateSuperSegments(Nodes,SuperSegments,Ways); |
425 | amb | 90 | |
426 | amb | 650 | nsuper=SuperSegments->number; |
427 | amb | 104 | |
428 | amb | 1151 | FreeSegmentList(SuperSegments,0); |
429 | amb | 90 | |
430 | amb | 97 | SuperSegments=SuperSegments2; |
431 | amb | 90 | } |
432 | |||
433 | amb | 1132 | /* Sort the super-segments and remove duplicates */ |
434 | amb | 58 | |
435 | amb | 1132 | DeduplicateSuperSegments(SuperSegments,Ways); |
436 | amb | 58 | |
437 | amb | 643 | /* Index the segments */ |
438 | |||
439 | amb | 1100 | IndexSegments(SuperSegments,Nodes,Ways); |
440 | amb | 643 | |
441 | /* Check for end condition */ | ||
442 | |||
443 | amb | 650 | if(SuperSegments->number==nsuper) |
444 | quit=1; | ||
445 | |||
446 | amb | 89 | iteration++; |
447 | amb | 58 | |
448 | amb | 89 | if(iteration>max_iterations) |
449 | quit=1; | ||
450 | } | ||
451 | while(!quit); | ||
452 | amb | 58 | |
453 | amb | 229 | /* Combine the super-segments */ |
454 | |||
455 | printf("\nCombine Segments and Super-Segments\n===================================\n\n"); | ||
456 | amb | 227 | fflush(stdout); |
457 | amb | 58 | |
458 | amb | 104 | /* Merge the super-segments */ |
459 | |||
460 | amb | 256 | MergedSegments=MergeSuperSegments(Segments,SuperSegments); |
461 | amb | 104 | |
462 | amb | 1151 | FreeSegmentList(Segments,0); |
463 | amb | 256 | |
464 | amb | 1151 | FreeSegmentList(SuperSegments,0); |
465 | amb | 58 | |
466 | amb | 256 | Segments=MergedSegments; |
467 | amb | 90 | |
468 | amb | 1133 | /* Re-index the merged segments */ |
469 | amb | 258 | |
470 | amb | 1100 | IndexSegments(Segments,Nodes,Ways); |
471 | amb | 275 | |
472 | amb | 229 | /* Cross reference the nodes and segments */ |
473 | amb | 90 | |
474 | amb | 229 | printf("\nCross-Reference Nodes and Segments\n==================================\n\n"); |
475 | fflush(stdout); | ||
476 | amb | 90 | |
477 | amb | 1107 | /* Sort the nodes and segments geographically */ |
478 | amb | 645 | |
479 | amb | 665 | SortNodeListGeographically(Nodes); |
480 | amb | 645 | |
481 | amb | 1107 | SortSegmentListGeographically(Segments,Nodes); |
482 | amb | 209 | |
483 | amb | 1107 | /* Re-index the segments */ |
484 | amb | 212 | |
485 | amb | 1100 | IndexSegments(Segments,Nodes,Ways); |
486 | amb | 665 | |
487 | amb | 1108 | /* Sort the turn relations geographically */ |
488 | amb | 212 | |
489 | amb | 1108 | SortTurnRelationListGeographically(Relations,Nodes,Segments); |
490 | amb | 551 | |
491 | amb | 229 | /* Output the results */ |
492 | |||
493 | printf("\nWrite Out Database Files\n========================\n\n"); | ||
494 | fflush(stdout); | ||
495 | |||
496 | amb | 89 | /* Write out the nodes */ |
497 | amb | 58 | |
498 | amb | 1109 | SaveNodeList(Nodes,FileName(dirname,prefix,"nodes.mem"),Segments); |
499 | amb | 95 | |
500 | amb | 1151 | FreeNodeList(Nodes,0); |
501 | amb | 226 | |
502 | amb | 89 | /* Write out the segments */ |
503 | amb | 58 | |
504 | amb | 256 | SaveSegmentList(Segments,FileName(dirname,prefix,"segments.mem")); |
505 | amb | 58 | |
506 | amb | 1151 | FreeSegmentList(Segments,0); |
507 | amb | 226 | |
508 | amb | 89 | /* Write out the ways */ |
509 | amb | 58 | |
510 | amb | 398 | SaveWayList(Ways,FileName(dirname,prefix,"ways.mem")); |
511 | amb | 58 | |
512 | amb | 1151 | FreeWayList(Ways,0); |
513 | amb | 226 | |
514 | amb | 549 | /* Write out the relations */ |
515 | |||
516 | SaveRelationList(Relations,FileName(dirname,prefix,"relations.mem")); | ||
517 | |||
518 | amb | 1151 | FreeRelationList(Relations,0); |
519 | amb | 549 | |
520 | amb | 804 | /* Close the error log file */ |
521 | |||
522 | amb | 809 | if(errorlog) |
523 | close_errorlog(); | ||
524 | amb | 804 | |
525 | amb | 982 | /* Print the total time */ |
526 | |||
527 | if(option_logtime) | ||
528 | { | ||
529 | printf("\n"); | ||
530 | fprintf_elapsed_time(stdout,&start_time); | ||
531 | printf("Complete\n"); | ||
532 | fflush(stdout); | ||
533 | } | ||
534 | |||
535 | amb | 2 | return(0); |
536 | } | ||
537 | amb | 342 | |
538 | |||
539 | /*++++++++++++++++++++++++++++++++++++++ | ||
540 | Print out the usage information. | ||
541 | |||
542 | int detail The level of detail to use - 0 = low, 1 = high. | ||
543 | amb | 490 | |
544 | const char *argerr The argument that gave the error (if there is one). | ||
545 | |||
546 | const char *err Other error message (if there is one). | ||
547 | amb | 342 | ++++++++++++++++++++++++++++++++++++++*/ |
548 | |||
549 | amb | 490 | static void print_usage(int detail,const char *argerr,const char *err) |
550 | amb | 342 | { |
551 | fprintf(stderr, | ||
552 | "Usage: planetsplitter [--help]\n" | ||
553 | " [--dir=<dirname>] [--prefix=<name>]\n" | ||
554 | amb | 991 | #if defined(USE_PTHREADS) && USE_PTHREADS |
555 | " [--sort-ram-size=<size>] [--sort-threads=<number>]\n" | ||
556 | #else | ||
557 | amb | 452 | " [--sort-ram-size=<size>]\n" |
558 | amb | 991 | #endif |
559 | amb | 358 | " [--tmpdir=<dirname>]\n" |
560 | amb | 953 | " [--tagging=<filename>]\n" |
561 | amb | 982 | " [--loggable] [--logtime]\n" |
562 | " [--errorlog[=<name>]]\n" | ||
563 | amb | 342 | " [--parse-only | --process-only]\n" |
564 | amb | 1140 | " [--append] [--preserve] [--changes]\n" |
565 | amb | 342 | " [--max-iterations=<number>]\n" |
566 | amb | 975 | " [--prune-none]\n" |
567 | " [--prune-isolated=<len>]\n" | ||
568 | " [--prune-short=<len>]\n" | ||
569 | " [--prune-straight=<len>]\n" | ||
570 | amb | 342 | " [<filename.osm> ...]\n"); |
571 | |||
572 | amb | 490 | if(argerr) |
573 | fprintf(stderr, | ||
574 | "\n" | ||
575 | "Error with command line parameter: %s\n",argerr); | ||
576 | |||
577 | amb | 491 | if(err) |
578 | amb | 490 | fprintf(stderr, |
579 | "\n" | ||
580 | "Error: %s\n",err); | ||
581 | |||
582 | amb | 342 | if(detail) |
583 | fprintf(stderr, | ||
584 | "\n" | ||
585 | "--help Prints this information.\n" | ||
586 | "\n" | ||
587 | "--dir=<dirname> The directory containing the routing database.\n" | ||
588 | "--prefix=<name> The filename prefix for the routing database.\n" | ||
589 | "\n" | ||
590 | amb | 358 | "--sort-ram-size=<size> The amount of RAM (in MB) to use for data sorting\n" |
591 | amb | 452 | #if SLIM |
592 | " (defaults to 64MB otherwise.)\n" | ||
593 | #else | ||
594 | " (defaults to 256MB otherwise.)\n" | ||
595 | #endif | ||
596 | amb | 991 | #if defined(USE_PTHREADS) && USE_PTHREADS |
597 | "--sort-threads=<number> The number of threads to use for data sorting.\n" | ||
598 | #endif | ||
599 | "\n" | ||
600 | amb | 342 | "--tmpdir=<dirname> The directory name for temporary files.\n" |
601 | amb | 358 | " (defaults to the '--dir' option directory.)\n" |
602 | amb | 342 | "\n" |
603 | amb | 953 | "--tagging=<filename> The name of the XML file containing the tagging rules\n" |
604 | " (defaults to 'tagging.xml' with '--dir' and\n" | ||
605 | " '--prefix' options or the file installed in\n" | ||
606 | " '" DATADIR "').\n" | ||
607 | amb | 342 | "\n" |
608 | amb | 519 | "--loggable Print progress messages suitable for logging to file.\n" |
609 | amb | 982 | "--logtime Print the elapsed time for each processing step.\n" |
610 | amb | 810 | "--errorlog[=<name>] Log parsing errors to 'error.log' or the given name\n" |
611 | amb | 804 | " (the '--dir' and '--prefix' options are applied).\n" |
612 | amb | 519 | "\n" |
613 | amb | 1140 | "--parse-only Parse the OSM/OSC file(s) and store the results.\n" |
614 | amb | 953 | "--process-only Process the stored results from previous option.\n" |
615 | amb | 1120 | "--append Parse the OSM file(s) and append to existing results.\n" |
616 | amb | 1136 | "--preserve Keep the intermediate files after parsing & sorting.\n" |
617 | amb | 1140 | "--changes Parse the data as an OSC file and apply the changes.\n" |
618 | amb | 953 | "\n" |
619 | amb | 861 | "--max-iterations=<number> The number of iterations for finding super-nodes\n" |
620 | " (defaults to 5).\n" | ||
621 | amb | 342 | "\n" |
622 | amb | 975 | "--prune-none Disable the prune options below, they are re-enabled\n" |
623 | " by adding them to the command line after this option.\n" | ||
624 | amb | 1117 | "--prune-isolated=<len> Remove access from small disconnected segment groups\n" |
625 | amb | 975 | " (defaults to removing groups under 500m).\n" |
626 | "--prune-short=<len> Remove short segments (defaults to removing segments\n" | ||
627 | " up to a maximum length of 5m).\n" | ||
628 | "--prune-straight=<len> Remove nodes in almost straight highways (defaults to\n" | ||
629 | " removing nodes up to 3m offset from a straight line).\n" | ||
630 | amb | 395 | "\n" |
631 | amb | 358 | "<filename.osm> ... The name(s) of the file(s) to process (by default\n" |
632 | " data is read from standard input).\n" | ||
633 | amb | 342 | "\n" |
634 | "<transport> defaults to all but can be set to:\n" | ||
635 | "%s" | ||
636 | "\n" | ||
637 | "<highway> can be selected from:\n" | ||
638 | "%s" | ||
639 | "\n" | ||
640 | "<property> can be selected from:\n" | ||
641 | "%s", | ||
642 | TransportList(),HighwayList(),PropertyList()); | ||
643 | |||
644 | exit(!detail); | ||
645 | } |
Properties
Name | Value |
---|---|
cvs:description | Planet file splitter. |