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